瀏覽代碼

Merge branch 'feature-wcz' of lift-manager/lift-server into develop

wucizhong 5 年之前
父節點
當前提交
d58155b695

+ 9 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java

@@ -114,7 +114,7 @@ public class EmergencyRepairController {
             //急修图片
             result.setErRecordImgs(erRecordImgService.listByErRecordId(id));
             //评价
-            result.setEvaluation(evaluationService.findByRecord(id));
+            result.setEvaluation(evaluationService.findByRecord(id, ValuePool.EVALUATE_SOURCE_EMERGENCY));
             //故障信息
             fillFault(result);
         }
@@ -182,7 +182,7 @@ public class EmergencyRepairController {
         //派单时间 急修单创建时间
         entity.setHasEvaluate(0);
         entity.setAssignTime(LocalDateTime.now());
-        entity.setStatus(0);
+        entity.setStatus(ValuePool.EMERGENCY_STATE_TO_DO);
         boolean result = emergencyRepairService.save(entity);
         if (result) {
             //消息推送
@@ -605,10 +605,13 @@ public class EmergencyRepairController {
         Validate.notNull(repair, ValuePool.EMERGENCY_NOT_EXIST);
 
         Validate.equals(repair.getStatus(), ValuePool.EMERGENCY_STATE_COMPLETE, ValuePool.EMERGENCY_MUST_COMPLETE);
-        Validate.notEquals(repair.getHasEvaluate(), 1, ValuePool.EMERGENCY_HAD_EVALUATE);
-
+        //根据急修中的评价标识判断
+        Validate.notEquals(1, repair.getHasEvaluate(), ValuePool.EMERGENCY_HAD_EVALUATE);
+        //查询急修评价记录判断
+//        int has = evaluationService.countByRecord(entity.getRecordId(), ValuePool.EVALUATE_SOURCE_EMERGENCY);
+//        Validate.notTrue(has > 0, ValuePool.EMERGENCY_HAD_EVALUATE);
         //来源(1 维保;2 急修)
-        entity.setSource(2);
+        entity.setSource(ValuePool.EVALUATE_SOURCE_EMERGENCY);
         entity.setLiftId(repair.getLiftId());
         entity.setPostDate(LocalDateTime.now());
 
@@ -651,7 +654,7 @@ public class EmergencyRepairController {
         entity.setFaultDuty(request.getFaultDuty());
         entity.setRecoveryDate(request.getRecoveryDate());
         //修改状态已完成
-        entity.setStatus(2);
+        entity.setStatus(ValuePool.EMERGENCY_STATE_COMPLETE);
         RestResponse result = emergencyRepairService.repairOrder(entity, erRecordImgs);
         if (Objects.equals("1", result.getStatusCode())) {
             Long mtCompanyId = entity.getMtCompanyId();

+ 19 - 10
lift-business-service/src/main/java/cn/com/ty/lift/business/evaluation/service/EvaluationService.java

@@ -3,7 +3,7 @@ package cn.com.ty.lift.business.evaluation.service;
 import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
 import cn.com.ty.lift.business.evaluation.dao.mapper.EvaluationMapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
@@ -18,18 +18,27 @@ import org.springframework.stereotype.Service;
 @Service
 public class EvaluationService extends ServiceImpl<EvaluationMapper, Evaluation> {
 
-    public Evaluation findByRecord(Long recordId){
-        QueryWrapper<Evaluation> queryWrapper = new QueryWrapper<>();
-        LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = queryWrapper.lambda();
-        lambdaQueryWrapper.eq(Evaluation::getRecordId,recordId);
+    /**
+     * 根据记录id和来源分类查询评价记录
+     * @param recordId 急修or维保id
+     * @param source 急修or维保
+     */
+    public Evaluation findByRecord(Long recordId, int source){
+        LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.eq(Evaluation::getRecordId, recordId);
+        lambdaQueryWrapper.eq(Evaluation::getSource, source);
         lambdaQueryWrapper.last("LIMIT 1");
         return getOne(lambdaQueryWrapper);
     }
-
-    public int countByRecord(Long recordId){
-        QueryWrapper<Evaluation> queryWrapper = new QueryWrapper<>();
-        LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = queryWrapper.lambda();
-        lambdaQueryWrapper.eq(Evaluation::getRecordId,recordId);
+    /**
+     * 根据记录id和来源分类查询评价记录条数
+     * @param recordId 急修or维保id
+     * @param source 急修or维保
+     */
+    public int countByRecord(Long recordId, int source) {
+        LambdaQueryWrapper<Evaluation> lambdaQueryWrapper = Wrappers.lambdaQuery();
+        lambdaQueryWrapper.eq(Evaluation::getRecordId, recordId);
+        lambdaQueryWrapper.eq(Evaluation::getSource, source);
         return count(lambdaQueryWrapper);
     }
 }

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

@@ -152,7 +152,7 @@ public class MaintenanceRecordController {
         //查询图片
         entity.setMtRecordImgs(mtRecordImgService.listByRecord(id));
         //评价
-        entity.setEvaluation(evaluationService.findByRecord(id));
+        entity.setEvaluation(evaluationService.findByRecord(id, ValuePool.EVALUATE_SOURCE_MAINTENANCE));
         return RestResponse.success(entity);
     }
 
@@ -339,8 +339,13 @@ public class MaintenanceRecordController {
         Validate.notNull(record, ValuePool.MAINTENANCE_RECORD_NOT_EXIST);
         //状态 -1:待审核,0:待处理,1:已签到,保养中,2:完成保养,待评价,3:完成。
         Validate.isTrue("2".equals(record.getStatus()), ValuePool.MAINTENANCE_RECORD_MUST_COMPLETE);
+        //根据维保记录中的评价标识判断
+        Validate.notEquals(1, record.getHasEvaluate(), ValuePool.MAINTENANCE_HAD_EVALUATE);
+        //查询评价记录判断
+//        int has = evaluationService.countByRecord(entity.getRecordId(), ValuePool.EVALUATE_SOURCE_MAINTENANCE);
+//        Validate.notTrue(has > 0, ValuePool.MAINTENANCE_HAD_EVALUATE);
         //来源(1 维保;2 急修)
-        entity.setSource(1);
+        entity.setSource(ValuePool.EVALUATE_SOURCE_MAINTENANCE);
         entity.setLiftId(record.getLiftId());
         entity.setPostDate(LocalDateTime.now());
 

+ 8 - 4
lift-common/src/main/java/cn.com.ty.lift.common/utils/ValuePool.java

@@ -294,11 +294,15 @@ public interface ValuePool {
     static <T> T nullable(T object, T valueForNull) {
         return Objects.isNull(object) ? valueForNull : object;
     }
-    String MAINTENANCE_RECORD_NOT_EXIST = "维保记录不存在,请核查";
-    String MAINTENANCE_PLAN_NOT_EXIST = "维保计划不存在,请核查";
-    String MAINTENANCE_OPTION_NOT_EXIST = "维保操作项不存在,请核查";
+
+    String MAINTENANCE_RECORD_NOT_EXIST     = "维保记录不存在,请核查";
+    String MAINTENANCE_PLAN_NOT_EXIST       = "维保计划不存在,请核查";
+    String MAINTENANCE_OPTION_NOT_EXIST     = "维保操作项不存在,请核查";
     String MAINTENANCE_RECORD_MUST_AUDITING = "维保单必须待审核才能操作,请核查";
     String MAINTENANCE_RECORD_MUST_COMPLETE = "维保单必须完成后才能操作,请核查";
+    String MAINTENANCE_HAD_EVALUATE         = "维保已经评价了";
     //法规维保间隔15天
-    int MAINTENANCE_INTERVAL = 15;
+    int    MAINTENANCE_INTERVAL             = 15;
+    int    EVALUATE_SOURCE_MAINTENANCE      = 1;
+    int    EVALUATE_SOURCE_EMERGENCY        = 2;
 }