|
|
@@ -13,7 +13,9 @@ import com.hz.pm.api.projectlib.model.req.ProjectListReq; |
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
@@ -25,13 +27,31 @@ import java.util.Optional; |
|
|
|
*/ |
|
|
|
public interface IProjectService extends IService<Project> { |
|
|
|
|
|
|
|
Map<Long, String> PROJECT_CODE_MAP_ID = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
default Optional<String> getProjectCode(Long projectId) { |
|
|
|
LambdaQueryWrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getProjectCode) |
|
|
|
.eq(Project::getId, projectId) |
|
|
|
.last(BizConst.LIMIT_1); |
|
|
|
return Optional.ofNullable(getOne(query)) |
|
|
|
.flatMap(w -> Optional.of(w.getProjectCode())); |
|
|
|
if (projectId == null) { |
|
|
|
return Optional.empty(); |
|
|
|
} |
|
|
|
String projectCode = PROJECT_CODE_MAP_ID.get(projectId); |
|
|
|
if (projectCode == null) { |
|
|
|
synchronized (this) { |
|
|
|
projectCode = PROJECT_CODE_MAP_ID.get(projectId); |
|
|
|
if (projectCode == null) { |
|
|
|
Wrapper<Project> query = Wrappers.lambdaQuery(Project.class) |
|
|
|
.select(Project::getProjectCode) |
|
|
|
.eq(Project::getId, projectId) |
|
|
|
.last(BizConst.LIMIT_1); |
|
|
|
Project project = getOne(query); |
|
|
|
if (project != null) { |
|
|
|
projectCode = project.getProjectCode(); |
|
|
|
PROJECT_CODE_MAP_ID.put(projectId, projectCode); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return Optional.ofNullable(projectCode); |
|
|
|
} |
|
|
|
|
|
|
|
default Optional<Long> getNewProjectId(String projectCode) { |
|
|
|