|
|
@@ -1,18 +1,14 @@ |
|
|
|
package com.ningdatech.pmapi.projectdeclared.utils; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.ningdatech.basic.function.VUtils; |
|
|
|
import com.ningdatech.basic.util.StrPool; |
|
|
|
import com.ningdatech.pmapi.common.constant.BizConst; |
|
|
|
import com.ningdatech.pmapi.common.constant.RegionConst; |
|
|
|
import com.ningdatech.pmapi.gov.contants.BizProjectContant; |
|
|
|
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.gov.service.IGovBizProjectBaseinfoService; |
|
|
|
import com.ningdatech.pmapi.projectdeclared.contants.ProjectCodeContant; |
|
|
|
import com.ningdatech.pmapi.projectlib.model.dto.ProjectDTO; |
|
|
@@ -49,13 +45,28 @@ public class GenerateProjectCodeUtil { |
|
|
|
// 14-15 项目类型 |
|
|
|
String projectType = ProjectCodeContant.PROJECT_TYPE_PREFIX + project.getProjectType(); |
|
|
|
// 16-20 项目序号00001 |
|
|
|
Long max = projectService.count(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getProjectYear,project.getProjectYear()) |
|
|
|
.eq(Project::getNewest,Boolean.TRUE)); |
|
|
|
Long maxCurrent = max + 1; |
|
|
|
String serialNumber = String.format(ProjectCodeContant.SHUZI_5,maxCurrent); |
|
|
|
String currentCode = areaCode + year + projectType; |
|
|
|
// 16-20 项目序号00001 |
|
|
|
//要查询 两边的项目序号 |
|
|
|
Long max = 0L; |
|
|
|
GovBizProjectBaseinfo baseMax = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) |
|
|
|
.like(GovBizProjectBaseinfo::getBaseProjId, currentCode) |
|
|
|
.orderByDesc(GovBizProjectBaseinfo::getBaseProjId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.nonNull(baseMax) && StringUtils.isNotBlank(baseMax.getBaseProjId())){ |
|
|
|
max = Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5)); |
|
|
|
} |
|
|
|
Project projectMax = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.like(Project::getProjectCode, currentCode) |
|
|
|
.orderByDesc(Project::getProjectCode) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.nonNull(projectMax) && StringUtils.isNotBlank(projectMax.getProjectCode())){ |
|
|
|
Long projectMaxCode = Long.valueOf(projectMax.getProjectCode().substring(projectMax.getProjectCode().length() - 5)); |
|
|
|
max = Math.max(max,projectMaxCode); |
|
|
|
} |
|
|
|
max = max + 1; |
|
|
|
// 生成20位的项目编号 |
|
|
|
return areaCode + year + projectType + serialNumber; |
|
|
|
return currentCode + String.format(ProjectCodeContant.SHUZI_5, max); |
|
|
|
} |
|
|
|
|
|
|
|
public String generateProjectCode(ProjectCollection project){ |
|
|
@@ -67,13 +78,28 @@ public class GenerateProjectCodeUtil { |
|
|
|
// 14-15 项目类型 |
|
|
|
String projectType = ProjectCodeContant.PROJECT_TYPE_PREFIX + project.getProjectType(); |
|
|
|
// 16-20 项目序号00001 |
|
|
|
Long max = projectService.count(Wrappers.lambdaQuery(Project.class) |
|
|
|
.eq(Project::getProjectYear,project.getProjectYear()) |
|
|
|
.eq(Project::getNewest,Boolean.TRUE)); |
|
|
|
Long maxCurrent = max + 1; |
|
|
|
String serialNumber = String.format(ProjectCodeContant.SHUZI_5,maxCurrent); |
|
|
|
String currentCode = areaCode + year + projectType; |
|
|
|
// 16-20 项目序号00001 |
|
|
|
//要查询 两边的项目序号 |
|
|
|
Long max = 0L; |
|
|
|
GovBizProjectBaseinfo baseMax = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) |
|
|
|
.like(GovBizProjectBaseinfo::getBaseProjId, currentCode) |
|
|
|
.orderByDesc(GovBizProjectBaseinfo::getBaseProjId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.nonNull(baseMax) && StringUtils.isNotBlank(baseMax.getBaseProjId())){ |
|
|
|
max = Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5)); |
|
|
|
} |
|
|
|
Project projectMax = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.like(Project::getProjectCode, currentCode) |
|
|
|
.orderByDesc(Project::getProjectCode) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.nonNull(projectMax) && StringUtils.isNotBlank(projectMax.getProjectCode())){ |
|
|
|
Long projectMaxCode = Long.valueOf(projectMax.getProjectCode().substring(projectMax.getProjectCode().length() - 5)); |
|
|
|
max = Math.max(max,projectMaxCode); |
|
|
|
} |
|
|
|
max = max + 1; |
|
|
|
// 生成20位的项目编号 |
|
|
|
return areaCode + year + projectType + serialNumber; |
|
|
|
return currentCode + String.format(ProjectCodeContant.SHUZI_5, max); |
|
|
|
} |
|
|
|
|
|
|
|
public String generateProjectCode(GovBizProjectSaveDTO dto) { |
|
|
@@ -93,13 +119,30 @@ public class GenerateProjectCodeUtil { |
|
|
|
BizProjectContant.ProjectCollection.IS_EFFECTIVE; |
|
|
|
String currentCode = areaCode + year + projectType; |
|
|
|
// 16-20 项目序号00001 |
|
|
|
//要查询 两边的项目序号 |
|
|
|
Long max = 0L; |
|
|
|
GovBizProjectBaseinfo baseMax = baseinfoService.getOne(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) |
|
|
|
.like(GovBizProjectBaseinfo::getBaseProjId, currentCode) |
|
|
|
.orderByDesc(GovBizProjectBaseinfo::getBaseProjId) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
Long max = Objects.isNull(baseMax) ? 0L : Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5, baseMax.getBaseProjId().length())); |
|
|
|
if(Objects.nonNull(baseMax) && StringUtils.isNotBlank(baseMax.getBaseProjId())){ |
|
|
|
max = Long.valueOf(baseMax.getBaseProjId().substring(baseMax.getBaseProjId().length() - 5)); |
|
|
|
} |
|
|
|
Project projectMax = projectService.getOne(Wrappers.lambdaQuery(Project.class) |
|
|
|
.like(Project::getProjectCode, currentCode) |
|
|
|
.orderByDesc(Project::getProjectCode) |
|
|
|
.last(BizConst.LIMIT_1)); |
|
|
|
if(Objects.nonNull(projectMax) && StringUtils.isNotBlank(projectMax.getProjectCode())){ |
|
|
|
Long projectMaxCode = Long.valueOf(projectMax.getProjectCode().substring(projectMax.getProjectCode().length() - 5)); |
|
|
|
max = Math.max(max,projectMaxCode); |
|
|
|
} |
|
|
|
max = max + 1; |
|
|
|
// 生成20位的项目编号 |
|
|
|
return currentCode + String.format(ProjectCodeContant.SHUZI_5, max); |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
String projectCode = "33110020230100001"; |
|
|
|
System.out.println(projectCode.substring(projectCode.length() - 5)); |
|
|
|
} |
|
|
|
} |