吉安感知网项目-后端
linwei
2026-01-29 d1081f1c022023253a9ff68c2d60a09422e7179f
数据异议优化
2 files modified
56 ■■■■ changed files
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/mapper/GdDataObjectionMapper.xml 15 ●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdDataObjectionServiceImpl.java 41 ●●●● patch | view | raw | blame | history
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/mapper/GdDataObjectionMapper.xml
@@ -37,11 +37,12 @@
            ja_gd_data_objection do
        left join
                ja_gd_data_objection_attachment da
                on do.id = da.objection_id
                on do.id = da.objection_id and da.is_deleted = 0
        left join
                blade_dept bd on bd.id = do.create_dept
        <where>
                do.is_deleted = 0
                and da.is_deleted = 0
            <if test="param2.title != null and param2.title != ''">
                and do.title like concat('%',#{param2.title},'%')
            </if>
@@ -64,10 +65,16 @@
    </select>
    <select id="getDetail" resultType="org.sxkj.gd.orderdata.vo.GdDataObjectionVO">
        select do.*, GROUP_CONCAT(da.attach_name SEPARATOR ',') as attach_names ,GROUP_CONCAT(da.attach_id SEPARATOR ',') as attach_ids
        from ja_gd_data_objection do
        left join ja_gd_data_objection_attachment da on do.id = da.objection_id
        select
            do.*,
            GROUP_CONCAT(da.attach_name SEPARATOR ',') as attach_names ,
            GROUP_CONCAT(da.attach_id SEPARATOR ',') as attach_ids
        from
            ja_gd_data_objection do
        left join
                ja_gd_data_objection_attachment da on do.id = da.objection_id
        <where>
                and da.is_deleted = 0
            <if test="id != null ">
                and do.id = #{id}
            </if>
drone-service/drone-gd/src/main/java/org/sxkj/gd/orderdata/service/impl/GdDataObjectionServiceImpl.java
@@ -16,27 +16,29 @@
 */
package org.sxkj.gd.orderdata.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.sxkj.gd.orderdata.dto.GdDataObjectionDTO;
import org.sxkj.gd.orderdata.entity.GdDataObjectionAttachmentEntity;
import org.sxkj.gd.orderdata.entity.GdDataObjectionEntity;
import org.sxkj.gd.orderdata.excel.GdDataObjectionExcel;
import org.sxkj.gd.orderdata.mapper.GdDataObjectionMapper;
import org.sxkj.gd.orderdata.param.GdDataObjectionDetailParam;
import org.sxkj.gd.orderdata.param.GdDataObjectionPageParam;
import org.sxkj.gd.orderdata.service.IGdDataObjectionAttachmentService;
import org.sxkj.gd.orderdata.vo.GdDataObjectionVO;
import org.sxkj.gd.orderdata.excel.GdDataObjectionExcel;
import org.sxkj.gd.orderdata.mapper.GdDataObjectionMapper;
import org.sxkj.gd.orderdata.service.IGdDataObjectionService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.sxkj.gd.orderdata.vo.GdDataObjectionVO;
import org.sxkj.gd.orderdata.wrapper.GdDataObjectionWrapper;
import org.sxkj.gd.orderdata.wrapper.GdSupplyDemandAuditAttachmentWrapper;
import org.sxkj.system.cache.SysCache;
import java.util.List;
import java.util.stream.Collectors;
/**
 * 数据异议申请表 服务实现类
@@ -77,11 +79,30 @@
        boolean result = saveOrUpdate(gdDataObjectionEntity);
        if (result) {
            if (gdDataEvaluationDTO.getAttachmentList() != null) {
                List<GdDataObjectionAttachmentEntity> gdDataObjectionAttachmentEntities = GdSupplyDemandAuditAttachmentWrapper.build().entityDTO(gdDataEvaluationDTO.getAttachmentList());
                gdDataObjectionAttachmentEntities.forEach(gdDataObjectionAttachmentEntity -> {
                List<GdDataObjectionAttachmentEntity> entityList = GdSupplyDemandAuditAttachmentWrapper.build().entityDTO(gdDataEvaluationDTO.getAttachmentList());
                List<GdDataObjectionAttachmentEntity> list = gdDataObjectionAttachmentService.list(Wrappers.<GdDataObjectionAttachmentEntity>lambdaQuery()
                    .eq(GdDataObjectionAttachmentEntity::getObjectionId, gdDataObjectionEntity.getId())
                    .eq(GdDataObjectionAttachmentEntity::getIsDeleted, 0));
                // 过滤出list中存在但entityList不包含的数据(根据ID进行比较)
                List<GdDataObjectionAttachmentEntity> toDeleteList = list.stream()
                    .filter(item -> !entityList.stream()
                        .anyMatch(entityItem -> item.getId() != null && entityItem.getId() != null && item.getId().equals(entityItem.getId())))
                    .collect(Collectors.toList());
                // 删除过滤出的数据
                if (!toDeleteList.isEmpty()) {
                    List<Long> idsToDelete = toDeleteList.stream()
                        .map(GdDataObjectionAttachmentEntity::getId)
                        .collect(Collectors.toList());
                    gdDataObjectionAttachmentService.deleteLogic(idsToDelete);
                }
                entityList.forEach(gdDataObjectionAttachmentEntity -> {
                    gdDataObjectionAttachmentEntity.setObjectionId(gdDataObjectionEntity.getId());
                });
                return gdDataObjectionAttachmentService.saveOrUpdateBatch(gdDataObjectionAttachmentEntities);
                return gdDataObjectionAttachmentService.saveOrUpdateBatch(entityList);
            }
            return true;
        }