/gis/device/getDeviceLogCurves电量和水量折线图数据

This commit is contained in:
wyw 2024-08-13 19:37:22 +08:00
parent c4a03a4d44
commit 71069adb85
3 changed files with 26 additions and 14 deletions

View File

@ -18,6 +18,8 @@ import com.fastbee.iot.domain.ThingsModel;
import com.fastbee.iot.mapper.DeviceMapper;
import com.fastbee.iot.mapper.ProductMapper;
import com.fastbee.iot.service.*;
import com.fastbee.waterele.domain.MaWatereleRecord;
import com.fastbee.waterele.service.IMaWatereleRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
@ -47,6 +49,9 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
@Autowired
private IThingsModelService thingsModelService;
@Autowired
private IMaWatereleRecordService watereleRecordService;
public GisDeviceServiceImpl(@Qualifier("deviceMapper") DeviceMapper deviceMapper, @Qualifier("productMapper") ProductMapper productMapper) {
this.deviceMapper = deviceMapper;
this.productMapper = productMapper;
@ -220,21 +225,26 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
if (device == null) {
throw new RuntimeException("未查到该设备");
}
// List<AlertEntity> alertList = getAlertListForDevice(deviceId, device.getProductId());
// List<DeviceAlertDto> waterLevelAlert = new ArrayList<>();
// List<DeviceAlertDto> rainfallAlert = new ArrayList<>();
//
// if (!alertList.isEmpty()) {
// alertList.forEach(alert -> parseAlert(alert, waterLevelAlert, rainfallAlert));
// }
Map<String, Object> sumFlow = getDataList(device, "dataSumFlow");
Map<String, Object> insFlow = getDataList(device, "dataInsFlow");
//获取累计水量和累计电量的前20条数据记录
MaWatereleRecord watereleRecord = new MaWatereleRecord();
watereleRecord.setDevSn(device.getSerialNumber());
List<MaWatereleRecord> maWatereleRecords = watereleRecordService.selectMaWatereleRecordList(watereleRecord);
if(maWatereleRecords.size() > 20){
maWatereleRecords = maWatereleRecords.subList(0, 20);
}
maWatereleRecords.sort(Comparator.comparing(MaWatereleRecord::getCreateTime));
ArrayList<Object> sumFlow = new ArrayList<>();
ArrayList<Object> sumEle = new ArrayList<>();
ArrayList<Object> time = new ArrayList<>();
for (MaWatereleRecord record : maWatereleRecords) {
time.add(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,record.getCreateTime()));
sumFlow.add(record.getSumflow());
sumEle.add(record.getSumele());
}
Map<String, Object> rMap = new HashMap<>();
rMap.put("time", insFlow.get("time"));
rMap.put("sumFlow", sumFlow.get("data"));
rMap.put("insFlow", insFlow.get("data"));
// rMap.put("sumFlowAlert", waterLevelAlert);
// rMap.put("insFlowAlert", rainfallAlert);
rMap.put("time", time);
rMap.put("sumFlow", sumFlow);
rMap.put("sumEle", sumEle);
return rMap;
}

View File

@ -70,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
and p.tenant_id = #{tenantId}
</if>
<if test="productId != null and productId != ''"> and p.product_id = #{productId}</if>
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="status != null "> and p.status = #{status}</if>

View File

@ -52,6 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="areacode != null and areacode != ''"> and areaCode = #{areacode}</if>
<if test="action != null and action != ''"> and action = #{action}</if>
</where>
order by create_time desc
</select>
<select id="selectMaWatereleRecordById" parameterType="Long" resultMap="MaWatereleRecordResult">