From 28da7e877a08aaff967efa4adf9d2d4ab4b80c67 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期四, 09 四月 2026 16:29:46 +0800
Subject: [PATCH] 省立同德满意度功能修改

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskDetailTraceServiceImpl.java |   81 ++++++++++++++++++++++------------------
 1 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskDetailTraceServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskDetailTraceServiceImpl.java
index 6c0f49a..b19a590 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskDetailTraceServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskDetailTraceServiceImpl.java
@@ -3,6 +3,7 @@
 import java.util.*;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson2.JSON;
 import com.github.pagehelper.util.StringUtil;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -10,6 +11,7 @@
 import com.smartor.domain.DTO.DetailTraceDealDTO;
 import com.smartor.domain.VO.DetailTraceDealVO;
 import com.smartor.domain.VO.SatisfactionExceptConfigQuestionReqVO;
+import com.smartor.domain.VO.ServiceSubtaskDetailTraceVO;
 import com.smartor.mapper.ServiceSubtaskDetailMapper;
 import com.smartor.mapper.ServiceSubtaskDetailTraceMapper;
 import com.smartor.mapper.SvyLibScriptCategoryMapper;
@@ -62,56 +64,54 @@
     /**
      * 鏌ヨ闅忚浠诲姟寮傚父璁板綍璺熻釜鍒楄〃
      *
-     * @param serviceSubtaskDetailTrace 闅忚浠诲姟寮傚父璁板綍璺熻釜
+     * @param serviceSubtaskDetailTraceVO 闅忚浠诲姟寮傚父璁板綍璺熻釜
      * @return 闅忚浠诲姟寮傚父璁板綍璺熻釜
      */
     @Override
-    public List<ServiceSubtaskDetailTrace> selectServiceSubtaskDetailTtraceList(ServiceSubtaskDetailTrace serviceSubtaskDetailTrace) {
-        return serviceSubtaskDetailTraceMapper.selectServiceSubtaskDetailTtraceList(serviceSubtaskDetailTrace);
+    public List<ServiceSubtaskDetailTrace> selectServiceSubtaskDetailTtraceList(ServiceSubtaskDetailTraceVO serviceSubtaskDetailTraceVO) {
+        List<ServiceSubtaskDetailTrace> serviceSubtaskDetailTraces = serviceSubtaskDetailTraceMapper.selectServiceSubtaskDetailTtraceList(serviceSubtaskDetailTraceVO);
+        for (ServiceSubtaskDetailTrace serviceSubtaskDetailTrace : serviceSubtaskDetailTraces) {
+            if (StringUtils.isNotEmpty(serviceSubtaskDetailTrace.getPatdesc())) {
+                serviceSubtaskDetailTrace.setPatdescJson(JSON.parseObject(serviceSubtaskDetailTrace.getPatdesc()));
+            }
+        }
+        return serviceSubtaskDetailTraces;
     }
 
     @Override
-    public List<DetailTraceDealDTO> tracedeallist(DetailTraceDealVO detailTraceDealVO) {
-        // 鑾峰彇鎵�鏈夐渶瑕佸鐞嗙殑璁板綍
+    public Map<String, Object> tracedeallist(DetailTraceDealVO detailTraceDealVO) {
+        // 鍒嗛〉鏌ヨ
         List<ServiceSubtaskDetailTrace> tracedeallist = serviceSubtaskDetailTraceMapper.tracedeallist(detailTraceDealVO);
 
         // 鎸� questiontext 鍒嗙粍
-        Map<String, List<ServiceSubtaskDetailTrace>> groupByQuestion = tracedeallist.stream()
-                .filter(t -> t.getQuestiontext() != null)
-                .collect(Collectors.groupingBy(ServiceSubtaskDetailTrace::getQuestiontext));
+        Map<String, List<ServiceSubtaskDetailTrace>> groupByQuestion = tracedeallist.stream().filter(t -> t.getQuestiontext() != null).collect(Collectors.groupingBy(ServiceSubtaskDetailTrace::getQuestiontext));
 
         List<DetailTraceDealDTO> detailTraceDealDTOList = new ArrayList<>();
+        long totalException = 0L;
+        long noDealException = 0L;
+        long yesDealException = 0L;
+
         for (Map.Entry<String, List<ServiceSubtaskDetailTrace>> entry : groupByQuestion.entrySet()) {
             List<ServiceSubtaskDetailTrace> group = entry.getValue();
             DetailTraceDealDTO dto = new DetailTraceDealDTO();
 
             // 闂鍐呭
             dto.setQuestiontext(entry.getKey());
-
+            if (CollectionUtils.isNotEmpty(group)) {
+                dto.setScriptid(group.get(0).getScriptid());
+                dto.setTemplateType(group.get(0).getTemplateType());
+            }
             // 璐熻矗绉戝锛堝幓閲嶏級
-            List<Map<String, Object>> responsibleDept = group.stream()
-                    .filter(t -> t.getTodeptcode() != null)
-                    .collect(Collectors.collectingAndThen(
-                            Collectors.toMap(
-                                    ServiceSubtaskDetailTrace::getTodeptcode,
-                                    t -> {
-                                        Map<String, Object> deptMap = new HashMap<>();
-                                        deptMap.put("deptName", t.getTodeptname());
-                                        deptMap.put("deptCode", t.getTodeptcode());
-                                        return deptMap;
-                                    },
-                                    (existing, replacement) -> existing
-                            ),
-                            map -> new ArrayList<>(map.values())
-                    ));
+            List<Map<String, Object>> responsibleDept = group.stream().filter(t -> t.getTodeptcode() != null).collect(Collectors.collectingAndThen(Collectors.toMap(ServiceSubtaskDetailTrace::getTodeptcode, t -> {
+                Map<String, Object> deptMap = new HashMap<>();
+                deptMap.put("deptName", t.getTodeptname());
+                deptMap.put("deptCode", t.getTodeptcode());
+                return deptMap;
+            }, (existing, replacement) -> existing), map -> new ArrayList<>(map.values())));
             dto.setResponsibleDept(responsibleDept);
 
             // 鏈夋晥濉啓鏁帮細閫氳繃缁勫唴鐨� scriptid 鍘� service_subtask_detail 琛ㄦ煡璇�
-            List<Long> scriptIds = group.stream()
-                    .map(ServiceSubtaskDetailTrace::getScriptid)
-                    .filter(Objects::nonNull)
-                    .distinct()
-                    .collect(Collectors.toList());
+            List<Long> scriptIds = group.stream().map(ServiceSubtaskDetailTrace::getScriptid).filter(Objects::nonNull).distinct().collect(Collectors.toList());
             long effectiveFillNum = 0L;
             if (CollectionUtils.isNotEmpty(scriptIds)) {
                 ServiceSubtaskDetail query = new ServiceSubtaskDetail();
@@ -140,19 +140,26 @@
             exceptionQuesNum.put("all", exceptionFillNum);
             dto.setExceptionQuesNum(exceptionQuesNum);
 
+            // 姹囨�荤粺璁$疮鍔�
+            totalException += exceptionFillNum;
+            noDealException += noDeal;
+            yesDealException += yesDeal;
+
             // 鏈�鏂板鐞嗕汉鍜屽鐞嗘椂闂达紙鍙� handleTime 鏈�鏂扮殑涓�鏉★級
-            group.stream()
-                    .filter(t -> t.getHandleTime() != null)
-                    .max(Comparator.comparing(ServiceSubtaskDetailTrace::getHandleTime))
-                    .ifPresent(latest -> {
-                        dto.setHandleBy(latest.getHandleBy());
-                        dto.setHandleTime(latest.getHandleTime());
-                    });
+            group.stream().filter(t -> t.getHandleTime() != null).max(Comparator.comparing(ServiceSubtaskDetailTrace::getHandleTime)).ifPresent(latest -> {
+                dto.setHandleBy(latest.getHandleBy());
+                dto.setHandleTime(latest.getHandleTime());
+            });
 
             detailTraceDealDTOList.add(dto);
         }
 
-        return detailTraceDealDTOList;
+        Map<String, Object> result = new HashMap<>();
+        result.put("detailTraceDealDTOList", detailTraceDealDTOList);
+        result.put("totalException", totalException);
+        result.put("noDealException", noDealException);
+        result.put("yesDealException", yesDealException);
+        return result;
     }
 
     /**

--
Gitblit v1.9.3