|
@@ -1,15 +1,29 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
package cn.iocoder.yudao.module.pms.controller.admin.stat;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotmainworkorderbom.vo.IotMainWorkOrderBomPageReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotprojecttask.vo.IotProjectTaskPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.maintain.vo.IotMaintainPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp;
|
|
import cn.iocoder.yudao.module.pms.controller.admin.stat.vo.AllOrderResp;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDevicePageReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotmainworkorderbom.IotMainWorkOrderBomDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotopeationfill.IotOpeationFillDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotprojecttask.IotProjectTaskDO;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.IotDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderDeviceMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.inspect.IotInspectOrderMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorder.IotMainWorkOrderMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorder.IotMainWorkOrderMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotmainworkorderbom.IotMainWorkOrderBomMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotprojecttask.IotProjectTaskMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrddailyreport.IotRdDailyReportMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrhdailyreport.IotRhDailyReportMapper;
|
|
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotrydailyreport.IotRyDailyReportMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.maintain.IotMaintainMapper;
|
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
import cn.iocoder.yudao.module.system.service.dept.DeptService;
|
|
@@ -26,10 +40,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.annotation.security.PermitAll;
|
|
import javax.annotation.security.PermitAll;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
-import java.util.Set;
|
|
|
|
|
-import java.util.StringJoiner;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
@@ -49,6 +61,12 @@ public class IotReportOrderController {
|
|
|
private final DeptService deptService;
|
|
private final DeptService deptService;
|
|
|
private final DeptApi deptApi;
|
|
private final DeptApi deptApi;
|
|
|
private final IotInspectOrderDeviceMapper iotInspectOrderDeviceMapper;
|
|
private final IotInspectOrderDeviceMapper iotInspectOrderDeviceMapper;
|
|
|
|
|
+ private final IotMainWorkOrderBomMapper iotMainWorkOrderBomMapper;
|
|
|
|
|
+ private final IotDeviceMapper iotDeviceMapper;
|
|
|
|
|
+ private final IotRhDailyReportMapper iotRhDailyReportMapper;
|
|
|
|
|
+ private final IotRyDailyReportMapper iotRyDailyReportMapper;
|
|
|
|
|
+ private final IotRdDailyReportMapper iotRdDailyReportMapper;
|
|
|
|
|
+ private final IotProjectTaskMapper iotProjectTaskMapper;
|
|
|
|
|
|
|
|
@Operation(summary = "各工单状态数量统计")
|
|
@Operation(summary = "各工单状态数量统计")
|
|
|
@GetMapping("/number")
|
|
@GetMapping("/number")
|
|
@@ -57,7 +75,49 @@ public class IotReportOrderController {
|
|
|
List<AllOrderResp> inspects = iotInspectOrderMapper.selectStatusNumber(pageReqVO);
|
|
List<AllOrderResp> inspects = iotInspectOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> operations = iotOpeationFillMapper.selectStatusNumber(pageReqVO);
|
|
List<AllOrderResp> operations = iotOpeationFillMapper.selectStatusNumber(pageReqVO);
|
|
|
List<AllOrderResp> workOrders = iotMainWorkOrderMapper.selectStatusNumber(pageReqVO);
|
|
List<AllOrderResp> workOrders = iotMainWorkOrderMapper.selectStatusNumber(pageReqVO);
|
|
|
- return CommonResult.success(ImmutableMap.of("wx", maintains, "xj", inspects, "yx", operations, "by", workOrders));
|
|
|
|
|
|
|
+ // 日报
|
|
|
|
|
+ List<AllOrderResp> dailyReports = iotRhDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ List<AllOrderResp> ryDailyReports = iotRyDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ List<AllOrderResp> rdDailyReports = iotRdDailyReportMapper.selectStatusNumber(pageReqVO);
|
|
|
|
|
+ List<AllOrderResp> reports = new ArrayList<>();
|
|
|
|
|
+ AtomicReference<Long> noStatus = new AtomicReference<>(0l);
|
|
|
|
|
+ AtomicReference<Long> yesStatus = new AtomicReference<>(0l);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(dailyReports)) {
|
|
|
|
|
+ dailyReports.forEach(report -> {
|
|
|
|
|
+ if ("0".equals(report.getStatus())) {
|
|
|
|
|
+ noStatus.set(noStatus.get() + report.getNum());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ yesStatus.set(yesStatus.get() + report.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(ryDailyReports)) {
|
|
|
|
|
+ ryDailyReports.forEach(report -> {
|
|
|
|
|
+ if ("0".equals(report.getStatus())) {
|
|
|
|
|
+ noStatus.set(noStatus.get() + report.getNum());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ yesStatus.set(yesStatus.get() + report.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(rdDailyReports)) {
|
|
|
|
|
+ rdDailyReports.forEach(report -> {
|
|
|
|
|
+ if ("0".equals(report.getStatus())) {
|
|
|
|
|
+ noStatus.set(noStatus.get() + report.getNum());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ yesStatus.set(yesStatus.get() + report.getNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ AllOrderResp noReport = new AllOrderResp();
|
|
|
|
|
+ noReport.setStatus("0");
|
|
|
|
|
+ noReport.setNum(Long.valueOf(noStatus.get()));
|
|
|
|
|
+ reports.add(noReport);
|
|
|
|
|
+ AllOrderResp yesReport = new AllOrderResp();
|
|
|
|
|
+ yesReport.setStatus("1");
|
|
|
|
|
+ yesReport.setNum(Long.valueOf(yesStatus.get()));
|
|
|
|
|
+ reports.add(yesReport);
|
|
|
|
|
+ return CommonResult.success(ImmutableMap.of("wx", maintains, "xj", inspects, "yx", operations, "by", workOrders, "rb", reports));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -76,6 +136,97 @@ public class IotReportOrderController {
|
|
|
pageReqVO.setDeptIds(ids);
|
|
pageReqVO.setDeptIds(ids);
|
|
|
IPage<AllOrderResp> allOrder = iotMaintainMapper.getAllOrder(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
|
IPage<AllOrderResp> allOrder = iotMaintainMapper.getAllOrder(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO);
|
|
|
PageResult<AllOrderResp> result = new PageResult<>(allOrder.getRecords(), allOrder.getTotal());
|
|
PageResult<AllOrderResp> result = new PageResult<>(allOrder.getRecords(), allOrder.getTotal());
|
|
|
|
|
+ Map<Long, String> orderPair = new HashMap<>();
|
|
|
|
|
+ Map<Long, Long> orderDeviceIdPair = new HashMap<>();
|
|
|
|
|
+ Map<Long, String> devicePair = new HashMap<>();
|
|
|
|
|
+ // 任务列表
|
|
|
|
|
+ Set<Long> taskIds = new HashSet<>();
|
|
|
|
|
+ // 设备id列表
|
|
|
|
|
+ Set<Long> totalDeviceIds = new HashSet<>();
|
|
|
|
|
+ // 日报设备列表 key设备id value设备信息
|
|
|
|
|
+ Map<Long, String> reportDevicePair = new HashMap<>();
|
|
|
|
|
+ // 日报设备列表 key任务id value多个设备信息列表
|
|
|
|
|
+ Map<Long, Set<Long>> taskDevicesPair = new HashMap<>();
|
|
|
|
|
+ // 日报设备列表 key任务id value多个设备信息 分号分隔
|
|
|
|
|
+ Map<Long,String> taskDevicesStrPair = new HashMap<>();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(result.getList())) {
|
|
|
|
|
+ Set<Long> orderIds = new HashSet<>();
|
|
|
|
|
+ result.getList().forEach(order -> {
|
|
|
|
|
+ if ("保养工单".equals(order.getType())) {
|
|
|
|
|
+ orderIds.add(order.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if ("瑞都日报".equals(order.getType()) || "瑞鹰日报".equals(order.getType()) || "瑞恒日报".equals(order.getType())) {
|
|
|
|
|
+ taskIds.add(order.getTaskId());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ if (CollUtil.isNotEmpty(taskIds)) {
|
|
|
|
|
+ IotProjectTaskPageReqVO reqVO = new IotProjectTaskPageReqVO();
|
|
|
|
|
+ reqVO.setTaskIds(new ArrayList<>(taskIds));
|
|
|
|
|
+ List<IotProjectTaskDO> tasks = iotProjectTaskMapper.selectList(reqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(tasks)) {
|
|
|
|
|
+ tasks.forEach(task -> {
|
|
|
|
|
+ Set<Long> deviceIds = task.getDeviceIds();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds)) {
|
|
|
|
|
+ totalDeviceIds.addAll(deviceIds);
|
|
|
|
|
+ taskDevicesPair.put(task.getId(), task.getDeviceIds());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 查询所有设备信息
|
|
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
|
|
+ deviceReqVO.setDeviceIds(new ArrayList<>(totalDeviceIds));
|
|
|
|
|
+ List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(devices)) {
|
|
|
|
|
+ devices.forEach(device -> {
|
|
|
|
|
+ reportDevicePair.put(device.getId(), StrUtil.join("|", device.getDeviceCode(), device.getDeviceName()));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ // 建立日报关联的任务id 与 任务下所有设备 编码名称 的对应关系
|
|
|
|
|
+ if (CollUtil.isNotEmpty(taskDevicesPair) && CollUtil.isNotEmpty(reportDevicePair)) {
|
|
|
|
|
+ for (Map.Entry<Long, Set<Long>> entry : taskDevicesPair.entrySet()) {
|
|
|
|
|
+ Long taskId = entry.getKey();
|
|
|
|
|
+ Set<Long> deviceIds = entry.getValue();
|
|
|
|
|
+
|
|
|
|
|
+ // 使用流处理获取设备名称,并用分号连接
|
|
|
|
|
+ String deviceStr = deviceIds.stream()
|
|
|
|
|
+ .map(reportDevicePair::get) // 从 reportDevicePair 获取设备字符串
|
|
|
|
|
+ .filter(StrUtil::isNotBlank) // 过滤掉空值
|
|
|
|
|
+ .collect(Collectors.joining(";")); // 用分号连接
|
|
|
|
|
+
|
|
|
|
|
+ if (StrUtil.isNotBlank(deviceStr)) {
|
|
|
|
|
+ taskDevicesStrPair.put(taskId, deviceStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(orderIds)) {
|
|
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
|
|
+ // 查询所有保养工单的设备名称
|
|
|
|
|
+ IotMainWorkOrderBomPageReqVO bomReqVO = new IotMainWorkOrderBomPageReqVO();
|
|
|
|
|
+ bomReqVO.setWorkOrderIds(new ArrayList<>(orderIds));
|
|
|
|
|
+ List<IotMainWorkOrderBomDO> orderBoms = iotMainWorkOrderBomMapper.selectList(bomReqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(orderBoms)) {
|
|
|
|
|
+ orderBoms.forEach(bom -> {
|
|
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
|
|
+ orderDeviceIdPair.put(bom.getWorkOrderId(), bom.getDeviceId());
|
|
|
|
|
+ });
|
|
|
|
|
+ // 查询所有设备的编码 名称
|
|
|
|
|
+ IotDevicePageReqVO deviceReqVO = new IotDevicePageReqVO();
|
|
|
|
|
+ deviceReqVO.setDeviceIds(new ArrayList<>(deviceIds));
|
|
|
|
|
+ List<IotDeviceDO> devices = iotDeviceMapper.selectListAlone(deviceReqVO);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(devices)) {
|
|
|
|
|
+ devices.forEach(device -> {
|
|
|
|
|
+ devicePair.put(device.getId(), StrUtil.join("|", device.getDeviceCode(), device.getDeviceName()));
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ orderDeviceIdPair.forEach((orderId, deviceId) -> {
|
|
|
|
|
+ if (devicePair.containsKey(deviceId)) {
|
|
|
|
|
+ orderPair.put(orderId, devicePair.get(deviceId));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
List<AllOrderResp> collect = result.getList().stream().map(e -> {
|
|
List<AllOrderResp> collect = result.getList().stream().map(e -> {
|
|
|
if ("巡检工单".equals(e.getType())){
|
|
if ("巡检工单".equals(e.getType())){
|
|
|
String deviceInfo = iotInspectOrderDeviceMapper.getDeviceInfo(e.getId());
|
|
String deviceInfo = iotInspectOrderDeviceMapper.getDeviceInfo(e.getId());
|
|
@@ -87,6 +238,15 @@ public class IotReportOrderController {
|
|
|
joiner.add(fillDO.getDeviceCode() + "/" + fillDO.getDeviceName());
|
|
joiner.add(fillDO.getDeviceCode() + "/" + fillDO.getDeviceName());
|
|
|
}
|
|
}
|
|
|
e.setDevice(joiner.toString());
|
|
e.setDevice(joiner.toString());
|
|
|
|
|
+ } else if ("保养工单".equals(e.getType())) {
|
|
|
|
|
+ if (orderPair.containsKey(e.getId())) {
|
|
|
|
|
+ e.setDevice(orderPair.get(e.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if ("瑞都日报".equals(e.getType()) || "瑞鹰日报".equals(e.getType()) || "瑞恒日报".equals(e.getType())) {
|
|
|
|
|
+ // 设置日报的设备信息
|
|
|
|
|
+ if (taskDevicesStrPair.containsKey(e.getTaskId())) {
|
|
|
|
|
+ e.setDevice(taskDevicesStrPair.get(e.getTaskId()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
return e;
|
|
return e;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|