From fdf1b9c1e4489a0c2615fa596268b2f71fad7b4c Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 15 四月 2024 09:08:10 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java | 213 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 166 insertions(+), 47 deletions(-)
diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java
index 533c031..50b52cf 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java
@@ -1,96 +1,215 @@
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.utils.DateUtils;
+import com.ruoyi.common.utils.DtoConversionUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.smartor.domain.*;
+import com.smartor.mapper.IvrLibaTargetMapper;
+import com.smartor.mapper.IvrLibaTargetTagMapper;
+import com.smartor.mapper.IvrLibaTargetoptionMapper;
+import com.smartor.service.IIvrLibaTargetService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import com.smartor.mapper.IvrLibaTargetMapper;
-import com.smartor.domain.IvrLibaTarget;
-import com.smartor.service.IIvrLibaTargetService;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
/**
- * 鎸囨爣搴揝ervice涓氬姟灞傚鐞�
- *
- * @author smartor
- * @date 2023-03-22
+ * 鎸囨爣閫夐」搴揝ervice涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2023-12-14
*/
+@Slf4j
@Service
-public class IvrLibaTargetServiceImpl implements IIvrLibaTargetService
-{
+public class IvrLibaTargetServiceImpl implements IIvrLibaTargetService {
@Autowired
private IvrLibaTargetMapper ivrLibaTargetMapper;
+ @Autowired
+ private IvrLibaTargetTagMapper ivrLibaTargetTagMapper;
+
+ @Autowired
+ private IvrLibaTargetoptionMapper ivrLibaTargetoptionMapper;
+
/**
- * 鏌ヨ鎸囨爣搴�
- *
- * @param targetID 鎸囨爣搴撲富閿�
- * @return 鎸囨爣搴�
+ * 鏌ヨ鎸囨爣閫夐」搴�
+ *
+ * @param id 鎸囨爣閫夐」搴撲富閿�
+ * @return 鎸囨爣閫夐」搴�
*/
@Override
- public IvrLibaTarget selectIvrLibaTargetByTargetID(String targetID)
- {
- return ivrLibaTargetMapper.selectIvrLibaTargetByTargetID(targetID);
+ public IvrLibaTarget selectIvrLibaTargetByTargetID(Long id) {
+ return ivrLibaTargetMapper.selectIvrLibaTargetByTargetID(id);
}
/**
- * 鏌ヨ鎸囨爣搴撳垪琛�
- *
- * @param ivrLibaTarget 鎸囨爣搴�
- * @return 鎸囨爣搴�
+ * 鏌ヨ鎸囨爣閫夐」搴撳垪琛�
+ *
+ * @param ivrLibaTarget 鎸囨爣閫夐」搴�
+ * @return 鎸囨爣閫夐」搴�
*/
@Override
- public List<IvrLibaTarget> selectIvrLibaTargetList(IvrLibaTarget ivrLibaTarget)
- {
+ public List<IvrLibaTarget> selectIvrLibaTargetList(IvrLibaTarget ivrLibaTarget) {
return ivrLibaTargetMapper.selectIvrLibaTargetList(ivrLibaTarget);
}
+ @Override
+ public List<IvrLibaTargetVO> targetInfo(IvrLibaTarget ivrLibaTarget) {
+ List<IvrLibaTarget> ivrLibaTargets = ivrLibaTargetMapper.selectIvrLibaTargetList(ivrLibaTarget);
+ List<IvrLibaTargetVO> ivrLibaTargetVOS = DtoConversionUtils.sourceToTarget(ivrLibaTargets, IvrLibaTargetVO.class);
+ for (IvrLibaTargetVO ivrLibaTarget1 : ivrLibaTargetVOS) {
+ IvrLibaTargetoption ivrLibaTargetoption = new IvrLibaTargetoption();
+ ivrLibaTargetoption.setTargetid(ivrLibaTarget1.getId());
+ //鑾峰彇璇ユ寚鏍囩殑閫夐」
+ List<IvrLibaTargetoption> ivrLibaTargetoptions = ivrLibaTargetoptionMapper.selectIvrLibaTargetoptionList(ivrLibaTargetoption);
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetoptions)) {
+ for (IvrLibaTargetoption ivrLibaTargetoption1 : ivrLibaTargetoptions) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ try {
+ if (StringUtils.isNotEmpty(ivrLibaTargetoption1.getDynamiccruxsJson()))
+ ivrLibaTargetoption1.setDynamiccruxs(objectMapper.readValue(ivrLibaTargetoption1.getDynamiccruxsJson(), List.class));
+ if (StringUtils.isNotEmpty(ivrLibaTargetoption1.getNodynamiccruxsJson()))
+ ivrLibaTargetoption1.setNodynamiccruxs(objectMapper.readValue(ivrLibaTargetoption1.getNodynamiccruxsJson(), List.class));
+ } catch (JsonProcessingException e) {
+ e.printStackTrace();
+ }
+ }
+ ivrLibaTarget1.setTargetoptionList(ivrLibaTargetoptions);
+ }
+ //鑾峰彇璇ユ寚鏍囩殑鏍囩
+ List<BaseTag> baseTags = ivrLibaTargetTagMapper.selectTagName(ivrLibaTarget1.getId());
+ ivrLibaTarget1.setBaseTagList(baseTags);
+ }
+ //涓嬮潰鐢ㄥ乏澶栨劅瑙夋湁鐐归棶棰橈紝where涓殑option鐨刣el浼氬鑷村乏杈圭殑鏌ヨ涓嶅叏锛屽厛涓嶇敤鍚�
+// ivrLibaTargetMapper.targetInfo(ivrLibaTarget)
+ return ivrLibaTargetVOS;
+ }
+
/**
- * 鏂板鎸囨爣搴�
- *
- * @param ivrLibaTarget 鎸囨爣搴�
+ * 鏂板鎸囨爣閫夐」搴�
+ *
+ * @param ivrLibaTargetVO 鎸囨爣閫夐」搴�
* @return 缁撴灉
*/
@Override
- public int insertIvrLibaTarget(IvrLibaTarget ivrLibaTarget)
- {
+ @Transactional(rollbackFor = Exception.class)
+ public int insertIvrLibaTarget(IvrLibaTargetVO ivrLibaTargetVO) {
+ //鏂板鎸囨爣淇℃伅
+ IvrLibaTarget ivrLibaTarget = DtoConversionUtils.sourceToTarget(ivrLibaTargetVO, IvrLibaTarget.class);
ivrLibaTarget.setCreateTime(DateUtils.getNowDate());
- return ivrLibaTargetMapper.insertIvrLibaTarget(ivrLibaTarget);
+ ivrLibaTargetMapper.insertIvrLibaTarget(ivrLibaTarget);
+
+ //鏂板璇ユ寚鏍囧搴旂殑鏍囩淇℃伅
+ for (BaseTag baseTag : ivrLibaTargetVO.getBaseTagList()) {
+ IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
+ ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
+ //鍓嶇浼犳潵鐨刡aseTag鐨則agid灏辨槸鎸囨爣鏍囩鐨勪富閿甶d,涓嶆槸baseTag鐨勪富閿�
+ ivrLibaTargetTag.setTagid(baseTag.getTagid());
+ ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
+ }
+
+ //鏂板璇ユ寚鏍囧搴旂殑鎸囨爣閫夐」淇℃伅
+ for (IvrLibaTargetoption targetoption : ivrLibaTargetVO.getTargetoptionList()) {
+ if (ObjectUtils.isEmpty(targetoption)) continue;
+ log.info("targetoption鐨勬暟鎹负锛歿}", targetoption);
+ targetoption.setTargetid(ivrLibaTarget.getId());
+ ivrLibaTargetoptionMapper.insertIvrLibaTargetoption(targetoption);
+ }
+
+ log.info("鎸囨爣id涓猴細{}", ivrLibaTarget.getId().intValue());
+ return ivrLibaTarget.getId().intValue();
}
/**
- * 淇敼鎸囨爣搴�
- *
- * @param ivrLibaTarget 鎸囨爣搴�
+ * 鏂板鎴栦慨鏀规寚鏍囬�夐」搴�
+ *
+ * @param ivrLibaTargetVO 鎸囨爣閫夐」搴�
* @return 缁撴灉
*/
@Override
- public int updateIvrLibaTarget(IvrLibaTarget ivrLibaTarget)
- {
+ @Transactional(rollbackFor = Exception.class)
+ public int saveOrupdateIvrLibaTarget(IvrLibaTargetVO ivrLibaTargetVO) {
+ IvrLibaTarget ivrLibaTarget = DtoConversionUtils.sourceToTarget(ivrLibaTargetVO, IvrLibaTarget.class);
ivrLibaTarget.setUpdateTime(DateUtils.getNowDate());
- return ivrLibaTargetMapper.updateIvrLibaTarget(ivrLibaTarget);
+ if (ivrLibaTargetVO.getIsoperation() != null && ivrLibaTargetVO.getIsoperation() == 1) {
+ //鏂板
+ ivrLibaTargetMapper.insertIvrLibaTarget(ivrLibaTarget);
+ } else if (ivrLibaTargetVO.getIsoperation() != null && ivrLibaTargetVO.getIsoperation() == 2) {
+ //淇敼
+ ivrLibaTargetMapper.updateIvrLibaTarget(ivrLibaTarget);
+ }
+
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getBaseTagList())) {
+ for (BaseTag baseTag : ivrLibaTargetVO.getBaseTagList()) {
+ if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 1) {
+ //鏂板
+ IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
+ ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
+ //鍓嶇浼犳潵鐨刡aseTag鐨則agid灏辨槸鎸囨爣鏍囩鐨勪富閿甶d,涓嶆槸baseTag鐨勪富閿�
+ ivrLibaTargetTag.setTagid(baseTag.getTagid());
+ ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
+ } else if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 2) {
+ //鍓嶇椤甸潰搴旇娌℃湁淇敼
+ } else if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 3) {
+ //鍒犻櫎
+ ivrLibaTargetTagMapper.deleteIvrLibaTargetTagById(baseTag.getTagid());
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getTargetoptionList())) {
+ for (IvrLibaTargetoption ivrLibaTargetoption : ivrLibaTargetVO.getTargetoptionList()) {
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetoption.getNodynamiccruxs())) {
+ ivrLibaTargetoption.setNodynamiccruxsJson(new Gson().toJson(ivrLibaTargetoption.getNodynamiccruxs()));
+ }
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetoption.getDynamiccruxs())) {
+ ivrLibaTargetoption.setDynamiccruxsJson(new Gson().toJson(ivrLibaTargetoption.getDynamiccruxs()));
+ }
+
+ if (ivrLibaTargetoption.getIsoperation() != null && ivrLibaTargetoption.getIsoperation() == 1) {
+ //鏂板
+ ivrLibaTargetoption.setTargetid(ivrLibaTarget.getId());
+ ivrLibaTargetoptionMapper.insertIvrLibaTargetoption(ivrLibaTargetoption);
+ } else if (ivrLibaTargetoption.getIsoperation() != null && ivrLibaTargetoption.getIsoperation() == 2) {
+ //淇敼
+ ivrLibaTargetoptionMapper.updateIvrLibaTargetoption(ivrLibaTargetoption);
+ } else if (ivrLibaTargetoption.getIsoperation() != null && ivrLibaTargetoption.getIsoperation() == 3) {
+ // 鍒犻櫎
+ ivrLibaTargetoptionMapper.deleteIvrLibaTargetoptionByTargetoptionid(ivrLibaTargetoption.getTargetoptionid());
+ }
+
+ }
+ }
+
+ return ivrLibaTarget.getId().intValue();
}
+
/**
- * 鎵归噺鍒犻櫎鎸囨爣搴�
- *
- * @param targetIDs 闇�瑕佸垹闄ょ殑鎸囨爣搴撲富閿�
+ * 鎵归噺鍒犻櫎鎸囨爣閫夐」搴�
+ *
* @return 缁撴灉
*/
@Override
- public int deleteIvrLibaTargetByTargetIDs(String[] targetIDs)
- {
- return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetIDs(targetIDs);
+ public int deleteIvrLibaTargetByTargetIDs(Long[] ids) {
+ return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetIDs(ids);
}
/**
- * 鍒犻櫎鎸囨爣搴撲俊鎭�
- *
- * @param targetID 鎸囨爣搴撲富閿�
+ * 鍒犻櫎鎸囨爣閫夐」搴撲俊鎭�
+ *
* @return 缁撴灉
*/
@Override
- public int deleteIvrLibaTargetByTargetID(String targetID)
- {
- return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetID(targetID);
+ public int deleteIvrLibaTargetByTargetID(Long id) {
+ return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetID(id);
}
}
--
Gitblit v1.9.3