liusheng
2024-09-21 d3bf339bd64d7b7efddc0afdd4beb1866b8b5a04
smartor/src/main/java/com/smartor/service/impl/HeLibraryServiceImpl.java
@@ -1,22 +1,20 @@
package com.smartor.service.impl;
import java.util.List;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.DtoConversionUtils;
import com.smartor.domain.HeLibrary;
import com.smartor.domain.HeLibraryTag;
import com.smartor.domain.HeLibraryVO;
import com.smartor.domain.TempDetpRelevance;
import com.smartor.mapper.HeLibraryMapper;
import com.smartor.mapper.HeLibraryTagMapper;
import com.smartor.mapper.TempDetpRelevanceMapper;
import com.smartor.service.IHeLibraryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * 宣教资料库Service业务层处理
@@ -32,9 +30,6 @@
    @Autowired
    private HeLibraryTagMapper heLibraryTagMapper;
    @Autowired
    private TempDetpRelevanceMapper tempDetpRelevanceMapper;
    /**
     * 查询宣教资料库
@@ -103,50 +98,49 @@
     */
    @Override
    public Integer saveOrUpdateScript(HeLibraryVO heLibraryVO) {
        Integer i = null;
        HeLibrary heLibrary = DtoConversionUtils.sourceToTarget(heLibraryVO, HeLibrary.class);
        if (heLibraryVO.getIsoperation() != null && heLibraryVO.getIsoperation() == 1) {
            //新增
            i = heLibraryMapper.insertHeLibrary(heLibrary);
            heLibraryMapper.insertHeLibrary(heLibrary);
        } else if (heLibraryVO.getIsoperation() != null && heLibraryVO.getIsoperation() == 2) {
            //修改
            i = heLibraryMapper.updateHeLibrary(heLibrary);
            heLibraryMapper.updateHeLibrary(heLibrary);
        }
        log.info("新增或修改宣教详情的id为:{}", heLibrary.getId());
//
//        //对标签进行处理
//        for (HeLibraryTag heLibraryTag : heLibraryVO.getHeLibraryTagList()) {
//            if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 1) {
//                //新增
//                heLibraryTag.setHeid(heLibrary.getId());
//                heLibraryTagMapper.insertHeLibraryTag(heLibraryTag);
//            } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 2) {
//                //修改
//                heLibraryTag.setHeid(heLibrary.getId());
//                heLibraryTagMapper.updateHeLibraryTag(heLibraryTag);
//            } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 3) {
//                //删除
//                if (heLibraryTag.getId() == null) {
//                    log.info("删除失败,模板指标id为空");
//                } else {
//                    heLibraryTagMapper.deleteHeLibraryTagById(heLibraryTag.getId());
//                }
//            }
//        }
//
//        //对科室进行处理
//        for (TempDetpRelevance tempDetpRelevance : heLibraryVO.getTempDetpRelevances()) {
//            if (tempDetpRelevance.getId() == null) {
//                //新增
//                tempDetpRelevance.setTempid(heLibrary.getId());
//                tempDetpRelevance.setType(3L);
//                tempDetpRelevanceMapper.insertTempDetpRelevance(tempDetpRelevance);
//            } else {
//                tempDetpRelevanceMapper.updateTempDetpRelevance(tempDetpRelevance);
//            }
//        }
        //对标签进行处理
        for (HeLibraryTag heLibraryTag : heLibraryVO.getHeLibraryTagList()) {
            if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 1) {
                //新增
                heLibraryTag.setHeid(heLibrary.getId());
                heLibraryTagMapper.insertHeLibraryTag(heLibraryTag);
            } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 2) {
                //修改
                heLibraryTag.setHeid(heLibrary.getId());
                heLibraryTagMapper.updateHeLibraryTag(heLibraryTag);
            } else if (heLibraryTag.getIsoperation() != null && heLibraryTag.getIsoperation() == 3) {
                //删除
                if (heLibraryTag.getId() == null) {
                    log.info("删除失败,模板指标id为空");
                } else {
                    heLibraryTagMapper.deleteHeLibraryTagById(heLibraryTag.getId());
                }
            }
        }
        //对科室进行处理
        for (TempDetpRelevance tempDetpRelevance : heLibraryVO.getTempDetpRelevances()) {
            if (tempDetpRelevance.getId() == null) {
                //新增
                tempDetpRelevance.setTempid(heLibrary.getId());
                tempDetpRelevance.setType(3L);
                tempDetpRelevanceMapper.insertTempDetpRelevance(tempDetpRelevance);
            } else {
                tempDetpRelevanceMapper.updateTempDetpRelevance(tempDetpRelevance);
            }
        }
        return i;
        return heLibrary.getId().intValue();
    }
    @Override