Procházet zdrojové kódy

项目归集 生成项目编号

master
PoffyZhang před 1 rokem
rodič
revize
8417cac87f
3 změnil soubory, kde provedl 42 přidání a 6 odebrání
  1. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java
  2. +0
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java
  3. +33
    -5
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java

+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/gov/manage/GovProjectCollectionManage.java Zobrazit soubor

@@ -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<GovProjectDictionaryVO> dictionary(String type) {

List<GovProjectDictionary> 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.保存基本信息


+ 0
- 1
pmapi/src/main/java/com/ningdatech/pmapi/gov/model/dto/GovBizProjectSaveDTO.java Zobrazit soubor

@@ -22,7 +22,6 @@ public class GovBizProjectSaveDTO implements Serializable {
private static final long serialVersionUID = 1L;

@ApiModelProperty("项目编号")
@NotBlank(message = "项目编号不能为空")
private String baseProjId;

@ApiModelProperty("基本项目名称")


+ 33
- 5
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java Zobrazit soubor

@@ -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;
}
}

Načítá se…
Zrušit
Uložit