shudonghui 1 سال پیش
والد
کامیت
9e1227bc13

+ 7 - 8
sop-api/src/main/java/com/qmth/sop/server/api/QualityAnalyseController.java

@@ -65,19 +65,18 @@ public class QualityAnalyseController {
     @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,
-                      @ApiParam(value = "供应商") @RequestParam(required = false) Long supplierId) {
-        Map<String, Object> map = qualityAnalyseService.pie(serviceUnitId, supplierId);
+    public Result pie(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId) {
+        Map<String, Object> map = qualityAnalyseService.pie(serviceUnitId);
         return ResultUtil.ok(map);
     }
 
     //质量问题总体盘点归因雷达图
-
+    @Aac(auth=false)
     @ApiOperation(value = "质量问题总体盘点归因雷达图")
     @RequestMapping(value = "/radar", method = RequestMethod.POST)
     public Result radar(@ApiParam(value = "服务单元", required = true) @RequestParam Long serviceUnitId,
-                        @ApiParam(value = "供应商") @RequestParam(required = false) Long supplierId) {
-        Map<String, Object> map = qualityAnalyseService.radar(serviceUnitId, supplierId);
+                        @ApiParam(value = "影响度分组", required = true) @RequestParam QualityAnalyseGroupEnum group) {
+        Map<String, Map<String, Object>> map = qualityAnalyseService.radar(serviceUnitId, group);
         return ResultUtil.ok(map);
     }
 
@@ -116,10 +115,10 @@ public class QualityAnalyseController {
     @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) Long supplierId,
+                         @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, supplierId);
+        IPage<TBQualityProblemApplyResult> resultIPage = qualityAnalyseService.detail(new Page<>(pageNumber, pageSize), serviceUnitId, degree);
 
         return ResultUtil.ok(resultIPage);
     }

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

@@ -23,9 +23,9 @@ import java.util.Map;
 public interface QualityAnalyseMapper extends BaseMapper<TBQualityProblemApply> {
 
 
-    IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, @Param("serviceUnitId") Long serviceUnitId, @Param("supplierId") Long supplierId);
+    IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, @Param("serviceUnitId") Long serviceUnitId, @Param("degree") InfluenceDegreeEnum degree);
 
-    Map<String, Object> radar(@Param("serviceUnitId")Long serviceUnitId,@Param("supplierId") Long supplierId);
+    List<Map<String, Object>> radar(@Param("serviceUnitId")Long serviceUnitId,@Param("supplierId") Long supplierId);
 
     List<TBService> list( @Param("startTime")Long startTime, @Param("endTime")Long endTime);
 

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

@@ -21,11 +21,11 @@ public interface QualityAnalyseService extends IService<TBQualityProblemApply> {
 
     Map<String,Map<String, Object>> influence(Long serviceUnitId, QualityAnalyseGroupEnum group);
 
-    Map<String, Object> pie(Long serviceUnitId, Long supplierId);
+    Map<String, Object> pie(Long serviceUnitId);
 
-    Map<String, Object> radar(Long serviceUnitId, Long supplierId);
+    Map<String, Map<String, Object>> radar(Long serviceUnitId, QualityAnalyseGroupEnum group);
 
-    IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, Long serviceUnitId, Long supplierId);
+    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);
 }

+ 39 - 6
sop-business/src/main/java/com/qmth/sop/business/service/impl/QualityAnalyseServiceImpl.java

@@ -67,18 +67,51 @@ public class QualityAnalyseServiceImpl extends ServiceImpl<QualityAnalyseMapper,
 
 
     @Override
-    public Map<String, Object> pie(Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.pie(serviceUnitId, supplierId);
+    public Map<String, Object> pie(Long serviceUnitId) {
+        return this.baseMapper.pie(serviceUnitId,null);
     }
 
     @Override
-    public Map<String, Object> radar(Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.radar(serviceUnitId, supplierId);
+    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().collect(Collectors.groupingBy(map -> map.get("reason"))).forEach((k, v) -> {
+            Map<String, Object> map = new HashMap<>();
+            map.put("reason",k);
+            map.put("count",v.stream().mapToLong(map1-> (long) map1.get("count")).sum());
+            result.put("all", map);
+        });
+
+
+        if (group.equals(QualityAnalyseGroupEnum.REASON_REGION)) {
+
+            radar.stream().collect(Collectors.groupingBy(map -> map.get("region_name"))).forEach((k, v) -> {
+                Map<String, Object> z = new HashMap<>();
+                v.stream().collect(Collectors.groupingBy(map2 -> map2.get("reason"))).forEach((k1, v1) -> {
+                    z.put("reason",k1);
+                    z.put("count",v1.stream().mapToLong(map1-> (long) map1.get("count")).sum());
+                });
+                result.put(k.toString(), z);
+            });
+        } else if (group.equals(QualityAnalyseGroupEnum.REASON_SUPPLIER)) {
+            radar.stream().collect(Collectors.groupingBy(map -> map.get("supplier"))).forEach((k, v) -> {
+                Map<String, Object> z = new HashMap<>();
+                v.stream().collect(Collectors.groupingBy(map2 -> map2.get("reason"))).forEach((k1, v1) -> {
+                    z.put("reason",k1);
+                    z.put("count",v1.stream().mapToLong(map1-> (long) map1.get("count")).sum());
+                });
+                result.put(k.toString(), z);
+            });
+        }
+        return result;
+
     }
 
     @Override
-    public IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, Long serviceUnitId, Long supplierId) {
-        return this.baseMapper.detail(objectPage, serviceUnitId, supplierId);
+    public IPage<TBQualityProblemApplyResult> detail(Page<Object> objectPage, Long serviceUnitId,InfluenceDegreeEnum degree) {
+        return this.baseMapper.detail(objectPage, serviceUnitId, degree);
     }
 
     @Override

+ 8 - 4
sop-business/src/main/resources/mapper/QualityAnalyseMapper.xml

@@ -47,16 +47,18 @@
     </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_service s ON a.service_id = s.id
-        left join t_b_service_region r on r.service_id=s.id
+        LEFT JOIN t_b_service_region r ON r.service_id = a.service_id
         LEFT JOIN sys_user u ON u.id = r.lead_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>
@@ -69,6 +71,8 @@
             </if>
         </where>
         GROUP BY
+        r.region_name,
+        s.NAME,
         a.reason
     </select>
     <sql id="query">
@@ -115,8 +119,8 @@
             <if test="serviceUnitId != null and serviceUnitId != ''">
                 and a.service_id = #{serviceUnitId}
             </if>
-            <if test="supplierId != null and supplierId != ''">
-                and us.supplier_id = #{supplierId}
+            <if test="degree != null and degree != ''">
+                and s.influenceDegree = #{degree}
             </if>
         </where>
         ORDER BY a.create_time DESC