Conflicts: pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.javatags/24080901
@@ -31,7 +31,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; | |||||
"com.ningdatech.pmapi.filemanage.controller", | "com.ningdatech.pmapi.filemanage.controller", | ||||
"com.ningdatech.pmapi.performance.controller", | "com.ningdatech.pmapi.performance.controller", | ||||
"com.ningdatech.pmapi.irs.controller", | "com.ningdatech.pmapi.irs.controller", | ||||
"com.ningdatech.pmapi.safety.controller" | |||||
"com.ningdatech.pmapi.safety.controller", | |||||
"com.ningdatech.pmapi.portrait.controller" | |||||
}) | }) | ||||
public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { | public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { | ||||
@@ -0,0 +1,56 @@ | |||||
package com.ningdatech.pmapi.portrait.controller; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | |||||
import com.ningdatech.pmapi.portrait.manage.TagManage; | |||||
import com.ningdatech.pmapi.portrait.model.dto.TagDTO; | |||||
import com.ningdatech.pmapi.portrait.model.dto.TagToProjectDTO; | |||||
import com.ningdatech.pmapi.portrait.model.req.TagPageReq; | |||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import javax.validation.Valid; | |||||
/** | |||||
* @Classname TagController | |||||
* @Description | |||||
* @Date 2023/8/2 14:11 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@RestController | |||||
@RequiredArgsConstructor | |||||
@Api(tags = "项目画像-标签") | |||||
@RequestMapping("/api/v1/portrait/tag") | |||||
public class TagController { | |||||
private final TagManage tagManage; | |||||
@GetMapping("/list/{areaCode}") | |||||
@ApiOperation("按区域查询标签列表") | |||||
public PageVo<TagVO> list(@PathVariable String areaCode, TagPageReq req) { | |||||
return tagManage.list(areaCode,req); | |||||
} | |||||
@PostMapping("/save") | |||||
@ApiOperation("保存标签") | |||||
@WebLog("保存标签") | |||||
public String save(@Valid @RequestBody TagDTO dto) { | |||||
return tagManage.save(dto); | |||||
} | |||||
@PostMapping("/save-to-project") | |||||
@ApiOperation("设置标签到项目") | |||||
@WebLog("设置标签到项目") | |||||
public String saveToProject(@Valid @RequestBody TagToProjectDTO dto) { | |||||
return tagManage.saveToProject(dto); | |||||
} | |||||
@PostMapping("/remove-tag-to-project") | |||||
@ApiOperation("项目删除标签") | |||||
@WebLog("项目删除标签") | |||||
public String removeTagToProject(@Valid @RequestBody TagToProjectDTO dto) { | |||||
return tagManage.removeTagToProject(dto); | |||||
} | |||||
} |
@@ -0,0 +1,174 @@ | |||||
package com.ningdatech.pmapi.portrait.manage; | |||||
import cn.hutool.core.bean.BeanUtil; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
import com.ningdatech.basic.function.VUtils; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.basic.util.CollUtils; | |||||
import com.ningdatech.pmapi.portrait.model.dto.TagDTO; | |||||
import com.ningdatech.pmapi.portrait.model.dto.TagToProjectDTO; | |||||
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; | |||||
import com.ningdatech.pmapi.portrait.model.entity.Tag; | |||||
import com.ningdatech.pmapi.portrait.model.req.TagPageReq; | |||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | |||||
import com.ningdatech.pmapi.portrait.service.IProjectTagService; | |||||
import com.ningdatech.pmapi.portrait.service.ITagService; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectService; | |||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | |||||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||||
import lombok.AllArgsConstructor; | |||||
import lombok.extern.slf4j.Slf4j; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.springframework.stereotype.Component; | |||||
import java.time.LocalDateTime; | |||||
import java.util.List; | |||||
import java.util.Objects; | |||||
/** | |||||
* @Classname TagManage | |||||
* @Description | |||||
* @Date 2023/8/2 14:10 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@Component | |||||
@Slf4j | |||||
@AllArgsConstructor | |||||
public class TagManage { | |||||
private final ITagService tagService; | |||||
private final IProjectService projectService; | |||||
private final IProjectTagService projectTagService; | |||||
/** | |||||
* 标签分页 | |||||
* @param areaCode | |||||
* @param req | |||||
* @return | |||||
*/ | |||||
public PageVo<TagVO> list(String areaCode, TagPageReq req) { | |||||
LambdaQueryWrapper<Tag> query = Wrappers.lambdaQuery(Tag.class) | |||||
.eq(Tag::getAreaCode, areaCode) | |||||
.like(StringUtils.isNotBlank(req.getName()),Tag::getName,req.getName()) | |||||
.orderByDesc(Tag::getUpdateOn); | |||||
checkAuth(query,LoginUserUtil.loginUserDetail()); | |||||
Page<Tag> page = tagService.page(req.page(), query); | |||||
long total; | |||||
if ((total = page.getTotal()) == 0) { | |||||
return PageVo.empty(); | |||||
} | |||||
List<TagVO> records = CollUtils.convert(page.getRecords(), | |||||
t -> BeanUtil.copyProperties(t,TagVO.class)); | |||||
return PageVo.of(records, total); | |||||
} | |||||
/** | |||||
* 权限控制 | |||||
* @param query | |||||
* @param user | |||||
*/ | |||||
private void checkAuth(LambdaQueryWrapper<Tag> query, UserInfoDetails user) { | |||||
//如果是超管 | |||||
if(user.getSuperAdmin()){ | |||||
log.info(user.getUsername() + " 是超管,可以看所有标签"); | |||||
}else if(user.getRegionAdmin()){ | |||||
//如果是区域管理员 | |||||
log.info(user.getUsername() + " 是区管,可以看本区域" + user.getRegionCode() + "标签"); | |||||
query.eq(Tag::getAreaCode,user.getRegionCode()); | |||||
}else{ | |||||
//其它角色全都看不见 | |||||
query.eq(Tag::getId,0L); | |||||
} | |||||
} | |||||
/** | |||||
* 保存标签 | |||||
* @param dto | |||||
* @return | |||||
*/ | |||||
public String save(TagDTO dto) { | |||||
deduplicationName(dto); | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||||
Tag entity = BeanUtil.copyProperties(dto,Tag.class); | |||||
if(Objects.nonNull(dto.getId())){ | |||||
Tag old = tagService.getById(dto.getId()); | |||||
VUtils.isTrue(Objects.isNull(old)).throwMessage("此id标签不存在!"); | |||||
entity.setId(old.getId()); | |||||
}else{ | |||||
entity.setId(null); | |||||
entity.setCreateOn(LocalDateTime.now()); | |||||
entity.setCreateBy(user.getUsername()); | |||||
} | |||||
entity.setUpdateOn(LocalDateTime.now()); | |||||
entity.setUpdateBy(user.getUsername()); | |||||
tagService.saveOrUpdate(entity); | |||||
return "保存成功"; | |||||
} | |||||
/** | |||||
* 标签名 去重 | |||||
* @param dto | |||||
*/ | |||||
private void deduplicationName(TagDTO dto) { | |||||
if(StringUtils.isNotBlank(dto.getName())){ | |||||
long count = tagService.count(Wrappers.lambdaQuery(Tag.class) | |||||
.eq(Tag::getAreaCode, dto.getAreaCode()) | |||||
.eq(Tag::getName, dto.getName()) | |||||
.ne(Objects.nonNull(dto.getId()), Tag::getId, dto.getId())); | |||||
VUtils.isTrue(count > 0).throwMessage("保存失败!此区域标签名重复!"); | |||||
} | |||||
} | |||||
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("标签不存在!"); | |||||
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()); | |||||
projectTagService.save(projectTag); | |||||
return "保存成功"; | |||||
} | |||||
public String removeTagToProject(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("标签不存在!"); | |||||
VUtils.isTrue(!tag.getAreaCode().equals(project.getAreaCode())) | |||||
.throwMessage("项目和标签不是一个区域的!"); | |||||
ProjectTag pt = projectTagService.getOne(Wrappers.lambdaQuery(ProjectTag.class) | |||||
.eq(ProjectTag::getProjectCode, projectCode) | |||||
.eq(ProjectTag::getTagId, tagId)); | |||||
VUtils.isTrue(Objects.isNull(pt)) | |||||
.throwMessage("该项目没有绑定此标签!"); | |||||
projectTagService.removeById(pt.getId()); | |||||
return "删除成功"; | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ningdatech.pmapi.portrait.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; | |||||
/** | |||||
* <p> | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-2 | |||||
*/ | |||||
public interface ProjectTagMapper extends BaseMapper<ProjectTag> { | |||||
} |
@@ -0,0 +1,15 @@ | |||||
package com.ningdatech.pmapi.portrait.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.ningdatech.pmapi.portrait.model.entity.Tag; | |||||
/** | |||||
* <p> | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-2 | |||||
*/ | |||||
public interface TagMapper extends BaseMapper<Tag> { | |||||
} |
@@ -0,0 +1,36 @@ | |||||
package com.ningdatech.pmapi.portrait.model.dto; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.io.Serializable; | |||||
/** | |||||
* <p> | |||||
* 标签 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-02 | |||||
*/ | |||||
@Data | |||||
@ApiModel(value = "Tag对象", description = "标签") | |||||
public class TagDTO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
private Long id; | |||||
@ApiModelProperty("标签名") | |||||
private String name; | |||||
@ApiModelProperty("备注") | |||||
private String remark; | |||||
@ApiModelProperty("区域CODE") | |||||
@NotNull(message = "区域CODE必填") | |||||
private String areaCode; | |||||
} |
@@ -0,0 +1,31 @@ | |||||
package com.ningdatech.pmapi.portrait.model.dto; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import javax.validation.constraints.NotNull; | |||||
import java.io.Serializable; | |||||
/** | |||||
* <p> | |||||
* 标签 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-02 | |||||
*/ | |||||
@Data | |||||
@ApiModel(value = "Tag对象", description = "标签") | |||||
public class TagToProjectDTO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
@NotNull(message = "标签ID必填") | |||||
private Long tagId; | |||||
@ApiModelProperty("当前项目编号") | |||||
@NotNull(message = "项目编号必填") | |||||
private String projectCode; | |||||
} |
@@ -0,0 +1,40 @@ | |||||
package com.ningdatech.pmapi.portrait.model.entity; | |||||
import com.baomidou.mybatisplus.annotation.IdType; | |||||
import com.baomidou.mybatisplus.annotation.TableId; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* <p> | |||||
* 标签项目关联 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-02 | |||||
*/ | |||||
@Data | |||||
@TableName("nd_project_tag") | |||||
@ApiModel(value = "ProjectTag对象", description = "标签项目关联") | |||||
public class ProjectTag implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
@TableId(type = IdType.AUTO) | |||||
private Long id; | |||||
@ApiModelProperty("项目编号") | |||||
private String projectCode; | |||||
@ApiModelProperty("标签ID") | |||||
private Long tagId; | |||||
private LocalDateTime createOn; | |||||
private String createBy; | |||||
} |
@@ -0,0 +1,45 @@ | |||||
package com.ningdatech.pmapi.portrait.model.entity; | |||||
import com.baomidou.mybatisplus.annotation.IdType; | |||||
import com.baomidou.mybatisplus.annotation.TableId; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* <p> | |||||
* 标签 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-02 | |||||
*/ | |||||
@Data | |||||
@TableName("nd_tag") | |||||
@ApiModel(value = "Tag对象", description = "标签") | |||||
public class Tag implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
@TableId(type = IdType.AUTO) | |||||
private Long id; | |||||
@ApiModelProperty("标签名") | |||||
private String name; | |||||
@ApiModelProperty("备注") | |||||
private String remark; | |||||
@ApiModelProperty("区域CODE") | |||||
private String areaCode; | |||||
private LocalDateTime createOn; | |||||
private LocalDateTime updateOn; | |||||
private String createBy; | |||||
private String updateBy; | |||||
} |
@@ -0,0 +1,25 @@ | |||||
package com.ningdatech.pmapi.portrait.model.req; | |||||
import com.ningdatech.basic.model.PagePo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.*; | |||||
/** | |||||
* @Classname TagPageReq | |||||
* @Description | |||||
* @Date 2023/8/2 14:16 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@Data | |||||
@Builder | |||||
@AllArgsConstructor | |||||
@NoArgsConstructor | |||||
@ApiModel("标签列表查询") | |||||
@EqualsAndHashCode(callSuper = true) | |||||
public class TagPageReq extends PagePo { | |||||
@ApiModelProperty("标签名") | |||||
private String name; | |||||
} |
@@ -0,0 +1,40 @@ | |||||
package com.ningdatech.pmapi.portrait.model.vo; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
import java.time.LocalDateTime; | |||||
/** | |||||
* <p> | |||||
* 标签 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-02 | |||||
*/ | |||||
@Data | |||||
@ApiModel(value = "Tag对象", description = "标签") | |||||
public class TagVO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
private Long id; | |||||
@ApiModelProperty("标签名") | |||||
private String name; | |||||
@ApiModelProperty("备注") | |||||
private String remark; | |||||
@ApiModelProperty("区域CODE") | |||||
private String areaCode; | |||||
private LocalDateTime createOn; | |||||
private LocalDateTime updateOn; | |||||
private String createBy; | |||||
private String updateBy; | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package com.ningdatech.pmapi.portrait.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; | |||||
/** | |||||
* @Classname ITagService | |||||
* @Description | |||||
* @Date 2023/8/2 10:47 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
public interface IProjectTagService extends IService<ProjectTag> { | |||||
} |
@@ -0,0 +1,14 @@ | |||||
package com.ningdatech.pmapi.portrait.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.ningdatech.pmapi.portrait.model.entity.Tag; | |||||
/** | |||||
* @Classname ITagService | |||||
* @Description | |||||
* @Date 2023/8/2 10:47 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
public interface ITagService extends IService<Tag> { | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package com.ningdatech.pmapi.portrait.service.impl; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.pmapi.portrait.mapper.ProjectTagMapper; | |||||
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; | |||||
import com.ningdatech.pmapi.portrait.service.IProjectTagService; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* <p> | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-2 | |||||
*/ | |||||
@Service | |||||
public class ProjectTagServiceImpl extends ServiceImpl<ProjectTagMapper, | |||||
ProjectTag> implements IProjectTagService { | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package com.ningdatech.pmapi.portrait.service.impl; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.pmapi.portrait.mapper.TagMapper; | |||||
import com.ningdatech.pmapi.portrait.model.entity.Tag; | |||||
import com.ningdatech.pmapi.portrait.service.ITagService; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* <p> | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-08-2 | |||||
*/ | |||||
@Service | |||||
public class TagServiceImpl extends ServiceImpl<TagMapper, | |||||
Tag> implements ITagService { | |||||
} |
@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.google.common.collect.Lists; | import com.google.common.collect.Lists; | ||||
import com.google.common.collect.Maps; | |||||
import com.ningdatech.basic.function.VUtils; | import com.ningdatech.basic.function.VUtils; | ||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
@@ -34,6 +35,11 @@ import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||||
import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; | import com.ningdatech.pmapi.performance.model.dto.ProjectCoreBusinessDTO; | ||||
import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; | import com.ningdatech.pmapi.performance.model.entity.ProjectCoreBusinessIndicators; | ||||
import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; | import com.ningdatech.pmapi.performance.service.IProjectCoreBusinessIndicatorsService; | ||||
import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; | |||||
import com.ningdatech.pmapi.portrait.model.entity.Tag; | |||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | |||||
import com.ningdatech.pmapi.portrait.service.IProjectTagService; | |||||
import com.ningdatech.pmapi.portrait.service.ITagService; | |||||
import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | import com.ningdatech.pmapi.projectdeclared.model.dto.DelayedApplyDTO; | ||||
import com.ningdatech.pmapi.projectdeclared.model.entity.*; | import com.ningdatech.pmapi.projectdeclared.model.entity.*; | ||||
import com.ningdatech.pmapi.projectdeclared.model.vo.*; | import com.ningdatech.pmapi.projectdeclared.model.vo.*; | ||||
@@ -105,6 +111,9 @@ public class ProjectLibManage { | |||||
private final ITodoService todoService; | private final ITodoService todoService; | ||||
private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; | private final IProjectCoreBusinessIndicatorsService projectCoreBusinessIndicatorsService; | ||||
private final IProjectTagService projectTagService; | |||||
private final ITagService tagService; | |||||
private final IOperationService operationService; | private final IOperationService operationService; | ||||
public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) { | public PageVo<ProjectLibListItemVO> projectLibList(ProjectListReq req) { | ||||
@@ -146,6 +155,24 @@ public class ProjectLibManage { | |||||
return PageVo.empty(); | return PageVo.empty(); | ||||
} | } | ||||
UserFullInfoDTO finalUser = user; | UserFullInfoDTO finalUser = user; | ||||
Set<String> projectCodes = page.getRecords().stream() | |||||
.map(Project::getProjectCode).collect(Collectors.toSet()); | |||||
List<ProjectTag> pts = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) | |||||
.in(ProjectTag::getProjectCode, projectCodes)); | |||||
Map<String,List<ProjectTag>> tagMap = Maps.newHashMap(); | |||||
Map<Long,String> tagNameMap = Maps.newHashMap(); | |||||
if(CollUtil.isNotEmpty(pts)){ | |||||
tagMap = pts.stream().collect(Collectors.groupingBy(ProjectTag::getProjectCode)); | |||||
Set<Long> tagIds = pts.stream().map(ProjectTag::getTagId).collect(Collectors.toSet()); | |||||
List<Tag> tags = tagService.list(Wrappers.lambdaQuery(Tag.class) | |||||
.in(Tag::getId, tagIds)); | |||||
if(CollUtil.isNotEmpty(tags)){ | |||||
tagNameMap = tags.stream().collect(Collectors.toMap(Tag::getId,Tag::getName)); | |||||
} | |||||
} | |||||
Map<String, List<ProjectTag>> finalTagMap = tagMap; | |||||
Map<Long,String> finalTagNameMap = tagNameMap; | |||||
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { | List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> { | ||||
ProjectLibListItemVO item = new ProjectLibListItemVO(); | ProjectLibListItemVO item = new ProjectLibListItemVO(); | ||||
item.setId(w.getId()); | item.setId(w.getId()); | ||||
@@ -168,11 +195,28 @@ public class ProjectLibManage { | |||||
item.setCanPreDeclared(Boolean.TRUE); | item.setCanPreDeclared(Boolean.TRUE); | ||||
} | } | ||||
item.setPrePlanProjectId(w.getPrePlanProjectId()); | item.setPrePlanProjectId(w.getPrePlanProjectId()); | ||||
setTag(item,finalTagMap,finalTagNameMap); | |||||
return item; | return item; | ||||
}); | }); | ||||
return PageVo.of(records, total); | return PageVo.of(records, total); | ||||
} | } | ||||
private void setTag(ProjectLibListItemVO item, Map<String, List<ProjectTag>> finalTagMap, Map<Long, String> finalTagNameMap) { | |||||
if(finalTagMap.containsKey(item.getProjectCode())){ | |||||
List<TagVO> tags = Lists.newArrayList(); | |||||
List<ProjectTag> projectTags = finalTagMap.get(item.getProjectCode()); | |||||
for(ProjectTag pt :projectTags){ | |||||
if(finalTagNameMap.containsKey(pt.getTagId())){ | |||||
TagVO vo = new TagVO(); | |||||
vo.setId(pt.getTagId()); | |||||
vo.setName(finalTagNameMap.get(pt.getTagId())); | |||||
tags.add(vo); | |||||
} | |||||
} | |||||
item.setTags(tags); | |||||
} | |||||
} | |||||
public List<Project> projectList(ProjectListReq req) { | public List<Project> projectList(ProjectListReq req) { | ||||
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req); | ||||
return projectService.list(query); | return projectService.list(query); | ||||
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.annotation.JSONField; | |||||
import com.fasterxml.jackson.annotation.JsonFormat; | import com.fasterxml.jackson.annotation.JsonFormat; | ||||
import com.ningdatech.basic.util.NdDateUtils; | import com.ningdatech.basic.util.NdDateUtils; | ||||
import com.ningdatech.pmapi.common.util.BizUtils; | import com.ningdatech.pmapi.common.util.BizUtils; | ||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | |||||
import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; | import com.ningdatech.pmapi.projectdeclared.model.entity.Contract; | ||||
import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; | import com.ningdatech.pmapi.projectdeclared.model.vo.ContractVO; | ||||
import com.ningdatech.pmapi.projectdeclared.model.vo.OperationVO; | import com.ningdatech.pmapi.projectdeclared.model.vo.OperationVO; | ||||
@@ -400,6 +401,9 @@ public class ProjectDetailVO { | |||||
@ApiModelProperty("审批详情") | @ApiModelProperty("审批详情") | ||||
private ProcessProgressDetailVo process; | private ProcessProgressDetailVo process; | ||||
@ApiModelProperty("标签") | |||||
private List<TagVO> tags; | |||||
public String getVersionStr() { | public String getVersionStr() { | ||||
if (Objects.nonNull(this.newest) && this.newest) { | if (Objects.nonNull(this.newest) && this.newest) { | ||||
this.versionStr = "当前版本"; | this.versionStr = "当前版本"; | ||||
@@ -3,6 +3,7 @@ package com.ningdatech.pmapi.projectlib.model.vo; | |||||
import com.alibaba.fastjson.annotation.JSONField; | import com.alibaba.fastjson.annotation.JSONField; | ||||
import com.fasterxml.jackson.annotation.JsonFormat; | import com.fasterxml.jackson.annotation.JsonFormat; | ||||
import com.ningdatech.pmapi.common.enumeration.CommonEnum; | import com.ningdatech.pmapi.common.enumeration.CommonEnum; | ||||
import com.ningdatech.pmapi.portrait.model.vo.TagVO; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; | ||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | ||||
import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; | ||||
@@ -16,6 +17,7 @@ import lombok.experimental.Tolerate; | |||||
import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
import java.time.LocalDate; | import java.time.LocalDate; | ||||
import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||
import java.util.List; | |||||
import java.util.Objects; | import java.util.Objects; | ||||
import java.util.Optional; | import java.util.Optional; | ||||
@@ -142,6 +144,9 @@ public class ProjectLibListItemVO { | |||||
@ApiModelProperty("初步方案项目ID") | @ApiModelProperty("初步方案项目ID") | ||||
private Long prePlanProjectId; | private Long prePlanProjectId; | ||||
@ApiModelProperty("标签") | |||||
private List<TagVO> tags; | |||||
//预审申报时候 需不需要上传上级条线意见文件 | //预审申报时候 需不需要上传上级条线意见文件 | ||||
private Boolean needUploadSuperLineFile; | private Boolean needUploadSuperLineFile; | ||||
public Boolean getNeedUploadSuperLineFile() { | public Boolean getNeedUploadSuperLineFile() { | ||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject; | |||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
import com.ningdatech.basic.exception.BizException; | |||||
import com.ningdatech.basic.function.VUtils; | import com.ningdatech.basic.function.VUtils; | ||||
import com.ningdatech.basic.model.PageVo; | import com.ningdatech.basic.model.PageVo; | ||||
import com.ningdatech.basic.util.CollUtils; | import com.ningdatech.basic.util.CollUtils; | ||||
@@ -64,7 +65,8 @@ public class SafetyRiskManage { | |||||
.ge(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) | .ge(Project::getStatus, ProjectStatusEnum.UNDER_CONSTRUCTION.getCode()) | ||||
.ne(Project::getStatus, ProjectStatusEnum.OPERATION.getCode()) | .ne(Project::getStatus, ProjectStatusEnum.OPERATION.getCode()) | ||||
.like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()) | .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()) | ||||
.like(StringUtils.isNotBlank(req.getBuildOrgName()),Project::getBuildOrgName,req.getBuildOrgName()); | |||||
.like(StringUtils.isNotBlank(req.getBuildOrgName()),Project::getBuildOrgName,req.getBuildOrgName()) | |||||
.orderByDesc(Project::getUpdateOn); | |||||
checkAuth(query,LoginUserUtil.loginUserDetail()); | checkAuth(query,LoginUserUtil.loginUserDetail()); | ||||
Page<Project> page = projectService.page(req.page(), query); | Page<Project> page = projectService.page(req.page(), query); | ||||
long total; | long total; | ||||
@@ -145,9 +147,16 @@ public class SafetyRiskManage { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | UserInfoDetails user = LoginUserUtil.loginUserDetail(); | ||||
String projectCode = dtos.get(0).getProjectCode(); | |||||
if(StringUtils.isBlank(projectCode)){ | |||||
throw new BizException("参数有误!"); | |||||
} | |||||
supplierSafetyQualificationService.remove(Wrappers.lambdaQuery(SupplierSafetyQualification.class) | |||||
.eq(SupplierSafetyQualification::getProjectCode, projectCode)); | |||||
Integer sucessNum = 0; | Integer sucessNum = 0; | ||||
for(SupplierSafetyQualificationDTO dto : dtos){ | for(SupplierSafetyQualificationDTO dto : dtos){ | ||||
String projectCode = dto.getProjectCode(); | |||||
projectCode = dto.getProjectCode(); | |||||
Project project = projectService.getOne(Wrappers.lambdaQuery(Project.class) | Project project = projectService.getOne(Wrappers.lambdaQuery(Project.class) | ||||
.eq(Project::getNewest, Boolean.TRUE) | .eq(Project::getNewest, Boolean.TRUE) | ||||
.eq(Project::getProjectCode, projectCode) | .eq(Project::getProjectCode, projectCode) | ||||
@@ -176,9 +185,16 @@ public class SafetyRiskManage { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | UserInfoDetails user = LoginUserUtil.loginUserDetail(); | ||||
String projectCode = dtos.get(0).getProjectCode(); | |||||
if(StringUtils.isBlank(projectCode)){ | |||||
throw new BizException("参数有误!"); | |||||
} | |||||
personSafetyInfoService.remove(Wrappers.lambdaQuery(PersonSafetyInfo.class) | |||||
.eq(PersonSafetyInfo::getProjectCode, projectCode)); | |||||
Integer sucessNum = 0; | Integer sucessNum = 0; | ||||
for(PersonSafetyInfoDTO dto : dtos){ | for(PersonSafetyInfoDTO dto : dtos){ | ||||
String projectCode = dto.getProjectCode(); | |||||
projectCode = dto.getProjectCode(); | |||||
Project project = projectService.getOne(Wrappers.lambdaQuery(Project.class) | Project project = projectService.getOne(Wrappers.lambdaQuery(Project.class) | ||||
.eq(Project::getNewest, Boolean.TRUE) | .eq(Project::getNewest, Boolean.TRUE) | ||||
.eq(Project::getProjectCode, projectCode) | .eq(Project::getProjectCode, projectCode) | ||||