From 8417cac87ff1adb85b189295fa5c33484ef900ba Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Thu, 24 Aug 2023 17:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=BD=92=E9=9B=86=20?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=A1=B9=E7=9B=AE=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov/manage/GovProjectCollectionManage.java | 9 +++++ .../pmapi/gov/model/dto/GovBizProjectSaveDTO.java | 1 - .../utils/GenerateProjectCodeUtil.java | 38 +++++++++++++++++++--- 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java index 897c693..887d3c2 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java @@ -13,6 +13,7 @@ import com.ningdatech.pmapi.gov.model.dto.*; import com.ningdatech.pmapi.gov.model.entity.*; import com.ningdatech.pmapi.gov.model.vo.*; import com.ningdatech.pmapi.gov.service.*; +import com.ningdatech.pmapi.projectdeclared.utils.GenerateProjectCodeUtil; import com.ningdatech.pmapi.projectlib.model.req.ProjectListReq; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; @@ -48,6 +49,8 @@ public class GovProjectCollectionManage { private final IGovBizProjectProcureService procureService; + private final GenerateProjectCodeUtil generateProjectCodeUtil; + public List dictionary(String type) { List dictionaries = dictionaryService.list(Wrappers.lambdaQuery(GovProjectDictionary.class) @@ -182,6 +185,12 @@ public class GovProjectCollectionManage { */ public String save(GovBizProjectSaveDTO saveDTO) { String baseProjId = saveDTO.getBaseProjId(); + + //如果是新增的话 要生成 项目编号 + if(StringUtils.isBlank(baseProjId)){ + baseProjId = generateProjectCodeUtil.generateProjectCode(saveDTO); + } + String baseProjName = saveDTO.getBaseProjName(); //1.保存基本信息 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java index 43a680c..6d81244 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java @@ -22,7 +22,6 @@ public class GovBizProjectSaveDTO implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty("项目编号") - @NotBlank(message = "项目编号不能为空") private String baseProjId; @ApiModelProperty("基本项目名称") diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java index 166e8ec..72f816a 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java @@ -1,12 +1,18 @@ package com.ningdatech.pmapi.projectdeclared.utils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.ningdatech.pmapi.fiscal.service.ICompanyFiscalCodeService; +import com.ningdatech.basic.function.VUtils; +import com.ningdatech.pmapi.common.constant.BizConst; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectApplyDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectBaseinfoDTO; +import com.ningdatech.pmapi.gov.model.dto.GovBizProjectSaveDTO; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectApply; +import com.ningdatech.pmapi.gov.model.entity.GovBizProjectBaseinfo; +import com.ningdatech.pmapi.gov.service.IGovBizProjectApplyService; import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant; import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.ProjectCollection; -import com.ningdatech.pmapi.projectlib.service.IProjectCollectionService; import com.ningdatech.pmapi.projectlib.service.IProjectService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -21,14 +27,12 @@ import java.util.Objects; */ @Component public class GenerateProjectCodeUtil { - @Autowired - private ICompanyFiscalCodeService companyFiscalCodeService; @Autowired private IProjectService projectService; @Autowired - private IProjectCollectionService projectCollectionService; + private IGovBizProjectApplyService applyService; public String generateProjectCode(ProjectDTO project){ // 获取所属行政区划代码(9位) @@ -65,4 +69,28 @@ public class GenerateProjectCodeUtil { // 生成20位的项目编号 return areaCode + year + projectType + serialNumber; } + + public String generateProjectCode(GovBizProjectSaveDTO dto){ + // 获取所属行政区划代码(9位) + GovBizProjectBaseinfoDTO baseinfo = dto.getBaseinfo(); + GovBizProjectApplyDTO apply = dto.getApply(); + + VUtils.isTrue(Objects.isNull(baseinfo)).throwMessage("没有项目基本信息 无法生成项目编号!"); + VUtils.isTrue(Objects.isNull(apply)).throwMessage("没有项目申报信息 无法生成项目编号!"); + + + String areaCode = baseinfo.getBaseAreaCode() + BizConst.NINE_AREA_CODE_LAST; + // 获取建设年度 (10-13) + String year = Objects.nonNull(apply.getBaseProjSetYear()) ? apply.getBaseProjSetYear() + : String.valueOf(LocalDateTime.now().getYear()); + // 14-15 项目类型 + String projectType = baseinfo.getBaseProjType(); + // 16-20 项目序号00001 + Long max = applyService.count(Wrappers.lambdaQuery(GovBizProjectApply.class) + .eq(GovBizProjectApply::getBaseProjSetYear,apply.getBaseProjSetYear())); + Long maxCurrent = max + 1; + String serialNumber = String.format(ProjectCodeContant.SHUZI_5,maxCurrent); + // 生成20位的项目编号 + return areaCode + year + projectType + serialNumber; + } }