change -修改物联网温湿度设备实时监控,五分钟范围

boardTest
启龙 曹 10 months ago
parent 18d458f4a9
commit dd6ba355f9

@ -6,9 +6,9 @@ spring:
# 主库数据源
master:
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
url: jdbc:sqlserver://175.27.215.92:1433;SelectMethod=cursor;DatabaseName=jdap_ems
url: jdbc:sqlserver://119.45.202.115:1433;SelectMethod=cursor;DatabaseName=jdap_ems
username: sa
password: Hawei@123
password: haiwei@123
# 从库数据源
slave:
driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver

@ -1,11 +1,15 @@
package com.os.ems.record.controller;
import java.util.List;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONArray;
import com.os.common.utils.StringUtils;
import com.os.ems.base.service.IEmsBaseEnergyTypeService;
import com.os.ems.base.service.IEmsBaseMonitorInfoService;
import com.os.ems.record.domain.EmsIOTData;
import com.os.ems.record.domain.EmsIOTInstantMonitorData;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -42,6 +46,8 @@ public class TWTempertureDataController extends BaseController
@Autowired
private IEmsBaseEnergyTypeService emsBaseEnergyTypeService;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
*
*/
@ -81,6 +87,44 @@ public class TWTempertureDataController extends BaseController
return success(emsIOTData);
}
/**
*
* @param monitorCodeList
* @return
*/
@GetMapping("/iotInstantMonitoring")
public AjaxResult iotInstantMonitoring(String monitorCodeList){
List<TWTempertureData> list = new ArrayList<TWTempertureData>();
if(StringUtils.isNotEmpty(monitorCodeList)){
String[] split = monitorCodeList.split(",");
for (String monitorId : split) {
TWTempertureData tWTempertureData = new TWTempertureData();
tWTempertureData.setMonitorId(monitorId);
Map<String,Object> params = new HashMap<>();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE,-5);
Calendar startTime = (Calendar) calendar.clone();
params.put("beginRecordTime",sdf.format(startTime.getTime()));
params.put("endRecordTime",sdf.format(new Date()));
tWTempertureData.setParams(params);
List<TWTempertureData> twTempertureData = tWTempertureDataService.selectIotInstantList(tWTempertureData);
if(twTempertureData.size()>0){
Optional<TWTempertureData> first = twTempertureData.stream().sorted(Comparator.comparing(TWTempertureData::getRecodeTime)).findFirst();
list.add(first.get());
}
}
}
System.out.println(JSONArray.toJSONString(list));
return success(list);
}
/**
*
*/

@ -0,0 +1,28 @@
package com.os.ems.record.domain;
import java.util.List;
public class EmsIOTInstantMonitorData {
private String monitorId;
private TWTempertureData data;
public EmsIOTInstantMonitorData() {
}
public String getMonitorId() {
return monitorId;
}
public void setMonitorId(String monitorId) {
this.monitorId = monitorId;
}
public TWTempertureData getData() {
return data;
}
public void setData(TWTempertureData data) {
this.data = data;
}
}

@ -65,4 +65,11 @@ public interface TWTempertureDataMapper
* @return
*/
List<TWTempertureData> selectIotInstantList(TWTempertureData tWTempertureData);
/**
*
* @param monitorId
* @return
*/
TWTempertureData selectIotInstantMinitoringData(String monitorId);
}

@ -65,4 +65,11 @@ public interface ITWTempertureDataService
* @return
*/
List<TWTempertureData> selectIotInstantList(TWTempertureData tWTempertureData);
/**
*
* @param monitorId
* @return
*/
TWTempertureData selectIotInstantMinitoringData(String monitorId);
}

@ -100,4 +100,14 @@ public class TWTempertureDataServiceImpl implements ITWTempertureDataService
public List<TWTempertureData> selectIotInstantList(TWTempertureData tWTempertureData) {
return tWTempertureDataMapper.selectIotInstantList(tWTempertureData);
}
/**
*
* @param monitorId
* @return
*/
@Override
public TWTempertureData selectIotInstantMinitoringData(String monitorId) {
return tWTempertureDataMapper.selectIotInstantMinitoringData(monitorId);
}
}

@ -79,6 +79,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by twtd.collectTime
</select>
<select id="selectIotInstantMinitoringData" parameterType="TWTempertureData" resultMap="TWTempertureDataResult">
<include refid="selectTWTempertureDataVo"></include>
<where>
<if test="monitorId != null and monitorId != ''"> and twtd.monitorId = #{monitorId}</if>
</where>
order by twtd.recordTime desc
</select>
<insert id="insertTWTempertureData" parameterType="TWTempertureData" useGeneratedKeys="true" keyProperty="objid">
insert into T_W_TempertureData
<trim prefix="(" suffix=")" suffixOverrides=",">

Loading…
Cancel
Save