@@ -0,0 +1,37 @@ | |||||
package com.ningdatech.pmapi.performance.controller; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.performance.manage.OrgSelfAppraisalManage; | |||||
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; | |||||
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.springframework.web.bind.annotation.*; | |||||
/** | |||||
* @Classname OrgSelfAppraisalController | |||||
* @Description | |||||
* @Date 2023/6/25 14:16 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@RestController | |||||
@RequiredArgsConstructor | |||||
@Api(tags = "绩效评价-单位自评") | |||||
@RequestMapping("/api/v1/self-appraisal") | |||||
public class OrgSelfAppraisalController { | |||||
private final OrgSelfAppraisalManage selfAppraisalManage; | |||||
@GetMapping("/list") | |||||
@ApiOperation("当前用户的绩效评价计划列表") | |||||
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) { | |||||
return selfAppraisalManage.list(req); | |||||
} | |||||
@GetMapping("/detail/{id}") | |||||
@ApiOperation("当前用户的绩效评价计划详情") | |||||
public PerformanceAppraisalVO detail(@PathVariable Long id) { | |||||
return selfAppraisalManage.detail(id); | |||||
} | |||||
} |
@@ -57,6 +57,13 @@ public class PerformanceAppraisalPlanController { | |||||
return performanceAppraisalPlanManage.edit(editDTO); | return performanceAppraisalPlanManage.edit(editDTO); | ||||
} | } | ||||
@PostMapping("/delete/{id}") | |||||
@ApiOperation("绩效评价删除") | |||||
@WebLog("绩效评价删除") | |||||
public String delete(@PathVariable Long id) { | |||||
return performanceAppraisalPlanManage.delete(id); | |||||
} | |||||
@GetMapping("/group/list/{appraisalId}") | @GetMapping("/group/list/{appraisalId}") | ||||
@ApiOperation("绩效评价分组列表") | @ApiOperation("绩效评价分组列表") | ||||
public List<PerformanceAppraisalProjectGroupVO> groupList(@PathVariable Long appraisalId, | public List<PerformanceAppraisalProjectGroupVO> groupList(@PathVariable Long appraisalId, | ||||
@@ -64,10 +71,23 @@ public class PerformanceAppraisalPlanController { | |||||
return performanceAppraisalPlanManage.groupList(appraisalId,name); | return performanceAppraisalPlanManage.groupList(appraisalId,name); | ||||
} | } | ||||
@GetMapping("/group/detail/{id}") | |||||
@ApiOperation("绩效评价分组详情") | |||||
public PerformanceAppraisalProjectGroupVO groupDetail(@PathVariable Long id) { | |||||
return performanceAppraisalPlanManage.groupDetail(id); | |||||
} | |||||
@PostMapping("/group/save") | @PostMapping("/group/save") | ||||
@ApiOperation("绩效评价分组保存") | @ApiOperation("绩效评价分组保存") | ||||
@WebLog("绩效评价分组保存") | @WebLog("绩效评价分组保存") | ||||
public String groupSave(@Valid @RequestBody PerformanceAppraisalProjectGroupSaveDTO dto) { | public String groupSave(@Valid @RequestBody PerformanceAppraisalProjectGroupSaveDTO dto) { | ||||
return performanceAppraisalPlanManage.groupSave(dto); | return performanceAppraisalPlanManage.groupSave(dto); | ||||
} | } | ||||
@PostMapping("/group/delete/{id}") | |||||
@ApiOperation("绩效评价分组删除") | |||||
@WebLog("绩效评价分组删除") | |||||
public String groupDelete(@PathVariable Long id) { | |||||
return performanceAppraisalPlanManage.groupDelete(id); | |||||
} | |||||
} | } |
@@ -35,6 +35,8 @@ public class PerformanceAppraisalConveter { | |||||
vo.setProjectType(project.getProjectType()); | vo.setProjectType(project.getProjectType()); | ||||
vo.setProjectTypeName(getProjectTypeName(project.getProjectType())); | vo.setProjectTypeName(getProjectTypeName(project.getProjectType())); | ||||
vo.setBuildOrgName(project.getBuildOrgName()); | vo.setBuildOrgName(project.getBuildOrgName()); | ||||
vo.setDeclareAmount(project.getDeclareAmount()); | |||||
vo.setProjectYear(project.getProjectYear()); | |||||
} | } | ||||
return vo; | return vo; | ||||
}).collect(Collectors.toList()); | }).collect(Collectors.toList()); | ||||
@@ -54,7 +56,6 @@ public class PerformanceAppraisalConveter { | |||||
application.getApplicationName() : application.getAccountAppName()); | application.getApplicationName() : application.getAccountAppName()); | ||||
vo.setApplicationType(application.getApplicationType()); | vo.setApplicationType(application.getApplicationType()); | ||||
vo.setBizDomain(application.getBizDomain()); | vo.setBizDomain(application.getBizDomain()); | ||||
// vo.setBuildOrgName(application.get()); | |||||
vo.setPublishSide(application.getPublishSide()); | vo.setPublishSide(application.getPublishSide()); | ||||
} | } | ||||
return vo; | return vo; | ||||
@@ -0,0 +1,180 @@ | |||||
package com.ningdatech.pmapi.performance.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.StringUtils; | |||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||||
import com.google.common.collect.Maps; | |||||
import com.ningdatech.basic.function.VUtils; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter; | |||||
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; | |||||
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalApplication; | |||||
import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; | |||||
import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; | |||||
import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; | |||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; | |||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectService; | |||||
import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.Project; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectApplication; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectApplicationService; | |||||
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.springframework.stereotype.Component; | |||||
import java.util.*; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* @Classname OrgSelfAppraisalManage | |||||
* @Description | |||||
* @Date 2023/6/19 14:18 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@Component | |||||
@Slf4j | |||||
@AllArgsConstructor | |||||
public class OrgSelfAppraisalManage { | |||||
private final IPerformanceAppraisalService performanceAppraisalService; | |||||
private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; | |||||
private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; | |||||
private final IProjectService projectService; | |||||
private final IProjectApplicationService applicationService; | |||||
/** | |||||
* 绩效列表 | |||||
* @param req | |||||
* @return | |||||
*/ | |||||
public PageVo<PerformanceAppraisalVO> list(PerformanceAppraisalListReq req) { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||||
//当前登录用户 单位code | |||||
String empPosUnitCode = user.getEmpPosUnitCode(); | |||||
projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.eq(Project::getBuildOrgCode,empPosUnitCode)); | |||||
Page<PerformanceAppraisal> page = req.page(); | |||||
LambdaQueryWrapper<PerformanceAppraisal> wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) | |||||
.like(StringUtils.isNotBlank(req.getName()),PerformanceAppraisal::getName,req.getName()) | |||||
.ge(Objects.nonNull(req.getStart()),PerformanceAppraisal::getCreateOn,req.getStart()) | |||||
.le(Objects.nonNull(req.getEnd()),PerformanceAppraisal::getCreateOn,req.getEnd()) | |||||
.orderByDesc(PerformanceAppraisal::getUpdateOn); | |||||
performanceAppraisalService.page(page,wrapper); | |||||
if(0L == page.getTotal()){ | |||||
return PageVo.empty(); | |||||
} | |||||
List<Long> paIds = page.getRecords().stream().map(PerformanceAppraisal::getId).collect(Collectors.toList()); | |||||
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | |||||
.in(PerformanceAppraisalProject::getAppraisalId, paIds)); | |||||
Map<String,Project> projectMap = Maps.newHashMap(); | |||||
Map<Long,List<PerformanceAppraisalProject>> papsGroupMap = Maps.newHashMap(); | |||||
if(CollUtil.isNotEmpty(paps)){ | |||||
papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); | |||||
List<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.in(Project::getProjectCode, projectCodes) | |||||
.eq(Project::getNewest, Boolean.TRUE)); | |||||
if(CollUtil.isNotEmpty(projects)){ | |||||
projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); | |||||
} | |||||
} | |||||
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) | |||||
.in(PerformanceAppraisalApplication::getAppraisalId, paIds)); | |||||
Map<Long,ProjectApplication> applicationMap = Maps.newHashMap(); | |||||
Map<Long,List<PerformanceAppraisalApplication>> paasGroupMap = Maps.newHashMap(); | |||||
if(CollUtil.isNotEmpty(paas)){ | |||||
paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); | |||||
List<Long> applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); | |||||
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.in(ProjectApplication::getId, applicationIds)); | |||||
if(CollUtil.isNotEmpty(apps)){ | |||||
applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); | |||||
} | |||||
} | |||||
Map<Long, List<PerformanceAppraisalProject>> finalPapsGroupMap = papsGroupMap; | |||||
Map<Long,List<PerformanceAppraisalApplication>> finalPaasGroupMap = paasGroupMap; | |||||
Map<String,Project> finalProjectMap = projectMap; | |||||
Map<Long,ProjectApplication> finalApplicationMap = applicationMap; | |||||
List<PerformanceAppraisalVO> res = page.getRecords().stream().map(p -> { | |||||
PerformanceAppraisalVO vo = BeanUtil.copyProperties(p,PerformanceAppraisalVO.class); | |||||
if(finalPapsGroupMap.containsKey(p.getId())){ | |||||
vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(p.getId()),finalProjectMap)); | |||||
} | |||||
if(finalPaasGroupMap.containsKey(p.getId())){ | |||||
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(p.getId()),finalApplicationMap)); | |||||
} | |||||
return vo; | |||||
}).collect(Collectors.toList()); | |||||
return PageVo.of(res,page.getTotal()); | |||||
} | |||||
public PerformanceAppraisalVO detail(Long id) { | |||||
PerformanceAppraisal pa = performanceAppraisalService.getById(id); | |||||
VUtils.isTrue(Objects.isNull(pa)).throwMessage("该计划不存在"); | |||||
PerformanceAppraisalVO vo = BeanUtil.copyProperties(pa,PerformanceAppraisalVO.class); | |||||
//绩效关联的项目 | |||||
List<PerformanceAppraisalProject> paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) | |||||
.eq(PerformanceAppraisalProject::getAppraisalId, id)); | |||||
Map<String,Project> projectMap = Maps.newHashMap(); | |||||
Map<Long,List<PerformanceAppraisalProject>> papsGroupMap = Maps.newHashMap(); | |||||
if(CollUtil.isNotEmpty(paps)){ | |||||
papsGroupMap = paps.stream().collect(Collectors.groupingBy(PerformanceAppraisalProject::getAppraisalId)); | |||||
List<String> projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.in(Project::getProjectCode, projectCodes) | |||||
.eq(Project::getNewest, Boolean.TRUE)); | |||||
if(CollUtil.isNotEmpty(projects)){ | |||||
projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); | |||||
} | |||||
} | |||||
//绩效关联的应用 | |||||
List<PerformanceAppraisalApplication> paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) | |||||
.eq(PerformanceAppraisalApplication::getAppraisalId, id)); | |||||
Map<Long,ProjectApplication> applicationMap = Maps.newHashMap(); | |||||
Map<Long,List<PerformanceAppraisalApplication>> paasGroupMap = Maps.newHashMap(); | |||||
if(CollUtil.isNotEmpty(paas)){ | |||||
paasGroupMap = paas.stream().collect(Collectors.groupingBy(PerformanceAppraisalApplication::getAppraisalId)); | |||||
List<Long> applicationIds = paas.stream().map(PerformanceAppraisalApplication::getApplicationId).collect(Collectors.toList()); | |||||
List<ProjectApplication> apps = applicationService.list(Wrappers.lambdaQuery(ProjectApplication.class) | |||||
.in(ProjectApplication::getId, applicationIds)); | |||||
if(CollUtil.isNotEmpty(apps)){ | |||||
applicationMap = apps.stream().collect(Collectors.toMap(ProjectApplication::getId,a -> a)); | |||||
} | |||||
} | |||||
Map<Long, List<PerformanceAppraisalProject>> finalPapsGroupMap = papsGroupMap; | |||||
Map<Long,List<PerformanceAppraisalApplication>> finalPaasGroupMap = paasGroupMap; | |||||
Map<String,Project> finalProjectMap = projectMap; | |||||
Map<Long,ProjectApplication> finalApplicationMap = applicationMap; | |||||
if(finalPapsGroupMap.containsKey(vo.getId())){ | |||||
vo.setProjects(PerformanceAppraisalConveter.convertProjects(finalPapsGroupMap.get(vo.getId()),finalProjectMap)); | |||||
} | |||||
if(finalPaasGroupMap.containsKey(vo.getId())){ | |||||
vo.setApplications(PerformanceAppraisalConveter.convertApplications(finalPaasGroupMap.get(vo.getId()),finalApplicationMap)); | |||||
} | |||||
return vo; | |||||
} | |||||
} |
@@ -8,6 +8,7 @@ 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.Maps; | import com.google.common.collect.Maps; | ||||
import com.google.common.collect.Sets; | import com.google.common.collect.Sets; | ||||
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.StrPool; | import com.ningdatech.basic.util.StrPool; | ||||
@@ -368,6 +369,27 @@ public class PerformanceAppraisalPlanManage { | |||||
} | } | ||||
} | } | ||||
/** | |||||
* 删除绩效评价计划 | |||||
* 连带删除 其下所有 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public String delete(Long id) { | |||||
PerformanceAppraisal pa = performanceAppraisalService.getById(id); | |||||
VUtils.isTrue(Objects.isNull(pa)).throwMessage("绩效评价不存在 删除失败!"); | |||||
//如果到了自评就不能删除了 | |||||
if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ | |||||
throw new BizException("自评已经开始 不能够删除绩效评价"); | |||||
} | |||||
if(performanceAppraisalService.removeById(id)){ | |||||
return "删除成功"; | |||||
} | |||||
return "删除失败"; | |||||
} | |||||
public List<PerformanceAppraisalProjectGroupVO> groupList(Long appraisalId,String name) { | public List<PerformanceAppraisalProjectGroupVO> groupList(Long appraisalId,String name) { | ||||
List<PerformanceAppraisalProjectGroup> groups = groupService.list( | List<PerformanceAppraisalProjectGroup> groups = groupService.list( | ||||
Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) | Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) | ||||
@@ -422,6 +444,52 @@ public class PerformanceAppraisalPlanManage { | |||||
} | } | ||||
/** | /** | ||||
* 分组详情 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public PerformanceAppraisalProjectGroupVO groupDetail(Long id) { | |||||
PerformanceAppraisalProjectGroup group = groupService.getById(id); | |||||
if(Objects.isNull(group)){ | |||||
return null; | |||||
} | |||||
Map<String, Project> projectMap = Maps.newHashMap(); | |||||
List<Project> projects = projectService.list(Wrappers.lambdaQuery(Project.class) | |||||
.in(StringUtils.isNotBlank(group.getProjectIds()),Project::getProjectCode, | |||||
Arrays.stream(group.getProjectIds().split(StrPool.COMMA)).collect(Collectors.toList())) | |||||
.eq(Project::getNewest,Boolean.TRUE)); | |||||
if(CollUtil.isNotEmpty(projects)){ | |||||
projectMap = projects.stream().collect(Collectors.toMap(Project::getProjectCode,p -> p)); | |||||
} | |||||
Map<String, UserFullInfoDTO> userMap = Maps.newHashMap(); | |||||
Set<String> allEmployeeCodes = Sets.newHashSet(); | |||||
allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getReAppraisalUsers())); | |||||
allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getVerificationUsers())); | |||||
if(CollUtil.isNotEmpty(allEmployeeCodes)){ | |||||
List<UserFullInfoDTO> users = userInfoHelper.getUserFullInfoByEmployeeCodes(allEmployeeCodes); | |||||
if(CollUtil.isNotEmpty(users)){ | |||||
userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); | |||||
} | |||||
} | |||||
PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); | |||||
vo.setAppraisalId(group.getAppraisalId()); | |||||
vo.setName(group.getName()); | |||||
vo.setCreateOn(group.getCreateOn()); | |||||
vo.setCreateBy(group.getCreateBy()); | |||||
vo.setUpdateBy(group.getUpdateBy()); | |||||
vo.setUpdateOn(group.getUpdateOn()); | |||||
vo.setId(group.getId()); | |||||
vo.setProjects(checkProject(group.getProjectIds(), projectMap)); | |||||
vo.setReAppraisalUsers(checkUser(group.getReAppraisalUsers(), userMap)); | |||||
vo.setVerificationUsers(checkUser(group.getVerificationUsers(), userMap)); | |||||
return vo; | |||||
} | |||||
/** | |||||
* 分组 保存 | * 分组 保存 | ||||
* @param dto | * @param dto | ||||
* @return | * @return | ||||
@@ -455,6 +523,32 @@ public class PerformanceAppraisalPlanManage { | |||||
return "操作成功"; | return "操作成功"; | ||||
} | } | ||||
/** | |||||
* 删除分组 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public String groupDelete(Long id) { | |||||
PerformanceAppraisalProjectGroup group = groupService.getById(id); | |||||
VUtils.isTrue(Objects.isNull(group)).throwMessage("分组不存在"); | |||||
//评价Id | |||||
Long appraisalId = group.getAppraisalId(); | |||||
PerformanceAppraisal pa = performanceAppraisalService.getById(appraisalId); | |||||
VUtils.isTrue(Objects.isNull(pa)).throwMessage("评价不存在"); | |||||
//如果到了自评就不能删除了 | |||||
if(pa.getSelfAppraisalStart().compareTo(LocalDateTime.now()) < 0){ | |||||
throw new BizException("自评已经开始 不能够删除绩效评价"); | |||||
} | |||||
if(groupService.removeById(id)){ | |||||
return "删除成功"; | |||||
} | |||||
return "删除失败"; | |||||
} | |||||
private List<PerformanceAppraisalProjectVO> checkProject(String projectIds, Map<String, Project> projectMap) { | private List<PerformanceAppraisalProjectVO> checkProject(String projectIds, Map<String, Project> projectMap) { | ||||
if(StringUtils.isBlank(projectIds)){ | if(StringUtils.isBlank(projectIds)){ | ||||
return Collections.emptyList(); | return Collections.emptyList(); | ||||
@@ -0,0 +1,55 @@ | |||||
package com.ningdatech.pmapi.projectlib.controller; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.log.annotation.WebLog; | |||||
import com.ningdatech.pmapi.projectlib.manage.ProjectCollectionManage; | |||||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectCollectionSaveDTO; | |||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectCollectionVO; | |||||
import io.swagger.annotations.Api; | |||||
import io.swagger.annotations.ApiOperation; | |||||
import lombok.RequiredArgsConstructor; | |||||
import org.springframework.web.bind.annotation.*; | |||||
import javax.validation.Valid; | |||||
/** | |||||
* @Classname ProjectCollectionController | |||||
* @Description | |||||
* @Date 2023/6/25 9:11 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@RestController | |||||
@RequiredArgsConstructor | |||||
@Api(tags = "项目归集控制器") | |||||
@RequestMapping("/api/v1/project-collection") | |||||
public class ProjectCollectionController { | |||||
private final ProjectCollectionManage collectionManage; | |||||
@GetMapping("/list") | |||||
@ApiOperation("项目归集列表") | |||||
public PageVo<ProjectCollectionVO> list(ProjectListReq req) { | |||||
return collectionManage.list(req); | |||||
} | |||||
@GetMapping("/detail/{id}") | |||||
@ApiOperation("项目归集详情") | |||||
public ProjectCollectionVO detail(@PathVariable Long id) { | |||||
return collectionManage.detail(id); | |||||
} | |||||
@PostMapping("/save") | |||||
@ApiOperation("项目归集保存") | |||||
@WebLog("项目归集保存") | |||||
public String save(@Valid @RequestBody ProjectCollectionSaveDTO dto) { | |||||
return collectionManage.save(dto); | |||||
} | |||||
@PostMapping("/delete/{id}") | |||||
@ApiOperation("项目归集删除") | |||||
@WebLog("项目归集删除") | |||||
public String delete(@PathVariable Long id) { | |||||
return collectionManage.delete(id); | |||||
} | |||||
} |
@@ -0,0 +1,136 @@ | |||||
package com.ningdatech.pmapi.projectlib.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; | |||||
import com.ningdatech.basic.function.VUtils; | |||||
import com.ningdatech.basic.model.PageVo; | |||||
import com.ningdatech.pmapi.common.helper.RegionCacheHelper; | |||||
import com.ningdatech.pmapi.projectlib.model.dto.ProjectCollectionSaveDTO; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectCollection; | |||||
import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; | |||||
import com.ningdatech.pmapi.projectlib.model.vo.ProjectCollectionVO; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectCollectionService; | |||||
import com.ningdatech.pmapi.sys.model.dto.RegionDTO; | |||||
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; | |||||
import java.util.stream.Collectors; | |||||
/** | |||||
* @Classname ProjectCollectionManage | |||||
* @Description | |||||
* @Date 2023/6/25 9:13 | |||||
* @Author PoffyZhang | |||||
*/ | |||||
@Component | |||||
@Slf4j | |||||
@AllArgsConstructor | |||||
public class ProjectCollectionManage { | |||||
private final IProjectCollectionService collectionService; | |||||
private final RegionCacheHelper regionCacheHelper; | |||||
/** | |||||
* 项目归集 | |||||
* @param req | |||||
* @return | |||||
*/ | |||||
public PageVo<ProjectCollectionVO> list(ProjectListReq req) { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||||
String buildOrgCode = req.getBuildOrgCode(); | |||||
//如果是超管 可以看所有 | |||||
if(user.getSuperAdmin()){ | |||||
buildOrgCode = null; | |||||
} | |||||
Page<ProjectCollection> page = req.page(); | |||||
LambdaQueryWrapper<ProjectCollection> wrapper = Wrappers.lambdaQuery(ProjectCollection.class) | |||||
.like(StringUtils.isNotBlank(req.getProjectName()), ProjectCollection::getProjectName, req.getProjectName()) | |||||
.like(StringUtils.isNotBlank(req.getBuildOrgName()), ProjectCollection::getBuildOrgName, req.getBuildOrgName()) | |||||
.eq(Objects.nonNull(buildOrgCode), ProjectCollection::getBuildOrgCode, buildOrgCode); | |||||
//处理 行政区域 | |||||
if(StringUtils.isNotBlank(req.getRegionCode())){ | |||||
List<RegionDTO> regions = regionCacheHelper.listChildren(req.getRegionCode(), req.getRegionLevel()); | |||||
if(CollUtil.isNotEmpty(regions)){ | |||||
wrapper.in(ProjectCollection::getAreaCode,regions.stream().map(RegionDTO::getRegionCode).collect(Collectors.toList())); | |||||
} | |||||
} | |||||
collectionService.page(page,wrapper); | |||||
if(0L == page.getTotal()){ | |||||
return PageVo.empty(); | |||||
} | |||||
List<ProjectCollectionVO> res = page.getRecords().stream() | |||||
.map(record -> BeanUtil.copyProperties(record,ProjectCollectionVO.class)) | |||||
.collect(Collectors.toList()); | |||||
return PageVo.of(res,page.getTotal()); | |||||
} | |||||
/** | |||||
* 项目归集详情 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public ProjectCollectionVO detail(Long id) { | |||||
ProjectCollection projectCollection = collectionService.getById(id); | |||||
return BeanUtil.copyProperties(projectCollection,ProjectCollectionVO.class); | |||||
} | |||||
/** | |||||
* 保存 | |||||
* @param dto | |||||
* @return | |||||
*/ | |||||
public String save(ProjectCollectionSaveDTO dto) { | |||||
UserInfoDetails user = LoginUserUtil.loginUserDetail(); | |||||
ProjectCollection projectCollection = BeanUtil.copyProperties(dto,ProjectCollection.class); | |||||
if(Objects.nonNull(dto.getId())){ | |||||
ProjectCollection old = collectionService.getById(dto.getId()); | |||||
VUtils.isTrue(Objects.isNull(old)).throwMessage("该项目归集不存在!"); | |||||
projectCollection.setId(dto.getId()); | |||||
}else{ | |||||
projectCollection.setCreateBy(user.getUsername()); | |||||
projectCollection.setCreateOn(LocalDateTime.now()); | |||||
} | |||||
projectCollection.setUpdateBy(user.getUsername()); | |||||
projectCollection.setUpdateOn(LocalDateTime.now()); | |||||
if(collectionService.saveOrUpdate(projectCollection)){ | |||||
return "保存成功"; | |||||
} | |||||
return "保存失败"; | |||||
} | |||||
/** | |||||
* 删除 | |||||
* @param id | |||||
* @return | |||||
*/ | |||||
public String delete(Long id) { | |||||
ProjectCollection projectCollection = collectionService.getById(id); | |||||
VUtils.isTrue(Objects.isNull(projectCollection)).throwMessage("该项目归集不存在 删除失败"); | |||||
if(collectionService.removeById(id)){ | |||||
return "删除成功"; | |||||
} | |||||
return "删除失败"; | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
package com.ningdatech.pmapi.projectlib.mapper; | |||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectCollection; | |||||
/** | |||||
* <p> | |||||
* Mapper 接口 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-06-25 | |||||
*/ | |||||
public interface ProjectCollectionMapper extends BaseMapper<ProjectCollection> { | |||||
} |
@@ -0,0 +1,5 @@ | |||||
<?xml version="1.0" encoding="UTF-8"?> | |||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
<mapper namespace="com.ningdatech.pmapi.projectlib.mapper.ProjectCollectionMapper"> | |||||
</mapper> |
@@ -0,0 +1,151 @@ | |||||
package com.ningdatech.pmapi.projectlib.model.dto; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
import java.math.BigDecimal; | |||||
import java.time.LocalDateTime; | |||||
import java.util.Objects; | |||||
import java.util.Optional; | |||||
/** | |||||
* <p> | |||||
* 项目归集对象 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-06-21 | |||||
*/ | |||||
@Data | |||||
@ApiModel(value = "ProjectCollectionSaveDTO", description = "项目归集对象保存") | |||||
public class ProjectCollectionSaveDTO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
private Long id; | |||||
@ApiModelProperty("项目编号") | |||||
private String projectCode; | |||||
@ApiModelProperty("所属地区编号") | |||||
private String areaCode; | |||||
@ApiModelProperty("所属地区名称") | |||||
private String area; | |||||
@ApiModelProperty("项目阶段") | |||||
private Integer stage; | |||||
@ApiModelProperty("项目状态") | |||||
private Integer status; | |||||
@ApiModelProperty("项目名称") | |||||
private String projectName; | |||||
@ApiModelProperty("项目负责人") | |||||
private String responsibleMan; | |||||
@ApiModelProperty("负责人手机号码") | |||||
private String responsibleManMobile; | |||||
@ApiModelProperty("项目联系人") | |||||
private String contactName; | |||||
@ApiModelProperty("项目联系人手机号码") | |||||
private String contactPhone; | |||||
@ApiModelProperty("建设单位名称") | |||||
private String buildOrgName; | |||||
@ApiModelProperty("建设单位统一社会信用代码") | |||||
private String orgCreditCode; | |||||
@ApiModelProperty("公司编码code") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty("项目类型 1:建设 2:运维") | |||||
private Integer projectType; | |||||
@ApiModelProperty("是否首次新建 0:否 1:是") | |||||
private Integer isFirst; | |||||
@ApiModelProperty("项目预算年度") | |||||
private Integer projectYear; | |||||
@ApiModelProperty("建设层级 1:国家级 2:省级 3:省本级 4:市级 5:市本级 6:区县 7乡镇") | |||||
private Integer buildLevel; | |||||
@ApiModelProperty("发改编码") | |||||
private String developCode; | |||||
@ApiModelProperty("财政编码") | |||||
private String financialCode; | |||||
@ApiModelProperty("项目简介") | |||||
private String projectIntroduction; | |||||
@ApiModelProperty("资金申报情况-申报金额(万元)") | |||||
private BigDecimal declareAmount; | |||||
@ApiModelProperty("立项批复资金(万元)") | |||||
private BigDecimal approvalAmount; | |||||
@ApiModelProperty("关联应用") | |||||
private String applicationName; | |||||
@ApiModelProperty("关联应用IRS编码") | |||||
private String applicationIrsCode; | |||||
@ApiModelProperty("可行性研究报告") | |||||
private String feasibilityStudyReport; | |||||
@ApiModelProperty("立项批复文件") | |||||
private String approvedFile; | |||||
@ApiModelProperty("采购文件") | |||||
private String purchaseFile; | |||||
@ApiModelProperty("中标通知书") | |||||
private String acceptanceLetter; | |||||
@ApiModelProperty("采购合同") | |||||
private String purchaseContract; | |||||
@ApiModelProperty("验收报告") | |||||
private String acceptanceReport; | |||||
@ApiModelProperty("变更批复文件") | |||||
private String changeApprovalDoc; | |||||
@ApiModelProperty("承建单位") | |||||
private String constructionOrg; | |||||
@ApiModelProperty("承建单位统一信用编码") | |||||
private String constructionOrgCreditCode; | |||||
@ApiModelProperty("监理单位") | |||||
private String supervisorOrg; | |||||
@ApiModelProperty("监理单位统一信用编码") | |||||
private String supervisorOrgCreditCode; | |||||
@ApiModelProperty("主管部门名称") | |||||
private String superOrg; | |||||
@ApiModelProperty("主管部门Code") | |||||
private String superOrgCode; | |||||
private String projectTypeName; | |||||
public String getProjectTypeName() { | |||||
if (Objects.nonNull(this.projectType)) { | |||||
Optional.ofNullable(ProjectTypeEnum.getDesc(this.projectType)) | |||||
.ifPresent(desc -> this.projectTypeName = desc); | |||||
} | |||||
return this.projectTypeName; | |||||
} | |||||
} |
@@ -28,6 +28,9 @@ public class ProjectCollection implements Serializable { | |||||
@TableId(type = IdType.AUTO) | @TableId(type = IdType.AUTO) | ||||
private Long id; | private Long id; | ||||
@ApiModelProperty("项目编号") | |||||
private String projectCode; | |||||
@ApiModelProperty("所属地区编号") | @ApiModelProperty("所属地区编号") | ||||
private String areaCode; | private String areaCode; | ||||
@@ -31,6 +31,9 @@ public class ProjectListReq extends PagePo { | |||||
@ApiModelProperty("区域编码") | @ApiModelProperty("区域编码") | ||||
private String regionCode; | private String regionCode; | ||||
@ApiModelProperty("区域等级") | |||||
private Integer regionLevel = 3; | |||||
@ApiModelProperty("项目名称") | @ApiModelProperty("项目名称") | ||||
private String projectName; | private String projectName; | ||||
@@ -0,0 +1,156 @@ | |||||
package com.ningdatech.pmapi.projectlib.model.vo; | |||||
import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; | |||||
import io.swagger.annotations.ApiModel; | |||||
import io.swagger.annotations.ApiModelProperty; | |||||
import lombok.Data; | |||||
import java.io.Serializable; | |||||
import java.math.BigDecimal; | |||||
import java.time.LocalDateTime; | |||||
import java.util.Objects; | |||||
import java.util.Optional; | |||||
/** | |||||
* <p> | |||||
* 项目归集对象 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-06-21 | |||||
*/ | |||||
@Data | |||||
@ApiModel(value = "ProjectCollectionVO", description = "项目归集对象") | |||||
public class ProjectCollectionVO implements Serializable { | |||||
private static final long serialVersionUID = 1L; | |||||
@ApiModelProperty("主键") | |||||
private Long id; | |||||
@ApiModelProperty("项目编号") | |||||
private String projectCode; | |||||
@ApiModelProperty("所属地区编号") | |||||
private String areaCode; | |||||
@ApiModelProperty("所属地区名称") | |||||
private String area; | |||||
@ApiModelProperty("项目阶段") | |||||
private Integer stage; | |||||
@ApiModelProperty("项目状态") | |||||
private Integer status; | |||||
@ApiModelProperty("项目名称") | |||||
private String projectName; | |||||
@ApiModelProperty("项目负责人") | |||||
private String responsibleMan; | |||||
@ApiModelProperty("负责人手机号码") | |||||
private String responsibleManMobile; | |||||
@ApiModelProperty("项目联系人") | |||||
private String contactName; | |||||
@ApiModelProperty("项目联系人手机号码") | |||||
private String contactPhone; | |||||
@ApiModelProperty("建设单位名称") | |||||
private String buildOrgName; | |||||
@ApiModelProperty("建设单位统一社会信用代码") | |||||
private String orgCreditCode; | |||||
@ApiModelProperty("公司编码code") | |||||
private String buildOrgCode; | |||||
@ApiModelProperty("项目类型 1:建设 2:运维") | |||||
private Integer projectType; | |||||
@ApiModelProperty("是否首次新建 0:否 1:是") | |||||
private Integer isFirst; | |||||
@ApiModelProperty("项目预算年度") | |||||
private Integer projectYear; | |||||
@ApiModelProperty("建设层级 1:国家级 2:省级 3:省本级 4:市级 5:市本级 6:区县 7乡镇") | |||||
private Integer buildLevel; | |||||
@ApiModelProperty("发改编码") | |||||
private String developCode; | |||||
@ApiModelProperty("财政编码") | |||||
private String financialCode; | |||||
@ApiModelProperty("项目简介") | |||||
private String projectIntroduction; | |||||
@ApiModelProperty("资金申报情况-申报金额(万元)") | |||||
private BigDecimal declareAmount; | |||||
@ApiModelProperty("立项批复资金(万元)") | |||||
private BigDecimal approvalAmount; | |||||
@ApiModelProperty("关联应用") | |||||
private String applicationName; | |||||
@ApiModelProperty("关联应用IRS编码") | |||||
private String applicationIrsCode; | |||||
private LocalDateTime createOn; | |||||
private LocalDateTime updateOn; | |||||
private String createBy; | |||||
private String updateBy; | |||||
@ApiModelProperty("可行性研究报告") | |||||
private String feasibilityStudyReport; | |||||
@ApiModelProperty("立项批复文件") | |||||
private String approvedFile; | |||||
@ApiModelProperty("采购文件") | |||||
private String purchaseFile; | |||||
@ApiModelProperty("中标通知书") | |||||
private String acceptanceLetter; | |||||
@ApiModelProperty("采购合同") | |||||
private String purchaseContract; | |||||
@ApiModelProperty("验收报告") | |||||
private String acceptanceReport; | |||||
@ApiModelProperty("变更批复文件") | |||||
private String changeApprovalDoc; | |||||
@ApiModelProperty("承建单位") | |||||
private String constructionOrg; | |||||
@ApiModelProperty("承建单位统一信用编码") | |||||
private String constructionOrgCreditCode; | |||||
@ApiModelProperty("监理单位") | |||||
private String supervisorOrg; | |||||
@ApiModelProperty("监理单位统一信用编码") | |||||
private String supervisorOrgCreditCode; | |||||
@ApiModelProperty("主管部门名称") | |||||
private String superOrg; | |||||
@ApiModelProperty("主管部门Code") | |||||
private String superOrgCode; | |||||
private String projectTypeName; | |||||
public String getProjectTypeName() { | |||||
if (Objects.nonNull(this.projectType)) { | |||||
Optional.ofNullable(ProjectTypeEnum.getDesc(this.projectType)) | |||||
.ifPresent(desc -> this.projectTypeName = desc); | |||||
} | |||||
return this.projectTypeName; | |||||
} | |||||
} |
@@ -0,0 +1,16 @@ | |||||
package com.ningdatech.pmapi.projectlib.service; | |||||
import com.baomidou.mybatisplus.extension.service.IService; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectCollection; | |||||
/** | |||||
* <p> | |||||
* 服务类 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-06-25 | |||||
*/ | |||||
public interface IProjectCollectionService extends IService<ProjectCollection> { | |||||
} |
@@ -0,0 +1,21 @@ | |||||
package com.ningdatech.pmapi.projectlib.service.impl; | |||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||||
import com.ningdatech.pmapi.projectlib.mapper.ProjectCollectionMapper; | |||||
import com.ningdatech.pmapi.projectlib.model.entity.ProjectCollection; | |||||
import com.ningdatech.pmapi.projectlib.service.IProjectCollectionService; | |||||
import org.springframework.stereotype.Service; | |||||
/** | |||||
* <p> | |||||
* 服务实现类 | |||||
* </p> | |||||
* | |||||
* @author ZPF | |||||
* @since 2023-06-25 | |||||
*/ | |||||
@Service | |||||
public class ProjectCollectionServiceImpl extends ServiceImpl<ProjectCollectionMapper, ProjectCollection> | |||||
implements IProjectCollectionService { | |||||
} |
@@ -19,6 +19,7 @@ import com.ningdatech.pmapi.sys.model.dto.RoleUpdateDTO; | |||||
import com.ningdatech.pmapi.sys.model.entity.*; | import com.ningdatech.pmapi.sys.model.entity.*; | ||||
import com.ningdatech.pmapi.sys.service.*; | import com.ningdatech.pmapi.sys.service.*; | ||||
import com.ningdatech.pmapi.sys.utils.AuthCacheKeyUtils; | import com.ningdatech.pmapi.sys.utils.AuthCacheKeyUtils; | ||||
import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; | |||||
import com.ningdatech.pmapi.user.manage.UserAuthManage; | import com.ningdatech.pmapi.user.manage.UserAuthManage; | ||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
@@ -119,6 +120,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IR | |||||
Role role = BeanUtil.toBean(data, Role.class); | Role role = BeanUtil.toBean(data, Role.class); | ||||
role.setCreateBy(userId); | role.setCreateBy(userId); | ||||
role.setUpdateBy(userId); | role.setUpdateBy(userId); | ||||
role.setCode(RoleEnum.NORMAL_MEMBER.name()); | |||||
save(role); | save(role); | ||||
saveRoleMenu(data.getMenuIds(), role.getId()); | saveRoleMenu(data.getMenuIds(), role.getId()); | ||||
saveRoleMenuDatascope(data.getMenuDataScopeList(), role.getId()); | saveRoleMenuDatascope(data.getMenuDataScopeList(), role.getId()); | ||||
@@ -145,6 +145,18 @@ public class UserInfoDetails extends AbstractLoginUser implements UserDetails { | |||||
return Boolean.FALSE; | return Boolean.FALSE; | ||||
} | } | ||||
public Boolean getSuperAdmin() { | |||||
if (CollUtil.isNotEmpty(this.userRoleList)) { | |||||
for (Role role : this.userRoleList) { | |||||
RoleEnum roleEnum = RoleEnum.mathByName(role.getCode()); | |||||
if (Objects.nonNull(roleEnum) && roleEnum.eq(RoleEnum.SUPER_ADMIN.name())) { | |||||
return Boolean.TRUE; | |||||
} | |||||
} | |||||
} | |||||
return Boolean.FALSE; | |||||
} | |||||
public Boolean getIsMunicipalOrg() { | public Boolean getIsMunicipalOrg() { | ||||
//如果是丽水市本级的code 就是 | //如果是丽水市本级的code 就是 | ||||
if (RegionConst.RC_LS.equals(this.regionCode)) { | if (RegionConst.RC_LS.equals(this.regionCode)) { | ||||