Merge remote-tracking branch 'origin/IOT' into IOT

IOT
夜笙歌 1 month ago
commit ebb18eda2c

@ -81,6 +81,22 @@ public class TWTempertureData extends BaseEntity
@Excel(name = "能源类型")
private Long monitorType;
/** pm1.0 */
@Excel(name = "pm1.0")
private BigDecimal pm1;
/** pm2.5 */
@Excel(name = "pm2.5")
private BigDecimal pm2;
/** pm10.0 */
@Excel(name = "pm10.0")
private BigDecimal pm10;
/** 粉尘 */
@Excel(name = "粉尘")
private BigDecimal standby;
public void setObjid(Long objid)
{
this.objid = objid;
@ -216,6 +232,44 @@ public class TWTempertureData extends BaseEntity
this.monitorType = monitorType;
}
public void setPm1(BigDecimal pm1)
{
this.pm1 = pm1;
}
public BigDecimal getPm1()
{
return pm1;
}
public void setPm2(BigDecimal pm2)
{
this.pm2 = pm2;
}
public BigDecimal getPm2()
{
return pm2;
}
public void setPm10(BigDecimal pm10)
{
this.pm10 = pm10;
}
public BigDecimal getPm10()
{
return pm10;
}
public void setStandby(BigDecimal standby)
{
this.standby = standby;
}
public BigDecimal getStandby()
{
return standby;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -233,6 +287,10 @@ public class TWTempertureData extends BaseEntity
.append("confirmTime", getConfirmTime())
.append("confirmFlag", getConfirmFlag())
.append("monitorType", getMonitorType())
.append("pm1", getPm1())
.append("pm2", getPm2())
.append("pm10", getPm10())
.append("standby", getStandby())
.toString();
}
}

@ -20,6 +20,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="confirmFlag" column="confirmFlag" />
<result property="monitorName" column="monitor_name" />
<result property="monitorType" column="monitor_type" />
<result property="pm1" column="pm1"/>
<result property="pm2" column="pm2"/>
<result property="pm10" column="pm10"/>
<result property="standby" column="standby"/>
</resultMap>
<sql id="selectTWTempertureDataVo">
@ -38,8 +44,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
twtd.confirmFlag,
ebmi.monitor_name,
ebmi.monitor_type
ebmi.monitor_type,
twtd.pm1,
twtd.pm2,
twtd.pm10,
twtd.standby
from T_W_TempertureData twtd
left join ems_base_monitor_info ebmi on twtd.monitorId = ebmi.monitor_code
</sql>
@ -64,22 +74,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
<if test="confirmFlag != null "> and twtd.confirmFlag = #{confirmFlag}</if>
<if test="monitorType != null "> and ebmi.monitor_type = #{monitorType}</if>
<if test="pm1 != null "> and twtd.pm1 = #{pm1}</if>
<if test="pm2 != null "> and twtd.pm2 = #{pm2}</if>
<if test="pm10 != null "> and twtd.pm10 = #{pm10}</if>
<if test="standby != null "> and twtd.standby = #{standby}</if>
</where>
order by twtd.recodeTime desc
</select>
<select id="selectTWTempertureDataByObjid" parameterType="Long" resultMap="TWTempertureDataResult">
<include refid="selectTWTempertureDataVo"/>
where objid = #{objid}
where twtd.objid = #{objid}
</select>
<select id="selectIotInstantList" parameterType="TWTempertureData" resultMap="TWTempertureDataResult">
<include refid="selectTWTempertureDataVo"></include>
<where>
<if test="monitorId != null and monitorId != ''">and twtd.monitorId = #{monitorId}</if>
<if test="params.beginCollectTime != null and params.beginCollectTime != '' and params.endCollectTime != null and params.endCollectTime != ''">
and collectTime between #{params.beginCollectTime} and #{params.endCollectTime}</if>
and twtd.collectTime between #{params.beginCollectTime} and #{params.endCollectTime}</if>
<if test="params.beginRecordTime != null and params.beginRecordTime != '' and params.endRecordTime != null and params.endRecordTime != ''">
and recodeTime between #{params.beginRecordTime} and #{params.endRecordTime}</if>
and twtd.recodeTime between #{params.beginRecordTime} and #{params.endRecordTime}</if>
</where>
order by twtd.collectTime
</select>
@ -107,6 +121,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="confirmPersonID != null">confirmPersonID,</if>
<if test="confirmTime != null">confirmTime,</if>
<if test="confirmFlag != null">confirmFlag,</if>
<if test="pm1 != null">pm1,</if>
<if test="pm2 != null">pm2,</if>
<if test="pm10 != null">pm10,</if>
<if test="standby != null">standby,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="monitorId != null">#{monitorId},</if>
@ -121,6 +139,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="confirmPersonID != null">#{confirmPersonID},</if>
<if test="confirmTime != null">#{confirmTime},</if>
<if test="confirmFlag != null">#{confirmFlag},</if>
<if test="pm1 != null">#{pm1},</if>
<if test="pm2 != null">#{pm2},</if>
<if test="pm10 != null">#{pm10},</if>
<if test="standby != null">#{standby},</if>
</trim>
</insert>
@ -139,6 +162,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="confirmPersonID != null">confirmPersonID = #{confirmPersonID},</if>
<if test="confirmTime != null">confirmTime = #{confirmTime},</if>
<if test="confirmFlag != null">confirmFlag = #{confirmFlag},</if>
<if test="pm1 != null">pm1 = #{pm1},</if>
<if test="pm2 != null">pm2 = #{pm2},</if>
<if test="pm10 != null">pm10 = #{pm10},</if>
<if test="standby != null">standby = #{standby},</if>
</trim>
where objid = #{objid}
</update>

@ -59,6 +59,13 @@
<artifactId>ruoyi-system</artifactId>
</dependency>
<!-- SpringBoot Websocket -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies>
</project>
</project>

@ -0,0 +1,58 @@
package com.ruoyi.framework.websocket;
import java.util.concurrent.Semaphore;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*
* @author ruoyi
*/
public class SemaphoreUtils
{
/**
* SemaphoreUtils
*/
private static final Logger LOGGER = LoggerFactory.getLogger(SemaphoreUtils.class);
/**
*
*
* @param semaphore
* @return
*/
public static boolean tryAcquire(Semaphore semaphore)
{
boolean flag = false;
try
{
flag = semaphore.tryAcquire();
}
catch (Exception e)
{
LOGGER.error("获取信号量异常", e);
}
return flag;
}
/**
*
*
* @param semaphore
*/
public static void release(Semaphore semaphore)
{
try
{
semaphore.release();
}
catch (Exception e)
{
LOGGER.error("释放信号量异常", e);
}
}
}

@ -0,0 +1,20 @@
package com.ruoyi.framework.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* websocket
*
* @author ruoyi
*/
@Configuration
public class WebSocketConfig
{
@Bean
public ServerEndpointExporter serverEndpointExporter()
{
return new ServerEndpointExporter();
}
}

@ -0,0 +1,106 @@
package com.ruoyi.framework.websocket;
import java.util.concurrent.Semaphore;
import javax.websocket.OnClose;
import javax.websocket.OnError;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* websocket
*
* @author ruoyi
*/
@Component
@ServerEndpoint("/websocket/message")
public class WebSocketServer
{
/**
* WebSocketServer
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketServer.class);
/**
* 线100
*/
public static int socketMaxOnlineCount = 100;
private static Semaphore socketSemaphore = new Semaphore(socketMaxOnlineCount);
/**
*
*/
@OnOpen
public void onOpen(Session session) throws Exception
{
boolean semaphoreFlag = false;
// 尝试获取信号量
semaphoreFlag = SemaphoreUtils.tryAcquire(socketSemaphore);
if (!semaphoreFlag)
{
// 未获取到信号量
LOGGER.error("\n 当前在线人数超过限制数- {}", socketMaxOnlineCount);
WebSocketUsers.sendMessageToUserByText(session, "当前在线人数超过限制数:" + socketMaxOnlineCount);
session.close();
}
else
{
// 添加用户
WebSocketUsers.put(session.getId(), session);
LOGGER.info("\n 建立连接 - {}", session);
LOGGER.info("\n 当前人数 - {}", WebSocketUsers.getUsers().size());
WebSocketUsers.sendMessageToUserByText(session, "连接成功");
}
}
/**
*
*/
@OnClose
public void onClose(Session session)
{
LOGGER.info("\n 关闭连接 - {}", session);
// 移除用户
boolean removeFlag = WebSocketUsers.remove(session.getId());
if (!removeFlag)
{
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
}
/**
*
*/
@OnError
public void onError(Session session, Throwable exception) throws Exception
{
if (session.isOpen())
{
// 关闭连接
session.close();
}
String sessionId = session.getId();
LOGGER.info("\n 连接异常 - {}", sessionId);
LOGGER.info("\n 异常信息 - {}", exception);
// 移出用户
WebSocketUsers.remove(sessionId);
// 获取到信号量则需释放
SemaphoreUtils.release(socketSemaphore);
}
/**
*
*/
@OnMessage
public void onMessage(String message, Session session)
{
String msg = message.replace("你", "我").replace("吗", "");
WebSocketUsers.sendMessageToUserByText(session, msg);
}
}

@ -0,0 +1,140 @@
package com.ruoyi.framework.websocket;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.websocket.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* websocket
*
* @author ruoyi
*/
public class WebSocketUsers
{
/**
* WebSocketUsers
*/
private static final Logger LOGGER = LoggerFactory.getLogger(WebSocketUsers.class);
/**
*
*/
private static Map<String, Session> USERS = new ConcurrentHashMap<String, Session>();
/**
*
*
* @param key
* @param session
*/
public static void put(String key, Session session)
{
USERS.put(key, session);
}
/**
*
*
* @param session
*
* @return
*/
public static boolean remove(Session session)
{
String key = null;
boolean flag = USERS.containsValue(session);
if (flag)
{
Set<Map.Entry<String, Session>> entries = USERS.entrySet();
for (Map.Entry<String, Session> entry : entries)
{
Session value = entry.getValue();
if (value.equals(session))
{
key = entry.getKey();
break;
}
}
}
else
{
return true;
}
return remove(key);
}
/**
*
*
* @param key
*/
public static boolean remove(String key)
{
LOGGER.info("\n 正在移出用户 - {}", key);
Session remove = USERS.remove(key);
if (remove != null)
{
boolean containsValue = USERS.containsValue(remove);
LOGGER.info("\n 移出结果 - {}", containsValue ? "失败" : "成功");
return containsValue;
}
else
{
return true;
}
}
/**
* 线
*
* @return
*/
public static Map<String, Session> getUsers()
{
return USERS;
}
/**
*
*
* @param message
*/
public static void sendMessageToUsersByText(String message)
{
Collection<Session> values = USERS.values();
for (Session value : values)
{
sendMessageToUserByText(value, message);
}
}
/**
*
*
* @param userName
* @param message
*/
public static void sendMessageToUserByText(Session session, String message)
{
if (session != null)
{
try
{
session.getBasicRemote().sendText(message);
}
catch (IOException e)
{
LOGGER.error("\n[发送消息异常]", e);
}
}
else
{
LOGGER.info("\n[你已离线]");
}
}
}

@ -135,8 +135,11 @@ export default {
zxyg: null,
activePower: null,
reactivePower: null,
collectType: null,
monitorType: 3
collectType: 3,
monitorType: 3,
energyTypeId: 3,
energyType: 3,
monitorTypeId: 3
},
//
form: {},
@ -146,9 +149,7 @@ export default {
},
//
rules: {
objId: [
{ required: true, message: '编号不能为空', trigger: 'blur' }
]
},
columns: [
{ key: 0, label: `主键标识`, visible: false },
@ -245,7 +246,9 @@ export default {
/** 查询计量设备信息下拉树结构 */
getTreeselect() {
getMonitorInfoTree({ monitorTypeList: [3]}).then(response => {
debugger
console.log(123213)
getMonitorInfoTree({monitorTypeList: [3]}).then(response => {
this.monitorInfoOptions = response.data
})
},

@ -145,9 +145,9 @@ export default {
},
//
rules: {
objId: [
/* objId: [
{required: true, message: '编号不能为空', trigger: 'blur'}
]
]*/
},
columns: [
{key: 0, label: `主键标识`, visible: false},
@ -245,7 +245,7 @@ export default {
/** 查询计量设备信息下拉树结构 */
getTreeselect() {
getMonitorInfoTree({
monitorTypeList: [5, 6, 7, 8, 9],
monitorTypeList: [3],
monitorType: this.$route.query.monitorType
}).then(response => {
this.monitorInfoOptions = response.data

Loading…
Cancel
Save