调取后保存数据
This commit is contained in:
+17
@@ -236,4 +236,21 @@ public class ProjectRxswinEOController extends JeroController<ProjectRxswinEO, I
|
|||||||
return Result.OK(iSExist);
|
return Result.OK(iSExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param projectId
|
||||||
|
* @param ids
|
||||||
|
* @param flag flag-->YES覆盖, flag-->NO不覆盖
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "调取后保存数据")
|
||||||
|
@ApiOperation(value="调取后保存数据", notes="调取后保存数据")
|
||||||
|
@GetMapping(value = "/addBatch")
|
||||||
|
public Result<?> addBatch(@RequestParam(name="projectId",required=true) String projectId,
|
||||||
|
@RequestParam(name="ids",required=true) String ids,
|
||||||
|
@RequestParam(name="flag",required=true) String flag) {
|
||||||
|
projectRxswinEOService.addBatch(projectId, ids,flag);
|
||||||
|
return Result.OK("");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
@@ -6,6 +6,8 @@ package com.jero.modules.project.enums;
|
|||||||
public enum StatusEnum {
|
public enum StatusEnum {
|
||||||
SAVE("保存","0"),
|
SAVE("保存","0"),
|
||||||
SUBMIT("提交","1"),
|
SUBMIT("提交","1"),
|
||||||
|
COVER_YES("覆盖","YES"),
|
||||||
|
COVER_NO("不覆盖","NO"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
@@ -92,4 +92,7 @@ public interface IProjectRxswinEOService extends IService<ProjectRxswinEO> {
|
|||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
String iSExist(String projectId,String ids);
|
String iSExist(String projectId,String ids);
|
||||||
|
|
||||||
|
|
||||||
|
void addBatch(String projectId,String ids,String flag);
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-9
@@ -208,19 +208,18 @@ public class ProjectRxswinEOServiceImpl extends ServiceImpl<ProjectRxswinEOMappe
|
|||||||
List<ProjectRxswinEO> projectRxswinEOS = rxswinEOList.stream().filter(e -> themeList.contains(e.getTheme())).collect(Collectors.toList());
|
List<ProjectRxswinEO> projectRxswinEOS = rxswinEOList.stream().filter(e -> themeList.contains(e.getTheme())).collect(Collectors.toList());
|
||||||
if(projectRxswinEOS.isEmpty()){
|
if(projectRxswinEOS.isEmpty()){
|
||||||
//直接新增
|
//直接新增
|
||||||
for (ProjectRxswinEO projectRxswinEO : rxswinEOList) {
|
saveBatchInfo(projectId, user, rxswinEOList);
|
||||||
projectRxswinEO.setId(UUID.randomUUID().toString().replaceAll("-",""));
|
|
||||||
projectRxswinEO.setProjectId(projectId);
|
|
||||||
projectRxswinEO.setCreateTime(new Date());
|
|
||||||
projectRxswinEO.setCreateBy(user.getUsername());
|
|
||||||
projectRxswinEO.setState(StatusEnum.SAVE.getValue());
|
|
||||||
}
|
|
||||||
this.saveBatch(rxswinEOList);
|
|
||||||
}else{
|
}else{
|
||||||
return "YES";
|
return "YES";
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
//直接新增
|
//直接新增
|
||||||
|
saveBatchInfo(projectId, user, rxswinEOList);
|
||||||
|
}
|
||||||
|
return "NO";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveBatchInfo(String projectId, LoginUser user, List<ProjectRxswinEO> rxswinEOList) {
|
||||||
for (ProjectRxswinEO projectRxswinEO : rxswinEOList) {
|
for (ProjectRxswinEO projectRxswinEO : rxswinEOList) {
|
||||||
projectRxswinEO.setId(UUID.randomUUID().toString().replaceAll("-",""));
|
projectRxswinEO.setId(UUID.randomUUID().toString().replaceAll("-",""));
|
||||||
projectRxswinEO.setProjectId(projectId);
|
projectRxswinEO.setProjectId(projectId);
|
||||||
@@ -230,6 +229,53 @@ public class ProjectRxswinEOServiceImpl extends ServiceImpl<ProjectRxswinEOMappe
|
|||||||
}
|
}
|
||||||
this.saveBatch(rxswinEOList);
|
this.saveBatch(rxswinEOList);
|
||||||
}
|
}
|
||||||
return "NO";
|
|
||||||
|
/**
|
||||||
|
* 调取后保存数据
|
||||||
|
* @param projectId
|
||||||
|
* @param ids
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addBatch(String projectId, String ids,String flag) {
|
||||||
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
|
||||||
|
//新增的
|
||||||
|
LambdaQueryWrapper<ProjectRxswinEO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(ProjectRxswinEO::getId, Arrays.asList(ids.split(",")));
|
||||||
|
List<ProjectRxswinEO> rxswinEOList = this.list(wrapper);
|
||||||
|
|
||||||
|
//已存在的
|
||||||
|
LambdaQueryWrapper<ProjectRxswinEO> wrapperTemp = new LambdaQueryWrapper<>();
|
||||||
|
wrapperTemp.eq(ProjectRxswinEO::getProjectId, projectId);
|
||||||
|
List<ProjectRxswinEO> rxswinEOS = this.list(wrapperTemp);
|
||||||
|
|
||||||
|
List<String> themeList = rxswinEOS.stream().map(ProjectRxswinEO::getTheme).collect(Collectors.toList());
|
||||||
|
List<ProjectRxswinEO> yesList = rxswinEOList.stream().filter(e -> themeList.contains(e.getTheme())).collect(Collectors.toList());
|
||||||
|
List<ProjectRxswinEO> noList = rxswinEOList.stream().filter(e -> !themeList.contains(e.getTheme())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
if(StatusEnum.COVER_YES.getValue().equals(flag)){
|
||||||
|
//未存在的进行新增
|
||||||
|
saveBatchInfo(projectId, user, noList);
|
||||||
|
|
||||||
|
for (ProjectRxswinEO projectRxswinEO : yesList) {
|
||||||
|
List<ProjectRxswinEO> collect = rxswinEOS.stream()
|
||||||
|
.filter(e -> projectRxswinEO.getTheme().equals(e.getTheme())).collect(Collectors.toList());
|
||||||
|
if(!collect.isEmpty()){
|
||||||
|
projectRxswinEO.setId(collect.get(0).getId());
|
||||||
|
projectRxswinEO.setCreateTime(collect.get(0).getCreateTime());
|
||||||
|
}
|
||||||
|
projectRxswinEO.setUpdateTime(new Date());
|
||||||
|
projectRxswinEO.setCreateBy(user.getUsername());
|
||||||
|
projectRxswinEO.setState(StatusEnum.SAVE.getValue());
|
||||||
|
}
|
||||||
|
//已存在的进行覆盖
|
||||||
|
this.updateBatchById(yesList);
|
||||||
|
|
||||||
|
|
||||||
|
}else if(StatusEnum.COVER_NO.getValue().equals(flag)){
|
||||||
|
saveBatchInfo(projectId, user, noList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user