|
@@ -0,0 +1,111 @@
|
|
|
+package com.jpsoft.picc.scheduled;
|
|
|
+
|
|
|
+
|
|
|
+import com.jpsoft.picc.modules.base.entity.InsuranceDefinition;
|
|
|
+import com.jpsoft.picc.modules.base.service.InsuranceDefinitionService;
|
|
|
+import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
|
+import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
|
|
|
+import com.jpsoft.picc.modules.business.entity.InsurancePolicyMember;
|
|
|
+import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
|
|
|
+import com.jpsoft.picc.modules.business.service.InsurancePolicyService;
|
|
|
+import com.jpsoft.picc.modules.common.constant.PolicyStatus;
|
|
|
+import lombok.extern.apachecommons.CommonsLog;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.Calendar;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Component
|
|
|
+@Configuration
|
|
|
+@EnableScheduling
|
|
|
+@CommonsLog
|
|
|
+public class FissionWantedTask {
|
|
|
+
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsurancePolicyService insurancePolicyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsurancePolicyMemberService insurancePolicyMemberService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InsuranceDefinitionService insuranceDefinitionService;
|
|
|
+
|
|
|
+ @Scheduled(cron="0 0 3 * * ?")
|
|
|
+ public void staticCronTask() {
|
|
|
+ editInsurancePolicy();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void editInsurancePolicy(){
|
|
|
+
|
|
|
+ Calendar cal = Calendar.getInstance();
|
|
|
+
|
|
|
+ //获取当前年份
|
|
|
+ String year = String.valueOf(cal.get(Calendar.YEAR));
|
|
|
+
|
|
|
+ //获取下一月为几月
|
|
|
+ String month = String.valueOf(cal.get(Calendar.MONTH) + 2);
|
|
|
+
|
|
|
+ //获取当前日
|
|
|
+ String day = String.valueOf(cal.get(Calendar.DATE));
|
|
|
+
|
|
|
+ //待初审状态
|
|
|
+ String status = String.valueOf(PolicyStatus.PendingTrial.getValue());
|
|
|
+
|
|
|
+ //待制单状态
|
|
|
+ String status1 = String.valueOf(PolicyStatus.PendingMakePolicy.getValue());
|
|
|
+
|
|
|
+ String nextYearMonth = year + month;
|
|
|
+
|
|
|
+ //获取待调整下月投保单
|
|
|
+ List<InsurancePolicy> insurancePolicyList = insurancePolicyService.toBeAdjustedPolicy(nextYearMonth,status);
|
|
|
+
|
|
|
+ for (InsurancePolicy insurancePolicy :insurancePolicyList) {
|
|
|
+
|
|
|
+ String id = insurancePolicy.getId();
|
|
|
+
|
|
|
+ InsuranceDefinition insuranceDefinition = insuranceDefinitionService.get(insurancePolicy.getDefinitionId());
|
|
|
+
|
|
|
+ //险种截止日期
|
|
|
+ String cutOffTime = insuranceDefinition.getCutOffTime();
|
|
|
+
|
|
|
+ if(cutOffTime.equals(day)){
|
|
|
+ //如果当日为截至日期则修改
|
|
|
+ List<InsurancePolicyMember> insurancePolicyMemberList = insurancePolicyMemberService.findByPolicyId(id);
|
|
|
+
|
|
|
+ boolean isUnChecked = false;
|
|
|
+
|
|
|
+ for (InsurancePolicyMember insurancePolicyMember:insurancePolicyMemberList) {
|
|
|
+ String memberStatus = insurancePolicyMember.getStatus();
|
|
|
+ //花名册人员是否为已复核状态
|
|
|
+ if(!memberStatus.equals("2")){
|
|
|
+ isUnChecked = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isUnChecked){
|
|
|
+ insurancePolicy.setStatus(status);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ insurancePolicy.setStatus(status1);
|
|
|
+ }
|
|
|
+ insurancePolicyService.update(insurancePolicy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info(nextYearMonth + "已完成修改状态");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|