Browse Source

[feat]修改预警查询控制返回

pull/7/head
杨威 4 weeks ago
parent
commit
2bd766ee4d
  1. 10
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  2. 46
      dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceFlightRecordsServiceImpl.java

10
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

@ -247,7 +247,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
QueryWrapper<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
return TableDataInfo.build();
}
Page<BusinessAlert> page = this.baseMapper.pageBusinessAlert(pageQuery.build(), wrapper, ptPrefix);
@ -282,7 +282,7 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
QueryWrapper<BusinessAlert> 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<BusinessAlert> 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<BusinessAlert> 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<BusinessAlert> wrapper = buildQueryWrapper(bo);
if (ObjectUtil.isEmpty(wrapper)){
return new TableDataInfo<>();
return TableDataInfo.build();
}
String tableWorkflow = ptPrefix.getTableWorkflow(); // eg: "dk_workflow"

46
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<DeviceFlightReco
@Override
public void saveDeviceFlight(DeviceFlightRecordsEntity deviceFlightRecords) {
public void saveDeviceFlight(DeviceFlightRecordsEntity currentFlightRecord) {
//查询之前的数据
DeviceFlightRecordsEntity deviceFlightRecordsEntities = this.baseMapper.selectOne(new LambdaQueryWrapper<DeviceFlightRecordsEntity>().eq(DeviceFlightRecordsEntity::getDeviceSn,deviceFlightRecords.getDeviceSn()));
DeviceFlightRecordsEntity deviceFlightRecordsEntities = this.baseMapper.selectOne(new LambdaQueryWrapper<DeviceFlightRecordsEntity>().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<DeviceFlightReco
List<DeviceFlightRecordsEntity> deviceFlightRecordsEntities = this.baseMapper.selectList(new LambdaQueryWrapper<>());
int flyCount = deviceFlightRecordsEntities.stream()
int flyCount = Optional.ofNullable(deviceFlightRecordsEntities)
.map(list -> list.stream()
.map(DeviceFlightRecordsEntity::getFlyCount)
.reduce(0, Integer::sum);
.reduce(0, Integer::sum))
.orElse(0);
// int flyAccTime = deviceFlightRecordsEntities.stream()
// .map(DeviceFlightRecordsEntity::getFlyAccTime)
// .reduce(0, Integer::sum);
int flyAccTime = deviceFlightRecordsEntities.stream()
int flyAccTime = Optional.ofNullable(deviceFlightRecordsEntities)
.map(list -> list.stream()
.map(DeviceFlightRecordsEntity::getFlyAccTime)
.reduce(0, Integer::sum);
.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;
}

Loading…
Cancel
Save