From 907641e56c2085aaa81f267946dc3e3e9fca73e7 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 18 九月 2024 09:39:02 +0800
Subject: [PATCH] 代码提交
---
smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java | 262 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 215 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..ce0f95e 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,264 @@
package com.smartor.service.impl;
-import java.util.List;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+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.lang.reflect.Array;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
/**
- * 鎸囨爣搴揝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) {
+ ivrLibaTarget1.setSuitWayList(JSONArray.parseArray(ivrLibaTarget1.getSuitWay(), String.class));
+
+ 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);
+ }
+ //鑾峰彇璇ユ寚鏍囩殑鏍囩
+ IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget1.getId());
+ List<IvrLibaTargetTag> ivrLibaTargetTags = ivrLibaTargetTagMapper.selectIvrLibaTargetTagList(ivrLibaTargetTag);
+
+ ivrLibaTarget1.setIvrLibaTargetTagList(ivrLibaTargetTags);
+ }
+ //鍒ゆ柇鍏ュ弬鏉′欢涓紝tagName鏄惁鏈夊�硷紝濡傛灉鏈夊�硷紝鍒欓渶瑕佹牴鎹粰鐨勫�艰繘琛屾爣绛捐繃婊�
+ if (StringUtils.isNotEmpty(ivrLibaTarget.getTagName())) {
+ List<IvrLibaTargetVO> ivrLibaTargetVOList = new ArrayList<>();
+ aa:
+ for (IvrLibaTargetVO ivrLibaTarget1 : ivrLibaTargetVOS) {
+ for (IvrLibaTargetTag ivrLibaTargetTag1 : ivrLibaTarget1.getIvrLibaTargetTagList()) {
+ if (ivrLibaTargetTag1.getTagname().contains(ivrLibaTarget.getTagName().trim())) {
+ ivrLibaTargetVOList.add(ivrLibaTarget1);
+ continue aa;
+ }
+ }
+ }
+ ivrLibaTargetVOS = ivrLibaTargetVOList;
+ }
+ //涓嬮潰鐢ㄥ乏澶栨劅瑙夋湁鐐归棶棰橈紝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 (IvrLibaTargetTag ivrLibaTargetTag : ivrLibaTargetVO.getIvrLibaTargetTagList()) {
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
+ 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);
+ if (ObjectUtils.isNotEmpty(ivrLibaTargetVO.getSuitWayList()))
+ ivrLibaTarget.setSuitWay(JSON.toJSONString(ivrLibaTargetVO.getSuitWayList()));
ivrLibaTarget.setUpdateTime(DateUtils.getNowDate());
- return ivrLibaTargetMapper.updateIvrLibaTarget(ivrLibaTarget);
+ if (ivrLibaTargetVO.getIsoperation() != null && ivrLibaTargetVO.getIsoperation() == 1) {
+ //鏂板
+ ivrLibaTarget.setCreateTime(new Date());
+ ivrLibaTarget.setUpdateTime(new Date());
+ ivrLibaTargetMapper.insertIvrLibaTarget(ivrLibaTarget);
+ } else if (ivrLibaTargetVO.getIsoperation() != null && ivrLibaTargetVO.getIsoperation() == 2) {
+ //淇敼
+ ivrLibaTarget.setUpdateTime(new Date());
+ ivrLibaTargetMapper.updateIvrLibaTarget(ivrLibaTarget);
+ }
+
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getIvrLibaTargetTagList())) {
+ for (IvrLibaTargetTag ivrLibaTargetTag : ivrLibaTargetVO.getIvrLibaTargetTagList()) {
+ if (ivrLibaTargetTag.getId() == null) {
+ //鏂板
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
+ ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
+ } else if (ivrLibaTargetTag.getId() != null) {
+ //鍓嶇椤甸潰搴旇娌℃湁淇敼
+ ivrLibaTargetTagMapper.updateIvrLibaTargetTag(ivrLibaTargetTag);
+ }
+ }
+ }
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getTargetoptionList()) && ivrLibaTargetVO.getValueType() == 1) {
+ //閫夐」澶勭悊
+ 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());
+ }
+
+ }
+ } else if (ivrLibaTargetVO.getValueType() == 2 || ivrLibaTargetVO.getValueType() == 3) {
+ }
+
+ 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);
+ }
+
+ /**
+ * 鎸囨爣娴嬭瘯闂鍖归厤
+ */
+ @Override
+ public String targetQuesMate(IvrLibaTargetVO ivrLibaTargetVO) {
+
+ for (IvrLibaTargetoption ivrLibaTargetoption : ivrLibaTargetVO.getTargetoptionList()) {
+
+ Matcher matcher = null;
+ if (StringUtils.isNotEmpty(ivrLibaTargetoption.getTargetregex())) {
+ Pattern pattern = Pattern.compile(ivrLibaTargetoption.getTargetregex());
+ matcher = pattern.matcher(ivrLibaTargetVO.getContent());
+ }
+ //涓嶅寘鍚�
+ Matcher matcher2 = null;
+ if (StringUtils.isNotEmpty(ivrLibaTargetoption.getTargetregex2())) {
+ Pattern pattern2 = Pattern.compile(ivrLibaTargetoption.getTargetregex2());
+ matcher2 = pattern2.matcher(ivrLibaTargetVO.getContent());
+ }
+ if (StringUtils.isNotEmpty(ivrLibaTargetoption.getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrLibaTargetoption.getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrLibaTargetoption.getTargetregex2()) && StringUtils.isNotEmpty(ivrLibaTargetoption.getTargetregex()) && matcher.matches()) {
+ return ivrLibaTargetoption.getTargetvalue();
+ }
+
+ }
+ return null;
}
}
--
Gitblit v1.9.3