Browse Source

代码修改

wangliang 9 months ago
parent
commit
8c62af7ccd
26 changed files with 44 additions and 3638 deletions
  1. 0 155
      sop-api/src/main/java/com/qmth/sop/server/api/CrmAnalyseController.java
  2. 0 78
      sop-api/src/main/java/com/qmth/sop/server/api/DeviceMonitorController.java
  3. 0 142
      sop-api/src/main/java/com/qmth/sop/server/api/QualityAnalyseController.java
  4. 0 212
      sop-api/src/main/java/com/qmth/sop/server/api/ServiceAnalyseController.java
  5. 0 121
      sop-api/src/main/java/com/qmth/sop/server/api/SopAnalyseController.java
  6. 0 61
      sop-business/src/main/java/com/qmth/sop/business/mapper/CrmAnalyseMapper.java
  7. 0 28
      sop-business/src/main/java/com/qmth/sop/business/mapper/DeviceMonitorMapper.java
  8. 0 40
      sop-business/src/main/java/com/qmth/sop/business/mapper/QualityAnalyseMapper.java
  9. 0 54
      sop-business/src/main/java/com/qmth/sop/business/mapper/ServiceAnalyseMapper.java
  10. 0 46
      sop-business/src/main/java/com/qmth/sop/business/mapper/SopAnalyseMapper.java
  11. 0 41
      sop-business/src/main/java/com/qmth/sop/business/service/CrmAnalyseService.java
  12. 0 17
      sop-business/src/main/java/com/qmth/sop/business/service/DeviceMonitorService.java
  13. 0 33
      sop-business/src/main/java/com/qmth/sop/business/service/QualityAnalyseService.java
  14. 0 50
      sop-business/src/main/java/com/qmth/sop/business/service/ServiceAnalyseService.java
  15. 0 31
      sop-business/src/main/java/com/qmth/sop/business/service/SopAnalyseService.java
  16. 0 155
      sop-business/src/main/java/com/qmth/sop/business/service/impl/CrmAnalyseServiceImpl.java
  17. 0 58
      sop-business/src/main/java/com/qmth/sop/business/service/impl/DeviceMonitorServiceImpl.java
  18. 0 151
      sop-business/src/main/java/com/qmth/sop/business/service/impl/QualityAnalyseServiceImpl.java
  19. 0 398
      sop-business/src/main/java/com/qmth/sop/business/service/impl/ServiceAnalyseServiceImpl.java
  20. 0 492
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SopAnalyseServiceImpl.java
  21. 44 1
      sop-business/src/main/resources/db/log/wangliang_update_log.sql
  22. 0 343
      sop-business/src/main/resources/mapper/CrmAnalyseMapper.xml
  23. 0 107
      sop-business/src/main/resources/mapper/DeviceMonitorMapper.xml
  24. 0 202
      sop-business/src/main/resources/mapper/QualityAnalyseMapper.xml
  25. 0 369
      sop-business/src/main/resources/mapper/ServiceAnalyseMapper.xml
  26. 0 253
      sop-business/src/main/resources/mapper/SopAnalyseMapper.xml

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

@@ -1,155 +0,0 @@
-package com.qmth.sop.server.api;
-
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.bean.result.CrmAnalyseResult;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.service.CrmAnalyseService;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.ProductTypeEnum;
-import com.qmth.sop.common.util.Result;
-import com.qmth.sop.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import java.util.Map;
-
-/**
- * 派单分析 控制器
- *
- * @author: shudonghui
- * @date: 2023-08-14 15:55:18
- * @version: 1.0
- * @email: shudonghui@qmth.com.cn
- * @Company: www.qmth.com.cn
- */
-@Api(tags = "派单分析 Controller")
-@RestController
-@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) {
-        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)})
-    public Result customTypeDetail(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                                   @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                                   @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.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) {
-        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)})
-    public Result monthlyDetail(@ApiParam(value = "年度", required = true) @RequestParam String year,
-                                @ApiParam(value = "月份", required = true) @RequestParam String month,
-                                @ApiParam(value = "客户类型", required = true) @RequestParam ProductTypeEnum type,
-                                @ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                                @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                                @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.monthlyDetail(new Page<>(pageNumber, pageSize), year, month, type,startTime,endTime));
-    }
-
-    //供应商派单分布
-    @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) {
-        return ResultUtil.ok(crmAnalyseService.supplier(startTime, endTime));
-    }
-
-    @ApiOperation(value = "供应商派单分布下钻接口")
-    @RequestMapping(value = "/supplier/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "供应商派单分布下钻", response = TBCrmResult.class)})
-    public Result supplierDetail(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                                 @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                                 @ApiParam(value = "供应商", required = false) @RequestParam(required = false) 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) {
-        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) {
-        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)})
-    public Result regionDetail(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                               @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                               @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, province, 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) {
-        return ResultUtil.ok(crmAnalyseService.project(startTime, endTime));
-    }
-
-    //项目派单完成率详细
-    @ApiOperation(value = "项目派单完成率详细接口")
-    @RequestMapping(value = "/project/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目派单完成率详细", response = CrmAnalyseResult.class)})
-    public Result projectDetail(@ApiParam(value = "开始时间", required = true) @RequestParam Long startTime,
-                                @ApiParam(value = "结束时间", required = true) @RequestParam Long endTime,
-                                @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) {
-        return ResultUtil.ok(crmAnalyseService.projectDetail(new Page<>(pageNumber, pageSize), startTime, endTime, serviceId));
-    }
-
-    //派单累计 服务人员累计
-    @ApiOperation(value = "派单累计 服务人员累计")
-    @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) {
-        return ResultUtil.ok(crmAnalyseService.projectCount(startTime, endTime));
-    }
-}

+ 0 - 78
sop-api/src/main/java/com/qmth/sop/server/api/DeviceMonitorController.java

@@ -1,78 +0,0 @@
-package com.qmth.sop.server.api;
-
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.service.DeviceMonitorService;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.util.Result;
-import com.qmth.sop.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 设备保障监控 控制器
- *
- * @author: shudonghui
- * @date: 2023-08-14 15:55:18
- * @version: 1.0
- * @email: shudonghui@qmth.com.cn
- * @Company: www.qmth.com.cn
- */
-@Api(tags = "设备保障监控 Controller")
-@RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + SystemConstant.PREFIX_URL_DEVICE + "/monitor")
-public class DeviceMonitorController {
-
-
-    @Resource
-    DeviceMonitorService deviceMonitorService;
-
-    
-    @ApiOperation(value = "库存监控统计接口")
-    @RequestMapping(value = "/count", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "库存监控统计", response = Map.class)})
-    public Result count(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId,
-                        @ApiParam(value = "型号", required = false) @RequestParam(required = false) String model
-    ) {
-        Map<String, Object> map = deviceMonitorService.count(supplierId, model);
-
-        return ResultUtil.ok(map);
-    }
-
-    //按型号统计状态明细
-    
-    @ApiOperation(value = "按型号统计状态明细")
-    @RequestMapping(value = "/countByModel", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "按型号统计状态明细", response = List.class)})
-    public Result countByModel(@ApiParam(value = "供应商", required = false) @RequestParam(required = false) Long supplierId) {
-        List<Map<String, Object>> list = deviceMonitorService.countByModel(supplierId);
-
-        return ResultUtil.ok(list);
-    }
-
-    //按服务单元统计设备状态
-    
-    @ApiOperation(value = "按服务单元统计设备状态")
-    @RequestMapping(value = "/countByServiceUnit", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态", response = Map.class)})
-    public Result countByServiceUnit() {
-        Map<String, Object> map = deviceMonitorService.countByServiceUnit();
-        return ResultUtil.ok(map);
-    }
-    //按服务单元统计设备状态明细
-    
-    @ApiOperation(value = "按服务单元统计设备状态明细")
-    @RequestMapping(value = "/countByServiceUnitDetail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "按服务单元统计设备状态明细", response = List.class)})
-    public Result countByServiceUnitDetail() {
-        List<Map<String, Object>> list = deviceMonitorService.countByServiceUnitDetail();
-        return ResultUtil.ok(list);
-    }
-
-}

+ 0 - 142
sop-api/src/main/java/com/qmth/sop/server/api/QualityAnalyseController.java

@@ -1,142 +0,0 @@
-package com.qmth.sop.server.api;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.google.gson.JsonObject;
-import com.qmth.boot.api.annotation.Aac;
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.service.QualityAnalyseService;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.InfluenceDegreeEnum;
-import com.qmth.sop.common.enums.QualityAnalyseGroupEnum;
-import com.qmth.sop.common.enums.QualityProblemReasonEnum;
-import com.qmth.sop.common.util.Result;
-import com.qmth.sop.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-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;
-
-/**
- * 质量分析监控 控制器
- *
- * @author: shudonghui
- * @date: 2023-08-14 15:55:18
- * @version: 1.0
- * @email: shudonghui@qmth.com.cn
- * @Company: www.qmth.com.cn
- */
-@Api(tags = "质量分析监控 Controller")
-@RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/quality/analyse")
-public class QualityAnalyseController {
-
-
-    @Resource
-    QualityAnalyseService qualityAnalyseService;
-
-
-    @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 = qualityAnalyseService.list(startTime,endTime);
-        return ResultUtil.ok(list);
-    }
-
-
-    /**
-     * 4.质量问题总体盘点
-     * ①饼图:显示已完成审核,且确定为质量问题(审核结果非“不是问题”)的质量问题的数量统计,以及各影响度的质量问题事件的占比;
-     * ②【数据下钻】点击影响度行数据,可显示影响度下质量问题查询明细,筛选条件为:年度+服务单元+非“不是问题”+影响度;
-     * ③归因雷达图:按找质量问题归因维度展示雷达图,以及全部及各供应商的雷达图。不提供【数据下钻】;
-     */
-    //质量问题总体盘点饼图
-    @ApiOperation(value = "质量问题总体盘点饼图")
-    @RequestMapping(value = "/pie", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "质量问题总体盘点饼图", response = Map.class)})
-    public Result pie(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        Map<String, Object> map = qualityAnalyseService.pie(serviceUnitId);
-        return ResultUtil.ok(map);
-    }
-
-    //质量问题总体盘点归因雷达图
-    @ApiOperation(value = "质量问题总体盘点归因雷达图")
-    @RequestMapping(value = "/radar", method = RequestMethod.POST)
-    public Result radar(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                        @ApiParam(value = "影响度分组", required = true) @RequestParam QualityAnalyseGroupEnum group) {
-        Map<String, Map<String, Object>> map = qualityAnalyseService.radar(serviceUnitId, group);
-        return ResultUtil.ok(map);
-    }
-
-
-    /**
-     * 5.质量问题审核进度=(已完成审核的质量问题总数÷总数)×100%;不提供【数据下钻】;
-     */
-
-    @ApiOperation(value = "质量问题审核进度")
-    @RequestMapping(value = "/progress", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "质量问题审核进度", response = Double.class)})
-    public Result progress(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        Double progress = qualityAnalyseService.progress(serviceUnitId);
-        return ResultUtil.ok(progress);
-    }
-
-    /**
-     * * 6.影响度/归因    供应商/大区分布及对比:
-     * * 可视化展示如图,供应商/大区的归属,仅针对审核完成且定责为供应商的人员,或大区管辖的项目;
-     * * 【数据下钻】点击行数据,可查看质量问题数据明细。
-     */
-    @ApiOperation(value = "影响度/归因")
-    @RequestMapping(value = "/influence", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "影响度/归因", response = JSONObject.class)})
-    public Result influence(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                            @ApiParam(value = "影响度分组", required = true) @RequestParam QualityAnalyseGroupEnum group) {
-        return ResultUtil.ok(qualityAnalyseService.influence(serviceUnitId, group));
-    }
-
-    //* ②【数据下钻】点击影响度行数据,可显示影响度下质量问题查询明细,筛选条件为:年度+服务单元+非“不是问题”+影响度;
-    //质量问题查询明细
-
-    @ApiOperation(value = "质量问题饼图明细")
-    @RequestMapping(value = "/supplier/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "质量问题饼图明细", response = TBQualityProblemApplyResult.class)})
-    public Result detail(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                         @ApiParam(value = "供应商") @RequestParam(required = false) InfluenceDegreeEnum degree,
-                         @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<TBQualityProblemApplyResult> resultIPage = qualityAnalyseService.detail(new Page<>(pageNumber, pageSize), serviceUnitId, degree);
-
-        return ResultUtil.ok(resultIPage);
-    }
-
-    //* ②【数据下钻】点击影响度行数据,可显示影响度下质量问题查询明细,筛选条件为:年度+服务单元+非“不是问题”+影响度;
-    //质量问题查询明细
-
-    @ApiOperation(value = "影响度/归因明细")
-    @RequestMapping(value = "/influence/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "影响度/归因明细", response = TBQualityProblemApplyResult.class)})
-    public Result influence(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                            @ApiParam(value = "供应商") @RequestParam(required = false) Long supplierId,
-                            @ApiParam(value = "大区") @RequestParam(required = false) Long region_id,
-                            @ApiParam(value = "影响度") @RequestParam(required = false) InfluenceDegreeEnum Influence_degree,
-                            @ApiParam(value = "问题原因类型") @RequestParam(required = false) QualityProblemReasonEnum reason,
-                            @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<TBQualityProblemApplyResult> resultIPage = qualityAnalyseService.influence(new Page<>(pageNumber, pageSize), serviceUnitId, supplierId,region_id,Influence_degree,reason);
-
-        return ResultUtil.ok(resultIPage);
-    }
-
-}

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

@@ -1,212 +0,0 @@
-package com.qmth.sop.server.api;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
-import com.qmth.sop.business.entity.TBCrm;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.service.ServiceAnalyseService;
-import com.qmth.sop.business.service.TBCrmService;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.util.Result;
-import com.qmth.sop.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.constraints.Max;
-import javax.validation.constraints.Min;
-import java.text.DecimalFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 服务单元分析 控制器
- *
- * @author: shudonghui
- * @date: 2023-08-14 15:55:18
- * @version: 1.0
- * @email: shudonghui@qmth.com.cn
- * @Company: www.qmth.com.cn
- */
-@Api(tags = "服务单元分析 Controller")
-@RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/service/analyse")
-public class ServiceAnalyseController {
-
-    @Resource
-    ServiceAnalyseService serviceAnalyseService;
-
-    @Resource
-    TBCrmService tbCrmService;
-
-    //服务单元列表
-    @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);
-        return ResultUtil.ok(list);
-    }
-
-    /**
-     * 4.服务单元概览
-     * ①项目执行进度=服务单元下已完成的派单(研究生派单下SOP已完结;教务处派单下已有完成的SOP,无在执行的SOP。可能存在教务处多个SOP之间空窗期导致数据的误差,这个指标允许少量误差存在);
-     * ②设备出库总量:当前服务单元下已出库且尚未入库的设备总量;
-     * ③设备占用率:(设备出库总量÷正常设备总量)×100%;
-     * ④在服务人员总数:在执行的SOP现场服务人员数量,包括助理工程师、实施工程师、区域协调人;
-     * ⑤现场人员占用率:(在服务人员总数÷认证有效的在服务人员总数)×100%;
-     * ⑥以上指标都不需提供【数据下钻】;
-     */
-    @ApiOperation(value = "服务单元概览接口")
-    @RequestMapping(value = "/overview", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "服务单元概览", response = Map.class)})
-    public Result overview(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        return ResultUtil.ok(serviceAnalyseService.overview(serviceUnitId));
-    }
-
-    /**
-     * 5.人力供应商项目数量分布及占比:
-     * ①当前服务单元已划分了区域协调人的项目总数、供应商分布占比;
-     * ②派单数:可提供【数据下钻】,点击派单数后可显示该服务单元下已调配了区域协调人的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
-     * ③供应商:点击供应商,显示当前供应商在该服务单元下的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
-     */
-    @ApiOperation(value = "人力供应商项目数量分布及占比")
-    @RequestMapping(value = "/supplier", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "人力供应商项目数量分布及占比", response = Map.class)})
-    public Result supplier(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        Map<String, Object> map = serviceAnalyseService.supplier(serviceUnitId);
-        return ResultUtil.ok(map);
-    }
-
-    /**
-     * ②派单数:可提供【数据下钻】,点击派单数后可显示该服务单元下已调配了区域协调人的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
-     * ③供应商:点击供应商,显示当前供应商在该服务单元下的派单项目明细;明细表需要增加“服务单元”、“供应商”字段;
-     */
-    @ApiOperation(value = "派单明细")
-    @RequestMapping(value = "/supplier/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "派单明细", response = TBCrmResult.class)})
-    public Result dispatch(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                           @ApiParam(value = "供应商") @RequestParam(required = false) 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 = serviceAnalyseService.supplierDetail(new Page<>(pageNumber, pageSize), serviceUnitId, supplierId);
-        return ResultUtil.ok(resultIPage);
-    }
-
-    /**
-     * 6.人力供应商项目角色人员分布:
-     * ①默认选中当前服务单元下项目调配人数最多的人力供应商;
-     * ②显示当前供应商提供的项目角色各自的人数占比;
-     * ③覆盖大区:统计当前服务单元下该供应商区域协调人负责的项目覆盖的大区数量及明细;
-     */
-    @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(serviceUnitId, 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 = false) @RequestParam(required = false) Long 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, null));
-//        List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, regionId, null);
-//        map.put("projectWait", crmAllocation.stream().filter(e -> e.getDistributed() < e.getQuota()).count());
-//        map.put("regionCities", crmAllocation.stream().filter(e -> e.getCity() != null).collect(Collectors.groupingBy(UserArchivesAllocationResult::getCity)).size());
-        map.put("projectWait", serviceAnalyseService.findWaitZone(regionId));
-        map.put("regionCities", tbCrmService.count(new QueryWrapper<TBCrm>().lambda().eq(TBCrm::getRegionId, regionId)));
-        return ResultUtil.ok(map);
-    }
-
-    /**
-     * 7.项目调配完成进度=(差额为0的派单总数÷派单总数)×100%;不提供【数据下钻】
-     */
-    @ApiOperation(value = "项目调配完成进度")
-    @RequestMapping(value = "/project/allocation", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目调配完成进度", response = Double.class)})
-    public Result allocation(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        List<UserArchivesAllocationResult> crmAllocation = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
-
-        double result = crmAllocation.isEmpty() ? 0.00 : (double) crmAllocation.stream().filter(e -> e.getUnDistributed() == 0).count() / crmAllocation.size();
-// 创建DecimalFormat对象,指定保留两位小数
-        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
-// 使用DecimalFormat格式化浮点数结果,得到字符串形式的结果
-        String formattedResult = decimalFormat.format(result);
-// 输出格式化后的结果
-        return ResultUtil.success(formattedResult);
-    }
-
-    /**
-     * 8.人员配额完成进度=(已分配人员数量÷总配额)×100%;不提供【数据下钻】
-     */
-    @ApiOperation(value = "人员配额完成进度")
-    @RequestMapping(value = "/personnel/quota", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "人员配额完成进度", response = Double.class)})
-    public Result quota(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        List<UserArchivesAllocationResult> list = serviceAnalyseService.findCrmAllocation(serviceUnitId, null, null);
-        int quota = list.stream().mapToInt(UserArchivesAllocationResult::getQuota).sum();
-        int distributed = list.stream().mapToInt(UserArchivesAllocationResult::getDistributed).sum();
-        double result = quota == 0 ? 0 : (double) distributed / quota;
-// 创建DecimalFormat对象,指定保留两位小数
-        DecimalFormat decimalFormat = new DecimalFormat("#0.00");
-// 使用DecimalFormat格式化浮点数结果,得到字符串形式的结果
-        String formattedResult = decimalFormat.format(result);
-// 输出格式化后的结果
-        return ResultUtil.success(formattedResult);
-    }
-
-    /**
-     * 9.设备供应商设备使用占比:当前服务单元下各设备供应商提供已出库尚未出库的设备的数量及占比;
-     */
-    @ApiOperation(value = "设备供应商设备使用占比")
-    @RequestMapping(value = "/device/use", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "设备供应商设备使用占比", response = Map.class)})
-    public Result device(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
-        List<Map<String, Object>> list = serviceAnalyseService.device(serviceUnitId);
-        return ResultUtil.ok(list);
-    }
-
-    /**
-     * 10.大区服务人数分布及对比:
-     * 1.当前服务单元下各大区在服务人员的数量分布及对比。单个柱形图可按供应商占比分颜色展示占比。
-     * 2.在服务人员:发布的派单所占用的资源
-     * 3.按照自小单元 大区-供应商 去重
-     */
-    @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) {
-        return ResultUtil.ok(serviceAnalyseService.personnel(serviceUnitId));
-    }
-}

+ 0 - 121
sop-api/src/main/java/com/qmth/sop/server/api/SopAnalyseController.java

@@ -1,121 +0,0 @@
-package com.qmth.sop.server.api;
-
-import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.service.SopAnalyseService;
-import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
-import com.qmth.sop.common.enums.SopAnalyseSortEnum;
-import com.qmth.sop.common.util.Result;
-import com.qmth.sop.common.util.ResultUtil;
-import io.swagger.annotations.*;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
-/**
- * sop分析 控制器
- *
- * @author: shudonghui
- * @date: 2023-08-14 15:55:18
- * @version: 1.0
- * @email: shudonghui@qmth.com.cn
- * @Company: www.qmth.com.cn
- */
-@Api(tags = "sop分析 Controller")
-@RestController
-@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/sop/analyse")
-public class SopAnalyseController {
-
-
-    @Resource
-    SopAnalyseService sopAnalyseService;
-
-
-    @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 = sopAnalyseService.list(startTime,endTime);
-        return ResultUtil.ok(list);
-    }
-
-    /*
-     * 1.监控台是对当前SOP执行情况(延期、违规预警),以及项目管理角色(大区、供应商)对SOP预警处理情况、考勤异常的实时监控;
-     * 2.动态查询条件:时间周期(年度等)、服务单元(已发布状态);
-     * 3.总体概况(中间上面一部分的数据看板)
-     * ①可按照大区/人力供应商进行切换如图;
-     * ②按照派单数TOP3的大区、人力供应商显示;
-     * ③完成进度:该大区/供应商派单的完成进度,按照派单已有完成SOP,且没有在执行的SOP认为是已完成的派单;
-     * ④平均处理时限:该大区/供应商预警处理的平均时限。按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
-     * 若预警为关闭后重启,则需要重新从预警产生到最后一次关闭的时长进行计算;
-     */
-
-    @ApiOperation(value = "总体概况接口")
-    @RequestMapping(value = "/overview", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "总体概况", response = Map.class)})
-    public Result overview(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId,
-                           @ApiParam(value = "分组", required = true) @RequestParam SopAnalyseGroupEnum group) {
-        return ResultUtil.ok(sopAnalyseService.overview(serviceId, group));
-    }
-
-
-    /*
-     * 4.项目/供应商/大区预警待处理TOP10:
-     * ①待处理(待处理预警):按派单统计待处理的预警数(违规+延期);
-     * ②处理最慢(已处理完毕的预警):
-     * A.平均时限:按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
-     * 若预警为关闭后重启,则需要重新从预警产生到最后一次关闭的时长进行计算;
-     * B.排序:按平均时限的倒序排列;
-     * ③处理最快(已处理完毕的预警):
-     * A.平均时限:同上;
-     * B.排序:按平均时限的顺序排列。
-     * ④(预警数)均值:由于供应商分配的项目数量不同,所以单从总数无法判定供应商对预警处理的力度。均值=预警总数/派单数;
-     * ⑤【数据下钻】不提供。
-     */
-
-    @ApiOperation(value = "项目/供应商/大区预警待处理TOP10接口")
-    @RequestMapping(value = "/processing", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目/供应商/大区预警待处理TOP10", response = Map.class)})
-    public Result processing(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId,
-                             @ApiParam(value = "分组", required = true) @RequestParam SopAnalyseGroupEnum group,
-                             @ApiParam(value = "排序", required = true) @RequestParam SopAnalyseSortEnum sort) {
-        List<Map<String, Object>> list = sopAnalyseService.processing(serviceId, group,sort);
-        return ResultUtil.ok(list);
-    }
-
-    /*
-     * 5.供应商预警均值走势:
-     * 供应商近一周预警数的均值走势。
-     * ④(预警数)均值:由于供应商分配的项目数量不同,所以单从总数无法判定供应商对预警处理的力度。均值=预警总数/派单数;
-     */
-
-    @ApiOperation(value = "供应商预警均值走势接口")
-    @RequestMapping(value = "/trend", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "供应商预警均值走势", response = Map.class)})
-    public Result trend(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId) {
-        return ResultUtil.ok(sopAnalyseService.trend(serviceId));
-    }
-
-    /*
-      6.项目/大区/供应商考勤异常TOP:
-      ①(异常)均值=异常总数/派单数;
-      ②【数据下钻】不提供;
-     */
-
-    @ApiOperation(value = "项目/大区/供应商考勤异常TOP接口")
-    @RequestMapping(value = "/attendance", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "项目/大区/供应商考勤异常TOP", response = Map.class)})
-    public Result attendance(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceId,
-                             @ApiParam(value = "分组", required = true) @RequestParam SopAnalyseGroupEnum group) {
-        List<Map<String, Object>> list = sopAnalyseService.attendance(serviceId, group);
-        return ResultUtil.ok(list);
-    }
-
-
-}

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

@@ -1,61 +0,0 @@
-package com.qmth.sop.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.CrmAnalyseResult;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.entity.TBCrm;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * </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);
-
-    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);
-    }
-
-    @SuppressWarnings("MybatisXMapperMethodInspection")
-    List<Map<String, Object>> 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, Long startTime, Long endTime, DataPermissionDto dpr) {
-        return crmDetail(iPage, startTime, endTime, month, year, type, null, null, null, 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);
-    }
-
-    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, 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) {
-        return crmDetail(iPage, startTime, endTime, null, null, null, null, null, serviceId, dpr);
-    }
-
-    List<Map<String, Object>> project(@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);
-
-    Integer findAllocation(@Param("startTime") Long startTime,@Param("endTime")  Long endTime,@Param("dpr")  DataPermissionDto dpr);
-}

+ 0 - 28
sop-business/src/main/java/com/qmth/sop/business/mapper/DeviceMonitorMapper.java

@@ -1,28 +0,0 @@
-package com.qmth.sop.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.entity.SysDevice;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * </p>
- *
- * @author dhshu
- *
- */
-public interface DeviceMonitorMapper extends BaseMapper<SysDevice> {
-
-
-    Map<String, Object> count(@Param("supplierId") Long supplierId,@Param("model") String model);
-
-    List<Map<String, Object>> countByModel(@Param("supplierId") Long supplierId);
-
-    Map<String, Object> countByServiceUnit(@Param("dpr") DataPermissionDto dpr);
-
-    List<Map<String, Object>> countByServiceUnitDetail(@Param("dpr") DataPermissionDto dpr);
-}

+ 0 - 40
sop-business/src/main/java/com/qmth/sop/business/mapper/QualityAnalyseMapper.java

@@ -1,40 +0,0 @@
-package com.qmth.sop.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
-import com.qmth.sop.business.entity.TBQualityProblemApply;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.common.enums.InfluenceDegreeEnum;
-import com.qmth.sop.common.enums.QualityProblemReasonEnum;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * </p>
- *
- * @author dhshu
- *
- */
-public interface QualityAnalyseMapper extends BaseMapper<TBQualityProblemApply> {
-
-
-    IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, @Param("serviceUnitId") Long serviceUnitId, @Param("degree") String degree);
-
-    List<Map<String, Object>> radar(@Param("serviceUnitId")Long serviceUnitId,@Param("supplierId") Long supplierId);
-
-    List<TBService> list(@Param("startTime")Long startTime, @Param("endTime")Long endTime, @Param("dpr") DataPermissionDto dpr);
-
-    Double progress( @Param("serviceUnitId")Long serviceUnitId);
-
-    List<Map<String, Object>> influence( @Param("serviceUnitId")Long serviceUnitId);
-
-    List<Map<String, Object>> pie(@Param("serviceUnitId")Long serviceUnitId,@Param("supplierId") Long supplierId);
-
-    IPage<TBQualityProblemApplyResult> influenceDetail(Page<Object> tPage,@Param("serviceUnitId") Long serviceUnitId,@Param("supplierId") Long supplierId,@Param("region_id") Long region_id,@Param("influenceDegree") String influenceDegree,@Param("reason") String reason);
-}

+ 0 - 54
sop-business/src/main/java/com/qmth/sop/business/mapper/ServiceAnalyseMapper.java

@@ -1,54 +0,0 @@
-package com.qmth.sop.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
-import com.qmth.sop.business.entity.TBService;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * </p>
- *
- * @author dhshu
- */
-public interface ServiceAnalyseMapper extends BaseMapper<TBService> {
-
-
-    List<TBService> list(@Param("startTime") Long startTime, @Param("endTime") Long endTime, @Param("dpr") DataPermissionDto dpr);
-
-    List<Map<String, Object>> projectProgress(@Param("serviceUnitId") Long serviceUnitId);
-
-    List<Map<String, Object>> equipmentOutboundTotal(@Param("serviceUnitId") Long serviceUnitId);
-
-    Integer projectCount(@Param("serviceUnitId") Long serviceUnitId);
-
-    List<Map<String, Object>> supplierDistribution(@Param("serviceUnitId") Long serviceUnitId);
-
-    IPage<TBCrmResult> crmDetail(Page<Object> iPage, @Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
-
-    List<Map<String, Object>> supplierRole(@Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
-
-    List<Map<String, Object>> supplierRegion(@Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
-
-
-    List<Map<String, Object>> device(@Param("serviceUnitId") Long serviceUnitId);
-
-    List<Map<String, Object>> personnel(@Param("serviceUnitId") Long serviceUnitId);
-
-    List<UserArchivesAllocationResult> findCrmAllocation(@Param("serviceUnitId") Long serviceUnitId, @Param("regionId") Long regionId, @Param("supplierId") Long supplierId);
-
-    /**
-     * 查找当前大区待划定派单数量
-     *
-     * @param regionId
-     * @return
-     */
-    int findWaitZone(@Param("regionId") Long regionId);
-}

+ 0 - 46
sop-business/src/main/java/com/qmth/sop/business/mapper/SopAnalyseMapper.java

@@ -1,46 +0,0 @@
-package com.qmth.sop.business.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.CrmSupplierRelation;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.SopMonitor;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.entity.TBSopInfo;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * <p>
- * </p>
- *
- * @author dhshu
- */
-public interface SopAnalyseMapper extends BaseMapper<TBSopInfo> {
-
-    List<TBService> list(@Param("startTime") Long startTime, @Param("endTime") Long endTime,
-            @Param("dpr") DataPermissionDto dpr);
-
-    List<Map<String, Object>> overview(@Param("serviceId") Long serviceId, @Param("type") String type);
-
-    List<Map<String, Object>> trend(@Param("serviceId") Long serviceId);
-
-    List<Map<String, Object>> attendance(@Param("serviceId") Long serviceId, @Param("type") String type);
-
-    /**
-s     * 根据服务单元id查询sop监控数据集
-     *
-     * @param serviceId 服务单元id
-     * @return 监控数据集
-     */
-    List<SopMonitor> findSopMonitorListByServiceId(@Param("serviceId") Long serviceId);
-
-    /**
-     * 根据服务单元查询 派单和供应商关系
-     *
-     * @param serviceId 服务单元id
-     * @return 关系
-     */
-    List<CrmSupplierRelation> findCrmSupplierRelationByServiceId(@Param("serviceId") Long serviceId);
-}

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

@@ -1,41 +0,0 @@
-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.CrmAnalyseResult;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.entity.TBCrm;
-import com.qmth.sop.common.enums.ProductTypeEnum;
-
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * @author dhshu
- * @date:
- */
-public interface CrmAnalyseService extends IService<TBCrm> {
-    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, Object>>> monthly(Long startTime, Long endTime, ProductTypeEnum type);
-
-    IPage<TBCrmResult> monthlyDetail(Page<Object> objectPage, String year, String month, ProductTypeEnum type, Long startTime, Long endTime);
-
-    List<CrmAnalyseResult> supplier(Long startTime, Long endTime);
-
-    IPage<TBCrmResult> supplierDetail(Page<Object> objectPage, Long startTime, Long endTime, Long supplierId);
-
-    List<CrmAnalyseResult> region(Long startTime, Long endTime, ProductTypeEnum type);
-
-    IPage<TBCrmResult> regionDetail(Page<Object> objectPage, Long startTime, Long endTime, String province, ProductTypeEnum type);
-
-    List<CrmAnalyseResult> project(Long startTime, Long endTime);
-
-    IPage<TBCrmResult> projectDetail(Page<Object> objectPage, Long startTime, Long endTime, Long serviceId);
-
-    Map<String, Object> projectCount(Long startTime, Long endTime);
-}

+ 0 - 17
sop-business/src/main/java/com/qmth/sop/business/service/DeviceMonitorService.java

@@ -1,17 +0,0 @@
-package com.qmth.sop.business.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.entity.SysDevice;
-
-import java.util.List;
-import java.util.Map;
-
-public interface DeviceMonitorService extends IService<SysDevice> {
-    Map<String, Object> count(Long supplierId, String model);
-
-    List<Map<String, Object>> countByModel(Long supplierId);
-
-    Map<String, Object> countByServiceUnit();
-
-    List<Map<String, Object>> countByServiceUnitDetail();
-}

+ 0 - 33
sop-business/src/main/java/com/qmth/sop/business/service/QualityAnalyseService.java

@@ -1,33 +0,0 @@
-package com.qmth.sop.business.service;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.google.gson.JsonObject;
-import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
-import com.qmth.sop.business.entity.TBQualityProblemApply;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.common.enums.InfluenceDegreeEnum;
-import com.qmth.sop.common.enums.QualityAnalyseGroupEnum;
-import com.qmth.sop.common.enums.QualityProblemReasonEnum;
-
-import java.util.List;
-import java.util.Map;
-
-public interface QualityAnalyseService extends IService<TBQualityProblemApply> {
-
-    List<TBService> list(Long startTime,Long endTime);
-
-    Double progress(Long serviceUnitId);
-
-    JSONObject influence(Long serviceUnitId, QualityAnalyseGroupEnum group);
-
-    Map<String, Object> pie(Long serviceUnitId);
-
-    Map<String, Map<String, Object>> radar(Long serviceUnitId, QualityAnalyseGroupEnum group);
-
-    IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, Long serviceUnitId, InfluenceDegreeEnum degree);
-
-    IPage<TBQualityProblemApplyResult> influence(Page<Object> tPage, Long serviceUnitId, Long supplierId, Long region_id, InfluenceDegreeEnum influenceDegree, QualityProblemReasonEnum reason);
-}

+ 0 - 50
sop-business/src/main/java/com/qmth/sop/business/service/ServiceAnalyseService.java

@@ -1,50 +0,0 @@
-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.UserArchivesAllocationResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.ServiceUnitOverview;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.ServiceUnitPersonnel;
-import com.qmth.sop.business.entity.TBService;
-
-import java.util.List;
-import java.util.Map;
-
-public interface ServiceAnalyseService extends IService<TBService> {
-    List<TBService> list(Long startTime, Long endTime);
-
-    @Deprecated
-    Map<String, Object> overview1(Long serviceUnitId);
-
-    ServiceUnitOverview overview(Long serviceUnitId);
-
-    Map<String, Object> supplier(Long serviceUnitId);
-
-    IPage<TBCrmResult> supplierDetail(Page<Object> objectPage, Long serviceUnitId, Long supplierId);
-
-    List<Map<String, Object>> supplierRole(Long serviceUnitId, Long supplierId);
-
-    List<Map<String, Object>> supplierRegion(Long serviceUnitId, Long supplierId);
-
-    List<Map<String, Object>> device(Long serviceUnitId);
-
-    @Deprecated
-    List<Map<String, Object>> personnel1(Long serviceUnitId);
-
-    ServiceUnitPersonnel personnel(Long serviceUnitId);
-
-    UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId);
-
-    List<UserArchivesAllocationResult> findCrmAllocation(Long serviceUnitId, Long regionId, Long supplierId);
-
-    /**
-     * 查找当前大区待划定派单数量
-     *
-     * @param regionId
-     * @return
-     */
-    int findWaitZone(Long regionId);
-}

+ 0 - 31
sop-business/src/main/java/com/qmth/sop/business/service/SopAnalyseService.java

@@ -1,31 +0,0 @@
-package com.qmth.sop.business.service;
-
-import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.SopSupplierAvgView;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.SopSupplierAvgViewTimes;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.SopWarnOverview;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.entity.TBSopInfo;
-import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
-import com.qmth.sop.common.enums.SopAnalyseSortEnum;
-
-import java.util.List;
-import java.util.Map;
-
-public interface SopAnalyseService extends IService<TBSopInfo> {
-    List<TBService> list(Long startTime,Long endTime);
-
-    @Deprecated
-    List<Map<String, Object>> overview1(Long serviceId, SopAnalyseGroupEnum group);
-
-    List<SopWarnOverview> overview(Long serviceId,SopAnalyseGroupEnum group);
-
-    List<Map<String, Object>> processing(Long serviceId, SopAnalyseGroupEnum group, SopAnalyseSortEnum sort);
-
-    @Deprecated
-    Map<Object, List<Map<String, Object>>> trend1(Long serviceId);
-
-    List<SopSupplierAvgViewTimes> trend(Long serviceId);
-
-    List<Map<String, Object>> attendance(Long serviceId, SopAnalyseGroupEnum group);
-}

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

@@ -1,155 +0,0 @@
-package com.qmth.sop.business.service.impl;
-
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.CrmAnalyseResult;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.entity.TBCrm;
-import com.qmth.sop.business.mapper.CrmAnalyseMapper;
-import com.qmth.sop.business.service.CrmAnalyseService;
-import com.qmth.sop.business.service.SysUserService;
-import com.qmth.sop.common.enums.ProductTypeEnum;
-import com.qmth.sop.common.util.ServletUtil;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * @author dhshu
- * @date:
- */
-@Service
-public class CrmAnalyseServiceImpl extends ServiceImpl<CrmAnalyseMapper, TBCrm> implements CrmAnalyseService {
-
-    @Resource
-    private SysUserService sysUserService;
-
-    @Override
-    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);
-    }
-
-    @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);
-    }
-
-    @Override
-    public Map<String, List<Map<String, Object>>> monthly(Long startTime, Long endTime, ProductTypeEnum type) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        Map<String, List<Map<String, Object>>> 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;
-    }
-
-    @Override
-    public IPage<TBCrmResult> monthlyDetail(Page<Object> iPage, String year, String month, ProductTypeEnum type,
-            Long startTime, Long endTime) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.crmDetail(iPage, year, month, Objects.nonNull(type) ? type.name() : null, startTime,
-                endTime, 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);
-    }
-
-    @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);
-    }
-
-    @Override
-    public List<CrmAnalyseResult> region(Long startTime, Long endTime, ProductTypeEnum type) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        List<CrmAnalyseResult> region = this.baseMapper.region(startTime, endTime,
-                Objects.nonNull(type) ? type.name() : null, dpr);
-        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.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;
-        }).collect(Collectors.toList());
-    }
-
-    @Override
-    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, province,
-                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());
-        List<Map<String, Object>> project = this.baseMapper.project(startTime, endTime, dpr);
-        List<CrmAnalyseResult> list = new ArrayList<>();
-
-        project.stream().collect(Collectors.groupingBy(map -> map.get("name"))).forEach((k, v) -> {
-            CrmAnalyseResult crmAnalyseResult = new CrmAnalyseResult();
-            crmAnalyseResult.setName((String) k);
-            crmAnalyseResult.setId(Long.valueOf(v.get(0).get("id").toString()));
-            int crmNum = v.stream().collect(Collectors.groupingBy(map -> map.get("crm_no"))).size();
-            final int[] finish = { 0 };
-            v.stream().collect(Collectors.groupingBy(map -> map.get("crm_no"))).forEach((k1, v1) -> {
-                if (v1.stream().anyMatch(map2 -> map2.get("sop_no") != null)
-                        && 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;
-                }
-            });
-            crmAnalyseResult.setRate(finish[0] * 100 / crmNum + "%");
-            list.add(crmAnalyseResult);
-        });
-        //list 按字符串Rate升序排列
-        list.sort(Comparator.comparingDouble(o -> Double.parseDouble(o.getRate().replace("%", ""))));
-        return list;
-
-    }
-
-    @Override
-    public IPage<TBCrmResult> projectDetail(Page<Object> iPage, Long startTime, Long endTime, Long serviceId) {
-        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());
-        Map<String, Object> map = this.baseMapper.projectCount(startTime, endTime, dpr);
-        Integer allocation = this.baseMapper.findAllocation(startTime, endTime, dpr);
-        map = CollectionUtils.isEmpty(map) ? new HashMap<>() : map;
-        map.put("person", Objects.isNull(allocation) ? 0 : allocation);
-        return map;
-    }
-}

+ 0 - 58
sop-business/src/main/java/com/qmth/sop/business/service/impl/DeviceMonitorServiceImpl.java

@@ -1,58 +0,0 @@
-package com.qmth.sop.business.service.impl;
-
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.entity.SysDevice;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.mapper.DeviceMonitorMapper;
-import com.qmth.sop.business.service.DeviceMonitorService;
-import com.qmth.sop.business.service.SysUserService;
-import com.qmth.sop.common.util.ServletUtil;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author dhshu
- * @date:
- */
-@Service
-public class DeviceMonitorServiceImpl extends ServiceImpl<DeviceMonitorMapper, SysDevice>
-        implements DeviceMonitorService {
-
-    @Resource
-    private SysUserService sysUserService;
-
-    @Override
-    public Map<String, Object> count(Long supplierId, String model) {
-        return this.baseMapper.count(supplierId, model);
-    }
-
-    @Override
-    public List<Map<String, Object>> countByModel(Long supplierId) {
-        return this.baseMapper.countByModel(supplierId);
-    }
-
-    @Override
-    public Map<String, Object> countByServiceUnit() {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        Map<String, Object> map = this.baseMapper.countByServiceUnit(dpr);
-
-        Map<String, Object> count = this.count(null, null);
-        if (!CollectionUtils.isEmpty(map)) {
-            count.putAll(map);
-        }
-        return count;
-    }
-
-    @Override
-    public List<Map<String, Object>> countByServiceUnitDetail() {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.countByServiceUnitDetail(dpr);
-    }
-}

+ 0 - 151
sop-business/src/main/java/com/qmth/sop/business/service/impl/QualityAnalyseServiceImpl.java

@@ -1,151 +0,0 @@
-package com.qmth.sop.business.service.impl;
-
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.entity.TBQualityProblemApply;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.mapper.QualityAnalyseMapper;
-import com.qmth.sop.business.service.QualityAnalyseService;
-import com.qmth.sop.business.service.SysUserService;
-import com.qmth.sop.common.enums.InfluenceDegreeEnum;
-import com.qmth.sop.common.enums.QualityAnalyseGroupEnum;
-import com.qmth.sop.common.enums.QualityProblemReasonEnum;
-import com.qmth.sop.common.util.ServletUtil;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-@Service
-public class QualityAnalyseServiceImpl extends ServiceImpl<QualityAnalyseMapper, TBQualityProblemApply> implements QualityAnalyseService {
-
-    @Resource
-    private SysUserService sysUserService;
-
-    @Override
-    public List<TBService> list(Long startTime, Long endTime) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.list(startTime, endTime, dpr);
-    }
-
-
-    @Override
-    public Double progress(Long serviceUnitId) {
-        return this.baseMapper.progress(serviceUnitId);
-    }
-
-    @Override
-    public JSONObject influence(Long serviceUnitId, QualityAnalyseGroupEnum group) {
-        List<Map<String, Object>> influence = this.baseMapper.influence(serviceUnitId);
-//        Map<String, Map<String, Object>> result = new HashMap<>();
-        JSONObject result = new JSONObject();
-
-        if (group.equals(QualityAnalyseGroupEnum.INFLUENCE_REGION)) {
-            influence.stream().filter(map -> map.get("region_name") != null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-//                Map<String, Object> map = new HashMap<>();
-                JSONObject map = new JSONObject();
-                v.stream().filter(map1 -> map1.get("Influence_degree") != null).collect(Collectors.groupingBy(map1 -> map1.get("Influence_degree"))).forEach((k1, v1) -> {
-                    map.put(k1.toString(), v1.size());
-                });
-                map.put("id", v.get(0).get("region_id").toString());
-                result.put(k.toString(), map);
-            });
-        } else if (group.equals(QualityAnalyseGroupEnum.INFLUENCE_SUPPLIER)) {
-            influence.stream().filter(map -> map.get("Influence_degree") != null).collect(Collectors.groupingBy(map -> map.get("Influence_degree"))).forEach((k, v) -> {
-                JSONObject map = new JSONObject();
-
-                v.stream().filter(map1 -> map1.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier"))).forEach((k1, v1) -> {
-                    JSONObject map1 = new JSONObject();
-                    map1.put("value", v1.size());
-                    map1.put("id", v.get(0).get("supplier_id").toString());
-                    map.put(k1.toString(), map1);
-                });
-                result.put(k.toString(), map);
-            });
-        } else if (group.equals(QualityAnalyseGroupEnum.REASON_REGION)) {
-            influence.stream().filter(map -> map.get("region_name") != null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-//                Map<String, Object> map = new HashMap<>();
-                JSONObject map = new JSONObject();
-                v.stream().filter(map1 -> map1.get("Influence_degree") != null).collect(Collectors.groupingBy(map1 -> map1.get("Influence_degree"))).forEach((k1, v1) -> {
-                    map.put(k1.toString(), v1.size());
-                });
-                map.put("id", v.get(0).get("region_id").toString());
-                result.put(k.toString(), map);
-            });
-        } else if (group.equals(QualityAnalyseGroupEnum.REASON_SUPPLIER)) {
-            influence.stream().filter(map -> map.get("reason") != null).collect(Collectors.groupingBy(map -> map.get("reason"))).forEach((k, v) -> {
-                JSONObject map = new JSONObject();
-
-                v.stream().filter(map1 -> map1.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier"))).forEach((k1, v1) -> {
-                    JSONObject map1 = new JSONObject();
-                    map1.put("value", v1.size());
-                    map1.put("id", v.get(0).get("supplier_id").toString());
-                    map.put(k1.toString(), map1);
-                });
-                result.put(k.toString(), map);
-            });
-        }
-        return result;
-    }
-
-
-    @Override
-    public Map<String, Object> pie(Long serviceUnitId) {
-        List<Map<String, Object>> pie = this.baseMapper.pie(serviceUnitId, null);
-        Map<String, Object> result = new HashMap<>();
-        pie.stream().filter(map1 -> map1.get("Influence_degree") != null).collect(Collectors.groupingBy(map -> map.get("Influence_degree"))).forEach((k, v) -> result.put(k.toString(), v.stream().filter(map1 -> map1.get("count") != null).mapToLong(map1 -> (long) map1.get("count")).sum()));
-        return result;
-    }
-
-    @Override
-    public Map<String, Map<String, Object>> radar(Long serviceUnitId, QualityAnalyseGroupEnum group) {
-        List<Map<String, Object>> radar = this.baseMapper.radar(serviceUnitId, null);
-        Map<String, Map<String, Object>> result = new HashMap<>();
-        radar.stream().filter(map1 -> map1.get("reason") != null).collect(Collectors.groupingBy(map -> map.get("reason"))).forEach((k, v) -> {
-            Map<String, Object> countMap = new HashMap<>(), map = new HashMap<>();
-            countMap.put(k.toString(), v.stream().filter(map1 -> map1.get("count") != null).mapToLong(map1 -> (long) map1.get("count")).sum());
-            if (result.containsKey("all")) {
-                map = result.get("all");
-                map.put(k.toString(), countMap.get(k.toString()));
-            } else {
-                map.put(k.toString(), countMap.get(k.toString()));
-            }
-            result.put("all", map);
-        });
-
-        if (group.equals(QualityAnalyseGroupEnum.REASON_REGION)) {
-            radar.stream().filter(map1 -> map1.get("region_name") != null).collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-                Map<String, Object> z = new HashMap<>();
-                v.stream().filter(map1 -> map1.get("reason") != null).collect(Collectors.groupingBy(map2 -> map2.get("reason"))).forEach((k1, v1) -> z.put(k1.toString(), v1.stream().filter(map1 -> map1.get("count") != null).mapToLong(map1 -> (long) map1.get("count")).sum()));
-                result.put(k.toString(), z);
-            });
-        } else if (group.equals(QualityAnalyseGroupEnum.REASON_SUPPLIER)) {
-            radar.stream().filter(map1 -> map1.get("supplier") != null).collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
-                Map<String, Object> z = new HashMap<>();
-                v.stream().filter(map1 -> map1.get("reason") != null).collect(Collectors.groupingBy(map2 -> map2.get("reason"))).forEach((k1, v1) -> z.put(k1.toString(), v1.stream().filter(map1 -> map1.get("count") != null).mapToLong(map1 -> (long) map1.get("count")).sum()));
-                result.put(k.toString(), z);
-            });
-        }
-        return result;
-    }
-
-    @Override
-    public IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, Long serviceUnitId, InfluenceDegreeEnum degree) {
-        return this.baseMapper.detail(objectPage, serviceUnitId, Objects.nonNull(degree) ? degree.toString() : null);
-    }
-
-    @Override
-    public IPage<TBQualityProblemApplyResult> influence(Page<Object> tPage, Long serviceUnitId, Long supplierId, Long region_id, InfluenceDegreeEnum influenceDegree, QualityProblemReasonEnum reason) {
-        return this.baseMapper.influenceDetail(tPage, serviceUnitId, supplierId, region_id, Objects.nonNull(influenceDegree) ? influenceDegree.toString() : null, Objects.nonNull(reason) ? reason.toString() : null);
-    }
-}

+ 0 - 398
sop-business/src/main/java/com/qmth/sop/business/service/impl/ServiceAnalyseServiceImpl.java

@@ -1,398 +0,0 @@
-package com.qmth.sop.business.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.CrmArchivesAllocationResult;
-import com.qmth.sop.business.bean.result.TBCrmResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationResult;
-import com.qmth.sop.business.bean.result.UserArchivesAllocationSubTotalResult;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.RegionPersonnel;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.ServiceUnitOverview;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.ServiceUnitPersonnel;
-import com.qmth.sop.business.bean.result.analyze.serviceUnit.SupplierPersonnel;
-import com.qmth.sop.business.entity.*;
-import com.qmth.sop.business.mapper.ServiceAnalyseMapper;
-import com.qmth.sop.business.service.*;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.CrmStatusEnum;
-import com.qmth.sop.common.enums.DeviceStatusEnum;
-import com.qmth.sop.common.enums.ExceptionResultEnum;
-import com.qmth.sop.common.enums.InOutTypeEnum;
-import com.qmth.sop.common.util.ServletUtil;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Service
-public class ServiceAnalyseServiceImpl extends ServiceImpl<ServiceAnalyseMapper, TBService> implements ServiceAnalyseService {
-
-    @Resource
-    private TBSopInfoService tbSopInfoService;
-
-    @Resource
-    private TBUserArchivesSupplierService tbUserArchivesSupplierService;
-
-    @Resource
-    private SysUserService sysUserService;
-
-    @Resource
-    private TBUserArchivesAllocationService tbUserArchivesAllocationService;
-
-    @Resource
-    private TBCrmService tbCrmService;
-
-    @Resource
-    private TBDeviceInOutService tbDeviceInOutService;
-
-    @Resource
-    private SysDeviceService sysDeviceService;
-
-    @Resource
-    private TBServiceRegionService tbServiceRegionService;
-
-    @Resource
-    private SysSupplierService sysSupplierService;
-
-    @Override
-    public List<TBService> list(Long startTime, Long endTime) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.list(startTime, endTime, dpr);
-    }
-
-    /**
-     * 4.服务单元概览
-     * ①项目执行进度=服务单元下已完成的派单(研究生派单下SOP已完结;教务处派单下已有完成的SOP,无在执行的SOP。可能存在教务处多个SOP之间空窗期导致数据的误差,这个指标允许少量误差存在);
-     * ②设备出库总量:当前服务单元下已出库且尚未入库的设备总量;
-     * ③设备占用率:(设备出库总量÷正常设备总量)×100%;
-     * ④在服务人员总数:在执行的SOP现场服务人员数量,包括助理工程师、实施工程师、区域协调人;
-     * ⑤现场人员占用率:(在服务人员总数÷认证有效的在服务人员总数)×100%;
-     */
-    @Deprecated
-    @Override
-    public Map<String, Object> overview1(Long serviceUnitId) {
-        Map<String, Object> map = new HashMap<>();
-        List<Map<String, Object>> list = this.baseMapper.projectProgress(serviceUnitId);
-        int finishCount = 0, size = 0;
-        if (!CollectionUtils.isEmpty(list)) {
-            size = list.size();
-            finishCount = (int) list.stream().filter(s -> Objects.nonNull(s.get("status")) && s.get("status").equals("FINISH")).count();
-        }
-        BigDecimal sizeBig = BigDecimal.valueOf(size), percent = BigDecimal.valueOf(100),
-                finishCompleteRate = BigDecimal.valueOf(finishCount);
-        finishCompleteRate = size > 0 ? finishCompleteRate.divide(sizeBig, 2, BigDecimal.ROUND_HALF_UP).multiply(percent).setScale(2, BigDecimal.ROUND_HALF_UP) : sizeBig;
-        map.put("projectProgress", finishCompleteRate);
-        List<Map<String, Object>> deviceMap = this.baseMapper.equipmentOutboundTotal(serviceUnitId);
-        map.put("equipmentOutboundTotal", !CollectionUtils.isEmpty(deviceMap) ? Integer.parseInt(deviceMap.get(0).get("outs").toString()) : 0);
-        int totalDevices = !CollectionUtils.isEmpty(deviceMap) ? Integer.parseInt(deviceMap.get(0).get("deviceSum").toString()) : 0;
-        BigDecimal totalDevicesBig = BigDecimal.valueOf(totalDevices),
-                OutboundTotal = BigDecimal.valueOf(Integer.parseInt(map.get("equipmentOutboundTotal").toString())),
-                deviceRate = totalDevices > 0 ? OutboundTotal.divide(totalDevicesBig, 2, BigDecimal.ROUND_HALF_UP).multiply(percent).setScale(2, BigDecimal.ROUND_HALF_UP) : OutboundTotal;
-        map.put("equipmentOccupancyRate", deviceRate);
-//        List<Map<String, Object>> sopPassageMap = tbSopInfoService.findSopPassage(serviceUnitId);
-        Integer distributed = 0;
-//        if (!CollectionUtils.isEmpty(sopPassageMap)) {
-//            for (Map m : sopPassageMap) {
-//                //需要去重
-//                String regionUserStr = Objects.nonNull(m) && Objects.nonNull(m.get("regionUserIds")) ? m.get("regionUserIds").toString() : null;
-//                if (Objects.nonNull(regionUserStr)) {
-//                    String[] strs = regionUserStr.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    distributed = distributed + set.size();
-//                }
-//                String engineerUserStr = Objects.nonNull(m) && Objects.nonNull(m.get("engineerUserIds")) ? m.get("engineerUserIds").toString() : null;
-//                if (Objects.nonNull(engineerUserStr)) {
-//                    String[] strs = engineerUserStr.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    distributed = distributed + set.size();
-//                }
-//                String assistantEngineerUserId = Objects.nonNull(m) && Objects.nonNull(m.get("assistantEngineerUserIds")) ? m.get("assistantEngineerUserIds").toString() : null;
-//                if (Objects.nonNull(assistantEngineerUserId)) {
-//                    String[] strs = assistantEngineerUserId.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    distributed = distributed + set.size();
-//                }
-//            }
-//        }
-        map.put("servicePersonnelTotal", distributed);
-        //认证有效的人员总数
-        int totalUserArchives = tbUserArchivesSupplierService.countAuthentication();
-        BigDecimal totalUserBig = BigDecimal.valueOf(totalUserArchives),
-                userServicesTotal = BigDecimal.valueOf(distributed),
-                userRate = totalUserArchives > 0 ? userServicesTotal.divide(totalUserBig, 2, BigDecimal.ROUND_HALF_UP).multiply(percent).setScale(2, BigDecimal.ROUND_HALF_UP) : userServicesTotal;
-        map.put("sitePersonnelOccupancyRate", userRate);
-        return map;
-    }
-
-    /**
-     * 4.服务单元概览
-     * ①项目执行进度=服务单元下已完成的派单(研究生派单下SOP已完结;教务处派单下已有完成的SOP,无在执行的SOP。可能存在教务处多个SOP之间空窗期导致数据的误差,这个指标允许少量误差存在);
-     * ②设备出库总量:当前服务单元下已出库且尚未入库的设备总量;
-     * ③设备占用率:(设备出库总量÷正常设备总量)×100%;
-     * ④在服务人员总数:在执行的SOP现场服务人员数量,包括助理工程师、实施工程师、区域协调人;
-     * ⑤现场人员占用率:(在服务人员总数÷认证有效的在服务人员总数)×100%;
-     */
-    @Override
-    public ServiceUnitOverview overview(Long serviceUnitId) {
-        ServiceUnitOverview result = new ServiceUnitOverview();
-        BigDecimal percent = new BigDecimal(100);
-        // -- 项目执行进度 --
-        List<TBCrm> tbCrmDatasource = tbCrmService.list(new QueryWrapper<TBCrm>().lambda()
-                .eq(TBCrm::getServiceId, serviceUnitId)
-                .eq(TBCrm::getEnable,true));
-        int crmFinishCount = (int) tbCrmDatasource.stream().filter(e -> CrmStatusEnum.FINISH.equals(e.getStatus())).count();
-        int crmTotalCount = tbCrmDatasource.size();
-        BigDecimal projectProgress = new BigDecimal(0);
-        if (crmTotalCount > 0){
-            projectProgress = new BigDecimal(crmFinishCount).divide(new BigDecimal(crmTotalCount), 2, RoundingMode.HALF_UP).multiply(percent);
-        }
-
-        // -- 设备出库总量 -- (可以知道是哪个设备没入库)
-        List<TBDeviceInOut> tbDeviceInOutDatasource = tbDeviceInOutService.list(new QueryWrapper<TBDeviceInOut>().lambda().eq(TBDeviceInOut::getServiceId, serviceUnitId));
-
-        // 设备入库map -> (设备编号,入库次数)
-        Map<String, Integer> deviceInMap = tbDeviceInOutDatasource
-                .stream()
-                .filter(e -> InOutTypeEnum.IN.equals(e.getType()))
-                .collect(Collectors.toMap(TBDeviceInOut::getDeviceSerialNo, e -> 1, Integer::sum));
-
-        // 设备出库map -> (设备编号,出库次数)
-        int equipmentOutboundTotal = 0;
-        Map<String, Integer> deviceOutMap = tbDeviceInOutDatasource
-                .stream()
-                .filter(e -> InOutTypeEnum.OUT.equals(e.getType()))
-                .collect(Collectors.toMap(TBDeviceInOut::getDeviceSerialNo, e -> 1, Integer::sum));
-
-        for (String deviceNo : deviceOutMap.keySet()) {
-            // 出库次数
-            Integer outCount = deviceOutMap.get(deviceNo);
-            Integer inCount = 0;
-            if (deviceInMap.containsKey(deviceNo)) {
-                inCount = deviceInMap.get(deviceNo);
-            }
-            if (inCount > outCount) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("在服务单元下,设备[%s]入库次数比出库次数多异常", deviceNo));
-            }
-            outCount = outCount - inCount;
-            if (outCount > 1) {
-                throw ExceptionResultEnum.ERROR.exception(String.format("在服务单元下,设备[%s]出库次数异常", deviceNo));
-            }
-            equipmentOutboundTotal = equipmentOutboundTotal + outCount;
-        }
-
-        // -- 设备占用率 --
-        int normalDeviceCount = sysDeviceService.count(new QueryWrapper<SysDevice>().lambda().eq(SysDevice::getStatus, DeviceStatusEnum.NORMAL));
-        BigDecimal equipmentOccupancyRate = new BigDecimal(0);
-        if (normalDeviceCount > 0){
-            equipmentOccupancyRate = new BigDecimal(equipmentOutboundTotal).divide(new BigDecimal(normalDeviceCount), 2, RoundingMode.HALF_UP).multiply(percent);
-        }
-
-        // -- 在服务人员总数 --
-//        List<Map<String, Object>> sopPassageMap = tbSopInfoService.findSopPassage(serviceUnitId);
-        Integer servicePersonnelTotal = 0;
-//        if (!CollectionUtils.isEmpty(sopPassageMap)) {
-//            for (Map m : sopPassageMap) {
-//                //需要去重
-//                String regionUserStr = Objects.nonNull(m) && Objects.nonNull(m.get("regionUserIds")) ? m.get("regionUserIds").toString() : null;
-//                if (Objects.nonNull(regionUserStr)) {
-//                    String[] strs = regionUserStr.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    servicePersonnelTotal = servicePersonnelTotal + set.size();
-//                }
-//                String engineerUserStr = Objects.nonNull(m) && Objects.nonNull(m.get("engineerUserIds")) ? m.get("engineerUserIds").toString() : null;
-//                if (Objects.nonNull(engineerUserStr)) {
-//                    String[] strs = engineerUserStr.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    servicePersonnelTotal = servicePersonnelTotal + set.size();
-//                }
-//                String assistantEngineerUserId = Objects.nonNull(m) && Objects.nonNull(m.get("assistantEngineerUserIds")) ? m.get("assistantEngineerUserIds").toString() : null;
-//                if (Objects.nonNull(assistantEngineerUserId)) {
-//                    String[] strs = assistantEngineerUserId.split(",");
-//                    Set<String> set = new HashSet<>(Arrays.asList(strs));
-//                    servicePersonnelTotal = servicePersonnelTotal + set.size();
-//                }
-//            }
-//        }
-
-        //认证有效的人员总数
-        int totalUserArchives = tbUserArchivesSupplierService.countAuthentication();
-        BigDecimal sitePersonnelOccupancyRate = new BigDecimal(0);
-        if (totalUserArchives > 0) {
-            sitePersonnelOccupancyRate = new BigDecimal(servicePersonnelTotal).divide(new BigDecimal(totalUserArchives), 2, RoundingMode.HALF_UP).multiply(percent);
-        }
-        result.setProjectProgress(projectProgress);
-        result.setEquipmentOutboundTotal(equipmentOutboundTotal);
-        result.setEquipmentOccupancyRate(equipmentOccupancyRate);
-        result.setServicePersonnelTotal(servicePersonnelTotal);
-        result.setSitePersonnelOccupancyRate(sitePersonnelOccupancyRate);
-        return result;
-    }
-
-    /**
-     * ①当前服务单元已划分了区域协调人的项目总数、供应商分布占比;
-     */
-    @Override
-    public Map<String, Object> supplier(Long serviceUnitId) {
-        Map<String, Object> map = new HashMap<>();
-        map.put("projectCount", this.baseMapper.projectCount(serviceUnitId));
-        List<Map<String, Object>> maps = this.baseMapper.supplierDistribution(serviceUnitId);
-//        maps = maps.stream().peek(m -> m.put("percent",(Integer) map.get("projectCount")==0?0: ((Long) m.get("count")) * 100 / ((Integer) map.get("projectCount")) + "%")).collect(Collectors.toList());
-        map.put("supplierDistribution", maps);
-        return map;
-    }
-
-    @Override
-    public IPage<TBCrmResult> supplierDetail(Page<Object> iPage, Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.crmDetail(iPage, serviceUnitId, supplierId);
-    }
-
-    @Override
-    public List<Map<String, Object>> supplierRole(Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.supplierRole(serviceUnitId, supplierId);
-    }
-
-    @Override
-    public List<Map<String, Object>> supplierRegion(Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.supplierRegion(serviceUnitId, supplierId);
-    }
-
-
-    @Override
-    public List<Map<String, Object>> device(Long serviceUnitId) {
-        return this.baseMapper.device(serviceUnitId);
-    }
-
-    @Deprecated
-    @Override
-    public List<Map<String, Object>> personnel1(Long serviceUnitId) {
-        return this.baseMapper.personnel(serviceUnitId);
-    }
-
-    @Override
-    public ServiceUnitPersonnel personnel(Long serviceUnitId) {
-        List<TBCrm> publishCrmList = tbCrmService.list(new QueryWrapper<TBCrm>()
-                .lambda()
-                .eq(TBCrm::getServiceId, serviceUnitId)
-                .eq(TBCrm::getEnable, true));
-//                .eq(TBCrm::getStatus, CrmStatusEnum.PUBLISH));
-
-        Set<Long> regionIdSet = publishCrmList.stream()
-                .filter(e -> e.getRegionId() != null && e.getRegionId() > 0)
-                .map(TBCrm::getRegionId).collect(Collectors.toSet());
-
-        List<RegionPersonnel> regionPersonnelList = new ArrayList<>();
-
-        // 全量供应商id集合
-        Set<Long> supplierIdSet = new HashSet<>();
-        for (Long regionId : regionIdSet) {
-            TBServiceRegion tbServiceRegion = tbServiceRegionService.getById(regionId);
-            if (Objects.isNull(tbServiceRegion)) {
-                throw ExceptionResultEnum.ERROR.exception("未找到大区信息");
-            }
-            String regionName = tbServiceRegion.getRegionName();
-
-            List<TBCrm> crmList = publishCrmList.stream()
-                    .filter(e -> regionId.equals(e.getRegionId()))
-                    .collect(Collectors.toList());
-
-            // 大区下供应商和人员关系Map
-            Map<Long, Set<Long>> supplierMap = new HashMap<>();
-            for (TBCrm tbCrm : crmList) {
-                List<CrmArchivesAllocationResult> detail = tbUserArchivesAllocationService.findAllocationByCrmNo(tbCrm.getCrmNo());
-                detail.forEach(e -> {
-                    Long supplierId = e.getSupplierId();
-                    Long userId = e.getUserId();
-                    if (supplierMap.containsKey(supplierId)) {
-                        supplierMap.get(supplierId).add(userId);
-                    } else {
-                        Set<Long> userIdSet = new HashSet<>();
-                        userIdSet.add(userId);
-                        supplierMap.put(supplierId, userIdSet);
-                        supplierIdSet.add(supplierId);
-                    }
-                });
-            }
-
-            List<SupplierPersonnel> supplierPersonnelList = new ArrayList<>();
-            int count = 0;
-            for (Long supplierId : supplierMap.keySet()) {
-                SysSupplier sysSupplier = sysSupplierService.getById(supplierId);
-                String supplierName = sysSupplier.getName();
-
-                SupplierPersonnel supplierPersonnel = new SupplierPersonnel();
-                supplierPersonnel.setSupplierId(supplierId);
-                supplierPersonnel.setSupplierName(supplierName);
-                int cellCount = supplierMap.get(supplierId).size();
-                supplierPersonnel.setCount(cellCount);
-                supplierPersonnelList.add(supplierPersonnel);
-                count = count + cellCount;
-            }
-            RegionPersonnel regionPersonnel = new RegionPersonnel();
-
-            regionPersonnel.setRegionId(regionId);
-            regionPersonnel.setRegionName(regionName);
-            regionPersonnel.setSupplierPersonnelInfo(supplierPersonnelList);
-            regionPersonnel.setCount(count);
-            regionPersonnelList.add(regionPersonnel);
-        }
-        ServiceUnitPersonnel serviceUnitPersonnel = new ServiceUnitPersonnel();
-        serviceUnitPersonnel.setSupplierIdSet(supplierIdSet);
-        serviceUnitPersonnel.setRegionPersonnelInfo(regionPersonnelList);
-        return serviceUnitPersonnel;
-    }
-
-
-    @Override
-    public UserArchivesAllocationSubTotalResult findCrmAllocationSubTotal(Long serviceUnitId, Long regionId, Long supplierId) {
-
-//        List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocation(serviceUnitId, regionId, supplierId);
-        IPage<UserArchivesAllocationResult> userArchivesAllocationResultIPage = tbUserArchivesAllocationService.findCrmAllocationPage(serviceUnitId, null, null, null, null, null, regionId, SystemConstant.PAGE_NUMBER_MIN, SystemConstant.PAGE_SIZE_MAX_SELECT);
-        Integer publishedCrmCount = 0, totalCrmCount = 0, coordinatorQuota = 0, coordinatorDistributed = 0, effectQuota = 0,
-                effectDistributed = 0, assistantQuota = 0, assistantDistributed = 0;
-        if (Objects.nonNull(userArchivesAllocationResultIPage)) {
-            List<UserArchivesAllocationResult> list = userArchivesAllocationResultIPage.getRecords();
-            publishedCrmCount = Math.toIntExact(list.stream().filter(e -> CrmStatusEnum.PUBLISH.equals(e.getCrmStatus())).count());
-            totalCrmCount = list.size();
-            coordinatorQuota = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorQuota).sum();
-            coordinatorDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getCoordinatorDistributed).sum();
-            effectQuota = list.stream().mapToInt(UserArchivesAllocationResult::getEffectQuota).sum();
-            effectDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getEffectDistributed).sum();
-            assistantQuota = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantQuota).sum();
-            assistantDistributed = list.stream().mapToInt(UserArchivesAllocationResult::getAssistantDistributed).sum();
-        }
-        UserArchivesAllocationSubTotalResult result = new UserArchivesAllocationSubTotalResult();
-        result.setPublishedCrmCount(publishedCrmCount);
-        result.setTotalCrmCount(totalCrmCount);
-        result.setCoordinatorDistributed(coordinatorDistributed);
-        result.setCoordinatorQuota(coordinatorQuota);
-        result.setEffectDistributed(effectDistributed);
-        result.setEffectQuota(effectQuota);
-        result.setAssistantDistributed(assistantDistributed);
-        result.setAssistantQuota(assistantQuota);
-        return result;
-    }
-
-    @Override
-    public List<UserArchivesAllocationResult> findCrmAllocation(Long serviceUnitId, Long regionId, Long supplierId) {
-        return this.baseMapper.findCrmAllocation(serviceUnitId, regionId, supplierId);
-    }
-
-    /**
-     * 查找当前大区待划定派单数量
-     *
-     * @param regionId
-     * @return
-     */
-    @Override
-    public int findWaitZone(Long regionId) {
-        return this.baseMapper.findWaitZone(regionId);
-    }
-}

+ 0 - 492
sop-business/src/main/java/com/qmth/sop/business/service/impl/SopAnalyseServiceImpl.java

@@ -1,492 +0,0 @@
-package com.qmth.sop.business.service.impl;
-
-import cn.hutool.core.date.DateUnit;
-import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.qmth.sop.business.bean.dto.DataPermissionDto;
-import com.qmth.sop.business.bean.result.analyze.sopWarn.*;
-import com.qmth.sop.business.entity.SysUser;
-import com.qmth.sop.business.entity.TBService;
-import com.qmth.sop.business.entity.TBSopInfo;
-import com.qmth.sop.business.mapper.SopAnalyseMapper;
-import com.qmth.sop.business.service.SopAnalyseService;
-import com.qmth.sop.business.service.SysUserService;
-import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.SopAnalyseGroupEnum;
-import com.qmth.sop.common.enums.SopAnalyseSortEnum;
-import com.qmth.sop.common.util.ServletUtil;
-import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.time.DateFormatUtils;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.*;
-import java.util.stream.Collectors;
-
-@Service
-public class SopAnalyseServiceImpl extends ServiceImpl<SopAnalyseMapper, TBSopInfo> implements SopAnalyseService {
-
-    @Resource
-    private SysUserService sysUserService;
-
-    @Override
-    public List<TBService> list(Long startTime, Long endTime) {
-        SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
-        DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        return this.baseMapper.list(startTime, endTime, dpr);
-    }
-
-    /**
-     * * ①可按照大区/人力供应商进行切换如图;
-     * * ②按照派单数TOP3的大区、人力供应商显示;
-     * * ③完成进度:该大区/供应商派单的完成进度,按照派单已有完成SOP,且没有在执行的SOP认为是已完成的派单;
-     * * ④平均处理时限:该大区/供应商预警处理的平均时限。按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
-     */
-    @Deprecated
-    @Override
-    public List<Map<String, Object>> overview1(Long serviceId, SopAnalyseGroupEnum group) {
-        List<Map<String, Object>> list = this.baseMapper.overview(serviceId, group.name());
-        List<Map<String, Object>> result = new ArrayList<>();
-        if (group.equals(SopAnalyseGroupEnum.REGION)) {
-            list.stream().filter(map -> map.get("region_name") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("region_name", k);
-                        processOverviewData(v, map);
-                        result.add(map);
-                    });
-        } else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
-            list.stream().filter(map -> map.get("supplier") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("supplier", k);
-                        processOverviewData(v, map);
-                        result.add(map);
-                    });
-        }
-        return result.stream().sorted(Comparator.comparingInt(o -> Integer.parseInt(o.get("crmNum").toString())))
-                .limit(3).collect(Collectors.toList());
-    }
-
-    /**
-     * * ①可按照大区/人力供应商进行切换如图;
-     * * ②按照派单数TOP3的大区、人力供应商显示;
-     * * ③完成进度:该大区/供应商派单的完成进度,按照派单已有完成SOP,且没有在执行的SOP认为是已完成的派单;
-     * * ④平均处理时限:该大区/供应商预警处理的平均时限。按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
-     */
-    @Override
-    public List<SopWarnOverview> overview(Long serviceId, SopAnalyseGroupEnum group) {
-        List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
-        List<SopWarnOverview> result = new ArrayList<>();
-        switch (group) {
-        case REGION:
-            Set<Long> regionIdSet = sopMonitorList.stream().filter(e -> e.getRegionId() != null && e.getRegionId() > 0)
-                    .map(SopMonitor::getRegionId).collect(Collectors.toSet());
-            for (Long regionId : regionIdSet) {
-                List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> regionId.equals(e.getRegionId()))
-                        .collect(Collectors.toList());
-                String regionName = dataCell.get(0).getRegionName();
-                SopWarnOverview regionOverview = buildSopOverviewStatistic(dataCell);
-                regionOverview.setRegionId(regionId);
-                regionOverview.setRegionName(regionName);
-                result.add(regionOverview);
-            }
-            break;
-        case SUPPLIER:
-            // 由大区经理兼任不显示
-            Set<Long> supplierIdSet = sopMonitorList.stream()
-                    .filter(e -> e.getSupplierId() != null && e.getSupplierId() > 0).map(SopMonitor::getSupplierId)
-                    .collect(Collectors.toSet());
-            for (Long supplierId : supplierIdSet) {
-                List<SopMonitor> dataCell = sopMonitorList.stream().filter(e -> supplierId.equals(e.getSupplierId()))
-                        .collect(Collectors.toList());
-                SopWarnOverview supplierOverview = buildSopOverviewStatistic(dataCell);
-                supplierOverview.setSupplierName(dataCell.get(0).getSupplierName());
-                supplierOverview.setSupplierId(supplierId);
-                result.add(supplierOverview);
-            }
-            break;
-        }
-        return result;
-    }
-
-    /**
-     * 创建sop监控统计
-     *
-     * @param dataCell 数据集
-     * @return sop监控
-     */
-    private SopWarnOverview buildSopOverviewStatistic(List<SopMonitor> dataCell) {
-        SopWarnOverview sopWarnOverview = new SopWarnOverview();
-        if (CollectionUtils.isNotEmpty(dataCell)) {
-            int crmNum = (int) dataCell.stream().map(SopMonitor::getCrmNo).distinct().count();
-            int finishCrmNum = (int) (crmNum - dataCell.stream().filter(e -> !e.getFinishStatus())
-                    .map(SopMonitor::getCrmNo).distinct().count());
-            int effectAvgTimeCount = 0;
-            long effectTotalMinutes = 0L;
-            int violationNum = 0;
-            int finishViolationNum = 0;
-            int delayNum = 0;
-            int finishDelayNum = 0;
-
-            for (SopMonitor sopMonitor : dataCell) {
-                SopMonitorEnum sopMonitorType = sopMonitor.getSopMonitorType();
-                switch (sopMonitorType) {
-                case DELAY_WARN:
-                    delayNum++;
-                    break;
-                case VIOLATION:
-                    violationNum++;
-                    break;
-                }
-
-                Boolean finishStatus = sopMonitor.getFinishStatus();
-                if (finishStatus) {
-                    Long startTime = sopMonitor.getStartTime();
-                    Long closeTime = sopMonitor.getCloseTime();
-                    if (startTime != null && startTime > 0 && closeTime != null && closeTime > 0) {
-                        effectAvgTimeCount++;
-                        long cellMinutes = DateUtil.between(new Date(startTime), new Date(closeTime), DateUnit.MINUTE);
-                        effectTotalMinutes = effectTotalMinutes + cellMinutes;
-                    }
-
-                    switch (sopMonitorType) {
-                    case DELAY_WARN:
-                        finishDelayNum++;
-                        break;
-                    case VIOLATION:
-                        finishViolationNum++;
-                        break;
-                    }
-                }
-            }
-
-            sopWarnOverview.setCrmNum(crmNum);
-            sopWarnOverview.setFinishCrmNum(finishCrmNum);
-            BigDecimal avgMinutes = new BigDecimal(0);
-            if (effectAvgTimeCount > 0) {
-                avgMinutes = new BigDecimal(effectTotalMinutes).divide(new BigDecimal(effectAvgTimeCount), 2,
-                        RoundingMode.HALF_UP);
-            }
-            sopWarnOverview.setAvgMinutes(avgMinutes);
-            sopWarnOverview.setViolationNum(violationNum);
-            sopWarnOverview.setFinishViolationNum(finishViolationNum);
-            sopWarnOverview.setDelayNum(delayNum);
-            sopWarnOverview.setFinishDelayNum(finishDelayNum);
-        }
-        return sopWarnOverview;
-    }
-
-    private static void processOverviewData(List<Map<String, Object>> v, Map<String, Object> map) {
-        //派单数
-        map.put("crmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size());
-        //已完成派单数
-        map.put("finishCrmNum", v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).values().stream()
-                .filter(list1 -> list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("sopStatus")))
-                        || list1.stream().allMatch(map1 -> "FINISH".equals(map1.get("status")))).count());
-        //违规数
-        map.put("violationNum", v.stream().filter(map1 -> map1.get("vid") != null)
-                .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
-        //已关闭违规数
-        map.put("finishViolationNum",
-                v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus")))
-                        .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
-        //延期数
-        map.put("delayNum", v.stream().filter(map1 -> map1.get("did") != null)
-                .collect(Collectors.groupingBy(map1 -> map1.get("did"))).size());
-        //已关闭延期数
-        map.put("finishDelayNum",
-                v.stream().filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus")))
-                        .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size());
-        Double processViolationTime = v.stream().filter(map1 -> map1.get("vdiff") != null)
-                .mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
-        Double processDelayTime = v.stream().filter(map1 -> map1.get("ddiff") != null)
-                .mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
-        //平均处理时限分钟
-        int total = (Integer.parseInt(map.get("finishViolationNum").toString()) + Integer.parseInt(
-                map.get("finishDelayNum").toString()));
-        map.put("avgMinutes", total == 0 ?
-                0 :
-                new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2,
-                        RoundingMode.HALF_UP));
-
-    }
-
-    /*
-     * 4.项目/供应商/大区预警待处理TOP10:
-     * ①待处理(待处理预警):按派单统计待处理的预警数(违规+延期);
-     * ②处理最慢(已处理完毕的预警):
-     * A.平均时限:按照预警产生到关闭的时长的均值,≥1小时,按小时显示;<小时,按分钟显示;
-     * 若预警为关闭后重启,则需要重新从预警产生到最后一次关闭的时长进行计算;
-     * B.排序:按平均时限的倒序排列;
-     * ③处理最快(已处理完毕的预警):
-     * A.平均时限:同上;
-     * B.排序:按平均时限的顺序排列。
-     * ④(预警数)均值:由于供应商分配的项目数量不同,所以单从总数无法判定供应商对预警处理的力度。均值=预警总数/派单数;
-     * ⑤【数据下钻】不提供。
-     */
-    @Override
-    public List<Map<String, Object>> processing(Long serviceId, SopAnalyseGroupEnum group, SopAnalyseSortEnum sort) {
-        List<Map<String, Object>> result = new ArrayList<>();
-        List<Map<String, Object>> list = this.baseMapper.overview(serviceId, group.name());
-        if (group.equals(SopAnalyseGroupEnum.CRM)) {
-            list.stream().filter(map -> map.get("name") != null).collect(Collectors.groupingBy(map -> map.get("name")))
-                    .forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("crmName", k);
-                        //大区
-                        map.put("region_name", v.get(0).get("region_name"));
-                        processing(v, map);
-                        result.add(map);
-                    });
-        } else if (group.equals(SopAnalyseGroupEnum.REGION)) {
-            list.stream().filter(map -> map.get("region_name") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("region_name", k);
-                        processing(v, map);
-                        result.add(map);
-                    });
-        } else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
-            list.stream().filter(map -> map.get("supplier") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("supplier", k);
-                        //大区
-                        map.put("region_name", v.get(0).get("region_name"));
-                        processing(v, map);
-                        result.add(map);
-                    });
-        }
-
-        if (sort.equals(SopAnalyseSortEnum.PENDING)) {
-            return result.stream()
-                    .sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("pendingProcessing").toString())))
-                    .limit(10).collect(Collectors.toList());
-        } else if (sort.equals(SopAnalyseSortEnum.SLOWEST)) {
-            return result.stream()
-                    .sorted(Comparator.comparingDouble(o -> -Double.parseDouble(o.get("avgMinutes").toString())))
-                    .limit(10).collect(Collectors.toList());
-        } else if (sort.equals(SopAnalyseSortEnum.FASTEST)) {
-            return result.stream()
-                    .sorted(Comparator.comparingDouble(o -> Double.parseDouble(o.get("avgMinutes").toString())))
-                    .limit(10).collect(Collectors.toList());
-        }
-        return null;
-
-    }
-
-    private static void processing(List<Map<String, Object>> v, Map<String, Object> map) {
-        //区域协调人
-        map.put("real_name", v.get(0).get("real_name"));
-        //违规数
-        Integer violationNum = v.stream().filter(map1 -> map1.get("did") != null)
-                .collect(Collectors.groupingBy(map1 -> map1.get("did"))).size();
-        //已关闭违规数
-        Long finishViolationNum = v.stream()
-                .filter(map1 -> map1.get("did") != null && "CLOSE".equals(map1.get("dstatus"))).count();
-        //延期数
-        Integer delayNum = v.stream().filter(map1 -> map1.get("vid") != null)
-                .collect(Collectors.groupingBy(map1 -> map1.get("vid"))).size();
-        //已关闭延期数
-        Long finishDelayNum = v.stream().filter(map1 -> map1.get("vid") != null && "CLOSE".equals(map1.get("vstatus")))
-                .count();
-        Double processViolationTime = v.stream().filter(map1 -> map1.get("ddiff") != null)
-                .mapToDouble(map1 -> Double.parseDouble(map1.get("ddiff").toString())).sum();
-        Double processDelayTime = v.stream().filter(map1 -> map1.get("vdiff") != null)
-                .mapToDouble(map1 -> Double.parseDouble(map1.get("vdiff").toString())).sum();
-        //平均处理时限分钟
-        long total = finishViolationNum + finishDelayNum;
-        map.put("avgMinutes", total == 0 ?
-                0 :
-                new BigDecimal(processViolationTime + processDelayTime).divide(new BigDecimal(total), 2,
-                        RoundingMode.HALF_UP));
-        //待处理总数数
-        map.put("pendingProcessing", violationNum + delayNum - total);
-        //预警均值
-        map.put("avgWarn", new BigDecimal(violationNum + delayNum).divide(
-                new BigDecimal(v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
-                RoundingMode.HALF_UP));
-    }
-
-    /*
-     * 5.供应商预警均值走势:
-     * 供应商近一周预警数的均值走势。
-     */
-    @Override
-    public Map<Object, List<Map<String, Object>>> trend1(Long serviceId) {
-        List<Map<String, Object>> list = this.baseMapper.trend(serviceId);
-        //        Map<Object, List<Map<String, Object>>> collect1 = list.stream().collect(Collectors.groupingBy(map -> map.get("click_date")));
-        //        Map<Object, Map<Object, List<Map<String, Object>>>> collect = new HashMap<>();
-        //        collect1.forEach((k, v) -> collect.put(k,v.stream().filter(map -> map.get("supplier") != null).collect(Collectors.groupingBy(map1 -> map1.get("supplier")))));
-        return list.stream().filter(map -> map.get("supplier") != null)
-                .collect(Collectors.groupingBy(map1 -> map1.get("supplier")));
-
-    }
-
-    /*
-     * 5.供应商预警均值走势:
-     * 供应商近一周预警数的均值走势。
-     * ④(预警数)均值:由于供应商分配的项目数量不同,所以单从总数无法判定供应商对预警处理的力度。均值=预警总数/派单数;
-     */
-    @Override
-    public List<SopSupplierAvgViewTimes> trend(Long serviceId) {
-        List<CrmSupplierRelation> crmSupplierRelationList = this.baseMapper.findCrmSupplierRelationByServiceId(
-                serviceId);
-        Map<Long, Set<String>> supplierCrmNumMap = new HashMap<>();
-        for (CrmSupplierRelation crmSupplierRelation : crmSupplierRelationList) {
-            String crmNo = crmSupplierRelation.getCrmNo();
-            Long supplierId = crmSupplierRelation.getSupplierId();
-            if (supplierCrmNumMap.containsKey(supplierId)) {
-                supplierCrmNumMap.get(supplierId).add(crmNo);
-            } else {
-                Set<String> crmNoSet = new HashSet<>();
-                crmNoSet.add(crmNo);
-                supplierCrmNumMap.put(supplierId, crmNoSet);
-            }
-        }
-
-        List<SopMonitor> sopMonitorList = this.baseMapper.findSopMonitorListByServiceId(serviceId);
-        Date date = new Date();
-        List<Long> times = new ArrayList<>();
-        for (int i = 8; i > 1; i--) {
-            int v = i - 1;
-            Calendar calendar = Calendar.getInstance();
-            calendar.setTime(date);
-            calendar.add(Calendar.DAY_OF_MONTH, -v);
-            calendar.set(Calendar.HOUR_OF_DAY, 24);
-            calendar.set(Calendar.MINUTE, 0);
-            calendar.set(Calendar.SECOND, 0);
-            calendar.set(Calendar.MILLISECOND, 0);
-            Long endTime = calendar.getTimeInMillis() - 1;
-            times.add(endTime);
-        }
-
-        // 7天涉及到的所有供应商信息 id - name 补充零用
-        Map<Long, String> supplierInfoMap = new HashMap<>();
-        List<SopSupplierAvgViewTimes> result = new ArrayList<>();
-        for (Long time : times) {
-            // 当天之前的预警(大区经理兼任的不算)
-            List<SopMonitor> monitorTimeCell = sopMonitorList.stream()
-                    .filter(e -> !e.getFinishStatus() && e.getStartTime() < time && e.getSupplierId() != null
-                            && e.getSupplierId() > 0).collect(Collectors.toList());
-
-            List<Long> supplierIdList = monitorTimeCell.stream().map(SopMonitor::getSupplierId).distinct()
-                    .collect(Collectors.toList());
-            List<SopSupplierAvgView> sopSupplierAvgViewList = new ArrayList<>();
-            for (Long supplierId : supplierIdList) {
-                List<SopMonitor> monitorSupplierCell = monitorTimeCell.stream()
-                        .filter(e -> e.getSupplierId().equals(supplierId)).collect(Collectors.toList());
-
-                if (CollectionUtils.isNotEmpty(monitorSupplierCell)) {
-                    String supplierName = monitorSupplierCell.get(0).getSupplierName();
-                    int warnCount = monitorSupplierCell.size();
-                    if (supplierCrmNumMap.containsKey(supplierId)) {
-                        int crmCount = supplierCrmNumMap.get(supplierId).size();
-                        BigDecimal rate = new BigDecimal(warnCount).divide(new BigDecimal(crmCount), 2,
-                                RoundingMode.HALF_UP);
-
-                        SopSupplierAvgView sopSupplierAvgView = new SopSupplierAvgView();
-                        sopSupplierAvgView.setSupplierId(supplierId);
-                        sopSupplierAvgView.setRate(rate);
-                        sopSupplierAvgView.setSupplierName(supplierName);
-                        sopSupplierAvgViewList.add(sopSupplierAvgView);
-                        if (!supplierInfoMap.containsKey(supplierId)) {
-                            supplierInfoMap.put(supplierId, supplierName);
-                        }
-                    }
-
-                }
-            }
-
-            SopSupplierAvgViewTimes sopSupplierAvgViewTimes = new SopSupplierAvgViewTimes();
-            sopSupplierAvgViewTimes.setTime(time);
-            sopSupplierAvgViewTimes.setTimeStr(DateFormatUtils.format(time, SystemConstant.DEFAULT_DATE_DAY_PATTERN));
-            if (CollectionUtils.isNotEmpty(sopSupplierAvgViewList)) {
-                sopSupplierAvgViewTimes.setSopSupplierAvgViewInfo(sopSupplierAvgViewList);
-            }
-            result.add(sopSupplierAvgViewTimes);
-
-            // 补零
-            for (SopSupplierAvgViewTimes supplierAvgViewTimes : result) {
-                List<SopSupplierAvgView> list = supplierAvgViewTimes.getSopSupplierAvgViewInfo();
-                if (CollectionUtils.isEmpty(list)) {
-                    list = new ArrayList<>();
-                }
-                List<Long> alreadyUsedSupplierIdList = list.stream().map(SopSupplierAvgView::getSupplierId)
-                        .collect(Collectors.toList());
-                List<Long> needFillIdList = supplierInfoMap.keySet().stream()
-                        .filter(k -> !alreadyUsedSupplierIdList.contains(k)).collect(Collectors.toList());
-                for (Long supplierId : needFillIdList) {
-                    SopSupplierAvgView view = new SopSupplierAvgView();
-                    view.setRate(new BigDecimal(0));
-                    view.setSupplierId(supplierId);
-                    view.setSupplierName(supplierInfoMap.get(supplierId));
-                    list.add(view);
-                }
-            }
-        }
-        return result;
-    }
-
-    /*
-      6.项目/大区/供应商考勤异常TOP:
-      ①(异常)均值=异常总数/派单数;
-      ②【数据下钻】不提供;
-     */
-    @Override
-    public List<Map<String, Object>> attendance(Long serviceId, SopAnalyseGroupEnum group) {
-        List<Map<String, Object>> result = new ArrayList<>();
-        List<Map<String, Object>> attendance = this.baseMapper.attendance(serviceId, group.name());
-        if (group.equals(SopAnalyseGroupEnum.CRM)) {
-            attendance.stream().filter(map -> map.get("name") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("name"))).forEach(
-                            (k, v) -> v.stream().filter(map -> map.get("dname") != null)
-                                    .collect(Collectors.groupingBy(map -> map.get("dname"))).forEach((x, y) -> {
-                                        Map<String, Object> map = new HashMap<>();
-                                        map.put("crmName", k);
-                                        map.put("dname", x);
-                                        map.put("real_name", v.get(0).get("real_name"));
-                                        map.put("total", y.stream().filter(map1 -> map1.get("id") != null).count());
-                                        result.add(map);
-                                    }));
-
-        } else if (group.equals(SopAnalyseGroupEnum.REGION)) {
-            attendance.stream().filter(map -> map.get("region_name") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("region_name", k);
-                        map.put("real_name", v.get(0).get("real_name"));
-                        long total = v.stream().filter(map1 -> map1.get("id") != null).count();
-                        map.put("total", total);
-                        map.put("avg", total == 0 ?
-                                0 :
-                                new BigDecimal(total).divide(new BigDecimal(
-                                                v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
-                                        RoundingMode.HALF_UP));
-                        result.add(map);
-                    });
-
-        } else if (group.equals(SopAnalyseGroupEnum.SUPPLIER)) {
-            attendance.stream().filter(map -> map.get("supplier") != null)
-                    .collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
-                        Map<String, Object> map = new HashMap<>();
-                        map.put("supplier", k);
-                        long total = v.stream().filter(map1 -> map1.get("id") != null).count();
-                        map.put("total", total);
-                        map.put("avg", total == 0 ?
-                                0 :
-                                new BigDecimal(total).divide(new BigDecimal(
-                                                v.stream().collect(Collectors.groupingBy(map1 -> map1.get("crm_no"))).size()), 2,
-                                        RoundingMode.HALF_UP));
-                        result.add(map);
-                    });
-
-        }
-        return result.stream().sorted(Comparator.comparingInt(o -> -Integer.parseInt(o.get("total").toString())))
-                .limit(10).collect(Collectors.toList());
-    }
-
-}

+ 44 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -421,4 +421,47 @@ SET name='大区考勤异常数统计接口', url='/api/admin/resource/security/
 WHERE id=1109;
 UPDATE sys_privilege
 SET name='人力供应商考勤异常数统计', url='/api/admin/resource/security/human_ding_exception/report', `type`='URL', parent_id=1105, `sequence`=1, property='AUTH', related=NULL, enable=1, default_auth=1, front_display=1
-WHERE id=1110;
+WHERE id=1110;
+
+DELETE FROM sys_privilege
+WHERE id=1073;
+DELETE FROM sys_privilege
+WHERE id=1074;
+DELETE FROM sys_privilege
+WHERE id=1075;
+DELETE FROM sys_privilege
+WHERE id=1076;
+DELETE FROM sys_privilege
+WHERE id=1077;
+DELETE FROM sys_privilege
+WHERE id=1078;
+DELETE FROM sys_privilege
+WHERE id=1079;
+DELETE FROM sys_privilege
+WHERE id=1080;
+DELETE FROM sys_privilege
+WHERE id=1081;
+DELETE FROM sys_privilege
+WHERE id=1082;
+DELETE FROM sys_privilege
+WHERE id=1083;
+DELETE FROM sys_privilege
+WHERE id=1084;
+DELETE FROM sys_privilege
+WHERE id=1085;
+DELETE FROM sys_privilege
+WHERE id=1086;
+DELETE FROM sys_privilege
+WHERE id=1087;
+DELETE FROM sys_privilege
+WHERE id=1088;
+DELETE FROM sys_privilege
+WHERE id=1089;
+DELETE FROM sys_privilege
+WHERE id=1090;
+DELETE FROM sys_privilege
+WHERE id=1091;
+DELETE FROM sys_privilege
+WHERE id=1092;
+DELETE FROM sys_privilege
+WHERE id=1093;

+ 0 - 343
sop-business/src/main/resources/mapper/CrmAnalyseMapper.xml

@@ -1,343 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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,-->
-        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_detail rd on rd.id=c.region_detail_id
-        <where>
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.status!='FINISH' AND c.region_detail_id IS NOT NULL
-            <if test="type != null and type != ''">
-                and cu.type = #{type}
-            </if>
-            <!--            <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}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        GROUP BY
-        <!--        r.id,-->
-        rd.province
-        order by count(DISTINCT c.id ) desc
-    </select>
-    <select id="project" resultType="java.util.Map">
-
-        SELECT
-        s.id,
-        s.`name`,
-        c.crm_no,
-        si.sop_no,
-        tffa.`status`
-        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
-        LEFT JOIN t_b_sop_info si ON si.crm_no = c.crm_no
-        LEFT JOIN t_f_custom_flow_entity tfcfe ON tfcfe.CODE = si.sop_no
-        LEFT JOIN t_f_flow_approve tffa ON tffa.flow_id = tfcfe.flow_id
-
-        <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>-->
-            <if test="startTime != null">
-                AND s.start_time <![CDATA[ >= ]]> #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND s.start_time <![CDATA[ <= ]]> #{endTime}
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-    </select>
-
-    <select id="supplier" resultType="com.qmth.sop.business.bean.result.CrmAnalyseResult">
-        SELECT
-        su.id,
-        su.`name`,
-        count(DISTINCT c.id ) count
-        FROM
-        t_b_crm c
-        LEFT JOIN t_b_service s ON c.service_id = s.id
-        left join t_b_service_region r on r.id=c.region_id
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_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
-        <where>
-            <!--            <if test="year != null and year != ''">-->
-            <!--                and YEAR ( FROM_UNIXTIME( s.start_time / 1000 ))=  #{year}-->
-            <!--            </if>-->
-            and su.id is not null
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.service_id is not null and c.enable=1
-            <if test="startTime != null">
-                AND s.start_time >= #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        GROUP BY
-        su.id,
-        su.`name`
-
-    </select>
-
-    <select id="monthly" resultType="java.util.Map">
-        SELECT
-        a.year,
-        a.month ,
-        count(DISTINCT a.id) count
-        FROM
-        (
-        SELECT DISTINCT
-        CAST( YEAR ( FROM_UNIXTIME( c.begin_time / 1000 )) AS CHAR ) YEAR,
-        MONTH (
-        FROM_UNIXTIME( c.begin_time / 1000 )) MONTH,
-        c.id
-        FROM
-        t_b_crm c
-        LEFT JOIN t_b_service s ON c.service_id = s.id
-        LEFT JOIN sys_custom cu ON cu.id = c.custom_id
-        <where>
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.service_id is not null and c.enable=1
-            <if test="type != null and type != ''">
-                and cu.type = #{type}
-            </if>
-
-            <if test="startTime != null">
-                AND s.start_time >= #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        ) a
-        GROUP BY
-        a.YEAR,
-        a.MONTH
-        ORDER BY
-        a.YEAR,
-        a.MONTH
-
-    </select>
-
-
-    <select id="countCustomType" resultType="java.util.Map">
-        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_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>
-
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.service_id is not null and c.enable=1
-            <if test="startTime != null">
-                AND s.start_time <![CDATA[ >= ]]> #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND s.start_time <![CDATA[ <= ]]> #{endTime}
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-    </select>
-
-    <select id="crmDetail" resultType="com.qmth.sop.business.bean.result.TBCrmResult">
-        SELECT
-        distinct a.id as crmId,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,
-        sc.type custom_type,
-        p.name product,
-        lu.real_name leadName,
-        cu.real_name createName,
-        tbs.status serviceUnitStatus,
-        u.real_name regionCoordinator,
-        su.name supplier
-        from t_b_crm a
-        LEFT JOIN t_b_service tbs ON a.service_id = tbs.id
-        left join t_b_service_region r on r.id=a.region_id
-        left join t_b_service_region_detail rd on rd.id=a.region_detail_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
-        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
-        <where>
-            and tbs.`status` IN ( 'PUBLISH', 'FINISH' ) and a.service_id is not null and a.enable=1
-            <if test="serviceId != null and serviceId != ''">
-                and a.crm_no is not null
-                and a.service_id = #{serviceId}
-            </if>
-            <!--            <if test="regionId != null and regionId != ''">-->
-            <!--                and r.id = #{regionId}-->
-            <!--            </if>-->
-            <if test="province != null and province != ''">
-<!--                and r.id is not null-->
-                and a.status!='FINISH'
-                and rd.province = #{province}
-            </if>
-            <if test="type != null and type != ''">
-                and sc.type = #{type}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and su.id = #{supplierId}
-            </if>
-            <if test="startTime != null">
-                AND tbs.start_time <![CDATA[ >= ]]> #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND tbs.start_time <![CDATA[ <= ]]> #{endTime}
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND tbs.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-            <if test="crmYear != null and 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}
-            </if>
-        </where>
-        ORDER BY a.crm_no DESC
-    </select>
-
-    <select id="projectCount" resultType="java.util.Map">
-        SELECT
-        sum(case when c.id is not null then 1 else 0 end ) crm
-<!--        count(DISTINCT a.id ) person-->
-        FROM
-        t_b_service s
-        LEFT JOIN t_b_crm c ON c.service_id = s.id
-<!--        LEFT JOIN t_b_user_archives_allocation a ON a.service_id = s.id-->
-        <where>
-            and s.`status` IN ( 'PUBLISH', 'FINISH' ) and c.service_id is not null and c.enable=1
-            <if test="startTime != null">
-                AND s.start_time >= #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-    </select>
-    <select id="findAllocation"
-            resultType="java.lang.Integer">
-        SELECT
-        sum(result.distributed)
-        FROM
-        (SELECT
-
-
-        IF(tbc.region_coordinator_id IS NULL, 0, 1) + IFNULL(effectR.reality, 0) + IFNULL(assistantR.reality, 0) AS distributed
-
-        FROM
-        t_b_crm tbc
-
-        LEFT JOIN t_b_service tbs ON tbc.service_id = tbs.id
-
-        LEFT JOIN sys_custom su ON tbc.custom_id = su.id
-        LEFT JOIN sys_level sl ON su.level_id = sl.id
-
-        LEFT JOIN (SELECT
-        slr.quota, slr.level_id
-        FROM
-        sys_level_role slr
-        LEFT JOIN sys_role sr ON sr.id = slr.role_id
-        WHERE
-        sr.type = 'EFFECT_ENGINEER') effectQ ON effectQ.level_id = sl.id
-        LEFT JOIN (SELECT
-        slr.quota, slr.level_id
-        FROM
-        sys_level_role slr
-        LEFT JOIN sys_role sr ON sr.id = slr.role_id
-        WHERE
-        sr.type = 'ASSISTANT_ENGINEER') assistantQ ON assistantQ.level_id = sl.id
-        LEFT JOIN (SELECT
-        tbuaa.crm_no, COUNT(*) AS reality
-        FROM
-        t_b_user_archives_allocation tbuaa
-        LEFT JOIN sys_role sr ON sr.id = tbuaa.role_id
-        WHERE
-        sr.type = 'EFFECT_ENGINEER'
-        GROUP BY tbuaa.crm_no) effectR ON effectR.crm_no = tbc.crm_no
-        LEFT JOIN (SELECT
-        tbuaa.crm_no, COUNT(*) AS reality
-        FROM
-        t_b_user_archives_allocation tbuaa
-        LEFT JOIN sys_role sr ON sr.id = tbuaa.role_id
-        WHERE
-        sr.type = 'ASSISTANT_ENGINEER'
-        GROUP BY tbuaa.crm_no) assistantR ON assistantR.crm_no = tbc.crm_no
-        <where>
-            and tbs.`status` IN ( 'PUBLISH', 'FINISH' ) and tbc.service_id is not null and tbc.enable=1
-            <if test="startTime != null">
-                AND tbs.start_time >= #{startTime}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= tbs.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND tbs.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-
-        ) result
-
-    </select>
-</mapper>

+ 0 - 107
sop-business/src/main/resources/mapper/DeviceMonitorMapper.xml

@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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.DeviceMonitorMapper">
-    <select id="count" resultType="java.util.Map">
-        SELECT count(d.id) TOTAL,
-        sum(case when d.bound='OUT' then 1 else 0 end) ISOUT,
-        sum(case when d.bound='IN' and d.`status`!='BREAK_DOWN' then 1 else 0 end) ISIN,
-        sum(case when d.`status`='BREAK_DOWN' then 1 else 0 end) BREAK_DOWN
-        from sys_device d
-        <where>
-            <if test="supplierId != null and supplierId != ''">
-                and d.supplier_id = #{supplierId}
-            </if>
-            <if test="model != null and model != ''">
-                and d.model = #{model}
-            </if>
-        </where>
-    </select>
-
-
-    <select id="countByModel" resultType="java.util.Map">
-        SELECT
-        d.model MODEL,
-        count( d.id ) TOTAL,
-        sum( CASE WHEN d.bound = 'OUT' THEN 1 ELSE 0 END ) ISOUT,
-        sum( CASE WHEN d.bound='IN' and d.`status`!='BREAK_DOWN' THEN 1 ELSE 0 END ) ISIN,
-        sum( CASE WHEN d.`status` = 'BREAK_DOWN' THEN 1 ELSE 0 END ) BREAK_DOWN
-        FROM
-        sys_device d
-        <where>
-            <if test="supplierId != null and supplierId != ''">
-                and d.supplier_id = #{supplierId}
-            </if>
-        </where>
-        group by d.model
-    </select>
-    <select id="countByServiceUnit" resultType="java.util.Map">
-        SELECT
-        sum(  l.devices ) DEVICES
-<!--        sum( CASE WHEN d.bound = 'OUT' THEN 1 ELSE 0 END ) OUTS-->
-        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
-        LEFT JOIN sys_level l ON l.id = cu.level_id
-
-<!--        left join t_b_device_in_out io on io.service_id=s.id-->
-<!--        left join sys_device d on d.device_code=io.device_no-->
-        <where>
-            and s.status !='FINISH'
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-
-        </where>
-    </select>
-    <select id="countByServiceUnitDetail" resultType="java.util.Map">
-
-
-        SELECT a.*,b.OUTS from (
-
-        SELECT s.id ,
-        s.`name` NAME,
-        ifNull(sum(l.devices),0) devices
-
-        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
-        LEFT JOIN sys_level l ON l.id = cu.level_id
-        <where>
-            and s.status !='FINISH'
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-
-        </where>
-        GROUP BY s.id ,s.`name`
-        ) a
-        left join
-
-        (SELECT s.id ,
-
-        sum(case when io.type='OUT' then 1 else 0 end )-sum(case when io.type='IN' then 1 else 0 end ) OUTS
-
-        FROM
-        t_b_service s
-
-        left join t_b_device_in_out io on io.service_id=s.id
-        left join sys_device d on d.serial_no=io.device_serial_no
-        <where>
-            and s.status !='FINISH'
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-
-        </where>
-        GROUP BY s.id )
-        b on a.id =b.id
-    </select>
-</mapper>

+ 0 - 202
sop-business/src/main/resources/mapper/QualityAnalyseMapper.xml

@@ -1,202 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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.QualityAnalyseMapper">
-    <select id="list" resultType="com.qmth.sop.business.entity.TBService">
-        select * from t_b_service s
-        <where>
-            and s.status in ('PUBLISH','FINISH')
-
-            <!--            <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}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        order by s.start_time desc
-    </select>
-    <select id="pie" resultType="java.util.Map">
-        SELECT
-        a.Influence_degree,
-        count( a.id ) count
-        FROM
-        t_b_quality_problem_apply a
-        LEFT JOIN t_b_sop_info si ON si.sop_no = a.sop_no
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = si.id
-        left join t_b_crm c on c.crm_no=si.crm_no
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.mobile_number
-        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
-        LEFT JOIN t_f_custom_flow_entity fe ON fe.`code` = a.problem_no
-        LEFT JOIN t_f_flow_approve fa ON fa.flow_id = fe.flow_id
-        <where>
-            and a.type != 'NO_PROBLEM' AND fa.STATUS = 'FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
-            </if>
-        </where>
-        GROUP BY
-        a.Influence_degree
-    </select>
-    <select id="radar" resultType="java.util.Map">
-        SELECT
-        r.region_name,
-        s.NAME supplier,
-        a.reason,
-        count( a.id ) count
-        FROM
-        t_b_quality_problem_apply a
-        LEFT JOIN t_b_sop_info si ON si.sop_no = a.sop_no
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = si.id
-        left join t_b_crm c on c.crm_no=si.crm_no
-        left join t_b_service_region r on r.id=c.region_id
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.mobile_number
-        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
-        LEFT JOIN sys_supplier s ON s.id = us.supplier_id
-        LEFT JOIN t_f_custom_flow_entity fe ON fe.`code` = a.problem_no
-        LEFT JOIN t_f_flow_approve fa ON fa.flow_id = fe.flow_id
-        <where>
-            and a.type != 'NO_PROBLEM' and fa.STATUS = 'FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
-            </if>
-        </where>
-        GROUP BY
-        r.region_name,
-        s.NAME,
-        a.reason
-    </select>
-    <sql id="query">
-        SELECT
-        distinct a.*,
-        si.type sopType,
-        sc.NAME custom,
-        sc.type customType,
-        fa.STATUS,
-        fa.setup,
-        fa.create_time submissionTime,
-        fa.update_time updateDateTime,
-        cu.real_name submitter ,
-        fe.flow_id as flowId,
-        IFNULL(art.NAME_,'--') as taskName,
-        art.TASK_DEF_KEY_ as taskDefKey,
-        (select group_concat(us1.real_name SEPARATOR ';') from sys_user us1
-        where find_in_set(us1.id, a.user_ids)) user_names,
-        (select group_concat(us1.real_name SEPARATOR ';') from sys_user us1
-        where find_in_set(us1.id, (select tffl.pend_approve_id from t_f_flow_log tffl where tffl.flow_id = fe.flow_id order by tffl.create_time desc limit 1))) pend_approve_users
-        FROM
-        t_b_quality_problem_apply a
-        LEFT JOIN t_b_sop_info si on si.sop_no = a.sop_no
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = si.id
-        left join t_b_crm c on c.crm_no=si.crm_no
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.mobile_number
-        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = ua.id
-        LEFT JOIN t_f_custom_flow_entity fe ON 	fe.`code`= a.problem_no
-        LEFT JOIN t_f_flow_approve fa ON fa.flow_id = fe.flow_id
-        LEFT JOIN sys_user cu ON cu.id = fa.create_id
-        left join ACT_RU_TASK art on art.PROC_INST_ID_ = fa.flow_id
-        left join act_ru_identitylink ari on ari.TASK_ID_ = art.ID_
-        left join t_b_crm tbc on tbc.crm_no = fe.crm_no
-        LEFT JOIN sys_custom sc ON sc.id = tbc.custom_id
-        left join t_b_service tbs on tbs.id = tbc.service_id
-
-    </sql>
-    <select id="detail" resultType="com.qmth.sop.business.bean.result.TBQualityProblemApplyResult">
-        <include refid="query" />
-        <where>
-                and a.type != 'NO_PROBLEM' AND fa.STATUS = 'FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-            <if test="degree != null and degree != ''">
-                and a.Influence_degree = #{degree}
-            </if>
-        </where>
-        ORDER BY a.create_time DESC
-    </select>
-
-    <select id="influenceDetail" resultType="com.qmth.sop.business.bean.result.TBQualityProblemApplyResult">
-        <include refid="query" />
-        <where>
-            AND fa.STATUS = 'FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
-            </if>
-            <if test="region_id != null and region_id != ''">
-                and c.region_id = #{region_id}
-            </if>
-            <if test="influenceDegree != null and influenceDegree != ''">
-                and a.Influence_degree = #{influenceDegree}
-            </if>
-            <if test="reason != null and reason != ''">
-                and a.reason = #{reason}
-            </if>
-        </where>
-        ORDER BY a.create_time DESC
-    </select>
-
-
-    <select id="progress" resultType="java.lang.Double">
-        SELECT
-        sum(case when fa.`status`='FINISH' then 1 else 0 end )*100/count( a.id ) count
-        FROM
-        t_b_quality_problem_apply a
-        LEFT JOIN t_f_custom_flow_entity fe ON fe.`code` = a.problem_no
-        LEFT JOIN t_f_flow_approve fa ON fa.flow_id = fe.flow_id
-        <where>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-
-        </where>
-
-    </select>
-    <select id="influence" resultType="java.util.Map">
-        SELECT
-        a.id,
-        a.Influence_degree,
-        su.`name` supplier,
-        su.id supplier_id,
-        r.id region_id,
-        r.region_name,
-        a.reason
-        FROM
-        t_b_quality_problem_apply a
-        LEFT JOIN t_b_sop_info si ON si.sop_no = a.sop_no
-        LEFT JOIN t_f_custom_flow_entity fe ON fe.`code` = a.problem_no
-        LEFT JOIN t_f_flow_approve fa ON fa.flow_id = fe.flow_id
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = si.id
-        left join t_b_crm c on c.crm_no=si.crm_no
-        left join t_b_service_region r on r.id=c.region_id
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.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
-        <where>
-            AND fa.STATUS = 'FINISH'
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-        </where>
-
-    </select>
-</mapper>

+ 0 - 369
sop-business/src/main/resources/mapper/ServiceAnalyseMapper.xml

@@ -1,369 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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.ServiceAnalyseMapper">
-    <select id="list" resultType="com.qmth.sop.business.entity.TBService">
-        select * from t_b_service s
-        <where>
-            and s.status in ('PUBLISH','FINISH')
-
-            <!--            <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}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        order by s.start_time desc
-    </select>
-
-    <select id="equipmentOutboundTotal" resultType="java.util.Map">
-        SELECT
-            IFNULL(sum(case when io.status = 'NORMAL' then 1 else 0 end),0) deviceSum,
-            IFNULL(sum(case when io.type = 'OUT' and io.service_id = #{serviceUnitId} then 1 else 0 end),0) outs
-        from t_b_device_in_out io
-    </select>
-
-    <select id="projectProgress" resultType="java.util.Map">
-        select tfcfe.code as code,tfcfe.crm_no as crmNo,tfcfe.flow_id as flowId,tffa.status as status from t_b_service tbs
-        left join t_b_crm tbc ON tbc.service_id = tbs.id
-        left join t_f_custom_flow_entity tfcfe on tfcfe.crm_no = tbc.crm_no
-        left join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
-        <where>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and tbs.id = #{serviceUnitId}
-            </if>
-            and tfcfe.code like 'SOP%'
-        </where>
-    </select>
-
-    <select id="projectCount" resultType="java.lang.Integer">
-        SELECT
-        count(DISTINCT c.id )
-        FROM
-        t_b_service s
-        LEFT JOIN t_b_crm c ON c.service_id = s.id
-        <where>
-
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and s.id = #{serviceUnitId}
-            </if>
-
-        </where>
-    </select>
-    <select id="supplierDistribution" resultType="java.util.Map">
-        SELECT
-        CONCAT( su.id, '' ) id,
-        su.`name`,
-        count( DISTINCT c.id ) count
-        FROM t_b_service s
-        LEFT JOIN t_b_crm c ON s.id = c.service_id
-        LEFT JOIN t_b_user_archives_allocation tbuaa on tbuaa.crm_no = c.crm_no
-        LEFT JOIN t_b_user_archives_supplier tbuas on tbuas.user_archives_id = tbuaa.archives_id
-        LEFT JOIN sys_supplier su on su.id = tbuas.supplier_id
-        <where>
-                    and su.id IS NOT NULL
-                    <if test="serviceUnitId != null and serviceUnitId != ''">
-                        and s.id = #{serviceUnitId}
-                    </if>
-                </where>
-        GROUP BY
-        su.id,
-        su.`name`
-    </select>
-    <select id="crmDetail" resultType="com.qmth.sop.business.bean.result.TBCrmResult">
-        SELECT
-        distinct a.*,
-        tbs.name service,
-        cru.real_name crm_user_name,
-        sc.NAME custom,
-        sc.type custom_type,
-        p.name product,
-        lu.real_name leadName,
-        cu.real_name createName,
-        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
-        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 sys_custom sc ON sc.id = a.custom_id
-        LEFT JOIN sys_user u ON u.id = a.region_coordinator_id
-        left join t_b_user_archives_allocation tbuaa on tbuaa.crm_no = a.crm_no
-        LEFT JOIN t_b_user_archives ua ON ua.id = tbuaa.archives_id
-        LEFT JOIN t_b_user_archives_supplier tbuas on tbuas.user_archives_id = ua.id
-        LEFT JOIN sys_supplier su on su.id = tbuas.supplier_id
-        <where>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and a.service_id = #{serviceUnitId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and su.id = #{supplierId}
-            </if>
-        </where>
-        ORDER BY
-        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.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>
-                    <if test="serviceUnitId != null and serviceUnitId != ''">
-                        and ua.service_id = #{serviceUnitId}
-                    </if>
-                </where>
-        GROUP BY
-        r.NAME
-
-        UNION all
-
-
-
-        SELECT
-        '区域协调人' as NAME,
-        count( DISTINCT aa.region_user_id ) count
-
-        FROM
-        t_b_user_archives_allocation aa
-        LEFT JOIN sys_user u ON u.id = aa.region_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
-        <where>
-            and us.authentication_valid_time > UNIX_TIMESTAMP()* 1000
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
-            </if>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and aa.service_id = #{serviceUnitId}
-            </if>
-        </where>
-    </select>
-    <select id="supplierRegion" resultType="java.util.Map">
-        SELECT DISTINCT
-        cast(r.id as char) as region_id,
-        r.region_name
-        FROM
-        t_b_crm c
-        LEFT JOIN
-        t_b_service_region r ON r.id = c.region_id
-        LEFT JOIN
-        t_b_user_archives_allocation tbuaa on tbuaa.crm_no = c.crm_no
-        LEFT JOIN
-        t_b_user_archives ua ON ua.id = tbuaa.archives_id
-        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 r.id IS NOT NULL
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and c.service_id = #{serviceUnitId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
-            </if>
-        </where>
-    </select>
-
-    <select id="findCrmAllocation" resultType="com.qmth.sop.business.bean.result.UserArchivesAllocationResult">
-        SELECT
-        *,
-        (result.effectQuota + result.assistantQuota + result.coordinatorQuota) AS quota,
-        (result.coordinatorUnDistributed + result.effectUnDistributed + result.assistantUnDistributed) AS unDistributed
-        FROM
-        (SELECT
-        tbs.id AS serviceUnitId,
-        tbs.name AS serviceUnitName,
-        tbc.id AS crmId,
-        tbc.crm_no AS crmNo,
-        su.id AS customId,
-        su.name AS customName,
-        su.type AS customType,
-        su.province AS province,
-        su.city AS city,
-        su.area AS area,
-        sl.id AS levelId,
-        sl.level AS level,
-        1 AS coordinatorQuota,
-        IFNULL(effectQ.quota, 0) AS effectQuota,
-        IFNULL(assistantQ.quota, 0) AS assistantQuota,
-        IF(tbc.region_coordinator_id IS NULL, 0, 1) AS coordinatorDistributed,
-        IFNULL(effectR.reality, 0) AS effectDistributed,
-        IFNULL(assistantR.reality, 0) AS assistantDistributed,
-        IF(tbc.region_coordinator_id IS NULL, 0, 1) + IFNULL(effectR.reality, 0) + IFNULL(assistantR.reality, 0) AS distributed,
-        IF(tbc.region_coordinator_id IS NULL, 1, 0) AS coordinatorUnDistributed,
-        IF(IFNULL(effectQ.quota, 0) - IFNULL(effectR.reality, 0) &lt; 0, 0, IFNULL(effectQ.quota, 0) - IFNULL(effectR.reality, 0)) AS effectUnDistributed,
-        IF(IFNULL(assistantQ.quota, 0) - IFNULL(assistantR.reality, 0) &lt; 0, 0, IFNULL(assistantQ.quota, 0) - IFNULL(assistantR.reality, 0)) AS assistantUnDistributed,
-        tbc.status AS crmStatus,
-        tbs.service_lead_id AS serviceUnitLeaderId,
-        tbc.lead_id AS regionManagerId,
-        rm.real_name AS regionManagerName,
-        pu.real_name AS publishUserName,
-        tbc.publish_time AS publishTime,
-        r.id region_id,
-        us.supplier_id
-        FROM
-        t_b_crm tbc
-
-        LEFT JOIN t_b_service tbs ON tbc.service_id = tbs.id
-        LEFT JOIN t_b_service_region r ON tbs.id = r.service_id
-        LEFT JOIN sys_user u ON u.id = tbc.region_coordinator_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_custom su ON tbc.custom_id = su.id
-        LEFT JOIN sys_level sl ON su.level_id = sl.id
-        LEFT JOIN sys_user pu ON tbc.publish_user_id = pu.id
-        LEFT JOIN sys_user rm ON tbc.lead_id = rm.id
-        LEFT JOIN (SELECT
-        slr.quota, slr.level_id
-        FROM
-        sys_level_role slr
-        LEFT JOIN sys_role sr ON sr.id = slr.role_id
-        WHERE
-        sr.type = 'EFFECT_ENGINEER') effectQ ON effectQ.level_id = sl.id
-        LEFT JOIN (SELECT
-        slr.quota, slr.level_id
-        FROM
-        sys_level_role slr
-        LEFT JOIN sys_role sr ON sr.id = slr.role_id
-        WHERE
-        sr.type = 'ASSISTANT_ENGINEER') assistantQ ON assistantQ.level_id = sl.id
-        LEFT JOIN (SELECT
-        tbuaa.crm_no, COUNT(*) AS reality
-        FROM
-        t_b_user_archives_allocation tbuaa
-        LEFT JOIN sys_role sr ON sr.id = tbuaa.role_id
-        WHERE
-        sr.type = 'EFFECT_ENGINEER'
-        GROUP BY tbuaa.crm_no) effectR ON effectR.crm_no = tbc.crm_no
-        LEFT JOIN (SELECT
-        tbuaa.crm_no, COUNT(*) AS reality
-        FROM
-        t_b_user_archives_allocation tbuaa
-        LEFT JOIN sys_role sr ON sr.id = tbuaa.role_id
-        WHERE
-        sr.type = 'ASSISTANT_ENGINEER'
-        GROUP BY tbuaa.crm_no) assistantR ON assistantR.crm_no = tbc.crm_no ) result
-        <where>
-            <if test="serviceUnitId != null">
-                AND result.serviceUnitId = #{serviceUnitId}
-            </if>
-            <if test="regionId != null and regionId != ''">
-                AND result.region_id =#{regionId}
-            </if>
-            <if test="supplierId != null and supplierId != ''">
-                AND result.supplier_id = #{supplierId}
-            </if>
-        </where>
-        ORDER BY result.serviceUnitId DESC, result.crmId DESC
-    </select>
-
-    <select id="device" resultType="java.util.Map">
-        SELECT
-        su.`name`,
-        sum(case when io.type='OUT' then 1 else 0 end )-sum(case when io.type='IN' then 1 else 0 end ) outs
-<!--        sum( CASE WHEN d.`status` = 'NORMAL' THEN 1 ELSE 0 END ) count-->
-        FROM
-        t_b_service s
-        LEFT JOIN t_b_device_in_out io ON io.service_id = s.id
-        LEFT JOIN sys_device d ON d.serial_no = io.device_serial_no
-        LEFT JOIN sys_supplier su ON su.id = d.supplier_id
-        <where> 1 = 1
-            and io.id IS NOT NULL and su.id is not null
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and s.id = #{serviceUnitId}
-            </if>
-        </where>
-        GROUP BY
-        su.`name`
-    </select>
-    <select id="personnel" resultType="java.util.Map">
-        SELECT
-        su.`name`,
-        r.region_name,
-        count( DISTINCT aa.user_id ) count
-        FROM
-        t_b_user_archives_allocation aa
-        LEFT JOIN t_b_service_region r ON aa.service_id = r.service_id
-        LEFT JOIN t_b_user_archives_supplier us ON us.user_archives_id = aa.archives_id
-        LEFT JOIN sys_supplier su ON su.id = us.supplier_id
-        <where>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and aa.service_id = #{serviceUnitId}
-            </if>
-        </where>
-        GROUP BY
-        su.`name`,
-        r.region_name
-
-        UNION ALL
-
-        SELECT
-        su.`name`,
-        r.region_name,
-        count( DISTINCT aa.region_user_id ) count
-        FROM
-        t_b_user_archives_allocation aa
-        LEFT JOIN sys_user u ON u.id = aa.region_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 t_b_service_region r ON aa.service_id = r.service_id
-        LEFT JOIN sys_supplier su ON su.id = us.supplier_id
-        <where>
-            <if test="serviceUnitId != null and serviceUnitId != ''">
-                and aa.service_id = #{serviceUnitId}
-            </if>
-        </where>
-        GROUP BY
-        su.`name`,
-        r.region_name
-    </select>
-
-    <select id="findWaitZone" resultType="java.lang.Integer">
-        select IFNULL(count(1),0) as c from t_b_crm tbc
-        left join sys_custom sc on sc.id = tbc.custom_id
-        where exists(
-                SELECT tbsr.id FROM t_b_service_region tbsr
-                        left join t_b_service_region_detail tbsrd on tbsrd.service_region_id = tbsr.id
-                where tbsr.id = #{regionId} and sc.province = tbsrd.province and sc.city = tbsrd.city)
-          and tbc.service_id is null and tbc.enable = 1
-    </select>
-</mapper>

+ 0 - 253
sop-business/src/main/resources/mapper/SopAnalyseMapper.xml

@@ -1,253 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!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.SopAnalyseMapper">
-    <select id="list" resultType="com.qmth.sop.business.entity.TBService">
-        select * from t_b_service s
-        <where>
-            and s.status = 'PUBLISH'
-
-            <!--            <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}
-            </if>
-            <if test="endTime != null">
-                AND #{endTime} >= s.start_time
-            </if>
-            <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND s.service_lead_id = #{dpr.requestUserId}
-                </if>
-            </if>
-        </where>
-        order by s.start_time desc
-    </select>
-
-    <select id="overview" resultType="java.util.Map">
-        SELECT
-        r.region_name,
-        u.real_name,
-        su.NAME supplier,
-        c.crm_no,
-        c.name,
-        c.`status`,
-        s.sop_no,
-        tffa.status sopStatus,
-        d.id did,
-        d.`status` dstatus,
-        case when d.`status`='CLOSE' then ((d.close_time - d.warn_time)/60/1000) else null end ddiff,
-        v.id vid,
-        v.`status` vstatus,
-        case when v.`status`='CLOSE' then ((v.close_time - v.create_time)/60/1000) else null end vdiff
-        FROM
-        t_b_sop_info s
-        left join t_b_crm c on c.crm_no=s.crm_no
-        left join t_b_service_region r on r.id=c.region_id
-        LEFT join t_f_custom_flow_entity tfcfe on tfcfe.code = s.sop_no
-        LEFT join t_f_flow_approve tffa on tffa.flow_id = tfcfe.flow_id
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = s.id
-        <if test="type != null and type != ''">
-            <choose>
-                <when test="type == 'CRM' or type == 'SUPPLIER'">
-                    LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-                </when>
-                <otherwise>
-                    LEFT JOIN sys_user u ON u.id = c.lead_id
-                </otherwise>
-            </choose>
-        </if>
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.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
-        left join t_b_delay_warn d on d.sop_no=s.sop_no
-        left join t_b_violation v on v.sop_no=s.sop_no
-        <where>
-
-            <if test="serviceId != null and serviceId != ''">
-               and  s.service_id= #{serviceId}
-            </if>
-
-        </where>
-    </select>
-    <select id="trend" resultType="java.util.Map">
-        SELECT
-        a.click_date,
-        b.supplier,
-        ifnull( b.count, 0 ) AS count
-        FROM
-        (
-        SELECT
-        curdate() AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 1 DAY ) AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 2 DAY ) AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 3 DAY ) AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 4 DAY ) AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 5 DAY ) AS click_date UNION ALL
-        SELECT
-        date_sub( curdate(), INTERVAL 6 DAY ) AS click_date
-        ) a
-        LEFT JOIN (
-        SELECT
-        su.NAME supplier,
-        DATE_FORMAT(
-        FROM_UNIXTIME( ( CASE WHEN d.create_time IS NOT NULL THEN d.create_time WHEN v.create_time IS NOT NULL THEN v.create_time ELSE NULL END )/ 1000 ),
-        '%Y-%m-%d'
-        ) dattime,
-        count( DISTINCT d.id )+ count( DISTINCT v.id ) count
-        FROM
-        t_b_sop_info s
-        left join t_b_crm c on c.crm_no=s.crm_no
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = s.id
-        LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.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
-        LEFT JOIN t_b_delay_warn d ON d.sop_no = s.sop_no
-        LEFT JOIN t_b_violation v ON v.sop_no = s.sop_no
-        <where>
-            and (d.id IS NOT NULL OR v.id IS NOT NULL)
-            <if test="serviceId != null and serviceId != ''">
-                and  s.service_id= #{serviceId}
-            </if>
-
-        </where>
-        GROUP BY
-        su.NAME,
-        dattime
-        ) b ON a.click_date = b.dattime
-    </select>
-
-    <select id="attendance" resultType="java.util.Map">
-        SELECT
-        r.region_name,
-        u.real_name,
-        su.NAME supplier,
-        c.crm_no,
-        c.name,
-        c.`status`,
-        s.sop_no,
-        d.id,
-        du.real_name dname
-        FROM
-        t_b_sop_info s
-        left join t_b_crm c on c.crm_no=s.crm_no
-        left join t_b_service_region r on r.id=c.region_id
---         LEFT JOIN t_b_sop_info_detail sd ON sd.sop_info_id = s.id
-        <if test="type != null and type != ''">
-            <choose>
-                <when test="type == 'CRM' or type == 'SUPPLIER'">
-                    LEFT JOIN sys_user u ON u.id = c.region_coordinator_id
-                </when>
-                <otherwise>
-                    LEFT JOIN sys_user u ON u.id = c.lead_id
-                </otherwise>
-            </choose>
-        </if>
-        LEFT JOIN t_b_user_archives ua ON ua.mobile_number = u.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
-        left join t_b_ding_apply d on d.sop_no=s.sop_no
-        left join sys_user du on du.id=d.create_id
-        <where>
-            <if test="serviceId != null and serviceId != ''">
-                and  s.service_id= #{serviceId}
-            </if>
-        </where>
-    </select>
-
-    <select id="findSopMonitorListByServiceId"
-            resultType="com.qmth.sop.business.bean.result.analyze.sopWarn.SopMonitor">
-        SELECT
-            sopMonitor.sop_monitor_type AS sopMonitorType,
-            sopMonitor.crm_no AS crmNo,
-            sopMonitor.sop_no AS sopNo,
-            sopMonitor.service_id AS serviceId,
-            sopMonitor.user_id AS userId,
-            sopMonitor.finish_status AS finishStatus,
-            sopMonitor.start_time AS startTime,
-            sopMonitor.close_time AS closeTime,
-            tbc.region_id AS regionId,
-            tbsr.region_name AS regionName,
-            IFNULL(ss.id,0) AS supplierId,
-            IFNULL(ss.name,'大区经理兼任') AS supplierName
-        FROM
-            (SELECT
-                 'DELAY_WARN' AS sop_monitor_type,
-                 crm_no,
-                 sop_no,
-                 service_id,
-                 create_id AS user_id,
-                 IF(status = 'CLOSE', TRUE, FALSE) AS finish_status,
-                 warn_time AS start_time,
-                 close_time AS close_time
-             FROM
-                 t_b_delay_warn
-             UNION ALL SELECT
-                 'VIOLATION' AS sop_monitor_type,
-                 crm_no,
-                 sop_no,
-                 service_id,
-                 create_id AS user_id,
-                 IF(status = 'CLOSE', TRUE, FALSE) AS finish_status,
-                 create_time AS start_time,
-                 close_time AS close_time
-             FROM
-                 t_b_violation) sopMonitor
-                LEFT JOIN
-            t_b_crm tbc ON tbc.crm_no = sopMonitor.crm_no
-                LEFT JOIN
-            t_b_service_region tbsr ON tbc.region_id = tbsr.id
-                LEFT JOIN
-            sys_user su ON sopMonitor.user_id = su.id
-                LEFT JOIN
-            t_b_user_archives tbua ON tbua.mobile_number = su.mobile_number
-                LEFT JOIN
-            t_b_user_archives_supplier tbuas ON tbua.id = tbuas.user_archives_id
-                LEFT JOIN
-            sys_supplier ss ON tbuas.supplier_id = ss.id
-        <where>
-            <if test="serviceId != null">
-                AND sopMonitor.service_id = #{serviceId}
-            </if>
-        </where>
-    </select>
-    <select id="findCrmSupplierRelationByServiceId"
-            resultType="com.qmth.sop.business.bean.result.analyze.sopWarn.CrmSupplierRelation">
-        SELECT
-            cu.service_id AS serviceId,
-            cu.crm_no AS crmNo,
-            cu.user_id AS userId,
-            IFNULL(ss.id, 0) AS supplierId,
-            IFNULL(ss.name, '大区经理兼任') AS supplierName
-        FROM
-            (SELECT
-                 service_id, crm_no, user_id
-             FROM
-                 t_b_user_archives_allocation
-             UNION ALL SELECT
-                           service_id, crm_no, region_coordinator_id AS user_id
-             FROM
-                 t_b_crm) cu
-                LEFT JOIN
-            sys_user su ON cu.user_id = su.id
-                LEFT JOIN
-            t_b_user_archives tbua ON su.mobile_number = tbua.mobile_number
-                LEFT JOIN
-            t_b_user_archives_supplier tbuas ON tbuas.user_archives_id = tbua.id
-                LEFT JOIN
-            sys_supplier ss ON ss.id = tbuas.supplier_id
-                LEFT JOIN
-            t_b_crm tbc ON tbc.crm_no = cu.crm_no
-        <where>
-            <if test="serviceId != null">
-                AND cu.service_id = #{serviceId}
-            </if>
-        </where>
-    </select>
-</mapper>