فهرست منبع

[chg]维保计划查询sql修改

别傲 5 سال پیش
والد
کامیت
1fd857f10d

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

@@ -3,7 +3,9 @@ package cn.com.ty.lift.business.maintenance.dao.entity;
 import java.math.BigDecimal;
 import java.util.Date;
 
+import cn.com.ty.lift.business.common.BaseEntity;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 /**
  * 实体类 - 表:maintenance_record
@@ -11,62 +13,141 @@ import lombok.Data;
  * @since 2019-12-12 11:27:30
  */
 @Data
-public class MaintenanceRecord {
+@EqualsAndHashCode(callSuper = true)
+public class MaintenanceRecord extends BaseEntity {
+
+	/**
+	 * 保养记录ID
+	 */
 	private Long id;
 
+	/**
+	 * 维保计划ID
+	 */
 	private Long mtPlanId;
 
+	/**
+	 * 电梯ID
+	 */
 	private Long liftId;
 
+	/**
+	 * 项目ID
+	 */
 	private Long projectId;
 
+	/**
+	 * 维保公司ID
+	 */
 	private Long mtCompanyId;
 
+	/**
+	 * 维保工ID
+	 */
 	private Long workerId;
 
+	/**
+	 * 编号,电梯编号+4位流水号'
+	 */
 	private String code;
 
+	/**
+	 * 电梯类型 1直梯,2扶梯
+	 */
 	private Byte liftType;
 
+	/**
+	 * 保养类型 1.半月,2.季度,3.半年,4.全年
+	 */
 	private Byte type;
 
+	/**
+	 * 计划保养时间
+	 */
 	private Date planDate;
 
+	/**
+	 * 实际保养时间
+	 */
 	private Date workDate;
 
+	/**
+	 * 停梯时间
+	 */
 	private Date stopDate;
 
+	/**
+	 * 恢复时间
+	 */
 	private Date recoveryDate;
 
+	/**
+	 * 保养建议
+	 */
 	private String maintenanceAdvice;
 
+	/**
+	 * 保养项目  用键值对的方式存储,如(1:0,2:1,3:1...)
+	 */
 	private String maintenanceOption;
 
+	/**
+	 * 签到位置
+	 */
 	private String position;
 
+	/**
+	 * 状态 1:已签到,未完成保养,2:完成保养,未选择评价方式,3:待评价,4:完成。
+	 */
 	private Byte status;
 
+	/**
+	 * 是否正常 0:正常 1:提前 2:延期
+	 */
 	private Byte isRegular;
 
-	private Long creatorId;
-
-	private Date createDate;
-
+	/**
+	 * 维保人员1
+	 */
 	private Long workerId1;
 
+	/**
+	 * 是否补录 0:正常 1:补录
+	 */
 	private Byte isRepair;
 
+	/**
+	 * 补录原因
+	 */
 	private String repairReason;
 
+	/**
+	 * 维保工签名1
+	 */
 	private String signatureImg1;
 
+	/**
+	 * 维保工签名2
+	 */
 	private String signatureImg2;
 
+	/**
+	 * 零配件
+	 */
 	private String sparepart;
 
+	/**
+	 * 配件费
+	 */
 	private BigDecimal partsCost;
 
+	/**
+	 * 工时费
+	 */
 	private BigDecimal manCost;
 
+	/**
+	 * 安全确认
+	 */
 	private String safetyConfirm;
 }

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

@@ -5,6 +5,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.MaintenancePlan;
 import cn.com.xwy.boot.controller.BaseRequestModel;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 import java.util.Date;
 import java.util.List;
@@ -15,6 +16,7 @@ import java.util.List;
  * @description 维保计划列表请求体
  */
 @Data
+@EqualsAndHashCode(callSuper = true)
 public class MaintenancePlanRequest extends BaseRequestModel {
     /**
      * 电梯列表

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/MaintenancePlanResponse.java

@@ -13,6 +13,10 @@ public class MaintenancePlanResponse {
      * 维保计划id
      */
     private Long id;
+    /**
+     * 是否制定维保计划(0:未制定,1:已制定)
+     */
+    private String status;
     /**
      * 电梯id
      */

+ 4 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenancePlanService.java

@@ -105,6 +105,8 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         int periods = request.getPeriods();
         //获取保养间隔
         int interval = request.getInterval();
+        //获取首保时间
+        Date firstTime = request.getFirstTime();
         for (MaintenancePlan plan : plans) {
             //获取项目id
             Long projectId = plan.getProjectId();
@@ -124,7 +126,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
                 entry.setWorkerId(plan.getWorkerId());
                 entry.setType(maintenanceType[periods - 1]);
                 if (i == 0) {
-                    entry.setPlanDate(plan.getPlanDate());
+                    entry.setPlanDate(firstTime);
                 } else {
                     //设置维护保养时间
                     MaintenancePlan maintenancePlan = planList.get(i - 1);
@@ -143,7 +145,7 @@ public class MaintenancePlanService extends ServiceImpl<MaintenancePlanMapper, M
         List<ProjectLiftRelevance> entryList = request.getRelevanceList();
         for (ProjectLiftRelevance entry : entryList) {
             entry.setPlanInterval(interval);
-            entry.setFirstTime(request.getFirstTime());
+            entry.setFirstTime(firstTime);
         }
         projectLiftRelevanceService.updateBatchById(entryList);
         return planList;

+ 30 - 23
lift-business-service/src/main/resources/mapper/maintenance/MaintenancePlanMapper.xml

@@ -21,29 +21,33 @@
 
 	<select id="findByCondition" resultType="cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanResponse" parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.MaintenancePlanRequest">
 		SELECT
-		  mp.id                    AS id,
-		  mp.plan_date             AS planDate,
-		  mp.id                    AS liftId,
-		  l.registration_code      AS registrationCode,
-		  l.device_position        AS devicePosition,
-		  plr.id                   AS relevanceId,
-          plr.company_id           AS mtCompanyId,
-          plr.worker_id            AS workerId,
-		  plr.plan_interval        AS planInterval,
-          p.id                     AS projectId,
-		  p.project_name           AS projectName,
-		  p.project_code           AS projectCode,
-		  pclr.lift_company_status AS liftStatus,
-		  r.area_name              AS regionName,
-		  ui.name                  AS workerName
-		FROM maintenance_plan mp
-		left join platform_company_lift_relevance pclr ON mp.mt_company_id = pclr.company_id AND mp.lift_id = pclr.lift_id
-		LEFT JOIN lift l ON mp.lift_id = l.id
-		left join project_lift_relevance plr ON mp.mt_company_id = plr.company_id AND mp.project_id = plr.project_id AND mp.lift_id = plr.lift_id
-		LEFT JOIN project p ON mp.mt_company_id = p.mt_company_id AND plr.project_id = p.id
+		mp.id                       AS id,
+		if(isnull(mp.id), '0', '1') AS status,
+		mp.plan_date                AS planDate,
+		l.id                        AS liftId,
+		l.registration_code         AS registrationCode,
+		l.device_position           AS devicePosition,
+		plr.id                      AS relevanceId,
+		plr.company_id              AS mtCompanyId,
+		plr.worker_id               AS workerId,
+		plr.plan_interval           AS planInterval,
+		p.id                        AS projectId,
+		p.project_name              AS projectName,
+		p.project_code              AS projectCode,
+		pclr.lift_company_status    AS liftStatus,
+		r.area_name                 AS regionName,
+		ui.name                     AS workerName
+		FROM
+		project_lift_relevance plr
+		LEFT JOIN platform_company_lift_relevance pclr ON plr.company_id = pclr.company_id AND plr.lift_id = pclr.lift_id
+		LEFT JOIN lift l ON plr.lift_id = l.id
+		LEFT JOIN project p ON plr.company_id = p.mt_company_id AND plr.project_id = p.id
+		LEFT JOIN maintenance_plan mp ON plr.company_id = mp.mt_company_id AND plr.project_id = mp.project_id
+		AND mp.status = 0 AND mp.plan_date = (SELECT MIN(plan_date) FROM maintenance_plan WHERE status = 0
+		AND mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}) AND plr.lift_id = mp.lift_id
 		LEFT JOIN user_info ui ON plr.worker_id = ui.user_id
 		LEFT JOIN region r ON p.region_id = r.id
-		WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
+		WHERE plr.company_id = #{request.mtCompanyId,jdbcType=VARCHAR}
 		<if test="request.projectId!=null and request.projectId!=''">
 			AND p.id = #{request.projectId,jdbcType=BIGINT}
 		</if>
@@ -53,6 +57,9 @@
 		<if test="request.regionId!=null and request.regionId!=''">
 			AND p.region_id = #{request.regionId,jdbcType=BIGINT}
 		</if>
+		<if test="request.planInterval!=null and request.planInterval!=''">
+			AND plr.plan_interval = #{request.planInterval,jdbcType=INTEGER}
+		</if>
 		<if test="request.beginTime!=null and request.beginTime!=''">
 			AND mp.plan_date > #{request.beginTime,jdbcType=VARCHAR}
 		</if>
@@ -60,14 +67,14 @@
 			AND <![CDATA[mp.plan_date < #{request.endTime,jdbcType=VARCHAR}]]>
 		</if>
 		<if test="request.registrationCode!=null and request.registrationCode!=''">
-			AND l.registration_code like #{request.registrationCode,jdbcType=VARCHAR}
+			AND l.registration_code LIKE #{request.registrationCode,jdbcType=VARCHAR}
 		</if>
 	</select>
 
 	<select id="findIdList" resultMap="BaseResultMap" parameterType="java.util.Date">
 		SELECT
 		id,
-		plan_date as planDate
+		plan_date AS planDate
 		FROM maintenance_plan
 		WHERE plan_date > #{currentTime,jdbcType=TIMESTAMP}
 	</select>

+ 1 - 1
pom.xml

@@ -34,7 +34,7 @@
 
     <repositories>
         <repository>
-            <id>local</id>
+            <id>reserved</id>
             <url>http://132.232.206.88:8081/repository/local</url>
         </repository>
         <repository>