shudonghui 1 년 전
부모
커밋
4bd487866e

+ 2 - 2
sop-api/src/main/java/com/qmth/sop/server/api/CrmAnalyseController.java

@@ -114,11 +114,11 @@ public class CrmAnalyseController {
     @ApiResponses({@ApiResponse(code = 200, message = "大区在执行派单排名下钻", response = CrmAnalyseResult.class)})
     public Result regionDetail(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                                @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                               @ApiParam(value = "大区", required = true) @RequestParam Long regionId,
+                               @ApiParam(value = "城市", required = true) @RequestParam String province,
                                @ApiParam(value = "客户类型", required = true) @RequestParam ProductTypeEnum type,
                                @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                                @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        return ResultUtil.ok(crmAnalyseService.regionDetail(new Page<>(pageNumber, pageSize), startTime, endTime, regionId, type));
+        return ResultUtil.ok(crmAnalyseService.regionDetail(new Page<>(pageNumber, pageSize), startTime, endTime, province, type));
     }
 
     //项目派单完成率

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/mapper/CrmAnalyseMapper.java

@@ -23,7 +23,7 @@ public interface CrmAnalyseMapper extends BaseMapper<TBCrm> {
     @SuppressWarnings("MybatisXMapperMethodInspection")
     Map<String, Object> countCustomType(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("month") String month, @Param("crmYear") String crmYear, @Param("type") String type, @Param("supplierId") Long supplierId, @Param("regionId") Long regionId, @Param("serviceId") Long serviceId, @Param("dpr") DataPermissionDto dpr);
+    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("month") String month, @Param("crmYear") String crmYear, @Param("type") String type, @Param("supplierId") Long supplierId, @Param("province") String province, @Param("serviceId") Long serviceId, @Param("dpr") DataPermissionDto dpr);
 
     default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long startTime, Long endTime, String type, DataPermissionDto dpr) {
         return crmDetail(iPage, startTime, endTime, null, null, type, null, null, null, dpr);
@@ -44,8 +44,8 @@ public interface CrmAnalyseMapper extends BaseMapper<TBCrm> {
 
     List<CrmAnalyseResult> region(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("type") String type, @Param("dpr") DataPermissionDto dpr);
 
-    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long startTime, Long endTime, Long regionId, String type, DataPermissionDto dpr) {
-        return crmDetail(iPage, startTime, endTime, null, null, type, null, regionId, null, dpr);
+    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long startTime, Long endTime, String province, String type, DataPermissionDto dpr) {
+        return crmDetail(iPage, startTime, endTime, null, null, type, null, province, null, dpr);
     }
 
     default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long serviceId, Long startTime, Long endTime, DataPermissionDto dpr) {

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/CrmAnalyseService.java

@@ -31,7 +31,7 @@ public interface CrmAnalyseService extends IService<TBCrm> {
 
     List<CrmAnalyseResult> region(Long startTime, Long endTime, ProductTypeEnum type);
 
-    IPage<TBCrmResult> regionDetail(Page<Object> objectPage, Long startTime, Long endTime, Long regionId, ProductTypeEnum type);
+    IPage<TBCrmResult> regionDetail(Page<Object> objectPage, Long startTime, Long endTime, String province, ProductTypeEnum type);
 
     List<CrmAnalyseResult> project(Long startTime, Long endTime);
 

+ 3 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/CrmAnalyseServiceImpl.java

@@ -86,7 +86,7 @@ public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm>
         List<CrmAnalyseResult> region1 = this.baseMapper.region(startTime - 24 * 60 * 60 * 1000L, endTime - 24 * 60 * 60 * 1000L, Objects.nonNull(type) ? type.name() : null, dpr);
 
         return  region.stream().map(map->{
-            CrmAnalyseResult crmAnalyseResult = region1.stream().filter(map1 -> map1.getId().equals(map.getId()) && map1.getName().equals(map.getName())).findFirst().orElse(new CrmAnalyseResult());
+            CrmAnalyseResult crmAnalyseResult = region1.stream().filter(map1 -> map1.getName().equals(map.getName())).findFirst().orElse(new CrmAnalyseResult());
             map.setCompare(map.getCount()-crmAnalyseResult.getCount());
             map.setRate(String.format("%.2f", Double.parseDouble(String.valueOf(map.getCount()-crmAnalyseResult.getCount()))*100 /map.getCount()) + "%");
             return map;
@@ -94,10 +94,10 @@ public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm>
     }
 
     @Override
-    public IPage<TBCrmResult> regionDetail(Page<Object> iPage, Long startTime, Long endTime, Long regionId, ProductTypeEnum type) {
+    public IPage<TBCrmResult> regionDetail(Page<Object> iPage, Long startTime, Long endTime, String province, ProductTypeEnum type) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.crmDetail(iPage, startTime, endTime, regionId, Objects.nonNull(type) ? type.name() : null, dpr);
+        return this.baseMapper.crmDetail(iPage, startTime, endTime, province, Objects.nonNull(type) ? type.name() : null, dpr);
     }
 
     @Override

+ 15 - 9
sop-business/src/main/resources/mapper/CrmAnalyseMapper.xml

@@ -31,14 +31,15 @@
         <!--        r.region_name-->
         <!--        order by count( c.id )-->
         SELECT
-        r.id,
-        cu.province name,
-        count( c.id ) count
+<!--        r.id,-->
+        rd.province name,
+        count(DISTINCT 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
+        left join t_b_service_region_detail rd on rd.service_region_id=r.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 != ''">
@@ -60,9 +61,9 @@
             </if>
         </where>
         GROUP BY
-        r.id,
-        cu.province
-        order by count( c.id ) desc
+<!--        r.id,-->
+        rd.province
+        order by count(DISTINCT c.id ) desc
     </select>
     <select id="project" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
         SELECT
@@ -99,7 +100,7 @@
         SELECT
         su.id,
         su.`name`,
-        count( c.id ) count
+        count(DISTINCT c.id ) count
         FROM
         t_b_crm c
         LEFT JOIN t_b_service s ON c.service_id = s.id
@@ -221,6 +222,7 @@
         from t_b_service tbs
         LEFT JOIN  t_b_crm a ON a.service_id = tbs.id
         left join t_b_service_region r on r.service_id=tbs.id
+        left join t_b_service_region_detail rd on rd.service_region_id=r.id
         LEFT JOIN t_b_product p ON p.id = a.product_id
         LEFT JOIN sys_custom sc ON sc.id = a.custom_id
         LEFT JOIN sys_user u ON u.id = a.region_coordinator_id
@@ -231,11 +233,15 @@
         LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
         LEFT JOIN sys_supplier su ON su.id = us.supplier_id
         <where>
+            and tbs.`status`='PUBLISH' and a.service_id is not null and r.id is not null
             <if test="serviceId != null and serviceId != ''">
                 and a.service_id = #{serviceId}
             </if>
-            <if test="regionId != null and regionId != ''">
-                and r.id = #{regionId}
+<!--            <if test="regionId != null and regionId != ''">-->
+<!--                and r.id = #{regionId}-->
+<!--            </if>-->
+            <if test="province != null and province != ''">
+                and rd.province = #{province}
             </if>
             <if test="type != null and type != ''">
                 and sc.type = #{type}