fix 81705 车型项目库详情-调取,勾选一页的数据添加,提示操作失败

This commit is contained in:
lijiarao
2024-02-02 20:28:52 +08:00
parent ab86bc2a18
commit 43e1cf2a22
5 changed files with 97 additions and 71 deletions
@@ -88,74 +88,8 @@ public class LawsAssessController extends JeroController<LawsAssess, ILawsAssess
@ApiOperation(value="车型项目库-法规清单-调取", notes="车型项目库-法规清单-调取")
@PostMapping(value = "/retrieval")
public Result<T> retrieval(@Validated @RequestBody LawsAssessAddVo lawsAssessAddVo) {
String projectId = lawsAssessAddVo.getProjectId();
String standardNumbers = lawsAssessAddVo.getStandardNumber();
if (StringUtils.isBlank(standardNumbers)){
throw new JeroBootException(ResultCommon.PLEASE_SELECT_DATA);
}
//查询当前项目已绑定的标准,为了不造成重复绑定
//查询该项目下所有未删除的标准
List<LawsAssess> allByProjectIdNotDeleted = lawsAssessService.getAllByProjectIdNotDeleted(projectId);
List<String> allByProjectIdNotDeletedIdList = allByProjectIdNotDeleted.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
//查询该项目下所有删除的标准
List<LawsAssess> allByProjectIdDeleted = lawsAssessService.getAllByProjectIdDeleted(projectId);
List<String> allByProjectIdDeletedIdList = allByProjectIdDeleted.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
lawsAssessService.retrieval(lawsAssessAddVo);
List<LawsAssess> lawsAssesses = new ArrayList<>();
for (String standardNumber : standardNumbers.split(",")) {
LawsDomesticStandard lawsDomesticStandard = lawsDomesticStandardService.queryByStandardNumber(standardNumber);
if (lawsDomesticStandard != null){
String id = lawsDomesticStandard.getId();
if (allByProjectIdNotDeletedIdList.contains(id)){
//如果已存在跳过新增
continue;
}
if (allByProjectIdDeletedIdList.contains(id)){
//如果已删除则恢复未删除状态
LawsAssess lawsAssess = lawsAssessService.getById(id);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssessService.updateById(lawsAssess);
continue;
}
LawsAssess lawsAssess = new LawsAssess();
lawsAssess.setSource(CommonConstant.STANDARD_SOURCE_1);
lawsAssess.setProjectId(projectId);
lawsAssess.setStandardId(id);
LawsDomesticStandard standard = lawsDomesticStandardService.queryById(id);
lawsAssess.setStandardNumber(standard.getStandardNumber());
lawsAssess.setStandardName(standard.getStandardName());
lawsAssess.setProcessStatus(AssessCommon.NOT_EVALUATED);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssesses.add(lawsAssess);
continue;
}
LawsOverseasStandard lawsOverseasStandard = lawsOverseasStandardService.queryByStandardNumber(standardNumber);
if (lawsOverseasStandard != null){
String id = lawsOverseasStandard.getId();
if (allByProjectIdNotDeletedIdList.contains(id)){
//如果已存在跳过新增
continue;
}
if (allByProjectIdDeletedIdList.contains(id)){
//如果已删除则恢复未删除状态
LawsAssess lawsAssess = lawsAssessService.getById(id);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssessService.updateById(lawsAssess);
continue;
}
LawsAssess lawsAssess = new LawsAssess();
lawsAssess.setSource(CommonConstant.STANDARD_SOURCE_2);
lawsAssess.setProjectId(projectId);
lawsAssess.setStandardId(id);
LawsOverseasStandard standard = lawsOverseasStandardService.queryById(id);
lawsAssess.setStandardNumber(standard.getStandardNumber());
lawsAssess.setStandardName(standard.getStandardName());
lawsAssess.setProcessStatus(AssessCommon.NOT_EVALUATED);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssesses.add(lawsAssess);
}
}
lawsAssessService.saveBatch(lawsAssesses);
return Result.OK("操作成功!");
}
@@ -14,4 +14,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface LawsAssessMapper extends BaseMapper<LawsAssess> {
Integer changeDelFlag(@Param("id") String id);
List<LawsAssess> getAllByProjectIdDeleted(@Param("projectId") String projectId);
}
@@ -22,4 +22,18 @@
<result column="reality_time" property="realityTime" />
<result column="state" property="state" />
</resultMap>
<select id="getAllByProjectIdDeleted" resultMap="LawsAssessResultMap">
select * from laws_assess la
<where>
la.del_flag = 1
and la.project_id = #{projectId}
</where>
</select>
<update id="changeDelFlag">
update laws_assess la
set la.del_flag = 0
where id = #{id}
</update>
</mapper>
@@ -4,6 +4,8 @@ import com.jero.modules.projectLibrary.entity.LawsAssess;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jero.modules.projectLibrary.vo.LawsAssessAddVo;
import java.util.List;
/**
@@ -77,4 +79,6 @@ public interface ILawsAssessService extends IService<LawsAssess> {
List<LawsAssess> getAllByProjectIdDeleted(String projectId);
void assignment(List<LawsAssess> records);
void retrieval(LawsAssessAddVo lawsAssessAddVo);
}
@@ -2,6 +2,7 @@ package com.jero.modules.projectLibrary.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.api.vo.ResultCommon;
import com.jero.common.constant.CommonConstant;
import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.system.vo.DictModel;
@@ -9,10 +10,12 @@ import com.jero.modules.laws.standard.entity.LawsDomesticStandard;
import com.jero.modules.laws.standard.entity.LawsOverseasStandard;
import com.jero.modules.laws.standard.service.ILawsDomesticStandardService;
import com.jero.modules.laws.standard.service.ILawsOverseasStandardService;
import com.jero.modules.projectLibrary.common.AssessCommon;
import com.jero.modules.projectLibrary.entity.LawsAssess;
import com.jero.modules.projectLibrary.mapper.LawsAssessMapper;
import com.jero.modules.projectLibrary.service.ILawsAssessService;
import com.jero.modules.projectLibrary.vo.DecompositionOrderSourceVO;
import com.jero.modules.projectLibrary.vo.LawsAssessAddVo;
import com.jero.modules.split.entity.SarFileSplitInfoEO;
import com.jero.modules.split.service.ISarFileSplitInfoService;
import org.apache.commons.lang3.StringUtils;
@@ -22,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional;
import com.jero.common.exception.JeroBootException;
import java.util.*;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.system.query.QueryGenerator;
@@ -51,6 +55,8 @@ public class LawsAssessServiceImpl extends ServiceImpl<LawsAssessMapper, LawsAss
private ILawsOverseasStandardService lawsOverseasStandardService;
@Resource
private ISysBaseAPI sysBaseAPI;
@Resource
private LawsAssessMapper lawsAssessMapper;
/**
* 分页查询
*
@@ -156,10 +162,7 @@ public class LawsAssessServiceImpl extends ServiceImpl<LawsAssessMapper, LawsAss
if (StringUtils.isBlank(projectId)){
return new ArrayList<>();
}
LambdaQueryWrapper<LawsAssess> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LawsAssess::getProjectId, projectId);
wrapper.eq(LawsAssess::getDelFlag, CommonConstant.DEL_FLAG_1.toString());
return list(wrapper);
return lawsAssessMapper.getAllByProjectIdDeleted(projectId);
}
@Override
@@ -229,4 +232,72 @@ public class LawsAssessServiceImpl extends ServiceImpl<LawsAssessMapper, LawsAss
assess.setDecompositionOrderSourceVOList(mapList);
}
}
@Override
public void retrieval(LawsAssessAddVo lawsAssessAddVo) {
String projectId = lawsAssessAddVo.getProjectId();
String standardNumbers = lawsAssessAddVo.getStandardNumber();
if (StringUtils.isBlank(standardNumbers)){
throw new JeroBootException(ResultCommon.PLEASE_SELECT_DATA);
}
//查询当前项目已绑定的标准,为了不造成重复绑定
//查询该项目下所有未删除的标准
List<LawsAssess> allByProjectIdNotDeleted = this.getAllByProjectIdNotDeleted(projectId);
List<String> allByProjectIdNotDeletedIdList = allByProjectIdNotDeleted.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
//查询该项目下所有删除的标准
List<LawsAssess> allByProjectIdDeleted = this.getAllByProjectIdDeleted(projectId);
List<String> allByProjectIdDeletedIdList = allByProjectIdDeleted.stream().map(LawsAssess::getStandardId).distinct().collect(Collectors.toList());
List<LawsAssess> lawsAssesses = new ArrayList<>();
for (String standardNumber : standardNumbers.split(",")) {
LawsDomesticStandard lawsDomesticStandard = lawsDomesticStandardService.queryByStandardNumber(standardNumber);
if (lawsDomesticStandard != null){
String id = lawsDomesticStandard.getId();
if (allByProjectIdNotDeletedIdList.contains(id)){
//如果已存在跳过新增
continue;
}
if (allByProjectIdDeletedIdList.contains(id)){
//如果已删除则恢复未删除状态
lawsAssessMapper.changeDelFlag(id);
continue;
}
LawsAssess lawsAssess = new LawsAssess();
lawsAssess.setSource(CommonConstant.STANDARD_SOURCE_1);
lawsAssess.setProjectId(projectId);
lawsAssess.setStandardId(id);
LawsDomesticStandard standard = lawsDomesticStandardService.queryById(id);
lawsAssess.setStandardNumber(standard.getStandardNumber());
lawsAssess.setStandardName(standard.getStandardName());
lawsAssess.setProcessStatus(AssessCommon.NOT_EVALUATED);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssesses.add(lawsAssess);
continue;
}
LawsOverseasStandard lawsOverseasStandard = lawsOverseasStandardService.queryByStandardNumber(standardNumber);
if (lawsOverseasStandard != null){
String id = lawsOverseasStandard.getId();
if (allByProjectIdNotDeletedIdList.contains(id)){
//如果已存在跳过新增
continue;
}
if (allByProjectIdDeletedIdList.contains(id)){
//如果已删除则恢复未删除状态
lawsAssessMapper.changeDelFlag(id);
continue;
}
LawsAssess lawsAssess = new LawsAssess();
lawsAssess.setSource(CommonConstant.STANDARD_SOURCE_2);
lawsAssess.setProjectId(projectId);
lawsAssess.setStandardId(id);
LawsOverseasStandard standard = lawsOverseasStandardService.queryById(id);
lawsAssess.setStandardNumber(standard.getStandardNumber());
lawsAssess.setStandardName(standard.getStandardName());
lawsAssess.setProcessStatus(AssessCommon.NOT_EVALUATED);
lawsAssess.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
lawsAssesses.add(lawsAssess);
}
}
this.saveBatch(lawsAssesses);
}
}