From 75cb81f0b88f313857ea431b46b929bef95d7cc8 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 29 七月 2024 10:36:59 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java |  151 ++++++++++++++++++++++++++++++++++----------------
 1 files changed, 103 insertions(+), 48 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
index bf0c347..ae06130 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskAnswerServiceImpl.java
@@ -1,13 +1,24 @@
 package com.smartor.service.impl;
 
+import com.alibaba.fastjson2.JSON;
+import com.alibaba.fastjson2.JSONArray;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.RSAPublicKeyExample;
 import com.ruoyi.common.utils.StringUtils;
 import com.smartor.domain.*;
+import com.smartor.mapper.IvrTaskTemplateScriptMapper;
 import com.smartor.mapper.ServiceSubtaskAnswerMapper;
 import com.smartor.mapper.ServiceSubtaskMapper;
+import com.smartor.mapper.ServiceTaskMapper;
+import com.smartor.service.IIvrTaskTemplateService;
 import com.smartor.service.IServiceSubtaskAnswerService;
+import com.smartor.service.ISvyTaskTemplateService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
@@ -15,10 +26,7 @@
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 
 /**
  * 浠诲姟闂嵎闂閫夐」Service涓氬姟灞傚鐞�
@@ -31,9 +39,6 @@
 public class ServiceSubtaskAnswerServiceImpl implements IServiceSubtaskAnswerService {
     @Autowired
     private ServiceSubtaskAnswerMapper serviceSubtaskAnswerMapper;
-
-    @Autowired
-    private ServiceSubtaskMapper serviceSubtaskMapper;
 
     @Autowired
     private RedisCache redisCache;
@@ -115,13 +120,17 @@
         if (ObjectUtils.isNotEmpty(serviceSubTaskAnswerReq)) {
             //闇�瑕佺珛鍗虫墽琛�
             RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
-            Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskAnswerReq.getParam1(), pri_key));
-            Long pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskAnswerReq.getParam2(), pri_key));
+//            Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskAnswerReq.getParam1(), pri_key));
+//            Long pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskAnswerReq.getParam2(), pri_key));
+
+            Long tid=Long.valueOf(serviceSubTaskAnswerReq.getParam1());
+            Long pid=Long.valueOf(serviceSubTaskAnswerReq.getParam2());
+
             allKeys = new HashSet<>();
             if (serviceSubTaskAnswerReq.getType() == 1) {
-                allKeys.add(redisCache.getCacheObject(pid + "-" + tid + "-SFscriptCache"));
+                allKeys.add(pid + "-" + tid + "-SFscriptCache");
             } else if (serviceSubTaskAnswerReq.getType() == 2) {
-                allKeys.add(redisCache.getCacheObject(pid + "-" + tid + "-WJscriptCache"));
+                allKeys.add(pid + "-" + tid + "-WJscriptCache");
             }
         }
 
@@ -130,17 +139,17 @@
             String[] split = key.split("-");
             if (key.contains("-SFscriptCache")) {
                 //鍖呭惈浜�,璇存槑浜嗘槸闅忚闂
-                List<IvrLibaTemplateScriptVO> cacheList = redisCache.getCacheList(key);
+                List<IvrTaskTemplateScriptVO> cacheList = redisCache.getCacheObject(key);
                 for (int i = 0; i < cacheList.size(); i++) {
                     if (i == 0) {
                         // 璇存槑鏄涓�棰�
-                        IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO = cacheList.get(0);
+                        IvrTaskTemplateScriptVO ivrLibaTemplateScriptVO = cacheList.get(0);
                         //灏嗙涓�棰樼殑淇℃伅鏀惧埌琛ㄤ腑
                         setSFInfo(ivrLibaTemplateScriptVO, Long.valueOf(split[1]), Long.valueOf(split[0]));
                         nextScriptno = cacheList.get(0).getNextScriptno();
                     } else {
                         //涓嶆槸绗� 涓� 棰�
-                        for (IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO : cacheList) {
+                        for (IvrTaskTemplateScriptVO ivrLibaTemplateScriptVO : cacheList) {
                             if (ivrLibaTemplateScriptVO.getId() == nextScriptno) {
                                 setSFInfo(ivrLibaTemplateScriptVO, Long.valueOf(split[1]), Long.valueOf(split[0]));
                                 nextScriptno = ivrLibaTemplateScriptVO.getNextScriptno();
@@ -149,7 +158,7 @@
                     }
                 }
             } else if (key.contains("-WJscriptCache")) {
-                List<SvyLibTemplateScriptVO> cacheList = redisCache.getCacheList(key);
+                List<SvyTaskTemplateScriptVO> cacheList = redisCache.getCacheList(key);
                 for (int i = 0; i < cacheList.size(); i++) {
                     if (i == 0) {
                         // 璇存槑鏄涓�棰�
@@ -157,10 +166,10 @@
                         setWJInfo(cacheList.get(0), Long.valueOf(split[1]), Long.valueOf(split[0]));
                         nextScriptno = Long.valueOf(cacheList.get(0).getNextScriptno());
                     } else {
-                        for (SvyLibTemplateScriptVO svyLibTemplateScriptVO : cacheList) {
-                            if (svyLibTemplateScriptVO.getId() == nextScriptno) {
+                        for (SvyTaskTemplateScriptVO svyTaskTemplateScriptVO : cacheList) {
+                            if (svyTaskTemplateScriptVO.getId() == nextScriptno) {
                                 //灏嗙涓�棰樼殑淇℃伅鏀惧埌琛ㄤ腑
-                                setWJInfo(svyLibTemplateScriptVO, Long.valueOf(split[1]), Long.valueOf(split[0]));
+                                setWJInfo(svyTaskTemplateScriptVO, Long.valueOf(split[1]), Long.valueOf(split[0]));
                                 nextScriptno = Long.valueOf(cacheList.get(0).getNextScriptno());
                             }
 
@@ -183,65 +192,111 @@
     @Override
     public Integer saveQuestionCache(ServiceSubTaskCacheReq serviceSubTaskCacheReq) {
         RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample();
-        Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskCacheReq.getParam1(), pri_key));
-        Long pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskCacheReq.getParam2(), pri_key));
-        if (CollectionUtils.isNotEmpty(serviceSubTaskCacheReq.getIvrLibaTemplateScriptVOList())) {
+//        Long tid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskCacheReq.getParam1(), pri_key));
+//        Long pid = Long.valueOf(rsaPublicKeyExample.decryptedData(serviceSubTaskCacheReq.getParam2(), pri_key));
+        Long tid=Long.valueOf(serviceSubTaskCacheReq.getParam1());
+        Long pid=Long.valueOf(serviceSubTaskCacheReq.getParam2());
+        if (CollectionUtils.isNotEmpty(serviceSubTaskCacheReq.getIvrTaskTemplateScriptVOList())) {
             //闅忚
-            redisCache.setCacheObject(pid + "-" + tid + "-SFscriptCache", serviceSubTaskCacheReq.getIvrLibaTemplateScriptVOList());
-        } else if (CollectionUtils.isNotEmpty(serviceSubTaskCacheReq.getSvyLibTemplateScriptVOList())) {
+            redisCache.setCacheObject(pid + "-" + tid + "-SFscriptCache", serviceSubTaskCacheReq.getIvrTaskTemplateScriptVOList());
+        } else if (CollectionUtils.isNotEmpty(serviceSubTaskCacheReq.getSvyTaskTemplateScriptVOList())) {
             //闂嵎
-            redisCache.setCacheObject(pid + "-" + tid + "-WJscriptCache", serviceSubTaskCacheReq.getSvyLibTemplateScriptVOList());
+            redisCache.setCacheObject(pid + "-" + tid + "-WJscriptCache", serviceSubTaskCacheReq.getSvyTaskTemplateScriptVOList());
         }
         return 1;
     }
 
+    @Override
+    public List<ServiceSubtaskAnswer> selectPatQuestionResult(ServiceSubTaskQueryReq serviceSubTaskQueryReq) {
+        log.error("selectPatQuesTionResult鐨勫叆鍙備负锛歿}", serviceSubTaskQueryReq);
+        ServiceSubtaskAnswer serviceSubtaskAnswer = new ServiceSubtaskAnswer();
+        serviceSubtaskAnswer.setTaskid(serviceSubTaskQueryReq.getTaskid());
+        serviceSubtaskAnswer.setPatId(serviceSubTaskQueryReq.getPatId());
+        serviceSubtaskAnswer.setScriptid(serviceSubTaskQueryReq.getScriptid());
+        List<ServiceSubtaskAnswer> serviceSubtaskAnswerList = serviceSubtaskAnswerMapper.selectServiceSubtaskAnswerList(serviceSubtaskAnswer);
+        for (ServiceSubtaskAnswer serviceSubtaskAnswer1 : serviceSubtaskAnswerList) {
+            ObjectMapper mapper = new ObjectMapper();
+            try {
+                List<ServiceSubtaskOptionAnswer> serviceSubtaskOptionAnswer = mapper.readValue(serviceSubtaskAnswer1.getAnswer(), List.class);
+                serviceSubtaskAnswer1.setOptionAnswer(serviceSubtaskOptionAnswer);
+            } catch (JsonProcessingException e) {
+                e.printStackTrace();
+            }
+        }
+        return serviceSubtaskAnswerList;
+    }
 
-    private void setSFInfo(IvrLibaTemplateScriptVO ivrLibaTemplateScriptVO, Long taskid, Long patid) {
-        ServiceSubtaskAnswer serviceSubtaskAnswer = null;
-        String dx = "";
-        if (ivrLibaTemplateScriptVO.getScriptType().equals("1") || ivrLibaTemplateScriptVO.getScriptType().equals("2")) {
+    private void setSFInfo(IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO, Long taskid, Long patid) {
+        ServiceSubtaskAnswer serviceSubtaskAnswer = new ServiceSubtaskAnswer();
+        List<ServiceSubtaskOptionAnswer> answerList = new ArrayList<>();
+        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getScriptType()) && ivrTaskTemplateScriptVO.getScriptType().equals("1") || StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getScriptType()) && ivrTaskTemplateScriptVO.getScriptType().equals("2")) {
             //1銆�2涓哄崟閫夋垨澶氶��
-            for (IvrLibaTemplateTargetoption ivrLibaTemplateTargetoption : ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList()) {
+            for (IvrTaskTemplateTargetoption ivrTaskTemplateTargetoption : ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList()) {
                 //鑾峰彇鐢ㄦ埛閫変腑鐨勯�夐」鍙�
-                dx = dx + "," + ivrLibaTemplateTargetoption.getOptionNo().toString();
+                if (ivrTaskTemplateTargetoption.getIsUserOperation() == true) {
+                    ServiceSubtaskOptionAnswer serviceSubtaskOptionAnswer = new ServiceSubtaskOptionAnswer();
+                    serviceSubtaskOptionAnswer.setId(ivrTaskTemplateTargetoption.getId());
+                    serviceSubtaskOptionAnswer.setCode(ivrTaskTemplateTargetoption.getOptionCode());
+                    serviceSubtaskOptionAnswer.setValue(ivrTaskTemplateTargetoption.getTargetvalue());
+                    serviceSubtaskOptionAnswer.setAppenddesc(ivrTaskTemplateTargetoption.getAppenddesc());
+                    answerList.add(serviceSubtaskOptionAnswer);
+                }
             }
         } else {
             //闈炲崟澶氶��
-            if (CollectionUtils.isNotEmpty(ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList())) {
-                dx = ivrLibaTemplateScriptVO.getIvrLibaScriptTargetoptionList().get(0).getAppenddesc();
+            if (CollectionUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList())) {
+                log.error("IvrTaskScriptTargetoptionList鐨勫�间负锛歿}", ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList());
+                ServiceSubtaskOptionAnswer serviceSubtaskOptionAnswer = new ServiceSubtaskOptionAnswer();
+                serviceSubtaskOptionAnswer.setId(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(0).getId());
+                serviceSubtaskOptionAnswer.setCode(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(0).getOptionCode());
+                serviceSubtaskOptionAnswer.setValue(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(0).getTargetvalue());
+                serviceSubtaskOptionAnswer.setAppenddesc(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(0).getAppenddesc());
+                answerList.add(serviceSubtaskOptionAnswer);
             }
         }
-        serviceSubtaskAnswer.setTaskid(Long.valueOf(taskid));
-        serviceSubtaskAnswer.setPatId(Long.valueOf(patid));
-        serviceSubtaskAnswer.setScriptid(ivrLibaTemplateScriptVO.getId());
-        serviceSubtaskAnswer.setScriptType(Long.valueOf(ivrLibaTemplateScriptVO.getScriptType()));
-        serviceSubtaskAnswer.setAnswer(dx.substring(1));
+        //鏁版嵁淇濆瓨
+        serviceSubtaskAnswer.setTaskid(taskid);
+        serviceSubtaskAnswer.setPatId(patid);
+        serviceSubtaskAnswer.setScriptid(ivrTaskTemplateScriptVO.getId());
+        serviceSubtaskAnswer.setScriptType(Long.valueOf(ivrTaskTemplateScriptVO.getScriptType()));
+        serviceSubtaskAnswer.setAnswer(JSON.toJSONString(answerList));
         serviceSubtaskAnswer.setComment(null);
         serviceSubtaskAnswer.setCreateTime(new Date());
         serviceSubtaskAnswer.setUpdateTime(new Date());
         serviceSubtaskAnswerMapper.insertServiceSubtaskAnswer(serviceSubtaskAnswer);
     }
 
-    private void setWJInfo(SvyLibTemplateScriptVO svyLibTemplateScriptVO, Long taskid, Long patid) {
+    private void setWJInfo(SvyTaskTemplateScriptVO svyTaskTemplateScriptVO, Long taskid, Long patid) {
         ServiceSubtaskAnswer serviceSubtaskAnswer = null;
-        String dx = "";
-        if (svyLibTemplateScriptVO.getScriptType().equals("1") || svyLibTemplateScriptVO.getScriptType().equals("2")) {
+        List<ServiceSubtaskOptionAnswer> answerList = new ArrayList<>();
+        if (svyTaskTemplateScriptVO.getScriptType().equals("1") || svyTaskTemplateScriptVO.getScriptType().equals("2")) {
             //1銆�2涓哄崟閫夋垨澶氶��
-            for (SvyLibTemplateTargetoption svyLibTemplateTargetoption : svyLibTemplateScriptVO.getSvyLibTemplateTargetoptions()) {
-                //鑾峰彇鐢ㄦ埛閫変腑鐨勯�夐」鍙�
-                dx = dx + "," + svyLibTemplateTargetoption.getOptionNo().toString();
+            for (SvyTaskTemplateTargetoption svyTaskTemplateTargetoption : svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions()) {
+                if (svyTaskTemplateTargetoption.getIsUserOperation() == true) {
+                    ServiceSubtaskOptionAnswer serviceSubtaskOptionAnswer = new ServiceSubtaskOptionAnswer();
+                    serviceSubtaskOptionAnswer.setId(svyTaskTemplateTargetoption.getId());
+                    serviceSubtaskOptionAnswer.setCode(svyTaskTemplateTargetoption.getOptionCode());
+                    serviceSubtaskOptionAnswer.setValue(svyTaskTemplateTargetoption.getTargetvalue());
+                    serviceSubtaskOptionAnswer.setAppenddesc(svyTaskTemplateTargetoption.getAppenddesc());
+                    answerList.add(serviceSubtaskOptionAnswer);
+                }
             }
         } else {
             //闈炲崟澶氶��
-            if (CollectionUtils.isNotEmpty(svyLibTemplateScriptVO.getSvyLibTemplateTargetoptions())) {
-                dx = svyLibTemplateScriptVO.getSvyLibTemplateTargetoptions().get(0).getAppenddesc();
+            if (CollectionUtils.isNotEmpty(svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions())) {
+                ServiceSubtaskOptionAnswer serviceSubtaskOptionAnswer = new ServiceSubtaskOptionAnswer();
+                serviceSubtaskOptionAnswer.setId(svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions().get(0).getId());
+                serviceSubtaskOptionAnswer.setCode(svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions().get(0).getOptionCode());
+                serviceSubtaskOptionAnswer.setValue(svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions().get(0).getTargetvalue());
+                serviceSubtaskOptionAnswer.setAppenddesc(svyTaskTemplateScriptVO.getSvyTaskTemplateTargetoptions().get(0).getAppenddesc());
+                answerList.add(serviceSubtaskOptionAnswer);
             }
         }
         serviceSubtaskAnswer.setTaskid(Long.valueOf(taskid));
         serviceSubtaskAnswer.setPatId(Long.valueOf(patid));
-        serviceSubtaskAnswer.setScriptid(svyLibTemplateScriptVO.getId());
-        serviceSubtaskAnswer.setScriptType(Long.valueOf(svyLibTemplateScriptVO.getScriptType()));
-        serviceSubtaskAnswer.setAnswer(dx.substring(1));
+        serviceSubtaskAnswer.setScriptid(svyTaskTemplateScriptVO.getId());
+        serviceSubtaskAnswer.setScriptType(Long.valueOf(svyTaskTemplateScriptVO.getScriptType()));
+        serviceSubtaskAnswer.setAnswer(JSON.toJSONString(answerList));
         serviceSubtaskAnswer.setComment(null);
         serviceSubtaskAnswer.setCreateTime(new Date());
         serviceSubtaskAnswer.setUpdateTime(new Date());

--
Gitblit v1.9.3