|
@@ -1,853 +0,0 @@
|
|
-package com.galaxis.manatee.Test.implCost;
|
|
|
|
-
|
|
|
|
-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.ChuanyunImplCostDao;
|
|
|
|
-import com.galaxis.manatee.dao.ChuanyunMonthLaborCostWgDao;
|
|
|
|
-import com.galaxis.manatee.dao.ChuanyunReimbursementDao;
|
|
|
|
-import com.galaxis.manatee.dao.ChuanyunSelfWorkHourDao;
|
|
|
|
-import com.galaxis.manatee.entity.chuanyun.data.object.*;
|
|
|
|
-import com.galaxis.manatee.entity.chuanyun.dto.*;
|
|
|
|
-import com.galaxis.manatee.exception.BigSizeException;
|
|
|
|
-import com.galaxis.manatee.manager.ChuanYunManager;
|
|
|
|
-import com.galaxis.manatee.manager.ClawFeign;
|
|
|
|
-import com.galaxis.manatee.service.GroupProjectService;
|
|
|
|
-import com.galaxis.manatee.service.ImplCostService;
|
|
|
|
-import com.galaxis.manatee.service.WorkGroupService;
|
|
|
|
-import com.galaxis.manatee.task.U9InfoTask;
|
|
|
|
-import com.galaxis.manatee.util.CollectionsUtils;
|
|
|
|
-import com.galaxis.manatee.util.TimeUtil;
|
|
|
|
-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.time.LocalDateTime;
|
|
|
|
-import java.util.*;
|
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
-
|
|
|
|
-@Slf4j
|
|
|
|
-@SpringBootTest
|
|
|
|
-public class WorkGroupImplCostTest {
|
|
|
|
-
|
|
|
|
- private WorkGroupService workGroupService;
|
|
|
|
- private GroupProjectService groupProjectService;
|
|
|
|
- private ChuanyunImplCostDao implCostDao;
|
|
|
|
- private ChuanyunReimbursementDao reimbursementDao;
|
|
|
|
- private ChuanyunSelfWorkHourDao selfWorkHourDao;
|
|
|
|
- private ChuanyunMonthLaborCostWgDao chuanyunMonthLaborCostWgDao;
|
|
|
|
- private ImplCostService implCostService;
|
|
|
|
- private ChuanYunManager chuanYunManager;
|
|
|
|
- private ClawFeign clawFeign;
|
|
|
|
- private U9InfoTask infoTask;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- public void setWorkGroupService(WorkGroupService workGroupService, GroupProjectService groupProjectService, ChuanyunImplCostDao implCostDao, ChuanyunReimbursementDao reimbursementDao, ChuanyunSelfWorkHourDao selfWorkHourDao, ChuanyunMonthLaborCostWgDao chuanyunMonthLaborCostWgDao) {
|
|
|
|
- this.workGroupService = workGroupService;
|
|
|
|
- this.groupProjectService = groupProjectService;
|
|
|
|
- this.implCostDao = implCostDao;
|
|
|
|
- this.reimbursementDao = reimbursementDao;
|
|
|
|
- this.selfWorkHourDao = selfWorkHourDao;
|
|
|
|
- this.chuanyunMonthLaborCostWgDao = chuanyunMonthLaborCostWgDao;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- public void setImplCostService(ImplCostService implCostService) {
|
|
|
|
- this.implCostService = implCostService;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- public void setChuanYunManager(ChuanYunManager chuanYunManager) {
|
|
|
|
- this.chuanYunManager = chuanYunManager;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- public void setClawFeign(ClawFeign clawFeign) {
|
|
|
|
- this.clawFeign = clawFeign;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- public void setInfoTask(U9InfoTask infoTask) {
|
|
|
|
- this.infoTask = infoTask;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void saveU9LaborCostWg() {
|
|
|
|
- infoTask.saveLaborCostWgTest();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- void test1() {
|
|
|
|
- List<ChuanyunGroupProjectDO> groupProjects = groupProjectService.findByProjectCode("D18002");
|
|
|
|
- if (Objects.isNull(groupProjects)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- groupProjects.forEach(chuanyunGroupProjectDO -> {
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
- List<LocalDate> localDates = mergeCollections.stream().filter(localDate -> localDate.isAfter(LocalDate.of(2022, 7, 1))).toList();
|
|
|
|
-
|
|
|
|
-// mergeCollections.forEach(localDate -> {
|
|
|
|
- localDates.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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
- 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);
|
|
|
|
- implCostDao.saveAndFlush(chuanyunImplCostDO);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- void test2() {
|
|
|
|
- List<ChuanyunImplCostDO> all = implCostService.findAllInChuanyun();
|
|
|
|
- all.forEach(chuanyunImplCostDO -> {
|
|
|
|
- chuanYunManager.delete(ChuanyunImplCostDO.SCHEMA_CODE, chuanyunImplCostDO.getObjectId());
|
|
|
|
- log.info("删除: {}", chuanyunImplCostDO);
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- void test3() {
|
|
|
|
- ChuanyunImplCostDO old = implCostDao.findByProjectCodeAndWorkGroupAndLocalDate("D19411-1", "defaultWorkgroup", LocalDate.of(2022, 7, 1).atStartOfDay());
|
|
|
|
- System.out.println(old);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- void test7(){
|
|
|
|
- workGroupService.implAllCost();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void findTest() {
|
|
|
|
- boolean flag = true;
|
|
|
|
- List<String> m = List.of("status_2,1", "F0000003_2,D21389");
|
|
|
|
- Filter filter = Filter.instance(0, 10, true, Filter.AND, m);
|
|
|
|
- ChuanyunFindAllBizDTO<ChuanyunBuildProject> buildResponse = null;
|
|
|
|
- try {
|
|
|
|
- buildResponse = chuanYunManager.findAll(ChuanyunBuildProject.SCHEMA_CODE, filter);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (buildResponse == null || !buildResponse.getSuccessful()) {
|
|
|
|
- flag = false;
|
|
|
|
- }
|
|
|
|
- ChuanyunFindAllBizReturnData<ChuanyunBuildProject> returnData = buildResponse.getReturnData();
|
|
|
|
- if (returnData == null) {
|
|
|
|
- flag = false;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<ChuanyunBuildProject> bizObjectArray = returnData.getBizObjectArray();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- List<ChuanyunBuildProject> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void findTest1() {
|
|
|
|
- List<String> m = List.of("status_2,1", "F0000003_2,D21389");
|
|
|
|
- Filter f = Filter.instance(0, 10, true, Filter.AND, m);
|
|
|
|
-
|
|
|
|
- ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
|
|
|
|
- try {
|
|
|
|
- chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunBuildProject.SCHEMA_CODE, f);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- //保存
|
|
|
|
- List<Object> buildBizObjectArray = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- List<ChuanyunBuildProject> bpList = objectMapper.convertValue(buildBizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- final Object monitor = new Object();
|
|
|
|
- bpList.forEach(chuanyunBuildProject -> {
|
|
|
|
- synchronized (monitor) {
|
|
|
|
- String buildProjectId = chuanyunBuildProject.getObjectId();
|
|
|
|
- List<String> m1 = List.of("F0000001_2," + buildProjectId);
|
|
|
|
- Filter filter = Filter.instance(0, 10, true, Filter.AND, m1);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> projectList = null;
|
|
|
|
- try {
|
|
|
|
- projectList = chuanYunManager.findAll(ChuanyunProjectOrganizationStructureDO.SCHEMA_CODE, filter);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (projectList == null || projectList.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<ChuanyunProjectOrganizationStructureDO> projectOrganizationStructureList = objectMapper.convertValue(projectList.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- List<String> parentIdList = projectOrganizationStructureList.stream().map(BasicDO::getObjectId).toList();
|
|
|
|
- parentIdList.forEach(parentId -> {
|
|
|
|
- // 查询工作组信息
|
|
|
|
- List<String> m2 = List.of("parentObjectId_2," + parentId);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> workGroupResponse = null;
|
|
|
|
- try {
|
|
|
|
- workGroupResponse = chuanYunManager.findAll(ChuanyunWorkGroupDO.SCHEMA_CODE, Filter.instance(0, 30, true, Filter.AND, m2));
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (workGroupResponse == null || !workGroupResponse.getSuccessful()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (workGroupResponse.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<ChuanyunWorkGroupDO> workGroupList = objectMapper.convertValue(workGroupResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- workGroupList.forEach(chuanyunWorkGroupDO -> {
|
|
|
|
- // 查询该项目在总表中的记录
|
|
|
|
- List<String> m3 = List.of("F0000075_5,异常", "F0000002_2," + chuanyunBuildProject.getProjectCode());
|
|
|
|
- Filter instance = Filter.instance(0, 50, true, Filter.AND, m3);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> groupProjectResponse = null;
|
|
|
|
- try {
|
|
|
|
- groupProjectResponse = chuanYunManager.findAll(ChuanyunGroupProjectDO.SCHEMA_CODE, instance);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (!groupProjectResponse.getSuccessful() || groupProjectResponse.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<Object> bizObjectArray = groupProjectResponse.getReturnData().getBizObjectArray();
|
|
|
|
- List<ChuanyunGroupProjectDO> groupProjectDOList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- Optional<ChuanyunGroupProjectDO> groupProjectDO = groupProjectDOList.stream().findFirst();
|
|
|
|
- if (groupProjectDO.isPresent()) {
|
|
|
|
- ChuanyunGroupProjectDO chuanyunGroupProjectDO = groupProjectDO.get();
|
|
|
|
- List<String> userIdList = chuanyunWorkGroupDO.getSubWorkGroupMemberObject().stream().map(BasicSubDO::getObjectId).toList();
|
|
|
|
- // 查询报销单
|
|
|
|
- BigDecimal total = new BigDecimal("0.00");
|
|
|
|
- BigDecimal totalManDay = new BigDecimal("0.000");
|
|
|
|
- // 查询项目工作组人天
|
|
|
|
- for (String userId : userIdList) {
|
|
|
|
- // 查询用户在该项目的报销单
|
|
|
|
- List<ChuanyunReimbursementDO> reimbursements = reimbursementDao.findAllByGroupProjectIdAndReimburseUserIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), userId, List.of(1, 2));
|
|
|
|
- BigDecimal totalReimburse = reimbursements.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- total = total.add(totalReimburse);
|
|
|
|
- List<ChuanyunSelfWorkHourDO> workHours = selfWorkHourDao.findAllByProjectIdAndUserIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), userId, List.of("1", "2"));
|
|
|
|
- BigDecimal totalWorkHour = workHours.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- // 人天
|
|
|
|
- BigDecimal manDay = totalWorkHour.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
|
- totalManDay = totalManDay.add(manDay);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- // 统计工作组所有的工时
|
|
|
|
- String projectObjectId = chuanyunGroupProjectDO.getObjectId();
|
|
|
|
- String projectCode = chuanyunGroupProjectDO.getProjectCode();
|
|
|
|
- String workGroupId = chuanyunWorkGroupDO.getObjectId();
|
|
|
|
-
|
|
|
|
- ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroup(projectObjectId, projectCode, workGroupId);
|
|
|
|
- if (!Objects.isNull(old)) {
|
|
|
|
- BigDecimal oldImplCost = old.getImplCost();
|
|
|
|
- BigDecimal oldManDay = old.getManDay();
|
|
|
|
- if (Objects.isNull(oldImplCost) || Objects.isNull(oldManDay) || oldImplCost.compareTo(total) != 0 || oldManDay.compareTo(totalManDay) != 0) {
|
|
|
|
- old.setImplCost(total);
|
|
|
|
- old.setManDay(totalManDay);
|
|
|
|
- implCostDao.save(old);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- ChuanyunImplCostDO chuanyunImplCostDO = new ChuanyunImplCostDO();
|
|
|
|
- chuanyunImplCostDO.setProjectId(projectObjectId);
|
|
|
|
- chuanyunImplCostDO.setProjectCode(projectCode);
|
|
|
|
- chuanyunImplCostDO.setWorkGroup(workGroupId);
|
|
|
|
- chuanyunImplCostDO.setWorkGroupName(chuanyunWorkGroupDO.getWorkGroupName());
|
|
|
|
- chuanyunImplCostDO.setImplCost(total);
|
|
|
|
- chuanyunImplCostDO.setManDay(totalManDay);
|
|
|
|
- implCostDao.saveAndFlush(chuanyunImplCostDO);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void findOneTest() {
|
|
|
|
-
|
|
|
|
- ChuanyunFindBizDTO<Object> buildResponse = null;
|
|
|
|
-
|
|
|
|
- buildResponse = chuanYunManager.find(ChuanyunBuildProject.SCHEMA_CODE, "9cdcf0d7-c8db-41b5-a03c-4caf2a2eb1f8");
|
|
|
|
-
|
|
|
|
- if (buildResponse == null || !buildResponse.getSuccessful()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- ChuanyunFindBizReturnData<Object> returnData = buildResponse.getReturnData();
|
|
|
|
-
|
|
|
|
- Object bizObject = returnData.getBizObject();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- ChuanyunBuildProject chuanyunBuildProject = objectMapper.convertValue(bizObject, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void reimburseTest() {
|
|
|
|
- workGroupService.implCost();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void pushToChuanyun() {
|
|
|
|
- workGroupService.pushToChuanyun();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void workGroupMonthTest() {
|
|
|
|
- // 查询立项表中数据
|
|
|
|
- List<ChuanyunBuildProject> buildProjectList = findAll();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- // 查询组织架构录入
|
|
|
|
- final Object monitor = new Object();
|
|
|
|
- buildProjectList.parallelStream().forEach(chuanyunBuildProject -> {
|
|
|
|
- synchronized (monitor) {
|
|
|
|
- String buildProjectId = chuanyunBuildProject.getObjectId();
|
|
|
|
- List<String> m1 = List.of("F0000001_2," + buildProjectId);
|
|
|
|
- Filter filter = Filter.instance(0, 10, true, Filter.AND, m1);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> projectList = null;
|
|
|
|
- try {
|
|
|
|
- projectList = chuanYunManager.findAll(ChuanyunProjectOrganizationStructureDO.SCHEMA_CODE, filter);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (projectList == null || projectList.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<ChuanyunProjectOrganizationStructureDO> projectOrganizationStructureList = objectMapper.convertValue(projectList.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- List<String> parentIdList = projectOrganizationStructureList.stream().map(BasicDO::getObjectId).toList();
|
|
|
|
- parentIdList.forEach(parentId -> {
|
|
|
|
- // 查询工作组信息
|
|
|
|
- List<String> m2 = List.of("parentObjectId_2," + parentId);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> workGroupResponse = null;
|
|
|
|
- try {
|
|
|
|
- workGroupResponse = chuanYunManager.findAll(ChuanyunWorkGroupDO.SCHEMA_CODE, Filter.instance(0, 30, true, Filter.AND, m2));
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (workGroupResponse == null || !workGroupResponse.getSuccessful()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (workGroupResponse.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<ChuanyunWorkGroupDO> workGroupList = objectMapper.convertValue(workGroupResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- workGroupList.forEach(chuanyunWorkGroupDO -> {
|
|
|
|
- // 查询该项目在总表中的记录
|
|
|
|
- List<String> m3 = List.of("F0000075_5,异常", "F0000002_2," + chuanyunBuildProject.getProjectCode());
|
|
|
|
- Filter instance = Filter.instance(0, 50, true, Filter.AND, m3);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> groupProjectResponse = null;
|
|
|
|
- try {
|
|
|
|
- groupProjectResponse = chuanYunManager.findAll(ChuanyunGroupProjectDO.SCHEMA_CODE, instance);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (!groupProjectResponse.getSuccessful() || groupProjectResponse.getReturnData() == null) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- List<Object> bizObjectArray = groupProjectResponse.getReturnData().getBizObjectArray();
|
|
|
|
- List<ChuanyunGroupProjectDO> groupProjectDOList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- Optional<ChuanyunGroupProjectDO> groupProjectDO = groupProjectDOList.stream().findFirst();
|
|
|
|
- if (groupProjectDO.isPresent()) {
|
|
|
|
- ChuanyunGroupProjectDO chuanyunGroupProjectDO = groupProjectDO.get();
|
|
|
|
- List<String> userIdList = chuanyunWorkGroupDO.getSubWorkGroupMemberObject().stream().map(BasicSubDO::getObjectId).toList();
|
|
|
|
- // 查询报销单
|
|
|
|
- // 查询项目工作组人天
|
|
|
|
- Map<LocalDate, List<ChuanyunReimbursementDO>> reimbursementMap = new HashMap<>();
|
|
|
|
- Map<LocalDate, List<ChuanyunSelfWorkHourDO>> workHoursMap = new HashMap<>();
|
|
|
|
-
|
|
|
|
- for (String userId : userIdList) {
|
|
|
|
- // 查询用户在该项目的报销单
|
|
|
|
- List<ChuanyunReimbursementDO> reimbursements = reimbursementDao.findAllByGroupProjectIdAndReimburseUserIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), userId, List.of(1, 2));
|
|
|
|
- // 报销单按日期分组
|
|
|
|
- Map<LocalDate, List<ChuanyunReimbursementDO>> map1 = reimbursements.stream().collect(Collectors.groupingBy(chuanyunReimbursementDO -> LocalDate.of(chuanyunReimbursementDO.getBusinessDate().getYear(), chuanyunReimbursementDO.getBusinessDate().getMonthValue(), 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.findAllByProjectIdAndUserIdAndStatusIn(chuanyunGroupProjectDO.getObjectId(), userId, List.of("1", "2"));
|
|
|
|
- Map<LocalDate, List<ChuanyunSelfWorkHourDO>> map2 = workHours.stream().collect(Collectors.groupingBy(chuanyunSelfWorkHourDO -> LocalDate.of(chuanyunSelfWorkHourDO.getDayLogDate().getYear(), chuanyunSelfWorkHourDO.getDayLogDate().getMonthValue(), 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);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Set<LocalDate> localDates = reimbursementMap.keySet();
|
|
|
|
- Set<LocalDate> localDates1 = workHoursMap.keySet();
|
|
|
|
- Set<LocalDate> mergeCollections = CollectionsUtils.mergeCollections(localDates, localDates1);
|
|
|
|
-
|
|
|
|
- mergeCollections.forEach(localDate -> {
|
|
|
|
- BigDecimal totalReimbursement;
|
|
|
|
- BigDecimal totalManDay;
|
|
|
|
- List<ChuanyunReimbursementDO> reimbursements = reimbursementMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
|
- if (reimbursements.isEmpty()) {
|
|
|
|
- totalReimbursement = new BigDecimal("0.00");
|
|
|
|
- } else {
|
|
|
|
- totalReimbursement = reimbursements.stream().map(ChuanyunReimbursementDO::getTotalAmountNotTaxed).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- }
|
|
|
|
- List<ChuanyunSelfWorkHourDO> selfWorkHours = workHoursMap.getOrDefault(localDate, Collections.emptyList());
|
|
|
|
- if (selfWorkHours.isEmpty()) {
|
|
|
|
- totalManDay = new BigDecimal("0.00");
|
|
|
|
- } else {
|
|
|
|
- BigDecimal totalWorkHours = selfWorkHours.stream().map(ChuanyunSelfWorkHourDO::getStandardWorkHour).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
- totalManDay = totalWorkHours.divide(BigDecimal.valueOf(8), 3, RoundingMode.UP);
|
|
|
|
- }
|
|
|
|
- // 统计工作组所有的工时
|
|
|
|
- String projectObjectId = chuanyunGroupProjectDO.getObjectId();
|
|
|
|
- String projectCode = chuanyunGroupProjectDO.getProjectCode();
|
|
|
|
- String workGroupId = chuanyunWorkGroupDO.getObjectId();
|
|
|
|
-
|
|
|
|
- ChuanyunImplCostDO old = implCostDao.findByProjectIdAndProjectCodeAndWorkGroupAndLocalDate(projectObjectId, projectCode, workGroupId, localDate.atStartOfDay());
|
|
|
|
- if (!Objects.isNull(old)) {
|
|
|
|
- BigDecimal oldImplCost = old.getImplCost();
|
|
|
|
- BigDecimal oldManDay = old.getManDay();
|
|
|
|
- if (Objects.isNull(old.getLocalDate())) {
|
|
|
|
- old.setLocalDate(localDate.atStartOfDay());
|
|
|
|
- }
|
|
|
|
- if (Objects.isNull(oldImplCost) || Objects.isNull(oldManDay) || oldImplCost.compareTo(totalReimbursement) != 0 || oldManDay.compareTo(totalManDay) != 0) {
|
|
|
|
- old.setImplCost(totalReimbursement);
|
|
|
|
- old.setManDay(totalManDay);
|
|
|
|
- implCostDao.saveAndFlush(old);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- ChuanyunImplCostDO chuanyunImplCostDO = new ChuanyunImplCostDO();
|
|
|
|
- chuanyunImplCostDO.setProjectId(projectObjectId);
|
|
|
|
- chuanyunImplCostDO.setProjectCode(projectCode);
|
|
|
|
- chuanyunImplCostDO.setLocalDate(localDate.atStartOfDay());
|
|
|
|
- chuanyunImplCostDO.setWorkGroup(workGroupId);
|
|
|
|
- chuanyunImplCostDO.setWorkGroupName(chuanyunWorkGroupDO.getWorkGroupName());
|
|
|
|
- chuanyunImplCostDO.setImplCost(totalReimbursement);
|
|
|
|
- chuanyunImplCostDO.setManDay(totalManDay);
|
|
|
|
- implCostDao.saveAndFlush(chuanyunImplCostDO);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void pushToChuanyunTest() {
|
|
|
|
- List<ChuanyunImplCostDO> all = implCostDao.findAll();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- all.forEach(implCostDO -> {
|
|
|
|
- String projectId = implCostDO.getProjectId();
|
|
|
|
- String projectCode = implCostDO.getProjectCode();
|
|
|
|
- String workGroup = implCostDO.getWorkGroup();
|
|
|
|
- LocalDateTime localDate = implCostDO.getLocalDate();
|
|
|
|
- List<String> m = List.of("F0000001_2," + projectId, "F0000002_2," + projectCode, "F0000006_2," + workGroup, "F0000008_2," + localDate);
|
|
|
|
- Filter filter = Filter.instance(0, 10, true, Filter.AND, m);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> implCostResponse = null;
|
|
|
|
- try {
|
|
|
|
- implCostResponse = chuanYunManager.findAll(ChuanyunImplCostDO.SCHEMA_CODE, filter);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
- }
|
|
|
|
- assert implCostResponse != null;
|
|
|
|
- if (implCostResponse.getSuccessful()) {
|
|
|
|
- ChuanyunFindAllBizReturnData<Object> returnData = implCostResponse.getReturnData();
|
|
|
|
- if (returnData != null && returnData.getBizObjectArray() != null) {
|
|
|
|
- List<ChuanyunImplCostDO> chuanyunImplCostDOList = objectMapper.convertValue(returnData.getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- Optional<ChuanyunImplCostDO> implCostOptional = chuanyunImplCostDOList.stream().findFirst();
|
|
|
|
- if (implCostOptional.isPresent()) {
|
|
|
|
- ChuanyunImplCostDO chuanyunImplCostDO = implCostOptional.get();
|
|
|
|
- if (Objects.isNull(chuanyunImplCostDO.getImplCost()) || Objects.isNull(chuanyunImplCostDO.getManDay()) ||
|
|
|
|
- chuanyunImplCostDO.getImplCost().compareTo(implCostDO.getImplCost()) != 0 ||
|
|
|
|
- chuanyunImplCostDO.getManDay().compareTo(implCostDO.getManDay()) != 0) {
|
|
|
|
- // 工作组实施费用发生变化
|
|
|
|
- log.info("更新项目工作组实施费用");
|
|
|
|
- ImplCostUpdateDTO implCostUpdateDTO = new ImplCostUpdateDTO(implCostDO.getImplCost(), implCostDO.getManDay());
|
|
|
|
- try {
|
|
|
|
- String updateStr = objectMapper.writeValueAsString(implCostUpdateDTO);
|
|
|
|
- chuanYunManager.update(ChuanyunImplCostDO.SCHEMA_CODE, chuanyunImplCostDO.getObjectId(), updateStr);
|
|
|
|
- } catch (JsonProcessingException | BigSizeException e) {
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- // 直接保存
|
|
|
|
- try {
|
|
|
|
- String implCostStr = objectMapper.writeValueAsString(implCostDO);
|
|
|
|
- chuanYunManager.save(ChuanyunImplCostDO.SCHEMA_CODE, implCostStr, true);
|
|
|
|
- } catch (JsonProcessingException | BigSizeException e) {
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- });
|
|
|
|
- log.info("上传项目工作组实施费用完成");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void delImplCostTest() {
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- boolean flag = true;
|
|
|
|
- int start = 0;
|
|
|
|
- int pageSize = 200;
|
|
|
|
- while (flag) {
|
|
|
|
- Filter filter = Filter.instance(start, start + pageSize, true);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> delAll = null;
|
|
|
|
- try {
|
|
|
|
- delAll = chuanYunManager.findAll(ChuanyunImplCostDO.SCHEMA_CODE, filter);
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- if (Objects.isNull(delAll) || delAll.getReturnData() == null || delAll.getReturnData().getBizObjectArray() == null) {
|
|
|
|
- flag = false;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (delAll.getReturnData().getTotalCount() >= start + pageSize) {
|
|
|
|
- start += pageSize;
|
|
|
|
- } else {
|
|
|
|
- flag = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<Object> bizObjectArray = delAll.getReturnData().getBizObjectArray();
|
|
|
|
- List<ChuanyunImplCostDO> ic = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- ic.forEach(chuanyunImplCostDO -> {
|
|
|
|
- ChuanyunSaveDTO delete = chuanYunManager.delete(ChuanyunImplCostDO.SCHEMA_CODE, chuanyunImplCostDO.getObjectId());
|
|
|
|
- log.info("删除: {}", delete.getSuccessful());
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Data
|
|
|
|
- static class ImplCostUpdateDTO {
|
|
|
|
- @JsonProperty("F0000004")
|
|
|
|
- private BigDecimal implCost;
|
|
|
|
-
|
|
|
|
- @JsonProperty("F0000007")
|
|
|
|
- private BigDecimal manDay;
|
|
|
|
-
|
|
|
|
- public ImplCostUpdateDTO(BigDecimal implCost, BigDecimal manDay) {
|
|
|
|
- this.implCost = implCost;
|
|
|
|
- this.manDay = manDay;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- private List<ChuanyunBuildProject> findAll() {
|
|
|
|
- ArrayList<ChuanyunBuildProject> buildProjects = new ArrayList<>();
|
|
|
|
- ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
- int start = 0;
|
|
|
|
- long totalCount = 0L;
|
|
|
|
- boolean flag = true;
|
|
|
|
- int pageSize = 100;
|
|
|
|
- while (flag) {
|
|
|
|
- try {
|
|
|
|
- //从氚云查询数据
|
|
|
|
- List<String> m = List.of("status_2,1");
|
|
|
|
- var filter = Filter.instance(start, start + pageSize, true, Filter.AND, m);
|
|
|
|
- var chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunBuildProject.SCHEMA_CODE, filter);
|
|
|
|
- if (chuanyunFindAllResponse.getReturnData() == null || chuanyunFindAllResponse.getReturnData().getBizObjectArray() == null) {
|
|
|
|
- flag = false;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (chuanyunFindAllResponse.getReturnData().getTotalCount() >= start + pageSize) {
|
|
|
|
- start += pageSize;
|
|
|
|
- } else {
|
|
|
|
- flag = false;
|
|
|
|
- }
|
|
|
|
- //获取项目总数
|
|
|
|
- totalCount = chuanyunFindAllResponse.getReturnData().getTotalCount();
|
|
|
|
- //保存
|
|
|
|
- List<Object> bizObjectArray = chuanyunFindAllResponse.getReturnData().getBizObjectArray();
|
|
|
|
- List<ChuanyunBuildProject> bpList = objectMapper.convertValue(bizObjectArray, new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- buildProjects.addAll(bpList);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(e.getMessage());
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- return buildProjects;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void LocalDateTimeTest() {
|
|
|
|
- LocalDateTime localDateTime = LocalDate.now().atStartOfDay();
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void testFind() throws JsonProcessingException {
|
|
|
|
- List<String> matchers = new ArrayList<>();
|
|
|
|
- matchers.add("F0000005_2," + "AS20042");
|
|
|
|
- matchers.add("F0000002_2," + TimeUtil.formatDateTime(LocalDateTime.of(2020, 5, 1, 0, 0, 0)));
|
|
|
|
- matchers.add("F0000018_2," + "浙江凯乐士科技有限公司/项目交付/项目实施(集成项目交付)/项目实施/系统售后");
|
|
|
|
- var filter = Filter.instance(0, 1, true, "And", matchers);
|
|
|
|
- var chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunMonthLaborCostWgDO.SCHEMA_CODE, filter);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void deleteAll() {
|
|
|
|
- var objectMapper = new ObjectMapper();
|
|
|
|
- var start = 0;
|
|
|
|
- var totalCount = 0L;
|
|
|
|
- var flag = true;
|
|
|
|
- var pageSize = 100;
|
|
|
|
-
|
|
|
|
- while (flag) {
|
|
|
|
-
|
|
|
|
- //从氚云查询数据
|
|
|
|
- var filter = Filter.instance(start, start + pageSize, true);
|
|
|
|
- ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = null;
|
|
|
|
- try {
|
|
|
|
- chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunMonthLaborCostWgDO.SCHEMA_CODE, filter);
|
|
|
|
- if (chuanyunFindAllResponse.getReturnData() == null) {
|
|
|
|
- flag = false;
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- if (chuanyunFindAllResponse.getReturnData().getTotalCount() >= start + pageSize) {
|
|
|
|
- start += pageSize;
|
|
|
|
- } else {
|
|
|
|
- flag = false;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- List<ChuanyunMonthLaborCostWgDO> result = objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
|
- });
|
|
|
|
- if (result.size() > 0) {
|
|
|
|
- result.forEach(chuanyunMonthLaborCostWgDO -> chuanYunManager.delete(ChuanyunMonthLaborCostWgDO.SCHEMA_CODE, chuanyunMonthLaborCostWgDO.getObjectId()));
|
|
|
|
- }
|
|
|
|
- log.info("完成");
|
|
|
|
- } catch (JsonProcessingException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void push() {
|
|
|
|
- workGroupService.pushToChuanyun();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-}
|
|
|