|
|
@@ -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 { |
|
|
|