|
@@ -61,6 +61,7 @@ import java.util.stream.Collectors;
|
|
import java.util.stream.Stream;
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAIN_WORK_ORDER_EXECUTED;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAIN_WORK_ORDER_EXECUTED;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAIN_WORK_ORDER_NOT_EXISTS;
|
|
import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_MAIN_WORK_ORDER_NOT_EXISTS;
|
|
@@ -158,7 +159,46 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageResult<IotMainWorkOrderRespVO> sortedMainWorkOrderPage(IotMainWorkOrderPageReqVO pageReqVO) {
|
|
public PageResult<IotMainWorkOrderRespVO> sortedMainWorkOrderPage(IotMainWorkOrderPageReqVO pageReqVO) {
|
|
- // 查询 未执行 计划生成 的工单
|
|
|
|
|
|
+ // 根据 设备编码 新旧油服号 搜索
|
|
|
|
+ // 如果 pageReqVO.getName() 有值 先根据 name 值查询 新旧油服号都匹配的保养工单
|
|
|
|
+ List<Long> eligibleDeviceIds = new ArrayList<>();
|
|
|
|
+ List<Long> eligibleWorkOrderIds = new ArrayList<>();
|
|
|
|
+ if (StrUtil.isNotBlank(pageReqVO.getName())) {
|
|
|
|
+ IotDevicePageReqVO reqVO = new IotDevicePageReqVO();
|
|
|
|
+ reqVO.setDeviceName(pageReqVO.getName());
|
|
|
|
+ List<IotDeviceDO> eligibleDevices = iotDeviceMapper.selectListAlone(reqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(eligibleDevices)) {
|
|
|
|
+ eligibleDeviceIds = convertList(eligibleDevices, IotDeviceDO::getId);
|
|
|
|
+ // 如果有相关的设备 查询对应的保养工单
|
|
|
|
+ if (CollUtil.isNotEmpty(eligibleDeviceIds)) {
|
|
|
|
+ IotMainWorkOrderBomPageReqVO bomReqVO = new IotMainWorkOrderBomPageReqVO();
|
|
|
|
+ bomReqVO.setDeviceIds(eligibleDeviceIds);
|
|
|
|
+ List<IotMainWorkOrderBomDO> boms = iotMainWorkOrderBomMapper.selectList(bomReqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(boms)) {
|
|
|
|
+ Set<Long> workOrderIds = new HashSet<>();
|
|
|
|
+ boms.forEach(bom -> {
|
|
|
|
+ workOrderIds.add(bom.getWorkOrderId());
|
|
|
|
+ });
|
|
|
|
+ eligibleWorkOrderIds.addAll(workOrderIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 根据保养工单名称搜索
|
|
|
|
+ IotMainWorkOrderPageReqVO orderReqVO = new IotMainWorkOrderPageReqVO();
|
|
|
|
+ orderReqVO.setName(pageReqVO.getName());
|
|
|
|
+ List<IotMainWorkOrderDO> likeNameWorkOrders = iotMainWorkOrderMapper.selectList(orderReqVO);
|
|
|
|
+ if (CollUtil.isNotEmpty(likeNameWorkOrders)) {
|
|
|
|
+ likeNameWorkOrders.forEach(order -> {
|
|
|
|
+ if (!eligibleWorkOrderIds.contains(order.getId())) {
|
|
|
|
+ eligibleWorkOrderIds.add(order.getId());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isEmpty(eligibleWorkOrderIds)) {
|
|
|
|
+ return PageResult.empty();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // 查询 未执行 计划生成 的工单 计算距离保养使用
|
|
IotMainWorkOrderPageReqVO reqVO = new IotMainWorkOrderPageReqVO();
|
|
IotMainWorkOrderPageReqVO reqVO = new IotMainWorkOrderPageReqVO();
|
|
reqVO.setResult(1);
|
|
reqVO.setResult(1);
|
|
reqVO.setType(1);
|
|
reqVO.setType(1);
|
|
@@ -173,6 +213,9 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
IotMainWorkOrderBomPageReqVO bomReqVO = new IotMainWorkOrderBomPageReqVO();
|
|
IotMainWorkOrderBomPageReqVO bomReqVO = new IotMainWorkOrderBomPageReqVO();
|
|
if (CollUtil.isNotEmpty(workOrderIds)) {
|
|
if (CollUtil.isNotEmpty(workOrderIds)) {
|
|
bomReqVO.setWorkOrderIds(workOrderIds);
|
|
bomReqVO.setWorkOrderIds(workOrderIds);
|
|
|
|
+ if (CollUtil.isNotEmpty(eligibleDeviceIds)) {
|
|
|
|
+ bomReqVO.setDeviceIds(eligibleDeviceIds);
|
|
|
|
+ }
|
|
// 查询 未执行的计划生成的工单 的保养项明细
|
|
// 查询 未执行的计划生成的工单 的保养项明细
|
|
workOrderBomS= iotMainWorkOrderBomMapper.selectList(bomReqVO);
|
|
workOrderBomS= iotMainWorkOrderBomMapper.selectList(bomReqVO);
|
|
}
|
|
}
|
|
@@ -320,7 +363,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
}
|
|
}
|
|
// 查询所有设备列表 通过SQL形式 使用 FIELD 字段
|
|
// 查询所有设备列表 通过SQL形式 使用 FIELD 字段
|
|
IPage<IotMainWorkOrderRespVO> page = iotMainWorkOrderMapper.sortedMainWorkOrders(
|
|
IPage<IotMainWorkOrderRespVO> page = iotMainWorkOrderMapper.sortedMainWorkOrders(
|
|
- new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO, sortedWorkOrderIds, ids);
|
|
|
|
|
|
+ new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()), pageReqVO, sortedWorkOrderIds, ids, eligibleWorkOrderIds);
|
|
if (CollUtil.isNotEmpty(page.getRecords())) {
|
|
if (CollUtil.isNotEmpty(page.getRecords())) {
|
|
Map<Long, String> finalResultMap = resultMap;
|
|
Map<Long, String> finalResultMap = resultMap;
|
|
page.getRecords().forEach(order -> {
|
|
page.getRecords().forEach(order -> {
|