瀏覽代碼

[chg] 维保记录添加评价标识hasEvaluate

wcz 5 年之前
父節點
當前提交
c5d3e87ed1

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

@@ -90,7 +90,7 @@ public class MaintenanceRecordController {
         IPage<MtPlanResponse> pages = maintenancePlanService.pagePlanByCondition(request);
         Verify.notNull(pages, "维保计划不存在,请核查");
         List<MtPlanResponse> records = pages.getRecords();
-        if (IterUtil.isNotEmpty(records)) {
+        if (!records.isEmpty()) {
             List<ProjectLiftRelevance> relevances = projectLiftRelevanceService.listByMtCompany(request.getMtCompanyId());
             records.forEach(record -> {
                 Optional<ProjectLiftRelevance> liftRelevance = relevances
@@ -186,10 +186,9 @@ public class MaintenanceRecordController {
         Integer liftType = request.getLiftType();
         Long mtCompanyId = request.getMtCompanyId();
         List<MaintenanceOption> optionList = maintenanceOptionService.listByTypeAndLiftType(type, liftType, mtCompanyId);
-        Verify.notNull(optionList, "维保操作项不存在,请核查");
+        Verify.notTrue(IterUtil.isEmpty(optionList), "维保操作项不存在,请核查");
         //按照sort groupby
         Map<Integer, List<MaintenanceOption>> mtOptionMap = optionList.stream().collect(Collectors.groupingBy(MaintenanceOption::getSort));
-        Verify.notNull(mtOptionMap, "维保操作项不存在,请核查");
         List<MtOptionTree> mtOptionTrees = new ArrayList<>();
         mtOptionMap.forEach((sort, options) -> {
             mtOptionTrees.add(new MtOptionTree(sort, options));
@@ -240,7 +239,7 @@ public class MaintenanceRecordController {
          * app端添加维保单
          * -3:没有维保记录(可以补录)null -> -3
          * -2:已补录工单,(没有维保项,可以继续填写)
-         * -1:待审核(通过app端添加的),通过后台添加的,直接 ->3
+         * -1:待审核(通过app端添加的),通过后台添加的,直接 ->2
          */
         if (StrUtil.isEmpty(entity.getMaintenanceOption())) {
             entity.setStatus("-2");
@@ -251,6 +250,7 @@ public class MaintenanceRecordController {
         //补录
         entity.setIsRepair(1);
         entity.setWorkDate(LocalDate.now());
+        entity.setHasEvaluate(0);
         return maintenanceRecordService.tofill(entity);
     }
 
@@ -345,14 +345,14 @@ public class MaintenanceRecordController {
         MaintenanceRecord record = maintenanceRecordService.getById(entity.getRecordId());
         Verify.notNull(record, "维保记录不存在,请核查");
         //状态 -1:待审核,0:待处理,1:已签到,保养中,2:完成保养,待评价,3:完成。
-        Verify.notTrue("2".equals(record.getStatus()), "维保记录待评价才能操作");
+        Verify.isTrue("2".equals(record.getStatus()), "完成维保后才能评价");
         //来源(1 维保;2 急修)
         entity.setSource(1);
         entity.setLiftId(record.getLiftId());
         entity.setPostDate(LocalDateTime.now());
 
-        //维保记录设置完成
-        record.setStatus("3");
+        //维保记录设置已评价
+        record.setHasEvaluate(1);
         return maintenanceRecordService.evaluate(record, entity);
     }
 

+ 9 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/MaintenanceRecord.java

@@ -120,8 +120,10 @@ public class MaintenanceRecord extends BaseEntity {
 	private String position;
 
 	/**
-	 * 状态 -1:待审核,0:待处理,1:已签到,保养中,2:完成保养,待评价,3:完成。
-	 * -2:已补录工单(缺少维保项),可以继续填写
+	 * 状态 -1:待审核,0:待处理,1:已签到,保养中,2:完成保养,待评价。
+	 * -3:没有维保记录(可以补录)null -> -3
+	 * -2:已补录工单,(没有维保项,可以继续填写)
+	 * -1:待审核(通过app端添加的),通过后台添加的,直接 ->2
 	 */
 	private String status;
 
@@ -178,7 +180,11 @@ public class MaintenanceRecord extends BaseEntity {
 	 * 安全确认
 	 */
 	private String safetyConfirm;
-
+	/**
+	 * 是否已经评价 0:未评价,1:已评价
+	 */
+	@Range(max = 1,message = "评价状态有误")
+	private Integer hasEvaluate;
 	/**
 	 * 维保收费项
 	 */

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

@@ -16,7 +16,29 @@ public interface Verify {
     static VerifyException verifyException(String message){
         return new VerifyException(message);
     }
+    /**
+     * 判断表达式是否为真,如果为假,直接抛出异常,返回message
+     *
+     * @param expression 需要判断的布尔表达式
+     * @param message    抛出异常的消息
+     */
+    static void isTrue(boolean expression, String message) {
+        if (!expression) {
+            throw verifyException(message);
+        }
+    }
 
+    /**
+     * 判断表达式是否为真,如果为真,直接抛出异常,返回message
+     *
+     * @param expression 需要判断的布尔表达式
+     * @param message    抛出异常的消息
+     */
+    static void notTrue(boolean expression, String message) {
+        if (expression) {
+            throw verifyException(message);
+        }
+    }
     /**
      * 判断对象object是否为空,如果不为空,直接抛出异常,返回message
      *
@@ -46,29 +68,7 @@ public interface Verify {
     static void equals(int one, int other, String message){
         isTrue(one == other, message);
     }
-    /**
-     * 判断表达式是否为真,如果为假,直接抛出异常,返回message
-     *
-     * @param expression 需要判断的布尔表达式
-     * @param message    抛出异常的消息
-     */
-    static void isTrue(boolean expression, String message) {
-        if (!expression) {
-            throw verifyException(message);
-        }
-    }
 
-    /**
-     * 判断表达式是否为真,如果为真,直接抛出异常,返回message
-     *
-     * @param expression 需要判断的布尔表达式
-     * @param message    抛出异常的消息
-     */
-    static void notTrue(boolean expression, String message) {
-        if (expression) {
-            throw verifyException(message);
-        }
-    }
     static void greater(int value, int bounds, String message){
         isTrue(value > bounds, message);
     }