| | |
| | | |
| | | //每日业务统计 |
| | | @Override |
| | | public Map<String, Object> businessStatisticsByDay(String startTime,String endTime,String type) { |
| | | public Map<String, Object> businessStatisticsByDay(String startTime, String endTime, String type) { |
| | | DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay(); |
| | | LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59); |
| | | LocalDateTime oldStart=start ; |
| | | LocalDateTime oldEnd=end ; |
| | | switch (type){ |
| | | LocalDateTime oldStart = start; |
| | | LocalDateTime oldEnd = end; |
| | | switch (type) { |
| | | case "周": |
| | | oldStart = start.minusDays(7); |
| | | oldEnd = end.minusDays(7); |
| | |
| | | /*检测费用*/ |
| | | //今日检测费用 |
| | | QueryWrapper<CostStatisticsDto> costStatisticsDtoQueryWrappers = new QueryWrapper<>(); |
| | | costStatisticsDtoQueryWrappers.between("create_time", start,end); |
| | | costStatisticsDtoQueryWrappers.between("create_time", start, end); |
| | | IPage<CostStatisticsDto> page = new Page<>(); |
| | | page.setSize(-1); |
| | | page.setCurrent(-1); |
| | | IPage<CostStatisticsDto> iPage = insOrderMapper.selectCostStatistics(page, costStatisticsDtoQueryWrappers); |
| | | BigDecimal price = BigDecimal.ZERO; |
| | | for (CostStatisticsDto record : iPage.getRecords()) { |
| | | price.add(record.getPrice()); |
| | | price = price.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO); |
| | | } |
| | | map.put("PRICE", price); |
| | | //昨日检测费用 |
| | | QueryWrapper<CostStatisticsDto> costWrappers = new QueryWrapper<>(); |
| | | costWrappers.between("create_time", oldStart,oldEnd); |
| | | costWrappers.between("create_time", oldStart, oldEnd); |
| | | IPage<CostStatisticsDto> dtoIPage = insOrderMapper.selectCostStatistics(page, costWrappers); |
| | | BigDecimal priced = BigDecimal.ZERO; |
| | | for (CostStatisticsDto record : dtoIPage.getRecords()) { |
| | | priced.add(record.getPrice()); |
| | | priced = priced.add(ObjectUtils.isNotEmpty(record.getPrice()) ? record.getPrice() : BigDecimal.ZERO); |
| | | } |
| | | //比例=(今日-昨日)/昨日 |
| | | BigDecimal priceRatio = (price.subtract(priced)).divide(priced.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : priced, 2, BigDecimal.ROUND_HALF_UP); |
| | |
| | | //今日检测工时 |
| | | Double cost = 0.0; |
| | | for (CostStatisticsDto record : iPage.getRecords()) { |
| | | cost += record.getCost(); |
| | | cost += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0; |
| | | } |
| | | map.put("COST", cost); |
| | | //昨日检测工时 |
| | | Double costed = 0.0; |
| | | for (CostStatisticsDto record : dtoIPage.getRecords()) { |
| | | costed += record.getCost(); |
| | | costed += ObjectUtils.isNotEmpty(record.getCost()) ? record.getCost() : 0.0; |
| | | } |
| | | //比例=(今日-昨日)/昨日 |
| | | BigDecimal costRatio = new BigDecimal(cost - costed).divide(new BigDecimal(costed == 0 ? 1 : costed), 2, BigDecimal.ROUND_HALF_UP); |
| | |
| | | //获取近十日的横坐标 |
| | | LocalDate startDate = LocalDate.parse(startTime, format); |
| | | LocalDate endDate = LocalDate.parse(endTime, format); |
| | | List<LocalDate> lastTenDays = new ArrayList<>(); |
| | | List<String> lastTenDays = new ArrayList<>(); |
| | | List<Long> receTenDays = new ArrayList<>(); |
| | | List<Long> finTenDays = new ArrayList<>(); |
| | | while (!startDate.isAfter(endDate)) { |
| | | lastTenDays.add(startDate); |
| | | if (type.equals("年")){ |
| | | lastTenDays.add(startDate.format(format).substring(0,7)); |
| | | }else { |
| | | lastTenDays.add(startDate.format(format)); |
| | | } |
| | | receTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() |
| | | .eq(InsOrder::getState, 1) |
| | | .between(InsOrder::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59)))); |
| | | .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59)))); |
| | | finTenDays.add(insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery() |
| | | .eq(InsOrder::getState, 4) |
| | | .between(InsOrder::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59)))); |
| | | startDate = startDate.plusDays(1); |
| | | .between(InsOrder::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59)))); |
| | | if (type.equals("年")) { |
| | | startDate = startDate.plusMonths(1); |
| | | }else { |
| | | startDate=startDate.plusDays(1); |
| | | } |
| | | } |
| | | map.put("DAYS", lastTenDays); |
| | | map.put("RECETENDAYS", receTenDays); |
| | |
| | | |
| | | //检测项目统计 |
| | | @Override |
| | | public Map<String, Object> testProductByDay(String startTime,String endTime,String type) { |
| | | public Map<String, Object> testProductByDay(String startTime, String endTime, String type) { |
| | | DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay(); |
| | | LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59); |
| | | LocalDateTime oldStart=start ; |
| | | LocalDateTime oldEnd=end ; |
| | | LocalDateTime oldStart = start; |
| | | LocalDateTime oldEnd = end; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | /*项目接收*/ |
| | | //今日项目接收量 |
| | |
| | | //今日完成量中的合格量/今日完成量 |
| | | Long accept = insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .eq(InsProduct::getInsResult, 1) |
| | | .isNotNull(InsProduct::getInsResult) |
| | | .ne(InsProduct::getInsResult, 0) |
| | | .between(InsProduct::getCreateTime, start, end)); |
| | | map.put("ACCEPT", accept); |
| | | BigDecimal acceptRate = new BigDecimal(accept).divide(new BigDecimal(finishe == 0 ? 1 : finishe), 2, BigDecimal.ROUND_HALF_UP); |
| | |
| | | //获取近十日的横坐标 |
| | | LocalDate startDate = LocalDate.parse(startTime, format); |
| | | LocalDate endDate = LocalDate.parse(endTime, format); |
| | | List<LocalDate> lastTenDays = new ArrayList<>(); |
| | | List<String> lastTenDays = new ArrayList<>(); |
| | | List<Long> receTenDays = new ArrayList<>(); |
| | | List<Long> finTenDays = new ArrayList<>(); |
| | | while (!startDate.isAfter(endDate)) { |
| | | lastTenDays.add(startDate); |
| | | while (!startDate.isAfter(endDate)) { |
| | | if (type.equals("年")){ |
| | | lastTenDays.add(startDate.format(format).substring(0,7)); |
| | | }else { |
| | | lastTenDays.add(startDate.format(format)); |
| | | } |
| | | receTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .between(InsProduct::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59)))); |
| | | .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59)))); |
| | | finTenDays.add(insProductMapper.selectCount(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getState, 1) |
| | | .isNotNull(InsProduct::getInsResult) |
| | | .between(InsProduct::getCreateTime,startDate.atStartOfDay(),startDate.atTime(23,59,59)))); |
| | | startDate = startDate.plusDays(1); |
| | | .between(InsProduct::getCreateTime, startDate.atStartOfDay(), startDate.atTime(23, 59, 59)))); |
| | | if (type.equals("年")) { |
| | | startDate = startDate.plusMonths(1); |
| | | }else { |
| | | startDate=startDate.plusDays(1); |
| | | } |
| | | } |
| | | map.put("DAYS", lastTenDays); |
| | | map.put("RECETENDAYS", receTenDays); |
| | |
| | | |
| | | //首页-->各站点的工时 |
| | | @Override |
| | | public Map<String, Double> manHourByStation(String startTime, String endTime) { |
| | | public String manHourByStation(String startTime, String endTime, String sonLaboratory) { |
| | | DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay(); |
| | | LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59); |
| | | //查询这个时间内所有的工时 |
| | | List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end)); |
| | | //根据检验项查出来的站点进行分类 |
| | | List<AuxiliaryOutputWorkingHoursDto> outputWorkingHoursDtos = auxiliaryOutputWorkingHours.stream().map(auxiliaryOutputWorkingHours1 -> { |
| | | AuxiliaryOutputWorkingHoursDto auxiliaryOutputWorkingHoursDto = new AuxiliaryOutputWorkingHoursDto(); |
| | | BeanUtils.copyProperties(auxiliaryOutputWorkingHours1, auxiliaryOutputWorkingHoursDto); |
| | | InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()); |
| | | auxiliaryOutputWorkingHoursDto.setSonLaboratory(insProduct.getSonLaboratory()); |
| | | return auxiliaryOutputWorkingHoursDto; |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Double> map = outputWorkingHoursDtos.stream() |
| | | .collect(Collectors.groupingBy( |
| | | AuxiliaryOutputWorkingHoursDto::getSonLaboratory, |
| | | Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime))); |
| | | return map; |
| | | double sum = auxiliaryOutputWorkingHours.stream() |
| | | .filter(auxiliaryOutputWorkingHours1 -> |
| | | insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory) |
| | | ).mapToDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime).sum(); |
| | | String num = String.format("%.2f", sum); |
| | | return num; |
| | | } |
| | | |
| | | //首页-->各站点工时每个人所占百分比 |
| | | @Override |
| | | public Map<String, Map<String, Double>> manHourByPerson(String startTime, String endTime) { |
| | | public Map<Object, Double> manHourByPerson(String startTime, String endTime, String sonLaboratory) { |
| | | DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDateTime start = LocalDate.parse(startTime, format).atStartOfDay(); |
| | | LocalDateTime end = LocalDate.parse(endTime, format).atTime(23, 59, 59); |
| | |
| | | List<AuxiliaryOutputWorkingHours> auxiliaryOutputWorkingHours = auxiliaryOutputWorkingHoursMapper.selectList(Wrappers.<AuxiliaryOutputWorkingHours>lambdaQuery() |
| | | .between(AuxiliaryOutputWorkingHours::getCreateTime, start, end)); |
| | | //根据检验项查出来的站点进行分类 |
| | | List<AuxiliaryOutputWorkingHoursDto> outputWorkingHoursDtos = auxiliaryOutputWorkingHours.stream().map(auxiliaryOutputWorkingHours1 -> { |
| | | AuxiliaryOutputWorkingHoursDto auxiliaryOutputWorkingHoursDto = new AuxiliaryOutputWorkingHoursDto(); |
| | | BeanUtils.copyProperties(auxiliaryOutputWorkingHours1, auxiliaryOutputWorkingHoursDto); |
| | | InsProduct insProduct = insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()); |
| | | auxiliaryOutputWorkingHoursDto.setSonLaboratory(insProduct.getSonLaboratory()); |
| | | return auxiliaryOutputWorkingHoursDto; |
| | | }).collect(Collectors.toList()); |
| | | Map<String, Map<String, Double>> mapMap = outputWorkingHoursDtos.stream() |
| | | List<AuxiliaryOutputWorkingHours> outputWorkingHours = auxiliaryOutputWorkingHours.stream() |
| | | .filter(auxiliaryOutputWorkingHours1 -> |
| | | insProductMapper.selectById(auxiliaryOutputWorkingHours1.getInsProductId()).getSonLaboratory().equals(sonLaboratory) |
| | | ).collect(Collectors.toList()); |
| | | Map<Object, Double> mapMap = outputWorkingHours.stream() |
| | | .collect(Collectors.groupingBy( |
| | | AuxiliaryOutputWorkingHoursDto::getSonLaboratory, |
| | | Collectors.groupingBy( |
| | | t -> userMapper.selectById(t.getCheck()).getName(), |
| | | Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime)))); |
| | | Collectors.summingDouble(AuxiliaryOutputWorkingHours::getOutputWorkTime))); |
| | | |
| | | return mapMap; |
| | | } |