From 10aaa035f5be0312304d20f022bdb714a8f4900a Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 11 十二月 2024 22:16:23 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/IvrLibaScriptServiceImpl.java | 249 ++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 200 insertions(+), 49 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrLibaScriptServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrLibaScriptServiceImpl.java
index 25cd10d..1199649 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrLibaScriptServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrLibaScriptServiceImpl.java
@@ -1,96 +1,247 @@
package com.smartor.service.impl;
-import java.util.List;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.Gson;
+import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.DtoConversionUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.smartor.domain.*;
+import com.smartor.mapper.IvrLibaScriptMapper;
+import com.smartor.mapper.IvrLibaScriptTagMapper;
+import com.smartor.mapper.IvrLibaScriptTargetMapper;
+import com.smartor.mapper.IvrLibaScriptTargetoptionMapper;
+import com.smartor.service.IIvrLibaScriptService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import com.smartor.mapper.IvrLibaScriptMapper;
-import com.smartor.domain.IvrLibaScript;
-import com.smartor.service.IIvrLibaScriptService;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
/**
- * 璇濇湳搴揝ervice涓氬姟灞傚鐞�
- *
- * @author smartor
- * @date 2023-03-22
+ * 闂璇濇湳搴揝ervice涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2023-12-21
*/
+@Slf4j
@Service
-public class IvrLibaScriptServiceImpl implements IIvrLibaScriptService
-{
+public class IvrLibaScriptServiceImpl implements IIvrLibaScriptService {
@Autowired
private IvrLibaScriptMapper ivrLibaScriptMapper;
+ @Autowired
+ private IvrLibaScriptTagMapper ivrLibaScriptTagMapper;
+
+ @Autowired
+ private IvrLibaScriptTargetoptionMapper ivrLibaScriptTargetoptionMapper;
+
+ @Autowired
+ private IvrLibaScriptTargetMapper ivrLibaScriptTargetMapper;
+
/**
- * 鏌ヨ璇濇湳搴�
- *
- * @param questionid 璇濇湳搴撲富閿�
- * @return 璇濇湳搴�
+ * 鏌ヨ闂璇濇湳搴�
+ *
+ * @param questionid 闂璇濇湳搴撲富閿�
+ * @return 闂璇濇湳搴�
*/
@Override
- public IvrLibaScript selectIvrLibaScriptByQuestionid(String questionid)
- {
+ public IvrLibaScript selectIvrLibaScriptByQuestionid(String questionid) {
return ivrLibaScriptMapper.selectIvrLibaScriptByQuestionid(questionid);
}
/**
- * 鏌ヨ璇濇湳搴撳垪琛�
- *
- * @param ivrLibaScript 璇濇湳搴�
- * @return 璇濇湳搴�
+ * 鏌ヨ闂璇濇湳搴撳垪琛�
+ *
+ * @param ivrLibaScript 闂璇濇湳搴�
+ * @return 闂璇濇湳搴�
*/
@Override
- public List<IvrLibaScript> selectIvrLibaScriptList(IvrLibaScript ivrLibaScript)
- {
+ public List<IvrLibaScript> selectIvrLibaScriptList(IvrLibaScript ivrLibaScript) {
return ivrLibaScriptMapper.selectIvrLibaScriptList(ivrLibaScript);
}
/**
- * 鏂板璇濇湳搴�
- *
- * @param ivrLibaScript 璇濇湳搴�
+ * 鏌ヨ闂璇濇湳璇︽儏鏍规嵁鏉′欢
+ */
+ @Override
+ public IvrLibaScriptVO selectInfoByCondition(IvrLibaScriptVO ivrLibaScriptVO) {
+ log.info("鏌ヨ闂璇濇湳璇︽儏鏍规嵁鏉′欢鐨勫叆鍙備负 : {}", ivrLibaScriptVO);
+ //鍏堟牴鎹潯浠舵煡璇㈤棶棰樿〃淇℃伅
+ IvrLibaScript ivrLibaScript = DtoConversionUtils.sourceToTarget(ivrLibaScriptVO, IvrLibaScript.class);
+ List<IvrLibaScript> ivrLibaScripts = selectIvrLibaScriptList(ivrLibaScript);
+ if (CollectionUtils.isEmpty(ivrLibaScripts)) {
+ log.info("鎻愪緵鐨勬潯浠�,鏌ヨ鏁版嵁涓虹┖锛歿}", ivrLibaScript);
+ return null;
+ }
+ log.info("ivrLibaScript鐨勬煡璇㈢粨鏋滀负:{},鏁伴噺涓� : {}", ivrLibaScripts.get(0), ivrLibaScripts.size());
+ //瀹氫箟IvrLibaScriptVO 鐢ㄤ簬杩斿弬
+ IvrLibaScriptVO scriptVO = DtoConversionUtils.sourceToTarget(ivrLibaScripts.get(0), IvrLibaScriptVO.class);
+
+ //鑾峰彇tag淇℃伅
+ IvrLibaScriptTag ivrLibaScriptTag = new IvrLibaScriptTag();
+ ivrLibaScriptTag.setScriptid(ivrLibaScripts.get(0).getId());
+ List<IvrLibaScriptTag> ivrLibaScriptTags = ivrLibaScriptTagMapper.selectIvrLibaScriptTagList(ivrLibaScriptTag);
+ scriptVO.setIvrLibaScriptTagList(ivrLibaScriptTags);
+
+ //鑾峰彇option淇℃伅
+ IvrLibaScriptTargetoption ivrLibaScriptTargetoption = new IvrLibaScriptTargetoption();
+ ivrLibaScriptTargetoption.setScriptid(ivrLibaScripts.get(0).getId());
+ List<IvrLibaScriptTargetoption> ivrLibaScriptTargetoptions = ivrLibaScriptTargetoptionMapper.selectIvrLibaScriptTargetoptionList(ivrLibaScriptTargetoption);
+ for (IvrLibaScriptTargetoption ivrLibaScriptTargetoption1 : ivrLibaScriptTargetoptions) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ if (StringUtils.isNotEmpty(ivrLibaScriptTargetoption1.getDynamiccruxsJson()))
+ ivrLibaScriptTargetoption1.setDynamiccruxs(objectMapper.readValue(ivrLibaScriptTargetoption1.getDynamiccruxsJson(), List.class));
+ if (StringUtils.isNotEmpty(ivrLibaScriptTargetoption1.getNodynamiccruxsJson()))
+ ivrLibaScriptTargetoption1.setNodynamiccruxs(objectMapper.readValue(ivrLibaScriptTargetoption1.getNodynamiccruxsJson(), List.class));
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ scriptVO.setIvrLibaScriptTargetoptionList(ivrLibaScriptTargetoptions);
+
+// //鏌ヨ闂鎸囨爣鎺ュ彛
+// IvrLibaScriptTarget ivrLibaScriptTarget = new IvrLibaScriptTarget();
+// ivrLibaScriptTarget.setScriptid(ivrLibaScripts.get(0).getId());
+// List<IvrLibaScriptTarget> ivrLibaScriptTargets = ivrLibaScriptTargetMapper.selectIvrLibaScriptTargetList(ivrLibaScriptTarget);
+// scriptVO.setIvrLibaScriptTargetList(ivrLibaScriptTargets);
+
+ return scriptVO;
+ }
+
+ /**
+ * 鏂板鎴栦慨鏀归棶棰樿鎯�
+ *
+ * @param ivrLibaScriptVO
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ @Override
+ public Integer saveOrUpdateScript(IvrLibaScriptVO ivrLibaScriptVO) {
+ IvrLibaScript ivrLibaScript = DtoConversionUtils.sourceToTarget(ivrLibaScriptVO, IvrLibaScript.class);
+ //瀵归棶棰樿〃杩涜鏁版嵁澶勭悊
+ Integer i = null;
+ if (ivrLibaScriptVO.getIsoperation() != null && ivrLibaScriptVO.getIsoperation() == 1) {
+ i = ivrLibaScriptMapper.insertIvrLibaScript(ivrLibaScript);
+ } else if (ivrLibaScriptVO.getIsoperation() != null && ivrLibaScriptVO.getIsoperation() == 2) {
+ i = ivrLibaScriptMapper.updateIvrLibaScript(ivrLibaScript);
+ }
+ log.info("闂琛ㄥ搴旂殑id涓猴細{}", ivrLibaScript.getId());
+ if (ivrLibaScript.getId() == null) {
+ throw new BaseException("璇濇湳ID涓虹┖,璇锋鏌ヨ瘽鏈叆鍙備俊鎭槸鍚﹀畬鏁�");
+ }
+
+ //瀵归棶棰樻寚鏍囬�夐」杩涜澶勭悊
+ if (CollectionUtils.isNotEmpty(ivrLibaScriptVO.getIvrLibaScriptTargetoptionList())) {
+ for (IvrLibaScriptTargetoption ivrLibaScriptTargetoption : ivrLibaScriptVO.getIvrLibaScriptTargetoptionList()) {
+ if (CollectionUtils.isNotEmpty(ivrLibaScriptTargetoption.getNodynamiccruxs())) {
+ ivrLibaScriptTargetoption.setNodynamiccruxsJson(new Gson().toJson(ivrLibaScriptTargetoption.getNodynamiccruxs()));
+ }
+ if (CollectionUtils.isNotEmpty(ivrLibaScriptTargetoption.getDynamiccruxs())) {
+ ivrLibaScriptTargetoption.setDynamiccruxsJson(new Gson().toJson(ivrLibaScriptTargetoption.getDynamiccruxs()));
+ }
+
+ if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 1) {
+ //鏂板
+ ivrLibaScriptTargetoption.setScriptid(ivrLibaScript.getId());
+ ivrLibaScriptTargetoptionMapper.insertIvrLibaScriptTargetoption(ivrLibaScriptTargetoption);
+ }
+ if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 2) {
+ //淇敼
+ ivrLibaScriptTargetoption.setScriptid(ivrLibaScript.getId());
+ ivrLibaScriptTargetoptionMapper.updateIvrLibaScriptTargetoption(ivrLibaScriptTargetoption);
+ //濡傛灉瑕佺粰姝e垯缃┖锛屽垯闇�瑕佸崟鐙皟淇敼鏂规硶
+ if (CollectionUtils.isEmpty(ivrLibaScriptTargetoption.getNodynamiccruxs())) {
+ ivrLibaScriptTargetoption.setNodynamiccruxsJson(null);
+ ivrLibaScriptTargetoptionMapper.updateDynam(ivrLibaScriptTargetoption);
+ }
+ if (CollectionUtils.isEmpty(ivrLibaScriptTargetoption.getDynamiccruxs())) {
+ ivrLibaScriptTargetoption.setDynamiccruxsJson(null);
+ ivrLibaScriptTargetoptionMapper.updateDynam(ivrLibaScriptTargetoption);
+ }
+
+ }
+ if (ivrLibaScriptTargetoption.getIsoperation() != null && ivrLibaScriptTargetoption.getIsoperation() == 3) {
+ //鍒犻櫎
+ if (ivrLibaScriptTargetoption.getId() == null) {
+ log.info("鍒犻櫎澶辫触,闂鎸囨爣閫夐」id涓虹┖");
+ } else {
+ Boolean aBoolean = ivrLibaScriptTargetoptionMapper.deleteIvrLibaScriptTargetoptionByTargetoptionid(ivrLibaScriptTargetoption.getId());
+ log.info("aBoolean鐨勫�间负:{}", aBoolean);
+ }
+ }
+ }
+ }
+
+ //瀵归棶棰樻爣绛捐繘琛屽鐞�
+ if (CollectionUtils.isNotEmpty(ivrLibaScriptVO.getIvrLibaScriptTagList())) {
+ for (IvrLibaScriptTag ivrLibaScriptTag : ivrLibaScriptVO.getIvrLibaScriptTagList()) {
+ if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 1) {
+ //鏂板
+ ivrLibaScriptTag.setScriptid(ivrLibaScript.getId());
+ ivrLibaScriptTagMapper.insertIvrLibaScriptTag(ivrLibaScriptTag);
+ }
+ if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 2) {
+ //淇敼
+ ivrLibaScriptTag.setScriptid(ivrLibaScript.getId());
+ ivrLibaScriptTagMapper.updateIvrLibaScriptTag(ivrLibaScriptTag);
+ }
+ if (ivrLibaScriptTag.getIsoperation() != null && ivrLibaScriptTag.getIsoperation() == 3) {
+ //鍒犻櫎
+ if (ivrLibaScriptTag.getId() == null) {
+ log.info("鍒犻櫎澶辫触,闂鏍囩id涓虹┖");
+ } else {
+ ivrLibaScriptTagMapper.deleteIvrLibaScriptTagById(ivrLibaScriptTag.getId());
+ }
+ }
+ }
+ }
+ return i;
+ }
+
+ /**
+ * 鏂板闂璇濇湳搴�
+ *
+ * @param ivrLibaScript 闂璇濇湳搴�
* @return 缁撴灉
*/
@Override
- public int insertIvrLibaScript(IvrLibaScript ivrLibaScript)
- {
+ public int insertIvrLibaScript(IvrLibaScript ivrLibaScript) {
ivrLibaScript.setCreateTime(DateUtils.getNowDate());
return ivrLibaScriptMapper.insertIvrLibaScript(ivrLibaScript);
}
/**
- * 淇敼璇濇湳搴�
- *
- * @param ivrLibaScript 璇濇湳搴�
+ * 淇敼闂璇濇湳搴�
+ *
+ * @param ivrLibaScript 闂璇濇湳搴�
* @return 缁撴灉
*/
@Override
- public int updateIvrLibaScript(IvrLibaScript ivrLibaScript)
- {
+ public int updateIvrLibaScript(IvrLibaScript ivrLibaScript) {
ivrLibaScript.setUpdateTime(DateUtils.getNowDate());
return ivrLibaScriptMapper.updateIvrLibaScript(ivrLibaScript);
}
/**
- * 鎵归噺鍒犻櫎璇濇湳搴�
- *
- * @param questionids 闇�瑕佸垹闄ょ殑璇濇湳搴撲富閿�
+ * 鎵归噺鍒犻櫎闂璇濇湳搴�
+ *
+ * @param questionids 闇�瑕佸垹闄ょ殑闂璇濇湳搴撲富閿�
* @return 缁撴灉
*/
@Override
- public int deleteIvrLibaScriptByQuestionids(String[] questionids)
- {
- return ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionids(questionids);
+ public int deleteIvrLibaScriptByQuestionids(String[] questionids) {
+ Integer i = null;
+ for (String id : questionids) {
+ i = ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionid(Integer.valueOf(id));
+ }
+ return i;
}
- /**
- * 鍒犻櫎璇濇湳搴撲俊鎭�
- *
- * @param questionid 璇濇湳搴撲富閿�
- * @return 缁撴灉
- */
- @Override
- public int deleteIvrLibaScriptByQuestionid(String questionid)
- {
- return ivrLibaScriptMapper.deleteIvrLibaScriptByQuestionid(questionid);
- }
}
--
Gitblit v1.9.3