ソースを参照

Merge branch 'develop' of http://132.232.206.88:3000/lift-manager/lift-server into feature-bieao

别傲 5 年 前
コミット
51397cb5a2

+ 16 - 35
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/ScanRecordController.java

@@ -2,13 +2,11 @@ package cn.com.ty.lift.business.maintenance.controller;
 
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest;
-import cn.com.ty.lift.business.library.service.LiftService;
 import cn.com.ty.lift.business.maintenance.dao.entity.MaintenanceRecord;
 import cn.com.ty.lift.business.maintenance.dao.entity.ScanRecord;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.ScanRecordRequest;
-import cn.com.ty.lift.business.maintenance.dao.entity.model.response.ScanRecordResponse;
-import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceRecordMapper;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.ScanMaintenancePlanResponse;
+import cn.com.ty.lift.business.maintenance.dao.mapper.ScanRecordMapper;
 import cn.com.ty.lift.business.maintenance.service.MaintenanceRecordService;
 import cn.com.ty.lift.business.maintenance.service.ScanRecordService;
 import cn.com.xwy.boot.web.dto.RestResponse;
@@ -29,50 +27,33 @@ import org.springframework.web.bind.annotation.RestController;
 @RequestMapping("scan")
 @AllArgsConstructor
 public class ScanRecordController {
-    private final MaintenanceRecordMapper maintenanceRecordMapper;
     private final MaintenanceRecordService maintenanceRecordService;
     private final ScanRecordService scanRecordService;
-    private final LiftService liftService;
+    private final ScanRecordMapper scanRecordMapper;
 
     /**
      * 根据电梯id查询电梯信息
      *
-     * @param request id
+     * @param request liftId
      * @return 电梯信息
      */
     @PostMapping("lift/detail")
-    public RestResponse detail(@RequestBody LiftRequest request) {
-        Object response = liftService.detail(request.getId(), null);
-        if (ObjectUtil.isEmpty(response)) {
-            return RestResponse.success();
-        }
-        return RestResponse.success(response, MessageUtils.get("msg.query.detail.success"));
+    public RestResponse<?> detail(@RequestBody LiftRequest request) {
+        return RestResponse.success(scanRecordMapper.queryLiftInfoByLiftId(request.getLiftId()));
     }
 
     /**
-     * 根据电梯id查询已完成的维保记录
+     * 根据电梯id查询维保
      *
      * @param request liftId
      * @return 分页维保记录列表
      */
-    @PostMapping("maintenance/success/record")
-    public RestResponse maintenanceRecord(@RequestBody ScanRecordRequest request) {
-        Page<ScanRecordResponse> page = new Page<>(request.getPageNum(), request.getPageSize());
-        IPage<ScanRecordResponse> record = maintenanceRecordMapper.findRecordByLiftId(page, request);
-        if (record.getRecords().isEmpty()) {
-            return RestResponse.success();
-        }
-        for (ScanRecordResponse scanRecord : record.getRecords()) {
-            if (scanRecord.getLiftType() != null) {
-                int liftType = scanRecord.getLiftType();
-                if (liftType == 1) {
-                    scanRecord.setLiftTypeName("直梯");
-                } else if (liftType == 2) {
-                    scanRecord.setLiftTypeName("扶梯");
-                } else {
-                    scanRecord.setLiftTypeName("未设置电梯类型");
-                }
-            }
+    @PostMapping("maintenance/plan")
+    public RestResponse<Object> maintenanceRecord(@RequestBody ScanRecordRequest request) {
+        IPage<ScanMaintenancePlanResponse> page = new Page<>(request.getPageNum(), request.getPageSize());
+        IPage<ScanMaintenancePlanResponse> record = scanRecordMapper.queryMaintenancePlanByLiftId(page, request.getLiftId());
+        for (ScanMaintenancePlanResponse recordRecord : record.getRecords()) {
+            System.out.println(recordRecord.getId());
         }
         return RestResponse.success(record);
     }
@@ -80,12 +61,12 @@ public class ScanRecordController {
     /**
      * 维保详情记录
      *
-     * @param request 维保id
+     * @param request recordId
      * @return 维保记录详情
      */
     @PostMapping("maintenance/record/detail")
-    public RestResponse detail(@RequestBody MaintenanceRecordRequest request) {
-        MaintenanceRecord record = maintenanceRecordService.detail(request.getId());
+    public RestResponse detail(@RequestBody ScanRecordRequest request) {
+        MaintenanceRecord record = maintenanceRecordService.detail(request.getRecordId());
         if (ObjectUtil.isEmpty(record)) {
             return RestResponse.success();
         }

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

@@ -11,8 +11,8 @@ import lombok.EqualsAndHashCode;
 @Data
 @EqualsAndHashCode(callSuper = true)
 public class ScanRecordRequest extends ScanRecord {
-    @TableField(exist = false)
     private long pageNum = 1;
-    @TableField(exist = false)
     private long pageSize = 10;
+
+    private Long recordId;
 }

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

@@ -0,0 +1,15 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
+
+import lombok.Data;
+
+@Data
+public class ScanLiftInfoResponse {
+    private Long id;
+    private String registrationCode;
+    private String devicePosition;
+    private String projectName;
+    private String liftType;
+    private String workerName;
+    private String workerMobile;
+    private Integer projectStatus;
+}

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

@@ -0,0 +1,18 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class ScanMaintenancePlanResponse {
+    private Long id;
+    private LocalDateTime planDate;
+    private LocalDateTime workDate;
+    private String workerName;
+    private String maintenanceAdvice;
+    private String consumerAdvice;
+    private Long recordId;
+    private Integer status;
+    private Long liftId;
+}

+ 15 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/ScanRecordMapper.java

@@ -1,7 +1,15 @@
 package cn.com.ty.lift.business.maintenance.dao.mapper;
 
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import cn.com.ty.lift.business.maintenance.dao.entity.ScanRecord;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.ScanLiftInfoResponse;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.ScanMaintenancePlanResponse;
+import cn.com.ty.lift.common.constants.ApiConstants;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +21,10 @@ import cn.com.ty.lift.business.maintenance.dao.entity.ScanRecord;
  */
 public interface ScanRecordMapper extends BaseMapper<ScanRecord> {
 
+    @Select(ApiConstants.SQL.QUERY_LIFT_INFO_BY_LIFT_ID)
+    List<ScanLiftInfoResponse> queryLiftInfoByLiftId(Long liftId);
+
+    @Select(ApiConstants.SQL.QUERY_MAINTENANCE_PLAN_BY_LIFT_ID)
+    IPage<ScanMaintenancePlanResponse> queryMaintenancePlanByLiftId(IPage<ScanMaintenancePlanResponse> page, Long liftId);
+
 }

+ 33 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -397,5 +397,38 @@ public class ApiConstants {
                         "        where DATE_FORMAT(mp.plan_date, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')" +
                         "  and mp.status = '1' order by mp.plan_date";
 
+        String QUERY_LIFT_INFO_BY_LIFT_ID =
+                "<script>" +
+                        "select l.id                id," +
+                        "       l.registration_code registrationCode," +
+                        "       l.device_position   devicePosition," +
+                        "       p.project_name      projectName," +
+                        "       if(l.lift_type = 1, '直梯', '扶梯')         liftType," +
+                        "       ui.name             workerName," +
+                        "       ui.mobile           workerMobile," +
+                        "       p.project_status    projectStatus" +
+                        "   from project_lift_relevance plr" +
+                        "         left join lift l on plr.lift_id = l.id" +
+                        "         left join project p on plr.project_id = p.id" +
+                        "         left join user_info ui on plr.worker_id = ui.user_id" +
+                        "   where l.id = #{liftId}" +
+                        "  and p.project_status = '2'" +
+                        "</script>";
+
+        String QUERY_MAINTENANCE_PLAN_BY_LIFT_ID =
+                "select mp.id                 id," +
+                        "       mp.plan_date          planDate," +
+                        "       mp.work_date          workDate," +
+                        "       ui.name               workerName," +
+                        "       mr.maintenance_advice maintenanceAdvice," +
+                        "       e.advice              consumerAdvice," +
+                        "       mr.id                 recordId,"+
+                        "       mr.status             status," +
+                        "       mp.lift_id            liftId" +
+                        "   from maintenance_plan mp" +
+                        "         left join maintenance_record mr on mr.mt_plan_id = mp.id" +
+                        "         left join user_info ui on mp.worker_id = ui.user_id" +
+                        "         left join evaluation e on mr.id = e.record_id and e.source = '1'" +
+                        "   where mr.lift_id = #{liftId} order by mp.plan_date desc";
     }
 }