Browse Source

派单分析sql修改

wangliang 1 year ago
parent
commit
fafccbbe1c

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

@@ -1,8 +1,6 @@
 package com.qmth.sop.server.api;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.CrmAnalyseResult;
 import com.qmth.sop.business.bean.result.TBCrmResult;
@@ -20,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -37,24 +34,18 @@ import java.util.Map;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_CRM + "/analyse")
 public class CrmAnalyseController {
 
-
     @Resource
     CrmAnalyseService crmAnalyseService;
 
-
-   
     @ApiOperation(value = "客户类型分布接口")
     @RequestMapping(value = "/custom/type", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "客户类型分布", response = Map.class)})
     public Result customType(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                              @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
-        Map<String, Object> map = crmAnalyseService.countCustomType(startTime, endTime);
-
-        return ResultUtil.ok(map);
+        return ResultUtil.ok(crmAnalyseService.countCustomType(startTime, endTime));
     }
 
 
-   
     @ApiOperation(value = "客户类型分布下钻接口")
     @RequestMapping(value = "/custom/type/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "客户类型分布下钻", response = TBCrmResult.class)})
@@ -63,25 +54,18 @@ public class CrmAnalyseController {
                                    @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) {
-        IPage<TBCrmResult> resultIPage = crmAnalyseService.customTypeDetail(new Page<>(pageNumber, pageSize), startTime, endTime, type);
-
-        return ResultUtil.ok(resultIPage);
+        return ResultUtil.ok(crmAnalyseService.customTypeDetail(new Page<>(pageNumber, pageSize), startTime, endTime, type));
     }
 
-
-   
     @ApiOperation(value = "月度派单分布及对比接口")
     @RequestMapping(value = "/monthly", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "月度派单分布及对比接口", response = Map.class)})
     public Result monthly(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                           @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
                           @ApiParam(value = "客户类型", required = true) @RequestParam ProductTypeEnum type) {
-        Map<String, List<Map<String, String>>> map = crmAnalyseService.monthly(startTime, endTime, type);
-        return ResultUtil.ok(map);
+        return ResultUtil.ok(crmAnalyseService.monthly(startTime, endTime, type));
     }
 
-
-   
     @ApiOperation(value = "月度派单分布下钻接口")
     @RequestMapping(value = "/monthly/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "月度派单分布下钻", response = TBCrmResult.class)})
@@ -90,25 +74,18 @@ public class CrmAnalyseController {
                                 @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) {
-        IPage<TBCrmResult> resultIPage = crmAnalyseService.monthlyDetail(new Page<>(pageNumber, pageSize), year, month, type);
-
-        return ResultUtil.ok(resultIPage);
+        return ResultUtil.ok(crmAnalyseService.monthlyDetail(new Page<>(pageNumber, pageSize), year, month, type));
     }
 
     //供应商派单分布
-
-   
     @ApiOperation(value = "供应商派单分布接口")
     @RequestMapping(value = "/supplier", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "供应商派单分布", response = CrmAnalyseResult.class)})
     public Result supplier(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                            @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
-        List<CrmAnalyseResult> list = crmAnalyseService.supplier(startTime, endTime);
-        return ResultUtil.ok(list);
+        return ResultUtil.ok(crmAnalyseService.supplier(startTime, endTime));
     }
 
-
-    
     @ApiOperation(value = "供应商派单分布下钻接口")
     @RequestMapping(value = "/supplier/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "供应商派单分布下钻", response = TBCrmResult.class)})
@@ -117,27 +94,21 @@ public class CrmAnalyseController {
                                  @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId,
                                  @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) {
-        IPage<TBCrmResult> resultIPage = crmAnalyseService.supplierDetail(new Page<>(pageNumber, pageSize), startTime, endTime, supplierId);
-
-        return ResultUtil.ok(resultIPage);
+        return ResultUtil.ok(crmAnalyseService.supplierDetail(new Page<>(pageNumber, pageSize), startTime, endTime, supplierId));
     }
-    //大区在执行派单排名
 
-    
+    //大区在执行派单排名
     @ApiOperation(value = "大区在执行派单排名接口")
     @RequestMapping(value = "/region", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "大区在执行派单排名", response = CrmAnalyseResult.class)})
     public Result region(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                          @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
                          @ApiParam(value = "客户类型", required = true) @RequestParam ProductTypeEnum type) {
-        Map<String, List<CrmAnalyseResult>> map = crmAnalyseService.region(startTime, endTime, type);
-        return ResultUtil.ok(map);
+        return ResultUtil.ok(crmAnalyseService.region(startTime, endTime, type));
     }
 
 
     //大区在执行派单排名
-
-    
     @ApiOperation(value = "大区在执行派单排名下钻接口")
     @RequestMapping(value = "/region/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "大区在执行派单排名下钻", response = CrmAnalyseResult.class)})
@@ -147,27 +118,19 @@ public class CrmAnalyseController {
                                @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) {
-        IPage<TBCrmResult> resultIPage = crmAnalyseService.regionDetail(new Page<>(pageNumber, pageSize), startTime, endTime, regionId, type);
-
-        return ResultUtil.ok(resultIPage);
+        return ResultUtil.ok(crmAnalyseService.regionDetail(new Page<>(pageNumber, pageSize), startTime, endTime, regionId, type));
     }
 
-
     //项目派单完成率
-
-   
     @ApiOperation(value = "项目派单完成率接口")
     @RequestMapping(value = "/project", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "项目派单完成率", response = CrmAnalyseResult.class)})
     public Result project(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                           @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
-        List<CrmAnalyseResult> list = crmAnalyseService.project(startTime, endTime);
-        return ResultUtil.ok(list);
+        return ResultUtil.ok(crmAnalyseService.project(startTime, endTime));
     }
 
     //项目派单完成率详细
-
-   
     @ApiOperation(value = "项目派单完成率详细接口")
     @RequestMapping(value = "/project/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "项目派单完成率详细", response = CrmAnalyseResult.class)})
@@ -176,9 +139,7 @@ public class CrmAnalyseController {
                                 @ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId,
                                 @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) {
-        IPage<TBCrmResult> resultIPage = crmAnalyseService.projectDetail(new Page<>(pageNumber, pageSize), startTime, endTime, serviceId);
-
-        return ResultUtil.ok(resultIPage);
+        return ResultUtil.ok(crmAnalyseService.projectDetail(new Page<>(pageNumber, pageSize), startTime, endTime, serviceId));
     }
 
     //派单累计 服务人员累计
@@ -186,13 +147,7 @@ public class CrmAnalyseController {
     @RequestMapping(value = "/project/count", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "项目派单完成率详细", response = CrmAnalyseResult.class)})
     public Result projectCount(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                                @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
-        Map<String,Object> map = crmAnalyseService.projectCount(startTime, endTime);
-
-        return ResultUtil.ok(map);
+                               @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
+        return ResultUtil.ok(crmAnalyseService.projectCount(startTime, endTime));
     }
-
-
-
-
 }

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

@@ -2,7 +2,6 @@ package com.qmth.sop.server.api;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
@@ -39,24 +38,19 @@ import java.util.stream.Collectors;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/service/analyse")
 public class ServiceAnalyseController {
 
-
     @Resource
     ServiceAnalyseService serviceAnalyseService;
 
-
-
     //服务单元列表
-    
     @ApiOperation(value = "服务单元列表接口")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "服务单元列表", response = TBService.class)})
     public Result list(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
                        @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime) {
-        List<TBService> list = serviceAnalyseService.list(startTime,endTime);
+        List<TBService> list = serviceAnalyseService.list(startTime, endTime);
         return ResultUtil.ok(list);
     }
 
-
     /**
      * 4.服务单元概览
      * ①项目执行进度=服务单元下已完成的派单(研究生派单下SOP已完结;教务处派单下已有完成的SOP,无在执行的SOP。可能存在教务处多个SOP之间空窗期导致数据的误差,这个指标允许少量误差存在);
@@ -66,8 +60,6 @@ public class ServiceAnalyseController {
      * ⑤现场人员占用率:(在服务人员总数÷认证有效的在服务人员总数)×100%;
      * ⑥以上指标都不需提供【数据下钻】;
      */
-
-    
     @ApiOperation(value = "服务单元概览接口")
     @RequestMapping(value = "/overview", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "服务单元概览", response = Map.class)})
@@ -82,8 +74,6 @@ public class ServiceAnalyseController {
      * ②派单数:可提供【数据下钻】,点击派单数后可显示该服务单元下已调配了区域协调人的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
      * ③供应商:点击供应商,显示当前供应商在该服务单元下的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
      */
-
-    
     @ApiOperation(value = "人力供应商项目数量分布及占比")
     @RequestMapping(value = "/supplier", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "人力供应商项目数量分布及占比", response = Map.class)})
@@ -96,8 +86,6 @@ public class ServiceAnalyseController {
      * ②派单数:可提供【数据下钻】,点击派单数后可显示该服务单元下已调配了区域协调人的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
      * ③供应商:点击供应商,显示当前供应商在该服务单元下的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
      */
-
-    
     @ApiOperation(value = "派单明细")
     @RequestMapping(value = "/supplier/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "派单明细", response = TBCrmResult.class)})
@@ -106,7 +94,6 @@ public class ServiceAnalyseController {
                            @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) {
         IPage<TBCrmResult> resultIPage = serviceAnalyseService.supplierDetail(new Page<>(pageNumber, pageSize), serviceUnitId, supplierId);
-
         return ResultUtil.ok(resultIPage);
     }
 
@@ -116,45 +103,41 @@ public class ServiceAnalyseController {
      * ②显示当前供应商提供的项目角色各自的人数占比;
      * ③覆盖大区:统计当前服务单元下该供应商区域协调人负责的项目覆盖的大区数量及明细;
      */
-
-    
     @ApiOperation(value = "人力供应商项目角色人员分布")
     @RequestMapping(value = "/supplier/role", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "人力供应商项目角色人员分布", response = Map.class)})
     public Result role(
             @ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
             @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId) {
-        List<Map<String,Object>> list = serviceAnalyseService.supplierRole(supplierId);
+        List<Map<String, Object>> list = serviceAnalyseService.supplierRole(supplierId);
         return ResultUtil.ok(list);
     }
 
     /**
      * * ③覆盖大区:统计当前服务单元下该供应商区域协调人负责的项目覆盖的大区数量及明细;
      */
-    
     @ApiOperation(value = "人力供应商覆盖大区")
     @RequestMapping(value = "/supplier/region", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "人力供应商覆盖大区", response = Map.class)})
     public Result region(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
                          @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId) {
-        List<Map<String,Object>> list = serviceAnalyseService.supplierRegion(serviceUnitId, supplierId);
+        List<Map<String, Object>> list = serviceAnalyseService.supplierRegion(serviceUnitId, supplierId);
         return ResultUtil.ok(list);
     }
 
     /**
      * 统计当前服务单元下该供应商区域协调人负责的项目覆盖的大区明细;
      */
-    
     @ApiOperation(value = "人力供应商覆盖大区明细")
     @RequestMapping(value = "/supplier/region/detail", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "人力供应商覆盖大区", response = Map.class)})
     public Result regionDetail(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
                                @ApiParam(value = "供应商", required = true) @RequestParam Long supplierId,
                                @ApiParam(value = "大区", required = true) @RequestParam Long regionId) {
-        Map<String,Object> map=new HashMap<>();
-        map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId,regionId,supplierId));
+        Map<String, Object> map = new HashMap<>();
+        map.put("projectRoleQuota", serviceAnalyseService.findCrmAllocationSubTotal(serviceUnitId, regionId, supplierId));
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, supplierId);
-        map.put("projectWait", crmAllocation.stream().filter(e->e.getDistributed()<e.getQuota()).count());
+        map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
         map.put("regionCities", crmAllocation.stream().collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
         return ResultUtil.ok(map);
     }
@@ -162,19 +145,17 @@ public class ServiceAnalyseController {
     /**
      * 7.项目调配完成进度=(差额为0的派单总数÷派单总数)×100%;不提供【数据下钻】
      */
-
     @ApiOperation(value = "项目调配完成进度")
     @RequestMapping(value = "/project/allocation", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目调配完成进度", response = Long.class) })
+    @ApiResponses({@ApiResponse(code = 200, message = "项目调配完成进度", response = Long.class)})
     public Result allocation(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
         List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
-        return ResultUtil.ok(crmAllocation.isEmpty() ?0:crmAllocation.stream().filter(e->e.getDistributed()<e.getQuota()).count()/crmAllocation.size());
+        return ResultUtil.ok(crmAllocation.isEmpty() ? 0 : crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count() / crmAllocation.size());
     }
 
     /**
      * 8.人员配额完成进度=(已分配人员数量÷总配额)×100%;不提供【数据下钻】
      */
-    
     @ApiOperation(value = "人员配额完成进度")
     @RequestMapping(value = "/personnel/quota", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "人员配额完成进度", response = Long.class)})
@@ -182,13 +163,12 @@ public class ServiceAnalyseController {
         List<UserArchivesAllocationResult> list = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
         int quota = list.stream().mapToInt(UserArchivesAllocationResult::getQuota).sum();
         int distributed = list.stream().mapToInt(UserArchivesAllocationResult::getDistributed).sum();
-        return ResultUtil.ok(quota==0?0:distributed/quota);
+        return ResultUtil.ok(quota == 0 ? 0 : distributed / quota);
     }
 
     /**
      * 9.设备供应商设备使用占比:当前服务单元下各设备供应商提供已出库尚未出库的设备的数量及占比;
      */
-    
     @ApiOperation(value = "设备供应商设备使用占比")
     @RequestMapping(value = "/device/use", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "设备供应商设备使用占比", response = Map.class)})
@@ -197,21 +177,15 @@ public class ServiceAnalyseController {
         return ResultUtil.ok(list);
     }
 
-
-
     /**
      * 10.大区服务人数分布及对比:
-     *①当前服务单元下各大区在服务人员的数量分布及对比。单个柱形图可按供应商占比分颜色展示占比。
+     * ①当前服务单元下各大区在服务人员的数量分布及对比。单个柱形图可按供应商占比分颜色展示占比。
      */
-    
     @ApiOperation(value = "大区服务人数分布及对比")
     @RequestMapping(value = "/region/personnel", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "大区服务人数分布及对比", response = Map.class)})
     public Result personnel(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        List<Map<String, Object>> list= serviceAnalyseService.personnel(serviceUnitId);
+        List<Map<String, Object>> list = serviceAnalyseService.personnel(serviceUnitId);
         return ResultUtil.ok(list);
     }
-
-
-
 }

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

@@ -17,42 +17,43 @@ import java.util.Map;
  * </p>
  *
  * @author dhshu
- *
  */
 public interface CrmAnalyseMapper extends BaseMapper<TBCrm> {
 
+    @SuppressWarnings("MybatisXMapperMethodInspection")
+    Map<String, Object> countCustomType(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-    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("regionId") Long regionId, @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);
+    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);
     }
 
-    List<Map<String,String>> monthly(@Param("startTime") Long startTime,@Param("endTime") Long endTime,@Param("type") String type,@Param("dpr") DataPermissionDto dpr);
+    @SuppressWarnings("MybatisXMapperMethodInspection")
+    List<Map<String, String>> monthly(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("type") String type, @Param("dpr") DataPermissionDto dpr);
 
-    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, String year, String month, String type,DataPermissionDto dpr) {
-        return crmDetail(iPage,null,null,month,year,type,null,null,null,dpr);
+    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, String year, String month, String type, DataPermissionDto dpr) {
+        return crmDetail(iPage, null, null, month, year, type, null, null, null, dpr);
     }
 
-    List<CrmAnalyseResult> supplier(@Param("startTime") Long startTime,@Param("endTime") Long endTime,@Param("dpr") DataPermissionDto dpr);
+    List<CrmAnalyseResult> supplier(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-    default IPage<TBCrmResult> crmDetailSupplier(Page<Object> iPage, Long startTime, Long endTime,  Long supplierId,DataPermissionDto dpr) {
-        return crmDetail(iPage,startTime,endTime,null,null,null,supplierId,null,null,dpr);
+    default IPage<TBCrmResult> crmDetailSupplier(Page<Object> iPage, Long startTime, Long endTime, Long supplierId, DataPermissionDto dpr) {
+        return crmDetail(iPage, startTime, endTime, null, null, null, supplierId, null, null, dpr);
     }
 
-    List<CrmAnalyseResult> region(@Param("startTime") Long startTime,@Param("endTime") Long endTime, @Param("type") String type,@Param("dpr") DataPermissionDto dpr);
+    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, 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 serviceId, Long startTime, Long endTime,DataPermissionDto dpr) {
-        return crmDetail(iPage,startTime,endTime,null,null,null,null,null,serviceId,dpr);
+    default IPage<TBCrmResult> crmDetail(Page<Object> iPage, Long serviceId, Long startTime, Long endTime, DataPermissionDto dpr) {
+        return crmDetail(iPage, startTime, endTime, null, null, null, null, null, serviceId, dpr);
     }
 
-    List<CrmAnalyseResult> project(@Param("startTime") Long startTime,@Param("endTime") Long endTime,@Param("dpr") DataPermissionDto dpr);
+    List<CrmAnalyseResult> project(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 
-    Map<String, Object> projectCount(@Param("startTime") Long startTime,@Param("endTime") Long endTime,@Param("dpr") DataPermissionDto dpr);
+    @SuppressWarnings("MybatisXMapperMethodInspection")
+    Map<String, Object> projectCount(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
 }

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

@@ -3,8 +3,8 @@ package com.qmth.sop.business.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.bean.result.CrmAnalyseResult;
+import com.qmth.sop.business.bean.result.TBCrmResult;
 import com.qmth.sop.business.entity.TBCrm;
 import com.qmth.sop.common.enums.ProductTypeEnum;
 
@@ -17,11 +17,11 @@ import java.util.Map;
  * @date:
  */
 public interface CrmAnalyseService extends IService<TBCrm> {
-    Map<String,Object> countCustomType(Long startTime, Long endTime);
+    Map<String, Object> countCustomType(Long startTime, Long endTime);
 
     IPage<TBCrmResult> customTypeDetail(Page<Object> objectPage, Long startTime, Long endTime, ProductTypeEnum type);
 
-    Map<String, List<Map<String,String>>> monthly(Long startTime, Long endTime, ProductTypeEnum type);
+    Map<String, List<Map<String, String>>> monthly(Long startTime, Long endTime, ProductTypeEnum type);
 
     IPage<TBCrmResult> monthlyDetail(Page<Object> objectPage, String year, String month, ProductTypeEnum type);
 

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

@@ -28,29 +28,31 @@ import java.util.Objects;
  */
 @Service
 public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm> implements CrmAnalyseService {
+
     @Resource
     private SysUserService sysUserService;
+
     @Override
-    public Map<String,Object> countCustomType(Long startTime, Long endTime) {
+    public Map<String, Object> countCustomType(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.countCustomType(startTime,endTime,dpr);
+        return this.baseMapper.countCustomType(startTime, endTime, dpr);
     }
 
     @Override
     public IPage<TBCrmResult> customTypeDetail(Page<Object> iPage, Long startTime, Long endTime, ProductTypeEnum type) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.crmDetail(iPage,startTime,endTime, Objects.nonNull(type) ? type.name() : null,dpr);
+        return this.baseMapper.crmDetail(iPage, startTime, endTime, Objects.nonNull(type) ? type.name() : null, dpr);
     }
 
     @Override
-    public  Map<String, List<Map<String,String>>> monthly(Long startTime, Long endTime, ProductTypeEnum type) {
+    public Map<String, List<Map<String, String>>> monthly(Long startTime, Long endTime, ProductTypeEnum type) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        Map<String, List<Map<String,String>>> map=new HashMap<>();
-        map.put("year",this.baseMapper.monthly(startTime,endTime, Objects.nonNull(type) ? type.name() : null,dpr));
-        map.put("lastYear",this.baseMapper.monthly(startTime-365*24*60*60* 1000L,endTime-365*24*60*60* 1000L, Objects.nonNull(type) ? type.name() : null,dpr));
+        Map<String, List<Map<String, String>>> map = new HashMap<>();
+        map.put("year", this.baseMapper.monthly(startTime, endTime, Objects.nonNull(type) ? type.name() : null, dpr));
+        map.put("lastYear", this.baseMapper.monthly(startTime - 365 * 24 * 60 * 60 * 1000L, endTime - 365 * 24 * 60 * 60 * 1000L, Objects.nonNull(type) ? type.name() : null, dpr));
         return map;
     }
 
@@ -58,30 +60,30 @@ public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm>
     public IPage<TBCrmResult> monthlyDetail(Page<Object> iPage, String year, String month, ProductTypeEnum type) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.crmDetail(iPage,year,month, Objects.nonNull(type) ? type.name() : null,dpr);
+        return this.baseMapper.crmDetail(iPage, year, month, Objects.nonNull(type) ? type.name() : null, dpr);
     }
 
     @Override
     public List<CrmAnalyseResult> supplier(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.supplier(startTime,endTime,dpr);
+        return this.baseMapper.supplier(startTime, endTime, dpr);
     }
 
     @Override
     public IPage<TBCrmResult> supplierDetail(Page<Object> iPage, Long startTime, Long endTime, Long supplierId) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.crmDetailSupplier(iPage,startTime,endTime, supplierId,dpr);
+        return this.baseMapper.crmDetailSupplier(iPage, startTime, endTime, supplierId, dpr);
     }
 
     @Override
-    public Map<String,  List<CrmAnalyseResult>> region(Long startTime, Long endTime, ProductTypeEnum type) {
+    public Map<String, List<CrmAnalyseResult>> region(Long startTime, Long endTime, ProductTypeEnum type) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        Map<String,  List<CrmAnalyseResult>> map=new HashMap<>();
-        map.put("day",this.baseMapper.region(startTime,endTime,Objects.nonNull(type) ? type.name() : null,dpr));
-        map.put("lastDay",this.baseMapper.region(startTime-365*24*60*60* 1000L,endTime-365*24*60*60* 1000L,Objects.nonNull(type) ? type.name() : null,dpr));
+        Map<String, List<CrmAnalyseResult>> map = new HashMap<>();
+        map.put("day", this.baseMapper.region(startTime, endTime, Objects.nonNull(type) ? type.name() : null, dpr));
+        map.put("lastDay", this.baseMapper.region(startTime - 365 * 24 * 60 * 60 * 1000L, endTime - 365 * 24 * 60 * 60 * 1000L, Objects.nonNull(type) ? type.name() : null, dpr));
         return map;
     }
 
@@ -89,25 +91,25 @@ public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm>
     public IPage<TBCrmResult> regionDetail(Page<Object> iPage, Long startTime, Long endTime, Long regionId, 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, regionId, Objects.nonNull(type) ? type.name() : null, dpr);
     }
 
     @Override
     public List<CrmAnalyseResult> project(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.project(startTime,endTime,dpr);
+        return this.baseMapper.project(startTime, endTime, dpr);
     }
 
     @Override
     public IPage<TBCrmResult> projectDetail(Page<Object> iPage, Long startTime, Long endTime, Long serviceId) {
-        return this.baseMapper.crmDetail(iPage,serviceId,startTime,endTime,null);
+        return this.baseMapper.crmDetail(iPage, serviceId, startTime, endTime, null);
     }
 
     @Override
     public Map<String, Object> projectCount(Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.projectCount(startTime,endTime,dpr);
+        return this.baseMapper.projectCount(startTime, endTime, dpr);
     }
 }

+ 25 - 29
sop-business/src/main/resources/mapper/CrmAnalyseMapper.xml

@@ -70,19 +70,19 @@
         s.`name`,
         sum(case when c.`status`='FINISH' then 1 else 0 end)/count( c.id ) count
         FROM
-        t_b_crm c
+        t_b_service s
+        LEFT JOIN t_b_crm c ON c.service_id = s.id
         LEFT JOIN sys_custom cu ON cu.id = c.custom_id
-        LEFT JOIN t_b_service s ON c.service_id = s.id
         <where>
-            s.`status` IN ( 'PUBLISH', 'FINISH' )
+            s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.status is not null
             <!--            <if test="year != null and year != ''">-->
             <!--                and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}-->
             <!--            </if>-->
             <if test="startTime != null">
-                AND s.start_time >= #{startTime}
+                AND s.start_time <![CDATA[ >= ]]> #{startTime}
             </if>
             <if test="endTime != null">
-                AND #{endTime} >= s.start_time
+                AND s.start_time <![CDATA[ <= ]]> #{endTime}
             </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <if test="dpr.hasBusiness">
@@ -179,9 +179,8 @@
         SELECT
         sum(case when cu.type='OFFICE' then 1 else 0 end) as OFFICE,
         sum(case when cu.type='CLOUD_MARK' then 1 else 0 end) as CLOUD_MARK
-        FROM
-        t_b_crm c
-        LEFT JOIN t_b_service s ON c.service_id = s.id
+        FROM t_b_service s
+        LEFT JOIN t_b_crm c ON c.service_id = s.id
         LEFT join sys_custom cu on cu.id=c.custom_id
         <!--        WHERE-->
         <!--        YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}-->
@@ -190,10 +189,10 @@
             <!--                and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}-->
             <!--            </if>-->
             <if test="startTime != null">
-                AND s.start_time >= #{startTime}
+                AND s.start_time <![CDATA[ >= ]]> #{startTime}
             </if>
             <if test="endTime != null">
-                AND #{endTime} >= s.start_time
+                AND s.start_time <![CDATA[ <= ]]> #{endTime}
             </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <if test="dpr.hasBusiness">
@@ -203,10 +202,12 @@
         </where>
     </select>
 
-
     <select id="crmDetail" resultType="com.qmth.sop.business.bean.result.TBCrmResult">
-        SELECT DISTINCT
-        a.*,
+        SELECT
+        a.id,a.crm_no as crmNo,
+        a.begin_time  as beginTime,
+        a.name,
+        tbs.id,
         tbs.name service,
         cru.real_name crm_user_name,
         sc.NAME custom,
@@ -217,17 +218,14 @@
         tbs.status serviceUnitStatus,
         u.real_name regionCoordinator,
         su.name supplier
-        FROM
-        t_b_crm a
-        LEFT JOIN sys_user cru ON cru.id = a.crm_user_id
-        LEFT JOIN sys_user lu ON lu.id = a.lead_id
-        LEFT JOIN sys_user cu ON cu.id = a.create_id
+        from t_b_service tbs
+        LEFT JOIN  t_b_crm a ON a.service_id = tbs.id
         LEFT JOIN t_b_product p ON p.id = a.product_id
-        LEFT JOIN t_b_service tbs ON a.service_id = tbs.id
-        left join t_b_service_region r on r.service_id=tbs.id
         LEFT JOIN sys_custom sc ON sc.id = a.custom_id
-
-        LEFT JOIN sys_user u ON u.id = r.lead_id
+        LEFT JOIN sys_user u ON u.id = a.region_coordinator_id
+        LEFT JOIN sys_user lu ON lu.id = a.lead_id
+        LEFT JOIN sys_user cu ON cu.id = a.create_id
+        LEFT JOIN sys_user cru ON cru.id = a.crm_user_id
         LEFT JOIN t_b_user_archives ua ON u.mobile_number = ua.mobile_number
         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
@@ -248,10 +246,10 @@
             <!--                and YEAR ( FROM_UNIXTIME( tbs.start_time / 1000 ))=  #{year}-->
             <!--            </if>-->
             <if test="startTime != null">
-                AND tbs.start_time >= #{startTime}
+                AND tbs.start_time <![CDATA[ >= ]]> #{startTime}
             </if>
             <if test="endTime != null">
-                AND #{endTime} >= tbs.start_time
+                AND tbs.start_time <![CDATA[ <= ]]> #{endTime}
             </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
                 <if test="dpr.hasBusiness">
@@ -259,15 +257,13 @@
                 </if>
             </if>
             <if test="crmYear != null and crmYear != ''">
-                and YEAR ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{crmYear}
+                and YEAR (FROM_UNIXTIME( a.begin_time / 1000))= #{crmYear}
             </if>
             <if test="month != null and month != ''">
-                and MONTH ( FROM_UNIXTIME( a.begin_time / 1000 ))= #{month}
+                and MONTH (FROM_UNIXTIME(a.begin_time / 1000))= #{month}
             </if>
         </where>
-
-        ORDER BY
-        a.create_time DESC
+        ORDER BY a.crm_no DESC
     </select>
 
     <select id="projectCount" resultType="java.util.Map">