Browse Source

优化代码

master
PoffyZhang 1 year ago
parent
commit
459973db95
8 changed files with 112 additions and 4 deletions
  1. +2
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java
  2. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java
  3. +7
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java
  4. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java
  5. +92
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  6. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectRenewalFundDeclarationDTO.java
  7. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectRenewalFundDeclaration.java
  8. +3
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java

+ 2
- 2
pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java View File

@@ -694,8 +694,8 @@ public class GovProjectCollectionManage {
draft.setBaseEngineerPostpoFileMimplement(mimplement.getBaseEngineerPostpoFile());
draft.setBaseThirdAcceptFileMimplement(mimplement.getBaseThirdAcceptFile());
draft.setBaseUserConsFileMimplement(mimplement.getBaseUserConsFile());
draft.setBaseFinalExpertOpinionFileCimplement(mimplement.getBaseFinalExpertOpinionFile());
draft.setBaseFinalExpertOpinionFileMimplement(mimplement.getBaseFinalExpertOpinionFile());
draft.setBasePasswAssessFileMimplement(mimplement.getBasePasswAssessFile());
}

// 6.保存 采购信息


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java View File

@@ -43,7 +43,7 @@ public class GenerateProjectCodeUtil {
String year = Objects.nonNull(project.getProjectYear()) ? String.valueOf(project.getProjectYear())
: String.valueOf(LocalDateTime.now().getYear());
// 14-15 项目类型
String projectType = ProjectCodeContant.PROJECT_TYPE_PREFIX + project.getProjectType();
String projectType = project.getProjectType();
// 16-20 项目序号00001
String currentCode = areaCode + year + projectType;
// 16-20 项目序号00001


+ 7
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/controller/ProjectLibController.java View File

@@ -47,6 +47,13 @@ public class ProjectLibController {
return projectLibManage.projectLibListWithPermission(req,user);
}

@GetMapping("/all-list")
@ApiOperation("包含申报项目列表和项目归集列表")
public PageVo<ProjectLibListItemVO> projectAllList(ProjectListReq req) {
UserFullInfoDTO user = userInfoHelper.getUserFullInfo(LoginUserUtil.getUserId());
return projectLibManage.projectAllListWithPermission(req,user);
}

@GetMapping("/history-list/{id}")
@ApiOperation("项目历史版本列表")
public JSONObject historyProjects(@PathVariable Long id) {


+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/helper/ProjectHelper.java View File

@@ -62,7 +62,7 @@ public class ProjectHelper {
.in(CollUtil.isNotEmpty(req.getInstCodes()),Project::getInstCode,req.getInstCodes())
//已添加评价计划的项目code
.notIn(CollUtil.isNotEmpty(req.getProjectCodes()),Project::getProjectCode,req.getProjectCodes())
.orderByDesc(Project::getCreateOn);
.orderByDesc(Project::getUpdateOn);
return query;
}



+ 92
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -269,6 +269,98 @@ public class ProjectLibManage {
return PageVo.of(records, page.getTotal());
}

/**
* 项目申报和项目归集的并集
* @param req
* @param user
* @return
*/
public PageVo<ProjectLibListItemVO> projectAllListWithPermission(ProjectListReq req, UserFullInfoDTO user) {
LambdaQueryWrapper<Project> query = ProjectHelper.projectQuery(req);
user = buildProjectLibPermission(query, user);
//项目查最新
query.eq(Project::getNewest, Boolean.TRUE);
Page<Project> page = projectService.page(req.page(), query);
long total;
if (CollUtil.isEmpty(page.getRecords())) {
return PageVo.empty();
}
UserFullInfoDTO finalUser = user;

Set<String> projectCodes = page.getRecords().stream()
.map(Project::getProjectCode).collect(Collectors.toSet());
List<ProjectTag> pts = projectTagService.list(Wrappers.lambdaQuery(ProjectTag.class)
.in(ProjectTag::getProjectCode, projectCodes));
Map<String,List<ProjectTag>> tagMap = Maps.newHashMap();
Map<Long,String> tagNameMap = Maps.newHashMap();
if(CollUtil.isNotEmpty(pts)){
tagMap = pts.stream().collect(Collectors.groupingBy(ProjectTag::getProjectCode));
Set<Long> tagIds = pts.stream().map(ProjectTag::getTagId).collect(Collectors.toSet());
List<Tag> tags = tagService.list(Wrappers.lambdaQuery(Tag.class)
.in(Tag::getId, tagIds));
if(CollUtil.isNotEmpty(tags)){
tagNameMap = tags.stream().collect(Collectors.toMap(Tag::getId,Tag::getName));
}
}
Map<String, List<ProjectTag>> finalTagMap = tagMap;
Map<Long,String> finalTagNameMap = tagNameMap;

//已验收项目编号
List<String> acceptedProjectCode = page.getRecords().stream().filter(p -> ProjectStatusEnum.ACCEPTED.getCode().equals(p.getStatus()))
.map(Project::getProjectCode).collect(Collectors.toList());

Map<Long,List<ProjectRenewalFundDeclaration>> renewalMap = Maps.newHashMap();
if(CollUtil.isNotEmpty(acceptedProjectCode)){
List<ProjectRenewalFundDeclaration> renewalDeclarations = renewalFundDeclarationService.list(Wrappers.lambdaQuery(ProjectRenewalFundDeclaration.class)
.in(ProjectRenewalFundDeclaration::getProjectCode, acceptedProjectCode)
.eq(ProjectRenewalFundDeclaration::getApprovalStatus, ProjectRenewalApprovalStatusEnum.PASS.name())
.eq(ProjectRenewalFundDeclaration::getDeleted,Boolean.FALSE)
.orderByAsc(ProjectRenewalFundDeclaration::getProjectYear));
renewalMap = renewalDeclarations.stream().collect(Collectors.groupingBy(ProjectRenewalFundDeclaration::getProjectId));
}

Map<Long, List<ProjectRenewalFundDeclaration>> finalRenewalMap = renewalMap;
List<ProjectLibListItemVO> records = CollUtils.convert(page.getRecords(), w -> {
ProjectLibListItemVO item = new ProjectLibListItemVO();
item.setId(w.getId());
item.setProjectName(w.getProjectName());
item.setProjectCode(w.getProjectCode());
item.setArea(w.getArea());
item.setAreaCode(w.getAreaCode());
item.setCreateOn(w.getCreateOn());
item.setDeclaredAmount(w.getDeclareAmount());
item.setStage(w.getStage());
item.setStatus(w.getStatus());
item.setProjectType(w.getProjectType());
item.setProjectYear(w.getProjectYear());
item.setBuildOrg(w.getBuildOrgName());
item.setBizDomain(w.getBizDomain());
item.setProcessStatus(w.getProcessStatus());
item.setInstCode(w.getInstCode());
item.setIsHigherSuperOrg(w.getIsHigherSuperOrg());
if (finalUser.getIsOrgAdmin() &&
ProjectStatusEnum.PENDING_PREQUALIFICATION.getCode().equals(item.getStatus())
&& StringUtils.isNotBlank(w.getSuperOrgCode()) && StringUtils.isNotBlank(finalUser.getEmpPosUnitCode())
&& w.getSuperOrgCode().equals(finalUser.getEmpPosUnitCode())) {
item.setCanPreDeclared(Boolean.TRUE);
}
item.setApprovedAmount(w.getApprovalAmount());
item.setAnnualPlanAmount(w.getAnnualPlanAmount());
item.setPrePlanProjectId(w.getPrePlanProjectId());
setTag(item,finalTagMap,finalTagNameMap);
if(finalRenewalMap.containsKey(item.getId())){
List<ProjectRenewalFundDeclaration> prfs = finalRenewalMap.get(item.getId());
item.setAnnualAccumulateAmount(computeAmount(w.getAnnualPlanAmount(),prfs));
item.setAnnualAccumulateAmountList(convertAccmulate(w,prfs));
}else{
item.setAnnualAccumulateAmount(w.getAnnualPlanAmount());
item.setAnnualAccumulateAmountList(convertAccmulate(w,Collections.emptyList()));
}
return item;
});
return PageVo.of(records, page.getTotal());
}

private BigDecimal computeAmount(BigDecimal cuurentAmount,List<ProjectRenewalFundDeclaration> prfs) {
BigDecimal res = cuurentAmount;
for(ProjectRenewalFundDeclaration prf : prfs){


+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/dto/ProjectRenewalFundDeclarationDTO.java View File

@@ -26,6 +26,9 @@ public class ProjectRenewalFundDeclarationDTO implements Serializable {
@ApiModelProperty("关联项目ID")
private Long projectId;

@ApiModelProperty("项目编号")
private String projectCode;

@ApiModelProperty("项目年份")
private Integer projectYear;



+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/entity/ProjectRenewalFundDeclaration.java View File

@@ -38,6 +38,9 @@ public class ProjectRenewalFundDeclaration implements Serializable {
@ApiModelProperty("关联项目ID")
private Long projectId;

@ApiModelProperty("项目编号")
private String projectCode;

@ApiModelProperty("项目年份")
private Integer projectYear;



+ 3
- 0
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/model/vo/ProjectRenewalFundDeclarationVO.java View File

@@ -77,6 +77,9 @@ public class ProjectRenewalFundDeclarationVO implements Serializable {
@ApiModelProperty("关联项目ID")
private Long projectId;

@ApiModelProperty("项目编号")
private String projectCode;

@ApiModelProperty("关联项目名字")
private String projectName;



Loading…
Cancel
Save