Browse Source

生成21位项目编号

tags/24080901
CMM 1 year ago
parent
commit
49174b5042
2 changed files with 16 additions and 8 deletions
  1. +1
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java
  2. +15
    -7
      pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/utils/GenerateProjectCodeUtil.java

+ 1
- 1
pmapi/src/main/java/com/ningdatech/pmapi/projectdeclared/contants/DeclaredProjectContant.java View File

@@ -24,7 +24,7 @@ public interface DeclaredProjectContant {

class Project{
public static final Integer YEAR_THREE = 2;
public static final Integer YEAR_FOUR = 3;
public static final Integer YEAR_FOUR = 4;

public static final String FIXED_NUMBER = "0130";
public static final Long PROJECT_ID = 999L;


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

@@ -1,5 +1,6 @@
package com.ningdatech.pmapi.projectdeclared.utils;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.basic.exception.BizException;
import com.ningdatech.basic.util.StrPool;
import com.ningdatech.pmapi.fiscal.entity.CompanyFiscalCode;
@@ -7,9 +8,12 @@ import com.ningdatech.pmapi.fiscal.service.ICompanyFiscalCodeService;
import com.ningdatech.pmapi.projectdeclared.contants.DeclaredProjectContant;
import com.ningdatech.pmapi.projectdeclared.model.dto.DefaultDeclaredDTO;
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO;
import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;

/**
@@ -23,6 +27,9 @@ public class GenerateProjectCodeUtil {
@Autowired
private ICompanyFiscalCodeService companyFiscalCodeService;

@Autowired
private IProjectService projectService;

public String generateProjectCode(ProjectDTO projectInfo){
// 获取所属行政区划代码(6位)
String areaCode = projectInfo.getAreaCode();
@@ -36,18 +43,19 @@ public class GenerateProjectCodeUtil {
CompanyFiscalCode companyFiscalCode = companyFiscalCodeService.getByOrganizationCode(projectInfo.getBuildOrgCode());

// 从表中查出单位配置的财政编码
//if (Objects.isNull(companyFiscalCode)){
// throw new BizException("申报单位未配置财政编码!");
//}

// TODO 校验财政编码是否正确 部门编码(3位) + 单位编码(3位)
if (Objects.isNull(companyFiscalCode)){
throw new BizException("申报单位未配置财政编码!");
}

String fiscalCode = companyFiscalCode.getFiscalCode();
// 获取项目编号
String projectIdStr;
Long projectId = projectInfo.getId();
// 获取项目库当前最大项目序号
List<Project> projectList = projectService.list(Wrappers.lambdaQuery(Project.class).orderByDesc(Project::getId));
Project project = projectList.get(0);
Long projectId = project.getId();
if (projectId > DeclaredProjectContant.Project.PROJECT_ID){
// 超过999的项目号从1开始
// 超过999的项目号从1开始 1
Long newProjectId = projectId - DeclaredProjectContant.Project.PROJECT_ID;
projectIdStr = String.format(StrPool.FORMAT_NUMBER_THREE, newProjectId);
}else {


Loading…
Cancel
Save