Selaa lähdekoodia

Merge branch 'master' of http://47.100.37.243:10191/wutt/manHourHousekeeper into master

seyason 1 vuosi sitten
vanhempi
commit
86d3e576fd

+ 69 - 18
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -7,6 +7,7 @@ import com.management.platform.entity.*;
 import com.management.platform.entity.vo.OvertimeListVO;
 import com.management.platform.mapper.*;
 import com.management.platform.service.OperationRecordService;
+import com.management.platform.service.ParticipationService;
 import com.management.platform.service.ProjectService;
 import com.management.platform.util.DockWithMLD;
 import com.management.platform.util.HttpRespMsg;
@@ -66,6 +67,10 @@ public class ProjectController {
     private WxCorpInfoMapper wxCorpInfoMapper;
     @Resource
     private OperationRecordService operationRecordService;
+    @Resource
+    private ParticipationService participationService;
+
+
     @RequestMapping("/testRead")
     public HttpRespMsg testRead(String jobId) {
         return projectService.testRead(jobId);
@@ -1233,31 +1238,77 @@ public class ProjectController {
         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", 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<Project> needInsert=new ArrayList<>();
+        int insert=0;
+        int update=0;
         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();
-            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.setCompanyId(876)
-                       .setContent("同步来自泛微的项目数据,共"+needInsert.size()+"条数据")
+                       .setContent("同步新增来自泛微的项目数据,共"+insert+"条数据"+"\n"+"同步更新来自泛微的项目数据,共"+update+"条数据")
                        .setModuleName("项目管理").setOperationTime(LocalDateTime.now())
                        .setOperatorName(user.getName());
         operationRecordService.save(operationRecord);

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java

@@ -3053,7 +3053,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
         }
         Company company = new Company().setCompanyName(companyName)
                 .setExpirationDate(LocalDateTime.now().plusDays(36500));
-        company.setPackageWorktime(1);
+        company.setPackageProject(0);
         companyMapper.insert(company);
         //生成工作时长
         TimeType timeType = new TimeType();

+ 66 - 17
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -141,6 +141,9 @@ public class TimingTask {
     private SysRoleMapper sysRoleMapper;
     @Resource
     private UserService userService;
+    @Resource
+    private ParticipationService participationService;
+
 
     private static final List<Integer> VALID_TOKEN_CHARS = new ArrayList<>();
     static {
@@ -567,30 +570,76 @@ public class TimingTask {
             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"));
-            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", 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"));
-            List<Project> needInsert=new ArrayList<>();
+            int insert=0;
+            int update=0;
             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();
-                Project project=new Project();
-                project.setProjectName(String.valueOf(map.get("xmmc")))
-                        .setProjectCode(String.valueOf(map.get("xmdm")))
-                        .setCompanyId(compId)
-                        .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++;
+                        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(needInsert.size()>0){
-                projectService.saveBatch(needInsert);
             }
             OperationRecord operationRecord=new OperationRecord();
             operationRecord.setCompanyId(compId)
-                    .setContent("同步来自泛微的项目数据,共"+needInsert.size()+"条数据")
+                    .setContent("同步来自泛微的项目数据,共"+insert+"条数据"+"\n"+"同步更新来自泛微的项目数据,共"+update+"条数据")
                     .setModuleName("项目管理").setOperationTime(LocalDateTime.now());
             operationRecordService.save(operationRecord);
         }