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