|
@@ -34,6 +34,7 @@ import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.ZoneId;
|
|
|
+import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -112,6 +113,7 @@ public class PolicyOrderLogic {
|
|
|
return byId;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void update(PolicyOrder policyOrder) {
|
|
|
|
|
|
if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
|
|
@@ -150,6 +152,19 @@ public class PolicyOrderLogic {
|
|
|
workerPolicy.setStatus("DSX");
|
|
|
}
|
|
|
workerPolicy.insert();
|
|
|
+
|
|
|
+ if (workerPolicy.getPolicyType().equals("EM")) {
|
|
|
+
|
|
|
+ List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, policyOrder.getWebsitUserId())
|
|
|
+ .eq(WorkerPolicy::getPolicyType, "EM").list();
|
|
|
+
|
|
|
+ Boolean wp = this.hasOverlap(workerPolicyList);
|
|
|
+
|
|
|
+ if (wp)
|
|
|
+ throw new RemoteServiceException(policyOrder.getWorkerIdcard() + "雇主险有相同覆盖范围内的保险");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -238,6 +253,11 @@ public class PolicyOrderLogic {
|
|
|
policyOrder.setBuyUnitId(sysDictCompany.getDictCode());
|
|
|
|
|
|
|
|
|
+ if (policyOrder.getStartTime().after(policyOrder.getEndTime()))
|
|
|
+ throw new RemoteServiceException(policyOrder.getWorkerIdcard()+"开始时间不能大于结束时间");
|
|
|
+
|
|
|
+ if (!this.areInSameMonth(policyOrder.getStartTime(),policyOrder.getEndTime()))
|
|
|
+ throw new RemoteServiceException(policyOrder.getWorkerIdcard()+"工伤险的有效时间必须在同一个月内");
|
|
|
|
|
|
|
|
|
if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
|
|
@@ -293,6 +313,12 @@ public class PolicyOrderLogic {
|
|
|
policyOrderup.setClassWebsitName((String)row.get(12));
|
|
|
policyOrderup.setPayAmount(Convert.toBigDecimal(row.get(8)));
|
|
|
|
|
|
+ if (policyOrderup.getStartTime().after(policyOrderup.getEndTime()))
|
|
|
+ throw new RemoteServiceException(policyOrderup.getWorkerIdcard()+"开始时间不能大于结束时间");
|
|
|
+
|
|
|
+ if (!this.areInSameMonth(policyOrderup.getStartTime(),policyOrderup.getEndTime()))
|
|
|
+ throw new RemoteServiceException(policyOrderup.getWorkerIdcard()+"工伤险的有效时间必须在同一个月内");
|
|
|
+
|
|
|
|
|
|
if (new Date().after(policyOrderup.getStartTime()) && new Date().before(policyOrderup.getEndTime()))
|
|
|
policyOrderup.setPolicyOrderStatus("BZZ");
|
|
@@ -353,10 +379,30 @@ public class PolicyOrderLogic {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, websitUser.getId())
|
|
|
+ .eq(WorkerPolicy::getPolicyType, "IN").list();
|
|
|
+
|
|
|
+ Boolean wp = this.hasOverlap(workerPolicyList);
|
|
|
+
|
|
|
+ if (wp)
|
|
|
+ throw new RemoteServiceException(user.getIdCard()+"工伤险有相同覆盖范围内的保险");
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public boolean areInSameMonth(Date date1, Date date2) {
|
|
|
+ Calendar cal1 = Calendar.getInstance();
|
|
|
+ Calendar cal2 = Calendar.getInstance();
|
|
|
+
|
|
|
+ cal1.setTime(date1);
|
|
|
+ cal2.setTime(date2);
|
|
|
+
|
|
|
+ return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
|
|
|
+ cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void importEm(List<Object> objects) {
|
|
|
|
|
@@ -365,6 +411,9 @@ public class PolicyOrderLogic {
|
|
|
|
|
|
AdminWebsit adminWebsit = adminWebsitService.lambdaQuery().eq(AdminWebsit::getWebsitNumber, (String) row.get(1)).one();
|
|
|
|
|
|
+ if (!adminWebsit.getAttr().equals("SELF"))
|
|
|
+ throw new RemoteServiceException(adminWebsit.getName()+"第三方网点请去师傅管理添加雇主险");
|
|
|
+
|
|
|
User user = userService.lambdaQuery().eq(User::getIdCard, (String) row.get(4))
|
|
|
.one();
|
|
|
|
|
@@ -437,6 +486,9 @@ public class PolicyOrderLogic {
|
|
|
|
|
|
policyOrder.setType("EM");
|
|
|
|
|
|
+ if (policyOrder.getStartTime().after(policyOrder.getEndTime()))
|
|
|
+ throw new RemoteServiceException((String) row.get(4)+"开始时间不能大于结束时间");
|
|
|
+
|
|
|
if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
|
|
|
policyOrder.setPolicyOrderStatus("BZZ");
|
|
|
else if (new Date().after(policyOrder.getEndTime()))
|
|
@@ -448,6 +500,8 @@ public class PolicyOrderLogic {
|
|
|
policyOrder.insert();
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
WorkerPolicy workerPolicy = new WorkerPolicy();
|
|
|
workerPolicy.setWorkerId(websitUser.getWorkerNumber());
|
|
|
workerPolicy.setType("LINE");
|
|
@@ -472,11 +526,34 @@ public class PolicyOrderLogic {
|
|
|
}
|
|
|
workerPolicy.insert();
|
|
|
|
|
|
+ List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, websitUser.getId())
|
|
|
+ .eq(WorkerPolicy::getPolicyType, "EM").list();
|
|
|
+
|
|
|
+ Boolean wp = this.hasOverlap(workerPolicyList);
|
|
|
+
|
|
|
+ if (wp)
|
|
|
+ throw new RemoteServiceException(user.getIdCard()+"雇主险有相同覆盖范围内的保险");
|
|
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Boolean hasOverlap(List<WorkerPolicy> workerPolicies){
|
|
|
|
|
|
+ for (int i= 0; i<workerPolicies.size();i++){
|
|
|
+ WorkerPolicy workerPolicy = workerPolicies.get(i);
|
|
|
+ for (int j = i+1; j <workerPolicies.size() ; j++) {
|
|
|
+ WorkerPolicy workerPolicy2 = workerPolicies.get(j);
|
|
|
+ if (workerPolicy.getEndTime().after(workerPolicy2.getStartTime()) && workerPolicy2.getEndTime().after(workerPolicy.getStartTime())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return false;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|