| | |
| | | map.put("customer",count); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public String salesAnalysis(SalesDeliveryDto salesDeliveryDto) { |
| | | List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays()); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String salesRanking(SalesDeliveryDto salesDeliveryDto) { |
| | | List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays()); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String salesAmount(SalesDeliveryDto salesDeliveryDto) { |
| | | List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays()); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String salesDataRanking(SalesDeliveryDto salesDeliveryDto) { |
| | | List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays()); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public SalesTotalDto customerTrends(SalesDeliveryDto salesDeliveryDto) { |
| | | SalesTotalDto salesTotalDto = new SalesTotalDto(); |
| | | List<LocalDate> dates = convertDateList(salesDeliveryDto.getDays()); |
| | | List<Map<String, Long>> maps = new ArrayList<>(); |
| | | for (LocalDate date : dates) { |
| | | LocalDate firstDay = date.with(TemporalAdjusters.firstDayOfMonth()); |
| | | LocalDate lastDay = date.with(TemporalAdjusters.lastDayOfMonth()); |
| | | Date startDate = Date.from(firstDay.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| | | Date endDate = Date.from(lastDay.atTime(23, 59, 59).atZone(ZoneId.systemDefault()).toInstant()); |
| | | List<Customer> customers = customerMapper.selectList(Wrappers.<Customer>lambdaQuery() |
| | | .between(Customer::getMaintenanceTime, startDate, endDate)); |
| | | Map<String, Long> regionCountMap = Arrays.stream(AddressRegionEnum.values()) |
| | | .filter(addressRegionEnum -> addressRegionEnum.getRegionName().equals("SELF_PICKUP")) |
| | | .collect(Collectors.toMap( |
| | | AddressRegionEnum::getRegionName, // åºååä½ä¸ºkey |
| | | enumItem -> 0L // åå§å¼å
¨é¨ä¸º0 |
| | | )); |
| | | if (!CollectionUtils.isEmpty(customers)) { |
| | | regionCountMap = customers.stream() |
| | | // è°ç¨æ¹æ³å°åå§å°å转æ¢ä¸ºç®æ åºå |
| | | .map(customer -> AddressRegionEnum.matchRegion(customer.getCompanyAddress()).getRegionName()) |
| | | // è¿æ»¤æè½¬æ¢å¤±è´¥/空çåºåï¼å¯éï¼æ ¹æ®ä¸å¡éæ±ï¼ |
| | | .filter(region -> region != null && !region.isEmpty()) |
| | | // æåºååç»ï¼ç»è®¡æ¯ä¸ªåºåçæ°é |
| | | .collect(Collectors.groupingBy( |
| | | region -> region, // åç»ä¾æ®ï¼è½¬æ¢åçåºå |
| | | Collectors.counting() // è®¡æ° |
| | | )); |
| | | } |
| | | regionCountMap.put("ALLIN",customers.stream().count()); |
| | | maps.add(regionCountMap); |
| | | } |
| | | salesTotalDto.setDates(dates); |
| | | salesTotalDto.setCustomerTrends(maps); |
| | | return salesTotalDto; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®åç«¯ä¼ å å¹´/æ 转æ¢ä¸ºå¯¹åºLocalDateå表 |
| | | * @param days åç«¯åæ°ï¼"å¹´" / "æ" |
| | | * @return List<LocalDate> |
| | | */ |
| | | public static List<LocalDate> convertDateList(String days) { |
| | | List<LocalDate> resultList = new ArrayList<>(); |
| | | LocalDate now = LocalDate.now(); |
| | | int currentYear = now.getYear(); |
| | | |
| | | if ("å¹´".equals(days)) { |
| | | // éæ±ï¼è¿5å¹´ â æ¯å¹´ç 1æ1æ¥ |
| | | for (int i = 0; i < 5; i++) { |
| | | resultList.add(LocalDate.of(currentYear - i, 1, 1)); |
| | | } |
| | | } else if ("æ".equals(days)) { |
| | | // éæ±ï¼å½å¹´12个æ â æ¯æ1æ¥ |
| | | for (int month = 1; month <= 12; month++) { |
| | | resultList.add(LocalDate.of(currentYear, month, 1)); |
| | | } |
| | | } |
| | | return resultList; |
| | | } |
| | | } |