liusheng
2024-04-19 111c93ba533e13d9b47660c1e68ab1f9a23cfb68
smartor/src/main/java/com/smartor/service/impl/IvrLibaTargetServiceImpl.java
@@ -1,7 +1,11 @@
package com.smartor.service.impl;
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;
@@ -37,12 +41,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);
    }
    /**
@@ -62,14 +66,25 @@
        List<IvrLibaTargetVO> ivrLibaTargetVOS = DtoConversionUtils.sourceToTarget(ivrLibaTargets, IvrLibaTargetVO.class);
        for (IvrLibaTargetVO ivrLibaTarget1 : ivrLibaTargetVOS) {
            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());
            List<BaseTag> baseTags = ivrLibaTargetTagMapper.selectTagName(ivrLibaTarget1.getId());
            ivrLibaTarget1.setBaseTagList(baseTags);
        }
        //下面用左外感觉有点问题,where中的option的del会导致左边的查询不全,先不用吧
@@ -95,7 +110,7 @@
        for (BaseTag baseTag : ivrLibaTargetVO.getBaseTagList()) {
            IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
            ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
            ivrLibaTargetTag.setTargetid(ivrLibaTarget.getTargetID());
            ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
            //前端传来的baseTag的tagid就是指标标签的主键id,不是baseTag的主键
            ivrLibaTargetTag.setTagid(baseTag.getTagid());
            ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
@@ -105,12 +120,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();
    }
    /**
@@ -138,7 +153,7 @@
                    //新增
                    IvrLibaTargetTag ivrLibaTargetTag = new IvrLibaTargetTag();
                    ivrLibaTargetTag.setTagcategoryid(baseTag.getTagcategoryid());
                    ivrLibaTargetTag.setTargetid(ivrLibaTarget.getTargetID());
                    ivrLibaTargetTag.setTargetid(ivrLibaTarget.getId());
                    //前端传来的baseTag的tagid就是指标标签的主键id,不是baseTag的主键
                    ivrLibaTargetTag.setTagid(baseTag.getTagid());
                    ivrLibaTargetTagMapper.insertIvrLibaTargetTag(ivrLibaTargetTag);
@@ -152,9 +167,16 @@
        }
        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.getTargetID());
                    ivrLibaTargetoption.setTargetid(ivrLibaTarget.getId());
                    ivrLibaTargetoptionMapper.insertIvrLibaTargetoption(ivrLibaTargetoption);
                } else if (ivrLibaTargetoption.getIsoperation() != null && ivrLibaTargetoption.getIsoperation() == 2) {
                    //修改
@@ -167,29 +189,27 @@
            }
        }
        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);
    }
}