diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java index a7a5d31..306a086 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/UserInfoHelper.java @@ -3,6 +3,9 @@ package com.ningdatech.pmapi.common.helper; import com.ningdatech.pmapi.user.entity.UserInfo; import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import java.util.Collection; +import java.util.List; + /** * @author liuxinxin * @date 2023/2/10 下午4:38 @@ -23,6 +26,8 @@ public interface UserInfoHelper { UserFullInfoDTO getUserFullInfo(UserInfo userInfo); + List getUserFullInfos(List userInfos); + String getUserName(Long userId); /** @@ -34,6 +39,8 @@ public interface UserInfoHelper { UserFullInfoDTO getUserFullInfoByEmployeeCode(String employeeCode); + List getUserFullInfoByEmployeeCodes(Collection employeeCodes); + /** * 获取用户任职所在单位code * diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java index cc9b9c0..7dc75e0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/UserInfoHelperImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; import com.ningdatech.pmapi.organization.model.entity.DingOrganization; @@ -21,10 +22,9 @@ import com.ningdatech.pmapi.user.service.IUserInfoService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author liuxinxin @@ -127,6 +127,83 @@ public class UserInfoHelperImpl implements UserInfoHelper { return userFullInfo; } + /** + * 批量查询 这里 会没有角色 + * @param userInfos + * @return + */ + @Override + public List getUserFullInfos(List userInfos) { + List res = Lists.newArrayList(); + + if(CollUtil.isEmpty(userInfos)){ + return res; + } + + Map userMap = userInfos.stream().collect(Collectors.toMap(UserInfo::getEmployeeCode,e->e)); + + // 获取浙政钉雇员信息 组织信息 + List employeeCodes = userInfos.stream().map(UserInfo::getEmployeeCode).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(employeeCodes)) { + List dingEmployeeInfoList = iDingEmployeeInfoService + .list(Wrappers.lambdaQuery(DingEmployeeInfo.class) + .in(DingEmployeeInfo::getEmployeeCode, employeeCodes) + .eq(DingEmployeeInfo::getMainJob, "true")); + + if(CollUtil.isEmpty(dingEmployeeInfoList)){ + return res; + } + + // 装配用户任职所在单位 + List empPosUnitCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getEmpPosUnitCode).collect(Collectors.toList()); + List orgCodes = dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).collect(Collectors.toList()); + List allOrgCodes = Stream.concat(empPosUnitCodes.stream(),orgCodes.stream()).collect(Collectors.toList()); + if (CollUtil.isEmpty(allOrgCodes)) { + return res; + } + List dingOrganizations = iDingOrganizationService.listByCodes(allOrgCodes); + if (CollUtil.isEmpty(dingOrganizations)) { + return res; + } + Map orgMap = dingOrganizations.stream().collect(Collectors.toMap(DingOrganization::getOrganizationCode,d -> d)); + + res = dingEmployeeInfoList.stream().map(e -> { + UserFullInfoDTO userFullInfo = new UserFullInfoDTO(); + if(orgMap.containsKey(e.getEmpPosUnitCode())){ + DingOrganization organization = orgMap.get(e.getEmpPosUnitCode()); + userFullInfo.setEmpPosUnitCode(e.getEmpPosUnitCode()); + userFullInfo.setEmpPosUnitName(organization.getOrganizationName()); + userFullInfo.setRegionCode(organization.getDivisionCode()); + } + if(orgMap.containsKey(e.getOrganizationCode())){ + DingOrganization organization = orgMap.get(e.getOrganizationCode()); + userFullInfo.setOrganizationCode(organization.getOrganizationCode()); + userFullInfo.setOrganizationName(organization.getOrganizationName()); + // 测试使用 + userFullInfo.setRegionLevel(3); + } + + if(userMap.containsKey(e.getEmployeeCode())){ + UserInfo userInfo = userMap.get(e.getEmployeeCode()); + // 装配返回 + userFullInfo.setUserId(userInfo.getId()); + userFullInfo.setIdentifier(userInfo.getRealName()); + userFullInfo.setRealName(userInfo.getRealName()); + userFullInfo.setEmployeeCode(e.getEmployeeCode()); + userFullInfo.setUsername(userInfo.getRealName()); + userFullInfo.setMobile(userInfo.getMobile()); + userFullInfo.setAccountId(userInfo.getAccountId()); + String available = userInfo.getAvailable(); + if (StringUtils.isNotBlank(available)) { + userFullInfo.setAvailable(UserAvailableEnum.valueOf(available)); + } + } + return userFullInfo; + }).collect(Collectors.toList()); + } + return res; + } + @Override public String getUserName(Long userId) { UserFullInfoDTO userFullInfo = getUserFullInfo(userId); @@ -154,6 +231,12 @@ public class UserInfoHelperImpl implements UserInfoHelper { } @Override + public List getUserFullInfoByEmployeeCodes(Collection employeeCodes) { + List userInfos = userInfoService.getUserInfoByEmployeeCodes(employeeCodes); + return getUserFullInfos(userInfos); + } + + @Override public String getUserEmpPosUnitCode(Long userId) { UserFullInfoDTO userFullInfo = getUserFullInfo(userId); return userFullInfo.getEmpPosUnitCode(); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java index 809dca5..a30cd3f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/BizUtils.java @@ -2,6 +2,7 @@ package com.ningdatech.pmapi.common.util; import cn.hutool.core.util.StrUtil; import com.ningdatech.basic.util.StrPool; +import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import org.apache.commons.lang3.StringUtils; import org.springframework.util.NumberUtils; @@ -109,4 +110,10 @@ public class BizUtils { return strings.stream().map(w -> "'" + w + "'").collect(Collectors.joining(StrPool.COMMA, StrPool.LEFT_BRACKET, StrPool.RIGHT_BRACKET)); } + public static String getProjectTypeName(Integer projectType) { + if (Objects.nonNull(projectType)) { + return ProjectTypeEnum.getDesc(projectType); + } + return StringUtils.EMPTY; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CodeUtil.java new file mode 100644 index 0000000..12a5268 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/util/CodeUtil.java @@ -0,0 +1,27 @@ +package com.ningdatech.pmapi.common.util; + +import com.ningdatech.basic.util.StrPool; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; + +/** + * @Classname CodeUtil + * @Description + * @Date 2023/6/20 16:06 + * @Author PoffyZhang + */ +@Slf4j +public class CodeUtil { + + public static Collection convertStrToList(String str) { + if(StringUtils.isBlank(str)){ + return Collections.emptyList(); + } + return Arrays.stream(str.split(StrPool.COMMA)).collect(Collectors.toList()); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalController.java deleted file mode 100644 index fb26b7d..0000000 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalController.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.ningdatech.pmapi.performance.controller; - -import com.ningdatech.basic.model.PageVo; -import com.ningdatech.log.annotation.WebLog; -import com.ningdatech.pmapi.performance.manage.PerformanceAppraisalManage; -import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO; -import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO; -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 PerformanceAppraisalController - * @Description - * @Date 2023/6/19 14:16 - * @Author PoffyZhang - */ -@RestController -@RequiredArgsConstructor -@Api(tags = "绩效评价控制器") -@RequestMapping("/api/v1/performance-appraisal") -public class PerformanceAppraisalController { - - private final PerformanceAppraisalManage performanceAppraisalManage; - - @GetMapping("/list") - @ApiOperation("绩效列表") - public PageVo list(PerformanceAppraisalListReq req) { - return performanceAppraisalManage.list(req); - } - - @GetMapping("/detail/{id}") - @ApiOperation("绩效详情") - public PerformanceAppraisalVO detail(@PathVariable Long id) { - return performanceAppraisalManage.detail(id); - } - - @PostMapping("/create") - @ApiOperation("新建绩效") - @WebLog("新建绩效") - public String create(PerformanceAppraisalCreateDTO createDTO) { - return performanceAppraisalManage.create(createDTO); - } - - @PostMapping("/edit") - @ApiOperation("编辑绩效") - @WebLog("编辑绩效") - public String edit(PerformanceAppraisalEditDTO editDTO) { - return performanceAppraisalManage.edit(editDTO); - } -} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java new file mode 100644 index 0000000..d3bc462 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/PerformanceAppraisalPlanController.java @@ -0,0 +1,72 @@ +package com.ningdatech.pmapi.performance.controller; + +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.log.annotation.WebLog; +import com.ningdatech.pmapi.performance.manage.PerformanceAppraisalPlanManage; +import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO; +import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO; +import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalProjectGroupSaveDTO; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO; +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.*; + +import javax.validation.Valid; +import java.util.List; + +/** + * @Classname PerformanceAppraisalController + * @Description + * @Date 2023/6/19 14:16 + * @Author PoffyZhang + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "绩效评价-评价计划") +@RequestMapping("/api/v1/performance-appraisal/plan") +public class PerformanceAppraisalPlanController { + + private final PerformanceAppraisalPlanManage performanceAppraisalPlanManage; + + @GetMapping("/list") + @ApiOperation("绩效评价列表") + public PageVo list(PerformanceAppraisalListReq req) { + return performanceAppraisalPlanManage.list(req); + } + + @GetMapping("/detail/{id}") + @ApiOperation("绩效评价列表") + public PerformanceAppraisalVO detail(@PathVariable Long id) { + return performanceAppraisalPlanManage.detail(id); + } + + @PostMapping("/create") + @ApiOperation("绩效评价创建") + @WebLog("绩效评价创建") + public String create(@Valid @RequestBody PerformanceAppraisalCreateDTO createDTO) { + return performanceAppraisalPlanManage.create(createDTO); + } + + @PostMapping("/edit") + @ApiOperation("编辑绩效评价") + @WebLog("编辑绩效评价") + public String edit(@Valid @RequestBody PerformanceAppraisalEditDTO editDTO) { + return performanceAppraisalPlanManage.edit(editDTO); + } + + @GetMapping("/group/list/{appraisalId}") + @ApiOperation("绩效评价分组列表") + public List groupList(@PathVariable Long appraisalId) { + return performanceAppraisalPlanManage.groupList(appraisalId); + } + + @PostMapping("/group/save") + @ApiOperation("绩效评价分组保存") + @WebLog("绩效评价分组保存") + public String groupSave(@Valid @RequestBody PerformanceAppraisalProjectGroupSaveDTO dto) { + return performanceAppraisalPlanManage.groupSave(dto); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java index f2680f3..1b45196 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/convert/PerformanceAppraisalConveter.java @@ -28,8 +28,9 @@ public class PerformanceAppraisalConveter { PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO(); vo.setIsReAppraisal(p.getIsReAppraisal()); vo.setId(p.getProjectId()); - if(map.containsKey(p.getProjectId())){ - Project project = map.get(p.getProjectId()); + if(map.containsKey(p.getProjectCode())){ + Project project = map.get(p.getProjectCode()); + vo.setProjectCode(project.getProjectCode()); vo.setProjectName(project.getProjectName()); vo.setProjectType(project.getProjectType()); vo.setProjectTypeName(getProjectTypeName(project.getProjectType())); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java similarity index 69% rename from pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalManage.java rename to pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java index d329506..1dcdbd6 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java @@ -7,34 +7,43 @@ 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.google.common.collect.Sets; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.pmapi.common.helper.UserInfoHelper; +import com.ningdatech.pmapi.common.util.BizUtils; +import com.ningdatech.pmapi.common.util.CodeUtil; import com.ningdatech.pmapi.performance.convert.PerformanceAppraisalConveter; import com.ningdatech.pmapi.performance.model.dto.AppraisalProjectDTO; import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalCreateDTO; import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalEditDTO; +import com.ningdatech.pmapi.performance.model.dto.PerformanceAppraisalProjectGroupSaveDTO; 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.entity.PerformanceAppraisalProjectGroup; import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectGroupVO; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalApplicationService; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectGroupService; 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.UserFullInfoDTO; 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 org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -46,7 +55,7 @@ import java.util.stream.Collectors; @Component @Slf4j @AllArgsConstructor -public class PerformanceAppraisalManage { +public class PerformanceAppraisalPlanManage { private final IPerformanceAppraisalService performanceAppraisalService; @@ -58,6 +67,10 @@ public class PerformanceAppraisalManage { private final IProjectApplicationService applicationService; + private final IPerformanceAppraisalProjectGroupService groupService; + + private final UserInfoHelper userInfoHelper; + /** * 绩效列表 * @param req @@ -182,6 +195,7 @@ public class PerformanceAppraisalManage { * @param createDTO * @return */ + @Transactional public String create(PerformanceAppraisalCreateDTO createDTO) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); @@ -194,11 +208,15 @@ public class PerformanceAppraisalManage { pa.setUpdateBy(user.getUsername()); performanceAppraisalService.save(pa); - if(CollUtil.isNotEmpty(createDTO.getProjects())){ + if(CollUtil.isNotEmpty(createDTO.getProjects()) + && StringUtils.isNotBlank(createDTO.getTarget()) + && createDTO.getTarget().contains("1")){ saveProjects(createDTO,pa.getId(),user); } - if(CollUtil.isNotEmpty(createDTO.getApplicationIds())){ + if(CollUtil.isNotEmpty(createDTO.getApplicationIds()) + && StringUtils.isNotBlank(createDTO.getTarget()) + && createDTO.getTarget().contains("2")){ saveApplications(createDTO,pa.getId(),user); } @@ -211,6 +229,7 @@ public class PerformanceAppraisalManage { * @param editDTO * @return */ + @Transactional public String edit(PerformanceAppraisalEditDTO editDTO) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); @@ -252,7 +271,8 @@ public class PerformanceAppraisalManage { } } - private void saveProjects(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { + @Transactional + public void saveProjects(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { if(CollUtil.isEmpty(createDTO.getProjects())){ return; } @@ -275,7 +295,8 @@ public class PerformanceAppraisalManage { } } - private void saveApplications(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { + @Transactional + public void saveApplications(PerformanceAppraisalCreateDTO createDTO,Long id,UserInfoDetails user) { if(CollUtil.isEmpty(createDTO.getApplicationIds())){ return; } @@ -296,7 +317,8 @@ public class PerformanceAppraisalManage { } } - private void saveProjects(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { + @Transactional + public void saveProjects(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { if(Objects.isNull(editDTO.getProjects())){ return; } @@ -321,8 +343,9 @@ public class PerformanceAppraisalManage { } } - private void saveApplications(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { - if(CollUtil.isEmpty(editDTO.getApplicationIds())){ + @Transactional + public void saveApplications(PerformanceAppraisalEditDTO editDTO,UserInfoDetails user) { + if(Objects.isNull(editDTO.getApplicationIds())){ return; } @@ -344,4 +367,119 @@ public class PerformanceAppraisalManage { performanceAppraisalApplicationService.save(paa); } } + + public List groupList(Long appraisalId) { + List groups = groupService.list( + Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .eq(PerformanceAppraisalProjectGroup::getAppraisalId, appraisalId)); + + if(CollUtil.isEmpty(groups)){ + return Collections.emptyList(); + } + + Set allEmployeeCodes = Sets.newHashSet(); + Set projectCodes = Sets.newHashSet(); + Map userMap = Maps.newHashMap(); + Map projectMap = Maps.newHashMap(); + groups.stream().forEach(g -> { + allEmployeeCodes.addAll(CodeUtil.convertStrToList(g.getReAppraisalUsers())); + allEmployeeCodes.addAll(CodeUtil.convertStrToList(g.getVerificationUsers())); + projectCodes.addAll(CodeUtil.convertStrToList(g.getProjectIds())); + }); + + if(CollUtil.isNotEmpty(allEmployeeCodes)){ + List users = userInfoHelper.getUserFullInfoByEmployeeCodes(allEmployeeCodes); + if(CollUtil.isNotEmpty(users)){ + userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); + } + } + + if(CollUtil.isNotEmpty(projectCodes)){ + List 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)); + } + } + + Map finalProjectMap = projectMap; + Map finalUserMap = userMap; + return groups.stream().map(g -> { + PerformanceAppraisalProjectGroupVO vo = new PerformanceAppraisalProjectGroupVO(); + vo.setAppraisalId(g.getAppraisalId()); + vo.setName(g.getName()); + vo.setCreateOn(g.getCreateOn()); + vo.setCreateBy(g.getCreateBy()); + vo.setUpdateBy(g.getUpdateBy()); + vo.setUpdateOn(g.getUpdateOn()); + vo.setId(g.getId()); + vo.setProjects(checkProject(g.getProjectIds(), finalProjectMap)); + vo.setReAppraisalUsers(checkUser(g.getReAppraisalUsers(), finalUserMap)); + vo.setVerificationUsers(checkUser(g.getVerificationUsers(), finalUserMap)); + return vo; + }).collect(Collectors.toList()); + } + + /** + * 分组 保存 + * @param dto + * @return + */ + public String groupSave(PerformanceAppraisalProjectGroupSaveDTO dto) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + + PerformanceAppraisalProjectGroup group = BeanUtil.copyProperties(dto, PerformanceAppraisalProjectGroup.class); + + if(Objects.isNull(dto.getId())){ + group.setId(null); + group.setCreateOn(LocalDateTime.now()); + group.setCreateBy(user.getUsername()); + }else{ + PerformanceAppraisalProjectGroup old = groupService.getById(dto.getId()); + VUtils.isTrue(Objects.isNull(old)).throwMessage("该分组不存在 编辑失败!"); + group.setId(old.getId()); + } + if(CollUtil.isNotEmpty(dto.getProjectCodes())){ + group.setProjectIds(dto.getProjectCodes().stream().collect(Collectors.joining(StrPool.COMMA))); + } + if(CollUtil.isNotEmpty(dto.getReAppraisalUsers())){ + group.setReAppraisalUsers(dto.getReAppraisalUsers().stream().collect(Collectors.joining(StrPool.COMMA))); + } + if(CollUtil.isNotEmpty(dto.getVerificationUsers())){ + group.setVerificationUsers(dto.getVerificationUsers().stream().collect(Collectors.joining(StrPool.COMMA))); + } + group.setUpdateOn(LocalDateTime.now()); + group.setUpdateBy(user.getUsername()); + groupService.saveOrUpdate(group); + return "操作成功"; + } + + private List checkProject(String projectIds, Map projectMap) { + if(StringUtils.isBlank(projectIds)){ + return Collections.emptyList(); + } + return Arrays.stream(projectIds.split(StrPool.COMMA)).map(projectCode -> { + PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO(); + if(projectMap.containsKey(projectCode)){ + Project project = projectMap.get(projectCode); + vo.setProjectTypeName(BizUtils.getProjectTypeName(project.getProjectType())); + vo.setProjectType(project.getProjectType()); + vo.setId(project.getId()); + vo.setProjectCode(projectCode); + vo.setProjectYear(project.getProjectYear()); + vo.setDeclareAmount(project.getDeclareAmount()); + } + return vo; + }).collect(Collectors.toList()); + } + + private List checkUser(String users, Map userMap) { + if(StringUtils.isBlank(users)){ + return Collections.emptyList(); + } + return Arrays.stream(users.split(StrPool.COMMA)).map( + employeeCode -> userMap.get(employeeCode) + ).collect(Collectors.toList()); + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.java new file mode 100644 index 0000000..9fb9b82 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.performance.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProjectGroup; + +/** + *

+ * Mapper 接口 + *

+ * + * @author Zpf + * @since 2023-06-03 + */ +public interface PerformanceAppraisalProjectGroupMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.xml new file mode 100644 index 0000000..b017ca1 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalProjectGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalProjectDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalProjectDTO.java index e0ba8cd..1e4eace 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalProjectDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/AppraisalProjectDTO.java @@ -2,9 +2,7 @@ package com.ningdatech.pmapi.performance.model.dto; import io.swagger.annotations.ApiModelProperty; import lombok.Data; - import javax.validation.constraints.NotNull; -import java.util.List; /** * @Classname AppraisalProjectDTO diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java index c72260f..dd3e2b4 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalCreateDTO.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.performance.model.dto; +import com.alibaba.fastjson.annotation.JSONField; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalApplicationVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; import io.swagger.annotations.ApiModel; @@ -30,26 +31,32 @@ public class PerformanceAppraisalCreateDTO implements Serializable { @ApiModelProperty("自评开始时间") @NotNull(message = "自评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime selfAppraisalStart; @ApiModelProperty("自评结束时间") @NotNull(message = "自评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime selfAppraisalEnd; @ApiModelProperty("复评开始时间") @NotNull(message = "复评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime reAppraisalStart; @ApiModelProperty("复评结束时间") @NotNull(message = "复评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime reAppraisalEnd; @ApiModelProperty("核查开始时间") @NotNull(message = "核查时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime verificationStart; @ApiModelProperty("核查结束时间") @NotNull(message = "核查时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime verificationEnd; @ApiModelProperty("评价目标 1项目 2应用 可多选 1,2") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java index e2799b6..1654133 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalEditDTO.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.performance.model.dto; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -27,35 +28,34 @@ public class PerformanceAppraisalEditDTO implements Serializable { private Long id; @ApiModelProperty("计划名称") - @NotBlank(message = "请输入计划名称") + @JSONField(format = "yyyy-MM-dd") private String name; @ApiModelProperty("自评开始时间") - @NotNull(message = "自评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime selfAppraisalStart; @ApiModelProperty("自评结束时间") - @NotNull(message = "自评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime selfAppraisalEnd; @ApiModelProperty("复评开始时间") - @NotNull(message = "复评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime reAppraisalStart; @ApiModelProperty("复评结束时间") - @NotNull(message = "复评时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime reAppraisalEnd; @ApiModelProperty("核查开始时间") - @NotNull(message = "核查时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime verificationStart; @ApiModelProperty("核查结束时间") - @NotNull(message = "核查时间错误") + @JSONField(format = "yyyy-MM-dd") private LocalDateTime verificationEnd; @ApiModelProperty("评价目标 1项目 2应用 可多选 1,2") - @NotBlank(message = "评价目标不能为空") private String target; @ApiModelProperty("评价项目 只有ID 和是否复评") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java new file mode 100644 index 0000000..b5bc523 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceAppraisalProjectGroupSaveDTO.java @@ -0,0 +1,43 @@ +package com.ningdatech.pmapi.performance.model.dto; + +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; +import java.util.List; + +/** + * @Classname PerformanceAppraisalProjectGroupSaveDTO + * @Description 绩效评价和项目分组 + * @Date 2023/6/19 14:02 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "绩效评价项目分组", description = "绩效评价项目分组") +public class PerformanceAppraisalProjectGroupSaveDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("id") + private Long id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("计划id") + private Long appraisalId; + + @ApiModelProperty("分组内的所有项目code") + private List projectCodes; + + @ApiModelProperty("复评人员") + private List reAppraisalUsers; + + @ApiModelProperty("核查人员") + private List verificationUsers; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java new file mode 100644 index 0000000..dd6939c --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProjectGroup.java @@ -0,0 +1,49 @@ +package com.ningdatech.pmapi.performance.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; + +/** + * @Classname PerformanceAppraisalProjectGroup + * @Description 绩效评价和项目分组 + * @Date 2023/6/19 14:02 + * @Author PoffyZhang + */ +@Data +@TableName("nd_performance_appraisal_project_group") +@ApiModel(value = "绩效评价项目分组", description = "绩效评价项目分组") +public class PerformanceAppraisalProjectGroup implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + @TableId(type = IdType.AUTO) + private Long id; + + private LocalDateTime createOn; + private LocalDateTime updateOn; + private String createBy; + private String updateBy; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("计划id") + private Long appraisalId; + + @ApiModelProperty("分组内的所有项目id") + private String projectIds; + + @ApiModelProperty("复评人员") + private String reAppraisalUsers; + + @ApiModelProperty("核查人员") + private String verificationUsers; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java index 9a49528..064add0 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/req/PerformanceAppraisalListReq.java @@ -1,11 +1,8 @@ package com.ningdatech.pmapi.performance.model.req; -import com.fasterxml.jackson.annotation.JsonFormat; import com.ningdatech.basic.model.PagePo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; - -import javax.validation.constraints.NotNull; import java.time.LocalDateTime; /** @@ -23,10 +20,8 @@ public class PerformanceAppraisalListReq extends PagePo { private String name; @ApiModelProperty("开始时间") - @JsonFormat(pattern = "yyyy-MM-dd") - private LocalDateTime start; + private String start; @ApiModelProperty("结束时间") - @JsonFormat(pattern = "yyyy-MM-dd") - private LocalDateTime end; + private String end; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectGroupVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectGroupVO.java new file mode 100644 index 0000000..333e8a4 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectGroupVO.java @@ -0,0 +1,46 @@ +package com.ningdatech.pmapi.performance.model.vo; + +import com.ningdatech.pmapi.user.security.auth.model.UserFullInfoDTO; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDateTime; +import java.util.List; + +/** + * @Classname PerformanceAppraisalProjectGroupVO + * @Description 绩效评价和项目分组 + * @Date 2023/6/19 14:02 + * @Author PoffyZhang + */ +@Data +@ApiModel(value = "绩效评价项目分组", description = "绩效评价项目分组") +public class PerformanceAppraisalProjectGroupVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + private Long id; + + private LocalDateTime createOn; + private LocalDateTime updateOn; + private String createBy; + private String updateBy; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("计划id") + private Long appraisalId; + + @ApiModelProperty("分组内的所有项目") + private List projects; + + @ApiModelProperty("复评人员") + private List reAppraisalUsers; + + @ApiModelProperty("核查人员") + private List verificationUsers; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java index 896d313..57a3828 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalProjectVO.java @@ -6,6 +6,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -24,6 +25,9 @@ public class PerformanceAppraisalProjectVO implements Serializable { @ApiModelProperty("项目ID") private Long id; + @ApiModelProperty("项目编码") + private String projectCode; + @ApiModelProperty("项目名称") private String projectName; @@ -38,4 +42,10 @@ public class PerformanceAppraisalProjectVO implements Serializable { @ApiModelProperty("是否复评") private Boolean isReAppraisal; + + @ApiModelProperty("申报金额") + private BigDecimal declareAmount; + + @ApiModelProperty("预算年度") + private Integer projectYear; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalProjectGroupService.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalProjectGroupService.java new file mode 100644 index 0000000..4548554 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalProjectGroupService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.performance.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProjectGroup; + +/** + *

+ * 服务类 + *

+ * + * @author PoffyZhang + * @since 2023-06-03 + */ +public interface IPerformanceAppraisalProjectGroupService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalProjectGroupServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalProjectGroupServiceImpl.java new file mode 100644 index 0000000..4ac484e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalProjectGroupServiceImpl.java @@ -0,0 +1,21 @@ +package com.ningdatech.pmapi.performance.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ningdatech.pmapi.performance.mapper.PerformanceAppraisalProjectGroupMapper; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProjectGroup; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalProjectGroupService; +import org.springframework.stereotype.Service; + +/** + *

+ * 绩效评价分组 服务实现类 + *

+ * + * @author ZPF + * @since 2023-06-15 + */ +@Service +public class PerformanceAppraisalProjectGroupServiceImpl extends ServiceImpl implements IPerformanceAppraisalProjectGroupService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java index c285c2c..7f5ac38 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/IUserInfoService.java @@ -3,6 +3,9 @@ package com.ningdatech.pmapi.user.service; import com.baomidou.mybatisplus.extension.service.IService; import com.ningdatech.pmapi.user.entity.UserInfo; +import java.util.Collection; +import java.util.List; + /** *

* 服务类 @@ -17,4 +20,5 @@ public interface IUserInfoService extends IService { UserInfo getUserInfoByEmployeeCode(String employeeCode); + List getUserInfoByEmployeeCodes(Collection employeeCodes); } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java index ba023a4..3f5fa28 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/user/service/impl/UserInfoServiceImpl.java @@ -10,6 +10,9 @@ import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; +import java.util.Collection; +import java.util.List; + /** *

* 服务实现类 @@ -39,4 +42,10 @@ public class UserInfoServiceImpl extends ServiceImpl return getOne(query); } + @Override + public List getUserInfoByEmployeeCodes(Collection employeeCodes) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(UserInfo.class) + .in(UserInfo::getEmployeeCode, employeeCodes); + return list(query); + } }