diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/controller/TagController.java b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/controller/TagController.java index c56bf7a..0a46dce 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/controller/TagController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/controller/TagController.java @@ -13,6 +13,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import javax.validation.Valid; +import java.util.List; /** * @Classname TagController @@ -40,11 +41,18 @@ public class TagController { return tagManage.save(dto); } + @PostMapping("/delete/{id}") + @ApiOperation("删除标签") + @WebLog("删除标签") + public String save(@PathVariable Long id) { + return tagManage.delete(id); + } + @PostMapping("/save-to-project") @ApiOperation("设置标签到项目") @WebLog("设置标签到项目") - public String saveToProject(@Valid @RequestBody TagToProjectDTO dto) { - return tagManage.saveToProject(dto); + public String saveToProject(@Valid @RequestBody List dtos) { + return tagManage.saveToProject(dtos); } @PostMapping("/remove-tag-to-project") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java index 7aea60a..dbb16e5 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/portrait/manage/TagManage.java @@ -1,6 +1,7 @@ package com.ningdatech.pmapi.portrait.manage; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -125,32 +126,39 @@ public class TagManage { } } - public String saveToProject(TagToProjectDTO dto) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - - String projectCode = dto.getProjectCode(); - Project project = projectService.getProjectByCode(projectCode); - VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); - Long tagId = dto.getTagId(); - Tag tag = tagService.getById(tagId); - VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); + public String saveToProject(List dtos) { + if(CollUtil.isEmpty(dtos)){ + return "参入的标签为空"; + } - VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) - .throwMessage("项目和标签不是一个区域的!"); + UserInfoDetails user = LoginUserUtil.loginUserDetail(); - ProjectTag projectTag = new ProjectTag(); - projectTag.setProjectCode(projectCode); - projectTag.setTagId(tagId); - projectTag.setCreateOn(LocalDateTime.now()); - projectTag.setCreateBy(user.getUsername()); - projectTagService.save(projectTag); + Integer successNum = 0; + for(TagToProjectDTO dto : dtos){ + String projectCode = dto.getProjectCode(); + Project project = projectService.getProjectByCode(projectCode); + VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); + Long tagId = dto.getTagId(); + Tag tag = tagService.getById(tagId); + VUtils.isTrue(Objects.isNull(tag)).throwMessage("标签不存在!"); + + VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) + .throwMessage("项目和标签不是一个区域的!"); + + ProjectTag projectTag = new ProjectTag(); + projectTag.setProjectCode(projectCode); + projectTag.setTagId(tagId); + projectTag.setCreateOn(LocalDateTime.now()); + projectTag.setCreateBy(user.getUsername()); + if(projectTagService.save(projectTag)){ + successNum ++; + } + } - return "保存成功"; + return "保存成功" + successNum + "条"; } public String removeTagToProject(TagToProjectDTO dto) { - UserInfoDetails user = LoginUserUtil.loginUserDetail(); - String projectCode = dto.getProjectCode(); Project project = projectService.getProjectByCode(projectCode); VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); @@ -171,4 +179,23 @@ public class TagManage { return "删除成功"; } + + /** + * 删除标签 + * @param id + * @return + */ + public String delete(Long id) { + Tag tag = tagService.getById(id); + VUtils.isTrue(Objects.isNull(tag)) + .throwMessage("删除失败 此标签ID不存在!"); + + if(tagService.removeById(id)){ + //关联关系 也要删 + projectTagService.remove(Wrappers.lambdaQuery(ProjectTag.class) + .eq(ProjectTag::getTagId,id)); + return "删除成功"; + } + return "删除失败"; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java index 1bbb04f..4cbc593 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java @@ -60,6 +60,13 @@ import com.ningdatech.pmapi.projectlib.model.vo.ProjectApplicationVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import com.ningdatech.pmapi.projectlib.model.vo.ProjectLibListItemVO; import com.ningdatech.pmapi.projectlib.service.*; +import com.ningdatech.pmapi.safety.model.entity.PersonSafetyInfo; +import com.ningdatech.pmapi.safety.model.entity.SupplierSafetyQualification; +import com.ningdatech.pmapi.safety.model.vo.PersonSafetyInfoVO; +import com.ningdatech.pmapi.safety.model.vo.SafetyMonitorVO; +import com.ningdatech.pmapi.safety.model.vo.SupplierSafetyQualificationVO; +import com.ningdatech.pmapi.safety.service.IPersonSafetyInfoService; +import com.ningdatech.pmapi.safety.service.ISupplierSafetyQualificationService; import com.ningdatech.pmapi.todocenter.model.req.ProcessDetailReq; import com.ningdatech.pmapi.todocenter.service.ITodoService; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; @@ -116,6 +123,10 @@ public class ProjectLibManage { private final IOperationService operationService; + private final ISupplierSafetyQualificationService supplierSafetyQualificationService; + + private final IPersonSafetyInfoService personSafetyInfoService; + public PageVo projectLibList(ProjectListReq req) { LambdaQueryWrapper query = ProjectHelper.projectQuery(req); query.eq(Project::getNewest, Boolean.TRUE); @@ -790,6 +801,25 @@ public class ProjectLibManage { .last(BizConst.LIMIT_1)); vo.setOperation(BeanUtil.copyProperties(operation, OperationVO.class)); + SafetyMonitorVO safetyVo = new SafetyMonitorVO(); + //查询风险监测 + List ssq = supplierSafetyQualificationService.list(Wrappers.lambdaQuery(SupplierSafetyQualification.class) + .eq(SupplierSafetyQualification::getProjectCode, projectInfo.getProjectCode())); + if(CollUtil.isNotEmpty(ssq)){ + safetyVo.setSupplierSafetyQualification(ssq.stream() + .map(s -> BeanUtil.copyProperties(s, SupplierSafetyQualificationVO.class)) + .collect(Collectors.toList())); + } + vo.setSafetyInfo(safetyVo); + + List psi = personSafetyInfoService.list(Wrappers.lambdaQuery(PersonSafetyInfo.class) + .eq(PersonSafetyInfo::getProjectCode, projectInfo.getProjectCode())); + if(CollUtil.isNotEmpty(psi)){ + safetyVo.setPersonSafetyInfo(psi.stream() + .map(p -> BeanUtil.copyProperties(p, PersonSafetyInfoVO.class)) + .collect(Collectors.toList())); + } + //查询初验信息 List acceptancePersons = acceptancePersonService.list(Wrappers.lambdaQuery(PreInsAcceptancePerson.class) .in(PreInsAcceptancePerson::getProjectId, allVersionProjectId) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java index 06b5e94..d1443ec 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectDetailVO.java @@ -13,6 +13,7 @@ import com.ningdatech.pmapi.projectdeclared.model.vo.PreInsAcceptancePersonVO; import com.ningdatech.pmapi.projectdeclared.model.vo.PurchaseVO; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; +import com.ningdatech.pmapi.safety.model.vo.SafetyMonitorVO; import com.ningdatech.pmapi.todocenter.model.vo.ProcessProgressDetailVo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -445,4 +446,7 @@ public class ProjectDetailVO { } return StringUtils.EMPTY; } + + @ApiModelProperty("安全风险监测信息") + private SafetyMonitorVO safetyInfo; }