Просмотр исходного кода

1.控制台任务统计部门查询条件调整

wuhp 1 год назад
Родитель
Сommit
69183c5861

+ 3 - 0
src/main/java/com/ydtech/modules/admin/model/vo/TaskStatisticsVo.java

@@ -175,4 +175,7 @@ public class TaskStatisticsVo implements Serializable {
 
 
     @ApiModelProperty(value = "传参任务类型")
     @ApiModelProperty(value = "传参任务类型")
     private String taskType;
     private String taskType;
+
+    @ApiModelProperty(value = "控制台部门关系用户id")
+    private String relationUserId;
 }
 }

+ 4 - 0
src/main/java/com/ydtech/modules/admin/service/impl/TaskStatisticsServiceImpl.java

@@ -377,6 +377,10 @@ public class TaskStatisticsServiceImpl  implements TaskStatisticsService {
         HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDays(), taskStatisticsVo.getBeginDate(), taskStatisticsVo.getEndDate());
         HashMap<String, String> dateMapByType = getDateMapByTypeNew(taskStatisticsVo.getDays(), taskStatisticsVo.getBeginDate(), taskStatisticsVo.getEndDate());
         taskStatisticsVo.setBeginDate(dateMapByType.get("startDate"));
         taskStatisticsVo.setBeginDate(dateMapByType.get("startDate"));
         taskStatisticsVo.setEndDate(dateMapByType.get("endDate"));
         taskStatisticsVo.setEndDate(dateMapByType.get("endDate"));
+        String userId = BaseController.getUserId();
+        if(!taskStatisticsVo.getDeptIds().isEmpty()){
+            taskStatisticsVo.setRelationUserId(userId);
+        }
 
 
         IPage<TaskStatisticsDto> list = this.insAreaCompanyMapper.agentStatisticsQueryPage(page,taskStatisticsVo);
         IPage<TaskStatisticsDto> list = this.insAreaCompanyMapper.agentStatisticsQueryPage(page,taskStatisticsVo);
         Long total = this.insAreaCompanyMapper.agentStatisticsQueryPageTotal(taskStatisticsVo);
         Long total = this.insAreaCompanyMapper.agentStatisticsQueryPageTotal(taskStatisticsVo);

+ 75 - 81
src/main/resources/mapper/modules/order/InsAreaCompanyMapper.xml

@@ -1633,94 +1633,88 @@
         ) total
         ) total
     </select>
     </select>
 
 
-    <select id="agentStatisticsQueryPage"  resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
 
 
+    <select id="agentStatisticsQueryPage" resultType="com.ydtech.modules.admin.model.dto.TaskStatisticsDto">
         SELECT
         SELECT
-        sd.name as "deptName",
-        su.name as "userName",
-        io.userid as "userId",
-        sd.id as "deptId",
-        suLeader.name as "leaderName",
-        suLeader.mobile as "leaderMobile",
-        sd.management_source as "managementSource",
-        COUNT( CASE WHEN iot.order_status  = '0' THEN 1 END ) AS qutationCount,
-        COUNT( CASE WHEN iot.order_status  = '2' THEN 1 END ) AS underwritingCount,
-        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END ) AS qutationInsureCount,
-        COUNT( CASE WHEN iot.order_status =  '4' THEN 1 END ) AS underwritingReturn,
-        COUNT( CASE WHEN iot.order_status = '2' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as "passingRate",
-        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END )  /  COUNT( CASE WHEN iot.order_status ='0' THEN 1 END )  as "closeRate",
-        COUNT( CASE WHEN iot.order_status =  '3' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as  "contributionRate",
-        COUNT( CASE WHEN iot.order_status =  '0' THEN 1 END )  /  COUNT( CASE WHEN  iot.order_status in ('0','1','2','3','4') THEN 1 END )  as "quotationRate",
-        COUNT( CASE WHEN iot.order_status =  '1' THEN 1 END  )   as  "auditOrder"
+        sd.name AS "deptName",
+        su.name AS "userName",
+        io.userid AS "userId",
+        sd.id AS "deptId",
+        suLeader.name AS "leaderName",
+        suLeader.mobile AS "leaderMobile",
+        sd.management_source AS "managementSource",
+        COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS qutationCount,
+        COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) AS underwritingCount,
+        COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) AS qutationInsureCount,
+        COUNT(CASE WHEN iot.order_status = '4' THEN 1 END) AS underwritingReturn,
+        COUNT(CASE WHEN iot.order_status = '2' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3', '4') THEN 1 END) AS "passingRate",
+        COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) AS "closeRate",
+        COUNT(CASE WHEN iot.order_status = '3' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3', '4') THEN 1 END) AS "contributionRate",
+        COUNT(CASE WHEN iot.order_status = '0' THEN 1 END) / COUNT(CASE WHEN iot.order_status IN ('0', '1', '2', '3', '4') THEN 1 END) AS "quotationRate",
+        COUNT(CASE WHEN iot.order_status = '1' THEN 1 END) AS "auditOrder"
         FROM
         FROM
         (
         (
-        select DISTINCT iot.suborder,iot.order_status from `ins_orders_track` iot
-        ) iot
+        SELECT iot.suborder, iot.order_status
+        FROM ins_orders_track iot
         LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
         LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
-        left join ins_orders io on io.orderno = iac.orderno
-        left join sys_dept sd on sd.id=io.deptid
-        left join sys_user su on su.id=io.userid
-        left join sys_user suLeader on suLeader.id =su.leader_id
-        <where>
-            sd.management_source = '2'
-            and (iac.del_flag = '1' or io.del_flag IS NULL or io.del_flag = 1)
-            <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
-                and io.deptid like "${taskStatisticsVo.provinceId}%"
-            </if>
-            <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
-                and io.deptid like "${taskStatisticsVo.cityId}%"
-            </if>
-            <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
-                and io.deptid like "${taskStatisticsVo.countyId}%"
-            </if>
-            <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
-                and io.deptid like "${taskStatisticsVo.houseId}%"
-            </if>
-            <if test="taskStatisticsVo.userId !=null  and  taskStatisticsVo.userId!='' ">
-                and io.userid =#{taskStatisticsVo.userId}
-            </if>
-            <if test='taskStatisticsVo.userName !=null and taskStatisticsVo.userName!="" '>
-                and su.name like concat('%',#{taskStatisticsVo.userName},'%')
-            </if>
-            <if test='taskStatisticsVo.leaderId !=null and taskStatisticsVo.leaderId!="" '>
-                and su.leader_id  =#{taskStatisticsVo.leaderId}
-            </if>
-<!--        -->
-<!--            <if test='taskStatisticsVo.userId !=null and taskStatisticsVo.userId!="" '>-->
-<!--                and su.id =#{taskStatisticsVo.userId}-->
-<!--            </if>-->
-
-            <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
-                AND su.leader_id   in
-                <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-
-            <if test="taskStatisticsVo.createtimeStart !=null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd !=null and taskStatisticsVo.createtimeEnd != ''">
-                AND   DATE_FORMAT( io.createtime, '%Y-%m-%d')   BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
-            </if>
-
-            <if test="taskStatisticsVo.beginDate !=null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate !=null and taskStatisticsVo.endDate != ''">
-                AND   DATE_FORMAT( iac.createtime, '%Y-%m-%d')   BETWEEN DATE_FORMAT( #{taskStatisticsVo.beginDate}, '%Y-%m-%d')  AND DATE_FORMAT( #{taskStatisticsVo.endDate}, '%Y-%m-%d')
-            </if>
-
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_dept sd ON sd.id = io.deptid
+        LEFT JOIN sys_user su ON su.id = io.userid
+        WHERE
+        sd.management_source = '2'
+        AND (iac.del_flag = '1' OR io.del_flag IS NULL OR io.del_flag = 1)
+        <if test="taskStatisticsVo.provinceId != null and taskStatisticsVo.provinceId != ''">
+            AND io.deptid LIKE '${taskStatisticsVo.provinceId}%'
+        </if>
+        <if test="taskStatisticsVo.cityId != null and taskStatisticsVo.cityId != ''">
+            AND io.deptid LIKE '${taskStatisticsVo.cityId}%'
+        </if>
+        <if test="taskStatisticsVo.countyId != null and taskStatisticsVo.countyId != ''">
+            AND io.deptid LIKE '${taskStatisticsVo.countyId}%'
+        </if>
+        <if test="taskStatisticsVo.houseId != null and taskStatisticsVo.houseId != ''">
+            AND io.deptid LIKE '${taskStatisticsVo.houseId}%'
+        </if>
+        <if test="taskStatisticsVo.userId != null and taskStatisticsVo.userId != ''">
+            AND io.userid = #{taskStatisticsVo.userId}
+        </if>
+        <if test="taskStatisticsVo.userName != null and taskStatisticsVo.userName != ''">
+            AND su.name LIKE CONCAT('%', #{taskStatisticsVo.userName}, '%')
+        </if>
+        <if test="taskStatisticsVo.leaderId != null and taskStatisticsVo.leaderId != ''">
+            AND su.leader_id = #{taskStatisticsVo.leaderId}
+        </if>
+        <if test="taskStatisticsVo.leaderIds != null and taskStatisticsVo.leaderIds != '' and taskStatisticsVo.leaderIds.size() > 0">
+            AND su.leader_id IN
+            <foreach collection="taskStatisticsVo.leaderIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        <if test="taskStatisticsVo.createtimeStart != null and taskStatisticsVo.createtimeStart != '' and taskStatisticsVo.createtimeEnd != null and taskStatisticsVo.createtimeEnd != ''">
+            AND DATE_FORMAT(io.createtime, '%Y-%m-%d') BETWEEN #{taskStatisticsVo.createtimeStart} AND #{taskStatisticsVo.createtimeEnd}
+        </if>
+        <if test="taskStatisticsVo.beginDate != null and taskStatisticsVo.beginDate != '' and taskStatisticsVo.endDate != null and taskStatisticsVo.endDate != ''">
+            AND DATE_FORMAT(iac.createtime, '%Y-%m-%d') BETWEEN DATE_FORMAT(#{taskStatisticsVo.beginDate}, '%Y-%m-%d') AND DATE_FORMAT(#{taskStatisticsVo.endDate}, '%Y-%m-%d')
+        </if>
 
 
-            <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
-                AND sd.id  in
-                <foreach collection="taskStatisticsVo.deptIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
-            <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
-                AND io.userid  in
-                <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
-                    #{item}
-                </foreach>
-            </if>
+        <if test="taskStatisticsVo.deptIds != null and taskStatisticsVo.deptIds != '' and taskStatisticsVo.deptIds.size() > 0">
+            AND sd.id in ( select dept_id from sys_user_dept_relationship where user_id =#{taskStatisticsVo.relationUserId} )
+        </if>
 
 
-        </where>
-        GROUP BY io.userid , su.name, sd.id , sd.name,suLeader.name,suLeader.mobile,sd.management_source
+        <if test="taskStatisticsVo.userIds != null and taskStatisticsVo.userIds != '' and taskStatisticsVo.userIds.size() > 0">
+            AND io.userid IN
+            <foreach collection="taskStatisticsVo.userIds" item="item" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY iot.suborder, iot.order_status
+        ) iot
+        LEFT JOIN ins_area_company iac ON iac.id = iot.suborder
+        LEFT JOIN ins_orders io ON io.orderno = iac.orderno
+        LEFT JOIN sys_dept sd ON sd.id = io.deptid
+        LEFT JOIN sys_user su ON su.id = io.userid
+        LEFT JOIN sys_user suLeader ON suLeader.id = su.leader_id
+        GROUP BY io.userid, su.name, sd.id, sd.name, suLeader.name, suLeader.mobile, sd.management_source
     </select>
     </select>