瀏覽代碼

企业数据统计

黄远 5 年之前
父節點
當前提交
79037a8957

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

@@ -51,6 +51,11 @@ public class ApiConstants {
      */
     public static final String CURRENT_ROLE_ID = "currentRoleId";
 
+    /**
+     * 当前角色编码
+     */
+    public static final String CURRENT_ROLE_CODE = "currentRoleCode";
+
     /**
      * 当前权限路径
      */

+ 21 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/dao/dto/request/TodoRequest.java

@@ -10,6 +10,27 @@ import lombok.Data;
  */
 @Data
 public class TodoRequest {
+
+    /**
+     * 待办角色编码
+     */
+    private String currentRoleCode;
+
+    /**
+     * 当前用户id
+     */
+    private Long userId;
+
+    /**
+     * 区域主管idC
+     */
+    private Long regionChargeId;
+
+    /**
+     * 文员id
+     */
+    private String clerkId;
+
     /**
      * 公司id
      */

+ 16 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/homepage/service/TodoService.java

@@ -1,6 +1,7 @@
 package cn.com.ty.lift.system.homepage.service;
 
 import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.utils.ProjectUtils;
 import cn.com.ty.lift.system.constants.CommonConstants;
 import cn.com.ty.lift.system.homepage.dao.dto.request.TodoRequest;
@@ -48,6 +49,7 @@ public class TodoService {
      * @date 2020/2/14 10:55 上午
      */
     public RestResponse todoNum(TodoRequest todoRequest) {
+        handleTodoRequest(todoRequest);
         Map<Integer, Long> todoTypeToNum = CommonConstants.TODO_TYPE_TO_NUM;
         //1.设置行政待办事项数量
         //团队成员申请待办
@@ -78,6 +80,20 @@ public class TodoService {
                 ApiConstants.RESULT_SUCCESS, "获取待办数据成功");
     }
 
+    /**
+     * @param todoRequest 角色编码
+     * @description 通过角色来设置id值
+     * @date 2020/4/25 10:01 上午
+     */
+    private void handleTodoRequest(TodoRequest todoRequest) {
+        if (CommonEnum.DefaultRole.REGION_DIRECTOR.getCode().equals(todoRequest.getCurrentRoleCode())) {
+            todoRequest.setRegionChargeId(todoRequest.getUserId());
+        }
+        if(CommonEnum.DefaultRole.MTWORK.getCode().equals(todoRequest.getCurrentRoleCode())) {
+            todoRequest.setClerkId(todoRequest.getUserId().toString());
+        }
+    }
+
     /**
      * @param
      * @return

+ 1 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/user/service/impl/LoginService.java

@@ -267,6 +267,7 @@ public class LoginService implements ILoginService {
         Role role = userResponse.getRole();
         if (role != null) {
             currentUserInfoMap.put(ApiConstants.CURRENT_ROLE_ID, role.getId());
+            currentUserInfoMap.put(ApiConstants.CURRENT_ROLE_CODE, role.getCode());
         }
         //用户权限信息
         String permissionUrl = menuService.menuToUrl(ProjectUtils.deepCopy(userResponse.getMenus()));

+ 85 - 7
lift-system-service/src/main/resources/mapper/TodoDataMapper.xml

@@ -11,24 +11,51 @@
     <sql id="maintenanceTodoQuerySql">
         where
             mp.mt_company_id = #{mtCompanyId}
+        and
+            mp.status <![CDATA[ != ]]> 1
     </sql>
 
     <!-- 急修记录查询条件sql -->
     <sql id="emergencyTodoQuerySql">
         where
             er.mt_company_id = #{mtCompanyId}
+        and
+            er.status <![CDATA[ != ]]> 2
+        and
+            er.status <![CDATA[ != ]]> 3
+
     </sql>
 
     <!-- 大修记录查询条件sql -->
     <sql id="capitalTodoQuerySql">
         where
             cr.mt_company_id = #{mtCompanyId}
+        and
+            cr.projectStatus <![CDATA[ != ]]> 4
     </sql>
 
     <!-- 年检记录查询条件sql -->
     <sql id="annualInspectionTodoSql">
         where
             ai.mt_company_id = #{mtCompanyId}
+        and
+            ai.status = 1
+    </sql>
+
+    <!-- 区域项目查询 -->
+    <sql id="regionProjectSql">
+        <if test="clerkId != null || regionChargeId != null">
+            and p.region_id in (
+            select id from region r
+            where true
+            <if test="clerkId != null">
+                and r.cleck find_in_set(#{clerkId}, r.clerk)
+            </if>
+            <if test="regionChargeId != null">
+                and r.user_id = #{regionChargeId}
+            </if>
+            )
+        </if>
     </sql>
 
 
@@ -50,11 +77,21 @@
             lift l
         on
             mp.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            l.id = plr.lift_id
+        left join
+            project p
+        on 
+            plr.project_id = p.id
         left join
             user_info ui
         on
             mp.worker_id = ui.user_id
         <include refid="maintenanceTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by plan_date
         <include refid="pageQuerySql"/>
     </select>
 
@@ -89,6 +126,8 @@
         on
             er.worker_id = ui.user_id
         <include refid="emergencyTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by er.assign_time
         <include refid="pageQuerySql"/>
     </select>
 
@@ -97,15 +136,17 @@
             parameterType="cn.com.ty.lift.system.homepage.dao.dto.request.TodoRequest"
             resultType="cn.com.ty.lift.system.homepage.dao.dto.response.CapitalRepairResponse">
         select
-            cr.id as capitalRepairId,
-            cr.project_name as projectName,
-            cr.project_address as projectAddress,
-            cr.start_date as startDate,
-            cr.end_date as endDate,
-            cr.push_flag as pushFlag
+            p.id as capitalRepairId,
+            p.project_name as projectName,
+            p.project_address as projectAddress,
+            p.start_date as startDate,
+            p.end_date as endDate,
+            p.push_flag as pushFlag
         from
-            capital_repair cr
+            capital_repair p
         <include refid="capitalTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
+        order by p.create_date
         <include refid="pageQuerySql"/>
     </select>
 
@@ -142,6 +183,7 @@
         on
             ui.user_id = plr.worker_id
         <include refid="annualInspectionTodoSql"/>
+        <include refid="regionProjectSql"/>
         <include refid="pageQuerySql"/>
     </select>
 
@@ -199,7 +241,16 @@
             count(1)
         from
             emergency_repair er
+        left join
+            lift l
+        on
+            er.lift_id = l.id
+        left join
+            project p
+        on
+            er.project_id = p.id
         <include refid="emergencyTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取维保待办条数 -->
@@ -210,7 +261,20 @@
             count(1)
         from
             maintenance_plan mp
+        left join
+            lift l
+        on
+            mp.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            l.id = plr.lift_id
+        left join
+            project p
+        on
+            plr.project_id = p.id
         <include refid="maintenanceTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取大修待办条数 -->
@@ -222,6 +286,7 @@
         from
             capital_repair cr
         <include refid="capitalTodoQuerySql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
     <!-- 获取年检待办条数 -->
@@ -232,7 +297,20 @@
             count(1)
         from
             annual_inspection ai
+        left join
+            lift l
+        on
+            ai.lift_id = l.id
+        left join
+            project_lift_relevance plr
+        on
+            plr.lift_id = l.id
+        left join
+            project p
+        on
+            plr.project_id = p.id
         <include refid="annualInspectionTodoSql"/>
+        <include refid="regionProjectSql"/>
     </select>
 
 </mapper>