浏览代码

修复请假条下载问题。

Cyangbin 2 年之前
父节点
当前提交
910089f32d

+ 12 - 23
src/main/java/com/galaxis/manatee/controller/TestController.java

@@ -1,38 +1,16 @@
 package com.galaxis.manatee.controller;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.galaxis.manatee.constant.ChuanYunConstant;
-import com.galaxis.manatee.dao.ChuanyunMemberCostDao;
-import com.galaxis.manatee.dao.ChuanyunSelfWorkHourDao;
 import com.galaxis.manatee.dao.ChuanyunUserCompanyDao;
-import com.galaxis.manatee.entity.chuanyun.data.object.*;
-import com.galaxis.manatee.entity.chuanyun.dto.*;
-import com.galaxis.manatee.manager.ChuanYunManager;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunUserCompanyDO;
 import com.galaxis.manatee.service.*;
 import com.galaxis.manatee.task.ChuanyunBasicDataScheduledTask;
-import com.galaxis.manatee.util.TimeUtil;
 import lombok.extern.slf4j.Slf4j;
-import net.sf.json.util.JSONUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -57,6 +35,9 @@ public class TestController {
 
     private final ChuanyunBasicDataScheduledTask chuanyunBasicDataScheduledTask;
 
+    @Autowired
+    private DingTalkScheduledTask dingTalkScheduledTask;
+
 
     public TestController(LogUpdateService logUpdateService, LogStandardService logStandardService, LogCheckService logCheckService, LogService logService, LogDownloadService logDownloadService, ProjectMemberService projectMemberService, ChuanyunBasicDataScheduledTask chuanyunBasicDataScheduledTask) {
         this.logUpdateService = logUpdateService;
@@ -268,6 +249,14 @@ public class TestController {
 
     }
 
+    /**
+     * 上传请假信息
+     */
+    @GetMapping("/test/pullAskForLeave")
+    public void pullAskForLeave() {
+        dingTalkScheduledTask.manuallyAskForLeave();
+
+    }
 
 }
 

+ 2 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunMonthLaborCostWgDao.java

@@ -16,4 +16,6 @@ public interface ChuanyunMonthLaborCostWgDao extends GalaxisRepository<ChuanyunM
 
     List<ChuanyunMonthLaborCostWgDTO> findAllByProjectCode(String projectCode);
 
+    List<ChuanyunMonthLaborCostWgDTO> findAllByProjectCodeAndProjectId(String projectCode, String projectId);
+
 }

+ 2 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/dto/ChuanyunLaborCostWgPrimaryKey.java

@@ -13,6 +13,8 @@ import java.time.LocalDateTime;
 @Data
 public class ChuanyunLaborCostWgPrimaryKey {
 
+    protected String projectid;
+
     protected String projectcode;
 
     @JsonSerialize(using = LocalDateTimeSerializer.class)

+ 2 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/dto/ChuanyunMonthLaborCostWgDTO.java

@@ -29,6 +29,8 @@ public class ChuanyunMonthLaborCostWgDTO{
     @GenericGenerator(name ="idGeneratorChuanyunImplCos" ,strategy="com.galaxis.manatee.capsule.util.GalaxisIdGenerator")
     private Long id;
 
+    private String projectId;
+
     private String projectCode;
 
     private String workGroupId;

+ 1 - 1
src/main/java/com/galaxis/manatee/service/DingTalkAuthorization.java

@@ -31,7 +31,7 @@ public class DingTalkAuthorization {
      * @throws URISyntaxException   URI异常
      */
     @Scheduled(fixedDelay = 7000000L)
-    private void getToken() throws URISyntaxException {
+    public void getToken() throws URISyntaxException {
         var restTemplate=new RestTemplate();
         var uri=new URI(getTokenUri+"?appkey="+ DingTalkConstant.DING_TALK_APP_KEY +"&appsecret="+DingTalkConstant.DING_TALK_APP_SECRET);
         DingTalkToken dingTalkToken=restTemplate.getForObject(uri,DingTalkToken.class);

+ 37 - 12
src/main/java/com/galaxis/manatee/service/DingTalkScheduledTask.java

@@ -16,16 +16,14 @@ import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunProjectChangeDO;
 import com.galaxis.manatee.entity.ding.DingTalkProcessInstance;
 import com.taobao.api.ApiException;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.time.temporal.ChronoUnit;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-import java.util.UUID;
+import java.util.*;
 
 /**
  * 钉钉定时任务
@@ -38,6 +36,9 @@ import java.util.UUID;
 @Service
 public class DingTalkScheduledTask {
 
+    @Autowired
+    private DingTalkAuthorization dingTalkAuthorization;
+
     /**
      * 审批Id列表客户端
      */
@@ -170,6 +171,16 @@ public class DingTalkScheduledTask {
         }
     }
 
+    public void manuallyAskForLeave(){
+
+        try {
+            dingTalkAuthorization.getToken();
+            this.updateChuanyunAskForLeave(DingTalkConstant.PROCESS_CODE_ASKFORLEAVE);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
     private void updateChuanyunAskForLeave(String businessTripProcessCode) throws ApiException {
         var flag = true;
         //单个请求
@@ -191,7 +202,7 @@ public class DingTalkScheduledTask {
             if (oapiProcessinstanceListidsResponse.getErrcode() != 0) {
                 log.info(oapiProcessinstanceListidsResponse.getErrmsg());
                 try {
-                    Thread.sleep(5000);
+                    Thread.sleep(1000);
                 } catch (InterruptedException e) {
                     log.error(e.getMessage());
                 }
@@ -203,17 +214,31 @@ public class DingTalkScheduledTask {
                 if (instance.isEmpty()) {
                     OapiProcessinstanceGetRequest request = new OapiProcessinstanceGetRequest();
                     request.setProcessInstanceId(resultId);
+                    OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = null;
                     try {
-                        OapiProcessinstanceGetResponse oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
-                        ChuanyunAskForLeaveDO chuanyunAskForLeaveDo = ChuanyunAskForLeaveDO.fromAskForLeaveDTO(oapiProcessinstanceGetResponse.getProcessInstance());
-                        List<ChuanyunAskForLeaveDO> existsAskForLeave = chuanyunAskForLeaveDao.findByTitleSQL(chuanyunAskForLeaveDo.getTitle());
-                        if (existsAskForLeave != null && !existsAskForLeave.isEmpty()) {
-                            chuanyunAskForLeaveDao.deleteById(existsAskForLeave.get(0).getObjectId());
-                        }
-                        chuanyunAskForLeaveDoList.add(chuanyunAskForLeaveDo);
+                        oapiProcessinstanceGetResponse = processInstanceClient.execute(request, DingTalkConstant.DING_TALK_TOKEN);
                     } catch (ApiException e) {
                         e.printStackTrace();
                     }
+                    if (Objects.isNull(oapiProcessinstanceGetResponse)){
+                        log.info("查询请假单异常");
+                        return;
+                    }
+                    if (oapiProcessinstanceGetResponse.getErrcode() != 0){
+                        log.info(oapiProcessinstanceGetResponse.getErrmsg());
+                        try {
+                            Thread.sleep(1000);
+                        } catch (InterruptedException e) {
+                            log.error(e.getMessage());
+                        }
+                        return;
+                    }
+                    ChuanyunAskForLeaveDO chuanyunAskForLeaveDo = ChuanyunAskForLeaveDO.fromAskForLeaveDTO(oapiProcessinstanceGetResponse.getProcessInstance());
+                    List<ChuanyunAskForLeaveDO> existsAskForLeave = chuanyunAskForLeaveDao.findByTitleSQL(chuanyunAskForLeaveDo.getTitle());
+                    if (existsAskForLeave != null && !existsAskForLeave.isEmpty()) {
+                        chuanyunAskForLeaveDao.deleteById(existsAskForLeave.get(0).getObjectId());
+                    }
+                    chuanyunAskForLeaveDoList.add(chuanyunAskForLeaveDo);
                 }
             });
 

+ 1 - 1
src/main/java/com/galaxis/manatee/service/impl/WorkGroupServiceImpl.java

@@ -609,7 +609,7 @@ public class WorkGroupServiceImpl implements WorkGroupService {
                                     totalLaborCost = monthLaborCostWgDTOS.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
                                 }
 
-                                ChuanyunImplCostDO old = implCostDao.findByProjectCodeAndWorkGroupAndLocalDate(groupProjectCode, workGroupId, localDate.atStartOfDay());
+                                ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroupAndLocalDate(groupProjectObjectId, groupProjectCode, workGroupId, localDate.atStartOfDay());
                                 if (!Objects.isNull(old)) {
                                     BigDecimal oldImplCost = old.getImplCost();
                                     BigDecimal oldManDay = old.getManDay();

+ 2 - 2
src/main/resources/application.yml

@@ -50,9 +50,9 @@ spring:
         size: 500
       thread-name-prefix: scheduled-task-
   datasource:
-    url: jdbc:mysql://10.1.6.49:3306/manatee?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://10.2.5.35:3306/manatee?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai
     username: root
-    password: root
+    password: j$%rW-GRu$H#pj%V2M-B
     hikari:
       maximum-pool-size: 128
   jpa:

+ 1 - 1
src/test/java/com/galaxis/manatee/Test/LogTest.java

@@ -24,7 +24,7 @@ public class LogTest {
     @Test
     public void downloadLogByUserId(){
 
-        logService.downloadLogByUserId("28f1291d-b322-4983-9893-cc7f1742fcc2");
+        logService.downloadLogByUserId("f24ae788-8c3f-4cae-99ca-955ea684e373");
     }
 
 }

+ 39 - 0
src/test/java/com/galaxis/manatee/Test/askLeaveTest.java

@@ -0,0 +1,39 @@
+package com.galaxis.manatee.Test;
+
+import com.galaxis.manatee.dao.ChuanyunAskForLeaveDao;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunAskForLeaveDO;
+import com.galaxis.manatee.service.DingTalkScheduledTask;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+@SpringBootTest
+public class askLeaveTest {
+
+    private DingTalkScheduledTask dingTalkScheduledTask;
+
+    private ChuanyunAskForLeaveDao askForLeaveDao;
+
+    @Autowired
+    public void setDingTalkScheduledTask(DingTalkScheduledTask dingTalkScheduledTask) {
+        this.dingTalkScheduledTask = dingTalkScheduledTask;
+    }
+
+    @Autowired
+    public void setAskForLeaveDao(ChuanyunAskForLeaveDao askForLeaveDao) {
+        this.askForLeaveDao = askForLeaveDao;
+    }
+
+    @Test
+    void test(){
+        dingTalkScheduledTask.manuallyAskForLeave();
+    }
+
+    @Test
+    void test2(){
+        List<ChuanyunAskForLeaveDO> byTitleSQL = askForLeaveDao.findByTitleSQL("2022-09-09 上午张学炳提交的请假");
+        System.out.println(byTitleSQL);
+    }
+}

+ 2 - 4
src/test/java/com/galaxis/manatee/Test/buildProjectTest/BuildProjectTest.java

@@ -46,7 +46,7 @@ public class BuildProjectTest {
         ObjectMapper objectMapper = new ObjectMapper();
         List<ChuanyunBuildProject> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
         });
-
+        log.info("bpList: {}", bpList);
 
     }
 
@@ -125,7 +125,7 @@ public class BuildProjectTest {
 
 
     @Test
-    void syncBuildProjectToSubTable(){
+    void syncBuildProjectToSubTable() {
         List<String> m = List.of("F0000016_2,实施");
         var filter = Filter.instance(0, 400, true, Filter.AND, m);
         ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
@@ -144,8 +144,6 @@ public class BuildProjectTest {
         });
 
 
-
-
     }
 
     @Data

+ 370 - 0
src/test/java/com/galaxis/manatee/Test/fixStandard/fixStandardWorkHour.java

@@ -0,0 +1,370 @@
+package com.galaxis.manatee.Test.fixStandard;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.galaxis.manatee.constant.ChuanYunConstant;
+import com.galaxis.manatee.dao.*;
+import com.galaxis.manatee.entity.chuanyun.data.object.*;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizDTO;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunMonthLaborCostWgDTO;
+import com.galaxis.manatee.entity.chuanyun.dto.Filter;
+import com.galaxis.manatee.manager.ChuanYunManager;
+import com.galaxis.manatee.service.WorkGroupService;
+import com.galaxis.manatee.util.CollectionsUtils;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.util.StringUtils;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Slf4j
+@SpringBootTest
+public class fixStandardWorkHour {
+
+    private ChuanYunManager chuanYunManager;
+    private ChuanyunGroupProjectDao groupProjectDao;
+    private ChuanyunProjectDao projectDao;
+    private ChuanyunSelfWorkHourDao selfWorkHourDao;
+    private ChuanyunReimbursementDao reimbursementDao;
+    private ChuanyunMonthLaborCostWgDao chuanyunMonthLaborCostWgDao;
+    private ChuanyunImplCostDao implCostDao;
+    private WorkGroupService workGroupService;
+
+
+    @Autowired
+    public void setChuanYunManager(ChuanYunManager chuanYunManager) {
+        this.chuanYunManager = chuanYunManager;
+    }
+
+    @Autowired
+    public void setGroupProjectDao(ChuanyunGroupProjectDao groupProjectDao) {
+        this.groupProjectDao = groupProjectDao;
+    }
+
+    @Autowired
+    public void setProjectDao(ChuanyunProjectDao projectDao) {
+        this.projectDao = projectDao;
+    }
+
+    @Autowired
+    public void setSelfWorkHourDao(ChuanyunSelfWorkHourDao selfWorkHourDao) {
+        this.selfWorkHourDao = selfWorkHourDao;
+    }
+
+    @Autowired
+    public void setReimbursementDao(ChuanyunReimbursementDao reimbursementDao) {
+        this.reimbursementDao = reimbursementDao;
+    }
+
+    @Autowired
+    public void setWorkGroupService(WorkGroupService workGroupService) {
+        this.workGroupService = workGroupService;
+    }
+
+    @Autowired
+    public void setChuanyunMonthLaborCostWgDao(ChuanyunMonthLaborCostWgDao chuanyunMonthLaborCostWgDao) {
+        this.chuanyunMonthLaborCostWgDao = chuanyunMonthLaborCostWgDao;
+    }
+
+    @Autowired
+    public void setImplCostDao(ChuanyunImplCostDao implCostDao) {
+        this.implCostDao = implCostDao;
+    }
+
+    @Test
+    void fix() {
+
+        var objectMapper = new ObjectMapper();
+        var start = 0;
+        var totalCount = 0L;
+        var flag = true;
+        var pageSize = 500;
+        List<String> m = List.of("F0000005_5,生产项目", "F0000004_5,0", "F0000002_2,8352d30b-1d44-4c70-be3f-4cef2ace2dd5");
+
+        while (flag) {
+
+            //从氚云查询数据
+            var filter = Filter.instance(start, start + pageSize, true, Filter.AND, m);
+            ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
+            try {
+                chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunMemberHourDO.SCHEMA_CODE, filter);
+            } catch (JsonProcessingException e) {
+                e.printStackTrace();
+            }
+            if (chuanyunFindAllResponse.getReturnData() == null) {
+                flag = false;
+                continue;
+            }
+            if (chuanyunFindAllResponse.getReturnData().getTotalCount() >= start + pageSize) {
+                start += pageSize;
+            } else {
+                flag = false;
+            }
+            totalCount = chuanyunFindAllResponse.getReturnData().getTotalCount();
+            //转化为POJO
+            List<ChuanyunMemberHourDO> result = objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
+            });
+            result.parallelStream().forEach(chuanyunMemberHourDO -> {
+                try {
+                    if (Objects.isNull(chuanyunMemberHourDO.getProjectCode()) || !StringUtils.hasLength(chuanyunMemberHourDO.getProjectCode())) {
+                        log.info("{}", chuanyunMemberHourDO);
+                        if (!Objects.isNull(chuanyunMemberHourDO.getProjectId()) && StringUtils.hasLength(chuanyunMemberHourDO.getProjectId())) {
+                            String projectCode = "";
+                            Optional<ChuanyunGroupProjectDO> groupProjectDO = groupProjectDao.findById(chuanyunMemberHourDO.getProjectId());
+                            if (groupProjectDO.isPresent()) {
+                                projectCode = groupProjectDO.get().getProjectCode();
+                            } else {
+                                Optional<ChuanyunProjectDO> projectDO = projectDao.findById(chuanyunMemberHourDO.getProjectId());
+                                if (projectDO.isPresent()) {
+                                    projectCode = projectDO.get().getProjectCode();
+                                }
+                            }
+                            if (StringUtils.hasLength(projectCode)) {
+                                UpdateProjectCodeDTO updateProjectCodeDTO = new UpdateProjectCodeDTO(projectCode);
+                                String s = objectMapper.writeValueAsString(updateProjectCodeDTO);
+                                log.info("更新项目编号: {}", s);
+                                chuanYunManager.update(ChuanyunMemberHourDO.SCHEMA_CODE, chuanyunMemberHourDO.getObjectId(), s);
+                            }
+
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            });
+            log.info("start: {},total: {}", start, totalCount);
+
+
+        }
+
+
+    }
+
+    @Data
+    class UpdateProjectCodeDTO {
+
+        @JsonProperty("F0000011")
+        private String projectCode;
+
+        public UpdateProjectCodeDTO(String projectCode) {
+            this.projectCode = projectCode;
+        }
+    }
+
+    @Test
+    void fixImplCost() {
+        Optional<ChuanyunGroupProjectDO> groupProjectDOOptional = groupProjectDao.findById("2e3018f9-8ab7-11ea-8ae9-7cd30ab711fe");
+        ChuanyunGroupProjectDO chuanyunGroupProjectDO = groupProjectDOOptional.get();
+        String groupProjectObjectId = chuanyunGroupProjectDO.getObjectId();
+        String groupProjectCode = chuanyunGroupProjectDO.getProjectCode();
+        // 查询项目报销单
+        Map<LocalDate, List<ChuanyunReimbursementDO>> reimbursementMap = new HashMap<>();
+        Map<LocalDate, List<ChuanyunSelfWorkHourDO>> workHoursMap = new HashMap<>();
+        Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> laborCostMap = new HashMap<>();
+        List<ChuanyunReimbursementDO> reimbursements = reimbursementDao.findAllByGroupProjectIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), List.of(1, 2));
+        // 查询用户在该项目的报销单
+        // 报销单按日期分组
+        Map<LocalDate, List<ChuanyunReimbursementDO>> map1 = reimbursements.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
+            if (!Objects.isNull(chuanyunReimbursementDO.getBusinessDate())) {
+                return LocalDate.of(chuanyunReimbursementDO.getBusinessDate().getYear(), chuanyunReimbursementDO.getBusinessDate().getMonthValue(), 1);
+            } else {
+                return LocalDate.of(2015, 1, 1);
+            }
+        }));
+
+        map1.forEach((localDate, chuanyunReimbursementDOS) -> {
+            boolean containsKey = reimbursementMap.containsKey(localDate);
+            if (containsKey) {
+                // 表示已经存在该key
+                List<ChuanyunReimbursementDO> reimbursementDOList = reimbursementMap.get(localDate);
+                reimbursementDOList.addAll(chuanyunReimbursementDOS);
+                reimbursementMap.put(localDate, reimbursementDOList);
+            } else {
+                reimbursementMap.put(localDate, chuanyunReimbursementDOS);
+            }
+        });
+
+        List<ChuanyunSelfWorkHourDO> workHours = selfWorkHourDao.findAllByProjectIdAndStatusIn(groupProjectObjectId, List.of("1", "2"));
+        Map<LocalDate, List<ChuanyunSelfWorkHourDO>> map2 = workHours.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
+            if (!Objects.isNull(chuanyunSelfWorkHourDO.getDayLogDate())) {
+                return LocalDate.of(chuanyunSelfWorkHourDO.getDayLogDate().getYear(), chuanyunSelfWorkHourDO.getDayLogDate().getMonthValue(), 1);
+            } else {
+                return LocalDate.of(2015, 1, 1);
+            }
+        }));
+        map2.forEach((localDate, chuanyunSelfWorkHourDOS) -> {
+            boolean containsKey = workHoursMap.containsKey(localDate);
+            if (containsKey) {
+                // 表示已经存在该key
+                List<ChuanyunSelfWorkHourDO> selfWorkHours = workHoursMap.get(localDate);
+                selfWorkHours.addAll(chuanyunSelfWorkHourDOS);
+                workHoursMap.put(localDate, selfWorkHours);
+            } else {
+                workHoursMap.put(localDate, chuanyunSelfWorkHourDOS);
+            }
+        });
+
+        // todo 修改为根据项目id来查
+        List<ChuanyunMonthLaborCostWgDTO> laborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCodeAndProjectId(groupProjectCode, groupProjectObjectId);
+        Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> map3 = laborCostWgs.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
+            if (!Objects.isNull(chuanyunMonthLaborCostWgDTO.getLogDate())) {
+                return LocalDate.of(chuanyunMonthLaborCostWgDTO.getLogDate().getYear(), chuanyunMonthLaborCostWgDTO.getLogDate().getMonthValue(), 1);
+            } else {
+                return LocalDate.of(2015, 1, 1);
+            }
+
+        }));
+        map3.forEach((localDate, chuanyunMonthLaborCostWgDTOS) -> {
+            boolean containsKey = laborCostMap.containsKey(localDate);
+            if (containsKey) {
+                // 表示已经存在该key
+                List<ChuanyunMonthLaborCostWgDTO> monthLaborCostWgs = laborCostMap.get(localDate);
+                monthLaborCostWgs.addAll(chuanyunMonthLaborCostWgDTOS);
+                laborCostMap.put(localDate, monthLaborCostWgs);
+            } else {
+                laborCostMap.put(localDate, chuanyunMonthLaborCostWgDTOS);
+            }
+        });
+
+        Set<LocalDate> localDates1 = reimbursementMap.keySet();
+        Set<LocalDate> localDates2 = workHoursMap.keySet();
+        Set<LocalDate> localDates3 = laborCostMap.keySet();
+
+        Set<LocalDate> collections = CollectionsUtils.mergeCollections(localDates1, localDates2);
+        Set<LocalDate> mergeCollections = CollectionsUtils.mergeCollections(collections, localDates3);
+
+        mergeCollections.forEach(localDate -> {
+            List<ChuanyunReimbursementDO> reimbursementList = reimbursementMap.getOrDefault(localDate, Collections.emptyList());
+            List<ChuanyunSelfWorkHourDO> selfWorkHourList = workHoursMap.getOrDefault(localDate, Collections.emptyList());
+            List<ChuanyunMonthLaborCostWgDTO> laborCostWgList = laborCostMap.getOrDefault(localDate, Collections.emptyList());
+
+            Map<String, List<ChuanyunReimbursementDO>> workGroupIdReimbursementMap = reimbursementList.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> {
+                if (Objects.isNull(chuanyunReimbursementDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunReimbursementDO.getWorkGroupId())) {
+                    return ChuanYunConstant.DEFAULT_WORK_GROUP;
+                } else {
+                    return chuanyunReimbursementDO.getWorkGroupId();
+                }
+            }));
+            Map<String, List<ChuanyunSelfWorkHourDO>> workGroupIdSelfWorkHourMap = selfWorkHourList.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> {
+                if (Objects.isNull(chuanyunSelfWorkHourDO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunSelfWorkHourDO.getWorkGroupId())) {
+                    return ChuanYunConstant.DEFAULT_WORK_GROUP;
+                } else {
+                    return chuanyunSelfWorkHourDO.getWorkGroupId();
+                }
+            }));
+            Map<String, List<ChuanyunMonthLaborCostWgDTO>> workGroupIdLaborCostMap = laborCostWgList.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
+                if (Objects.isNull(chuanyunMonthLaborCostWgDTO.getWorkGroupId()) || !StringUtils.hasLength(chuanyunMonthLaborCostWgDTO.getWorkGroupId())) {
+                    return ChuanYunConstant.DEFAULT_WORK_GROUP;
+                } else {
+                    return chuanyunMonthLaborCostWgDTO.getWorkGroupId();
+                }
+            }));
+
+            Set<String> workGroup1 = workGroupIdReimbursementMap.keySet();
+            Set<String> workGroup2 = workGroupIdSelfWorkHourMap.keySet();
+            Set<String> workGroup3 = workGroupIdLaborCostMap.keySet();
+
+
+            Set<String> workGroupMergeCollections = CollectionsUtils.mergeStringCollections(workGroup1, workGroup2, workGroup3);
+            // 避免默认工作与实际工作组数据重复,可能会存在历史数据没有工作组,后面标准化的时候又补充了工作组信息。
+            workGroupMergeCollections.add(ChuanYunConstant.DEFAULT_WORK_GROUP);
+
+            workGroupMergeCollections.forEach(workGroupId -> {
+                List<ChuanyunReimbursementDO> reimbursementDOList = workGroupIdReimbursementMap.getOrDefault(workGroupId, Collections.emptyList());
+                List<ChuanyunSelfWorkHourDO> selfWorkHourDOS = workGroupIdSelfWorkHourMap.getOrDefault(workGroupId, Collections.emptyList());
+                List<ChuanyunMonthLaborCostWgDTO> monthLaborCostWgDTOS = workGroupIdLaborCostMap.getOrDefault(workGroupId, Collections.emptyList());
+
+                BigDecimal totalReimbursement;
+                BigDecimal totalManDay;
+                BigDecimal totalLaborCost;
+
+                if (reimbursementDOList.isEmpty()) {
+                    totalReimbursement = new BigDecimal("0.00");
+                } else {
+                    totalReimbursement = reimbursementDOList.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
+                }
+
+                if (selfWorkHourDOS.isEmpty()) {
+                    totalManDay = new BigDecimal("0.00");
+                } else {
+                    BigDecimal totalWorkHours = selfWorkHourDOS.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
+                    totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
+                }
+
+                if (monthLaborCostWgDTOS.isEmpty()) {
+                    totalLaborCost = new BigDecimal("0.00");
+                } else {
+                    totalLaborCost = monthLaborCostWgDTOS.stream().map(ChuanyunMonthLaborCostWgDTO::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+                }
+                // todo 变更
+                ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroupAndLocalDate(groupProjectObjectId, groupProjectCode, workGroupId, localDate.atStartOfDay());
+                if (!Objects.isNull(old)) {
+                    BigDecimal oldImplCost = old.getImplCost();
+                    BigDecimal oldManDay = old.getManDay();
+                    BigDecimal oldLaborCost = old.getLaborCost();
+                    if (Objects.isNull(old.getLocalDate()) ||
+                            Objects.isNull(oldImplCost) ||
+                            Objects.isNull(oldManDay) ||
+                            Objects.isNull(oldLaborCost) ||
+                            oldImplCost.compareTo(totalReimbursement) != 0 ||
+                            oldManDay.compareTo(totalManDay) != 0 || oldLaborCost.compareTo(totalLaborCost) != 0) {
+                        old.setImplCost(totalReimbursement);
+                        old.setManDay(totalManDay);
+                        old.setLaborCost(totalLaborCost);
+                        if (!StringUtils.hasLength(old.getOwnerId()) && !Objects.isNull(chuanyunGroupProjectDO.getEbgProjectManagerObject())) {
+                            old.setOwnerId(chuanyunGroupProjectDO.getEbgProjectManagerObject().getObjectId());
+                        }
+                        implCostDao.saveAndFlush(old);
+                    }
+                } else {
+                    // 判断默认工作组数据
+                    String defaultWorkGroupName = ChuanYunConstant.DEFAULT_WORK_GROUP_NAME;
+                    ChuanyunWorkGroupDO workGroupDO = workGroupService.findByObjectId(workGroupId);
+                    if (!Objects.isNull(workGroupDO)) {
+                        defaultWorkGroupName = workGroupDO.getWorkGroupName();
+                    } else {
+                        ChuanyunHistoryWorkGroupDO historyWorkGroupDO = workGroupService.findInHistoryByObjectId(workGroupId);
+                        if (!Objects.isNull(historyWorkGroupDO)) {
+                            defaultWorkGroupName = historyWorkGroupDO.getWorkGroupName();
+                        }
+                    }
+                    ChuanyunImplCostDO chuanyunImplCostDO = new ChuanyunImplCostDO();
+                    chuanyunImplCostDO.setProjectId(chuanyunGroupProjectDO.getObjectId());
+                    chuanyunImplCostDO.setProjectCode(groupProjectCode);
+                    chuanyunImplCostDO.setLocalDate(localDate.atStartOfDay());
+                    chuanyunImplCostDO.setWorkGroup(workGroupId);
+                    chuanyunImplCostDO.setWorkGroupName(defaultWorkGroupName);
+                    chuanyunImplCostDO.setImplCost(totalReimbursement);
+                    chuanyunImplCostDO.setManDay(totalManDay);
+                    chuanyunImplCostDO.setLaborCost(totalLaborCost);
+                    if (!Objects.isNull(chuanyunGroupProjectDO.getEbgProjectManagerObject())) {
+
+                        chuanyunImplCostDO.setOwnerId(chuanyunGroupProjectDO.getEbgProjectManagerObject().getObjectId());
+                    }
+                    implCostDao.saveAndFlush(chuanyunImplCostDO);
+                }
+
+            });
+
+        });
+
+    }
+
+    @Test
+    void allSelfWork() {
+        List<ChuanyunSelfWorkHourDO> workHours = selfWorkHourDao.findAllByProjectIdAndStatusIn("1f48d45f-10bf-4b26-ad5a-9f0e41ad02ef", List.of("1", "2"));
+        List<ChuanyunSelfWorkHourDO> selfWorkHourDOS = workHours.stream().sorted(Comparator.comparing(ChuanyunSelfWorkHourDO::getDayLogDate)).toList();
+        selfWorkHourDOS.forEach(System.out::println);
+    }
+
+
+}

+ 4 - 4
src/test/java/com/galaxis/manatee/Test/implCost/WorkGroupImplCostTest.java

@@ -121,8 +121,8 @@ public class WorkGroupImplCostTest {
                     workHoursMap.put(localDate, chuanyunSelfWorkHourDOS);
                 }
             });
-
-            List<ChuanyunMonthLaborCostWgDTO> laborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCode(groupProjectCode);
+            // todo 修改为根据项目id来查
+            List<ChuanyunMonthLaborCostWgDTO> laborCostWgs = chuanyunMonthLaborCostWgDao.findAllByProjectCodeAndProjectId(groupProjectCode, groupProjectObjectId);
             Map<LocalDate, List<ChuanyunMonthLaborCostWgDTO>> map3 = laborCostWgs.stream().collect(Collectors.groupingBy(chuanyunMonthLaborCostWgDTO -> {
                 if (!Objects.isNull(chuanyunMonthLaborCostWgDTO.getLogDate())) {
                     return LocalDate.of(chuanyunMonthLaborCostWgDTO.getLogDate().getYear(), chuanyunMonthLaborCostWgDTO.getLogDate().getMonthValue(), 1);
@@ -372,8 +372,8 @@ public class WorkGroupImplCostTest {
 
     @Test
     void test6() {
-        Map<String,String> map=new HashMap<>(1);
-        map.put("workgroupid_eq","f2049d31-155f-4405-89db-495949bb47a0");
+        Map<String, String> map = new HashMap<>(1);
+        map.put("workgroupid_eq", "f2049d31-155f-4405-89db-495949bb47a0");
         PageDTO<ChuanyunLaborCostWgDTO> chuanyunLaborCostWg = clawFeign.findChuanyunLaborCostWg(map);
         List<ChuanyunLaborCostWgDTO> content = chuanyunLaborCostWg.getContent();
         content.forEach(System.out::println);

+ 1 - 1
src/test/java/com/galaxis/manatee/Test/project/CleanZhong.java

@@ -101,7 +101,7 @@ public class CleanZhong {
 
     @Test
     public void test1() {
-        String objectId = "1d324137-c6ce-11ec-8d00-7cd30adfe3be";
+        String objectId = "2e3018f9-8ab7-11ea-8ae9-7cd30ab711fe";
         ChuanyunFindBizDTO<Object> objectChuanyunFindBizDTO = chuanYunManager.find(ChuanyunGroupProjectDO.SCHEMA_CODE, objectId);
         Object bizObject = objectChuanyunFindBizDTO.getReturnData().getBizObject();
         ObjectMapper objectMapper = new ObjectMapper();

+ 71 - 0
src/test/java/com/galaxis/manatee/Test/updateDayWorkHour.java

@@ -0,0 +1,71 @@
+package com.galaxis.manatee.Test;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunDayLog;
+import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizDTO;
+import com.galaxis.manatee.entity.chuanyun.dto.Filter;
+import com.galaxis.manatee.manager.ChuanYunManager;
+import lombok.Data;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+@SpringBootTest
+public class updateDayWorkHour {
+
+    private ChuanYunManager chuanYunManager;
+
+    @Autowired
+    public void setChuanYunManager(ChuanYunManager chuanYunManager) {
+        this.chuanYunManager = chuanYunManager;
+    }
+
+    @Test
+    void updateDayWorkHourProjectId() {
+        ObjectMapper objectMapper = new ObjectMapper();
+        List<String> m = List.of("project_2,2e3018f9-8ab7-11ea-8ae9-7cd30ab711fe", "projecttype_2,实施");
+        //从氚云查询数据
+        var filter = Filter.instance(0, 100, true, Filter.AND, m);
+        ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
+        try {
+            chuanyunFindAllResponse = chuanYunManager.findAll("D001789DayLog", filter);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+        }
+        if (chuanyunFindAllResponse.getReturnData() == null) {
+            return;
+        }
+        //转化为POJO
+        List<ChuanyunDayLog> result = objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
+        });
+
+        result.forEach(chuanyunDayLog -> {
+            UpdateProjectIdDTO updateProjectIdDTO = new UpdateProjectIdDTO("1f48d45f-10bf-4b26-ad5a-9f0e41ad02ef");
+            try {
+                String jsonStr = objectMapper.writeValueAsString(updateProjectIdDTO);
+                chuanYunManager.update("D001789DayLog",chuanyunDayLog.getObjectId(),jsonStr);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        });
+
+
+    }
+
+    @Data
+    class UpdateProjectIdDTO {
+
+        @JsonProperty("project")
+        private String project;
+
+        public UpdateProjectIdDTO(String project) {
+            this.project = project;
+        }
+    }
+
+}

+ 8 - 2
src/test/java/com/galaxis/manatee/Test/workHour/Standard.java

@@ -130,14 +130,20 @@ public class Standard {
     }
 
     @Test
+    public void downloadLogByUserId(){
+
+        logService.downloadLogByUserId("12264c19-12b2-44cf-8e63-ab2937605882");
+    }
+
+    @Test
     void standardSelfWorkHourOne() {
         // 3d94c30e-66f1-46e8-a2a3-fe32aa9a071d
-        logStandardService.standardSelfWorkHourByUserId("91c295cc-6de9-4a27-abd9-e3d94a5115c4");
+        logStandardService.standardSelfWorkHourByUserId("a4a1e5f8-f3a5-449f-8a1c-bdb63bbc4f6b");
     }
 
     @Test
     void pushOne() {
-        logUpdateService.updateChuanyunSelfWorkHourListByUserId("91c295cc-6de9-4a27-abd9-e3d94a5115c4");
+        logUpdateService.updateChuanyunSelfWorkHourListByUserId("a4a1e5f8-f3a5-449f-8a1c-bdb63bbc4f6b");
     }
 
     @Test