添加WebSocket支持

警告日志
在线设备管理
This commit is contained in:
wanggeng888 2021-03-25 13:42:21 +08:00
parent d18b0af9b0
commit 6483193f26
23 changed files with 815 additions and 1510 deletions

30
pom.xml
View File

@ -45,6 +45,7 @@
<artifactId>spring-boot-starter-freemarker</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@ -74,40 +75,17 @@
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>4.1.5</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.50.Final</version>
</dependency>
<!--
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.12.7</version>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>5.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>3.12.7</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
-->
<dependency>
<groupId>com.cm</groupId>

View File

@ -1,5 +1,7 @@
package com.cm.tenlion.pollutantdata;
import com.cm.tenlion.pollutantdata.manager.CollectorManager;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.cm.tenlion.pollutantdata.service.collector.ICollectorService;
import com.cm.tenlion.pollutantdata.service.dataminute.IDataMinuteService;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
@ -8,11 +10,11 @@ import com.cm.tenlion.pollutantdata.utils.net.TCPServer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@ -28,17 +30,18 @@ public class PollutantDataApplication {
private IDataMinuteService dataMinuteService;
@Autowired
private IPollService pollService;
@Autowired
private IAlarmLogService alarmLogService;
public static void main(String[] args) {
SpringApplication app = new SpringApplication(new Class[]{PollutantDataApplication.class});
app.setBannerMode(Banner.Mode.OFF);
app.run(args);
}
// @Scheduled(cron = "0 0/15 0-23 * * ?")
// public void hello() {
// this.pointInfoService.offLine(new Date());
// }
@Scheduled(cron = "0 0/1 * * * ?")
public void clearOfflineCollector() {
CollectorManager.getInstance().clearTimeoutCollectors();
}
@Bean
public ApplicationRunner applicationRunner() {
@ -50,12 +53,12 @@ public class PollutantDataApplication {
tcpServer.setCollectorService(collectorService);
tcpServer.setDataMinuteService(dataMinuteService);
tcpServer.setPollService(pollService);
tcpServer.setAlarmLogService(alarmLogService);
tcpServer.run();
} catch (Exception e) {
e.printStackTrace();
}
}).start();
// new Thread(new Server()).start();
};
}

View File

@ -41,7 +41,7 @@ public class AuthClientSecurityConfig extends WebSecurityConfigurerAdapter {
.and()
.logout().logoutSuccessUrl(authServer.getOauthLogout())
.and()
.authorizeRequests().antMatchers("/app/**","/resource/**", "/route/file/**", "/assets/**").permitAll()
.authorizeRequests().antMatchers("/app/**","/resource/**", "/route/file/**", "/assets/**", "/ws").permitAll()
.and()
.authorizeRequests()
.anyRequest()

View File

@ -0,0 +1,54 @@
package com.cm.tenlion.pollutantdata.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import java.util.concurrent.ThreadPoolExecutor;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: ScheduledConfig
* @Description:
* @Author: WangGeng
* @Date: 2020/9/26 12:01
* @Version: 1.0
**/
@Configuration
public class ScheduledConfig {
private static final int CORE_POOL_SIZE = 100;
private static final int MAX_POOL_SIZE = 500;
private static final int KEEP_ALIVE_TIME = 10;
private static final int QUEUE_CAPACITY = 500;
private static final String THREAD_NAME_PREFIX = "Async-Service-";
@Bean("taskExecutor")
public ThreadPoolTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(CORE_POOL_SIZE);
executor.setMaxPoolSize(MAX_POOL_SIZE);
executor.setQueueCapacity(QUEUE_CAPACITY);
executor.setKeepAliveSeconds(KEEP_ALIVE_TIME);
executor.setThreadNamePrefix(THREAD_NAME_PREFIX);
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
executor.initialize();
return executor;
}
/**
* @author:XingWL
* @description:任务调度器解决和WebSocket冲突
* @date: 2020/8/3 16:27
*/
@Bean
public TaskScheduler taskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(50);
scheduler.initialize();
return scheduler;
}
}

View File

@ -0,0 +1,27 @@
package com.cm.tenlion.pollutantdata.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: WebSocketConfig
* @Description: WebSocket配置
* @Author: WangGeng
* @Date: 2020/9/26 11:36
* @Version: 1.0
**/
@Configuration
@EnableWebSocket
public class WebSocketConfig {
@Bean
public ServerEndpointExporter webSocketEndpoint() {
return new ServerEndpointExporter();
}
}

View File

@ -0,0 +1,41 @@
package com.cm.tenlion.pollutantdata.dao.alarmlog;
import com.cm.common.exception.SaveException;
import com.cm.common.exception.SearchException;
import com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog.AlarmLogDTO;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IAlarmLogDao
* @Description: 警告日志
* @Author: wanggeng
* @Date: 2021/3/25 10:45 上午
* @Version: 1.0
*/
@Repository
public interface IAlarmLogDao {
/**
* 新增
*
* @param params
* @throws SaveException
*/
void save(Map<String, Object> params) throws SaveException;
/**
* 日志列表
*
* @param params
* @return
* @throws SearchException
*/
List<AlarmLogDTO> list(Map<String, Object> params) throws SearchException;
}

View File

@ -0,0 +1,145 @@
package com.cm.tenlion.pollutantdata.manager;
import com.cm.tenlion.pollutantdata.pojo.OnlineCollector;
import com.cm.tenlion.pollutantdata.pojo.dtos.collector.CollectorDTO;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: CollectorManager
* @Description: 采集器管理器
* @Author: wanggeng
* @Date: 2021/3/25 12:25 下午
* @Version: 1.0
*/
@Slf4j
public class CollectorManager {
private static final CollectorManager collectorManager = CollectorManagerBuilder.collectorManager;
private Map<String, OnlineCollector> collectors = new ConcurrentHashMap<>();
/**
* 超时毫秒15分钟
*/
public static final long TIMEOUT_MILLIS = 900000L;
private CollectorManager() {
}
public static CollectorManager getInstance() {
return collectorManager;
}
/**
* 添加采集器
*
* @param channelId
* @param collectorDTO
*/
public void addCollector(String channelId, CollectorDTO collectorDTO) {
OnlineCollector onlineCollector = getCollector(channelId);
if (onlineCollector == null) {
log.debug("{} 采集器设备接入", onlineCollector.getCollectorDTO().getCollectorMn());
onlineCollector = new OnlineCollector();
onlineCollector.setChannelId(channelId);
onlineCollector.setCollectorDTO(collectorDTO);
onlineCollector.setLastUploadDataTime(System.currentTimeMillis());
collectors.put(channelId, onlineCollector);
return;
}
onlineCollector.setLastUploadDataTime(System.currentTimeMillis());
}
public OnlineCollector getCollector(String channelId) {
return collectors.get(channelId);
}
/**
* 在线采集器列表
*
* @return
*/
public List<OnlineCollector> listCollectors() {
List<OnlineCollector> onlineCollectors = new ArrayList<>();
for (Map.Entry<String, OnlineCollector> kv : collectors.entrySet()) {
onlineCollectors.add(kv.getValue());
}
return onlineCollectors;
}
/**
* 超时采集器列表
*
* @return
*/
public List<OnlineCollector> listTimeoutCollectors() {
List<OnlineCollector> onlineCollectors = new ArrayList<>();
long currentTime = System.currentTimeMillis();
for (Map.Entry<String, OnlineCollector> kv : collectors.entrySet()) {
// 超过15分钟未上传视为超时
if (kv.getValue().getLastUploadDataTime() - currentTime < TIMEOUT_MILLIS) {
continue;
}
onlineCollectors.add(kv.getValue());
}
return onlineCollectors;
}
/**
* 未超时采集器列表
*
* @return
*/
public List<OnlineCollector> listUnTimeoutCollectors() {
List<OnlineCollector> onlineCollectors = new ArrayList<>();
long currentTime = System.currentTimeMillis();
for (Map.Entry<String, OnlineCollector> kv : collectors.entrySet()) {
// 超过15分钟未上传视为超时
if (kv.getValue().getLastUploadDataTime() - currentTime > TIMEOUT_MILLIS) {
continue;
}
onlineCollectors.add(kv.getValue());
}
return onlineCollectors;
}
/**
* 清空超时采集器
*/
public void clearTimeoutCollectors() {
List<OnlineCollector> timeoutCollectors = listTimeoutCollectors();
for (OnlineCollector onlineCollector : timeoutCollectors) {
collectors.remove(onlineCollector.getChannelId());
}
if (timeoutCollectors.isEmpty()) {
System.out.println("清除超时采集器0台");
} else {
log.debug("清除{}台超时采集器", timeoutCollectors.size());
}
}
/**
* 删除采集器
*
* @param channelId
*/
public void deleteCollector(String channelId) {
OnlineCollector onlineCollector = getCollector(channelId);
if (onlineCollector != null) {
log.debug("{} 采集器设备离线", onlineCollector.getCollectorDTO().getCollectorMn());
collectors.remove(channelId);
}
}
private static class CollectorManagerBuilder {
public static final CollectorManager collectorManager = new CollectorManager();
}
}

View File

@ -1,15 +0,0 @@
package com.cm.tenlion.pollutantdata.pojo;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: DataCP
* @Description: 数据CP
* @Author: wanggeng
* @Date: 2021/3/17 12:55 下午
* @Version: 1.0
*/
public class DataCP {
}

View File

@ -1,463 +0,0 @@
package com.cm.tenlion.pollutantdata.pojo;
import javax.persistence.*;
import java.util.Date;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: Divisor
* @Description:
* @Author: WangGeng
* @Date: 2021/3/13 13:41
* @Version: 1.0
**/
@Table(name = "sys_divisor")
public class Divisor {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String code;
private Integer type;
@Column(name = "is_show_avgval")
private Integer isShowAvgval;
@Column(name = "is_show_sumval")
private Integer isShowSumval;
@Column(name = "is_show_maxval")
private Integer isShowMaxval;
@Column(name = "is_show_minval")
private Integer isShowMinval;
@Column(name = "sum_type")
private Integer sumType;
@Column(name = "avg_unit")
private String avgUnit;
@Column(name = "sum_unit")
private String sumUnit;
@Column(name = "is_deleted")
private Integer idDeleted;
@Column(name = "protocol_type")
private String protocolType;
private String ceilval;
private String floorval;
@Column(name = "gmt_create")
private Date gmtCreate;
@Column(name = "gmt_modified")
private Date gmtModified;
public Divisor() {
}
public Integer getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String getCode() {
return this.code;
}
public Integer getType() {
return this.type;
}
public Integer getIsShowAvgval() {
return this.isShowAvgval;
}
public Integer getIsShowSumval() {
return this.isShowSumval;
}
public Integer getIsShowMaxval() {
return this.isShowMaxval;
}
public Integer getIsShowMinval() {
return this.isShowMinval;
}
public Integer getSumType() {
return this.sumType;
}
public String getAvgUnit() {
return this.avgUnit;
}
public String getSumUnit() {
return this.sumUnit;
}
public Integer getIdDeleted() {
return this.idDeleted;
}
public String getProtocolType() {
return this.protocolType;
}
public String getCeilval() {
return this.ceilval;
}
public String getFloorval() {
return this.floorval;
}
public Date getGmtCreate() {
return this.gmtCreate;
}
public Date getGmtModified() {
return this.gmtModified;
}
public void setId(final Integer id) {
this.id = id;
}
public void setName(final String name) {
this.name = name;
}
public void setCode(final String code) {
this.code = code;
}
public void setType(final Integer type) {
this.type = type;
}
public void setIsShowAvgval(final Integer isShowAvgval) {
this.isShowAvgval = isShowAvgval;
}
public void setIsShowSumval(final Integer isShowSumval) {
this.isShowSumval = isShowSumval;
}
public void setIsShowMaxval(final Integer isShowMaxval) {
this.isShowMaxval = isShowMaxval;
}
public void setIsShowMinval(final Integer isShowMinval) {
this.isShowMinval = isShowMinval;
}
public void setSumType(final Integer sumType) {
this.sumType = sumType;
}
public void setAvgUnit(final String avgUnit) {
this.avgUnit = avgUnit;
}
public void setSumUnit(final String sumUnit) {
this.sumUnit = sumUnit;
}
public void setIdDeleted(final Integer idDeleted) {
this.idDeleted = idDeleted;
}
public void setProtocolType(final String protocolType) {
this.protocolType = protocolType;
}
public void setCeilval(final String ceilval) {
this.ceilval = ceilval;
}
public void setFloorval(final String floorval) {
this.floorval = floorval;
}
public void setGmtCreate(final Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public void setGmtModified(final Date gmtModified) {
this.gmtModified = gmtModified;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof Divisor)) {
return false;
} else {
Divisor other = (Divisor) o;
if (!other.canEqual(this)) {
return false;
} else {
label215:
{
Object this$id = this.getId();
Object other$id = other.getId();
if (this$id == null) {
if (other$id == null) {
break label215;
}
} else if (this$id.equals(other$id)) {
break label215;
}
return false;
}
Object this$type = this.getType();
Object other$type = other.getType();
if (this$type == null) {
if (other$type != null) {
return false;
}
} else if (!this$type.equals(other$type)) {
return false;
}
label201:
{
Object this$isShowAvgval = this.getIsShowAvgval();
Object other$isShowAvgval = other.getIsShowAvgval();
if (this$isShowAvgval == null) {
if (other$isShowAvgval == null) {
break label201;
}
} else if (this$isShowAvgval.equals(other$isShowAvgval)) {
break label201;
}
return false;
}
Object this$isShowSumval = this.getIsShowSumval();
Object other$isShowSumval = other.getIsShowSumval();
if (this$isShowSumval == null) {
if (other$isShowSumval != null) {
return false;
}
} else if (!this$isShowSumval.equals(other$isShowSumval)) {
return false;
}
label187:
{
Object this$isShowMaxval = this.getIsShowMaxval();
Object other$isShowMaxval = other.getIsShowMaxval();
if (this$isShowMaxval == null) {
if (other$isShowMaxval == null) {
break label187;
}
} else if (this$isShowMaxval.equals(other$isShowMaxval)) {
break label187;
}
return false;
}
Object this$isShowMinval = this.getIsShowMinval();
Object other$isShowMinval = other.getIsShowMinval();
if (this$isShowMinval == null) {
if (other$isShowMinval != null) {
return false;
}
} else if (!this$isShowMinval.equals(other$isShowMinval)) {
return false;
}
label173:
{
Object this$sumType = this.getSumType();
Object other$sumType = other.getSumType();
if (this$sumType == null) {
if (other$sumType == null) {
break label173;
}
} else if (this$sumType.equals(other$sumType)) {
break label173;
}
return false;
}
label166:
{
Object this$idDeleted = this.getIdDeleted();
Object other$idDeleted = other.getIdDeleted();
if (this$idDeleted == null) {
if (other$idDeleted == null) {
break label166;
}
} else if (this$idDeleted.equals(other$idDeleted)) {
break label166;
}
return false;
}
Object this$name = this.getName();
Object other$name = other.getName();
if (this$name == null) {
if (other$name != null) {
return false;
}
} else if (!this$name.equals(other$name)) {
return false;
}
label152:
{
Object this$code = this.getCode();
Object other$code = other.getCode();
if (this$code == null) {
if (other$code == null) {
break label152;
}
} else if (this$code.equals(other$code)) {
break label152;
}
return false;
}
label145:
{
Object this$avgUnit = this.getAvgUnit();
Object other$avgUnit = other.getAvgUnit();
if (this$avgUnit == null) {
if (other$avgUnit == null) {
break label145;
}
} else if (this$avgUnit.equals(other$avgUnit)) {
break label145;
}
return false;
}
Object this$sumUnit = this.getSumUnit();
Object other$sumUnit = other.getSumUnit();
if (this$sumUnit == null) {
if (other$sumUnit != null) {
return false;
}
} else if (!this$sumUnit.equals(other$sumUnit)) {
return false;
}
Object this$protocolType = this.getProtocolType();
Object other$protocolType = other.getProtocolType();
if (this$protocolType == null) {
if (other$protocolType != null) {
return false;
}
} else if (!this$protocolType.equals(other$protocolType)) {
return false;
}
label124:
{
Object this$ceilval = this.getCeilval();
Object other$ceilval = other.getCeilval();
if (this$ceilval == null) {
if (other$ceilval == null) {
break label124;
}
} else if (this$ceilval.equals(other$ceilval)) {
break label124;
}
return false;
}
Object this$floorval = this.getFloorval();
Object other$floorval = other.getFloorval();
if (this$floorval == null) {
if (other$floorval != null) {
return false;
}
} else if (!this$floorval.equals(other$floorval)) {
return false;
}
Object this$gmtCreate = this.getGmtCreate();
Object other$gmtCreate = other.getGmtCreate();
if (this$gmtCreate == null) {
if (other$gmtCreate != null) {
return false;
}
} else if (!this$gmtCreate.equals(other$gmtCreate)) {
return false;
}
Object this$gmtModified = this.getGmtModified();
Object other$gmtModified = other.getGmtModified();
if (this$gmtModified == null) {
if (other$gmtModified != null) {
return false;
}
} else if (!this$gmtModified.equals(other$gmtModified)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof Divisor;
}
@Override
public int hashCode() {
boolean PRIME = true;
Object $id = this.getId();
int result = 1;
result = result * 59 + ($id == null ? 43 : $id.hashCode());
Object $type = this.getType();
result = result * 59 + ($type == null ? 43 : $type.hashCode());
Object $isShowAvgval = this.getIsShowAvgval();
result = result * 59 + ($isShowAvgval == null ? 43 : $isShowAvgval.hashCode());
Object $isShowSumval = this.getIsShowSumval();
result = result * 59 + ($isShowSumval == null ? 43 : $isShowSumval.hashCode());
Object $isShowMaxval = this.getIsShowMaxval();
result = result * 59 + ($isShowMaxval == null ? 43 : $isShowMaxval.hashCode());
Object $isShowMinval = this.getIsShowMinval();
result = result * 59 + ($isShowMinval == null ? 43 : $isShowMinval.hashCode());
Object $sumType = this.getSumType();
result = result * 59 + ($sumType == null ? 43 : $sumType.hashCode());
Object $idDeleted = this.getIdDeleted();
result = result * 59 + ($idDeleted == null ? 43 : $idDeleted.hashCode());
Object $name = this.getName();
result = result * 59 + ($name == null ? 43 : $name.hashCode());
Object $code = this.getCode();
result = result * 59 + ($code == null ? 43 : $code.hashCode());
Object $avgUnit = this.getAvgUnit();
result = result * 59 + ($avgUnit == null ? 43 : $avgUnit.hashCode());
Object $sumUnit = this.getSumUnit();
result = result * 59 + ($sumUnit == null ? 43 : $sumUnit.hashCode());
Object $protocolType = this.getProtocolType();
result = result * 59 + ($protocolType == null ? 43 : $protocolType.hashCode());
Object $ceilval = this.getCeilval();
result = result * 59 + ($ceilval == null ? 43 : $ceilval.hashCode());
Object $floorval = this.getFloorval();
result = result * 59 + ($floorval == null ? 43 : $floorval.hashCode());
Object $gmtCreate = this.getGmtCreate();
result = result * 59 + ($gmtCreate == null ? 43 : $gmtCreate.hashCode());
Object $gmtModified = this.getGmtModified();
result = result * 59 + ($gmtModified == null ? 43 : $gmtModified.hashCode());
return result;
}
@Override
public String toString() {
return "Divisor(id=" + this.getId() + ", name=" + this.getName() + ", code=" + this.getCode() + ", type=" + this.getType() + ", isShowAvgval=" + this.getIsShowAvgval() + ", isShowSumval=" + this.getIsShowSumval() + ", isShowMaxval=" + this.getIsShowMaxval() + ", isShowMinval=" + this.getIsShowMinval() + ", sumType=" + this.getSumType() + ", avgUnit=" + this.getAvgUnit() + ", sumUnit=" + this.getSumUnit() + ", idDeleted=" + this.getIdDeleted() + ", protocolType=" + this.getProtocolType() + ", ceilval=" + this.getCeilval() + ", floorval=" + this.getFloorval() + ", gmtCreate=" + this.getGmtCreate() + ", gmtModified=" + this.getGmtModified() + ")";
}
}

View File

@ -1,203 +0,0 @@
package com.cm.tenlion.pollutantdata.pojo;
import javax.persistence.*;
import java.util.Date;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: Offline
* @Description:
* @Author: WangGeng
* @Date: 2021/3/13 13:45
* @Version: 1.0
**/
@Table(name = "cus_point_offline_records")
public class Offline {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "point_id")
private Integer pointId;
@Column(name = "enterprise_id")
private Integer enterpriseId;
@Column(name = "gmt_offline")
private Date gmtOffline;
@Column(name = "gmt_create")
private Date gmtCreate;
@Column(name = "gmt_modified")
private Date gmtModified;
public Integer getId() {
return this.id;
}
public Integer getPointId() {
return this.pointId;
}
public Integer getEnterpriseId() {
return this.enterpriseId;
}
public Date getGmtOffline() {
return this.gmtOffline;
}
public Date getGmtCreate() {
return this.gmtCreate;
}
public Date getGmtModified() {
return this.gmtModified;
}
public void setId(final Integer id) {
this.id = id;
}
public void setPointId(final Integer pointId) {
this.pointId = pointId;
}
public void setEnterpriseId(final Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public void setGmtOffline(final Date gmtOffline) {
this.gmtOffline = gmtOffline;
}
public void setGmtCreate(final Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public void setGmtModified(final Date gmtModified) {
this.gmtModified = gmtModified;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof Offline)) {
return false;
} else {
Offline other = (Offline)o;
if (!other.canEqual(this)) {
return false;
} else {
Object this$id = this.getId();
Object other$id = other.getId();
if (this$id == null) {
if (other$id != null) {
return false;
}
} else if (!this$id.equals(other$id)) {
return false;
}
Object this$pointId = this.getPointId();
Object other$pointId = other.getPointId();
if (this$pointId == null) {
if (other$pointId != null) {
return false;
}
} else if (!this$pointId.equals(other$pointId)) {
return false;
}
Object this$enterpriseId = this.getEnterpriseId();
Object other$enterpriseId = other.getEnterpriseId();
if (this$enterpriseId == null) {
if (other$enterpriseId != null) {
return false;
}
} else if (!this$enterpriseId.equals(other$enterpriseId)) {
return false;
}
label62: {
Object this$gmtOffline = this.getGmtOffline();
Object other$gmtOffline = other.getGmtOffline();
if (this$gmtOffline == null) {
if (other$gmtOffline == null) {
break label62;
}
} else if (this$gmtOffline.equals(other$gmtOffline)) {
break label62;
}
return false;
}
label55: {
Object this$gmtCreate = this.getGmtCreate();
Object other$gmtCreate = other.getGmtCreate();
if (this$gmtCreate == null) {
if (other$gmtCreate == null) {
break label55;
}
} else if (this$gmtCreate.equals(other$gmtCreate)) {
break label55;
}
return false;
}
Object this$gmtModified = this.getGmtModified();
Object other$gmtModified = other.getGmtModified();
if (this$gmtModified == null) {
if (other$gmtModified != null) {
return false;
}
} else if (!this$gmtModified.equals(other$gmtModified)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof Offline;
}
@Override
public int hashCode() {
boolean PRIME = true;
Object $id = this.getId();
int result = 1;
result = result * 59 + ($id == null ? 43 : $id.hashCode());
Object $pointId = this.getPointId();
result = result * 59 + ($pointId == null ? 43 : $pointId.hashCode());
Object $enterpriseId = this.getEnterpriseId();
result = result * 59 + ($enterpriseId == null ? 43 : $enterpriseId.hashCode());
Object $gmtOffline = this.getGmtOffline();
result = result * 59 + ($gmtOffline == null ? 43 : $gmtOffline.hashCode());
Object $gmtCreate = this.getGmtCreate();
result = result * 59 + ($gmtCreate == null ? 43 : $gmtCreate.hashCode());
Object $gmtModified = this.getGmtModified();
result = result * 59 + ($gmtModified == null ? 43 : $gmtModified.hashCode());
return result;
}
@Override
public String toString() {
return "Offline(id=" + this.getId() + ", pointId=" + this.getPointId() + ", enterpriseId=" + this.getEnterpriseId() + ", gmtOffline=" + this.getGmtOffline() + ", gmtCreate=" + this.getGmtCreate() + ", gmtModified=" + this.getGmtModified() + ")";
}
public Offline() {
}
public Offline(final Integer id, final Integer pointId, final Integer enterpriseId, final Date gmtOffline, final Date gmtCreate, final Date gmtModified) {
this.id = id;
this.pointId = pointId;
this.enterpriseId = enterpriseId;
this.gmtOffline = gmtOffline;
this.gmtCreate = gmtCreate;
this.gmtModified = gmtModified;
}
}

View File

@ -0,0 +1,23 @@
package com.cm.tenlion.pollutantdata.pojo;
import com.cm.tenlion.pollutantdata.pojo.dtos.collector.CollectorDTO;
import lombok.Data;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: OnlineCollector
* @Description: 在线采集器
* @Author: wanggeng
* @Date: 2021/3/25 12:32 下午
* @Version: 1.0
*/
@Data
public class OnlineCollector {
private String channelId;
private CollectorDTO collectorDTO;
private long lastUploadDataTime;
}

View File

@ -1,546 +0,0 @@
package com.cm.tenlion.pollutantdata.pojo;
import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: PointInfo
* @Description:
* @Author: WangGeng
* @Date: 2021/3/13 13:46
* @Version: 1.0
**/
@Table(name = "cus_point")
public class PointInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "enterprise_id")
private Integer enterpriseId;
@Column(name = "user_id")
private Integer userId;
private String name;
private String mn;
private Integer type;
private String pass;
private String num;
@Column(name = "protocol_type")
private String protocolType;
@Column(name = "transfer_type")
private Integer transferType;
private String address;
private BigDecimal longitude;
private BigDecimal latitude;
private String remark;
@Column(name = "divisor_count")
private Integer divisorCount;
@Column(name = "is_deleted")
private Integer isDeleted;
@Column(name = "gmt_create")
private Date gmtCreate;
@Column(name = "gmt_modified")
private Date gmtModified;
@Column(name = "gmt_stop")
private Date gmtStop;
@Column(name = "stop_reason")
private String stopReason;
@Column(name = "is_started")
private Integer isStarted;
public PointInfo() {
}
public Integer getId() {
return this.id;
}
public Integer getEnterpriseId() {
return this.enterpriseId;
}
public Integer getUserId() {
return this.userId;
}
public String getName() {
return this.name;
}
public String getMn() {
return this.mn;
}
public Integer getType() {
return this.type;
}
public String getPass() {
return this.pass;
}
public String getNum() {
return this.num;
}
public String getProtocolType() {
return this.protocolType;
}
public Integer getTransferType() {
return this.transferType;
}
public String getAddress() {
return this.address;
}
public BigDecimal getLongitude() {
return this.longitude;
}
public BigDecimal getLatitude() {
return this.latitude;
}
public String getRemark() {
return this.remark;
}
public Integer getDivisorCount() {
return this.divisorCount;
}
public Integer getIsDeleted() {
return this.isDeleted;
}
public Date getGmtCreate() {
return this.gmtCreate;
}
public Date getGmtModified() {
return this.gmtModified;
}
public Date getGmtStop() {
return this.gmtStop;
}
public String getStopReason() {
return this.stopReason;
}
public Integer getIsStarted() {
return this.isStarted;
}
public void setId(final Integer id) {
this.id = id;
}
public void setEnterpriseId(final Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public void setUserId(final Integer userId) {
this.userId = userId;
}
public void setName(final String name) {
this.name = name;
}
public void setMn(final String mn) {
this.mn = mn;
}
public void setType(final Integer type) {
this.type = type;
}
public void setPass(final String pass) {
this.pass = pass;
}
public void setNum(final String num) {
this.num = num;
}
public void setProtocolType(final String protocolType) {
this.protocolType = protocolType;
}
public void setTransferType(final Integer transferType) {
this.transferType = transferType;
}
public void setAddress(final String address) {
this.address = address;
}
public void setLongitude(final BigDecimal longitude) {
this.longitude = longitude;
}
public void setLatitude(final BigDecimal latitude) {
this.latitude = latitude;
}
public void setRemark(final String remark) {
this.remark = remark;
}
public void setDivisorCount(final Integer divisorCount) {
this.divisorCount = divisorCount;
}
public void setIsDeleted(final Integer isDeleted) {
this.isDeleted = isDeleted;
}
public void setGmtCreate(final Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public void setGmtModified(final Date gmtModified) {
this.gmtModified = gmtModified;
}
public void setGmtStop(final Date gmtStop) {
this.gmtStop = gmtStop;
}
public void setStopReason(final String stopReason) {
this.stopReason = stopReason;
}
public void setIsStarted(final Integer isStarted) {
this.isStarted = isStarted;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof PointInfo)) {
return false;
} else {
PointInfo other = (PointInfo)o;
if (!other.canEqual(this)) {
return false;
} else {
label263: {
Object this$id = this.getId();
Object other$id = other.getId();
if (this$id == null) {
if (other$id == null) {
break label263;
}
} else if (this$id.equals(other$id)) {
break label263;
}
return false;
}
Object this$enterpriseId = this.getEnterpriseId();
Object other$enterpriseId = other.getEnterpriseId();
if (this$enterpriseId == null) {
if (other$enterpriseId != null) {
return false;
}
} else if (!this$enterpriseId.equals(other$enterpriseId)) {
return false;
}
label249: {
Object this$userId = this.getUserId();
Object other$userId = other.getUserId();
if (this$userId == null) {
if (other$userId == null) {
break label249;
}
} else if (this$userId.equals(other$userId)) {
break label249;
}
return false;
}
Object this$type = this.getType();
Object other$type = other.getType();
if (this$type == null) {
if (other$type != null) {
return false;
}
} else if (!this$type.equals(other$type)) {
return false;
}
label235: {
Object this$transferType = this.getTransferType();
Object other$transferType = other.getTransferType();
if (this$transferType == null) {
if (other$transferType == null) {
break label235;
}
} else if (this$transferType.equals(other$transferType)) {
break label235;
}
return false;
}
Object this$divisorCount = this.getDivisorCount();
Object other$divisorCount = other.getDivisorCount();
if (this$divisorCount == null) {
if (other$divisorCount != null) {
return false;
}
} else if (!this$divisorCount.equals(other$divisorCount)) {
return false;
}
label221: {
Object this$isDeleted = this.getIsDeleted();
Object other$isDeleted = other.getIsDeleted();
if (this$isDeleted == null) {
if (other$isDeleted == null) {
break label221;
}
} else if (this$isDeleted.equals(other$isDeleted)) {
break label221;
}
return false;
}
label214: {
Object this$isStarted = this.getIsStarted();
Object other$isStarted = other.getIsStarted();
if (this$isStarted == null) {
if (other$isStarted == null) {
break label214;
}
} else if (this$isStarted.equals(other$isStarted)) {
break label214;
}
return false;
}
Object this$name = this.getName();
Object other$name = other.getName();
if (this$name == null) {
if (other$name != null) {
return false;
}
} else if (!this$name.equals(other$name)) {
return false;
}
label200: {
Object this$mn = this.getMn();
Object other$mn = other.getMn();
if (this$mn == null) {
if (other$mn == null) {
break label200;
}
} else if (this$mn.equals(other$mn)) {
break label200;
}
return false;
}
label193: {
Object this$pass = this.getPass();
Object other$pass = other.getPass();
if (this$pass == null) {
if (other$pass == null) {
break label193;
}
} else if (this$pass.equals(other$pass)) {
break label193;
}
return false;
}
Object this$num = this.getNum();
Object other$num = other.getNum();
if (this$num == null) {
if (other$num != null) {
return false;
}
} else if (!this$num.equals(other$num)) {
return false;
}
Object this$protocolType = this.getProtocolType();
Object other$protocolType = other.getProtocolType();
if (this$protocolType == null) {
if (other$protocolType != null) {
return false;
}
} else if (!this$protocolType.equals(other$protocolType)) {
return false;
}
label172: {
Object this$address = this.getAddress();
Object other$address = other.getAddress();
if (this$address == null) {
if (other$address == null) {
break label172;
}
} else if (this$address.equals(other$address)) {
break label172;
}
return false;
}
Object this$longitude = this.getLongitude();
Object other$longitude = other.getLongitude();
if (this$longitude == null) {
if (other$longitude != null) {
return false;
}
} else if (!this$longitude.equals(other$longitude)) {
return false;
}
Object this$latitude = this.getLatitude();
Object other$latitude = other.getLatitude();
if (this$latitude == null) {
if (other$latitude != null) {
return false;
}
} else if (!this$latitude.equals(other$latitude)) {
return false;
}
label151: {
Object this$remark = this.getRemark();
Object other$remark = other.getRemark();
if (this$remark == null) {
if (other$remark == null) {
break label151;
}
} else if (this$remark.equals(other$remark)) {
break label151;
}
return false;
}
Object this$gmtCreate = this.getGmtCreate();
Object other$gmtCreate = other.getGmtCreate();
if (this$gmtCreate == null) {
if (other$gmtCreate != null) {
return false;
}
} else if (!this$gmtCreate.equals(other$gmtCreate)) {
return false;
}
label137: {
Object this$gmtModified = this.getGmtModified();
Object other$gmtModified = other.getGmtModified();
if (this$gmtModified == null) {
if (other$gmtModified == null) {
break label137;
}
} else if (this$gmtModified.equals(other$gmtModified)) {
break label137;
}
return false;
}
Object this$gmtStop = this.getGmtStop();
Object other$gmtStop = other.getGmtStop();
if (this$gmtStop == null) {
if (other$gmtStop != null) {
return false;
}
} else if (!this$gmtStop.equals(other$gmtStop)) {
return false;
}
Object this$stopReason = this.getStopReason();
Object other$stopReason = other.getStopReason();
if (this$stopReason == null) {
if (other$stopReason == null) {
return true;
}
} else if (this$stopReason.equals(other$stopReason)) {
return true;
}
return false;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof PointInfo;
}
public int hashCode() {
boolean PRIME = true;
int result = 1;
Object $id = this.getId();
result = result * 59 + ($id == null ? 43 : $id.hashCode());
Object $enterpriseId = this.getEnterpriseId();
result = result * 59 + ($enterpriseId == null ? 43 : $enterpriseId.hashCode());
Object $userId = this.getUserId();
result = result * 59 + ($userId == null ? 43 : $userId.hashCode());
Object $type = this.getType();
result = result * 59 + ($type == null ? 43 : $type.hashCode());
Object $transferType = this.getTransferType();
result = result * 59 + ($transferType == null ? 43 : $transferType.hashCode());
Object $divisorCount = this.getDivisorCount();
result = result * 59 + ($divisorCount == null ? 43 : $divisorCount.hashCode());
Object $isDeleted = this.getIsDeleted();
result = result * 59 + ($isDeleted == null ? 43 : $isDeleted.hashCode());
Object $isStarted = this.getIsStarted();
result = result * 59 + ($isStarted == null ? 43 : $isStarted.hashCode());
Object $name = this.getName();
result = result * 59 + ($name == null ? 43 : $name.hashCode());
Object $mn = this.getMn();
result = result * 59 + ($mn == null ? 43 : $mn.hashCode());
Object $pass = this.getPass();
result = result * 59 + ($pass == null ? 43 : $pass.hashCode());
Object $num = this.getNum();
result = result * 59 + ($num == null ? 43 : $num.hashCode());
Object $protocolType = this.getProtocolType();
result = result * 59 + ($protocolType == null ? 43 : $protocolType.hashCode());
Object $address = this.getAddress();
result = result * 59 + ($address == null ? 43 : $address.hashCode());
Object $longitude = this.getLongitude();
result = result * 59 + ($longitude == null ? 43 : $longitude.hashCode());
Object $latitude = this.getLatitude();
result = result * 59 + ($latitude == null ? 43 : $latitude.hashCode());
Object $remark = this.getRemark();
result = result * 59 + ($remark == null ? 43 : $remark.hashCode());
Object $gmtCreate = this.getGmtCreate();
result = result * 59 + ($gmtCreate == null ? 43 : $gmtCreate.hashCode());
Object $gmtModified = this.getGmtModified();
result = result * 59 + ($gmtModified == null ? 43 : $gmtModified.hashCode());
Object $gmtStop = this.getGmtStop();
result = result * 59 + ($gmtStop == null ? 43 : $gmtStop.hashCode());
Object $stopReason = this.getStopReason();
result = result * 59 + ($stopReason == null ? 43 : $stopReason.hashCode());
return result;
}
@Override
public String toString() {
return "PointInfo(id=" + this.getId() + ", enterpriseId=" + this.getEnterpriseId() + ", userId=" + this.getUserId() + ", name=" + this.getName() + ", mn=" + this.getMn() + ", type=" + this.getType() + ", pass=" + this.getPass() + ", num=" + this.getNum() + ", protocolType=" + this.getProtocolType() + ", transferType=" + this.getTransferType() + ", address=" + this.getAddress() + ", longitude=" + this.getLongitude() + ", latitude=" + this.getLatitude() + ", remark=" + this.getRemark() + ", divisorCount=" + this.getDivisorCount() + ", isDeleted=" + this.getIsDeleted() + ", gmtCreate=" + this.getGmtCreate() + ", gmtModified=" + this.getGmtModified() + ", gmtStop=" + this.getGmtStop() + ", stopReason=" + this.getStopReason() + ", isStarted=" + this.getIsStarted() + ")";
}
}

View File

@ -1,240 +0,0 @@
package com.cm.tenlion.pollutantdata.pojo;
import java.util.Date;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: WareInfo
* @Description:
* @Author: WangGeng
* @Date: 2021/3/13 13:47
* @Version: 1.0
**/
public class WareInfo {
private Integer pointId;
private String pointName;
private Date qn;
private String mn;
private Integer enterpriseId;
private String enterpriseName;
private String dataType;
private Map<String, Map<String, String>> data;
public WareInfo() {
}
public Integer getPointId() {
return this.pointId;
}
public String getPointName() {
return this.pointName;
}
public Date getQn() {
return this.qn;
}
public String getMn() {
return this.mn;
}
public Integer getEnterpriseId() {
return this.enterpriseId;
}
public String getEnterpriseName() {
return this.enterpriseName;
}
public String getDataType() {
return this.dataType;
}
public Map<String, Map<String, String>> getData() {
return this.data;
}
public void setPointId(final Integer pointId) {
this.pointId = pointId;
}
public void setPointName(final String pointName) {
this.pointName = pointName;
}
public void setQn(final Date qn) {
this.qn = qn;
}
public void setMn(final String mn) {
this.mn = mn;
}
public void setEnterpriseId(final Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public void setEnterpriseName(final String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public void setDataType(final String dataType) {
this.dataType = dataType;
}
public void setData(final Map<String, Map<String, String>> data) {
this.data = data;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof WareInfo)) {
return false;
} else {
WareInfo other = (WareInfo) o;
if (!other.canEqual(this)) {
return false;
} else {
label107:
{
Object this$pointId = this.getPointId();
Object other$pointId = other.getPointId();
if (this$pointId == null) {
if (other$pointId == null) {
break label107;
}
} else if (this$pointId.equals(other$pointId)) {
break label107;
}
return false;
}
Object this$enterpriseId = this.getEnterpriseId();
Object other$enterpriseId = other.getEnterpriseId();
if (this$enterpriseId == null) {
if (other$enterpriseId != null) {
return false;
}
} else if (!this$enterpriseId.equals(other$enterpriseId)) {
return false;
}
Object this$pointName = this.getPointName();
Object other$pointName = other.getPointName();
if (this$pointName == null) {
if (other$pointName != null) {
return false;
}
} else if (!this$pointName.equals(other$pointName)) {
return false;
}
label86:
{
Object this$qn = this.getQn();
Object other$qn = other.getQn();
if (this$qn == null) {
if (other$qn == null) {
break label86;
}
} else if (this$qn.equals(other$qn)) {
break label86;
}
return false;
}
label79:
{
Object this$mn = this.getMn();
Object other$mn = other.getMn();
if (this$mn == null) {
if (other$mn == null) {
break label79;
}
} else if (this$mn.equals(other$mn)) {
break label79;
}
return false;
}
label72:
{
Object this$enterpriseName = this.getEnterpriseName();
Object other$enterpriseName = other.getEnterpriseName();
if (this$enterpriseName == null) {
if (other$enterpriseName == null) {
break label72;
}
} else if (this$enterpriseName.equals(other$enterpriseName)) {
break label72;
}
return false;
}
Object this$dataType = this.getDataType();
Object other$dataType = other.getDataType();
if (this$dataType == null) {
if (other$dataType != null) {
return false;
}
} else if (!this$dataType.equals(other$dataType)) {
return false;
}
Object this$data = this.getData();
Object other$data = other.getData();
if (this$data == null) {
if (other$data != null) {
return false;
}
} else if (!this$data.equals(other$data)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof WareInfo;
}
@Override
public int hashCode() {
boolean PRIME = true;
int result = 1;
Object $pointId = this.getPointId();
result = result * 59 + ($pointId == null ? 43 : $pointId.hashCode());
Object $enterpriseId = this.getEnterpriseId();
result = result * 59 + ($enterpriseId == null ? 43 : $enterpriseId.hashCode());
Object $pointName = this.getPointName();
result = result * 59 + ($pointName == null ? 43 : $pointName.hashCode());
Object $qn = this.getQn();
result = result * 59 + ($qn == null ? 43 : $qn.hashCode());
Object $mn = this.getMn();
result = result * 59 + ($mn == null ? 43 : $mn.hashCode());
Object $enterpriseName = this.getEnterpriseName();
result = result * 59 + ($enterpriseName == null ? 43 : $enterpriseName.hashCode());
Object $dataType = this.getDataType();
result = result * 59 + ($dataType == null ? 43 : $dataType.hashCode());
Object $data = this.getData();
result = result * 59 + ($data == null ? 43 : $data.hashCode());
return result;
}
@Override
public String toString() {
return "WareInfo(pointId=" + this.getPointId() + ", pointName=" + this.getPointName() + ", qn=" + this.getQn() + ", mn=" + this.getMn() + ", enterpriseId=" + this.getEnterpriseId() + ", enterpriseName=" + this.getEnterpriseName() + ", dataType=" + this.getDataType() + ", data=" + this.getData() + ")";
}
}

View File

@ -0,0 +1,123 @@
package com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AlarmLogDTO
* @Description: 报警日志
* @Author: wanggeng
* @Date: 2021/3/25 11:01 上午
* @Version: 1.0
*/
public class AlarmLogDTO {
private String alarmLogId;
private String enterpriseId;
private String enterpriseName;
private String instrumentId;
private String instrumentName;
private String collectorId;
private String collectorName;
private String pollId;
private Double rtd;
private Double zsRtd;
private Double alarmValue;
private String gmtCreate;
public String getAlarmLogId() {
return alarmLogId == null ? "" : alarmLogId;
}
public void setAlarmLogId(String alarmLogId) {
this.alarmLogId = alarmLogId;
}
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName == null ? "" : enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getInstrumentId() {
return instrumentId == null ? "" : instrumentId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public String getInstrumentName() {
return instrumentName == null ? "" : instrumentName;
}
public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}
public String getCollectorId() {
return collectorId == null ? "" : collectorId;
}
public void setCollectorId(String collectorId) {
this.collectorId = collectorId;
}
public String getCollectorName() {
return collectorName == null ? "" : collectorName;
}
public void setCollectorName(String collectorName) {
this.collectorName = collectorName;
}
public String getPollId() {
return pollId == null ? "" : pollId;
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public Double getRtd() {
return rtd == null ? 0 : rtd;
}
public void setRtd(Double rtd) {
this.rtd = rtd;
}
public Double getZsRtd() {
return zsRtd == null ? 0 : zsRtd;
}
public void setZsRtd(Double zsRtd) {
this.zsRtd = zsRtd;
}
public Double getAlarmValue() {
return alarmValue == null ? 0 : alarmValue;
}
public void setAlarmValue(Double alarmValue) {
this.alarmValue = alarmValue;
}
public String getGmtCreate() {
return gmtCreate == null ? "" : gmtCreate;
}
public void setGmtCreate(String gmtCreate) {
this.gmtCreate = gmtCreate;
}
}

View File

@ -0,0 +1,105 @@
package com.cm.tenlion.pollutantdata.pojo.vos.alarmlog;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AlarmLogVO
* @Description: 报警日志
* @Author: wanggeng
* @Date: 2021/3/25 10:50 上午
* @Version: 1.0
*/
public class AlarmLogVO {
private String enterpriseId;
private String enterpriseName;
private String instrumentId;
private String instrumentName;
private String collectorId;
private String collectorName;
private String pollId;
private Double rtd;
private Double zsRtd;
private Double alarmValue;
public String getEnterpriseId() {
return enterpriseId == null ? "" : enterpriseId;
}
public void setEnterpriseId(String enterpriseId) {
this.enterpriseId = enterpriseId;
}
public String getEnterpriseName() {
return enterpriseName == null ? "" : enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getInstrumentId() {
return instrumentId == null ? "" : instrumentId;
}
public void setInstrumentId(String instrumentId) {
this.instrumentId = instrumentId;
}
public String getInstrumentName() {
return instrumentName == null ? "" : instrumentName;
}
public void setInstrumentName(String instrumentName) {
this.instrumentName = instrumentName;
}
public String getCollectorId() {
return collectorId == null ? "" : collectorId;
}
public void setCollectorId(String collectorId) {
this.collectorId = collectorId;
}
public String getCollectorName() {
return collectorName == null ? "" : collectorName;
}
public void setCollectorName(String collectorName) {
this.collectorName = collectorName;
}
public String getPollId() {
return pollId == null ? "" : pollId;
}
public void setPollId(String pollId) {
this.pollId = pollId;
}
public Double getRtd() {
return rtd == null ? 0 : rtd;
}
public void setRtd(Double rtd) {
this.rtd = rtd;
}
public Double getZsRtd() {
return zsRtd == null ? 0 : zsRtd;
}
public void setZsRtd(Double zsRtd) {
this.zsRtd = zsRtd;
}
public Double getAlarmValue() {
return alarmValue == null ? 0 : alarmValue;
}
public void setAlarmValue(Double alarmValue) {
this.alarmValue = alarmValue;
}
}

View File

@ -0,0 +1,50 @@
package com.cm.tenlion.pollutantdata.service.alarmlog;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog.AlarmLogDTO;
import com.cm.tenlion.pollutantdata.pojo.vos.alarmlog.AlarmLogVO;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: IAlarmLogService
* @Description: 警告日志
* @Author: wanggeng
* @Date: 2021/3/25 10:42 上午
* @Version: 1.0
*/
public interface IAlarmLogService {
/**
* 保存
*
* @param alarmLogVO
* @throws Exception
*/
void save(AlarmLogVO alarmLogVO) throws Exception;
/**
* 列表
*
* @param params
* @return
* @throws SearchException
*/
List<AlarmLogDTO> list(Map<String, Object> params) throws SearchException;
/**
* 列表分页
*
* @param page
* @return
* @throws SearchException
*/
SuccessResultList<List<AlarmLogDTO>> listPage(ListPage page) throws SearchException;
}

View File

@ -0,0 +1,58 @@
package com.cm.tenlion.pollutantdata.service.alarmlog.impl;
import com.cm.common.base.AbstractService;
import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.DateUtil;
import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil;
import com.cm.tenlion.pollutantdata.dao.alarmlog.IAlarmLogDao;
import com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog.AlarmLogDTO;
import com.cm.tenlion.pollutantdata.pojo.vos.alarmlog.AlarmLogVO;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: AlarmLogServiceImpl
* @Description: 警告日志
* @Author: wanggeng
* @Date: 2021/3/25 10:44 上午
* @Version: 1.0
*/
@Service
public class AlarmLogServiceImpl extends AbstractService implements IAlarmLogService {
@Autowired
private IAlarmLogDao alarmLogDao;
@Override
public void save(AlarmLogVO alarmLogVO) throws Exception {
Map<String, Object> params = HashMapUtil.beanToMap(alarmLogVO);
params.put("alarmLogId", UUIDUtil.getUUID());
params.put("gmtCreate", DateUtil.getTime());
alarmLogDao.save(params);
}
@Override
public List<AlarmLogDTO> list(Map<String, Object> params) throws SearchException {
return alarmLogDao.list(params);
}
@Override
public SuccessResultList<List<AlarmLogDTO>> listPage(ListPage page) throws SearchException {
PageHelper.startPage(page.getPage(), page.getRows());
List<AlarmLogDTO> alarmLogDTOs = list(page.getParams());
PageInfo<AlarmLogDTO> pageInfo = new PageInfo<>(alarmLogDTOs);
return new SuccessResultList<>(alarmLogDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
}

View File

@ -2,7 +2,9 @@ package com.cm.tenlion.pollutantdata.utils.net;
import com.cm.common.utils.RegexUtil;
import com.cm.tenlion.pollutantdata.enums.*;
import com.cm.tenlion.pollutantdata.manager.CollectorManager;
import com.cm.tenlion.pollutantdata.pojo.dtos.instrument.InstrumentDTO;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.cm.tenlion.pollutantdata.service.collector.ICollectorService;
import com.cm.tenlion.pollutantdata.service.dataminute.IDataMinuteService;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
@ -42,12 +44,18 @@ public class TCPHandler extends SimpleChannelInboundHandler<ByteBuf> {
private ICollectorService collectorService;
private IDataMinuteService dataMinuteService;
private IPollService pollService;
private IAlarmLogService alarmLogService;
public TCPHandler(IInstrumentService instrumentService, ICollectorService collectorService, IDataMinuteService dataMinuteService, IPollService pollService) {
public TCPHandler(IInstrumentService instrumentService,
ICollectorService collectorService,
IDataMinuteService dataMinuteService,
IPollService pollService,
IAlarmLogService alarmLogService) {
this.instrumentService = instrumentService;
this.collectorService = collectorService;
this.dataMinuteService = dataMinuteService;
this.pollService = pollService;
this.alarmLogService = alarmLogService;
}
@Override
@ -155,7 +163,7 @@ public class TCPHandler extends SimpleChannelInboundHandler<ByteBuf> {
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("inactive");
CollectorManager.getInstance().deleteCollector(ctx.channel().id().toString());
}
@Override

View File

@ -1,5 +1,6 @@
package com.cm.tenlion.pollutantdata.utils.net;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.cm.tenlion.pollutantdata.service.collector.ICollectorService;
import com.cm.tenlion.pollutantdata.service.dataminute.IDataMinuteService;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
@ -33,6 +34,7 @@ public class TCPServer {
private ICollectorService collectorService;
private IDataMinuteService dataMinuteService;
private IPollService pollService;
private IAlarmLogService alarmLogService;
private final int port;
@ -80,7 +82,7 @@ public class TCPServer {
}
});
// 这里的对象必须new否则只有第一次有效其余无法连接每次执行的后都需要new
pipeline.addLast(new TCPHandler(instrumentService, collectorService, dataMinuteService, pollService));
pipeline.addLast(new TCPHandler(instrumentService, collectorService, dataMinuteService, pollService, alarmLogService));
}
});
@ -114,4 +116,8 @@ public class TCPServer {
public void setPollService(IPollService pollService) {
this.pollService = pollService;
}
public void setAlarmLogService(IAlarmLogService alarmLogService) {
this.alarmLogService = alarmLogService;
}
}

View File

@ -0,0 +1,42 @@
package com.cm.tenlion.pollutantdata.utils.net;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
*
* @ClassName: WebSocket
* @Description: WebSocket
* @Author: wanggeng
* @Date: 2021/3/25 1:21 下午
* @Version: 1.0
*/
@Slf4j
@Component
@ServerEndpoint("/ws")
public class WebSocket {
@OnOpen
public void onOpen(Session session) {
System.out.println("连接");
}
@OnClose
public void onClose(Session session) {
System.out.println("关闭");
}
@OnMessage
public void onMsg(String message, Session session) {
System.out.println("消息");
}
}

View File

@ -4,10 +4,13 @@ import com.cm.common.utils.RegexUtil;
import com.cm.tenlion.pollutantdata.enums.DataCpFlagEnum;
import com.cm.tenlion.pollutantdata.enums.ExeRtnEnum;
import com.cm.tenlion.pollutantdata.enums.QnRtdEnum;
import com.cm.tenlion.pollutantdata.manager.CollectorManager;
import com.cm.tenlion.pollutantdata.pojo.dtos.collector.CollectorDTO;
import com.cm.tenlion.pollutantdata.pojo.dtos.instrument.InstrumentDTO;
import com.cm.tenlion.pollutantdata.pojo.pos.poll.PollPO;
import com.cm.tenlion.pollutantdata.pojo.vos.alarmlog.AlarmLogVO;
import com.cm.tenlion.pollutantdata.pojo.vos.dataminute.DataMinuteVO;
import com.cm.tenlion.pollutantdata.service.alarmlog.IAlarmLogService;
import com.cm.tenlion.pollutantdata.service.collector.ICollectorService;
import com.cm.tenlion.pollutantdata.service.dataminute.IDataMinuteService;
import com.cm.tenlion.pollutantdata.service.poll.IPollService;
@ -38,6 +41,7 @@ public class RealDataHandler implements IDataHandle<HJ212DataUtil.Data> {
private IPollService pollService;
private IDataMinuteService dataMinuteService;
private InstrumentDTO instrumentDTO;
private IAlarmLogService alarmLogService;
private String ipAddress;
@Override
@ -89,6 +93,7 @@ public class RealDataHandler implements IDataHandle<HJ212DataUtil.Data> {
new ResponseDefault(ctx, QnRtdEnum.CUSTOM_CP_SN_ERROR, ExeRtnEnum.COMMAND_ERROR, isRepo).response(data);
return;
}
DataMinuteVO dataMinuteVO = new DataMinuteVO();
dataMinuteVO.setEnterpriseId(instrumentDTO.getEnterpriseId());
dataMinuteVO.setInstrumentId(instrumentDTO.getInstrumentId());
@ -101,9 +106,37 @@ public class RealDataHandler implements IDataHandle<HJ212DataUtil.Data> {
dataMinuteVO.setZsRtd(dataCp.getZsRtd());
dataMinuteVO.setIpAddress(ipAddress);
dataMinuteService.save(dataMinuteVO);
CollectorManager.getInstance().addCollector(ctx.channel().id().toString(), collectorDTO);
// 超过报警值记录报警日志
if (dataMinuteVO.getRtd() > collectorDTO.getAlarmValue()) {
saveAlarmLog(dataMinuteVO, collectorDTO.getAlarmValue());
}
new ResponseDefault(ctx, QnRtdEnum.READY, ExeRtnEnum.SUCCESS, isRepo).response(data);
}
/**
* 保存报警日志
*
* @param dataMinuteVO
* @param alarmValue
*/
private void saveAlarmLog(DataMinuteVO dataMinuteVO, double alarmValue) throws Exception {
if (alarmValue < 0) {
return;
}
AlarmLogVO alarmLogVO = new AlarmLogVO();
alarmLogVO.setEnterpriseId(dataMinuteVO.getEnterpriseId());
alarmLogVO.setInstrumentId(dataMinuteVO.getInstrumentId());
alarmLogVO.setCollectorId(dataMinuteVO.getCollectorId());
alarmLogVO.setRtd(dataMinuteVO.getRtd());
alarmLogVO.setZsRtd(dataMinuteVO.getZsRtd());
alarmLogVO.setAlarmValue(alarmValue);
alarmLogVO.setPollId(dataMinuteVO.getPollId());
alarmLogService.save(alarmLogVO);
}
/**
* 检查污染因子
*
@ -154,6 +187,10 @@ public class RealDataHandler implements IDataHandle<HJ212DataUtil.Data> {
this.instrumentDTO = instrumentDTO;
}
public void setAlarmLogService(IAlarmLogService alarmLogService) {
this.alarmLogService = alarmLogService;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}

View File

@ -1,6 +1,6 @@
server:
port: 8080
url: http://192.168.0.106:8080/pollutant
url: http://192.168.0.103:8080/pollutant
title: 污染物上报系统
servlet:
context-path: /pollutant
@ -57,12 +57,12 @@ spring:
api-path:
user-center: ${security.oauth2.oauth-server}
inspection: http://192.168.0.106:7006/inspection
inspection: http://192.168.0.103:7006/inspection
# 安全
security:
oauth2:
oauth-server: http://192.168.0.106:7001/usercenter
oauth-server: http://192.168.0.103:7001/usercenter
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
client:
client-id: 74e4b55ad48840f9b4de86ce5da58b53
@ -85,9 +85,7 @@ mybatis:
logging:
level:
root: error
org.springframework.boot.autoconfigure.security.servlet: debug
ink.wgink: debug
cn.com.tenlion: debug
com.cm.tenlion: debug
# 文档
swagger:

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.tenlion.pollutantdata.dao.alarmlog.IAlarmLogDao">
<resultMap id="alarmLogDTO" type="com.cm.tenlion.pollutantdata.pojo.dtos.alarmlog.AlarmLogDTO">
<id column="alarm_log_id" property="alarmLogId"/>
<result column="enterprise_id" property="enterpriseId"/>
<result column="enterprise_name" property="enterpriseName"/>
<result column="instrument_id" property="instrumentId"/>
<result column="instrument_name" property="instrumentName"/>
<result column="collector_id" property="collectorId"/>
<result column="collector_name" property="collectorName"/>
<result column="poll_id" property="pollId"/>
<result column="rtd" property="rtd"/>
<result column="zs_rtd" property="zsRtd"/>
<result column="alarm_value" property="alarmValue"/>
<result column="gmt_create" property="gmtCreate"/>
</resultMap>
<!-- 新增 -->
<insert id="save" parameterType="map">
INSERT INTO pollute_alarm_log (
alarm_log_id,
enterprise_id,
enterprise_name,
instrument_id,
instrument_name,
collector_id,
collector_name,
poll_id,
rtd,
zs_rtd,
alarm_value,
gmt_create
) VALUES(
#{alarmLogId},
#{enterpriseId},
#{enterpriseName},
#{instrumentId},
#{instrumentName},
#{collectorId},
#{collectorName},
#{pollId},
#{rtd},
#{zsRtd},
#{alarmValue},
#{gmtCreate}
)
</insert>
<!-- 列表 -->
<select id="list" parameterType="map" resultMap="alarmLogDTO">
SELECT
alarm_log_id,
enterprise_id,
enterprise_name,
instrument_id,
instrument_name,
collector_id,
collector_name,
poll_id,
rtd,
zs_rtd,
alarm_value,
LEFT(gmt_create, 19) gmt_create
FROM
pollute_alarm_log
WHERE
1 = 1
ORDER BY
gmt_create DESC
</select>
</mapper>