Quellcode durchsuchen

update->做完保养,或补录保养单,将公司电梯状态设置为正常。修复更新项目状态时,项目列表为空,mybatis-plus报错问题

wanghaicheng vor 4 Jahren
Ursprung
Commit
c645d9a7e1

+ 28 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/MaintenanceRecordController.java

@@ -2,6 +2,8 @@ package cn.com.ty.lift.business.maintenance.controller;
 
 import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
 import cn.com.ty.lift.business.evaluation.service.EvaluationService;
+import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.*;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtPlanRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest;
@@ -11,6 +13,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtRecordRes
 import cn.com.ty.lift.business.maintenance.service.*;
 import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.model.CountPage;
 import cn.com.ty.lift.common.utils.ValuePool;
 import cn.com.ty.lift.common.verify.Val;
@@ -20,6 +23,8 @@ import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.collection.IterUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.google.common.base.Splitter;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -57,6 +62,7 @@ public class MaintenanceRecordController {
     private MaintenanceOptionService maintenanceOptionService;
     private ProjectLiftRelevanceService projectLiftRelevanceService;
     private EvaluationService evaluationService;
+    private PlatformCompanyLiftRelevanceService platformCompanyLiftRelevanceService;
 
     /**
      * 根据条件分页查询维保-日常保养
@@ -267,6 +273,13 @@ public class MaintenanceRecordController {
         entity.setIsRegular(0);
         //补录
         entity.setIsRepair(1);
+        //设置电梯状态到 正常
+        platformCompanyLiftRelevanceService.list(Wrappers.<PlatformCompanyLiftRelevance>lambdaUpdate()
+                .eq(PlatformCompanyLiftRelevance::getLiftId, entity.getLiftId())
+                .eq(PlatformCompanyLiftRelevance::getMtCompanyId, entity.getMtCompanyId())
+                .ne(PlatformCompanyLiftRelevance::getDeleteFlag, 1)
+                .ne(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.STOP_INSURANCE.getCode())
+                .set(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.NORMAL.getCode()));
         return maintenanceRecordService.tofill(entity);
     }
 
@@ -299,6 +312,13 @@ public class MaintenanceRecordController {
         entity.setIsRepair(1);
         entity.setWorkDate(LocalDateTime.now());
         entity.setHasEvaluate(0);
+        //设置电梯状态到 正常
+        platformCompanyLiftRelevanceService.list(Wrappers.<PlatformCompanyLiftRelevance>lambdaUpdate()
+                .eq(PlatformCompanyLiftRelevance::getLiftId, entity.getLiftId())
+                .eq(PlatformCompanyLiftRelevance::getMtCompanyId, entity.getMtCompanyId())
+                .ne(PlatformCompanyLiftRelevance::getDeleteFlag, 1)
+                .ne(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.STOP_INSURANCE.getCode())
+                .set(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.NORMAL.getCode()));
         return maintenanceRecordService.tofill(entity);
     }
 
@@ -316,6 +336,13 @@ public class MaintenanceRecordController {
         Validate.notNull(entity, ValuePool.MAINTENANCE_RECORD_NOT_EXIST);
         Validate.notTrue("-1".equals(entity.getStatus()), ValuePool.MAINTENANCE_RECORD_MUST_AUDITING);
         entity.setStatus("2");
+        //设置电梯状态到 正常
+        platformCompanyLiftRelevanceService.list(Wrappers.<PlatformCompanyLiftRelevance>lambdaUpdate()
+                .eq(PlatformCompanyLiftRelevance::getLiftId, entity.getLiftId())
+                .eq(PlatformCompanyLiftRelevance::getMtCompanyId, entity.getMtCompanyId())
+                .ne(PlatformCompanyLiftRelevance::getDeleteFlag, 1)
+                .ne(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.STOP_INSURANCE.getCode())
+                .set(PlatformCompanyLiftRelevance::getLiftCompanyStatus, CommonEnum.LiftStatus.NORMAL.getCode()));
         return maintenanceRecordService.pass(entity);
     }
 
@@ -419,6 +446,6 @@ public class MaintenanceRecordController {
     @PostMapping("export")
     @Validation(fields = {"recordIds"})
     public RestResponse<?> export(@Val @RequestBody MtRecordRequest mtRecordRequest) {
-       return RestResponse.success(maintenanceRecordService.export(mtRecordRequest));
+        return RestResponse.success(maintenanceRecordService.export(mtRecordRequest));
     }
 }

+ 6 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -140,9 +140,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
      * @date 2020/2/10 4:16 下午
      */
     public void updateBatch(List<Project> list, String projectStatus) {
-        list.forEach(project -> project.setProjectStatus(projectStatus));
-        updateBatchById(list, list.size());
-        log.info("批量更新项目状态" + list.size() + "条");
+        if (list != null && !list.isEmpty()) {
+            list.forEach(project -> project.setProjectStatus(projectStatus));
+            updateBatchById(list, list.size());
+        }
+        int size = list != null ? list.size() : 0;
+        log.info("批量更新项目状态" + size + "条");
     }