| | |
| | | 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 org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.lang.reflect.Array; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 指标选项库Service业务层处理 |
| | |
| | | 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()); |
| | | //获取该指标的选项 |
| | |
| | | @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) { |
| | | //新增 |
| | |
| | | } |
| | | } |
| | | } |
| | | 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())); |
| | |
| | | } |
| | | |
| | | } |
| | | } else if (ivrLibaTargetVO.getValueType() == 2 || ivrLibaTargetVO.getValueType() == 3) { |
| | | } |
| | | |
| | | return ivrLibaTarget.getId().intValue(); |
| | |
| | | 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; |
| | | } |
| | | } |