From 14c05113b72698a331259ce7c34c7ae8dd69ffd7 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期五, 09 一月 2026 14:34:03 +0800
Subject: [PATCH] 【市一】问题统计接口调整

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java |   61 +++++++++++++++++++++++++++---
 1 files changed, 54 insertions(+), 7 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index 8982e03..99eace4 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson2.JSON;
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import com.ruoyi.common.core.redis.RedisCache;
@@ -17,6 +18,7 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.ListUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -360,7 +362,7 @@
 //        return map;
 //    }
 
-    
+
     /**
      * 缁熻浠诲姟鍚勭鐘舵�佺殑鏁伴噺锛堝凡浼樺寲锛�
      * 浼樺寲璇存槑锛�
@@ -2197,8 +2199,18 @@
             stringBuilder.append("鍏ラ櫌鍑嗗涓績鐢佃瘽锛�89975977銆傚叆闄㈠姙鐞嗛』鐭�:https://mp.weixin.qq.com/s/OCkotuRyQ8Ld2owFF0YErw");
 
             String data = MessageSend.sendMsg(stringBuilder.toString(), "6", patArchiveSrmVO.getPhone(), LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
-            if (StringUtils.isNotEmpty(data) && data.contains("result=0")) {
-                sendError.add(patArchiveSrmVO);
+            if (StringUtils.isNotEmpty(data)) {
+                ObjectMapper mapper = new ObjectMapper();
+                JsonNode root = null;
+                try {
+                    root = mapper.readTree(data);
+                } catch (JsonProcessingException e) {
+                    e.printStackTrace();
+                }
+                String status = root.get("result").get(0).get("status").asText();
+                if (status.equals("00000")) {
+                    sendError.add(patArchiveSrmVO);
+                }
             }
         }
 
@@ -3027,7 +3039,8 @@
         Map<String, ServiceSubtaskScriptCount> result = new HashMap<>();
         List<ServiceSubtaskScriptCount> allCounts = new ArrayList<>();
         List<ServiceSubtaskScriptCount> allItemCounts = new ArrayList<>();
-        if(ObjectUtils.isEmpty(serviceSubtaskCountReq.getType())){
+        String type = serviceSubtaskCountReq.getType();
+        if(ObjectUtils.isEmpty(type)){
             //鏌ヨ璇煶缁熻鏄庣粏
             serviceSubtaskCountReq.setType("1");
             List<ServiceSubtaskScriptCount> ivyCounts = serviceSubtaskMapper.getSfStatisticsScriptDetails(serviceSubtaskCountReq);
@@ -3047,16 +3060,49 @@
             allItemCounts = serviceSubtaskMapper.getSfStatisticsScriptItemDetails(serviceSubtaskCountReq);
         }
 
-
         for(ServiceSubtaskScriptCount count : allCounts){
-            List<ServiceSubtaskScriptCount> itemCounts = new ArrayList<>();
+            Map<String, ServiceSubtaskScriptCount> itemCountMap = new HashMap<>();
+            //闂嵎鍔犱笂绌虹櫧閫夐」
+            if(ObjectUtils.isNotEmpty(count.getTemplateid())
+                    && ObjectUtils.isNotEmpty(count.getSubtaskType())
+                    && count.getSubtaskType().equals("2")){
+                SvyTaskTemplateScriptVO svyTaskTemplateScriptVO = new SvyTaskTemplateScriptVO();
+                svyTaskTemplateScriptVO.setId(count.getScriptid());
+                svyTaskTemplateScriptVO.setOrgid(serviceSubtaskCountReq.getOrgid());
+                SvyTaskTemplateScriptVO svyTaskTemplateScriptResultVo = svyTaskTemplateScriptService.selectInfoByCondition(svyTaskTemplateScriptVO);
+                if(ObjectUtils.isNotEmpty(svyTaskTemplateScriptResultVo)){
+                    List<SvyTaskTemplateTargetoption> svyTaskTemplateTargetoptions = svyTaskTemplateScriptResultVo.getSvyTaskTemplateTargetoptions();
+                    if(ObjectUtils.isNotEmpty(svyTaskTemplateTargetoptions)){
+                        //濉叆绌虹櫧淇℃伅
+                        svyTaskTemplateTargetoptions.forEach(targetoption ->{
+                            ServiceSubtaskScriptCount emptyCount = new ServiceSubtaskScriptCount();
+                            emptyCount.setScriptid(count.getScriptid());
+                            emptyCount.setScriptContent(count.getScriptContent());
+                            emptyCount.setScriptType(count.getScriptType());
+                            emptyCount.setSubtaskType(count.getSubtaskType());
+                            emptyCount.setCompletedQuantity(count.getCompletedQuantity());
+                            emptyCount.setAllQuantity(count.getAllQuantity());
+                            emptyCount.setCompletedPercentage(count.getCompletedPercentage());
+                            emptyCount.setTemplateid(count.getTemplateid());
+                            emptyCount.setChosenQuantity(0);
+                            emptyCount.setChosenPercentage("0.0");
+                            emptyCount.setOptionText(targetoption.getOptioncontent());
+                            itemCountMap.put(targetoption.getOptioncontent(),emptyCount);
+                        });
+                    }
+                }
+            }
             allItemCounts.forEach(itemCount ->{
                 if(ObjectUtils.isNotEmpty(count.getScriptid()) && ObjectUtils.isNotEmpty(itemCount.getScriptid())){
                     if(count.getScriptid().equals(itemCount.getScriptid())){
                         //鏀惧叆缁熻淇℃伅
                         itemCount.setScriptContent(count.getScriptContent());
+                        itemCount.setScriptType(count.getScriptType());
+                        itemCount.setSubtaskType(count.getSubtaskType());
                         itemCount.setCompletedQuantity(count.getCompletedQuantity());
                         itemCount.setAllQuantity(count.getAllQuantity());
+                        itemCount.setCompletedPercentage(count.getCompletedPercentage());
+                        itemCount.setTemplateid(count.getTemplateid());
                         //璁$畻閫夋嫨姣斾緥
                         int chosenQuantity = ObjectUtils.isNotEmpty(itemCount.getChosenQuantity())?itemCount.getChosenQuantity():0;
                         int completedQuantity = itemCount.getCompletedQuantity();
@@ -3064,10 +3110,11 @@
                             BigDecimal chosenPercentage = (new BigDecimal(chosenQuantity)).divide(new BigDecimal(completedQuantity), 2, RoundingMode.HALF_UP);
                             itemCount.setChosenPercentage(chosenPercentage.toString());
                         }
-                        itemCounts.add(itemCount);
+                        itemCountMap.put(itemCount.getOptionText(), itemCount);
                     }
                 }
             });
+            List<ServiceSubtaskScriptCount> itemCounts = new ArrayList<>(itemCountMap.values());
             count.setDetails(itemCounts);
             result.put(count.getScriptid().toString(),count);
         }

--
Gitblit v1.9.3