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 | 143 +++++++++++++++++++++++++++++++++++------------
1 files changed, 106 insertions(+), 37 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 53548bc..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,7 +1,13 @@
package com.smartor.service.impl;
+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;
@@ -14,7 +20,11 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
-import java.util.List;
+import java.lang.reflect.Array;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
/**
* 鎸囨爣閫夐」搴揝ervice涓氬姟灞傚鐞�
@@ -37,12 +47,12 @@
/**
* 鏌ヨ鎸囨爣閫夐」搴�
*
- * @param targetID 鎸囨爣閫夐」搴撲富閿�
+ * @param id 鎸囨爣閫夐」搴撲富閿�
* @return 鎸囨爣閫夐」搴�
*/
@Override
- public IvrLibaTarget selectIvrLibaTargetByTargetID(Long targetID) {
- return ivrLibaTargetMapper.selectIvrLibaTargetByTargetID(targetID);
+ public IvrLibaTarget selectIvrLibaTargetByTargetID(Long id) {
+ return ivrLibaTargetMapper.selectIvrLibaTargetByTargetID(id);
}
/**
@@ -61,16 +71,46 @@
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.getTargetID());
+ 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.getTargetID());
- ivrLibaTarget1.setBaseTagList(baseTags);
+ 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)
@@ -92,12 +132,8 @@
ivrLibaTargetMapper.insertIvrLibaTarget(ivrLibaTarget);
//鏂板璇ユ寚鏍囧搴旂殑鏍囩淇℃伅
- for (BaseTag baseTag : ivrLibaTargetVO.getBaseTagList()) {
- IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
- ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
- ivrLibaTargetTag.setTargetid(ivrLibaTarget.getTargetID());
- //鍓嶇浼犳潵鐨刡aseTag鐨則agid灏辨槸鎸囨爣鏍囩鐨勪富閿甶d,涓嶆槸baseTag鐨勪富閿�
- ivrLibaTargetTag.setTagid(baseTag.getTagid());
+ for (IvrLibaTargetTag ivrLibaTargetTag : ivrLibaTargetVO.getIvrLibaTargetTagList()) {
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
}
@@ -105,12 +141,12 @@
for (IvrLibaTargetoption targetoption : ivrLibaTargetVO.getTargetoptionList()) {
if (ObjectUtils.isEmpty(targetoption)) continue;
log.info("targetoption鐨勬暟鎹负锛歿}", targetoption);
- targetoption.setTargetid(ivrLibaTarget.getTargetID());
+ targetoption.setTargetid(ivrLibaTarget.getId());
ivrLibaTargetoptionMapper.insertIvrLibaTargetoption(targetoption);
}
- log.info("鎸囨爣id涓猴細{}", ivrLibaTarget.getTargetID().intValue());
- return ivrLibaTarget.getTargetID().intValue();
+ log.info("鎸囨爣id涓猴細{}", ivrLibaTarget.getId().intValue());
+ return ivrLibaTarget.getId().intValue();
}
/**
@@ -123,38 +159,45 @@
@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());
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.getBaseTagList())) {
- for (BaseTag baseTag : ivrLibaTargetVO.getBaseTagList()) {
- if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 1) {
+ if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getIvrLibaTargetTagList())) {
+ for (IvrLibaTargetTag ivrLibaTargetTag : ivrLibaTargetVO.getIvrLibaTargetTagList()) {
+ if (ivrLibaTargetTag.getId() == null) {
//鏂板
- IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
- ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
- ivrLibaTargetTag.setTargetid(ivrLibaTarget.getTargetID());
- //鍓嶇浼犳潵鐨刡aseTag鐨則agid灏辨槸鎸囨爣鏍囩鐨勪富閿甶d,涓嶆槸baseTag鐨勪富閿�
- ivrLibaTargetTag.setTagid(baseTag.getTagid());
+ ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
- } else if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 2) {
+ } else if (ivrLibaTargetTag.getId() != null) {
//鍓嶇椤甸潰搴旇娌℃湁淇敼
- } else if (baseTag.getIsoperation() != null && baseTag.getIsoperation() == 3) {
- //鍒犻櫎
- ivrLibaTargetTagMapper.deleteIvrLibaTargetTagById(baseTag.getTagid());
+ ivrLibaTargetTagMapper.updateIvrLibaTargetTag(ivrLibaTargetTag);
}
}
}
- if (CollectionUtils.isNotEmpty(ivrLibaTargetVO.getTargetoptionList())) {
+ 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.getTargetID());
+ ivrLibaTargetoption.setTargetid(ivrLibaTarget.getId());
ivrLibaTargetoptionMapper.insertIvrLibaTargetoption(ivrLibaTargetoption);
} else if (ivrLibaTargetoption.getIsoperation() != null && ivrLibaTargetoption.getIsoperation() == 2) {
//淇敼
@@ -165,31 +208,57 @@
}
}
+ } else if (ivrLibaTargetVO.getValueType() == 2 || ivrLibaTargetVO.getValueType() == 3) {
}
- return ivrLibaTarget.getTargetID().intValue();
+ return ivrLibaTarget.getId().intValue();
}
/**
* 鎵归噺鍒犻櫎鎸囨爣閫夐」搴�
*
- * @param targetIDs 闇�瑕佸垹闄ょ殑鎸囨爣閫夐」搴撲富閿�
* @return 缁撴灉
*/
@Override
- public int deleteIvrLibaTargetByTargetIDs(Long[] targetIDs) {
- return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetIDs(targetIDs);
+ public int deleteIvrLibaTargetByTargetIDs(Long[] ids) {
+ return ivrLibaTargetMapper.deleteIvrLibaTargetByTargetIDs(ids);
}
/**
* 鍒犻櫎鎸囨爣閫夐」搴撲俊鎭�
*
- * @param targetID 鎸囨爣閫夐」搴撲富閿�
* @return 缁撴灉
*/
@Override
- public int deleteIvrLibaTargetByTargetID(Long 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