| | |
| | | import me.zhengjie.modules.project.service.dto.ProjectQueryCriteria;
|
| | | import me.zhengjie.modules.project.service.dto.ProjectTypeQueryCriteria;
|
| | | import me.zhengjie.modules.project.service.mapstruct.ProjectMapper;
|
| | | import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
|
| | | import me.zhengjie.modules.system.domain.DictDetail;
|
| | | import me.zhengjie.modules.system.domain.User;
|
| | | import me.zhengjie.modules.system.repository.DictDetailRepository;
|
| | |
| | | private final CostRepository costRepository;
|
| | | private final ContractProjectRepository contractProjectRepository;
|
| | | private final SysGoalSettingService sysGoalSettingService;
|
| | | private final WeComServiceImpl weComService;
|
| | |
|
| | | @Autowired
|
| | | private TaskService taskService;
|
| | |
| | | Query query = new Query(Criteria.where("projectId").is(project.getId()));
|
| | | List<TaskMongo> taskMongoList = mongoTemplate.find(query, TaskMongo.class);
|
| | |
|
| | | List<TaskUserMongo> taskUserMongoList = mongoTemplate.find(Query.query(Criteria.where("task").in(taskMongoList)), TaskUserMongo.class);
|
| | | Aggregation customerAgg = Aggregation.newAggregation(
|
| | | Aggregation.match(Criteria.where("task").in(taskMongoList)),
|
| | | Aggregation.project("userId", "taskHours", "costHours"),
|
| | | Aggregation.group("userId").sum("taskHours").as("taskHours").sum("costHours").as("costHours")
|
| | | Aggregation.match(Criteria.where("taskUserMongo").in(taskUserMongoList)),
|
| | | Aggregation.project("userId", "consumedHours"),
|
| | | Aggregation.group("userId").sum("consumedHours").as("consumedHours")
|
| | | );
|
| | |
|
| | | AggregationResults<Map> aggregate = mongoTemplate.aggregate(customerAgg, TaskUserMongo.class, Map.class);
|
| | | AggregationResults<Map> aggregate = mongoTemplate.aggregate(customerAgg, TaskDaliyMongo.class, Map.class);
|
| | | BigDecimal actualCost =aggregate.getMappedResults().stream().filter(data -> data.get("_id") != null).map(data -> {
|
| | | BigDecimal moneyTotalCost = projectCostService.calcUserCostByHours(Long.parseLong(String.valueOf(data.get("_id"))), Double.valueOf(String.valueOf(data.get("costHours"))));
|
| | | BigDecimal moneyTotalCost = projectCostService.calcUserCostByHours(Long.parseLong(String.valueOf(data.get("_id"))), Double.valueOf(String.valueOf(data.get("consumedHours"))));
|
| | | return moneyTotalCost;
|
| | | }).reduce(BigDecimal.ZERO, BigDecimal::add);
|
| | |
|
| | |
| | | return projectDto;
|
| | | }).collect(Collectors.toList());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void generateReport(ProjectQueryCriteria criteria) {
|
| | | List<Long> projectIds;
|
| | | if (criteria.getIdInList().size() > 0) {
|
| | | // 指定项目
|
| | | projectIds = criteria.getIdInList();
|
| | | } else {
|
| | | // 暂定科技全部未结束、未停滞项目
|
| | | criteria.setProjectDistinguish(Constant.PROJECT_DISTINGUISH_PRODUCT);
|
| | | criteria.setProjectStatusIn(Arrays.asList(Constant.PROJECT_STATUS_NOT_STARTED, Constant.PROJECT_STATUS_UNDER_WAY));
|
| | | projectIds = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)).stream().map(p -> p.getId()).collect(Collectors.toList());
|
| | | }
|
| | | weComService.toWeComSheetPushProjectReport(projectIds);
|
| | | }
|
| | | } |