Browse Source

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

bieao 5 years ago
parent
commit
66e02a1783

+ 3 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/capital/dao/entity/model/request/CapitalRepairRequest.java

@@ -168,4 +168,7 @@ public class CapitalRepairRequest extends PageRequest {
      * 项目编号
      */
     private String projectCode;
+
+
+    private String currentRoleCode;
 }

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

@@ -108,7 +108,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
      * @date 2020/1/13 11:30 上午
      */
     public boolean calc(String liftCoordinate, String coordinate) {
-        double expected = 200;
+        double expected = 500;
         double result = MapHelper.GetPointDistance(liftCoordinate, coordinate);
         return (result * 1000) > expected;
     }

+ 2 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/project/controller/ProjectController.java

@@ -153,7 +153,8 @@ public class ProjectController {
     @PostMapping("add")
     @Validation(fields = {"userList"})
     public RestResponse add(@Val @RequestBody ProjectRequest request) {
-        Validator.valid(request.getProject(), "mtCompanyId", "ppCompanyId");
+        Validator.valid(request.getProject(), "mtCompanyId", "ppCompanyId", "ppContactId", "projectName",
+                "address", "num", "startDate", "endDate", "regionId", "projectUsage");
         return projectService.add(request);
     }
 

+ 9 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/Project.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import javax.validation.constraints.NotEmpty;
 import javax.validation.constraints.NotNull;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -45,6 +46,7 @@ public class Project extends BaseEntity {
      * 甲方联系人ID
      */
     @FieldName(name = "甲方联系人ID")
+    @NotNull(message = "甲方联系人ID不能为空")
     private Long ppContactId;
 
     /**
@@ -57,6 +59,7 @@ public class Project extends BaseEntity {
      * 项目名称
      */
     @FieldName(name = "项目名称")
+    @NotEmpty(message = "项目名称不能为空")
     private String projectName;
 
     /**
@@ -99,12 +102,14 @@ public class Project extends BaseEntity {
      * 项目地址
      */
     @FieldName(name = "项目地址")
+    @NotEmpty(message = "项目地址不能为空")
     private String address;
 
     /**
      * 台量
      */
     @FieldName(name = "台量")
+    @NotNull(message = "项目台量不能为空")
     private Integer num;
 
     /**
@@ -117,18 +122,21 @@ public class Project extends BaseEntity {
      * 用途 1.住宅2.办公楼3.医院4.商场5.工厂6.酒店7.交通枢纽8.学校9.剧场10.其他
      */
     @FieldName(name = "用途")
+    @NotEmpty(message = "项目用途不能为空")
     private String projectUsage;
 
     /**
      * 开始时间
      */
     @FieldName(name = "开始时间")
+    @NotNull(message = "开始时间不能为空")
     private LocalDate startDate;
 
     /**
      * 结束时间
      */
     @FieldName(name = "结束时间")
+    @NotNull(message = "结束时间不能为空")
     private LocalDate endDate;
 
     /**
@@ -177,6 +185,7 @@ public class Project extends BaseEntity {
      * 区域ID
      */
     @FieldName(name = "区域ID")
+    @NotNull(message = "区域ID不能为空")
     private Long regionId;
     /**
      * 是否保存

+ 5 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/model/request/ProjectRequest.java

@@ -163,4 +163,9 @@ public class ProjectRequest extends PageRequest {
 
     private String currentRoleCode;
 
+    /**
+     * 是否能查看到项目下其他维保工的电梯
+     */
+    private String look;
+
 }

+ 9 - 16
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectAppService.java

@@ -124,6 +124,12 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
      * @date 2019/12/31 3:13 PM
      */
     public IPage<ProjectLiftResponse> projectLiftList(ProjectRequest request) {
+        if (DefaultRole.MTWORK.getCode().equals(request.getCurrentRoleCode())) {
+            String globalSet = maintenanceRecordMapper.getGlobalSet(request.getMtCompanyId());
+            if (Objects.isNull(globalSet)) globalSet = "0";
+            //是否能查看到项目下其他维保工的电梯
+            request.setLook(Objects.equals("0", globalSet) ? "0" : "1");
+        }
         return baseMapper.findListByProjectId(request.getPage(), request);
     }
 
@@ -226,11 +232,7 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
             String globalSet = maintenanceRecordMapper.getGlobalSet(request.getMtCompanyId());
             if (Objects.isNull(globalSet)) globalSet = "0";
             //维保工不能查看到项目组其他维保工的任务
-            if (Objects.equals("0", globalSet)) {
-                request.setLook("0");
-            } else {
-                request.setLook("1");
-            }
+            request.setLook(Objects.equals("0", globalSet) ? "0" : "1");
         }
         //总经理查询所有保养任务
         if (DefaultRole.HIGH_DIRECTOR.getCode().equals(request.getCurrentRoleCode())) {
@@ -273,16 +275,11 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
         if (Objects.nonNull(request.getBeginTime())) {
             request.setEndTime(request.getBeginTime().with(TemporalAdjusters.lastDayOfMonth()));
         }
-        log.info("角色名称:" + request.getCurrentRoleCode());
         if (DefaultRole.MTWORK.getCode().equals(request.getCurrentRoleCode())) {
             String globalSet = maintenanceRecordMapper.getGlobalSet(request.getMtCompanyId());
             if (Objects.isNull(globalSet)) globalSet = "0";
             //维保工不能查看到项目组其他维保工的任务
-            if (Objects.equals("0", globalSet)) {
-                request.setLook("0");
-            } else {
-                request.setLook("1");
-            }
+            request.setLook(Objects.equals("0", globalSet) ? "0" : "1");
         }
         //总经理查询所有保养任务
         if (DefaultRole.HIGH_DIRECTOR.getCode().equals(request.getCurrentRoleCode())) {
@@ -333,11 +330,7 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
             String globalSet = maintenanceRecordMapper.getGlobalSet(request.getMtCompanyId());
             if (Objects.isNull(globalSet)) globalSet = "0";
             //维保工不能查看到项目组其他维保工的任务
-            if (Objects.equals("0", globalSet)) {
-                request.setLook("0");
-            } else {
-                request.setLook("1");
-            }
+            request.setLook(Objects.equals("0", globalSet) ? "0" : "1");
         }
         //总经理查询所有保养任务
         if (DefaultRole.HIGH_DIRECTOR.getCode().equals(request.getCurrentRoleCode())) {

+ 2 - 0
lift-business-service/src/main/resources/mapper/capital/CapitalRepairLiftRelevanceMapper.xml

@@ -18,6 +18,7 @@
         id, mt_company_id, project_id, lift_id, worker_id, delete_flag, creator_id, create_date, update_id, update_date
     </sql>
 
+    <!--app端 根据项目id查询项目下电梯列表 -->
     <select id="findListByProjectId" resultType="cn.com.ty.lift.business.project.dao.entity.model.response.ProjectLiftResponse"
             parameterType="cn.com.ty.lift.business.capital.dao.entity.model.request.CapitalRepairRequest">
         SELECT
@@ -28,6 +29,7 @@
             l.lift_type         AS liftType,
             l.use_company_code  AS useCompanyCode
         FROM capital_repair_lift_relevance crlr
+                 LEFT JOIN project_user pu ON crlr.project_id = pu.project_id
                  LEFT JOIN lift l ON crlr.lift_id = l.id
                  LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
         WHERE crlr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}

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

@@ -150,14 +150,14 @@
 		       mp.status           AS status
 		FROM maintenance_plan mp
 				 LEFT JOIN project p ON mp.project_id = p.id
-				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
 					LEFT JOIN project_user pu ON p.id = pu.project_id
 				</if>
 				 LEFT JOIN lift l ON mp.lift_id = l.id
 				 LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
 		 WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		  <choose>
-			  <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+			  <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
 				  AND pu.user_id = #{request.userId,jdbcType=BIGINT}
 			  </when>
 		      <when test="request.userId !=null">
@@ -191,14 +191,14 @@
 				  count(1) total
 		FROM maintenance_plan mp
 				LEFT JOIN project p ON mp.project_id = p.id
-				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1">
+				<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1">
 					LEFT JOIN project_user pu ON p.id = pu.project_id
 				</if>
 				LEFT JOIN lift l ON mp.lift_id = l.id
 				LEFT JOIN user_info ui ON mp.worker_id = ui.user_id
 		WHERE mp.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		<choose>
-			<when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+			<when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
 				AND pu.user_id = #{request.userId,jdbcType=BIGINT}
 			</when>
 			<when test="request.userId !=null">

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

@@ -122,14 +122,14 @@
 		    mr.has_evaluate     AS hasEvaluate
 		FROM maintenance_record mr
 		LEFT JOIN project p ON mr.project_id = p.id
-        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+        <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
             LEFT JOIN project_user pu ON p.id = pu.project_id
         </if>
 		LEFT JOIN lift l ON mr.lift_id = l.id
 		LEFT JOIN user_info ui ON mr.worker_id = ui.user_id
 		WHERE mr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <choose>
-            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
                 AND pu.user_id = #{request.userId,jdbcType=BIGINT}
             </when>
             <when test="request.userId !=null">
@@ -163,14 +163,14 @@
                  count(1) total
         FROM maintenance_record mr
                 LEFT JOIN project p ON mr.project_id = p.id
-                <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+                <if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
                     LEFT JOIN project_user pu ON p.id = pu.project_id
                 </if>
                 LEFT JOIN lift l ON mr.lift_id = l.id
                 LEFT JOIN user_info ui ON mr.worker_id = ui.user_id
         WHERE mr.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
         <choose>
-            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.look == 1 ">
+            <when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
                 AND pu.user_id = #{request.userId,jdbcType=BIGINT}
             </when>
             <when test="request.userId !=null">
@@ -265,7 +265,7 @@
     <!--日常保养-保养单:根据id查询,带关联信息-->
     <select id="infoById" resultMap="BaseResultMap"
             parameterType="cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest">
-        SELECT
+        SELECT DISTINCT
         mr.*,
         li.use_company_code,
         li.registration_code,

+ 18 - 0
lift-business-service/src/main/resources/mapper/project/ProjectMapper.xml

@@ -167,6 +167,9 @@
 		p.actual_num    AS actualNum,
 		p.project_status AS projectStatus
 		FROM project p
+		<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'ROLEMTWORK' or request.currentRoleCode == 'CLERK' ">
+			LEFT JOIN project_user pu ON p.id = pu.project_id
+		</if>
 		WHERE (project_status = '1' OR project_status = '2' OR project_status = '4')
 		<if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
 			AND p.mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
@@ -174,6 +177,9 @@
 		<if test="request.projectName!=null and request.projectName!=''">
 			AND p.project_name LIKE CONCAT('%',#{request.projectName,jdbcType=VARCHAR},'%')
 		</if>
+		<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'ROLEMTWORK' or request.currentRoleCode == 'CLERK' ">
+			AND pu.user_id = #{request.userId,jdbcType=BIGINT}
+		</if>
 	</select>
 
 	<!--app端 根据项目id查询项目下电梯列表 -->
@@ -187,6 +193,9 @@
 		  l.lift_type         AS liftType,
 		  l.use_company_code  AS useCompanyCode
 		FROM project_lift_relevance plr
+		<if test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
+			LEFT JOIN project_user pu ON plr.project_id = pu.project_id
+		</if>
 		  LEFT JOIN lift l ON plr.lift_id = l.id
 		  LEFT JOIN lift_brand lb ON l.lift_brand = lb.code
 		  WHERE 1=1
@@ -196,6 +205,15 @@
 		<if test="request.registrationCode!=null and request.registrationCode!=''">
 			AND l.registration_code LIKE CONCAT('%',#{request.registrationCode,jdbcType=VARCHAR},'%')
 		</if>
+		<choose>
+			<when test="request.currentRoleCode == 'REGION_DIRECTOR' or request.currentRoleCode == 'CLERK' or request.look == 1 ">
+				AND pu.user_id = #{request.userId,jdbcType=BIGINT}
+			</when>
+			<when test="request.currentRoleCode == 'ROLEMTWORK' and request.look == 0 ">
+				AND plr.worker_id = #{request.userId,jdbcType=BIGINT}
+			</when>
+			<otherwise/>
+		</choose>
 	</select>
 
 	<!--app端 根据项目id查询项目详情 -->