2023-05-11 10:28:06 完成能源监测总电表、电磁锅炉、蓄热锅炉、空气源热泵、发热电缆、沙盘、温度传感器的查询接口!

master
魔神煜修罗皇 2 years ago
parent 0d88bd0448
commit 3131b7135d
  1. 3
      psdc-business/src/main/java/com/psdc/mapper/PsdcThermometerRtdataMapper.java
  2. 7
      psdc-business/src/main/java/com/psdc/service/IPsdcThermometerHtdataService.java
  3. 56
      psdc-business/src/main/java/com/psdc/service/impl/PsdcThermometerHtdataServiceImpl.java
  4. 9
      psdc-business/src/main/resources/mapper/business/PsdcThermometerRtdataMapper.xml
  5. 35
      psdc-web/src/main/java/com/psdc/controller/monitor/WenDuController.java

@ -23,7 +23,8 @@ public interface PsdcThermometerRtdataMapper{
* @param thermometerRtdataId 主键
* @return 实例对象
*/
PsdcThermometerDataRes queryById(@Param("thermometerRtdataId") Integer thermometerRtdataId);
PsdcThermometerDataRes queryById(@Param("thermometerRtdataId") Integer thermometerRtdataId,
@Param("today") String today);
List<PsdcThermometerDataRes> selWenDu(@Param("devType") Integer devType);

@ -1,9 +1,12 @@
package com.psdc.service;
import com.psdc.core.domain.AjaxResult;
import com.psdc.entity.PsdcDevicePowerHdata96;
import com.psdc.entity.PsdcThermometerHtdata;
import com.psdc.entity.res.PsdcDevicePowerRes;
import java.util.List;
import java.util.Map;
/**
* @Author戴仕崑
@ -21,6 +24,8 @@ public interface IPsdcThermometerHtdataService {
PsdcDevicePowerRes selTotalElectricityInfo(Integer deviceId);
Map selTodayThermometerById(Integer deviceId);
AjaxResult selDzglWenDu(Integer deviceId);
}

@ -48,13 +48,13 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
Date date = new Date();
List<PsdcThermometerDataRes> ary = new ArrayList();
for (Integer d : devList) {
// 查询今日实时温度数据
PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(d);
String tb = sdf.format(date) + " 00:00:00"; // 今天开始检索时间
String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间
for (Integer d : devList) {
// 查询今日实时温度数据
PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(d, sdf.format(date));
List<Double> listIn = new ArrayList(); // 今天历史进水温度集合
List<Double> listOut = new ArrayList(); // 今天历史出水温度集合
List<Double> listTemp = new ArrayList(); // 今天历史温度集合
@ -63,7 +63,9 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
// 循环遍历今天历史数据对象集合
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(d, tb, te);
for (PsdcThermometerHtdata h : htdata){
if (null != h.getThermometerValue()){
listTemp.add(h.getThermometerValue());
}
if (null != h.getThermometerValueIn()){
listIn.add(h.getThermometerValueIn());
}
@ -108,6 +110,52 @@ public class PsdcThermometerHtdataServiceImpl implements IPsdcThermometerHtdataS
}
}
@Override
public Map<String, Object> selTodayThermometerById(Integer deviceId) {
Date date = new Date();
String tb = sdf.format(date) + " 00:00:00"; // 今天开始检索时间
String te = sdf.format(date) + " 23:59:59"; // 今天结束检索时间
Map<String, Object> map = new HashMap();
// 查询该设备实时温度数据
PsdcThermometerDataRes dataRes = psdcThermometerRtdataMapper.queryById(deviceId, sdf.format(date));
List<PsdcThermometerHtdata> htdata = psdcThermometerHtdataMapper.selTodayThermometer(deviceId, tb, te);
if (null == dataRes || null == htdata){
return null;
}
List<Double> listIn = new ArrayList(); // 今天历史进水温度集合
List<Double> listOut = new ArrayList(); // 今天历史出水温度集合
List<Double> listTemp = new ArrayList(); // 今天历史温度集合
List<String> times = new ArrayList(); // 时间轴
// 循环遍历今天历史数据对象集合
for (PsdcThermometerHtdata h : htdata){
if (null != h.getThermometerValue()){
listTemp.add(h.getThermometerValue());
}
if (null != h.getThermometerValueIn()){
listIn.add(h.getThermometerValueIn());
}
if (null != h.getThermometerValueOut()){
listOut.add(h.getThermometerValueOut());
}
String t = h.getUpdateTime().split(" ")[1].substring(0,5);
times.add(t);
}
map.put("deviceId", dataRes.getDeviceId());
map.put("deviceName", dataRes.getDeviceName());
map.put("deviceTemp", dataRes.getThermometerValue());
map.put("tempIn", listIn);
map.put("tempOut", listOut);
map.put("temps", listTemp);
map.put("times", times);
return map;
}
/**
* 查询电磁锅炉进水出水温度
* @return

@ -24,7 +24,14 @@
Select pd.device_id, pd.device_name, pd.device_runstatus, ptr.thermometer_value, ptr.thermometer_value_in, ptr.thermometer_value_out
From psdc_device pd
Left Join psdc_thermometer_rtdata ptr On ptr.device_id = pd.device_id
Where ptr.device_id = #{thermometerRtdataId}
<where>
<if test="thermometerRtdataId != null and thermometerRtdataId != ''">
ptr.device_id = #{thermometerRtdataId}
</if>
<if test="today != null and today != ''">
And DATE_FORMAT(ptr.update_time,'%Y-%m-%d') = #{today}
</if>
</where>
</select>
<select id="selWenDu" resultMap="PsdcThermometerRtdataMap2">

@ -0,0 +1,35 @@
package com.psdc.controller.monitor;
import com.psdc.core.domain.AjaxResult;
import com.psdc.service.IPsdcThermometerHtdataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author戴仕崑
* @Projectpsdc
* @FilenameWenDuController
* @Date2023/5/11 14:21
* @Version 1.0
*/
@RestController
@RequestMapping("/api/monitor/wdcgq/index")
public class WenDuController {
@Autowired
IPsdcThermometerHtdataService psdcThermometerHtdataService;
@PreAuthorize("@ss.hasPermi('emonitor:wdcgq')")
@RequestMapping(value = "/sel1/{deviceId}", method = RequestMethod.GET)
public AjaxResult seldrgl1(@PathVariable(value = "deviceId", required = false) Integer deviceId){
if (null == psdcThermometerHtdataService.selTodayThermometerById(deviceId)){
return AjaxResult.success("今日该设备暂无温度数据!");
}
return AjaxResult.success(psdcThermometerHtdataService.selTodayThermometerById(deviceId));
}
}
Loading…
Cancel
Save