|
@@ -3,6 +3,7 @@ package cn.cslg.pas.service;
|
|
|
import cn.cslg.pas.common.core.base.Constants;
|
|
|
import cn.cslg.pas.common.core.exception.CustomException;
|
|
|
import cn.cslg.pas.common.model.PersonnelVO;
|
|
|
+import cn.cslg.pas.common.model.dto.ClientDTO;
|
|
|
import cn.cslg.pas.common.model.dto.UploadFileDTO;
|
|
|
import cn.cslg.pas.common.model.vo.ProjectExportVO;
|
|
|
import cn.cslg.pas.common.model.vo.ProjectImportVO;
|
|
@@ -28,6 +29,7 @@ import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import cn.hutool.poi.excel.ExcelWriter;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -61,7 +63,6 @@ import java.util.stream.Collectors;
|
|
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
|
|
public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
|
|
|
- private final ClientService clientService;
|
|
|
private final ProjectUserService projectUserService;
|
|
|
private final PatentService patentService;
|
|
|
private final PatentApplicantService patentApplicantService;
|
|
@@ -128,6 +129,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
IPage<Project> pageList = baseMapper.getPageList(new Page<>(params.getCurrent(), params.getSize()), params);
|
|
|
|
|
|
List<Project> dataList = pageList.getRecords();
|
|
|
+ List<Integer> clientIds =dataList.stream().map(Project::getClientId).collect(Collectors.toList());
|
|
|
|
|
|
try {
|
|
|
//获取所属部门对应信息
|
|
@@ -148,6 +150,10 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
String jsonObject1 = requestService.getPersonnelFromPCS(dataList);
|
|
|
JSONArray jsonArray = JSON.parseArray(jsonObject1);
|
|
|
List<ProjectVO.Personnel> personnelList = jsonArray.toJavaList(ProjectVO.Personnel.class);
|
|
|
+ //获取专题库委托方对应信息
|
|
|
+ String jsonObject2 = requestService.getClientByIds(clientIds);
|
|
|
+ JSONArray jsonArray2 = JSON.parseArray(jsonObject2);
|
|
|
+ List<ClientDTO> clientList = jsonArray2.toJavaList(ClientDTO.class);
|
|
|
for (Project project : dataList) {
|
|
|
for (ProjectVO.Personnel personnel : personnelList) {
|
|
|
if (project.getPersonnelId() != null) {
|
|
@@ -156,6 +162,13 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ for (ClientDTO clientDTO : clientList) {
|
|
|
+ if (project.getClientId() != null) {
|
|
|
+ if (project.getClientId().equals(clientDTO.getId())) {
|
|
|
+ project.setClientName(clientDTO.getName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
@@ -216,10 +229,18 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
|
|
|
public Project getProjectById(Integer id) {
|
|
|
Project project = this.getById(id);
|
|
|
- Client client = clientService.getById(project.getClientId());
|
|
|
- if (client != null) {
|
|
|
- project.setClientName(client.getName());
|
|
|
+ try {
|
|
|
+ String res = requestService.getClientByIds(Arrays.asList(project.getClientId()));
|
|
|
+ JSONArray jsonArray2 = JSON.parseArray(res);
|
|
|
+ List<ClientDTO> clientList = jsonArray2.toJavaList(ClientDTO.class);
|
|
|
+ if (clientList != null &&clientList.size()!=0) {
|
|
|
+ project.setClientName(clientList.get(0).getName());
|
|
|
+ }
|
|
|
}
|
|
|
+ catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
return project;
|
|
|
}
|
|
|
|
|
@@ -278,10 +299,12 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- public Map<Object, Object> getScenarioAndTypeTotal() {
|
|
|
+ public Map<Object, Object> getScenarioAndTypeTotal() throws IOException {
|
|
|
List<Project> projectList = this.getAllProjectByMySelf();
|
|
|
List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList(Constants.ENTERPRISE_APPLICATION_SCENARIO, Constants.INVESTIGATION_TYPE));
|
|
|
- List<Client> clientList = clientService.getClientByObjectIds(this.getClientIds(projectList.stream().map(Project::getClientId).collect(Collectors.toList())));
|
|
|
+ String res = requestService.getClientByIds(projectList.stream().map(Project::getClientId).collect(Collectors.toList()));
|
|
|
+ JSONArray jsonArray2 = JSON.parseArray(res);
|
|
|
+ List<ClientDTO> clientList = jsonArray2.toJavaList(ClientDTO.class);
|
|
|
Map<Object, Object> type = new HashMap<>();
|
|
|
Map<Object, Object> scenario = new HashMap<>();
|
|
|
Map<Object, Object> result = new HashMap<>();
|
|
@@ -332,7 +355,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
return tempName;
|
|
|
}
|
|
|
|
|
|
- public Integer importProject(Integer projectId, String json, Integer userId) {
|
|
|
+ public Integer importProject(Integer projectId, String json, Integer userId) throws IOException {
|
|
|
if ((projectId == null || projectId.equals(0)) && StringUtils.isEmpty(json)) {
|
|
|
return 0;
|
|
|
}
|
|
@@ -341,14 +364,18 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
Project temp = this.getById(projectId);
|
|
|
Project data = JsonUtils.jsonToPojo(json, Project.class);
|
|
|
- Client client = clientService.getClientByName(Objects.requireNonNull(data).getClientName());
|
|
|
+ String res =requestService.getClientByName(Objects.requireNonNull(data).getClientName());
|
|
|
+ ClientDTO client =JSONObject.parseObject(res,ClientDTO.class);
|
|
|
+ Integer clientId =0;
|
|
|
if (client == null) {
|
|
|
- client = new Client();
|
|
|
client.setName(data.getClientName());
|
|
|
- client.setStatus(1);
|
|
|
- client.setCreateBy(userId);
|
|
|
- client.setCreateTime(DateUtils.getDateTime());
|
|
|
- client.insert();
|
|
|
+ String res2= requestService.addClient(client);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res2);
|
|
|
+ clientId = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ clientId=client.getId();
|
|
|
}
|
|
|
if (temp == null) {
|
|
|
temp = new Project();
|
|
@@ -358,7 +385,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
if (projectName == null || !projectName.equals(data.getName())) {
|
|
|
temp.setName(this.getImportProjectName(temp.getName()));
|
|
|
}
|
|
|
- temp.setClientId(client.getId());
|
|
|
+ temp.setClientId(clientId);
|
|
|
if (projectId == null || projectId.equals(0)) {
|
|
|
temp.setCreateBy(userId);
|
|
|
temp.setCreateTime(DateUtils.getDateTime());
|
|
@@ -371,14 +398,20 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
- public String add(Project project) {
|
|
|
+ public String add(Project project) throws IOException {
|
|
|
PersonnelVO user = cacheUtils.getLoginUserPersonnel(loginUtils.getId());
|
|
|
Project temp = this.getProjectByName(project.getName());
|
|
|
if (temp != null) {
|
|
|
return Response.error("专题库名称已存在");
|
|
|
}
|
|
|
if (project.getClientId() == -1) {
|
|
|
- project.setClientId(this.getNewClientId(project.getClientName(), user.getTenantId()));
|
|
|
+ ClientDTO clientDTO =new ClientDTO();
|
|
|
+ clientDTO.setName(project.getClientName());
|
|
|
+ clientDTO.setTenantId(user.getTenantId());
|
|
|
+ String res = requestService.addClient(clientDTO);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ Integer clientId = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
+ project.setClientId(clientId);
|
|
|
}
|
|
|
project.setScenario(StringUtils.join(project.getScenarioList(), ","));
|
|
|
project.setType(StringUtils.join(project.getTypeList(), ","));
|
|
@@ -391,14 +424,19 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
- public String edit(Project project) {
|
|
|
+ public String edit(Project project) throws IOException {
|
|
|
Project temp = this.getProjectByName(project.getName());
|
|
|
- Project project1 = this.getProjectById(project.getId());
|
|
|
if (temp != null && !temp.getId().equals(project.getId())) {
|
|
|
return Response.error("专题库名称已存在");
|
|
|
}
|
|
|
if (project.getClientId() == -1) {
|
|
|
- project.setClientId(this.getNewClientId(project.getClientName(), project1.getTenantId()));
|
|
|
+ ClientDTO clientDTO =new ClientDTO();
|
|
|
+ clientDTO.setName(project.getClientName());
|
|
|
+ clientDTO.setTenantId(project.getTenantId());
|
|
|
+ String res = requestService.addClient(clientDTO);
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ Integer clientId = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
+ project.setClientId(clientId);
|
|
|
}
|
|
|
project.setScenario(StringUtils.join(project.getScenarioList(), ","));
|
|
|
project.setType(StringUtils.join(project.getTypeList(), ","));
|
|
@@ -419,19 +457,21 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
return Response.success();
|
|
|
}
|
|
|
|
|
|
- private Integer getNewClientId(String name, Integer tenantId) {
|
|
|
-
|
|
|
- Client client = clientService.getOne(Wrappers.<Client>lambdaQuery().eq(Client::getName, name).last("limit 1"));
|
|
|
+ private Integer getNewClientId(String name) throws IOException {
|
|
|
+ String res =requestService.getClientByName(name);
|
|
|
+ ClientDTO client =JSONObject.parseObject(res,ClientDTO.class);
|
|
|
+ Integer clientId =0;
|
|
|
if (client == null) {
|
|
|
- client = new Client();
|
|
|
client.setName(name);
|
|
|
- client.setStatus(1);
|
|
|
- client.setCreateBy(loginUtils.getId());
|
|
|
- client.setCreateTime(DateUtils.getDateTime());
|
|
|
- client.setTenantId(tenantId);
|
|
|
- client.insert();
|
|
|
+ String res2= requestService.addClient(client);
|
|
|
+
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res2);
|
|
|
+ clientId = Integer.parseInt(jsonObject.get("data").toString());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ clientId =client.getId();
|
|
|
}
|
|
|
- return client.getId();
|
|
|
+ return clientId;
|
|
|
}
|
|
|
|
|
|
private void addProjectUser(Integer projectId) {
|
|
@@ -458,7 +498,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper, Project> {
|
|
|
Project project = new Project();
|
|
|
project.setSort(1);
|
|
|
project.setName(row.get("专题库名称").toString());
|
|
|
- project.setClientId(this.getNewClientId(row.get("委托方").toString(), user.getTenantId()));
|
|
|
+ project.setClientId(this.getNewClientId(row.get("委托方").toString()));
|
|
|
project.setRemark(row.get("备注").toString());
|
|
|
project.setCreateBy(loginUtils.getId());
|
|
|
project.setCreateTime(DateUtils.getDateTime());
|