From 2bd766ee4d11fe754f443ef109a41052e234b771 Mon Sep 17 00:00:00 2001 From: yangwei <867012372@qq.com> Date: Fri, 23 May 2025 16:42:35 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E4=BF=AE=E6=94=B9=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=8E=A7=E5=88=B6=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/BusinessAlertServiceImpl.java | 10 ++-- .../impl/DeviceFlightRecordsServiceImpl.java | 50 +++++++++++++------ 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java index 9b0b85d..61c4db4 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java @@ -247,7 +247,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { QueryWrapper wrapper = buildQueryWrapper(bo); if (ObjectUtil.isEmpty(wrapper)){ - return new TableDataInfo<>(); + return TableDataInfo.build(); } Page page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper, ptPrefix); @@ -282,7 +282,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { QueryWrapper wrapper = buildQueryWrapper(bo); if (ObjectUtil.isEmpty(wrapper)){ - return new TableDataInfo<>(); + return TableDataInfo.build(); } wrapper.in("t.flowStatus", BusinessStatusEnum.CANCEL.getStatus()); @@ -319,7 +319,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { QueryWrapper wrapper = buildQueryWrapper(bo); if (ObjectUtil.isEmpty(wrapper)){ - return new TableDataInfo<>(); + return TableDataInfo.build(); } wrapper.eq("t.handle_type",BusinessStatusEnum.FINISH.getStatus()); @@ -356,7 +356,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { QueryWrapper wrapper = buildQueryWrapper(bo); if (ObjectUtil.isEmpty(wrapper)){ - return new TableDataInfo<>(); + return TableDataInfo.build(); } wrapper.eq("t.node_type", 1); @@ -401,7 +401,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { QueryWrapper wrapper = buildQueryWrapper(bo); if (ObjectUtil.isEmpty(wrapper)){ - return new TableDataInfo<>(); + return TableDataInfo.build(); } String tableWorkflow = ptPrefix.getTableWorkflow(); // eg: "dk_workflow" diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceFlightRecordsServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceFlightRecordsServiceImpl.java index d441791..61caff5 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceFlightRecordsServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceFlightRecordsServiceImpl.java @@ -9,9 +9,7 @@ import org.dromara.sample.manage.service.IDeviceFlightRecordsService; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service @@ -19,18 +17,30 @@ public class DeviceFlightRecordsServiceImpl extends ServiceImpl().eq(DeviceFlightRecordsEntity::getDeviceSn,deviceFlightRecords.getDeviceSn())); + DeviceFlightRecordsEntity deviceFlightRecordsEntities = this.baseMapper.selectOne(new LambdaQueryWrapper().eq(DeviceFlightRecordsEntity::getDeviceSn,currentFlightRecord.getDeviceSn())); + //不为空 if (ObjectUtil.isNotEmpty(deviceFlightRecordsEntities)) { - deviceFlightRecordsEntities.setFlyCount(deviceFlightRecordsEntities.getFlyCount() + deviceFlightRecords.getFlyCount()); - deviceFlightRecordsEntities.setFlyAccTime(deviceFlightRecordsEntities.getFlyAccTime() + deviceFlightRecords.getFlyAccTime()); + //飞行总架次大于等于表中数据替换 否则累加 + if (currentFlightRecord.getFlyCount() >= deviceFlightRecordsEntities.getFlyCount()){ + deviceFlightRecordsEntities.setFlyCount(currentFlightRecord.getFlyCount()); + }else { + deviceFlightRecordsEntities.setFlyCount(deviceFlightRecordsEntities.getFlyCount() + currentFlightRecord.getFlyCount()); + } + + //飞行总时长大于等于表中数据替换 否则累加 + if (currentFlightRecord.getFlyAccTime() >= deviceFlightRecordsEntities.getFlyAccTime()){ + deviceFlightRecordsEntities.setFlyAccTime(currentFlightRecord.getFlyAccTime()); + }else { + deviceFlightRecordsEntities.setFlyAccTime(deviceFlightRecordsEntities.getFlyAccTime() + currentFlightRecord.getFlyAccTime()); + } this.updateById(deviceFlightRecordsEntities); }else { - this.save(deviceFlightRecords); + this.save(currentFlightRecord); } } @@ -40,18 +50,28 @@ public class DeviceFlightRecordsServiceImpl extends ServiceImpl deviceFlightRecordsEntities = this.baseMapper.selectList(new LambdaQueryWrapper<>()); - int flyCount = deviceFlightRecordsEntities.stream() - .map(DeviceFlightRecordsEntity::getFlyCount) - .reduce(0, Integer::sum); + int flyCount = Optional.ofNullable(deviceFlightRecordsEntities) + .map(list -> list.stream() + .map(DeviceFlightRecordsEntity::getFlyCount) + .reduce(0, Integer::sum)) + .orElse(0); - int flyAccTime = deviceFlightRecordsEntities.stream() - .map(DeviceFlightRecordsEntity::getFlyAccTime) - .reduce(0, Integer::sum); +// int flyAccTime = deviceFlightRecordsEntities.stream() +// .map(DeviceFlightRecordsEntity::getFlyAccTime) +// .reduce(0, Integer::sum); + int flyAccTime = Optional.ofNullable(deviceFlightRecordsEntities) + .map(list -> list.stream() + .map(DeviceFlightRecordsEntity::getFlyAccTime) + .reduce(0, Integer::sum)) + .orElse(0); + + + int flyAccTimeHour = (int) Math.round(flyAccTime / 3600.0); resultMap.put("flyCount",flyCount); - resultMap.put("flyAccTime",flyAccTime); + resultMap.put("flyAccTime",flyAccTimeHour); return resultMap; }