|
@@ -774,28 +774,30 @@ public class IotStaticController {
|
|
|
LocalDateTime startOfDay = getStartOfDay(last);
|
|
LocalDateTime startOfDay = getStartOfDay(last);
|
|
|
LocalDateTime endOfDay = getEndOfDay(first);
|
|
LocalDateTime endOfDay = getEndOfDay(first);
|
|
|
LocalDateTime[] createTime = new LocalDateTime[]{startOfDay, endOfDay};
|
|
LocalDateTime[] createTime = new LocalDateTime[]{startOfDay, endOfDay};
|
|
|
|
|
+ //查询维修成本
|
|
|
|
|
+ IotMaintainPageReqVO maintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
|
|
+ maintainPageReqVO.setDeptIds(ids);
|
|
|
|
|
+ maintainPageReqVO.setCreateTime(createTime);
|
|
|
|
|
+ maintainPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ List<IotMaintainDO> repairOrders = iotMaintainService.getIotMaintainPage(maintainPageReqVO).getList();
|
|
|
|
|
+ LinkedHashMap<String, Long> repairMap = countWxcbByDate(repairOrders, 7);
|
|
|
|
|
|
|
|
- IotOpeationFillPageReqVO iotOpeationFillPageReqVO = new IotOpeationFillPageReqVO();
|
|
|
|
|
- iotOpeationFillPageReqVO.setCreateTime(createTime);
|
|
|
|
|
- iotOpeationFillPageReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
|
|
-
|
|
|
|
|
- IotOutboundPageReqVO iotOutboundPageReqVO = new IotOutboundPageReqVO();
|
|
|
|
|
- iotOutboundPageReqVO.setCreateTime(createTime);
|
|
|
|
|
- iotOutboundPageReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
|
|
- iotOutboundPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
- List<IotOutboundDO> outs = iotOutboundMapper.selectListByTimeAndDept(iotOutboundPageReqVO);
|
|
|
|
|
// 查询保养成本
|
|
// 查询保养成本
|
|
|
IotMainWorkOrderPageReqVO workOrderReqVO = new IotMainWorkOrderPageReqVO();
|
|
IotMainWorkOrderPageReqVO workOrderReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
workOrderReqVO.setDeptIds(ids);
|
|
workOrderReqVO.setDeptIds(ids);
|
|
|
workOrderReqVO.setCreateTime(createTime);
|
|
workOrderReqVO.setCreateTime(createTime);
|
|
|
List<IotMainWorkOrderDO> workOrders = iotMainWorkOrderService.workOrders(workOrderReqVO);
|
|
List<IotMainWorkOrderDO> workOrders = iotMainWorkOrderService.workOrders(workOrderReqVO);
|
|
|
LinkedHashMap<String, Long> byOutMap = countBycbByDate(workOrders, 7);
|
|
LinkedHashMap<String, Long> byOutMap = countBycbByDate(workOrders, 7);
|
|
|
- LinkedHashMap<String, Long> outMap = countYwcbByDate(outs, 7);
|
|
|
|
|
|
|
+// LinkedHashMap<String, Long> outMap = countYwcbByDate(outs, 7);
|
|
|
LinkedList<Object> xAxis = new LinkedList<>();
|
|
LinkedList<Object> xAxis = new LinkedList<>();
|
|
|
LinkedList<Object> outData = new LinkedList<>();
|
|
LinkedList<Object> outData = new LinkedList<>();
|
|
|
- outMap.forEach( (k,v)->{
|
|
|
|
|
|
|
+ repairMap.forEach( (k,v)->{
|
|
|
xAxis.add(k);
|
|
xAxis.add(k);
|
|
|
- outData.add(v);
|
|
|
|
|
|
|
+ if (Objects.isNull(byOutMap.get(k))) {
|
|
|
|
|
+ outData.add(v);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ outData.add(v+byOutMap.get(k));
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
return success(ImmutableMap.of("xAxis", xAxis, "series", outData));
|
|
return success(ImmutableMap.of("xAxis", xAxis, "series", outData));
|
|
@@ -1005,6 +1007,41 @@ public class IotStaticController {
|
|
|
return dateMap;
|
|
return dateMap;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static LinkedHashMap<String, Long> countWxcbByDate(List<IotMaintainDO> records, int days) {
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ LocalDate today = LocalDate.now();
|
|
|
|
|
+
|
|
|
|
|
+ // 生成近七天的日期列表
|
|
|
|
|
+ LinkedHashMap<String, Long> dateMap = new LinkedHashMap<>();
|
|
|
|
|
+ for (int i = days-1; i >= 0; i--) {
|
|
|
|
|
+ LocalDate date = today.minusDays(i);
|
|
|
|
|
+ dateMap.put(date.format(formatter), 0L);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Long> amountMap = records.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(
|
|
|
|
|
+ record -> {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 提取日期部分(假设createTime是类似"yyyy-MM-ddHH:mm:ss"的字符串)
|
|
|
|
|
+ return String.valueOf(record.getCreateTime()).substring(0, 10);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ System.err.println("日期格式错误: " + record.getCreateTime());
|
|
|
|
|
+ return "invalid_date";
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 对每个分组计算金额总和:quantity * price累加
|
|
|
|
|
+ Collectors.summingLong(record -> record.getMaintainFee().longValue())
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ // 合并两个映射,确保所有日期都存在
|
|
|
|
|
+ dateMap.forEach((date, count) -> {
|
|
|
|
|
+ if (amountMap.containsKey(date)) {
|
|
|
|
|
+ dateMap.put(date, amountMap.get(date));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return dateMap;
|
|
|
|
|
+ }
|
|
|
public static LinkedHashMap<String, Long> countRecordsByDate(List<Map<String, Object>> records, int days) {
|
|
public static LinkedHashMap<String, Long> countRecordsByDate(List<Map<String, Object>> records, int days) {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
LocalDate today = LocalDate.now();
|
|
LocalDate today = LocalDate.now();
|