|
@@ -259,6 +259,27 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //由于未知原因,任务加了参与人,但是项目会稍后丢失参与人,我们系统要自动修复一下
|
|
|
+ @Scheduled(cron = "0 20 1 ? * *")
|
|
|
+ private void autoFixProjectParticipation() {
|
|
|
+ if (isDev) return;
|
|
|
+ Integer companyId = 3092;
|
|
|
+ List<TaskExecutor> missedParticipation = taskExecutorMapper.getMissedParticipation(companyId);
|
|
|
+ List<Participation> addList = new ArrayList<>();
|
|
|
+ for (TaskExecutor executor : missedParticipation) {
|
|
|
+ Participation participation = new Participation();
|
|
|
+ participation.setProjectId(executor.getProjectId());
|
|
|
+ participation.setUserId(executor.getExecutorId());
|
|
|
+ if (addList.stream().noneMatch(p->p.getProjectId().equals(participation.getProjectId()) && p.getUserId().equals(participation.getUserId()))) {
|
|
|
+ addList.add(participation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("需要补参与人数据:"+addList.size());
|
|
|
+ if (addList.size() > 0) {
|
|
|
+ participationMapper.insertBatch(addList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
|
|
|
@Scheduled(cron = "0 11 2 ? * *")
|
|
@@ -594,124 +615,6 @@ public class TimingTask {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Scheduled(cron = "0 15 3 ? * *")
|
|
|
- private void synFanWeiProjectDate() {
|
|
|
- if (isDev) return;
|
|
|
- if(!isPrivateDeploy) return;
|
|
|
- List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
|
|
|
- List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
|
|
|
- if(compIds.isEmpty()){
|
|
|
- return;
|
|
|
- }
|
|
|
- for (Integer compId : compIds) {
|
|
|
- String url="http://10.1.10.51:20175/api/cube/restful/interface/getModeDataPageList/getProejct";
|
|
|
- JSONObject jsonObject=new JSONObject();
|
|
|
- jsonObject.put("rybh","");
|
|
|
- jsonObject.put("workDate","");
|
|
|
- String jsonString = jsonObject.toJSONString();
|
|
|
- HttpRespMsg result = DockWithMLD.getResult(url, null);
|
|
|
- List<Map<String,Object>> dataList= (List<Map<String, Object>>) result.data;
|
|
|
- List<Project> workTimeProjectList = projectService.list(new QueryWrapper<Project>().eq("company_id", compId).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", compId).select("job_number", "id","name"));
|
|
|
- int insert=0;
|
|
|
- int update=0;
|
|
|
- StringBuilder sb=new StringBuilder();
|
|
|
- sb.append("更新的项目:");
|
|
|
- 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();
|
|
|
- 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());
|
|
|
- }
|
|
|
- boolean isUpdate=false;
|
|
|
- if(!item.getInchargerId().equals(first.get().getId())){
|
|
|
- update++;
|
|
|
- isUpdate=true;
|
|
|
- }
|
|
|
- projectService.updateById(item);
|
|
|
- List<Participation> allParticipations = participationService.list(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);
|
|
|
- }
|
|
|
- }
|
|
|
- List<String> collect = allParticipations.stream().map(al -> al.getUserId()).distinct().collect(Collectors.toList());
|
|
|
- List<String> collect1 = participationList.stream().map(pl -> pl.getUserId()).distinct().collect(Collectors.toList());
|
|
|
- System.out.println("之前的数据:"+collect);
|
|
|
- System.out.println("之后的数据:"+collect1);
|
|
|
- if(collect.size()!=collect1.size()){
|
|
|
- sb.append("["+item.getProjectName()+"/"+item.getProjectCode()+"]"+"\n");
|
|
|
- if(!isUpdate){
|
|
|
- update++;
|
|
|
- }
|
|
|
-
|
|
|
- }else if(!collect.containsAll(collect1)){
|
|
|
- sb.append("["+item.getProjectName()+"/"+item.getProjectCode()+"]"+"\n");
|
|
|
- if(!isUpdate){
|
|
|
- update++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- OperationRecord operationRecord=new OperationRecord();
|
|
|
- operationRecord.setCompanyId(compId)
|
|
|
- .setContent("同步来自泛微的项目数据,共"+insert+"条数据"+"\n"+"同步更新来自泛微的项目数据,共"+update+"条数据"+"\n"+sb.toString())
|
|
|
- .setModuleName("项目管理").setOperationTime(LocalDateTime.now());
|
|
|
- if(operationRecord.getContent().length()>1000){
|
|
|
- operationRecord.setContent(operationRecord.getContent().substring(0,999));
|
|
|
- }
|
|
|
- operationRecordService.save(operationRecord);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
|
|
|
//专门给明夷的定时任务
|