|
@@ -15,6 +15,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDevice
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotdevicerunlog.vo.IotDeviceRunLogRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorder.vo.IotMainWorkOrderPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotopeationfill.vo.IotOpeationFillPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotoutbound.vo.IotOutboundPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.OrderVo;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.vo.DeviceVO;
|
|
@@ -26,6 +27,7 @@ import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.inspect.IotInspectOrderDetailDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotcountdata.IotCountDataDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorder.IotMainWorkOrderDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotoutbound.IotOutboundDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotsapstock.IotSapStockDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.maintain.IotMaintainDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
|
|
@@ -37,6 +39,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorder.IotMainWorkOrderMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotoutbound.IotOutboundMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotsapstock.IotSapStockMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.DeviceServiceImpl;
|
|
@@ -63,6 +66,7 @@ import javax.annotation.Resource;
|
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.Serializable;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
@@ -117,6 +121,8 @@ public class IotStaticController {
|
|
|
private IotDeviceRunLogMapper iotDeviceRunLogMapper;
|
|
|
@Autowired
|
|
|
private TDDeviceMapper deviceMapper;
|
|
|
+ @Autowired
|
|
|
+ private IotOutboundMapper iotOutboundMapper;
|
|
|
|
|
|
@GetMapping("/main/day")
|
|
|
public CommonResult<Map<String, Object>> getMaintainDay() {
|
|
@@ -602,6 +608,37 @@ public class IotStaticController {
|
|
|
return success(ImmutableMap.of("todo", todo.get(),"finished", finished.get()));
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/rh/ywcb/{dept}")
|
|
|
+ @PermitAll
|
|
|
+ public CommonResult<Map<String, Object>> getRhYwcbStat(@PathVariable("dept") String dept) {
|
|
|
+ Set<Long> ids = getDeptIds(dept);
|
|
|
+ List<String> lastSevenDays = DateUtils.getLastSevenDays();
|
|
|
+ String first = lastSevenDays.get(0);
|
|
|
+ String last = lastSevenDays.get(lastSevenDays.size() - 1);
|
|
|
+ LocalDateTime startOfDay = getStartOfDay(last);
|
|
|
+ LocalDateTime endOfDay = getEndOfDay(first);
|
|
|
+ LocalDateTime[] createTime = new LocalDateTime[]{startOfDay, endOfDay};
|
|
|
+
|
|
|
+ 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);
|
|
|
+ LinkedHashMap<String, Long> outMap = countYwcbByDate(outs, 7);
|
|
|
+ LinkedList<Object> xAxis = new LinkedList<>();
|
|
|
+ LinkedList<Object> outData = new LinkedList<>();
|
|
|
+ outMap.forEach( (k,v)->{
|
|
|
+ xAxis.add(k);
|
|
|
+ outData.add(v);
|
|
|
+ });
|
|
|
+
|
|
|
+ return success(ImmutableMap.of("xAxis", xAxis, "series", outData));
|
|
|
+ }
|
|
|
+
|
|
|
@GetMapping("/rh/order/{dept}")
|
|
|
@PermitAll
|
|
|
public CommonResult<Map<String, Object>> getOrderNumberStat(@PathVariable("dept") String dept) {
|
|
@@ -678,25 +715,6 @@ public class IotStaticController {
|
|
|
ImmutableMap<String, Serializable> inspectResult = ImmutableMap.of("name", "巡检工单", "data", inspectData);
|
|
|
ImmutableMap<String, Serializable> fillResult = ImmutableMap.of("name", "运行记录", "data", fillData);
|
|
|
return success(ImmutableMap.of("xAxis", xAxis, "series", ImmutableList.of(maintainResult, workResult,inspectResult, fillResult)));
|
|
|
-// for (String lastSevenDay : lastSevenDays) {
|
|
|
-// // 转换为LocalDateTime
|
|
|
-// LocalDateTime startOfDay = getStartOfDay(lastSevenDay);
|
|
|
-// LocalDateTime endOfDay = getEndOfDay(lastSevenDay);
|
|
|
-// IotMaintainPageReqVO iotMaintainPageReqVO = new IotMaintainPageReqVO();
|
|
|
-// LocalDateTime[] createTime = new LocalDateTime[]{startOfDay, endOfDay};
|
|
|
-// iotMaintainPageReqVO.setCreateTime(createTime);
|
|
|
-// Long maintainCount = iotMaintainMapper.selectCountByTimeAndStatus(iotMaintainPageReqVO);
|
|
|
-// maintain.add(maintainCount);
|
|
|
-// IotMainWorkOrderPageReqVO iotMainWorkOrderPageReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
-// iotMainWorkOrderPageReqVO.setCreateTime(createTime);
|
|
|
-// Long workOrderCount = iotMainWorkOrderMapper.selectCountByTimeAndStatus(iotMainWorkOrderPageReqVO);
|
|
|
-// workorder.add(workOrderCount);
|
|
|
-// IotInspectOrderPageReqVO iotInspectOrderPageReqVO = new IotInspectOrderPageReqVO();
|
|
|
-// iotInspectOrderPageReqVO.setCreateTime(createTime);
|
|
|
-// Long inspectCount = iotInspectOrderMapper.selectCountByTimeAndStatus(iotInspectOrderPageReqVO);
|
|
|
-// inspect.add(inspectCount);
|
|
|
-// }
|
|
|
-
|
|
|
}
|
|
|
|
|
|
public static LinkedHashMap<String, Long> sumTotalByDate(List<Map<String, Object>> records, int days, String key) {
|
|
@@ -751,6 +769,41 @@ public class IotStaticController {
|
|
|
return dateMap;
|
|
|
}
|
|
|
|
|
|
+ public static LinkedHashMap<String, Long> countYwcbByDate(List<IotOutboundDO> 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.getQuantity().multiply(record.getUnitPrice()).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");
|