diff --git a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java index 2b0d82b..414a8b0 100644 --- a/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java +++ b/ningda-generator/src/main/java/com/ningdatech/generator/config/GeneratorCodeKingbaseConfig.java @@ -57,7 +57,7 @@ public class GeneratorCodeKingbaseConfig { public static void main(String[] args) { //generate("Liuxinxin", "expert", PATH_LXX, "expert_gov_business_strip"); - generate("CMM", "test", PATH_CMM, "nd_performance_appraisal_app_indicator"); + generate("CMM", "test", PATH_CMM, "nd_performance_appraisal_score_info"); } } diff --git a/pmapi/lib/commons-compress-1.19.jar b/pmapi/lib/commons-compress-1.19.jar new file mode 100644 index 0000000..5c9f52a Binary files /dev/null and b/pmapi/lib/commons-compress-1.19.jar differ diff --git a/pmapi/lib/commons-io-2.5.jar b/pmapi/lib/commons-io-2.5.jar new file mode 100644 index 0000000..107b061 Binary files /dev/null and b/pmapi/lib/commons-io-2.5.jar differ diff --git a/pmapi/lib/commons-lang-2.6.jar b/pmapi/lib/commons-lang-2.6.jar new file mode 100644 index 0000000..98467d3 Binary files /dev/null and b/pmapi/lib/commons-lang-2.6.jar differ diff --git a/pmapi/lib/commons-lang3-3.8.1.jar b/pmapi/lib/commons-lang3-3.8.1.jar new file mode 100644 index 0000000..2c65ce6 Binary files /dev/null and b/pmapi/lib/commons-lang3-3.8.1.jar differ diff --git a/pmapi/lib/commons-logging-1.1.1.jar b/pmapi/lib/commons-logging-1.1.1.jar new file mode 100644 index 0000000..1deef14 Binary files /dev/null and b/pmapi/lib/commons-logging-1.1.1.jar differ diff --git a/pmapi/lib/ofd-simple-tool-1.0.23.0324.jar b/pmapi/lib/ofd-simple-tool-1.0.23.0324.jar new file mode 100644 index 0000000..a3eaea3 Binary files /dev/null and b/pmapi/lib/ofd-simple-tool-1.0.23.0324.jar differ diff --git a/pmapi/lib/slf4j-simple-1.7.26.jar b/pmapi/lib/slf4j-simple-1.7.26.jar new file mode 100644 index 0000000..5d82cdf Binary files /dev/null and b/pmapi/lib/slf4j-simple-1.7.26.jar differ diff --git a/pmapi/lib/suwell-bank-extend-1.8.28.0627-sgcc.jar b/pmapi/lib/suwell-bank-extend-1.8.28.0627-sgcc.jar new file mode 100644 index 0000000..9218cde Binary files /dev/null and b/pmapi/lib/suwell-bank-extend-1.8.28.0627-sgcc.jar differ diff --git a/pmapi/lib/suwell-core-base-1.7.220623-lite.jar b/pmapi/lib/suwell-core-base-1.7.220623-lite.jar new file mode 100644 index 0000000..453c0c9 Binary files /dev/null and b/pmapi/lib/suwell-core-base-1.7.220623-lite.jar differ diff --git a/pmapi/lib/suwell-extend-1.0.22.0804.jar b/pmapi/lib/suwell-extend-1.0.22.0804.jar new file mode 100644 index 0000000..82b6c26 Binary files /dev/null and b/pmapi/lib/suwell-extend-1.0.22.0804.jar differ diff --git a/pmapi/pom.xml b/pmapi/pom.xml index 9954d4d..1f06fe5 100644 --- a/pmapi/pom.xml +++ b/pmapi/pom.xml @@ -265,7 +265,117 @@ cn.afterturn easypoi-base + + com.agent + agent-boot + 1.3.22 + system + ${project.basedir}/lib/agent-boot-1.3.22.0215.jar + + + + com.agent + agent-boot + 1.3.22 + system + ${project.basedir}/lib/agent-boot-1.3.22.0215.jar + + + + com.suwell + suwell-agent-http + 1.7 + system + ${project.basedir}/lib/suwell-agent-http-1.7.220630.jar + + + + com.suwell + suwell-agent-wrapper + 1.6 + system + ${project.basedir}/lib/suwell-agent-wrapper-1.6.221208.jar + + + + com.slf4j + slf4j-api + 1.7.29 + system + ${project.basedir}/lib/slf4j-api-1.7.29.jar + + + + com.httpclient + httpclient + 4.5.13 + system + ${project.basedir}/lib/httpclient-4.5.13.jar + + + + com.httpcore + httpcore + 4.4.13 + system + ${project.basedir}/lib/httpcore-4.4.13.jar + + + com.httpmime + httpmime + 4.5.13 + system + ${project.basedir}/lib/httpmime-4.5.13.jar + + + + com.jbArchivesTools + jbArchivesTools + 1.0 + system + ${project.basedir}/lib/jbArchivesTools-1.0-SNAPSHOT.jar + + + + com.suwell + suwell-convert-base + 1.5.19 + system + ${project.basedir}/lib/suwell-convert-base-1.5.19.0408.jar + + + + com.gson + gson + 2.8.0 + system + ${project.basedir}/lib/gson-2.8.0.jar + + + + com.suwell + suwell-rpc-manager-client + 2.7 + system + ${project.basedir}/lib/suwell-rpc-manager-client-2.7.211125.jar + + + + com.suwell + suwell-packet-wrapper + 1.21 + system + ${project.basedir}/lib/suwell-packet-wrapper-1.21.230306.jar + + + + com.dom4j + dom4j + 2.0.2 + system + ${project.basedir}/lib/dom4j-2.0.2.jar + diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java index 53d9cb1..f9539dd 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/common/handler/GlobalResponseHandler.java @@ -34,7 +34,8 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; "com.ningdatech.pmapi.safety.controller", "com.ningdatech.pmapi.portrait.controller", "com.ningdatech.pmapi.irs.controller", - "com.ningdatech.pmapi.dashboard.controller" + "com.ningdatech.pmapi.dashboard.controller", + "com.ningdatech.pmapi.wps.controller" }) public class GlobalResponseHandler implements ResponseBodyAdvice { diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/constant/BizConst.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/constant/BizConst.java new file mode 100644 index 0000000..c59b17d --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/constant/BizConst.java @@ -0,0 +1,38 @@ +package com.ningdatech.pmapi.performance.constant; + +/** + * 常量 + * @return + * @author CMM + * @since 2023/08/08 17:53 + */ +public interface BizConst { + + /** + * 500万元 + */ + Integer FIVE_MILLION = 500; + /** + * 2000万元 + */ + Integer TWENTY_MILLION = 2000; + + /** + * 立项批复金额在500万以下 + */ + Integer AMOUNT_RANGE_ONE = 1; + + /** + * 立项批复金额在500万-2000万之间 + */ + Integer AMOUNT_RANGE_TWO = 2; + + /** + * 立项批复金额大于2000万 + */ + Integer AMOUNT_RANGE_THREE = 3; + /** + * 复评员 + */ + String REAPPRAISAL_ROLE = "复评员"; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java index d9c16d0..9b10fc7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/OrgSelfAppraisalController.java @@ -2,14 +2,18 @@ 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.dto.ProjectAppraisalDTO; import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +import javax.validation.Valid; + /** * @Classname OrgSelfAppraisalController * @Description @@ -39,6 +43,19 @@ public class OrgSelfAppraisalController { @GetMapping("/appraisaled-list/{planId}") @ApiOperation("当前绩效评价已自评列表") public PageVo appraisaledList(@PathVariable Long planId,PerformanceAppraisalListReq req) { - return selfAppraisalManage.appraisaledList(planId); + return selfAppraisalManage.appraisaledList(planId,req); + } + + @GetMapping("/get-appraisal-template-detail/{projectCode}") + @ApiOperation("获取自评模版详情") + public ProjectAppraisalIndexDetailVO getAppraisalTemplateDetail(@PathVariable String projectCode){ + return selfAppraisalManage.getAppraisalTemplateDetail(projectCode); } + + @PostMapping("/submit-self-appraisal") + @ApiOperation("提交自评") + public String submitSelfAppraisal(@Valid @RequestBody ProjectAppraisalDTO param){ + return selfAppraisalManage.submitSelfAppraisal(param); + } + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java new file mode 100644 index 0000000..dd9e956 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/ReAppraisalController.java @@ -0,0 +1,51 @@ +package com.ningdatech.pmapi.performance.controller; + +import javax.validation.Valid; + +import com.ningdatech.pmapi.performance.manage.ReAppraisalManage; +import org.springframework.web.bind.annotation.*; + +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; + +/** + * ReAppraisalController + * @return + * @author CMM + * @since 2023/08/10 8:54 + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "绩效评价-人工复评") +@RequestMapping("/api/v1/re-appraisal") +public class ReAppraisalController { + + private final ReAppraisalManage reAppraisalManage; + + @GetMapping("/list") + @ApiOperation("当前复评用户的绩效评价计划列表") + public PageVo list(PerformanceAppraisalListReq req) { + return reAppraisalManage.list(req); + } + + @GetMapping("/group-project-list/{groupId}") + @ApiOperation("当前复评用户所在分组复评项目列表") + public PageVo groupProjectList(@PathVariable Long groupId, PerformanceAppraisalListReq req) { + return reAppraisalManage.groupProjectList(groupId,req); + } + + @PostMapping("/submit-reAppraisal") + @ApiOperation("提交复评") + public String submitReAppraisal(@Valid @RequestBody ProjectAppraisalDTO param){ + return reAppraisalManage.submitReAppraisal(param); + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java new file mode 100644 index 0000000..b68015e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/controller/VerifyController.java @@ -0,0 +1,50 @@ +package com.ningdatech.pmapi.performance.controller; + +import javax.validation.Valid; + +import com.ningdatech.pmapi.performance.manage.VerifyManage; +import org.springframework.web.bind.annotation.*; + +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; + +/** + * VerifyController + * @return + * @author CMM + * @since 2023/08/10 8:54 + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "绩效评价-专家核查") +@RequestMapping("/api/v1/verify") +public class VerifyController { + + private final VerifyManage verifyManage; + + @GetMapping("/list") + @ApiOperation("当前核查用户的绩效评价计划列表") + public PageVo list(PerformanceAppraisalListReq req) { + return verifyManage.list(req); + } + + @GetMapping("/group-project-list/{groupId}") + @ApiOperation("当前核查用户所在分组核查项目列表") + public PageVo groupProjectList(@PathVariable Long groupId, PerformanceAppraisalListReq req) { + return verifyManage.groupProjectList(groupId,req); + } + + @PostMapping("/submit-verify") + @ApiOperation("提交核查") + public String submitVerify(@Valid @RequestBody ProjectAppraisalDTO param){ + return verifyManage.submitVerify(param); + } + +} 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 d3095a6..c2bf13d 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 @@ -34,7 +34,7 @@ public class PerformanceAppraisalConveter { PerformanceAppraisalProjectVO vo = new PerformanceAppraisalProjectVO(); vo.setIsReAppraisal(p.getIsReAppraisal()); vo.setCanSelfAppraisal(checkCanSelfAppraisal(p)); - vo.setId(p.getProjectId()); + vo.setProjectId(p.getProjectId()); if(map.containsKey(p.getProjectCode())){ Project project = map.get(p.getProjectCode()); vo.setProjectCode(project.getProjectCode()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/AppraisalTypeEnum.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/AppraisalTypeEnum.java new file mode 100644 index 0000000..0dd22b3 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/enumration/AppraisalTypeEnum.java @@ -0,0 +1,42 @@ +package com.ningdatech.pmapi.performance.enumration; + +import java.util.Objects; + +import org.apache.commons.lang3.StringUtils; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * AppraisalTypeEnum + * @return + * @author CMM + * @since 2023/07/26 16:44 + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +public enum AppraisalTypeEnum { + /** + * 评价类型 + */ + SELF_APPRAISAL(1, "单位自评"), + RE_APPRAISAL(2, "人工复评"), + EXPERT_VERIFY(3, "专家核查"); + + private Integer code; + private String desc; + + public static String getDesc(Integer code) { + if (Objects.isNull(code)) { + return StringUtils.EMPTY; + } + for (AppraisalTypeEnum t : AppraisalTypeEnum.values()) { + if (code.equals(t.getCode())) { + return t.desc; + } + } + return StringUtils.EMPTY; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java new file mode 100644 index 0000000..2c866a1 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/TemplateDetailBuildHelper.java @@ -0,0 +1,22 @@ +package com.ningdatech.pmapi.performance.helper; + +import com.ningdatech.pmapi.performance.model.entity.PerformanceIndicatorProjectTemplateDetail; +import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO; +import com.ningdatech.pmapi.performance.model.vo.ProjectTemplateDetailVO; + +import java.util.List; + +/** + * 模板详情构建helper + * @return + * @author CMM + * @since 2023/08/09 22:28 + */ +public interface TemplateDetailBuildHelper { + /** + * 构建评价模板详情信息 + * @param templateDetails + * @return + */ + List buildTemplateDetail(List templateDetails, ProjectAppraisalIndexDetailVO vo); +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java new file mode 100644 index 0000000..5cfef4d --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/helper/impl/TemplateDetailBuildHelperImpl.java @@ -0,0 +1,130 @@ +package com.ningdatech.pmapi.performance.helper.impl; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.map.MapUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.google.common.collect.Lists; +import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; +import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum; +import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo; +import com.ningdatech.pmapi.performance.model.entity.PerformanceIndicatorProjectTemplateDetail; +import com.ningdatech.pmapi.performance.model.vo.ProjectAppraisalIndexDetailVO; +import com.ningdatech.pmapi.performance.model.vo.ProjectTemplateDetailVO; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalScoreInfoService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @author CMM + * @since 2023/08/09 22:31 + */ +@Component +@RequiredArgsConstructor +public class TemplateDetailBuildHelperImpl implements TemplateDetailBuildHelper { + + private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; + + @Override + public List buildTemplateDetail(List templateDetails, ProjectAppraisalIndexDetailVO vo) { + List res = Lists.newArrayList(); + //第一层是 一级的 + for (PerformanceIndicatorProjectTemplateDetail templateDetailFirst : templateDetails) { + if (PerformanceTemplateTypeEnum.FIRST_INDEX.getCode().equals(templateDetailFirst.getType())) { + ProjectTemplateDetailVO detailFirstVo = BeanUtil.copyProperties(templateDetailFirst, ProjectTemplateDetailVO.class); + List firstList = Lists.newArrayList(); + // 该层循环筛选出第二 指标 + for (PerformanceIndicatorProjectTemplateDetail templateDetailSecond : templateDetails) { + if (Objects.nonNull(templateDetailSecond.getParentId()) && + templateDetailSecond.getParentId().equals(templateDetailFirst.getId())) { + ProjectTemplateDetailVO detailSecondVo = BeanUtil.copyProperties(templateDetailSecond, ProjectTemplateDetailVO.class); + List secondList = Lists.newArrayList(); + // 该层循环筛选出第三 指标 + for (PerformanceIndicatorProjectTemplateDetail templateDetailThird : templateDetails) { + if (Objects.nonNull(templateDetailThird.getParentId()) && + templateDetailThird.getParentId().equals(templateDetailSecond.getId())) { + ProjectTemplateDetailVO detailThirdVo = BeanUtil.copyProperties(templateDetailThird, ProjectTemplateDetailVO.class); + // 如果有单位自评、复评、核查分数信息,各自装配信息 + // 获取自评分数信息 + List selfAppraisalScoreInfo = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getTemplateDetailId, templateDetailThird.getId()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.SELF_APPRAISAL.getCode())); + if (CollUtil.isNotEmpty(selfAppraisalScoreInfo)) { + detailThirdVo.setSelfAppraisalScoreInfo(selfAppraisalScoreInfo); + BigDecimal score = selfAppraisalScoreInfo.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + if (Objects.nonNull(vo)) { + vo.setSelfAppraisalTotalScore(score); + } + } + // 按照复评人员分组 获取复评分数信息 + List reAppraisalScoreInfo = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getTemplateDetailId, templateDetailThird.getId()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())); + if (CollUtil.isNotEmpty(reAppraisalScoreInfo)) { + Map> reAppScoreInfoMap = reAppraisalScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + HashMap scoreMap = MapUtil.newHashMap(); + for (String name : reAppScoreInfoMap.keySet()) { + List scoreInfos = reAppScoreInfoMap.get(name); + BigDecimal totalScore = scoreInfos.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + scoreMap.put(name, totalScore); + } + detailThirdVo.setReAppraisalTotalScoreInfo(scoreMap); + detailThirdVo.setReAppraisalScoreInfo(reAppScoreInfoMap); + if (Objects.nonNull(vo)){ + BigDecimal sum = scoreMap.values().stream() + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setVerifyTotalScore(sum); + } + } + // 按照核查人员分组 获取核查分数信息 + List verifyScoreInfo = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getTemplateDetailId, templateDetailThird.getId()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())); + if (CollUtil.isNotEmpty(verifyScoreInfo)) { + Map> verifyScoreInfoMap = verifyScoreInfo.stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeName)); + HashMap scoreMap = MapUtil.newHashMap(); + for (String name : verifyScoreInfoMap.keySet()) { + List scoreInfos = verifyScoreInfoMap.get(name); + BigDecimal totalScore = scoreInfos.stream().map(PerformanceAppraisalScoreInfo::getAppraisalScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + scoreMap.put(name, totalScore); + } + detailThirdVo.setVerifyTotalScoreInfo(scoreMap); + detailThirdVo.setVerifyScoreInfo(verifyScoreInfoMap); + if (Objects.nonNull(vo)){ + BigDecimal sum = scoreMap.values().stream() + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + vo.setVerifyTotalScore(sum); + } + } + secondList.add(detailThirdVo); + } + } + detailSecondVo.setChildren(secondList); + firstList.add(detailSecondVo); + } + } + detailFirstVo.setChildren(firstList); + res.add(detailFirstVo); + + } + } + return res; + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java index bec49ae..9dbbe38 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/IndicatorConfigManage.java @@ -9,10 +9,12 @@ import com.google.common.collect.Lists; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.StrPool; import com.ningdatech.pmapi.common.constant.CommonConst; import com.ningdatech.pmapi.common.enumeration.CommonEnum; import com.ningdatech.pmapi.common.helper.UserInfoHelper; import com.ningdatech.pmapi.performance.enumration.PerformanceTemplateTypeEnum; +import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper; import com.ningdatech.pmapi.performance.model.dto.PerformanceIndicatorAppIndexSaveDTO; import com.ningdatech.pmapi.performance.model.dto.PerformanceIndicatorProjectIndexSaveDTO; import com.ningdatech.pmapi.performance.model.dto.PerformanceIndicatorProjectTemplateSaveDTO; @@ -42,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.Arrays; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -60,6 +63,7 @@ public class IndicatorConfigManage { private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; private final IPerformanceAppraisalProjectIndicatorService projectIndicatorService; private final IPerformanceAppraisalAppIndicatorService appIndicatorService; + private final TemplateDetailBuildHelper templateDetailBuildHelper; /** * 模板列表 @@ -97,19 +101,27 @@ public class IndicatorConfigManage { } ProjectIndexTemplateVO vo = BeanUtil.copyProperties(template, ProjectIndexTemplateVO.class); + String projectTagIds = template.getProjectTagIds(); + if (StringUtils.isNotBlank(projectTagIds)){ + List proTagIdList = Arrays.stream(projectTagIds.split(StrPool.COMMA)).map(Long::valueOf).collect(Collectors.toList()); + vo.setProjectTagIds(proTagIdList); + } // 获取模版绩效指标详情 List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, id)); + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, id) + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); // 获取模版附加绩效指标详情 List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, id) .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); if(CollUtil.isNotEmpty(templateDetails)){ - vo.setTemplateDetails(buildTemplateDetail(templateDetails)); + List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,null); + vo.setTemplateDetails(templateDetailVos); } if (CollUtil.isNotEmpty(additionalTemplateDetails)){ - vo.setAdditionalIndexDetails(buildTemplateDetail(additionalTemplateDetails)); + List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,null); + vo.setAdditionalIndexDetails(additionalTemplateDetailVos); } return vo; } @@ -123,6 +135,13 @@ public class IndicatorConfigManage { public String projectTemplateSave(PerformanceIndicatorProjectTemplateSaveDTO dto) { UserInfoDetails user = LoginUserUtil.loginUserDetail(); PerformanceIndicatorProjectTemplate template = BeanUtil.copyProperties(dto, PerformanceIndicatorProjectTemplate.class); + List projectTagIds = dto.getProjectTagIds(); + List tagIdList = projectTagIds.stream().map(String::valueOf).collect(Collectors.toList()); + template.setProjectTagIds(String.join(StrPool.COMMA, tagIdList)); + if (Objects.isNull(dto.getStatus())){ + // 默认模版禁用 + template.setStatus(0); + } if(Objects.nonNull(dto.getId())){ PerformanceIndicatorProjectTemplate old = indicatorProjectTemplateService.getById(dto.getId()); VUtils.isTrue(Objects.isNull(old)).throwMessage("该模板不存在!"); @@ -139,10 +158,13 @@ public class IndicatorConfigManage { if(CollUtil.isNotEmpty(dto.getTemplateDetails())){ //先删除 indicatorProjectTemplateDetailService.remove(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) - .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,dto.getId())); + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId,dto.getId()) + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE)); + analysisTemplateDetails(dto.getTemplateDetails(),template.getId()); //校检 所有3级指标(不包括附加指标) 总分是不是100 List indexList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, template.getId()) + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.FALSE) .eq(PerformanceIndicatorProjectTemplateDetail::getType,PerformanceTemplateTypeEnum.THIRD_INDEX.getCode())); if(CollUtil.isNotEmpty(indexList)){ BigDecimal sum = indexList.stream() @@ -152,7 +174,6 @@ public class IndicatorConfigManage { boolean score = (BigDecimal.valueOf(100)).equals(sum); VUtils.isTrue(Boolean.FALSE.equals(score)).throwMessage("总分不是100 操作失败!"); } - analysisTemplateDetails(dto.getTemplateDetails(),template.getId()); } // 保存 模版附加指标详情 if (CollUtil.isNotEmpty(dto.getAdditionalIndexDetails())){ @@ -208,6 +229,7 @@ public class IndicatorConfigManage { templateDetail.setTemplateId(templateId); // 一级指标的父ID为null templateDetail.setParentId(parentId); + templateDetail.setIsAdditional(Boolean.FALSE); indicatorProjectTemplateDetailService.save(templateDetail); @@ -316,6 +338,17 @@ public class IndicatorConfigManage { public Boolean enOrDisProjectIndexTemplate(Long templateId, boolean active) { PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getById(templateId); if (Boolean.TRUE.equals(active)){ + // 根据创建模板时选择的项目类型、预算年度、项目金额、项目标签 + // 判断模板是否可以启用(同一套组合只能启用一套模板) + PerformanceIndicatorProjectTemplate template = indicatorProjectTemplateService.getOne(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) + .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectTemplate.getProjectType()) + .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectTemplate.getProjectYear()) + .eq(PerformanceIndicatorProjectTemplate::getAmountRange, projectTemplate.getAmountRange()) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds, projectTemplate.getProjectTagIds()) + .eq(PerformanceIndicatorProjectTemplate::getStatus,CommonEnum.YES.getCode())); + if (Objects.nonNull(template)){ + throw new BizException("相同配置的模板已存在,当前模板无法启用!"); + } projectTemplate.setStatus(CommonEnum.YES.getCode()); }else { projectTemplate.setStatus(CommonEnum.NO.getCode()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java index 30f3c57..b0bcb24 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/OrgSelfAppraisalManage.java @@ -8,14 +8,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ningdatech.basic.exception.BizException; import com.ningdatech.basic.function.VUtils; import com.ningdatech.basic.model.PageVo; -import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisal; -import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalProject; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.pmapi.performance.constant.BizConst; +import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; +import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; +import com.ningdatech.pmapi.performance.model.entity.*; import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; -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.IPerformanceAppraisalProjectService; -import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalService; +import com.ningdatech.pmapi.performance.model.vo.*; +import com.ningdatech.pmapi.performance.service.*; +import com.ningdatech.pmapi.portrait.model.entity.ProjectTag; +import com.ningdatech.pmapi.portrait.service.IProjectTagService; import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum; import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; import com.ningdatech.pmapi.projectlib.model.entity.Project; @@ -30,7 +34,9 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -47,16 +53,14 @@ import java.util.stream.Collectors; public class OrgSelfAppraisalManage { private final IPerformanceAppraisalService performanceAppraisalService; - private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; - - private final IPerformanceAppraisalApplicationService performanceAppraisalApplicationService; - private final IProjectService projectService; - - private final IProjectApplicationService applicationService; private final IRoleService roleService; - + private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService; + private final TemplateDetailBuildHelper templateDetailBuildHelper; + private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; + private final IProjectTagService projectTagService; + private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; /** * 绩效列表 * @param req @@ -73,7 +77,7 @@ public class OrgSelfAppraisalManage { Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) .eq(Role::getName, RoleEnum.COMPANY_MANAGER.getDesc())); if (Objects.isNull(role)){ - throw new BizException("系统没有单位管理员角色!"); + throw new BizException("登录用户没有单位管理员角色!"); } // 登录用户不是单位管理员,不能查看本单位的自评计划列表 @@ -121,7 +125,8 @@ public class OrgSelfAppraisalManage { // 获取评价计划内已添加的待评价项目信息 List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) - .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())); + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() + .filter(p -> Objects.isNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); if(CollUtil.isEmpty(paps)){ @@ -146,11 +151,11 @@ public class OrgSelfAppraisalManage { .map(p -> { PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); + BeanUtil.copyProperties(appraisalProject,vo); + vo.setProjectId(appraisalProject.getProjectId()); vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); - vo.setIsReAppraisal(appraisalProject.getIsReAppraisal()); - vo.setSelfAppraisalStart(appraisalProject.getSelfAppraisalStart()); - vo.setSelfAppraisalEnd(appraisalProject.getSelfAppraisalEnd()); vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); + vo.setAppraisalId(planId); return vo; }) .collect(Collectors.toList()); @@ -160,12 +165,54 @@ public class OrgSelfAppraisalManage { /** * 已经自评表 + * * @param planId + * @param req * @return */ - public PageVo appraisaledList(Long planId) { + public PageVo appraisaledList(Long planId, PerformanceAppraisalListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + + PerformanceAppraisal plan = performanceAppraisalService.getById(planId); + VUtils.isTrue(Objects.isNull(plan)).throwMessage("该评价计划不存在!"); + + // 获取评价计划内已添加的已评价项目信息 + List paps = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, plan.getId())).stream() + .filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); + Map papsMap = paps.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectId, p -> p)); + + if(CollUtil.isEmpty(paps)){ + return PageVo.empty(); + } - return PageVo.empty(); + // 获取本单位在当前评价计划内的项目 + Set projectCodes = paps.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toSet()); + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, projectCodes) + .eq(Project::getNewest, Boolean.TRUE) + .eq(Project::getBuildOrgCode, user.getEmpPosUnitCode()) + .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); + projectService.page(page,wrapper); + + if(0L == page.getTotal()){ + return PageVo.empty(); + } + List res = page.getRecords().stream() + .map(p -> { + PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); + PerformanceAppraisalProject appraisalProject = papsMap.get(p.getId()); + BeanUtil.copyProperties(appraisalProject,vo); + vo.setProjectId(appraisalProject.getProjectId()); + vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); + vo.setCanSelfAppraisal(checkCanSelfAppraisal(appraisalProject)); + vo.setAppraisalId(planId); + return vo; + }) + .collect(Collectors.toList()); + + return PageVo.of(res,page.getTotal()); } /** @@ -174,10 +221,149 @@ public class OrgSelfAppraisalManage { * @return */ private Boolean checkCanSelfAppraisal(PerformanceAppraisalProject appraisalProject) { + // 在自评时间段内,且是首次自评(打分时间为空) if(LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalStart()) > 0 && - LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0){ + LocalDateTime.now().compareTo(appraisalProject.getSelfAppraisalEnd()) < 0 && + Objects.isNull(appraisalProject.getSelfAppraisalScoreTime())){ return Boolean.TRUE; } return Boolean.FALSE; } + + public ProjectAppraisalIndexDetailVO getAppraisalTemplateDetail(String projectCode) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + String regionCode = user.getRegionCode(); + + ProjectAppraisalIndexDetailVO vo = new ProjectAppraisalIndexDetailVO(); + + // 根据项目编码获取最新版本的项目信息 + Project project = projectService.getProjectByCode(projectCode); + VUtils.isTrue(Objects.isNull(project)).throwMessage("项目不存在!"); + // 根据项目类型、预算年度、批复金额、项目标签匹配本区域指标模版 + Integer projectType = project.getProjectType(); + Integer projectYear = project.getProjectYear(); + BigDecimal approvalAmount = project.getApprovalAmount(); + VUtils.isTrue(Objects.isNull(approvalAmount)).throwMessage("未获取到该项目的立项批复金额"); + // 根据项目code获取项目标签ID列表 + List tagIdList = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class) + .eq(ProjectTag::getProjectCode, projectCode)).stream() + .map(ProjectTag::getTagId).collect(Collectors.toList()); + VUtils.isTrue(CollUtil.isEmpty(tagIdList)).throwMessage("当前项目未设置标签,匹配不到指标模板,请至项目库或评价计划编辑页面设置标签!"); + + List strIdList = tagIdList.stream().map(String::valueOf).collect(Collectors.toList()); + String projectTagIds = String.join(StrPool.COMMA, strIdList); + + Integer amountRange = null; + if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) < 0){ + amountRange = BizConst.AMOUNT_RANGE_ONE; + } else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.FIVE_MILLION)) >= 0 && + approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) < 0) { + amountRange = BizConst.AMOUNT_RANGE_TWO; + }else if (approvalAmount.compareTo(BigDecimal.valueOf(BizConst.TWENTY_MILLION)) >= 0){ + amountRange = BizConst.AMOUNT_RANGE_THREE; + } + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplate.class) + .eq(PerformanceIndicatorProjectTemplate::getRegionCode, regionCode) + .eq(PerformanceIndicatorProjectTemplate::getProjectType, projectType) + .eq(PerformanceIndicatorProjectTemplate::getProjectYear, projectYear) + .eq(PerformanceIndicatorProjectTemplate::getAmountRange, amountRange) + .eq(PerformanceIndicatorProjectTemplate::getProjectTagIds,projectTagIds) + .orderByDesc(PerformanceIndicatorProjectTemplate::getUpdateOn); + PerformanceIndicatorProjectTemplate projectTemplate = indicatorProjectTemplateService.getOne(wrapper); + + if (Objects.isNull(projectTemplate)){ + throw new BizException("该项目匹配不到指标模板,请返回上一页或者刷新重试。"); + } + // 装配项目指标详情及分数信息 + // 获取模版绩效指标详情 + List templateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId())); + // 获取模版附加绩效指标详情 + List additionalTemplateDetails = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .eq(PerformanceIndicatorProjectTemplateDetail::getTemplateId, projectTemplate.getId()) + .eq(PerformanceIndicatorProjectTemplateDetail::getIsAdditional,Boolean.TRUE)); + List templateDetailVos = templateDetailBuildHelper.buildTemplateDetail(templateDetails,vo); + List additionalTemplateDetailVos = templateDetailBuildHelper.buildTemplateDetail(additionalTemplateDetails,vo); + vo.setProjectName(project.getProjectName()); + vo.setBuildOrgName(project.getBuildOrgName()); + vo.setProjectStatus(project.getStatus()); + vo.setProjectYear(projectYear); + vo.setApprovalAmount(approvalAmount); + vo.setTemplateDetails(templateDetailVos); + vo.setAdditionalIndexDetails(additionalTemplateDetailVos); + return vo; + } + + @Transactional(rollbackFor = Exception.class) + public String submitSelfAppraisal(ProjectAppraisalDTO param) { + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String employeeCode = userDetail.getEmployeeCode(); + String username = userDetail.getUsername(); + Long appraisalId = param.getAppraisalId(); + Long appraisalProjectId = param.getAppraisalProjectId(); + String appraisalProjectCode = param.getAppraisalProjectCode(); + List appraisalInfoList = param.getAppraisalInfoList(); + // 判断该项目是否还存在于计划或分组中 + PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) + .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId) + .eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode)); + if (Objects.isNull(appraisalProject)){ + throw new BizException("该项目已被移除评价计划,请返回上一页或者刷新重试!"); + } + // 根据项目模板详情ID保存自评得分、打分时间 + if (CollUtil.isEmpty(appraisalInfoList)){ + throw new BizException("填写所有自评得分后才能提交!"); + } + List ids = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId) + .collect(Collectors.toList()); + // 查出项目模版详情信息 + List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); + if (CollUtil.isEmpty(detailList)){ + throw new BizException("评价指标不存在!"); + } + Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); + List scoreInfos = appraisalInfoList.stream().map(a -> { + PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); + BigDecimal score = a.getScore(); + BigDecimal indexScore = templateDetail.getIndexScore(); + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + throw new BizException("自评得分必须大于等于0且小于等于指标分值!"); + } + // 保存自评分数信息 + PerformanceAppraisalScoreInfo scoreInfo = new PerformanceAppraisalScoreInfo(); + scoreInfo.setAppraisalBasis(a.getAppraisalBasis()); + scoreInfo.setAppraisalScore(a.getScore()); + scoreInfo.setAppraisalBasisAppendix(a.getAppraisalBasisAppendix()); + scoreInfo.setAppraisalType(AppraisalTypeEnum.SELF_APPRAISAL.getCode()); + scoreInfo.setTemplateDetailId(templateDetail.getId()); + scoreInfo.setTemplateId(templateDetail.getTemplateId()); + scoreInfo.setAppraisalEmployeeCode(employeeCode); + scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalId(appraisalId); + scoreInfo.setAppraisalProjectId(appraisalProjectId); + scoreInfo.setAppraisalProjectCode(appraisalProjectCode); + scoreInfo.setCreateOn(LocalDateTime.now()); + scoreInfo.setCreateBy(username); + return scoreInfo; + }).collect(Collectors.toList()); + + if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ + // 计算自评总分并保存 + BigDecimal selfAppraisalTotalScore = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + appraisalProject.setSelfAppraisalTotalScore(selfAppraisalTotalScore); + appraisalProject.setSelfAppraisalScoreTime(LocalDateTime.now()); + appraisalProject.setIsCompleteSelfAppraisal(Boolean.TRUE); + appraisalProject.setUpdateOn(LocalDateTime.now()); + appraisalProject.setUpdateBy(username); + performanceAppraisalProjectService.updateById(appraisalProject); + return "提交成功"; + } + return "提交失败"; + } } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java index 4b705b4..7c1252f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/PerformanceAppraisalPlanManage.java @@ -224,6 +224,10 @@ public class PerformanceAppraisalPlanManage { List verificationUsers = Arrays.stream(verificationUsersStr.split(StrPool.COMMA)) .map(userInfoHelper::getUserFullInfoByEmployeeCode).collect(Collectors.toList()); groupVo.setVerificationUsers(verificationUsers); + if (StringUtils.isNotBlank(g.getVerifyLeader())){ + UserFullInfoDTO dto = userInfoHelper.getUserFullInfoByEmployeeCode(g.getVerifyLeader()); + groupVo.setVerifyLeader(dto); + } groupVo.setCreateOn(g.getCreateOn()); return groupVo; }).collect(Collectors.toList()); @@ -478,6 +482,9 @@ public class PerformanceAppraisalPlanManage { List paas = performanceAppraisalApplicationService.list(Wrappers.lambdaQuery(PerformanceAppraisalApplication.class) .eq(PerformanceAppraisalApplication::getAppraisalId, id)); performanceAppraisalApplicationService.removeBatchByIds(paas); + // 删除评级计划关联的分组信息 + groupService.remove(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .eq(PerformanceAppraisalProjectGroup::getAppraisalId,id)); return "删除成功"; } return "删除失败"; @@ -504,7 +511,11 @@ public class PerformanceAppraisalPlanManage { }); if(CollUtil.isNotEmpty(allEmployeeCodes)){ - List users = userInfoHelper.getUserFullInfoByEmployeeCodes(allEmployeeCodes); + List users = Lists.newArrayList(); + for (String employeeCode : allEmployeeCodes) { + UserFullInfoDTO userFullInfo = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + users.add(userFullInfo); + } if(CollUtil.isNotEmpty(users)){ userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); } @@ -533,6 +544,10 @@ public class PerformanceAppraisalPlanManage { vo.setProjects(checkProject(g.getProjectCodes(), finalProjectMap)); vo.setReAppraisalUsers(checkUser(g.getReAppraisalUsers(), finalUserMap)); vo.setVerificationUsers(checkUser(g.getVerificationUsers(), finalUserMap)); + if (StringUtils.isNotBlank(g.getVerifyLeader())){ + UserFullInfoDTO userFullInfoDto = finalUserMap.get(g.getVerifyLeader()); + vo.setVerifyLeader(userFullInfoDto); + } return vo; }).collect(Collectors.toList()); } @@ -563,7 +578,11 @@ public class PerformanceAppraisalPlanManage { allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getReAppraisalUsers())); allEmployeeCodes.addAll(CodeUtil.convertStrToList(group.getVerificationUsers())); if(CollUtil.isNotEmpty(allEmployeeCodes)){ - List users = userInfoHelper.getUserFullInfoByEmployeeCodes(allEmployeeCodes); + List users = Lists.newArrayList(); + for (String employeeCode : allEmployeeCodes) { + UserFullInfoDTO userFullInfoDto = userInfoHelper.getUserFullInfoByEmployeeCode(employeeCode); + users.add(userFullInfoDto); + } if(CollUtil.isNotEmpty(users)){ userMap = users.stream().collect(Collectors.toMap(UserFullInfoDTO::getEmployeeCode,u -> u)); } @@ -580,6 +599,10 @@ public class PerformanceAppraisalPlanManage { vo.setProjects(checkProject(group.getProjectCodes(), projectMap)); vo.setReAppraisalUsers(checkUser(group.getReAppraisalUsers(), userMap)); vo.setVerificationUsers(checkUser(group.getVerificationUsers(), userMap)); + if (StringUtils.isNotBlank(group.getVerifyLeader())){ + UserFullInfoDTO dto = userMap.get(group.getVerifyLeader()); + vo.setVerifyLeader(dto); + } return vo; } @@ -600,9 +623,12 @@ public class PerformanceAppraisalPlanManage { 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()); + // 先删除旧的分组 + groupList.remove(old); } if(CollUtil.isNotEmpty(dto.getProjectCodes())){ // 判断选择的项目是否已经在当前评价计划的其他分组内 @@ -610,7 +636,16 @@ public class PerformanceAppraisalPlanManage { List projectCodeList = groupList.stream() .map(PerformanceAppraisalProjectGroup::getProjectCodes) .collect(Collectors.toList()); - checkProjectCodes(dto.getProjectCodes(),projectCodeList); + List compareCodes = Lists.newArrayList(); + for (String projectCode : projectCodeList) { + if (projectCode.contains(StrPool.COMMA)){ + List codes = Arrays.asList(projectCode.split(StrPool.COMMA)); + compareCodes.addAll(codes); + }else { + compareCodes.add(projectCode); + } + } + checkProjectCodes(dto.getProjectCodes(),compareCodes); group.setProjectCodes(String.join(StrPool.COMMA, dto.getProjectCodes())); } if(CollUtil.isNotEmpty(dto.getReAppraisalUsers())){ @@ -619,7 +654,16 @@ public class PerformanceAppraisalPlanManage { List reUserList = groupList.stream() .map(PerformanceAppraisalProjectGroup::getReAppraisalUsers) .collect(Collectors.toList()); - checkReAppraisalAndVerifyUsers(dto.getReAppraisalUsers(),reUserList,CommonConst.REAPPRAISAL_TYPE); + List compareUsers = Lists.newArrayList(); + for (String reUser : reUserList) { + if (reUser.contains(StrPool.COMMA)){ + List users = Arrays.asList(reUser.split(StrPool.COMMA)); + compareUsers.addAll(users); + }else { + compareUsers.add(reUser); + } + } + checkReAppraisalAndVerifyUsers(dto.getReAppraisalUsers(),compareUsers,CommonConst.REAPPRAISAL_TYPE); group.setReAppraisalUsers(String.join(StrPool.COMMA, dto.getReAppraisalUsers())); } if(CollUtil.isNotEmpty(dto.getVerificationUsers())){ @@ -628,7 +672,16 @@ public class PerformanceAppraisalPlanManage { List verifyList = groupList.stream() .map(PerformanceAppraisalProjectGroup::getVerificationUsers) .collect(Collectors.toList()); - checkReAppraisalAndVerifyUsers(dto.getVerificationUsers(),verifyList,CommonConst.VERIFY_TYPE); + List compareUsers = Lists.newArrayList(); + for (String verifyUser : verifyList) { + if (verifyUser.contains(StrPool.COMMA)){ + List users = Arrays.asList(verifyUser.split(StrPool.COMMA)); + compareUsers.addAll(users); + }else { + compareUsers.add(verifyUser); + } + } + checkReAppraisalAndVerifyUsers(dto.getVerificationUsers(),compareUsers,CommonConst.VERIFY_TYPE); group.setVerificationUsers(String.join(StrPool.COMMA, dto.getVerificationUsers())); } group.setUpdateOn(LocalDateTime.now()); @@ -708,7 +761,7 @@ public class PerformanceAppraisalPlanManage { vo.setProjectName(project.getProjectName()); vo.setProjectTypeName(BizUtils.getProjectTypeName(project.getProjectType())); vo.setProjectType(project.getProjectType()); - vo.setId(project.getId()); + vo.setProjectId(project.getId()); vo.setProjectCode(projectCode); vo.setProjectYear(project.getProjectYear()); vo.setDeclareAmount(project.getDeclareAmount()); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java new file mode 100644 index 0000000..9d8bbbd --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/ReAppraisalManage.java @@ -0,0 +1,333 @@ +package com.ningdatech.pmapi.performance.manage; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +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.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.pmapi.performance.constant.BizConst; +import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; +import com.ningdatech.pmapi.performance.model.entity.*; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.performance.service.*; +import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.sys.model.entity.Role; +import com.ningdatech.pmapi.sys.service.IRoleService; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * ReAppraisalManage + * @return + * @author CMM + * @since 2023/08/10 8:55 + */ +@Component +@Slf4j +@AllArgsConstructor +public class ReAppraisalManage { + + private final IPerformanceAppraisalService performanceAppraisalService; + private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; + private final IProjectService projectService; + private final IRoleService roleService; + private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; + private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; + private final IPerformanceAppraisalProjectGroupService groupService; + /** + * 复评-评价计划列表 + * @param req + * @return + */ + public PageVo list(PerformanceAppraisalListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + String employeeCode = user.getEmployeeCode(); + //当前登录用户 单位code + String empPosUnitCode = user.getEmpPosUnitCode(); + // 获取当前登录用户的角色列表,只有绩效复评人员才能查看该列表 + List userRoleList = user.getUserRoleList(); + List roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); + Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) + .eq(Role::getName, BizConst.REAPPRAISAL_ROLE)); + if (Objects.isNull(role)){ + throw new BizException("登录用户没有复评员角色!"); + } + + // 登录用户不是复评员,不能查看复评计划列表 + if (!roleIdList.contains(role.getId())){ + return PageVo.empty(); + } + + // 从绩效评价 项目表中获取已经完成单位自评的项目 + List paps = performanceAppraisalProjectService.list().stream() + .filter(p -> Objects.nonNull(p.getSelfAppraisalScoreTime())).collect(Collectors.toList()); + + // 已存在的评价计划添加的评价项目都未完成单位自评 + if(CollUtil.isEmpty(paps)){ + return PageVo.empty(); + } + Set paIds = paps.stream().map(PerformanceAppraisalProject::getAppraisalId).collect(Collectors.toSet()); + + // 获取评价计划关联的分组信息 + List groups = groupService.list(Wrappers.lambdaQuery(PerformanceAppraisalProjectGroup.class) + .in(PerformanceAppraisalProjectGroup::getAppraisalId, paIds)); + // 获取当前登录复评员所在的分组信息 + List groupList = groups.stream().filter(g -> { + String reAppraisalUsers = g.getReAppraisalUsers(); + List empCodeList = Arrays.stream(reAppraisalUsers.split(StrPool.COMMA)).collect(Collectors.toList()); + if (empCodeList.contains(employeeCode)) { + return true; + } + return false; + }).collect(Collectors.toList()); + // 当前登录复评员用户,没有参加评价计划 + if (CollUtil.isEmpty(groupList)){ + return PageVo.empty(); + } + // 获取分组所在的评价计划ID + List appraisalIds = groupList.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList()); + // 因为同一个复评员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组 + Map groupMap = groupList.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g)); + // 获取复评计划列表 + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) + .in(PerformanceAppraisal::getId,appraisalIds) + .orderByDesc(PerformanceAppraisal::getUpdateOn); + performanceAppraisalService.page(page,wrapper); + + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalVO.class); + PerformanceAppraisalProjectGroup group = groupMap.get(p.getId()); + if (Objects.nonNull(group)) { + vo.setReAppraisalGroupId(group.getId()); + vo.setReAppraisalGroupName(group.getName()); + } + return vo; + }).collect(Collectors.toList()); + return PageVo.of(res,page.getTotal()); + } + + /** + * 是否可以复评 + * + * @param employeeCode + * @param projectCode + * @param appraisalId + * @return + */ + private Boolean checkCanReAppraisal(String employeeCode, String projectCode, Long appraisalId) { + // 首次复评(复评打分时间为空) + // 从绩效评价打分信息表中查询打分类型为复评、打分人员为当前登录复评用户的打分信息 + // 如果没有相关的打分信息,说明是当前登录复评用户是首次复评 + List scoreInfos = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode) + .eq(PerformanceAppraisalScoreInfo::getAppraisalId,appraisalId) + .eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode)); + if (CollUtil.isEmpty(scoreInfos)){ + return true; + } + return Boolean.FALSE; + } + + public PageVo groupProjectList(Long groupId, PerformanceAppraisalListReq req) { + + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String employeeCode = userDetail.getEmployeeCode(); + + // 获取分组内的项目信息 + PerformanceAppraisalProjectGroup projectGroup = groupService.getById(groupId); + String projectCodes = projectGroup.getProjectCodes(); + Long appraisalId = projectGroup.getAppraisalId(); + VUtils.isTrue(StringUtils.isBlank(projectCodes)).throwMessage("分组内项目信息不存在!"); + List projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList()); + + // 筛选出分组内已完成单位自评、需要复评的评价项目信息 + List appraisalProjects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .in(PerformanceAppraisalProject::getProjectCode, projectCodeList) + .eq(PerformanceAppraisalProject::getIsReAppraisal,Boolean.TRUE) + .eq(PerformanceAppraisalProject::getIsCompleteSelfAppraisal, Boolean.TRUE)); + // 分组内已完成单位自评的项目信息不存在 + if (CollUtil.isEmpty(appraisalProjects)){ + return PageVo.empty(); + } + List proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + Map appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p)); + + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, proCodeList) + .eq(Project::getNewest, Boolean.TRUE) + .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); + projectService.page(page,wrapper); + + // 分组内项目信息不存在 + if (CollUtil.isEmpty(page.getRecords())){ + return PageVo.empty(); + } + + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); + PerformanceAppraisalProject appraisalProject = appraisalProjectMap.get(p.getProjectCode()); + BeanUtil.copyProperties(appraisalProject, vo); + vo.setProjectId(appraisalProject.getProjectId()); + vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); + vo.setCanReAppraisal(checkCanReAppraisal(employeeCode,appraisalProject.getProjectCode(),appraisalId)); + if (Boolean.TRUE.equals(appraisalProject.getIsCompleteReAppraisal())){ + // 完成复评的项目可以进行核查 + vo.setCanVerify(Boolean.TRUE); + } + vo.setGroupId(groupId); + return vo; + }) + .collect(Collectors.toList()); + return PageVo.of(res,page.getTotal()); + } + + @Transactional(rollbackFor = Exception.class) + public String submitReAppraisal(ProjectAppraisalDTO param) { + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String employeeCode = userDetail.getEmployeeCode(); + String username = userDetail.getUsername(); + Long appraisalId = param.getAppraisalId(); + Long appraisalProjectId = param.getAppraisalProjectId(); + String appraisalProjectCode = param.getAppraisalProjectCode(); + List appraisalInfoList = param.getAppraisalInfoList(); + Long groupId = param.getGroupId(); + PerformanceAppraisalProjectGroup group = groupService.getById(groupId); + + // 获取评价项目 + PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) + .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId) + .eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode)); + + List ids = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId) + .collect(Collectors.toList()); + // 查出项目模版详情信息 + List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); + if (CollUtil.isEmpty(detailList)){ + throw new BizException("评价指标不存在!"); + } + Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); + List scoreInfos = appraisalInfoList.stream().map(a -> { + PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); + BigDecimal score = a.getScore(); + BigDecimal indexScore = templateDetail.getIndexScore(); + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + throw new BizException("复评得分必须大于等于0且小于等于指标分值!"); + } + // 保存复评分数信息 + PerformanceAppraisalScoreInfo scoreInfo = new PerformanceAppraisalScoreInfo(); + scoreInfo.setAppraisalBasis(a.getAppraisalBasis()); + scoreInfo.setAppraisalScore(a.getScore()); + scoreInfo.setAppraisalBasisAppendix(a.getAppraisalBasisAppendix()); + scoreInfo.setAppraisalType(AppraisalTypeEnum.RE_APPRAISAL.getCode()); + scoreInfo.setTemplateDetailId(templateDetail.getId()); + scoreInfo.setTemplateId(templateDetail.getTemplateId()); + scoreInfo.setAppraisalEmployeeCode(employeeCode); + scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalId(appraisalId); + scoreInfo.setAppraisalProjectId(appraisalProjectId); + scoreInfo.setAppraisalProjectCode(appraisalProjectCode); + scoreInfo.setCreateOn(LocalDateTime.now()); + scoreInfo.setCreateBy(username); + return scoreInfo; + }).collect(Collectors.toList()); + + if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ + // 计算复评总分并保存 + BigDecimal reAppraisalTotalScore = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal lastReappraisalTotalScore; + // 判断项目所在分组内其他复评人员是否已经打分 + if (Objects.nonNull(appraisalProject.getReAppraisalTotalScore())){ + // 已经进行了复评,计算两个分值的平均分 + BigDecimal add = reAppraisalTotalScore.add(appraisalProject.getReAppraisalTotalScore()); + lastReappraisalTotalScore = add.divide(BigDecimal.valueOf(2)); + }else { + // 还没有进行过复评 + lastReappraisalTotalScore = reAppraisalTotalScore; + } + appraisalProject.setReAppraisalTotalScore(lastReappraisalTotalScore); + // 取最新地复评打分时间 + appraisalProject.setReAppraisalScoreTime(LocalDateTime.now()); + // 判断当前复评人是否为该评价项目所在分组的复评人员中的最后一个复评人 + judgeCompleteReAppraisal(group, appraisalProject); + appraisalProject.setUpdateOn(LocalDateTime.now()); + appraisalProject.setUpdateBy(username); + performanceAppraisalProjectService.updateById(appraisalProject); + return "提交成功"; + } + return "提交失败"; + } + + private void judgeCompleteReAppraisal(PerformanceAppraisalProjectGroup group, PerformanceAppraisalProject appraisalProject) { + Map> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.RE_APPRAISAL.getCode())) + .stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode)); + + List reUsers = Lists.newArrayList(); + String reAppraisalUsers = group.getReAppraisalUsers(); + String projectCodes = group.getProjectCodes(); + if (reAppraisalUsers.contains(StrPool.COMMA)){ + reUsers = Arrays.asList(reAppraisalUsers.split(StrPool.COMMA)); + }else { + reUsers.add(reAppraisalUsers); + } + List users = Lists.newArrayList(); + for (String reUser : reUsers) { + // 获取分组内复评人员对分组内项目的复评分数信息 + List scoreInfoList = scoreInfoMap.get(reUser); + if (CollUtil.isNotEmpty(scoreInfoList)){ + List projectIdList = scoreInfoList.stream() + .map(PerformanceAppraisalScoreInfo::getAppraisalProjectId) + .collect(Collectors.toList()); + List proCodes = projectService.listByIds(projectIdList).stream() + .map(Project::getProjectCode) + .collect(Collectors.toList()); + // 当前登录用户所在分组的复评人员 对分组内所有项目进行了复评 + if (CollUtil.isNotEmpty(proCodes)){ + String join = String.join(StrPool.COMMA, proCodes); + if (join.equals(projectCodes)) { + users.add(reUser); + } + } + } + } + if (CollUtil.isNotEmpty(users)) { + String join = String.join(StrPool.COMMA, users); + if (join.equals(reAppraisalUsers)) { + // 标记项目完成复评 + appraisalProject.setIsCompleteReAppraisal(Boolean.TRUE); + } + } + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java new file mode 100644 index 0000000..66e7d01 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/manage/VerifyManage.java @@ -0,0 +1,332 @@ +package com.ningdatech.pmapi.performance.manage; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import com.google.common.collect.Lists; +import com.ningdatech.pmapi.user.entity.enumeration.RoleEnum; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +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.exception.BizException; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.basic.model.PageVo; +import com.ningdatech.basic.util.StrPool; +import com.ningdatech.pmapi.performance.enumration.AppraisalTypeEnum; +import com.ningdatech.pmapi.performance.helper.TemplateDetailBuildHelper; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalDTO; +import com.ningdatech.pmapi.performance.model.dto.ProjectAppraisalInfoDTO; +import com.ningdatech.pmapi.performance.model.entity.*; +import com.ningdatech.pmapi.performance.model.req.PerformanceAppraisalListReq; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalProjectVO; +import com.ningdatech.pmapi.performance.model.vo.PerformanceAppraisalVO; +import com.ningdatech.pmapi.performance.service.*; +import com.ningdatech.pmapi.portrait.service.IProjectTagService; +import com.ningdatech.pmapi.projectlib.enumeration.ProjectTypeEnum; +import com.ningdatech.pmapi.projectlib.model.entity.Project; +import com.ningdatech.pmapi.projectlib.service.IProjectService; +import com.ningdatech.pmapi.sys.model.entity.Role; +import com.ningdatech.pmapi.sys.service.IRoleService; +import com.ningdatech.pmapi.user.security.auth.model.UserInfoDetails; +import com.ningdatech.pmapi.user.util.LoginUserUtil; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * VerifyManage + * @return + * @author CMM + * @since 2023/08/10 8:55 + */ +@Component +@Slf4j +@AllArgsConstructor +public class VerifyManage { + + private final IPerformanceAppraisalService performanceAppraisalService; + private final IPerformanceAppraisalProjectService performanceAppraisalProjectService; + private final IProjectService projectService; + private final IRoleService roleService; + private final IPerformanceIndicatorProjectTemplateService indicatorProjectTemplateService; + private final TemplateDetailBuildHelper templateDetailBuildHelper; + private final IPerformanceIndicatorProjectTemplateDetailService indicatorProjectTemplateDetailService; + private final IProjectTagService projectTagService; + private final IPerformanceAppraisalScoreInfoService performanceAppraisalScoreInfoService; + private final IPerformanceAppraisalProjectGroupService groupService; + /** + * 核查-评价计划列表 + * @param req + * @return + */ + public PageVo list(PerformanceAppraisalListReq req) { + UserInfoDetails user = LoginUserUtil.loginUserDetail(); + String employeeCode = user.getEmployeeCode(); + // 获取当前登录用户的角色列表,只有专家核查人员才能查看该列表 + List userRoleList = user.getUserRoleList(); + List roleIdList = userRoleList.stream().map(Role::getId).collect(Collectors.toList()); + Role role = roleService.getOne(Wrappers.lambdaQuery(Role.class) + .eq(Role::getName, RoleEnum.EXPERT.getDesc())); + if (Objects.isNull(role)){ + throw new BizException("登录用户没有复评员角色!"); + } + + // 登录用户不是专家,不能查看核查计划列表 + if (!roleIdList.contains(role.getId())){ + return PageVo.empty(); + } + + // 从绩效评价 分组表中获取当前登录专家所在的分组信息 + List groups = Lists.newArrayList(); + List projectGroups = groupService.list(); + for (PerformanceAppraisalProjectGroup projectGroup : projectGroups) { + String verificationUsers = projectGroup.getVerificationUsers(); + if (verificationUsers.contains(StrPool.COMMA)){ + if (verificationUsers.contains(employeeCode)){ + groups.add(projectGroup); + } + } else if (verificationUsers.equals(employeeCode)) { + groups.add(projectGroup); + } + } + // 当前登录专家没有绩效分组信息 + if (CollUtil.isEmpty(groups)){ + return PageVo.empty(); + } + + // 获取分组所在的评价计划ID + List appraisalIds = groups.stream().map(PerformanceAppraisalProjectGroup::getAppraisalId).collect(Collectors.toList()); + // 因为同一个核查人员只能出现在一个计划的一个分组中,所以分组信息可按照评价计划ID进行分组 + Map groupMap = groups.stream().collect(Collectors.toMap(PerformanceAppraisalProjectGroup::getAppraisalId, g -> g)); + // 获取核查计划列表 + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(PerformanceAppraisal.class) + .in(PerformanceAppraisal::getId,appraisalIds) + .orderByDesc(PerformanceAppraisal::getUpdateOn); + performanceAppraisalService.page(page,wrapper); + + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalVO.class); + PerformanceAppraisalProjectGroup group = groupMap.get(p.getId()); + if (Objects.nonNull(group)) { + vo.setReAppraisalGroupId(group.getId()); + vo.setReAppraisalGroupName(group.getName()); + } + return vo; + }).collect(Collectors.toList()); + return PageVo.of(res,page.getTotal()); + } + + /** + * 是否可以核查 + * + * @param employeeCode + * @param projectCode + * @param appraisalId + * @return + */ + private Boolean checkCanVerify(String employeeCode, String projectCode, Long appraisalId) { + + // 首次核查(核查打分信息为空) + // 从绩效评价打分信息表中查询打分类型为专家核查、打分人员为当前登录专家用户的打分信息 + // 如果没有相关的打分信息,说明是当前登录复评用户是首次核查 + List scoreInfos = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode()) + .eq(PerformanceAppraisalScoreInfo::getAppraisalId,appraisalId) + .eq(PerformanceAppraisalScoreInfo::getAppraisalProjectCode,projectCode) + .eq(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode, employeeCode)); + if (CollUtil.isEmpty(scoreInfos)){ + return true; + } + return Boolean.FALSE; + } + + public PageVo groupProjectList(Long groupId, PerformanceAppraisalListReq req) { + + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String employeeCode = userDetail.getEmployeeCode(); + + // 获取分组内的项目信息 + PerformanceAppraisalProjectGroup projectGroup = groupService.getById(groupId); + String projectCodes = projectGroup.getProjectCodes(); + Long appraisalId = projectGroup.getAppraisalId(); + VUtils.isTrue(StringUtils.isBlank(projectCodes)).throwMessage("分组内项目信息不存在!"); + List projectCodeList = Arrays.stream(projectCodes.split(StrPool.COMMA)).collect(Collectors.toList()); + + // 筛选出分组内已完成复评的评价项目信息 + List appraisalProjects = performanceAppraisalProjectService.list(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .in(PerformanceAppraisalProject::getProjectCode, projectCodeList) + .eq(PerformanceAppraisalProject::getIsCompleteReAppraisal, Boolean.TRUE)); + // 分组内已完成复评的项目信息不存在 + if (CollUtil.isEmpty(appraisalProjects)){ + return PageVo.empty(); + } + List proCodeList = appraisalProjects.stream().map(PerformanceAppraisalProject::getProjectCode).collect(Collectors.toList()); + Map appraisalProjectMap = appraisalProjects.stream().collect(Collectors.toMap(PerformanceAppraisalProject::getProjectCode, p -> p)); + + Page page = req.page(); + LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(Project.class) + .in(Project::getProjectCode, proCodeList) + .eq(Project::getNewest, Boolean.TRUE) + .like(StringUtils.isNotBlank(req.getProjectName()),Project::getProjectName,req.getProjectName()); + projectService.page(page,wrapper); + + // 分组内项目信息不存在 + if (CollUtil.isEmpty(page.getRecords())){ + return PageVo.empty(); + } + + List res = page.getRecords().stream().map(p -> { + PerformanceAppraisalProjectVO vo = BeanUtil.copyProperties(p, PerformanceAppraisalProjectVO.class); + PerformanceAppraisalProject appraisalProject = appraisalProjectMap.get(p.getProjectCode()); + BeanUtil.copyProperties(appraisalProject, vo); + vo.setProjectId(appraisalProject.getProjectId()); + vo.setProjectTypeName(ProjectTypeEnum.getDesc(p.getProjectType())); + vo.setCanVerify(checkCanVerify(employeeCode,appraisalProject.getProjectCode(),appraisalId)); + // 如果登录用户是核查组长,该项目可填写整改意见 + String verifyLeader = projectGroup.getVerifyLeader(); + if (employeeCode.equals(verifyLeader)){ + vo.setCanRectify(Boolean.TRUE); + } + return vo; + }) + .collect(Collectors.toList()); + return PageVo.of(res,page.getTotal()); + } + + @Transactional(rollbackFor = Exception.class) + public String submitVerify(ProjectAppraisalDTO param) { + UserInfoDetails userDetail = LoginUserUtil.loginUserDetail(); + String employeeCode = userDetail.getEmployeeCode(); + String username = userDetail.getUsername(); + Long appraisalId = param.getAppraisalId(); + Long appraisalProjectId = param.getAppraisalProjectId(); + String appraisalProjectCode = param.getAppraisalProjectCode(); + List appraisalInfoList = param.getAppraisalInfoList(); + Long groupId = param.getGroupId(); + PerformanceAppraisalProjectGroup group = groupService.getById(groupId); + + // 获取评价项目 + PerformanceAppraisalProject appraisalProject = performanceAppraisalProjectService.getOne(Wrappers.lambdaQuery(PerformanceAppraisalProject.class) + .eq(PerformanceAppraisalProject::getAppraisalId, appraisalId) + .eq(PerformanceAppraisalProject::getProjectCode,appraisalProjectCode) + .eq(PerformanceAppraisalProject::getProjectId, appraisalProjectId)); + + List ids = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getProjectTemplateDetailId) + .collect(Collectors.toList()); + // 查出项目模版详情信息 + List detailList = indicatorProjectTemplateDetailService.list(Wrappers.lambdaQuery(PerformanceIndicatorProjectTemplateDetail.class) + .in(PerformanceIndicatorProjectTemplateDetail::getId, ids)); + if (CollUtil.isEmpty(detailList)){ + throw new BizException("评价指标不存在!"); + } + Map detailMap = detailList.stream().collect(Collectors.toMap(PerformanceIndicatorProjectTemplateDetail::getId, d -> d)); + List scoreInfos = appraisalInfoList.stream().map(a -> { + PerformanceIndicatorProjectTemplateDetail templateDetail = detailMap.get(a.getProjectTemplateDetailId()); + BigDecimal score = a.getScore(); + BigDecimal indexScore = templateDetail.getIndexScore(); + if (score.compareTo(indexScore) > 0 || score.compareTo(BigDecimal.ZERO) < 0){ + throw new BizException("核查得分必须大于等于0且小于等于指标分值!"); + } + // 保存核查分数信息 + PerformanceAppraisalScoreInfo scoreInfo = new PerformanceAppraisalScoreInfo(); + scoreInfo.setAppraisalBasis(a.getAppraisalBasis()); + scoreInfo.setAppraisalScore(a.getScore()); + scoreInfo.setAppraisalBasisAppendix(a.getAppraisalBasisAppendix()); + scoreInfo.setAppraisalType(AppraisalTypeEnum.EXPERT_VERIFY.getCode()); + scoreInfo.setTemplateDetailId(templateDetail.getId()); + scoreInfo.setTemplateId(templateDetail.getTemplateId()); + scoreInfo.setAppraisalEmployeeCode(employeeCode); + scoreInfo.setAppraisalEmployeeName(username); + scoreInfo.setAppraisalId(appraisalId); + scoreInfo.setAppraisalProjectId(appraisalProjectId); + scoreInfo.setAppraisalProjectCode(appraisalProjectCode); + scoreInfo.setCreateOn(LocalDateTime.now()); + scoreInfo.setCreateBy(username); + return scoreInfo; + }).collect(Collectors.toList()); + + if (performanceAppraisalScoreInfoService.saveBatch(scoreInfos)){ + // 计算核查总分并保存 + BigDecimal verifyTotalScore = appraisalInfoList.stream() + .map(ProjectAppraisalInfoDTO::getScore) + .filter(Objects::nonNull) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal lastVerifyTotalScore; + // 判断项目所在分组内其他复评人员是否已经打分 + if (Objects.nonNull(appraisalProject.getVerifyTotalScore())){ + // 已经进行了核查,计算两个分值的平均分 + BigDecimal add = verifyTotalScore.add(appraisalProject.getReAppraisalTotalScore()); + lastVerifyTotalScore = add.divide(BigDecimal.valueOf(2)); + }else { + // 还没有进行过复评 + lastVerifyTotalScore = verifyTotalScore; + } + appraisalProject.setReAppraisalTotalScore(lastVerifyTotalScore); + // 取最新地核查打分时间 + appraisalProject.setVerifyScoreTime(LocalDateTime.now()); + // 判断当前核查人是否为该评价项目所在分组的核查人员中的最后一个核查人 + judgeCompleteVerify(group, appraisalProject); + appraisalProject.setUpdateOn(LocalDateTime.now()); + appraisalProject.setUpdateBy(username); + if (Objects.nonNull(param.getIsRectify()) || + StringUtils.isNotBlank(param.getRectifyOpinion())) { + appraisalProject.setIsRectify(param.getIsRectify()); + appraisalProject.setRectifyOpinion(param.getRectifyOpinion()); + } + performanceAppraisalProjectService.updateById(appraisalProject); + return "提交成功"; + } + return "提交失败"; + } + + private void judgeCompleteVerify(PerformanceAppraisalProjectGroup group, PerformanceAppraisalProject appraisalProject) { + Map> scoreInfoMap = performanceAppraisalScoreInfoService.list(Wrappers.lambdaQuery(PerformanceAppraisalScoreInfo.class) + .eq(PerformanceAppraisalScoreInfo::getAppraisalType, AppraisalTypeEnum.EXPERT_VERIFY.getCode())) + .stream().collect(Collectors.groupingBy(PerformanceAppraisalScoreInfo::getAppraisalEmployeeCode)); + + List verifyUsers = Lists.newArrayList(); + String verificationUsers = group.getVerificationUsers(); + String projectCodes = group.getProjectCodes(); + if (verificationUsers.contains(StrPool.COMMA)){ + verifyUsers = Arrays.asList(verificationUsers.split(StrPool.COMMA)); + }else { + verifyUsers.add(verificationUsers); + } + List users = Lists.newArrayList(); + for (String verifyUser : verifyUsers) { + // 获取分组内核查人员对分组内项目的核查分数信息 + List scoreInfoList = scoreInfoMap.get(verifyUser); + if (CollUtil.isNotEmpty(scoreInfoList)){ + List projectIdList = scoreInfoList.stream() + .map(PerformanceAppraisalScoreInfo::getAppraisalProjectId) + .collect(Collectors.toList()); + List proCodes = projectService.listByIds(projectIdList).stream() + .map(Project::getProjectCode) + .collect(Collectors.toList()); + // 当前登录用户所在分组的核查人员 对分组内所有项目进行了核查 + if (CollUtil.isNotEmpty(proCodes)){ + String join = String.join(StrPool.COMMA, proCodes); + if (join.equals(projectCodes)) { + users.add(verifyUser); + } + } + } + } + if (CollUtil.isNotEmpty(users)) { + String join = String.join(StrPool.COMMA, users); + if (join.equals(verificationUsers)) { + appraisalProject.setIsCompleteVerify(Boolean.TRUE); + } + } + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.java new file mode 100644 index 0000000..e262a88 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.performance.mapper; + +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * Mapper 接口 + *

+ * + * @author CMM + * @since 2023-08-09 + */ +public interface PerformanceAppraisalScoreInfoMapper extends BaseMapper { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.xml new file mode 100644 index 0000000..b5be0ac --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/mapper/PerformanceAppraisalScoreInfoMapper.xml @@ -0,0 +1,5 @@ + + + + + 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 index e78b1be..4799285 100644 --- 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 @@ -43,4 +43,7 @@ public class PerformanceAppraisalProjectGroupSaveDTO implements Serializable { @ApiModelProperty("核查人员") private List verificationUsers; + + @ApiModelProperty("核查组长") + private String verifyLeader; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java index 5cc508e..31e646f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/PerformanceIndicatorProjectTemplateSaveDTO.java @@ -48,4 +48,7 @@ public class PerformanceIndicatorProjectTemplateSaveDTO implements Serializable @ApiModelProperty("附加绩效指标详情") private List additionalIndexDetails; + + @ApiModelProperty("项目标签信息") + private List projectTagIds; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java new file mode 100644 index 0000000..0d0be8d --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalDTO.java @@ -0,0 +1,42 @@ +package com.ningdatech.pmapi.performance.model.dto; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +/** + * 项目评价信息 + * @return + * @author CMM + * @since 2023/08/08 18:46 + */ +@Data +public class ProjectAppraisalDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("评价项目ID") + private Long appraisalProjectId; + + @ApiModelProperty("评价项目Code") + private String appraisalProjectCode; + + @ApiModelProperty("评价计划ID") + private Long appraisalId; + + @ApiModelProperty("项目模板指标详情评价信息集合") + private List appraisalInfoList; + + @ApiModelProperty("项目是否需要整改") + private Boolean isRectify; + + @ApiModelProperty("整改意见") + private String rectifyOpinion; + + @ApiModelProperty("评价项目所在分组ID") + private Long groupId; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalInfoDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalInfoDTO.java new file mode 100644 index 0000000..f6a839b --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/dto/ProjectAppraisalInfoDTO.java @@ -0,0 +1,37 @@ +package com.ningdatech.pmapi.performance.model.dto; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 项目评价信息 + * @return + * @author CMM + * @since 2023/08/08 18:46 + */ +@Data +public class ProjectAppraisalInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("项目模板指标详情ID") + private Long projectTemplateDetailId; + + @ApiModelProperty("评价得分") + @NotNull(message = "得分不能为空!") + private BigDecimal score; + + @ApiModelProperty("评价依据") + @Size(max = 500) + private String appraisalBasis; + + @ApiModelProperty("评价依据附件") + private String appraisalBasisAppendix; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java index cebda6d..eb11971 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalProject.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.performance.model.entity; +import com.alibaba.fastjson.annotation.JSONField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -8,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.time.LocalDateTime; /** @@ -41,7 +43,7 @@ public class PerformanceAppraisalProject implements Serializable { @ApiModelProperty("项目编码") private String projectCode; - @ApiModelProperty("是否核查") + @ApiModelProperty("是否复评") private Boolean isReAppraisal; @ApiModelProperty("自评开始时间") @@ -49,4 +51,38 @@ public class PerformanceAppraisalProject implements Serializable { @ApiModelProperty("自评结束时间") private LocalDateTime selfAppraisalEnd; + + @ApiModelProperty("自评总分") + private BigDecimal selfAppraisalTotalScore; + + @ApiModelProperty("自评打分时间") + private LocalDateTime selfAppraisalScoreTime; + + @ApiModelProperty("复评总分") + private BigDecimal reAppraisalTotalScore; + + @ApiModelProperty("复评打分时间") + private LocalDateTime reAppraisalScoreTime; + + @ApiModelProperty("核查总分") + private BigDecimal verifyTotalScore; + + @ApiModelProperty("核查打分时间") + private LocalDateTime verifyScoreTime; + + @ApiModelProperty("项目是否需要整改") + private Boolean isRectify; + + @ApiModelProperty("整改意见") + private String rectifyOpinion; + + @ApiModelProperty("是否完成自评") + private Boolean isCompleteSelfAppraisal; + + @ApiModelProperty("是否完成复评") + private Boolean isCompleteReAppraisal; + + @ApiModelProperty("是否完成核查") + private Boolean isCompleteVerify; + } 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 index 72f4672..9027e46 100644 --- 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 @@ -46,4 +46,7 @@ public class PerformanceAppraisalProjectGroup implements Serializable { @ApiModelProperty("核查人员") private String verificationUsers; + + @ApiModelProperty("核查组长") + private String verifyLeader; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java new file mode 100644 index 0000000..12e9fb3 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceAppraisalScoreInfo.java @@ -0,0 +1,73 @@ +package com.ningdatech.pmapi.performance.model.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + *

+ * + *

+ * + * @author CMM + * @since 2023-08-09 + */ +@Data +@TableName("nd_performance_appraisal_score_info") +@ApiModel(value = "NdPerformanceAppraisalScoreInfo对象", description = "") +public class PerformanceAppraisalScoreInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("主键") + private Long id; + + @ApiModelProperty("创建时间") + private LocalDateTime createOn; + + @ApiModelProperty("创建人") + private String createBy; + + @ApiModelProperty("创建时间") + private LocalDateTime updateOn; + + @ApiModelProperty("更新人") + private String updateBy; + + @ApiModelProperty("项目评价计划模板ID") + private Long templateId; + + @ApiModelProperty("项目评价计划模板详情ID") + private Long templateDetailId; + + @ApiModelProperty("评价得分") + private BigDecimal appraisalScore; + + @ApiModelProperty("评价依据") + private String appraisalBasis; + + @ApiModelProperty("评价依据附件") + private String appraisalBasisAppendix; + + @ApiModelProperty("评价人员code") + private String appraisalEmployeeCode; + + @ApiModelProperty("评价人员姓名") + private String appraisalEmployeeName; + + @ApiModelProperty("评价类型 1 单位自评、2 复评人员复评、3 专家核查") + private Integer appraisalType; + + @ApiModelProperty("评价计划ID") + private Long appraisalId; + + @ApiModelProperty("评价项目ID") + private Long appraisalProjectId; + + @ApiModelProperty("评价项目Code") + private String appraisalProjectCode; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java index 55b92d9..667f34f 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/entity/PerformanceIndicatorProjectTemplate.java @@ -10,6 +10,7 @@ import lombok.Data; import java.io.Serializable; import java.time.LocalDateTime; +import java.util.List; /** * @Classname PerformanceIndicatorTemplate @@ -54,9 +55,6 @@ public class PerformanceIndicatorProjectTemplate implements Serializable { @ApiModelProperty("项目资金范围 1.500万元以下、2.500-2000万元,3.2000万元及以上") private Integer amountRange; - @ApiModelProperty("项目标签ID") - private Long projectTagId; - - @ApiModelProperty("项目标签名称") - private String projectTagName; + @ApiModelProperty("项目标签信息") + private String projectTagIds; } 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 index 333e8a4..ad6cac2 100644 --- 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 @@ -43,4 +43,7 @@ public class PerformanceAppraisalProjectGroupVO implements Serializable { @ApiModelProperty("核查人员") private List verificationUsers; + + @ApiModelProperty("核查组长") + private UserFullInfoDTO verifyLeader; } 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 c96768b..9db9130 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 @@ -1,7 +1,6 @@ package com.ningdatech.pmapi.performance.model.vo; import com.alibaba.fastjson.annotation.JSONField; -import com.ningdatech.pmapi.projectlib.model.vo.ProjectDetailVO; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -9,7 +8,6 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.time.LocalDateTime; -import java.util.List; /** * @Classname PerformanceAppraisalProjectVO @@ -24,7 +22,7 @@ public class PerformanceAppraisalProjectVO implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("项目ID") - private Long id; + private Long projectId; @ApiModelProperty("项目编码") private String projectCode; @@ -53,6 +51,15 @@ public class PerformanceAppraisalProjectVO implements Serializable { @ApiModelProperty("是否可自评") private Boolean canSelfAppraisal = Boolean.FALSE; + @ApiModelProperty("是否可复评") + private Boolean canReAppraisal = Boolean.FALSE; + + @ApiModelProperty("是否可核查") + private Boolean canVerify = Boolean.FALSE; + + @ApiModelProperty("是否可整改") + private Boolean canRectify = Boolean.FALSE; + @ApiModelProperty("自评开始时间") private LocalDateTime selfAppraisalStart; @@ -60,11 +67,36 @@ public class PerformanceAppraisalProjectVO implements Serializable { private LocalDateTime selfAppraisalEnd; @ApiModelProperty("自评总分") - private BigDecimal selfAppraisalScore; + private BigDecimal selfAppraisalTotalScore; + + @ApiModelProperty("自评打分时间") + @JSONField(format = "yyyy-MM-dd HH:mm") + private LocalDateTime selfAppraisalScoreTime; + + @ApiModelProperty("复评总分") + private BigDecimal reAppraisalTotalScore; - @ApiModelProperty("打分时间") + @ApiModelProperty("复评打分时间") @JSONField(format = "yyyy-MM-dd HH:mm") - private LocalDateTime scoreTime; + private LocalDateTime reAppraisalScoreTime; + + @ApiModelProperty("核查总分") + private BigDecimal verifyTotalScore; + + @ApiModelProperty("核查打分时间") + @JSONField(format = "yyyy-MM-dd HH:mm") + private LocalDateTime verifyScoreTime; + + @ApiModelProperty("项目是否需要整改") + private Boolean isRectify; + + @ApiModelProperty("整改意见") + private String rectifyOpinion; + + @ApiModelProperty("评价计划ID") + private Long appraisalId; + @ApiModelProperty("所在分组ID") + private Long groupId; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java index f93f321..25db559 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/PerformanceAppraisalVO.java @@ -51,4 +51,17 @@ public class PerformanceAppraisalVO implements Serializable { @ApiModelProperty("备注") private String remark; + + @ApiModelProperty("复评分组ID") + private Long reAppraisalGroupId; + + @ApiModelProperty("复评分组名称") + private String reAppraisalGroupName; + + @ApiModelProperty("核查分组ID") + private Long verifyGroupId; + + @ApiModelProperty("核查分组名称") + private String verifyGroupName; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java new file mode 100644 index 0000000..0b26c1e --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectAppraisalIndexDetailVO.java @@ -0,0 +1,52 @@ +package com.ningdatech.pmapi.performance.model.vo; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 项目评价指标 + * @return + * @author CMM + * @since 2023/08/08 8:55 + */ +@Data +@ApiModel(value = "项目自(复)评项目指标模版详情", description = "项目自(复)评项目指标模版详情") +public class ProjectAppraisalIndexDetailVO implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("项目名称") + private String projectName; + + @ApiModelProperty("申报单位") + private String buildOrgName; + + @ApiModelProperty("项目状态") + private Integer projectStatus; + + @ApiModelProperty("批复金额") + private BigDecimal approvalAmount; + + @ApiModelProperty("预算年度") + private Integer projectYear; + + @ApiModelProperty("绩效指标详情") + private List templateDetails; + + @ApiModelProperty("附加绩效指标详情") + private List additionalIndexDetails; + + @ApiModelProperty("自评总得分") + private BigDecimal selfAppraisalTotalScore; + + @ApiModelProperty("复评总得分") + private BigDecimal reAppraisalTotalScore; + + @ApiModelProperty("核查总得分") + private BigDecimal verifyTotalScore; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectIndexTemplateVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectIndexTemplateVO.java index a344072..fad699c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectIndexTemplateVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectIndexTemplateVO.java @@ -50,15 +50,14 @@ public class ProjectIndexTemplateVO implements Serializable { @ApiModelProperty("状态 0关闭 1开启") private Integer status; + @ApiModelProperty("项目标签信息") + private List projectTagIds; + @ApiModelProperty("绩效指标详情") private List templateDetails; @ApiModelProperty("附加绩效指标详情") private List additionalIndexDetails; - @ApiModelProperty("项目标签ID") - private Long projectTagId; - @ApiModelProperty("项目标签名称") - private String projectTagName; } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java index c4d4b1d..2166577 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/model/vo/ProjectTemplateDetailVO.java @@ -1,5 +1,6 @@ package com.ningdatech.pmapi.performance.model.vo; +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -7,6 +8,7 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; +import java.util.Map; /** * @Classname PerformanceIndicatorProjectTemplateDetail @@ -20,6 +22,9 @@ public class ProjectTemplateDetailVO implements Serializable { private static final long serialVersionUID = 1L; + @ApiModelProperty("id") + private Long id; + @ApiModelProperty("关联模板ID") private Long templateId; @@ -52,4 +57,20 @@ public class ProjectTemplateDetailVO implements Serializable { @ApiModelProperty("子指标") private List children; + + @ApiModelProperty("自评分数信息") + private List selfAppraisalScoreInfo; + + @ApiModelProperty("复评分数信息") + private Map> reAppraisalScoreInfo; + + @ApiModelProperty("复评得分信息") + private Map reAppraisalTotalScoreInfo; + + @ApiModelProperty("核查分数信息") + private Map> verifyScoreInfo; + + @ApiModelProperty("核查得分信息") + private Map verifyTotalScoreInfo; + } diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalScoreInfoService.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalScoreInfoService.java new file mode 100644 index 0000000..d9e0ee6 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/IPerformanceAppraisalScoreInfoService.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.performance.service; + +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 服务类 + *

+ * + * @author CMM + * @since 2023-08-09 + */ +public interface IPerformanceAppraisalScoreInfoService extends IService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalScoreInfoServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalScoreInfoServiceImpl.java new file mode 100644 index 0000000..5b6ad52 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/performance/service/impl/PerformanceAppraisalScoreInfoServiceImpl.java @@ -0,0 +1,20 @@ +package com.ningdatech.pmapi.performance.service.impl; + +import com.ningdatech.pmapi.performance.model.entity.PerformanceAppraisalScoreInfo; +import com.ningdatech.pmapi.performance.mapper.PerformanceAppraisalScoreInfoMapper; +import com.ningdatech.pmapi.performance.service.IPerformanceAppraisalScoreInfoService; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + *

+ * 服务实现类 + *

+ * + * @author CMM + * @since 2023-08-09 + */ +@Service +public class PerformanceAppraisalScoreInfoServiceImpl extends ServiceImpl implements IPerformanceAppraisalScoreInfoService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/contants/WpsContant.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/contants/WpsContant.java new file mode 100644 index 0000000..ad581dd --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/contants/WpsContant.java @@ -0,0 +1,16 @@ +package com.ningdatech.pmapi.wps.contants; + +/** + * @Classname WpsContant + * @Description + * @Date 2023/8/15 14:09 + * @Author PoffyZhang + */ +public interface WpsContant { + + String WPS_CONVERT_URL_ONLINE = "http://10.53.157.47"; + String FIX_FILE_PATH = "/opt/file/"; + String PDF_PATH = "/opt/file/offices2pdf.pdf"; + String PDF_CONTENT_TYPE = "application/pdf"; + String PDF_NAME = "offices2pdf.pdf"; +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/controller/WpsConvertController.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/controller/WpsConvertController.java new file mode 100644 index 0000000..c229757 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/controller/WpsConvertController.java @@ -0,0 +1,82 @@ +package com.ningdatech.pmapi.wps.controller; + +import com.ningdatech.irs.service.IRefreshTokenService; +import com.ningdatech.pmapi.common.util.CryptUtils; +import com.ningdatech.pmapi.common.util.HttpUtil; +import com.ningdatech.pmapi.wps.manage.WpsConvertManage; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.client.RestTemplate; + +import javax.servlet.http.HttpServletResponse; +import java.security.NoSuchAlgorithmException; +import java.util.Objects; + +/** + * @Classname WpsConvertController + * @Description + * @Date 2023/8/14 13:58 + * @Author PoffyZhang + */ +@Slf4j +@RestController +@Api(tags = "待办中心控制器") +@RequestMapping("/api/v1/wps-convert") +public class WpsConvertController { + @Autowired + private IRefreshTokenService refreshTokenService; + + @Autowired + private WpsConvertManage wpsConvertManage; + + + @Value("${irs.interface-refresh.request-token-url}") + private String govRequestTokenUrl; + @Value("${irs.interface-refresh.refresh-token-url}") + private String govRefreshTokenUrl; + + @GetMapping("/office2pdf") + public String office2pdf(){ + return wpsConvertManage.offs2Pdf(); + } + + @GetMapping("/downloadToPdfStream") + public void downloadToPdfStream(@RequestParam Long fileId, HttpServletResponse response){ + wpsConvertManage.downloadToPdfStream(fileId,response); + } + + @GetMapping("/test-core") + public String testCore() throws NoSuchAlgorithmException { + long timestamp = System.currentTimeMillis(); + String appSecret = "496f0f2a19994f76b4fd9dae087366c7"; + String appKey = "A331101453557202109017383"; + + String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, + "Fc3re2cq7r64Qfa7", HttpMethod.POST.name()); + String sign = CryptUtils.MD5Encode(appKey + secret + timestamp); + HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory(); + RestTemplate restTemplate; + if(Objects.nonNull(factory)){ + restTemplate = new RestTemplate(factory); + }else{ + restTemplate = new RestTemplate(); + } + + String url = "https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm?" + + "dingCode=&matterName=&oid=&useState=1&limit=1000&page=1" + + "&appKey=" + appKey + "&sign=" + sign + "&requestTime=" + timestamp; + + ResponseEntity forEntity = restTemplate.getForEntity(url, String.class); + log.info(forEntity.getBody()); + return forEntity.getBody(); + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java new file mode 100644 index 0000000..e8fc4ea --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/manage/WpsConvertManage.java @@ -0,0 +1,159 @@ +package com.ningdatech.pmapi.wps.manage; + +import cn.hutool.core.util.CharsetUtil; +import com.aliyun.oss.OSS; +import com.aliyun.oss.OSSClientBuilder; +import com.aliyun.oss.model.OSSObject; +import com.aliyun.oss.model.ObjectMetadata; +import com.ningdatech.file.properties.FileServerProperties; +import com.ningdatech.file.service.FileService; +import com.ningdatech.pmapi.wps.contants.WpsContant; +import com.suwell.ofd.custom.agent.AtomAgent; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URLEncoder; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; + +/** + * @Classname WpsConvertManage + * @Description + * @Date 2023/8/14 13:42 + * @Author PoffyZhang + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class WpsConvertManage { + + @Resource + private FileService fileService; + + private final FileServerProperties fileServerProperties; + +// HTTPAgent ha = new HTTPAgent("http://127.0.0.1:8090"); + //2、定义方法实现 多个文件合并转为1个pdf文件 + public String offs2Pdf() { + AtomAgent ha = new AtomAgent("http://10.53.157.47"); + + try { + + //2-1、传参文件对象转换输出PDF文件 + //1)、定义集合,存储待转换的原文件 + List fileList =new ArrayList(); + //2)、定义转换后的pdf文件输出流 + OutputStream out = null; + //3)、添加原文件到集合 + fileList.add(new File("/temp/111.xlsx")); +// fileList.add(new File("D:/cs.doc")); +// fileList.add(new File("D:/a.pdf")); +// fileList.add(new File("D:\\555.ofd")); + //4)、赋值转换后的pdf文件输出流 + out=new FileOutputStream(new File("/temp/offices2_pdf.pdf")); + //5)、调用方法,执行将多个文件转为pdf文件 + ha.OFDToPDF(fileList, out); + + //2-2、传参文件流转换输出PDF文件(与2-1二选一即可) + //1)、定义集合,存储待转换的原文件(支持传文件流) +// Param[] params = new Param[] { +// new Param(PackEntry.wrap(new FileInputStream("D:\\temp\\111.ofd")), "ofd"), +// new Param(PackEntry.wrap(new FileInputStream("D:\\2.ofd")), "ofd"), +// new Param(PackEntry.wrap(new FileInputStream("D:\\T3.txt")), "txt") +// }; + //2)、赋值转换后的pdf文件输出流 +// out=new FileOutputStream(new File("D:/convert/offices_pdf.pdf")); + //3)、调用方法,执行将多个文件转为pdf文件 +// ha.OFDToPDF(params,out); + return "转换成功"; + } catch (Exception e) { + log.error(e.getMessage()); + } finally { + try { + //2-6、关闭资源 + ha.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return "转换失败"; + } + + public void downloadToPdfStream(Long fileId, HttpServletResponse response) { + com.ningdatech.file.entity.File file = fileService.getById(fileId); + downloadAndToPdf(file, response); + } + + private void downloadAndToPdf(com.ningdatech.file.entity.File file, HttpServletResponse response) { + OSS oss = new OSSClientBuilder().build(fileServerProperties.getAli().getEndpoint(), fileServerProperties.getAli().getAccessKeyId(), fileServerProperties.getAli().getAccessKeySecret()); + AtomAgent ha = new AtomAgent(WpsContant.WPS_CONVERT_URL_ONLINE); + try (OSSObject ossObject = oss.getObject(file.getBucket(), file.getPath()); + InputStream stream = ossObject.getObjectContent(); + ServletOutputStream outputStream = response.getOutputStream()) { + String filePath = WpsContant.FIX_FILE_PATH + file.getOriginalFileName(); + convert(stream,filePath); + //转换PDF + List fileList =new ArrayList(); + //2)、定义转换后的pdf文件输出流 + OutputStream out = null; + //3)、添加原文件到集合 + fileList.add(new File(filePath)); + //4)、赋值转换后的pdf文件输出流 + File pdfFile = new File(WpsContant.PDF_PATH); + out = new FileOutputStream(pdfFile); + //5)、调用方法,执行将多个文件转为pdf文件 + ha.OFDToPDF(fileList, out); + FileInputStream fileInputStream = new FileInputStream(pdfFile); + + ObjectMetadata metadata = ossObject.getObjectMetadata(); + response.setContentType(WpsContant.PDF_CONTENT_TYPE); + String fileName = URLEncoder.encode(WpsContant.PDF_NAME, CharsetUtil.UTF_8); + response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + fileName); + byte[] bytes = new byte[4096]; + int read; + while ((read = fileInputStream.read(bytes)) != -1) { + outputStream.write(bytes, 0, read); + } + outputStream.flush(); + for(File f : fileList){ + //用完就删 + f.deleteOnExit(); + } + }catch (Exception e){ + log.error(e.getMessage()); + }finally { + oss.shutdown(); + try { + ha.close(); + } catch (IOException e) { + log.error(e.getMessage()); + } + } + } + + public static void convert(InputStream inputStream, String filePath) { + try { + File file = new File(filePath); + FileOutputStream outputStream = new FileOutputStream(file); + + int bytesRead; + byte[] buffer = new byte[1024]; + + while ((bytesRead = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, bytesRead); + } + + outputStream.close(); + inputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/IConvertService.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/IConvertService.java new file mode 100644 index 0000000..31ae6a7 --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/IConvertService.java @@ -0,0 +1,5 @@ +package com.ningdatech.pmapi.wps.service; + +public interface IConvertService { + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/impl/ConvertService.java b/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/impl/ConvertService.java new file mode 100644 index 0000000..aef699a --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/wps/service/impl/ConvertService.java @@ -0,0 +1,19 @@ +package com.ningdatech.pmapi.wps.service.impl; + +import com.ningdatech.pmapi.wps.service.IConvertService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +/** + * @Classname ConvertService + * @Description + * @Date 2023/8/15 10:56 + * @Author PoffyZhang + */ +@Service +@Slf4j +public class ConvertService implements IConvertService { + + + +} diff --git a/pmapi/src/main/resources/security/auth-dev.yml b/pmapi/src/main/resources/security/auth-dev.yml index f878360..5c76021 100644 --- a/pmapi/src/main/resources/security/auth-dev.yml +++ b/pmapi/src/main/resources/security/auth-dev.yml @@ -36,6 +36,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** ignore-csrf-urls: - /api/v1/user/auth/** - /v2/api-docs @@ -64,6 +65,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** role-map: "engineer": "project_manager": diff --git a/pmapi/src/main/resources/security/auth-pre.yml b/pmapi/src/main/resources/security/auth-pre.yml index f878360..5c76021 100644 --- a/pmapi/src/main/resources/security/auth-pre.yml +++ b/pmapi/src/main/resources/security/auth-pre.yml @@ -36,6 +36,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** ignore-csrf-urls: - /api/v1/user/auth/** - /v2/api-docs @@ -64,6 +65,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** role-map: "engineer": "project_manager": diff --git a/pmapi/src/main/resources/security/auth-prod.yml b/pmapi/src/main/resources/security/auth-prod.yml index f878360..5c76021 100644 --- a/pmapi/src/main/resources/security/auth-prod.yml +++ b/pmapi/src/main/resources/security/auth-prod.yml @@ -36,6 +36,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** ignore-csrf-urls: - /api/v1/user/auth/** - /v2/api-docs @@ -64,6 +65,7 @@ security: - /file/download - /api/v1/zwdd/pull/** - /api/v1/irs/** + - /api/v1/wps-convert/** role-map: "engineer": "project_manager": diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/irs/irsTest4.java b/pmapi/src/test/java/com/ningdatech/pmapi/irs/irsTest4.java new file mode 100644 index 0000000..9e0d31e --- /dev/null +++ b/pmapi/src/test/java/com/ningdatech/pmapi/irs/irsTest4.java @@ -0,0 +1,60 @@ +package com.ningdatech.pmapi.irs; + +import com.ningdatech.irs.service.IRefreshTokenService; +import com.ningdatech.pmapi.AppTests; +import com.ningdatech.pmapi.common.util.CryptUtils; +import com.ningdatech.pmapi.common.util.HttpUtil; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.web.client.RestTemplate; + +import javax.annotation.Resource; +import java.security.NoSuchAlgorithmException; +import java.util.Objects; + +/** + * @Classname irsTest3 + * @Description + * @Date 2023/7/25 9:52 + * @Author PoffyZhang + */ +@Slf4j +public class irsTest4 extends AppTests { + @Resource + private IRefreshTokenService refreshTokenService; + + @Value("${irs.interface-refresh.request-token-url}") + private String govRequestTokenUrl; + @Value("${irs.interface-refresh.refresh-token-url}") + private String govRefreshTokenUrl; + + @Test + public void test1() throws NoSuchAlgorithmException { + long timestamp = System.currentTimeMillis(); + String appSecret = "496f0f2a19994f76b4fd9dae087366c7"; + String appKey = "A331101453557202109017383"; + String dataName = "大数据管理局"; + + String secret = refreshTokenService.refreshToken(appKey, appSecret, govRequestTokenUrl, govRefreshTokenUrl, + "Fc3re2cq7r64Qfa7", HttpMethod.POST.name()); + String sign = CryptUtils.MD5Encode(appKey + secret + timestamp); + HttpComponentsClientHttpRequestFactory factory = HttpUtil.generateHttpRequestFactory(); + RestTemplate restTemplate; + if(Objects.nonNull(factory)){ + restTemplate = new RestTemplate(factory); + }else{ + restTemplate = new RestTemplate(); + } + + String url = "https://interface.zjzwfw.gov.cn/gateway/api/001008012012001/dataSharing/Fc3re2cq7r64Qfa7.htm?" + + "dingCode=&matterName=&oid=&useState=1&limit=1000&page=1" + + "&appKey=" + appKey + "&sign=" + sign + "&requestTime=" + timestamp; + + ResponseEntity forEntity = restTemplate.getForEntity(url, String.class); + System.out.println(forEntity.getBody()); + } +}