|
|
@@ -70,6 +70,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.tdparams.IotTdParamsMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.DeviceServiceImpl;
|
|
|
import cn.iocoder.yudao.module.pms.service.inspect.IotInspectOrderService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotmainworkorder.IotMainWorkOrderService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotrydailyreport.IotRyDailyReportService;
|
|
|
import cn.iocoder.yudao.module.pms.service.maintain.IotMaintainService;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
@@ -176,6 +177,8 @@ public class IotStaticController {
|
|
|
private IotDeptTypeMapper iotDeptTypeMapper;
|
|
|
@Autowired
|
|
|
private DeptUtil deptUtil;
|
|
|
+ @Autowired
|
|
|
+ private IotMainWorkOrderService iotMainWorkOrderService;
|
|
|
|
|
|
@GetMapping("/main/day")
|
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
|
@@ -781,6 +784,12 @@ public class IotStaticController {
|
|
|
iotOutboundPageReqVO.setDeptIds(new ArrayList<>(ids));
|
|
|
iotOutboundPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
List<IotOutboundDO> outs = iotOutboundMapper.selectListByTimeAndDept(iotOutboundPageReqVO);
|
|
|
+ // 查询保养成本
|
|
|
+ IotMainWorkOrderPageReqVO workOrderReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
+ workOrderReqVO.setDeptIds(ids);
|
|
|
+ workOrderReqVO.setCreateTime(createTime);
|
|
|
+ List<IotMainWorkOrderDO> workOrders = iotMainWorkOrderService.workOrders(workOrderReqVO);
|
|
|
+ LinkedHashMap<String, Long> byOutMap = countBycbByDate(workOrders, 7);
|
|
|
LinkedHashMap<String, Long> outMap = countYwcbByDate(outs, 7);
|
|
|
LinkedList<Object> xAxis = new LinkedList<>();
|
|
|
LinkedList<Object> outData = new LinkedList<>();
|
|
|
@@ -960,6 +969,42 @@ public class IotStaticController {
|
|
|
return dateMap;
|
|
|
}
|
|
|
|
|
|
+ public static LinkedHashMap<String, Long> countBycbByDate(List<IotMainWorkOrderDO> 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.getCost().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) {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
LocalDate today = LocalDate.now();
|