|
@@ -7,6 +7,7 @@ import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.OvertimeListVO;
|
|
import com.management.platform.entity.vo.OvertimeListVO;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.service.OperationRecordService;
|
|
import com.management.platform.service.OperationRecordService;
|
|
|
|
+import com.management.platform.service.ParticipationService;
|
|
import com.management.platform.service.ProjectService;
|
|
import com.management.platform.service.ProjectService;
|
|
import com.management.platform.util.DockWithMLD;
|
|
import com.management.platform.util.DockWithMLD;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
@@ -66,6 +67,10 @@ public class ProjectController {
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
private WxCorpInfoMapper wxCorpInfoMapper;
|
|
@Resource
|
|
@Resource
|
|
private OperationRecordService operationRecordService;
|
|
private OperationRecordService operationRecordService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ParticipationService participationService;
|
|
|
|
+
|
|
|
|
+
|
|
@RequestMapping("/testRead")
|
|
@RequestMapping("/testRead")
|
|
public HttpRespMsg testRead(String jobId) {
|
|
public HttpRespMsg testRead(String jobId) {
|
|
return projectService.testRead(jobId);
|
|
return projectService.testRead(jobId);
|
|
@@ -1233,31 +1238,77 @@ public class ProjectController {
|
|
String jsonString = jsonObject.toJSONString();
|
|
String jsonString = jsonObject.toJSONString();
|
|
HttpRespMsg result = DockWithMLD.getResult(url, null);
|
|
HttpRespMsg result = DockWithMLD.getResult(url, null);
|
|
List<Map<String,Object>> dataList= (List<Map<String, Object>>) result.data;
|
|
List<Map<String,Object>> dataList= (List<Map<String, Object>>) result.data;
|
|
- List<Project> workTimeProjectList = projectService.list(new QueryWrapper<Project>().eq("company_id", 876).select("project_code"));
|
|
|
|
- List<Map<String, Object>> mapList = dataList.stream().filter(dl ->!dl.get("xmdm").equals("")&&
|
|
|
|
- !workTimeProjectList.stream().anyMatch(wl->wl.getProjectCode()!=null&&!wl.getProjectCode().equals("")&&wl.getProjectCode().equals(dl.get("xmdm")))).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Project> workTimeProjectList = projectService.list(new QueryWrapper<Project>().eq("company_id", 876).select("project_code","id"));
|
|
|
|
+// List<Map<String, Object>> mapList = dataList.stream().filter(dl ->!dl.get("xmdm").equals("")&&
|
|
|
|
+// !workTimeProjectList.stream().anyMatch(wl->wl.getProjectCode()!=null&&!wl.getProjectCode().equals("")&&wl.getProjectCode().equals(dl.get("xmdm")))).collect(Collectors.toList());
|
|
|
|
+ List<Map<String, Object>> mapList = dataList;
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", 876).select("job_number", "id","name"));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", 876).select("job_number", "id","name"));
|
|
- List<Project> needInsert=new ArrayList<>();
|
|
|
|
|
|
+ int insert=0;
|
|
|
|
+ int update=0;
|
|
for (Map<String, Object> map : mapList) {
|
|
for (Map<String, Object> map : mapList) {
|
|
|
|
+ List<Participation> participationList=new ArrayList<>();
|
|
Optional<User> first = userList.stream().filter(ul ->ul.getJobNumber()!=null&&ul.getJobNumber().equals(map.get("xmfzrplxm"))).findFirst();
|
|
Optional<User> first = userList.stream().filter(ul ->ul.getJobNumber()!=null&&ul.getJobNumber().equals(map.get("xmfzrplxm"))).findFirst();
|
|
- Project project=new Project();
|
|
|
|
- project.setProjectName(String.valueOf(map.get("xmmc")))
|
|
|
|
- .setProjectCode(String.valueOf(map.get("xmdm")))
|
|
|
|
- .setCompanyId(876)
|
|
|
|
- .setCreateDate(LocalDate.now());
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- project.setInchargerId(first.get().getId())
|
|
|
|
- .setInchargerName(first.get().getName());
|
|
|
|
|
|
+ if(workTimeProjectList.stream().anyMatch(wl->wl.getProjectCode()!=null&&wl.getProjectCode().equals(map.get("xmdm")))){
|
|
|
|
+ Optional<Project> project = workTimeProjectList.stream().filter(wl -> wl.getProjectCode() != null && wl.getProjectCode().equals(map.get("xmdm"))).findFirst();
|
|
|
|
+ if(project.isPresent()){
|
|
|
|
+ Project item = project.get();
|
|
|
|
+ item.setProjectName(String.valueOf(map.get("xmmc")));
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ item.setInchargerId(first.get().getId())
|
|
|
|
+ .setInchargerName(first.get().getName());
|
|
|
|
+ }
|
|
|
|
+ projectService.updateById(item);
|
|
|
|
+ update++;
|
|
|
|
+ participationService.remove(new QueryWrapper<Participation>().eq("project_id",item.getId()));
|
|
|
|
+ if(map.get("xmcygs")!=null&&!map.get("xmcygs").equals("")){
|
|
|
|
+ participationService.remove(new QueryWrapper<Participation>().eq("project_id",item.getId()));
|
|
|
|
+ String participations = String.valueOf(map.get("xmcygs"));
|
|
|
|
+ List<String> list = Arrays.asList(participations.split(","));
|
|
|
|
+ for (String s : list) {
|
|
|
|
+ Optional<User> participation = userList.stream().filter(ul ->ul.getJobNumber()!=null&&ul.getJobNumber().equals(s)).findFirst();
|
|
|
|
+ if(participation.isPresent()){
|
|
|
|
+ Participation p=new Participation();
|
|
|
|
+ p.setUserId(participation.get().getId()).setProjectId(item.getId());
|
|
|
|
+ participationList.add(p);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(participationList.size()>0){
|
|
|
|
+ participationService.saveBatch(participationList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ Project project=new Project();
|
|
|
|
+ project.setProjectName(String.valueOf(map.get("xmmc")))
|
|
|
|
+ .setProjectCode(String.valueOf(map.get("xmdm")))
|
|
|
|
+ .setCompanyId(876)
|
|
|
|
+ .setCreateDate(LocalDate.now());
|
|
|
|
+ if(first.isPresent()){
|
|
|
|
+ project.setInchargerId(first.get().getId())
|
|
|
|
+ .setInchargerName(first.get().getName());
|
|
|
|
+ }
|
|
|
|
+ projectService.save(project);
|
|
|
|
+ insert++;
|
|
|
|
+ if(map.get("xmcygs")!=null&&!map.get("xmcygs").equals("")){
|
|
|
|
+ String participations = String.valueOf(map.get("xmcygs"));
|
|
|
|
+ List<String> list = Arrays.asList(participations.split(","));
|
|
|
|
+ for (String s : list) {
|
|
|
|
+ Optional<User> participation = userList.stream().filter(ul ->ul.getJobNumber()!=null&&ul.getJobNumber().equals(s)).findFirst();
|
|
|
|
+ if(participation.isPresent()){
|
|
|
|
+ Participation p=new Participation();
|
|
|
|
+ p.setUserId(participation.get().getId()).setProjectId(project.getId());
|
|
|
|
+ participationList.add(p);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(participationList.size()>0){
|
|
|
|
+ participationService.saveBatch(participationList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- needInsert.add(project);
|
|
|
|
- }
|
|
|
|
- if(!projectService.saveBatch(needInsert)){
|
|
|
|
- httpRespMsg.setError("操作失败");
|
|
|
|
- return httpRespMsg;
|
|
|
|
}
|
|
}
|
|
OperationRecord operationRecord=new OperationRecord();
|
|
OperationRecord operationRecord=new OperationRecord();
|
|
operationRecord.setCompanyId(876)
|
|
operationRecord.setCompanyId(876)
|
|
- .setContent("同步来自泛微的项目数据,共"+needInsert.size()+"条数据")
|
|
|
|
|
|
+ .setContent("同步新增来自泛微的项目数据,共"+insert+"条数据"+"\n"+"同步更新来自泛微的项目数据,共"+update+"条数据")
|
|
.setModuleName("项目管理").setOperationTime(LocalDateTime.now())
|
|
.setModuleName("项目管理").setOperationTime(LocalDateTime.now())
|
|
.setOperatorName(user.getName());
|
|
.setOperatorName(user.getName());
|
|
operationRecordService.save(operationRecord);
|
|
operationRecordService.save(operationRecord);
|