Explorar el Código

处理协议费用有效状态不正确的问题

lixiaolong hace 2 meses
padre
commit
24e7e7aa90

+ 8 - 13
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementUndwrtRulesServiceImpl.java

@@ -24,8 +24,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
-import java.time.ZoneId;
+import java.time.ZoneOffset;
 import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
 /**
@@ -63,7 +64,7 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
     public List<AgreementRulesVo> queryList(String agreementId) {
         log.info("查询协议承保规则列表。 agreementId=[{}]", JSONUtil.toJsonStr(agreementId));
         List<AgreementRulesVo> rulesVos = baseMapper.queryList(agreementId);
-        LocalDateTime now = LocalDateTime.now();
+        AtomicReference<Date> now = new AtomicReference<>(new Date());
         if(CollUtil.isNotEmpty(rulesVos)){
             // 预计算相同parentId下的所有规则ID,用于后续费用汇总查询
             Map<String, List<String>> parentIdToRuleIds = new LinkedHashMap<>();
@@ -98,18 +99,12 @@ public class PtlAgreementUndwrtRulesServiceImpl extends ServiceImpl<PtlAgreement
                 }
                 if (CollUtil.isNotEmpty(allCostVos)) {
                     allCostVos.forEach(cost -> cost.getPtlAgreementCostVoList().forEach(vo -> {
-                        LocalDateTime effectiveTime = vo.getEffectiveTime().toInstant()
-                                .atZone(ZoneId.systemDefault())
-                                .toLocalDateTime();
-                        LocalDateTime failureTime = vo.getFailureTime().toInstant()
-                               .atZone(ZoneId.systemDefault())
-                               .toLocalDateTime();
-                        if(now.isAfter(effectiveTime) && now.isBefore(failureTime)){
-                            vo.setIsValid(0);
-                        }else{
-                            vo.setIsValid(1);
+                        now.set(Date.from(LocalDateTime.now().toInstant(ZoneOffset.UTC)));
+                        if (now.get().after(vo.getEffectiveTime()) && now.get().before(vo.getFailureTime())) {
+                            vo.setIsValid(0);  // 生效中
+                        } else {
+                            vo.setIsValid(1);  // 已失效
                         }
-
                     }));
                     rulesVo.setCostVoList(allCostVos);
                 }