法规清单--添加验重

This commit is contained in:
zhn
2022-04-27 10:08:39 +08:00
parent 7828cc8782
commit bb459ed077
2 changed files with 40 additions and 3 deletions
@@ -9,6 +9,8 @@ import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import com.jero.common.api.vo.Result;
import com.jero.common.system.query.QueryGenerator;
import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.service.IProjectLawsInventoryEOService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -38,6 +40,8 @@ import com.jero.common.aspect.annotation.AutoLog;
public class ProjectLawsInventoryEOController extends JeroController<ProjectLawsInventoryEO, IProjectLawsInventoryEOService> {
@Autowired
private IProjectLawsInventoryEOService projectLawsInventoryEOService;
@Autowired
private IBussDocumentLibraryEOService bussDocumentLibraryEOService;
/**
* 分页列表查询
@@ -208,9 +212,7 @@ public class ProjectLawsInventoryEOController extends JeroController<ProjectLaws
/**
* 通过id查询
* @param id
* @param cut
* @param operatorType
* @param params
* @return
*/
@AutoLog(value = "项目库-法规清单表-通过id与操作类型查询")
@@ -221,4 +223,15 @@ public class ProjectLawsInventoryEOController extends JeroController<ProjectLaws
return Result.OK(result);
}
@AutoLog(value = "法规清单添加调用文档库数据--分页")
@ApiOperation(value="法规清单添加调用文档库数据--分页", notes="法规清单添加调用文档库数据--分页")
@PostMapping(value = "/queryPageInfoBussDocument")
public Result<?> queryPageInfo(@RequestBody BussDocumentLibraryEO bussDocumentLibraryEO,
HttpServletRequest req) {
QueryWrapper<BussDocumentLibraryEO> queryWrapper = QueryGenerator.initQueryWrapper(bussDocumentLibraryEO, req.getParameterMap());
Page<BussDocumentLibraryEO> page = new Page<BussDocumentLibraryEO>(bussDocumentLibraryEO.getPageNo(), bussDocumentLibraryEO.getPageSize());
IPage<BussDocumentLibraryEO> pageList = bussDocumentLibraryEOService.queryPageInfoDummy(page, queryWrapper,bussDocumentLibraryEO);
return Result.OK(pageList);
}
}
@@ -101,9 +101,33 @@ public class ProjectLawsInventoryEOServiceImpl extends ServiceImpl<ProjectLawsIn
if(StringUtils.isEmpty(ids)){
throw new JeroBootException("文档库id不能为空,请检查!");
}
//验重,对于每条法规清单添加文档库数据(之前添加过的就不能再次添加)
//1.已经添加过的文档库数据
LambdaQueryWrapper<ProjectLawsInventoryEO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(ProjectLawsInventoryEO::getProjectLibraryId,Arrays.asList(projectLawsInventoryEO.getProjectLibraryId().split(",")));
List<ProjectLawsInventoryEO> projectLawsInventoryEOS = this.list(lambdaQueryWrapper);
List<String> serialNumberList = new ArrayList<>();
if(projectLawsInventoryEOS.size() != 0){
List<String> collect = projectLawsInventoryEOS.stream().map(ProjectLawsInventoryEO::getSerialNumber).collect(Collectors.toList());
serialNumberList.addAll(collect);
}
//2.文档库数据
LambdaQueryWrapper<BussDocumentLibraryEO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(BussDocumentLibraryEO::getId, Arrays.asList(ids.split(",")));
List<BussDocumentLibraryEO> bussDocumentLibraryEOList = iBussDocumentLibraryEOService.list(wrapper);
if(bussDocumentLibraryEOList.size() != 0){
List<String> serialNumberBussList = bussDocumentLibraryEOList.stream().map(BussDocumentLibraryEO::getSerialNumber).collect(Collectors.toList());
if(serialNumberList.size() != 0){
List<String> collect = serialNumberList.stream().filter(e -> serialNumberBussList.contains(e)).collect(Collectors.toList());
if(collect.size() != 0){
if(CutEnum.CN.getValue().equals(projectLawsInventoryEO.getCut())){
throw new JeroBootException(org.apache.commons.lang3.StringUtils.join(collect,",") + "已存在不能重复添加,请重新选择");
}else{
throw new JeroBootException(org.apache.commons.lang3.StringUtils.join(collect,",") + "Already exists and cannot be added again");
}
}
}
}
List<ProjectLawsInventoryEO> list = new ArrayList<>();
for (BussDocumentLibraryEO bussDocumentLibraryEO : bussDocumentLibraryEOList) {