Kaynağa Gözat

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

bieao 5 yıl önce
ebeveyn
işleme
0b5d3a8cb7

+ 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()));

+ 20 - 24
lift-business-service/src/main/resources/mapper/annualinspection/AnnualInspectionMapper.xml

@@ -248,21 +248,29 @@
 
     <select id="countDoingByUser" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.common.CommonRequest">
         SELECT
-            count(*)
+            count(1)
         FROM
             annual_inspection ai
+        LEFT JOIN platform_company_lift_relevance pc
+                ON ai.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND ai.mt_company_id = pc.mt_company_id
+        <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' or cond.currentRoleCode == 'ROLEMTWORK' ">
+            LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = pc.mt_company_id AND plr.lift_id = ai.lift_id AND plr.delete_flag = '0'
+        </if>
         <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
-            LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = ai.mt_company_id AND plr.lift_id = ai.lift_id
-            LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
+            LEFT JOIN project_user pu ON plr.project_id = pu.project_id AND pu.mt_company_id = plr.mt_company_id
         </if>
         WHERE
             ai.`status` = 0
-        <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK'">
-            AND pu.user_id = #{cond.userId}
-        </if>
-        <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
             AND ai.mt_company_id = #{cond.mtCompanyId}
-        </if>
+        <choose>
+            <when test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+                AND pu.user_id = #{cond.userId,jdbcType=BIGINT}
+            </when>
+            <when test="cond.currentRoleCode == 'ROLEMTWORK' ">
+                AND plr.worker_id = #{cond.userId,jdbcType=BIGINT}
+            </when>
+            <otherwise/>
+        </choose>
     </select>
 
     <!--app统计年检列表待确认总数 -->
@@ -271,22 +279,10 @@
         SELECT count(1) toConfirm
         FROM lift li
         LEFT JOIN platform_company_lift_relevance pclr ON li.id = pclr.lift_id AND pclr.lift_company_status!=1
-        <choose>
-            <when test=" request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
-                LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id AND plr.delete_flag = '0'
-                LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND AND ai.plan_date = li.annual_inspection_date
-                AND ai.mt_company_id = plr.mt_company_id
-            </when>
-            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
-                LEFT JOIN project_user pu ON pu.project_id = plr.project_id
-                LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.plan_date = li.annual_inspection_date AND
-                pu.mt_company_id = ai.mt_company_id
-            </when>
-            <otherwise>
-                LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND pclr.mt_company_id = ai.mt_company_id
-                AND ai.plan_date = li.annual_inspection_date
-            </otherwise>
-        </choose>
+        LEFT JOIN project_lift_relevance plr ON li.id = plr.lift_id AND plr.delete_flag = '0'
+        LEFT JOIN annual_inspection ai ON ai.lift_id = li.id AND ai.plan_date = li.annual_inspection_date
+        AND ai.mt_company_id = plr.mt_company_id
+        LEFT JOIN project_user pu ON pu.project_id = plr.project_id AND pu.mt_company_id = ai.mt_company_id
         WHERE <![CDATA[li.annual_inspection_date <= date_add(curdate(), INTERVAL 45 DAY)]]>
         AND <![CDATA[li.annual_inspection_date >= curdate() AND isnull(ai.id)]]>
         AND pclr.mt_company_id = #{request.mtCompanyId}

+ 4 - 11
lift-business-service/src/main/resources/mapper/capital/CapitalRepairLiftRelevanceMapper.xml

@@ -52,9 +52,7 @@
         pu.user_id        AS userId,
         pu.is_monitor     AS isMonitor
         FROM capital_repair cr
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
-            LEFT JOIN project_user pu ON cr.id = pu.project_id
-        </if>
+        LEFT JOIN project_user pu ON cr.id = pu.project_id
         WHERE 1=1
         <if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
             AND cr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
@@ -82,9 +80,7 @@
             SELECT count(1) total,
                 project_status
             FROM capital_repair cr
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
             LEFT JOIN project_user pu ON cr.id = pu.project_id
-        </if>
         WHERE cr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
             AND pu.user_id = #{request.userId,jdbcType=BIGINT}
@@ -140,12 +136,9 @@
         count(1)
         FROM capital_repair cr
         LEFT JOIN project_user pu ON cr.id = pu.project_id AND cr.mt_company_id = pu.mt_company_id
-        WHERE cr.project_status = '2'
-        <if test="request.userId != null and request.userId > 0">
-            AND pu.user_id = #{request.userId}
-        </if>
-        <if test="request.mtCompanyId != null and request.mtCompanyId > 0">
-            AND cr.mt_company_id = #{request.mtCompanyId}
+        WHERE cr.project_status = '2' AND cr.mt_company_id = #{request.mtCompanyId}
+        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.currentRoleCode == 'ROLEMTWORK' ">
+            AND pu.user_id = #{request.userId,jdbcType=BIGINT}
         </if>
     </select>
 </mapper>

+ 19 - 5
lift-business-service/src/main/resources/mapper/emergency/EmergencyRepairMapper.xml

@@ -150,6 +150,11 @@
         FROM
             emergency_repair er
             LEFT JOIN project pr ON er.project_id = pr.id AND pr.mt_company_id = er.mt_company_id
+            <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+                LEFT JOIN project_user pu ON pu.project_id = pr.id AND pu.mt_company_id = pr.mt_company_id
+                LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = pu.mt_company_id
+                         AND plr.project_id = pr.id AND plr.lift_id = er.lift_id
+            </if>
             LEFT JOIN region re ON pr.region_id = re.id
             LEFT JOIN lift li ON er.lift_id = li.id
             LEFT JOIN user_info ui ON ui.user_id = er.worker_id1
@@ -163,9 +168,6 @@
             <if test="cond.regionId != null and cond.regionId > 0">
                 AND pr.region_id = #{cond.regionId}
             </if>
-            <if test="cond.workerId != null">
-                AND er.worker_id1 = #{cond.workerId}
-            </if>
             <if test="cond.repairBegin != null">
                 AND date(er.caller_date) &gt;= #{cond.repairBegin}
             </if>
@@ -181,6 +183,17 @@
             <if test="cond.info != null and cond.info != ''">
                 AND li.registration_code LIKE concat('%',#{cond.info},'%')
             </if>
+            <if test="cond.workerId != null">
+                <choose>
+                    <when test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+                        AND pu.user_id = #{cond.userId,jdbcType=BIGINT}
+                    </when>
+                    <when test="cond.currentRoleCode == 'ROLEMTWORK' ">
+                        AND er.worker_id1 = #{cond.workerId}
+                    </when>
+                    <otherwise/>
+                </choose>
+            </if>
         </where>
     </select>
 
@@ -302,7 +315,10 @@
             count(1)
         FROM
             emergency_repair er
+        LEFT JOIN platform_company_lift_relevance pc
+             ON er.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND er.mt_company_id = pc.mt_company_id
         <if test="cond.currentRoleCode == 'REGION_DIRECTOR' or cond.currentRoleCode == 'CLERK' ">
+            LEFT JOIN project_lift_relevance pl ON pl.mt_company_id = pc.mt_company_id AND pl.lift_id = er.lift_id
             LEFT JOIN project_user pu ON er.project_id = pu.project_id AND er.mt_company_id = pu.mt_company_id
         </if>
         WHERE er.status = 1
@@ -334,8 +350,6 @@
         ON e.lift_id = pc.lift_id AND pc.lift_company_status !=1 AND e.mt_company_id = pc.mt_company_id
         <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
             LEFT JOIN project_lift_relevance pl ON pl.mt_company_id = pc.mt_company_id AND pl.lift_id = e.lift_id
-        </if>
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' ">
             LEFT JOIN project_user pu ON pl.project_id = pu.project_id AND pu.mt_company_id = pl.mt_company_id
         </if>
         WHERE e.mt_company_id = #{request.mtCompanyId}

+ 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>