|
@@ -115,7 +115,14 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
queryWrapper.last("limit 1");
|
|
|
return this.getOne(queryWrapper);
|
|
|
}
|
|
|
-
|
|
|
+ public Project getProjectByName(String name,Integer loginId) {
|
|
|
+ LambdaQueryWrapper<Project> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ PersonnelVO personnelVO = cacheUtils.getLoginUser(loginId);
|
|
|
+ queryWrapper.eq(Project::getName, name);
|
|
|
+ queryWrapper.eq(Project::getTenantId, personnelVO.getTenantId());
|
|
|
+ queryWrapper.last("limit 1");
|
|
|
+ return this.getOne(queryWrapper);
|
|
|
+ }
|
|
|
public IPage<Project> getPageList(ProjectVO params) throws IOException {
|
|
|
List<Integer> projectIds = new ArrayList<Integer>() {{
|
|
|
add(-1);
|
|
@@ -393,7 +400,18 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
return tempName;
|
|
|
}
|
|
|
-
|
|
|
+ public String getImportProjectName(String name,Integer userId) {
|
|
|
+ String tempName = name + "(1)";
|
|
|
+ Project project1 = this.getProjectByName(name,userId);
|
|
|
+ if (project1 == null) {
|
|
|
+ return name;
|
|
|
+ }
|
|
|
+ Project project2 = this.getProjectByName(tempName,userId);
|
|
|
+ if (project2 != null) {
|
|
|
+ tempName = this.getImportProjectName(tempName,userId);
|
|
|
+ }
|
|
|
+ return tempName;
|
|
|
+ }
|
|
|
public Integer importProject(Integer projectId, String json, Integer userId) throws IOException {
|
|
|
if ((projectId == null || projectId.equals(0)) && StringUtils.isEmpty(json)) {
|
|
|
return 0;
|
|
@@ -403,17 +421,8 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
Project temp = this.getById(projectId);
|
|
|
Project data = JsonUtils.jsonToPojo(json, Project.class);
|
|
|
- String res = requestService.getClientByName(Objects.requireNonNull(data).getClientName());
|
|
|
- ClientDTO client = JSONObject.parseObject(res, ClientDTO.class);
|
|
|
- Integer clientId = 0;
|
|
|
- if (client == null) {
|
|
|
- client.setName(data.getClientName());
|
|
|
- String res2 = requestService.addClient(client);
|
|
|
-
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(res2);
|
|
|
- clientId = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
- } else {
|
|
|
- clientId = client.getId();
|
|
|
+ if (data.getClientId() != null) {
|
|
|
+ temp.setClientId(data.getClientId());
|
|
|
}
|
|
|
if (temp == null) {
|
|
|
temp = new Project();
|
|
@@ -421,9 +430,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
String projectName = temp.getName();
|
|
|
BeanUtils.copyProperties(data, temp);
|
|
|
if (projectName == null || !projectName.equals(data.getName())) {
|
|
|
- temp.setName(this.getImportProjectName(temp.getName()));
|
|
|
+ temp.setName(this.getImportProjectName(temp.getName(),userId));
|
|
|
}
|
|
|
- temp.setClientId(clientId);
|
|
|
+
|
|
|
if (projectId == null || projectId.equals(0)) {
|
|
|
temp.setCreateBy(userId);
|
|
|
temp.setCreateTime(DateUtils.getDateTime());
|