shudonghui 1 рік тому
батько
коміт
fbf07bfb82

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/ServiceAnalyseController.java

@@ -138,7 +138,7 @@ public class ServiceAnalyseController {
         map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId, regionId, null));
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, supplierId);
         map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
-        map.put("regionCities", crmAllocation.stream().collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
+        map.put("regionCities", crmAllocation.stream().filter(e->e.getCity()!=null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
         return ResultUtil.ok(map);
     }
 

+ 23 - 17
sop-business/src/main/java/com/qmth/sop/business/service/impl/ServiceAnalyseServiceImpl.java

@@ -60,25 +60,31 @@ public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper,
         Map<String, Object> map = new HashMap<>();
         List<Map<String, Object>> list = this.baseMapper.projectProgress(serviceUnitId);
         int crmNum = list.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size();
-        final int[] finish = {0, 0};
+        final int[] finish = {0};
         list.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no")))
-                .forEach((k, v) -> {
-                    v.stream().collect(Collectors.groupingBy(map2 -> map2.get("type"))).forEach((k1, v1) -> {
-                        if (ProductTypeEnum.OFFICE.toString().equals(k1)) {
-                            if (v1.stream().anyMatch(map3 -> "FINISH".equals(map3.get("status"))) && v1.stream().noneMatch(map3 -> "FINISH".equals(map3.get("START")))) {
-                                finish[1] = finish[1] + 1;
-                            }
-                        } else if (ProductTypeEnum.CLOUD_MARK.toString().equals(k1)) {
-                            if (v1.stream().filter(map3 -> map3.get("sop_no") != null).count() == v1.stream().filter(map3 -> "FINISH".equals(map3.get("status"))).count()) {
-                                finish[1] = finish[1] + 1;
-                            }
-                        }
-
-                    });
-
+                .forEach((k1, v1) -> {
+                    if (v1.stream().filter(map2 -> map2.get("sop_no") != null).count() == v1.stream().filter(map2 -> "FINISH".equals(map2.get("status"))).count()) {
+                        finish[0] = finish[0] + 1;
+                    }
                 });
-
-        map.put("projectProgress", (finish[0] + finish[1])*100 / crmNum);
+//        list.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no")))
+//                .forEach((k, v) -> {
+//                    v.stream().filter(map3->map3.get("type")!=null).collect(Collectors.groupingBy(map2 -> map2.get("type"))).forEach((k1, v1) -> {
+//                        if (ProductTypeEnum.OFFICE.toString().equals(k1)) {
+//                            if (v1.stream().anyMatch(map3 -> "FINISH".equals(map3.get("status"))) && v1.stream().noneMatch(map3 -> "FINISH".equals(map3.get("START")))) {
+//                                finish[0] = finish[0] + 1;
+//                            }
+//                        } else if (ProductTypeEnum.CLOUD_MARK.toString().equals(k1)) {
+//                            if (v1.stream().filter(map3 -> map3.get("sop_no") != null).count() == v1.stream().filter(map3 -> "FINISH".equals(map3.get("status"))).count()) {
+//                                finish[1] = finish[1] + 1;
+//                            }
+//                        }
+//
+//                    });
+//
+//                });
+
+        map.put("projectProgress", (finish[0])*100 / crmNum);
         map.put("equipmentOutboundTotal", this.baseMapper.equipmentOutboundTotal(serviceUnitId));
         Integer outboundTotal = this.baseMapper.equipmentOutboundTotal(null);
         int totalDevices = sysDeviceService.count(new LambdaQueryWrapper<SysDevice>().eq(SysDevice::getStatus, DeviceStatusEnum.NORMAL));

+ 5 - 31
sop-business/src/main/resources/mapper/CrmAnalyseMapper.xml

@@ -2,37 +2,10 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.CrmAnalyseMapper">
     <select id="region" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
-        <!--        SELECT-->
-        <!--        r.id,-->
-        <!--        r.region_name,-->
-        <!--        count( c.id ) count-->
-        <!--        FROM-->
-        <!--        t_b_crm c-->
-        <!--        LEFT JOIN sys_custom cu ON cu.id = c.custom_id-->
-        <!--        LEFT JOIN t_b_service s ON c.service_id = s.id-->
-        <!--        left join t_b_service_region r on r.service_id=s.id-->
-        <!--        <where>-->
-        <!--            and s.`status`='PUBLISH' and c.service_id is not null and r.id is not null-->
-        <!--            <if test="type != null and type != ''">-->
-        <!--                and cu.type = #{type}-->
-        <!--            </if>-->
-        <!--&lt;!&ndash;            <if test="year != null and year != ''">&ndash;&gt;-->
-        <!--&lt;!&ndash;                and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}&ndash;&gt;-->
-        <!--&lt;!&ndash;            </if>&ndash;&gt;-->
-        <!--            <if test="startTime != null">-->
-        <!--                AND s.start_time >= #{startTime}-->
-        <!--            </if>-->
-        <!--            <if test="endTime != null">-->
-        <!--                AND #{endTime} >= s.start_time-->
-        <!--            </if>-->
-        <!--        </where>-->
-        <!--        GROUP BY-->
-        <!--        r.id,-->
-        <!--        r.region_name-->
-        <!--        order by count( c.id )-->
+
         SELECT
         <!--        r.id,-->
-        rd.province name,
+        cu.province name,
         count(DISTINCT c.id ) count
         FROM
         t_b_crm c
@@ -41,7 +14,7 @@
         left join t_b_service_region r on r.service_id=s.id
         left join t_b_service_region_detail rd on rd.service_region_id=r.id
         <where>
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.service_id is not null and r.id is not null
+            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.status!='FINISH'
             <if test="type != null and type != ''">
                 and cu.type = #{type}
             </if>
@@ -62,7 +35,7 @@
         </where>
         GROUP BY
         <!--        r.id,-->
-        rd.province
+        cu.province
         order by count(DISTINCT c.id ) desc
     </select>
     <select id="project" resultType="java.util.Map">
@@ -84,6 +57,7 @@
         <where>
             s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.crm_no is not null
             and c.service_id is not null and c.enable=1
+<!--            and c.`status`!='UN_PUBLISH'-->
             <!--            <if test="year != null and year != ''">-->
             <!--                and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}-->
             <!--            </if>-->

+ 79 - 50
sop-business/src/main/resources/mapper/ServiceAnalyseMapper.xml

@@ -60,60 +60,56 @@
         </where>
     </select>
     <select id="servicePersonnelTotal" resultType="java.lang.Integer">
-<!--        SELECT-->
-<!--        count( sd.region_user_id )+-->
-<!--        count( sd.engineer_user_id )+-->
-<!--        SUM( length( sd.assistant_engineer_user_ids )- length( REPLACE ( sd.assistant_engineer_user_ids, ',', '' ))+ 1 )-->
-<!--        FROM-->
-<!--        t_b_service s-->
-<!--        LEFT JOIN t_b_sop_info sop ON sop.service_id = s.id-->
-<!--        LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = sop.id-->
-<!--        SELECT-->
-<!--        count(DISTINCT s.user_id)-->
-<!--        FROM-->
-<!--        t_b_user_archives_allocation s-->
+        SELECT count( DISTINCT region_user_id )+ count( DISTINCT user_id )  from
 
-        SELECT count(DISTINCT id)  FROM sys_user  WHERE
-        id IN (
-        SELECT a.lead_id  FROM t_b_sop_info_detail a
-        left join t_b_sop_info i on a.sop_info_id=i.id
+        t_b_user_archives_allocation
+                <where>
+                    <if test="serviceUnitId != null and serviceUnitId != ''">
+                        and service_id = #{serviceUnitId}
+                    </if>
 
-        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no
-        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id
-        <where>
-            and tffa.status!='FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and i.service_id = #{serviceUnitId}
-            </if>
+                </where>
+<!--        SELECT count(DISTINCT id)  FROM sys_user  WHERE-->
+<!--        id IN (-->
+<!--        SELECT a.lead_id  FROM t_b_sop_info_detail a-->
+<!--        left join t_b_sop_info i on a.sop_info_id=i.id-->
 
-        </where>
-        UNION ALL
-        SELECT a.region_user_id  FROM t_b_sop_info_detail a
-        left join t_b_sop_info i on a.sop_info_id=i.id
+<!--        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no-->
+<!--        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id-->
+<!--        <where>-->
+<!--            and tffa.status!='FINISH'-->
+<!--            <if test="serviceUnitId != null and serviceUnitId != ''">-->
+<!--                and i.service_id = #{serviceUnitId}-->
+<!--            </if>-->
 
-        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no
-        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id
-        <where>
-            and tffa.status!='FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and i.service_id = #{serviceUnitId}
-            </if>
+<!--        </where>-->
+<!--        UNION ALL-->
+<!--        SELECT a.region_user_id  FROM t_b_sop_info_detail a-->
+<!--        left join t_b_sop_info i on a.sop_info_id=i.id-->
 
-        </where>
-        UNION ALL
-        SELECT a.engineer_user_id  FROM t_b_sop_info_detail a
-        left join t_b_sop_info i on a.sop_info_id=i.id
+<!--        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no-->
+<!--        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id-->
+<!--        <where>-->
+<!--            and tffa.status!='FINISH'-->
+<!--            <if test="serviceUnitId != null and serviceUnitId != ''">-->
+<!--                and i.service_id = #{serviceUnitId}-->
+<!--            </if>-->
 
-        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no
-        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id
-        <where>
-            and tffa.status!='FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and i.service_id = #{serviceUnitId}
-            </if>
+<!--        </where>-->
+<!--        UNION ALL-->
+<!--        SELECT a.engineer_user_id  FROM t_b_sop_info_detail a-->
+<!--        left join t_b_sop_info i on a.sop_info_id=i.id-->
 
-        </where>
-        )
+<!--        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = i.sop_no-->
+<!--        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id-->
+<!--        <where>-->
+<!--            and tffa.status!='FINISH'-->
+<!--            <if test="serviceUnitId != null and serviceUnitId != ''">-->
+<!--                and i.service_id = #{serviceUnitId}-->
+<!--            </if>-->
+
+<!--        </where>-->
+<!--        )-->
     </select>
     <select id="projectCount" resultType="java.lang.Integer">
         SELECT
@@ -192,12 +188,47 @@
         a.create_time DESC
     </select>
     <select id="supplierRole" resultType="java.util.Map">
+<!--        SELECT-->
+<!--        r.NAME,-->
+<!--        count( DISTINCT ua.archives_id ) count-->
+<!--        FROM-->
+<!--        t_b_user_archives_allocation ua-->
+<!--        LEFT JOIN sys_role r ON r.id = ua.role_id-->
+<!--        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.archives_id-->
+<!--        <where>-->
+<!--            and us.authentication_valid_time > UNIX_TIMESTAMP()* 1000-->
+<!--            <if test="supplierId != null and supplierId != ''">-->
+<!--                and us.supplier_id = #{supplierId}-->
+<!--            </if>-->
+<!--        </where>-->
+<!--        GROUP BY-->
+<!--        r.NAME-->
+
+
         SELECT
         r.NAME,
-        count( DISTINCT ua.archives_id ) count
+        count( DISTINCT ua.user_id ) count
         FROM
         t_b_user_archives_allocation ua
         LEFT JOIN sys_role r ON r.id = ua.role_id
+        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.archives_id
+                <where>
+                    and us.authentication_valid_time > UNIX_TIMESTAMP()* 1000
+                    <if test="supplierId != null and supplierId != ''">
+                        and us.supplier_id = #{supplierId}
+                    </if>
+                </where>
+        GROUP BY
+        r.NAME
+
+        UNION all
+
+        SELECT
+        '区域协调人' as NAME,
+        count( DISTINCT ua.region_user_id ) count
+
+        FROM
+        t_b_user_archives_allocation ua
         LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.archives_id
         <where>
             and us.authentication_valid_time > UNIX_TIMESTAMP()* 1000
@@ -205,8 +236,6 @@
                 and us.supplier_id = #{supplierId}
             </if>
         </where>
-        GROUP BY
-        r.NAME
     </select>
     <select id="supplierRegion" resultType="java.util.Map">
         SELECT DISTINCT