Pārlūkot izejas kodu

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

bieao 5 gadi atpakaļ
vecāks
revīzija
ca04af3abf

+ 0 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/mapper/EmergencyRepairMapper.java

@@ -34,7 +34,5 @@ public interface EmergencyRepairMapper extends BaseMapper<EmergencyRepair> {
 
     List<RepairResponse> listByIdList(@Param("cond") RepairRequest request);
 
-    long countDoingByWorker(@Param("cond") CommonRequest request);
-
     long countDoingByUser(@Param("cond") CommonRequest request);
 }

+ 1 - 10
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/service/EmergencyRepairService.java

@@ -511,15 +511,6 @@ public class EmergencyRepairService extends ServiceImpl<EmergencyRepairMapper, E
     }
 
     public long countDoingByUser(CommonRequest request){
-        String currentRoleCode = request.getCurrentRoleCode();
-        if(Objects.nonNull(currentRoleCode)){
-            if(Objects.equals(CommonEnum.DefaultRole.MTWORK.getCode(), currentRoleCode)){
-                return baseMapper.countDoingByWorker(request);
-            }else{
-                return baseMapper.countDoingByUser(request);
-            }
-        }else{
-            return 0;
-        }
+        return baseMapper.countDoingByUser(request);
     }
 }

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

@@ -8,6 +8,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequ
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtOptionTree;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtPlanResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.MtRecordResponse;
+import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceRecordMapper;
 import cn.com.ty.lift.business.maintenance.service.*;
 import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
@@ -56,6 +57,7 @@ public class MaintenanceRecordController {
     private MaintenanceOptionService    maintenanceOptionService;
     private ProjectLiftRelevanceService projectLiftRelevanceService;
     private EvaluationService           evaluationService;
+    private MaintenanceRecordMapper     maintenanceRecordMapper;
 
     /**
      * 根据条件分页查询维保-日常保养
@@ -314,7 +316,10 @@ public class MaintenanceRecordController {
     @PostMapping("fill")
     @Validation(fields = {"id", "maintenanceOption", "imgs"})
     public RestResponse fill(@Val @RequestBody MtRecordRequest request) {
-        MaintenanceRecord entity = maintenanceRecordService.getById(request.getId());
+        Long planId = request.getId();
+        //根据计划id获取记录id
+        Long recordId = maintenanceRecordMapper.getRecordIdByPlanId(planId);
+        MaintenanceRecord entity = maintenanceRecordService.getById(recordId);
         Validate.notNull(entity, ValuePool.MAINTENANCE_RECORD_NOT_EXIST);
 
         entity.setMaintenanceOption(request.getMaintenanceOption());

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

@@ -22,7 +22,7 @@ public class MtRecordRequest extends PageRequest {
     /**
      * 主键id
      */
-    @Min(value = 1,message = "维保记录ID有误")
+    @Min(value = 1,message = "维保计划ID有误")
     private Long id;
     /**
      * 电梯id

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

@@ -10,6 +10,7 @@ import cn.com.ty.lift.business.maintenance.dao.entity.model.response.*;
 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;
 
@@ -66,4 +67,7 @@ public interface MaintenanceRecordMapper extends BaseMapper<MaintenanceRecord> {
     MtRecordResponse infoById(@Param("cond") MtRecordRequest request);
 
     IPage<MtRecordResponse> pageByLift(IPage<MtRecordResponse> page, @Param("cond") MtRecordRequest request);
+
+    @Select("SELECT id FROM maintenance_record WHERE mt_plan_id = #{planId}")
+    Long getRecordIdByPlanId(Long planId);
 }

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

@@ -297,33 +297,26 @@
 		</where>
 	</select>
 
-    <select id="countDoingByWorker" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.common.CommonRequest">
-        SELECT
-            count(*)
-        FROM
-            emergency_repair er
-        WHERE er.status IN (0, 1)
-        <if test="cond.userId != null and cond.userId > 0">
-            AND er.worker_id1 = #{cond.userId}
-        </if>
-        <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
-            AND er.mt_company_id = #{cond.mtCompanyId}
-        </if>
-
-    </select>
-
     <select id="countDoingByUser" resultType="java.lang.Long" parameterType="cn.com.ty.lift.business.common.CommonRequest">
         SELECT
-            count(*)
+            count(1)
         FROM
             emergency_repair er
+        <if test="cond.currentRoleCode == 'REGION_DIRECTOR'">
             LEFT JOIN project_user pu ON er.project_id = pu.project_id AND er.mt_company_id = pu.mt_company_id
-        WHERE er.status IN (0, 1)
-        <if test="cond.userId != null and cond.userId > 0">
-            AND pu.user_id = #{cond.userId}
         </if>
+        WHERE er.status = 1
         <if test="cond.mtCompanyId != null and cond.mtCompanyId > 0">
             AND er.mt_company_id = #{cond.mtCompanyId}
         </if>
+        <choose>
+            <when test="cond.userId != null and cond.currentRoleCode == 'REGION_DIRECTOR' ">
+                AND pu.user_id = #{cond.userId,jdbcType=BIGINT}
+            </when>
+            <when test="cond.userId != null and cond.currentRoleCode == 'ROLEMTWORK' ">
+                AND er.worker_id1 = #{cond.userId,jdbcType=BIGINT}
+            </when>
+            <otherwise/>
+        </choose>
     </select>
 </mapper>

+ 12 - 4
lift-business-service/src/main/resources/mapper/maintenance/MaintenancePlanMapper.xml

@@ -278,15 +278,23 @@
 		SELECT
 			count(1)
 		FROM maintenance_plan mp
-		LEFT JOIN project_user pu ON pu.project_id = mp.project_id AND pu.mt_company_id = mp.mt_company_id
+		<if test="request.currentRoleCode == 'REGION_DIRECTOR'">
+			LEFT JOIN project_user pu ON pu.project_id = mp.project_id AND pu.mt_company_id = mp.mt_company_id
+		</if>
 		WHERE mp.status = '0'
 		AND mp.plan_date = current_date()
-		<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 mp.mt_company_id = #{request.mtCompanyId}
 		</if>
+		<choose>
+			<when test="request.userId != null and request.currentRoleCode == 'REGION_DIRECTOR' ">
+				AND pu.user_id = #{request.userId,jdbcType=BIGINT}
+			</when>
+			<when test="request.userId != null and request.currentRoleCode == 'ROLEMTWORK' ">
+				AND mp.worker_id = #{request.userId,jdbcType=BIGINT}
+			</when>
+			<otherwise/>
+		</choose>
 	</select>
 
 	<select id="exportList" parameterType="java.util.List" resultType="java.util.Map">

+ 2 - 1
lift-business-service/src/main/resources/mapper/project/ProjectLiftRelevanceMapper.xml

@@ -43,7 +43,8 @@
 		  LEFT JOIN lift l ON plr.lift_id = l.id
 		  LEFT JOIN platform_company_lift_relevance pclr
 					ON l.id = pclr.lift_id AND plr.mt_company_id = pclr.mt_company_id
-		WHERE plr.worker_id = #{request.workerId,jdbcType=BIGINT}
+		WHERE plr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
+		   AND plr.worker_id = #{request.workerId,jdbcType=BIGINT}
 	</select>
 
 	<select id="count" resultType="java.lang.Integer">