Browse Source

查询上次保养记录增加期数

别傲 5 years ago
parent
commit
59b1c9a428

+ 2 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/MtRecordRequest.java

@@ -95,4 +95,6 @@ public class MtRecordRequest extends PageRequest {
      * 注册代码/自定义编号
      */
     private String liftCodeQuery;
+
+    private Long userId;
 }

+ 5 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/MaintenanceRecordResponse.java

@@ -12,6 +12,7 @@ import java.time.LocalDate;
 @Data
 public class MaintenanceRecordResponse {
 
+    private Long mtPlanId;
     /**
      * 上次保养日期
      */
@@ -20,6 +21,10 @@ public class MaintenanceRecordResponse {
      * 上次保养类型
      */
     private String type;
+    /**
+     * 上次保养期数
+     */
+    private Long periods;
     /**
      * 项目id
      */

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/MaintenancePlanMapper.java

@@ -13,6 +13,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanRespo
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
 import java.util.Map;
@@ -54,4 +55,7 @@ public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> {
 
     long countWaitingMaintenanceByUser(@Param("request") CommonRequest request);
 
+    @Select("SELECT count FROM maintenance_plan WHERE id = #{planId}")
+    Long getCountByPlanId(Long planId);
+
 }

+ 0 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/MaintenanceRecordMapper.java

@@ -81,7 +81,4 @@ public interface MaintenanceRecordMapper extends BaseMapper<MaintenanceRecord> {
 
     @Select("SELECT value FROM global_set WHERE code = 'workLift' AND company_id = #{mtCompanyId}")
     String getGlobalSet(Long mtCompanyId);
-
-    @Select("SELECT id FROM maintenance_record WHERE mt_plan_id = #{planId}")
-    Long getRecordIdByPlanId(Long planId);
 }

+ 7 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -14,6 +14,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.model.response.Maintenance
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceRecordResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtRecordResponse;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceOptionMapper;
+import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
 import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceRecordMapper;
 import cn.com.ty.lift.business.maintenance.dao.third.*;
 import cn.com.ty.lift.business.project.dao.entity.Project;
@@ -68,7 +69,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     private ProjectService projectService;
     private ProjectLiftRelevanceService projectLiftRelevanceService;
     private MaintenanceOptionMapper maintenanceOptionMapper;
-    private Gson gson;
+    private MaintenancePlanMapper maintenancePlanMapper;
     @Autowired
     private Environment env;
 
@@ -84,6 +85,11 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (ObjectUtil.isNotEmpty(record)) {
             project.setType(record.getType());
             project.setWorkDate(record.getWorkDate());
+            //获取保养期数
+            Long mtPlanId = record.getMtPlanId();
+            Long count = maintenancePlanMapper.getCountByPlanId(mtPlanId);
+            project.setPeriods(count);
+            project.setMtPlanId(mtPlanId);
             return project;
         }
         return project;
@@ -445,8 +451,6 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (!result) {
             return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
         }
-        log.info("维保记录:" + gson.toJson(oldRecord));
-        log.info("维保计划id:" + oldRecord.getMtPlanId());
         MaintenancePlan plan = maintenancePlanService.getOne(oldRecord.getMtPlanId());
         if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.modify.fail"));
         plan.setStatus(Integer.parseInt(CommonEnum.MaintenancePlanStatus.COMPLETE.getCode()));

+ 8 - 3
lift-business-service/src/main/resources/mapper/maintenance/MaintenanceRecordMapper.xml

@@ -76,9 +76,10 @@
     <select id="findRecordByCompanyId"
             resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.response.MaintenanceRecordResponse"
             parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest">
-        SELECT work_date AS workDate,
-        type AS type,
-        lift_id AS liftId
+        SELECT mt_plan_id AS mtPlanId,
+               work_date AS workDate,
+               type AS type,
+               lift_id AS liftId
         FROM maintenance_record
         WHERE 1=1
         <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
@@ -225,6 +226,7 @@
         LEFT JOIN user_info ui ON mr.worker_id1 = ui.user_id
         LEFT JOIN project pr ON mr.project_id = pr.id AND pr.mt_company_id = mr.mt_company_id
         LEFT JOIN evaluation ev ON mr.id = ev.record_id
+        LEFT JOIN region r ON pr.region_id = r.id
         WHERE ((status = '2' AND has_evaluate = '0') or (status = '2' AND has_evaluate = '1'))
             <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
                 AND mr.mt_company_id = #{cond.mtCompanyId}
@@ -235,6 +237,9 @@
             <if test="cond.projectId != null and cond.projectId > 0">
                 AND pr.id = #{cond.projectId}
             </if>
+            <if test="cond.userId != null and cond.userId > 0">
+                AND r.user_id = #{cond.userId}
+            </if>
             <if test="cond.workerId != null and cond.workerId > 0">
                 AND mr.worker_id1 = #{cond.workerId}
             </if>