Browse Source

质量问题报表问题修改

wangliang 1 year ago
parent
commit
2391f02af6

+ 42 - 40
sop-business/src/main/java/com/qmth/sop/business/service/impl/QualityAnalyseServiceImpl.java

@@ -1,9 +1,9 @@
 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.alibaba.fastjson.JSONObject;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
 import com.qmth.sop.business.entity.SysUser;
@@ -30,11 +30,12 @@ public class QualityAnalyseServiceImpl extends ServiceImpl<QualityAnalyseMapper,
 
     @Resource
     private SysUserService sysUserService;
+
     @Override
-    public List<TBService> list(Long startTime,Long endTime) {
+    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);
+        return this.baseMapper.list(startTime, endTime, dpr);
     }
 
 
@@ -47,48 +48,48 @@ public class QualityAnalyseServiceImpl extends ServiceImpl<QualityAnalyseMapper,
     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();
+        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) -> {
+            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) -> {
+                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"));
+                map.put("id", v.get(0).get("region_id"));
                 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();
+            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"));
+                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"));
                     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) -> {
+            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) -> {
+                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"));
+                map.put("id", v.get(0).get("region_id"));
                 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();
+            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"));
+                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"));
                     map.put(k1.toString(), map1);
                 });
                 result.put(k.toString(), map);
@@ -102,48 +103,49 @@ public class QualityAnalyseServiceImpl extends ServiceImpl<QualityAnalyseMapper,
     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()));
+        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> map = new HashMap<>();
-            map.put(k.toString(),v.stream().filter(map1->map1.get("count")!=null).mapToLong(map1-> (long) map1.get("count")).sum());
+        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) -> {
+            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()));
+                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) -> {
+            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()));
+                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 );
+    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);
+        return this.baseMapper.influenceDetail(tPage, serviceUnitId, supplierId, region_id, Objects.nonNull(influenceDegree) ? influenceDegree.toString() : null, Objects.nonNull(reason) ? reason.toString() : null);
     }
 }