Pārlūkot izejas kodu

维保计划超期保养处理

别傲 5 gadi atpakaļ
vecāks
revīzija
be7953fb20

+ 10 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -24,6 +24,7 @@ import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.utils.MapHelper;
 import cn.com.ty.lift.common.verify.VerifyUtils;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
@@ -160,11 +161,14 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (ObjectUtil.isEmpty(entry)) return false;
         int interval = entry.getPlanInterval();
         List<MaintenancePlan> planList = maintenancePlanService.findPlanList(liftId, projectId, mtCompanyId, currentTime);
-        //获取当前时间后的维保计划列表,并清除计划
-        maintenancePlanService.removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
-        //按照修改时间重新生成计划
-        List<MaintenancePlan> plans = maintenancePlanService.generatePlan(plan, periods, interval, currentTime, endDate);
-        return maintenancePlanService.saveBatch(plans, plans.size());
+        if (CollUtil.isNotEmpty(planList)) {
+            //获取当前时间后的维保计划列表,并清除计划
+            maintenancePlanService.removeByIds(planList.stream().map(MaintenancePlan::getId).collect(Collectors.toList()));
+            //按照修改时间重新生成计划
+            List<MaintenancePlan> plans = maintenancePlanService.generatePlan(plan, periods, interval, currentTime, endDate);
+            return maintenancePlanService.saveBatch(plans, plans.size());
+        }
+        return true;
     }
 
     /**
@@ -210,7 +214,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             record.setWorkerId1(record.getWorkerId1());
             record.setWorkDate(LocalDate.now());
             MaintenancePlan plan = maintenancePlanService.getOne(record.getMtPlanId());
-            if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.add.fail"));
+            if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.maintenance.plan.not.exist"));
             record.setPlanDate(plan.getPlanDate());
             boolean ret = save(record);
             if (!ret) {

+ 1 - 0
lift-business-service/src/main/resources/locale/response.properties

@@ -34,5 +34,6 @@ msg.record.not.exist=\u4FDD\u517B\u5355\u4E0D\u5B58\u5728
 msg.lift.not.exist=\u7535\u68AF\u4E0D\u5B58\u5728
 msg.project.not.exist=\u9879\u76EE\u4E0D\u5B58\u5728
 msg.contract.not.exist=\u5408\u540C\u4E0D\u5B58\u5728
+msg.maintenance.plan.not.exist=\u7EF4\u4FDD\u8BA1\u5212\u4E0D\u5B58\u5728
 msg.capital.not.sign.record=\u8BE5\u9879\u76EE\u8FD8\u6CA1\u6709\u7B7E\u5230\u8BB0\u5F55
 msg.longitude.error=\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u7ECF\u7EAC\u5EA6