@@ -0,0 +1,33 @@ | |||
package com.hz.pm.api.projectlib.controller; | |||
import com.hz.pm.api.projectlib.manage.ProjectGovSystemReplaceInfoManage; | |||
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO; | |||
import lombok.RequiredArgsConstructor; | |||
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 java.util.List; | |||
/** | |||
* <p> | |||
* ProjectGovSystemReplaceInfoController | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 15:38 2024/3/20 | |||
*/ | |||
@RestController | |||
@RequestMapping("/api/v1/system-replace-info") | |||
@RequiredArgsConstructor | |||
public class ProjectGovSystemReplaceInfoController { | |||
private final ProjectGovSystemReplaceInfoManage systemReplaceInfoManage; | |||
@GetMapping("/all") | |||
public List<UnitProjectGovSystemReplaceVO> all(@RequestParam(required = false) String targetSystem) { | |||
return systemReplaceInfoManage.systemReplaceInfos(targetSystem); | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
package com.hz.pm.api.projectlib.manage; | |||
import cn.hutool.core.util.NumberUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; | |||
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO; | |||
import com.hz.pm.api.projectlib.model.vo.UnitProjectGovSystemReplaceVO.ProjectGovSystemReplaceVO; | |||
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; | |||
import com.hz.pm.api.projectlib.service.IProjectService; | |||
import com.hz.pm.api.user.helper.MhUnitCache; | |||
import com.hz.pm.api.user.model.dto.UnitDTO; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
import java.util.*; | |||
import java.util.stream.Collectors; | |||
/** | |||
* <p> | |||
* ProjectGovSystemReplaceInfoManage | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 15:40 2024/3/20 | |||
*/ | |||
@Component | |||
@RequiredArgsConstructor | |||
public class ProjectGovSystemReplaceInfoManage { | |||
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; | |||
private final IProjectService projectService; | |||
private final MhUnitCache mhUnitCache; | |||
public List<UnitProjectGovSystemReplaceVO> systemReplaceInfos(String targetSystem) { | |||
LambdaQueryWrapper<ProjectGovSystemReplaceInfos> pgsriQuery; | |||
if (StrUtil.isNotBlank(targetSystem)) { | |||
pgsriQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) | |||
.like(ProjectGovSystemReplaceInfos::getTargetSystem, targetSystem); | |||
} else { | |||
pgsriQuery = null; | |||
} | |||
List<ProjectGovSystemReplaceInfos> systemReplaceInfos = systemReplaceInfosService.list(pgsriQuery); | |||
if (systemReplaceInfos.isEmpty()) { | |||
return Collections.emptyList(); | |||
} | |||
Map<Long, List<ProjectGovSystemReplaceInfos>> projectSystemMap = CollUtils.group(systemReplaceInfos, | |||
ProjectGovSystemReplaceInfos::getProjectId); | |||
List<Project> projects = projectService.listByIds(projectSystemMap.keySet()); | |||
Map<Long, List<Project>> unitProjectMap = projects.stream() | |||
.filter(w -> NumberUtil.isNumber(w.getBuildOrgCode())) | |||
.collect(Collectors.groupingBy(w -> Long.parseLong(w.getBuildOrgCode()))); | |||
List<UnitProjectGovSystemReplaceVO> retList = new ArrayList<>(); | |||
unitProjectMap.forEach((unitId, tmpProjects) -> { | |||
UnitDTO unit = mhUnitCache.getById(unitId); | |||
UnitProjectGovSystemReplaceVO item = new UnitProjectGovSystemReplaceVO(); | |||
retList.add(item); | |||
item.setUnitName(unit == null ? "" : unit.getName()); | |||
item.setProjectSystemReplaces(new ArrayList<>()); | |||
for (Project proj : tmpProjects) { | |||
List<ProjectGovSystemReplaceInfos> replaceInfos = projectSystemMap.get(proj.getId()); | |||
if (replaceInfos == null) { | |||
continue; | |||
} | |||
ProjectGovSystemReplaceVO projectSystem = new ProjectGovSystemReplaceVO(); | |||
projectSystem.setProjectName(proj.getProjectName()); | |||
item.getProjectSystemReplaces().add(projectSystem); | |||
Map<Integer, List<ProjectGovSystemReplaceInfos>> replaceInfoGroup = CollUtils.group(replaceInfos, | |||
ProjectGovSystemReplaceInfos::getBatchNo); | |||
List<GovSystemReplaceInfoDTO> replaceInfoList = replaceInfoGroup.entrySet().stream() | |||
.sorted(Comparator.comparingInt(Map.Entry::getKey)) | |||
.map(w -> { | |||
List<ProjectGovSystemReplaceInfos> currBatchValues = w.getValue(); | |||
ProjectGovSystemReplaceInfos firstReplaceInfo = currBatchValues.get(0); | |||
GovSystemReplaceInfoDTO replaceInfo = new GovSystemReplaceInfoDTO(); | |||
replaceInfo.setReplaceType(firstReplaceInfo.getReplaceType()); | |||
replaceInfo.setTargetSystemName(firstReplaceInfo.getTargetSystem()); | |||
List<String> sourceSystemNames = CollUtils.fieldList(currBatchValues, | |||
ProjectGovSystemReplaceInfos::getSourceSystem); | |||
replaceInfo.setSourceSystemNames(sourceSystemNames); | |||
return replaceInfo; | |||
}).collect(Collectors.toList()); | |||
projectSystem.setReplaceSystems(replaceInfoList); | |||
} | |||
}); | |||
return retList; | |||
} | |||
} |
@@ -0,0 +1,32 @@ | |||
package com.hz.pm.api.projectlib.model.vo; | |||
import com.hz.pm.api.projectlib.model.dto.GovSystemReplaceInfoDTO; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* ProjectGovSystemReplaceVO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 15:47 2024/3/20 | |||
*/ | |||
@Data | |||
public class UnitProjectGovSystemReplaceVO { | |||
private String unitName; | |||
private List<ProjectGovSystemReplaceVO> projectSystemReplaces; | |||
@Data | |||
public static class ProjectGovSystemReplaceVO { | |||
private String projectName; | |||
private List<GovSystemReplaceInfoDTO> replaceSystems; | |||
} | |||
} |
@@ -1,8 +1,9 @@ | |||
package com.hz.pm.api.workbench.controller; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import com.hz.pm.api.workbench.manage.WorkbenchManage; | |||
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO; | |||
import com.hz.pm.api.workbench.model.vo.WorkbenchVO; | |||
import com.ningdatech.log.annotation.WebLog; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.AllArgsConstructor; | |||
@@ -12,6 +13,7 @@ import java.time.LocalDate; | |||
/** | |||
* 工作台前端控制器 | |||
* | |||
* @author ZPF | |||
* @since 2023/03/17 15:35 | |||
*/ | |||
@@ -28,7 +30,7 @@ public class WorkbenchController { | |||
* @return \ | |||
*/ | |||
@GetMapping | |||
public WorkbenchVO workbench(@RequestParam(required = false) Integer year){ | |||
public WorkbenchVO workbench(@RequestParam(required = false) Integer year) { | |||
if (year == null) { | |||
year = LocalDate.now().getYear(); | |||
} | |||
@@ -38,7 +40,14 @@ public class WorkbenchController { | |||
@ApiOperation(value = "催办", notes = "催办") | |||
@PostMapping("/urging/{recordId}") | |||
@WebLog("催办") | |||
public String urging(@PathVariable Long recordId){ | |||
public String urging(@PathVariable Long recordId) { | |||
return workbenchManage.urging(recordId); | |||
} | |||
@GetMapping("/projectTotalView") | |||
@ApiOperation("获取项目总览") | |||
public ProjectTotalViewVO projectTotalView(@RequestParam(required = false) Long unitId) { | |||
return workbenchManage.projectTotalView(unitId); | |||
} | |||
} |
@@ -3,6 +3,9 @@ package com.hz.pm.api.workbench.manage; | |||
import cn.hutool.core.bean.BeanUtil; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.date.StopWatch; | |||
import cn.hutool.core.util.NumberUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Assert; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
@@ -10,10 +13,15 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.google.common.collect.Sets; | |||
import com.hz.pm.api.common.helper.UserInfoHelper; | |||
import com.hz.pm.api.common.model.constant.BizConst; | |||
import com.hz.pm.api.common.model.entity.KeyValDTO; | |||
import com.hz.pm.api.common.util.DecimalUtil; | |||
import com.hz.pm.api.projectdeclared.manage.DefaultDeclaredProjectManage; | |||
import com.hz.pm.api.projectlib.entity.ProjectGovSystemReplaceInfos; | |||
import com.hz.pm.api.projectlib.manage.ProjectLibManage; | |||
import com.hz.pm.api.projectlib.model.entity.Project; | |||
import com.hz.pm.api.projectlib.model.enumeration.GovSystemReplaceTypeEnum; | |||
import com.hz.pm.api.projectlib.model.req.ProjectListReq; | |||
import com.hz.pm.api.projectlib.service.IProjectGovSystemReplaceInfosService; | |||
import com.hz.pm.api.projectlib.service.IProjectService; | |||
import com.hz.pm.api.sys.enumeration.ProjectEarlyWarningStatusEnum; | |||
import com.hz.pm.api.sys.manage.EarlyWarningManage; | |||
@@ -29,9 +37,11 @@ import com.hz.pm.api.todocenter.manage.TodoCenterManage; | |||
import com.hz.pm.api.todocenter.model.req.ToBeProcessedReq; | |||
import com.hz.pm.api.todocenter.model.vo.TodoCenterStatisticsVO; | |||
import com.hz.pm.api.todocenter.model.vo.TodoVO; | |||
import com.hz.pm.api.user.helper.MhUnitCache; | |||
import com.hz.pm.api.user.security.model.UserFullInfoDTO; | |||
import com.hz.pm.api.user.util.LoginUserUtil; | |||
import com.hz.pm.api.workbench.converter.WorkbenchConverter; | |||
import com.hz.pm.api.workbench.model.vo.ProjectTotalViewVO; | |||
import com.hz.pm.api.workbench.model.vo.WorkbenchVO; | |||
import com.hz.pm.api.workbench.model.vo.WorkbenchVO.WarningStatistics; | |||
import com.ningdatech.basic.model.PageVo; | |||
@@ -45,6 +55,7 @@ import lombok.extern.slf4j.Slf4j; | |||
import org.apache.commons.lang3.StringUtils; | |||
import org.springframework.stereotype.Component; | |||
import java.math.BigDecimal; | |||
import java.time.LocalDateTime; | |||
import java.time.temporal.ChronoUnit; | |||
import java.util.*; | |||
@@ -64,24 +75,17 @@ import java.util.stream.Collectors; | |||
public class WorkbenchManage { | |||
private final TodoCenterManage todoCenterManage; | |||
private final DefaultDeclaredProjectManage defaultDeclaredProjectManage; | |||
private final IEarlyWarningRecordsService earlyWarningRecordsService; | |||
private final IEarlyWarningService earlyWarningService; | |||
private final IProjectEarlyWarningService projectEarlyWarningService; | |||
private final NoticeManage noticeManage; | |||
private final UserInfoHelper userInfoHelper; | |||
private final ProjectLibManage projectLibManage; | |||
private final EarlyWarningManage earlyWarningManage; | |||
private final IProjectService projectService; | |||
private final MhUnitCache mhUnitCache; | |||
private final IProjectGovSystemReplaceInfosService systemReplaceInfosService; | |||
public WorkbenchVO getWorkbenchData(Integer year) { | |||
WorkbenchVO res = new WorkbenchVO(); | |||
@@ -349,4 +353,47 @@ public class WorkbenchManage { | |||
return "催办成功了" + employees.length + "个人"; | |||
} | |||
public ProjectTotalViewVO projectTotalView(Long unitId) { | |||
ProjectTotalViewVO retDetail = new ProjectTotalViewVO(); | |||
if (unitId == null) { | |||
unitId = LoginUserUtil.loginUserDetail().getMhUnitId(); | |||
} | |||
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) | |||
.select(Project::getReviewAmount, Project::getApprovalAmount, Project::getId) | |||
.eq(Project::getNewest, Boolean.TRUE); | |||
List<Long> viewUnitIds = mhUnitCache.getChildrenIdsRecursion(unitId); | |||
viewUnitIds.add(unitId); | |||
query.in(Project::getBuildOrgCode, CollUtils.convert(viewUnitIds, String::valueOf)); | |||
List<Project> projects = projectService.list(query); | |||
if (projects.isEmpty()) { | |||
return retDetail; | |||
} | |||
BigDecimal approvalAmount = DecimalUtil.sum(projects, Project::getApprovalAmount); | |||
BigDecimal reviewAmount = DecimalUtil.sum(projects, Project::getReviewAmount); | |||
retDetail.setTotalExecuteAmount(BigDecimal.ZERO); | |||
retDetail.setTotalApprovalAmount(approvalAmount); | |||
retDetail.setTotalReviewAmount(reviewAmount); | |||
Wrapper<ProjectGovSystemReplaceInfos> pgsriQuery = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) | |||
.in(ProjectGovSystemReplaceInfos::getProjectId, | |||
CollUtils.fieldList(projects, Project::getId)); | |||
List<ProjectGovSystemReplaceInfos> systemReplaceInfos = systemReplaceInfosService.list(pgsriQuery); | |||
Map<String, Long> typeCountMap = systemReplaceInfos.stream() | |||
.map(w -> StrUtil.split(w.getReplaceType(), ",")) | |||
.flatMap(Collection::stream) | |||
.collect(Collectors.groupingBy(w -> { | |||
if (NumberUtil.isNumber(w)) { | |||
return "其他"; | |||
} else { | |||
return GovSystemReplaceTypeEnum.get(Integer.parseInt(w)) | |||
.flatMap(t -> Optional.of(t.getVal())) | |||
.orElse("其他"); | |||
} | |||
}, Collectors.counting())); | |||
List<KeyValDTO<String, Integer>> systemTypes = typeCountMap.entrySet().stream() | |||
.map(w -> KeyValDTO.of(w.getKey(), w.getValue().intValue())) | |||
.collect(Collectors.toList()); | |||
retDetail.setSystemTypes(systemTypes); | |||
return retDetail; | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.hz.pm.api.workbench.model.vo; | |||
import com.hz.pm.api.common.model.entity.KeyValDTO; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.math.BigDecimal; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* ProjectTotalViewVO | |||
* </p> | |||
* | |||
* @author WendyYang | |||
* @since 11:54 2024/3/20 | |||
*/ | |||
@Data | |||
public class ProjectTotalViewVO { | |||
@ApiModelProperty("系统类型(替代类型)") | |||
private List<KeyValDTO<String, Integer>> systemTypes; | |||
@ApiModelProperty("评审金额") | |||
private BigDecimal totalReviewAmount; | |||
@ApiModelProperty("下达金额") | |||
private BigDecimal totalApprovalAmount; | |||
@ApiModelProperty("执行金额") | |||
private BigDecimal totalExecuteAmount; | |||
} |