浏览代码

[chg] 年检阶段三设置下一次年检计划和检查

wcz 5 年之前
父节点
当前提交
fe62809730

+ 7 - 11
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java

@@ -133,15 +133,13 @@ public class AnnualInspectionController {
      * stepName: 1
      */
     @PostMapping("confirm")
-    @Verifier(fields = {"liftId","mtCompanyId","planDate"})
+    @Verifier(fields = {"liftId","mtCompanyId","planDate","isCheckGoverner","loadInspectionSetting"})
     public RestResponse confirm(@Ver @RequestBody AnnualInspection entity){
         long count = annualInspectionService.countConfirm(entity.getLiftId(), entity.getMtCompanyId(), entity.getPlanDate());
         Verify.nogt0(count, "年检计划已存在");
         entity.setStatus(0);
         entity.setStepStatus(1);
         entity.setStepName(1);
-        entity.setIsCheckGoverner(0);
-        entity.setLoadInspectionSetting(0);
         boolean ai = annualInspectionService.saveOrUpdate(entity);
         return RestResponse.success(ai);
     }
@@ -176,7 +174,8 @@ public class AnnualInspectionController {
     public RestResponse update(@Ver @RequestBody InspectionRequest entity){
         AnnualInspection old = annualInspectionService.findByMtCompanyId(entity.getId(), entity.getMtCompanyId());
         Verify.notNull(old, Verify.Inspection.confirm);
-
+        Integer oldStepName = old.getStepName();
+        Verify.isTrue(oldStepName == 1, "年检第一阶段才能修改");
         old.setIsCheckGoverner(entity.getIsCheckGoverner());
         old.setLoadInspectionSetting(entity.getLoadInspectionSetting());
 
@@ -247,9 +246,10 @@ public class AnnualInspectionController {
      * 6	企业文员确认检验结果-整改 --> 回到第二阶段
      *      (3  企业文员确认现场检验时间 录入人员信息,政府质检,企业质检,联系电话)
      * 7	企业文员确认检验结果-不合格 --> 可以算年检超期
+     *  设置下次年检时间,是否检查限速器和是否荷载设置
      */
     @PostMapping("stepThree")
-    @Verifier(fields = {"id","mtCompanyId","stepStatus","checkResultImg","projectId"})
+    @Verifier(fields = {"id","mtCompanyId","stepStatus","checkResultImg","projectId","nextInspectionTime","isCheckGoverner","loadInspectionSetting"})
     public RestResponse stepThree(@Ver @RequestBody InspectionRequest entity){
         AnnualInspection old = annualInspectionService.findByMtCompanyId(entity.getId(), entity.getMtCompanyId());
         Verify.notNull(old, Verify.Inspection.confirm);
@@ -262,6 +262,7 @@ public class AnnualInspectionController {
 
         old.setCheckResultImg(entity.getCheckResultImg());
         old.setStepStatus(entity.getStepStatus());
+        old.setNextInspectionTime(entity.getNextInspectionTime());
 
         old.setStatus(0);
         //企业文员确认检验结果-整改 --> 回到第二阶段
@@ -273,7 +274,7 @@ public class AnnualInspectionController {
             old.setStepStatus(3);
             old.setStepName(2);//转回阶段2
         }
-        boolean ai = annualInspectionService.stepThree(old, entity.getProjectId());
+        boolean ai = annualInspectionService.stepThree(old, entity.getProjectId(), entity.getIsCheckGoverner(), entity.getLoadInspectionSetting());
         return RestResponse.success(ai);
     }
 
@@ -293,11 +294,6 @@ public class AnnualInspectionController {
         Verify.isTrue(oldStepName == 3, "请进行第三阶段操作");
         Verify.isTrue(oldStepStatus >= 5 && oldStepStatus <= 10, "请进行第四阶段操作");
         Verify.isTrue(stepStatus >= 8 && stepStatus <= 10, "请进行第四阶段操作");
-        // 合格,需要下次年检时间
-        if(stepStatus == 9){
-            Verify.notNull(entity.getNextInspectionTime(), Verify.Inspection.nextInspectionTime);
-            old.setNextInspectionTime(entity.getNextInspectionTime());
-        }
 
         old.setStepStatus(entity.getStepStatus());
         old.setAnnualInspectionImg(entity.getAnnualInspectionImg());

+ 1 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/dto/InspectionRequest.java

@@ -144,5 +144,6 @@ public class InspectionRequest extends PageRequest {
     /**
      * 下次年检日期
      */
+    @NotEmpty(message = "请设置下次年检时间")
     private LocalDate nextInspectionTime;
 }

+ 44 - 37
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/service/AnnualInspectionService.java

@@ -114,7 +114,7 @@ public class AnnualInspectionService extends ServiceImpl<AnnualInspectionMapper,
      * 7	企业文员确认检验结果-不合格 --> 可以算年检超期
      */
     @Transactional(rollbackFor = Exception.class)
-    public boolean stepThree(AnnualInspection entity, Long projectId) {
+    public boolean stepThree(AnnualInspection entity, Long projectId, Integer isCheckGoverner, Integer loadInspectionSetting) {
         //更新年检
         boolean up = updateById(entity);
         //更新失败,直接返回false
@@ -143,10 +143,48 @@ public class AnnualInspectionService extends ServiceImpl<AnnualInspectionMapper,
         }
         relevance.setLiftCompanyStatus(CommonEnum.LiftStatus.ANNUAL_INSPECTION.getCode());
         boolean re = platformCompanyLiftRelevanceService.updateById(relevance);
-        if (re) {
+        if(!re){
+            //强制手动事务回滚
+            rollback();
+            return false;
+        }
+        //更新电梯中下一次年检信息
+        //电梯不存在,说明数据有误,直接返回false
+        Lift lift = liftService.getById(liftId);
+        if (null == lift) {
+            rollback();
+            return false;
+        }
+        //更新电梯之前获取旧的年检时间
+        LocalDate oldInspectionDate = lift.getAnnualInspectionDate();
+        LocalDate nextInspectionTime = entity.getNextInspectionTime();
+
+        lift.setAnnualInspectionDate(nextInspectionTime);
+        lift.setIsCheckGoverner(isCheckGoverner);
+        lift.setLoadInspectionSetting(loadInspectionSetting);
+
+        boolean li = liftService.updateById(lift);
+        //更新电梯失败,返回false
+        if (!li) {
+            rollback();
+            return false;
+        }
+        //更新电梯成功,插入电梯操作记录
+        LiftHistory liftHistory = new LiftHistory();
+        liftHistory.setId(IdWorker.getId());
+        liftHistory.setMtCompanyId(mtCompanyId);
+        liftHistory.setLiftId(liftId);
+        liftHistory.setCode(lift.getLiftCode());
+        liftHistory.setDescription("修改电梯年检日期");
+        liftHistory.setContent(StrUtil.format("电梯年检日期由:{}修改成{}", oldInspectionDate, nextInspectionTime));
+        //fixme:获取当前登录用户
+        liftHistory.setOperatorId(entity.getCreatorId());
+        liftHistory.setOperateDate(LocalDateTime.now());
+        boolean lh = liftHistoryService.save(liftHistory);
+        //插入电梯记录成功,直接返回true,否则手动事务回滚,返回false
+        if (lh) {
             return true;
         } else {
-            //强制手动事务回滚
             rollback();
             return false;
         }
@@ -196,43 +234,12 @@ public class AnnualInspectionService extends ServiceImpl<AnnualInspectionMapper,
             //如果合格,修改电梯的业务状态为正常
             relevance.setLiftCompanyStatus(CommonEnum.LiftStatus.NORMAL.getCode());
             boolean re = platformCompanyLiftRelevanceService.updateById(relevance);
-            if(!re){
-                rollback();
-                return false;
-            }
-
-            //电梯不存在,说明数据有误,直接返回false
-            Lift lift = liftService.getById(liftId);
-            if (null == lift) {
-                return false;
-            }
-            //更新电梯之前获取旧的年检时间
-            LocalDate oldInspectionDate = lift.getAnnualInspectionDate();
-            LocalDate nextInspectionTime = entity.getNextInspectionTime();
-            lift.setAnnualInspectionDate(nextInspectionTime);
-            boolean li = liftService.updateById(lift);
-            //更新电梯失败,返回false
-            if (!li) {
-                return false;
-            }
-            //更新电梯成功,插入电梯操作记录
-            LiftHistory liftHistory = new LiftHistory();
-            liftHistory.setId(IdWorker.getId());
-            liftHistory.setMtCompanyId(mtCompanyId);
-            liftHistory.setLiftId(liftId);
-            liftHistory.setCode(lift.getLiftCode());
-            liftHistory.setDescription("修改电梯年检日期");
-            liftHistory.setContent(StrUtil.format("电梯年检日期由:{}修改成{}", oldInspectionDate, nextInspectionTime));
-            //fixme:获取当前登录用户
-            liftHistory.setOperatorId(entity.getCreatorId());
-            liftHistory.setOperateDate(LocalDateTime.now());
-            boolean lh = liftHistoryService.save(liftHistory);
-            //插入电梯记录成功,直接返回true,否则手动事务回滚,返回false
-            if (lh) {
+            if(re){
                 return true;
-            } else {
+            }else{
                 rollback();
                 return false;
+
             }
         }
         return true;

+ 8 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/Lift.java

@@ -228,6 +228,14 @@ public class Lift extends BaseEntity {
      * 年检日期
      */
     private LocalDate annualInspectionDate;
+    /**
+     * 是否检查限速器(0 否;1 是;默认0)
+     */
+    private Integer isCheckGoverner;
+    /**
+     * 是否荷载年检设置(0 否;1 是;默认0)
+     */
+    private Integer loadInspectionSetting;
 
     /**
      * 行政区划代码

+ 8 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/response/LiftAnnualInspectionResponse.java

@@ -48,4 +48,12 @@ public class LiftAnnualInspectionResponse {
      * 年检时间
      */
     private LocalDate planDate;
+    /**
+     * 是否检查限速器(0 否;1 是;默认0)
+     */
+    private Integer isCheckGoverner;
+    /**
+     * 是否荷载年检设置(0 否;1 是;默认0)
+     */
+    private Integer loadInspectionSetting;
 }

+ 4 - 0
lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml

@@ -46,6 +46,8 @@
         <result column="install_date" property="installDate" jdbcType="TIMESTAMP"/>
         <result column="inner_floor" property="innerFloor" jdbcType="INTEGER"/>
         <result column="annual_inspection_date" property="annualInspectionDate" jdbcType="DATE"/>
+        <result column="is_check_governer" property="isCheckGoverner" jdbcType="TINYINT" />
+        <result column="load_inspection_setting" property="loadInspectionSetting" jdbcType="TINYINT" />
         <result column="area_code" property="areaCode" jdbcType="CHAR"/>
         <result column="device_id" property="deviceId" jdbcType="VARCHAR"/>
         <result column="device_type" property="deviceType" jdbcType="TINYINT"/>
@@ -225,6 +227,8 @@
             li.use_company_code,
             li.device_position,
             ui.name                   AS director_name,
+            li.is_check_governer,
+            li.load_inspection_setting,
             li.annual_inspection_date AS plan_date
         FROM lift li
         LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id

+ 1 - 1
lift-common/src/main/java/cn.com.ty.lift.common/verify/Verify.java

@@ -443,7 +443,7 @@ public interface Verify {
          * 1  维保工确认年检计划
          */
         int STATUS_CONFIRM                          = 1;
-        String confirm                              = "请确认年检计划";
+        String confirm                              = "年检不存在,请确认年检计划";
 
         static boolean statusConfirm(int status){
             return STATUS_CONFIRM == status;