/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.DeviceMapper;
import com.fastbee.iot.mapper.ProductMapper; import com.fastbee.iot.mapper.ProductMapper;
import com.fastbee.iot.service.*; 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.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -47,6 +49,9 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
@Autowired @Autowired
private IThingsModelService thingsModelService; private IThingsModelService thingsModelService;
@Autowired
private IMaWatereleRecordService watereleRecordService;
public GisDeviceServiceImpl(@Qualifier("deviceMapper") DeviceMapper deviceMapper, @Qualifier("productMapper") ProductMapper productMapper) { public GisDeviceServiceImpl(@Qualifier("deviceMapper") DeviceMapper deviceMapper, @Qualifier("productMapper") ProductMapper productMapper) {
this.deviceMapper = deviceMapper; this.deviceMapper = deviceMapper;
this.productMapper = productMapper; this.productMapper = productMapper;
@ -220,21 +225,26 @@ public class GisDeviceServiceImpl implements IGisDeviceService {
if (device == null) { if (device == null) {
throw new RuntimeException("未查到该设备"); throw new RuntimeException("未查到该设备");
} }
// List<AlertEntity> alertList = getAlertListForDevice(deviceId, device.getProductId()); //获取累计水量和累计电量的前20条数据记录
// List<DeviceAlertDto> waterLevelAlert = new ArrayList<>(); MaWatereleRecord watereleRecord = new MaWatereleRecord();
// List<DeviceAlertDto> rainfallAlert = new ArrayList<>(); watereleRecord.setDevSn(device.getSerialNumber());
// List<MaWatereleRecord> maWatereleRecords = watereleRecordService.selectMaWatereleRecordList(watereleRecord);
// if (!alertList.isEmpty()) { if(maWatereleRecords.size() > 20){
// alertList.forEach(alert -> parseAlert(alert, waterLevelAlert, rainfallAlert)); maWatereleRecords = maWatereleRecords.subList(0, 20);
// } }
Map<String, Object> sumFlow = getDataList(device, "dataSumFlow"); maWatereleRecords.sort(Comparator.comparing(MaWatereleRecord::getCreateTime));
Map<String, Object> insFlow = getDataList(device, "dataInsFlow"); 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<>(); Map<String, Object> rMap = new HashMap<>();
rMap.put("time", insFlow.get("time")); rMap.put("time", time);
rMap.put("sumFlow", sumFlow.get("data")); rMap.put("sumFlow", sumFlow);
rMap.put("insFlow", insFlow.get("data")); rMap.put("sumEle", sumEle);
// rMap.put("sumFlowAlert", waterLevelAlert);
// rMap.put("insFlowAlert", rainfallAlert);
return rMap; 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"> <if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
and p.tenant_id = #{tenantId} and p.tenant_id = #{tenantId}
</if> </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="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="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="status != null "> and p.status = #{status}</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="areacode != null and areacode != ''"> and areaCode = #{areacode}</if>
<if test="action != null and action != ''"> and action = #{action}</if> <if test="action != null and action != ''"> and action = #{action}</if>
</where> </where>
order by create_time desc
</select> </select>
<select id="selectMaWatereleRecordById" parameterType="Long" resultMap="MaWatereleRecordResult"> <select id="selectMaWatereleRecordById" parameterType="Long" resultMap="MaWatereleRecordResult">