瀏覽代碼

批量修改费用起止期

Qchen 1 年之前
父節點
當前提交
1c96e7eaa5

+ 1 - 2
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -523,10 +523,9 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         Page<PtlAgreement> agreementPage = page(page, wrapper);
         agreementPage.getRecords().forEach(agreement -> {
             LocalDate startDate = agreement.getStartDate();
-            System.out.println(startDate);
             LocalDate endDate = agreement.getEndDate();
             LocalDate now = LocalDate.now();
-
+            //更新是否有效
             if (now.isEqual(startDate) || (now.isAfter(startDate) && now.isBefore(endDate))) {
                 agreement.setIsValid("1");
             } else {

+ 6 - 0
src/main/java/com/ydtech/modules/protocols/controller/PtlNewAgreementController.java

@@ -151,6 +151,12 @@ public class PtlNewAgreementController extends BaseController {
         return ptlAgreementProductCostsNewService.costsAuditBatch(costsAuditVo) ? HttpResult.ok("费用批量审核成功") : HttpResult.error("费用批量审核失败");
     }
 
+    @ApiOperation(value = "费用批量修改起止期")
+    @PostMapping("/costs/costsDateBatch")
+    public HttpResult costsDateBatch(@RequestBody AgreementProductCostsVo agreementProductCostsVo){
+        return ptlAgreementProductCostsNewService.costsDateBatch(agreementProductCostsVo) ? HttpResult.ok("费用批量修改起止期成功") : HttpResult.error("费用批量修改起止期失败");
+    }
+
     @ApiOperation(value = "费用批量修改")
     @PostMapping("/costs/costsBatch")
     public HttpResult costsBatch(@RequestBody AgreementProductCostsVo agreementProductCostsVo){

+ 8 - 1
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementProductCostsNewService.java

@@ -102,7 +102,14 @@ public interface PtlAgreementProductCostsNewService extends IService<PtlAgreemen
     boolean costsAuditBatch(CostsAuditVo costsAuditVo);
 
     /**
-     * 费用批量更改费用止期
+     * 费用批量更改费用起止期
+     * @param agreementProductCostsVo
+     * @return
+     */
+    boolean costsDateBatch(AgreementProductCostsVo agreementProductCostsVo);
+
+    /**
+     * 费用批量更改费用
      * @param agreementProductCostsVo
      * @return
      */

+ 39 - 6
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementProductCostsNewServiceImpl.java

@@ -1048,6 +1048,45 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
         return true;
     }
 
+    @Override
+    @Transactional
+    public boolean costsDateBatch(AgreementProductCostsVo agreementProductCostsVo) {
+        // 更新每个费用项目的起止期
+        for (String id : agreementProductCostsVo.getIds()) {
+           PtlAgreementProductCostsNew ptlAgreementProductCostsNew = this.getById(id);
+           if (ptlAgreementProductCostsNew == null) {
+               throw new SystemException("费用不存在");
+           }
+           if (agreementProductCostsVo.getCostsEndDate() != null) {
+               ptlAgreementProductCostsNew.setCostsEndDate(agreementProductCostsVo.getCostsEndDate());
+           }
+           if (agreementProductCostsVo.getCostsStartDate() != null) {
+               ptlAgreementProductCostsNew.setCostsStartDate(agreementProductCostsVo.getCostsStartDate());
+           }
+        String desc = "修改费用因子";
+        //添加费用因子轨迹
+        ptlAgreementProductCostsTrajectoryService.addCostsTrajectory(ptlAgreementProductCostsNew.getId(), desc, BaseController.getUser().getId());
+        //保存产品费用历史记录
+        PtlAgreementProductCostsNewHistory ptlAgreementProductCostsNewHistory = new PtlAgreementProductCostsNewHistory();
+        //添加费用ID
+        ptlAgreementProductCostsNewHistory.setId(IdGenerate.nextId());
+        ptlAgreementProductCostsNewHistory.setCostsId(ptlAgreementProductCostsNew.getId());
+        //生成批次ID
+        String uuid = IdGenerate.nextId();
+        ptlAgreementProductCostsNewHistory.setBatch(uuid);
+        ptlAgreementProductCostsNewHistory.setAgreementId(ptlAgreementProductCostsNew.getAgreementId());
+        ptlAgreementProductCostsNewHistory.setProductId(ptlAgreementProductCostsNew.getProductId());
+        ptlAgreementProductCostsNewHistory.setProductName(ptlAgreementProductCostsNew.getProductName());
+        ptlAgreementProductCostsNewHistory.setOperatorType("update");
+        ptlAgreementProductCostsNewHistory.setModifier(BaseController.getUser().getId());
+        ptlAgreementProductCostsNewHistory.setOperatorTime(LocalDateTime.now());
+        ptlAgreementProductCostsNewHistoryService.save(ptlAgreementProductCostsNewHistory);
+        baseMapper.updateById(ptlAgreementProductCostsNew);
+        }
+
+        return true;
+    }
+
     @Override
     @Transactional
     public boolean costsBatch(AgreementProductCostsVo agreementProductCostsVo) {
@@ -1096,12 +1135,6 @@ public class PtlAgreementProductCostsNewServiceImpl extends ServiceImpl<PtlAgree
     }
 
     private void updateCostsItem(AgreementProductCostsVo vo, PtlAgreementProductCostsNew item) {
-        if (vo.getCostsEndDate() != null) {
-            item.setCostsEndDate(vo.getCostsEndDate());
-        }
-        if (vo.getCostsStartDate() != null) {
-            item.setCostsStartDate(vo.getCostsStartDate());
-        }
         updateProportion(item, vo.getJqCostsProportion(), item::getJqCostsProportion, item::setJqCostsProportion, "交强险总费用");
         updateProportion(item, vo.getSyCostsProportion(), item::getSyCostsProportion, item::setSyCostsProportion, "商业险总费用");
         updateProportion(item, vo.getNoCostsProportion(), item::getNoCostsProportion, item::setNoCostsProportion, "非车险总费用");