Browse Source

Merge branch '20230731_ls2_operation+early_warning+safety_risk+portrait' of http://git.ningdatech.com/liushuai/project-management into dev

master
PoffyZhang 1 year ago
parent
commit
791f3cb46f
1 changed files with 10 additions and 12 deletions
  1. +10
    -12
      pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java

+ 10
- 12
pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java View File

@@ -28,6 +28,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;


/** /**
* @Classname TagManage * @Classname TagManage
@@ -130,32 +131,29 @@ public class TagManage {
if(CollUtil.isEmpty(dtos)){ if(CollUtil.isEmpty(dtos)){
return "参入的标签为空"; return "参入的标签为空";
} }

UserInfoDetails user = LoginUserUtil.loginUserDetail(); UserInfoDetails user = LoginUserUtil.loginUserDetail();

Integer successNum = 0;
String projectCode = dtos.get(0).getProjectCode();
Project project = projectService.getProjectByCode(projectCode);
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!");
projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class)
.eq(ProjectTag::getProjectCode,projectCode));
//去重
dtos = dtos.stream().distinct().collect(Collectors.toList());
for(TagToProjectDTO dto : dtos){ for(TagToProjectDTO dto : dtos){
String projectCode = dto.getProjectCode();
Project project = projectService.getProjectByCode(projectCode);
VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!");
Long tagId = dto.getTagId(); Long tagId = dto.getTagId();
Tag tag = tagService.getById(tagId); Tag tag = tagService.getById(tagId);
VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!");

VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode()))
.throwMessage("项目和标签不是一个区域的!"); .throwMessage("项目和标签不是一个区域的!");

ProjectTag projectTag = new ProjectTag(); ProjectTag projectTag = new ProjectTag();
projectTag.setProjectCode(projectCode); projectTag.setProjectCode(projectCode);
projectTag.setTagId(tagId); projectTag.setTagId(tagId);
projectTag.setCreateOn(LocalDateTime.now()); projectTag.setCreateOn(LocalDateTime.now());
projectTag.setCreateBy(user.getUsername()); projectTag.setCreateBy(user.getUsername());
if(projectTagService.save(projectTag)){
successNum ++;
}
projectTagService.save(projectTag);
} }


return "保存成功" + successNum + "条";
return "保存成功";
} }


public String removeTagToProject(TagToProjectDTO dto) { public String removeTagToProject(TagToProjectDTO dto) {


Loading…
Cancel
Save