|
|
@@ -42,6 +42,7 @@ import javax.annotation.Resource;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
@@ -118,8 +119,22 @@ public class IotInspectOrderServiceImpl implements IotInspectOrderService {
|
|
|
order.setStatus("finished");
|
|
|
order.setExecuteDate(LocalDateTime.now());
|
|
|
}
|
|
|
+ //填写巡检工单,更新异常等数目----------------------------------------
|
|
|
+ List<IotInspectOrderDetailDO> detailss = iotInspectOrderDetailMapper.selectList("order_id", orderId);
|
|
|
+ long deviceCount = detailss.stream().map(IotInspectOrderDetailDO::getDeviceId).distinct().count();
|
|
|
+ long exceptionCount = detailss.stream().filter(f -> Objects.nonNull(f.getIfNormal()) && !f.getIfNormal()).map(IotInspectOrderDetailDO::getDeviceId).distinct().count();
|
|
|
+ Map<Long, List<IotInspectOrderDetailDO>> collect11 = detailss.stream().collect(Collectors.groupingBy(IotInspectOrderDetailDO::getDeviceId));
|
|
|
+ AtomicInteger needDevice = new AtomicInteger();
|
|
|
+ collect11.forEach((k, v) -> {
|
|
|
+ if (v.stream().anyMatch(gg -> Objects.isNull(gg.getIfNormal()))){
|
|
|
+ needDevice.getAndIncrement();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ order.setTotalCount(Math.toIntExact(deviceCount));
|
|
|
+ order.setExceptionCount(Math.toIntExact(exceptionCount));
|
|
|
+ order.setNeedCount(needDevice.get());
|
|
|
iotInspectOrderMapper.updateById(order);
|
|
|
-
|
|
|
+ //--------------------------------------------------------------------------------------------------------
|
|
|
CompletableFuture.runAsync(()->{
|
|
|
//处理多责任人工单逻辑
|
|
|
//判断该设备是否多个责任人
|
|
|
@@ -343,6 +358,10 @@ public class IotInspectOrderServiceImpl implements IotInspectOrderService {
|
|
|
iotInspectOrderDO.setDeleted(false);
|
|
|
iotInspectOrderDO.setChargeName(Objects.nonNull(user)?user.getNickname():"");
|
|
|
iotInspectOrderDO.setDeptId(user.getDeptId());
|
|
|
+ Set<Long> collect = results.stream().map(IotInspectOrderDetailDO::getDeviceId).collect(Collectors.toSet());
|
|
|
+ iotInspectOrderDO.setTotalCount(collect.size());
|
|
|
+ iotInspectOrderDO.setNeedCount(collect.size());
|
|
|
+ iotInspectOrderDO.setExceptionCount(0);
|
|
|
TenantUtils.execute(1L, () -> iotInspectOrderMapper.insert(iotInspectOrderDO));
|
|
|
results.forEach(result-> result.setOrderId(iotInspectOrderDO.getId()));
|
|
|
TenantUtils.execute(1L, () -> {
|
|
|
@@ -355,7 +374,7 @@ public class IotInspectOrderServiceImpl implements IotInspectOrderService {
|
|
|
//发送消息
|
|
|
pmsMessage.sendMessage(iotInspectOrderDO.getId(), iotInspectOrderDO.getInspectOrderTitle(), PmsConstants.GENERATE_INSPECT, k, user.getMobile());
|
|
|
//写入子表
|
|
|
- Set<Long> collect = results.stream().map(IotInspectOrderDetailDO::getDeviceId).collect(Collectors.toSet());
|
|
|
+// Set<Long> collect = results.stream().map(IotInspectOrderDetailDO::getDeviceId).collect(Collectors.toSet());
|
|
|
List<IotInspectOrderDeviceDO> inspectDevices = new ArrayList<>();
|
|
|
collect.forEach(deviceId -> iotDeviceDOS.stream().filter(g -> deviceId.equals(g.getId())).findFirst().ifPresent(iotDeviceDO -> {
|
|
|
IotInspectOrderDeviceDO iotInspectOrderDeviceDO = new IotInspectOrderDeviceDO();
|