Commit 3a29e559 authored by xukaiqiang's avatar xukaiqiang

init

parents
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
*.iml
*.settings
*.classpath
*.project
*.springBeans
*.factorypath
target
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>YeeAmosIec104IntfRoot</artifactId>
<groupId>com.yeejoin.amos</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>YeeAmosConnectCommon</artifactId>
</project>
\ No newline at end of file
package com.yeejoin.amos.fas.core.common.request;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
/**
*
* <pre>
* 分页实体
* </pre>
*
* @author as-chenjiajun
* @version $Id: CommonPageable.java, v 0.1 2016-12-14 上午10:42:44 as-chenjiajun
* Exp $
*/
public class CommonPageable implements Pageable {
/**
* 页号(大于等于0)
*/
protected int pageNumber = 0;
/**
* 每页大小(大于等于0)
*/
protected int pageSize = 10;
/**
* 起始索引
*/
protected int offset = 0;
/**
* 排序
*/
protected Sort sort = null;
public CommonPageable() {
this.pageNumber = 0;
this.pageSize = 10;
this.offset = pageSize * pageNumber;
}
public CommonPageable(int pageNumber, int pageSize) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.offset = pageSize * pageNumber;
}
public CommonPageable(int pageNumber, int pageSize, Sort sort) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.sort = sort;
this.offset = pageSize * pageNumber;
}
public int getPageNumber() {
return this.pageNumber;
}
public int getPageSize() {
return pageSize;
}
public int getOffset() {
offset = pageSize * pageNumber;
return offset;
}
public Sort getSort() {
return sort;
}
public Pageable next() {
return null;
}
public Pageable previousOrFirst() {
return null;
}
public Pageable first() {
return null;
}
public boolean hasPrevious() {
return false;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public void setSort(Sort sort) {
this.sort = sort;
}
public void setOffset(int offset) {
this.offset = offset;
}
}
package com.yeejoin.amos.fas.core.common.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* <pre>
* 公共请求对象
* </pre>
*
* @author as-shibaobao
* @version $Id: CommonRequest.java, v 0.1 2018年1月26日 上午10:59:19 as-shibaobao Exp $
*/
@ApiModel
public class CommonRequest {
/**
* 字段名称
*/
@ApiModelProperty(value="字段名称",required=true)
private String name;
/**
* 字段值
*/
@ApiModelProperty(value="字段值",required=true)
private Object value;
/**
* 查询类型
*/
@ApiModelProperty(value="查询类型",notes="空值时,默认为等于;其它类型按QueryOperatorEnum",required=false)
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.amos.fas.core.common.response;
import java.util.List;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
/**
* <pre>
* 分页数据
* </pre>
*
* @author as-youjun
* @version $Id: CompanyPage.java, v 0.1 2017年4月13日 上午11:35:25 as-youjun Exp $
*/
public final class CommonPage<T> extends PageImpl<T> {
/**
* <pre>
* uid
* </pre>
*/
private static final long serialVersionUID = -5533124806408380886L;
/**
*
*/
private String message;
/**
* 返回结果状态
*/
private String result;
public CommonPage(List<T> content, Pageable pageable, long total) {
super(content, pageable, total);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult()
{
return result;
}
public void setResult(String result)
{
this.result = result;
}
}
package com.yeejoin.amos.connect.dao;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.io.Serializable;
import java.util.List;
/**
* 基础dao
*
* @param <T>
* @param <ID>
*/
@NoRepositoryBean
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, CrudRepository<T, ID>,
PagingAndSortingRepository<T, ID>, JpaSpecificationExecutor<T> {
public default T getOneBySpecification(Specification<T> specification) {
List<T> list = findAll(specification);
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
}
package com.yeejoin.amos.connect.dao.entity;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* <pre>
* 基本实体类
* </pre>
*
*/
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public class BasicEntity implements Serializable{
private static final long serialVersionUID = -5464322936854328207L;
/**
* id
*/
private long id;
@CreatedDate
@Column(name="create_date")
private Date createDate;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
}
package com.yeejoin.amos.connect.dao.entity;
import javax.persistence.*;
@Entity
@Table(name="i_client_linsten")
public class ClientListenVo {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
private Long id;
private String url;
private String remark;
private String channleNo;
private String dataType;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getChannleNo() {
return channleNo;
}
public void setChannleNo(String channleNo) {
this.channleNo = channleNo;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.yeejoin.amos.connect.dao.entity;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name="i_ip_port_conf")
public class ConfigVo {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
private Long id;
private String ip;
private String port;
private String commonAddress;
private String serviceType;
private String serviceId;
private String channelNo;
private int isDelete;
private Date lastUpdateTime;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public int getIsDelete() {
return isDelete;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getCommonAddress() {
return commonAddress;
}
public void setCommonAddress(String commonAddress) {
this.commonAddress = commonAddress;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getChannelNo() {
return channelNo;
}
public void setChannelNo(String channelNo) {
this.channelNo = channelNo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.yeejoin.amos.connect.dao.entity;
import com.yeejoin.amos.connect.utils.ExcelColumn;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name="i_point_config")
public class PointConfigVo implements Serializable{
/**
*
*/
private static final long serialVersionUID = -7259637704136034266L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
private Long id;
private Long commonAddress;
@ExcelColumn(value = "信息地址", col = 1)
private Integer originatorAddress;
private String value;
@ExcelColumn(value = "点名称", col = 2)
private String name;
@ExcelColumn(value = "点分类", col = 3)
private String pointClassify;
@ExcelColumn(value = "点编码", col = 4)
private String pointCode;
@ExcelColumn(value = "说明", col = 5)
private String remark;
@ExcelColumn(value = "是否有效", col = 6)
private boolean invalid;
private String channelNo;
private String pointType;
public PointConfigVo() {};
public PointConfigVo(Long id, Long commonAddress, Integer originatorAddress, String pointType, String pointClassify, boolean invalid, String channelNo, String name, String pointCode ) {
super();
this.id = id;
this.commonAddress = commonAddress;
this.originatorAddress = originatorAddress;
this.name = name;
this.pointClassify = pointClassify;
this.pointCode = pointCode;
this.invalid = invalid;
this.channelNo = channelNo;
this.pointType = pointType;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getCommonAddress() {
return commonAddress;
}
public void setCommonAddress(Long commonAddress) {
this.commonAddress = commonAddress;
}
public Integer getOriginatorAddress() {
return originatorAddress;
}
public void setOriginatorAddress(Integer originatorAddress) {
this.originatorAddress = originatorAddress;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public boolean getInvalid() {
return invalid;
}
public void setInvalid(boolean invalid) {
this.invalid = invalid;
}
public String getChannelNo() {
return channelNo;
}
public void setChannelNo(String channelNo) {
this.channelNo = channelNo;
}
public String getPointCode() {
return pointCode;
}
public void setPointCode(String pointCode) {
this.pointCode = pointCode;
}
public String getPointType() {
return pointType;
}
public void setPointType(String pointType) {
this.pointType = pointType;
}
public String getPointClassify() {
return pointClassify;
}
public void setPointClassify(String pointClassify) {
this.pointClassify = pointClassify;
}
@Override
public String toString() {
return "PointConfigVo [id=" + id + ", commonAddress=" + commonAddress + ", originatorAddress="
+ originatorAddress + ", value=" + value + ", name=" + name + ", pointClassify=" + pointClassify
+ ", pointCode=" + pointCode + ", remark=" + remark + ", invalid=" + invalid + ", channelNo="
+ channelNo + ", pointType=" + pointType + "]";
}
}
package com.yeejoin.amos.connect.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="i_transmit_mapper")
public class TransmitMapper {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
private Long id;
// @Column(columnDefinition = "comment '映射类型(UART,IEC104)'")
private String mapperType;
// @Column(columnDefinition = "comment '转发接收方地址(IP)'")
private String transmitIp;
// @Column(columnDefinition = "comment '转发接收方端口号'")
private String transmitPort;
// @Column(columnDefinition = "comment '转发方式(TCP,UDP,HTTP)'")
private String transmitType;
// @Column(columnDefinition = "comment '转发地址'")
private String transmitUrl;
// @Column(columnDefinition = "comment '映射ID'")
private Long mapperId;
public Long getId() {
return id;
}
public String getMapperType() {
return mapperType;
}
public String getTransmitIp() {
return transmitIp;
}
public String getTransmitPort() {
return transmitPort;
}
public String getTransmitType() {
return transmitType;
}
public String getTransmitUrl() {
return transmitUrl;
}
public Long getMapperId() {
return mapperId;
}
public void setId(Long id) {
this.id = id;
}
public void setMapperType(String mapperType) {
this.mapperType = mapperType;
}
public void setTransmitIp(String transmitIp) {
this.transmitIp = transmitIp;
}
public void setTransmitPort(String transmitPort) {
this.transmitPort = transmitPort;
}
public void setTransmitType(String transmitType) {
this.transmitType = transmitType;
}
public void setTransmitUrl(String transmitUrl) {
this.transmitUrl = transmitUrl;
}
public void setMapperId(Long mapperId) {
this.mapperId = mapperId;
}
}
package com.yeejoin.amos.connect.dao.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
@Entity
@Table(name="i_uart_config")
public class UartVo {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "ID",nullable=false,unique=true)
private Long id;
private String name;
private String remark;
private String createBy;
private Date createdTime;
private String serialPort;
private int baudRate;
private int dataBits;
private int stopBits;
private int parity;
private int isDelete;
public void setId(Long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setRemark(String remark) {
this.remark = remark;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public void setSerialPort(String serialPort) {
this.serialPort = serialPort;
}
public void setBaudRate(int baudRate) {
this.baudRate = baudRate;
}
public void setDataBits(int dataBits) {
this.dataBits = dataBits;
}
public void setStopBits(int stopBits) {
this.stopBits = stopBits;
}
public void setParity(int parity) {
this.parity = parity;
}
public void setIsDelete(int isDelete) {
this.isDelete = isDelete;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getRemark() {
return remark;
}
public String getCreateBy() {
return createBy;
}
public Date getCreatedTime() {
return createdTime;
}
public int getBaudRate() {
return baudRate;
}
public int getDataBits() {
return dataBits;
}
public int getStopBits() {
return stopBits;
}
public int getParity() {
return parity;
}
public int getIsDelete() {
return isDelete;
}
public String getSerialPort() {
return serialPort;
}
}
package com.yeejoin.amos.connect.utils;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExcelColumn {
/**
* Excel标题
*
* @return
* @author Lynch
*/
String value() default "";
/**
* Excel从左往右排列位置
*
* @return
* @author Lynch
*/
int col() default 0;
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>YeeAmosConnectStart</artifactId>
<name>YeeAmosConnectStart</name>
<parent>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosConnectRoot</artifactId>
<version>1.0.0</version>
</parent>
<dependencies>
<!-- 业务模块jar -->
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosConnentCommon</artifactId>
<version>${iec104.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosIec104IntfServer</artifactId>
<version>${iec104.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosUartServer</artifactId>
<version>${iec104.version}</version>
</dependency>
</dependencies>
<!-- maven打包时将lib提取到jar同目录,将配置文件提取到jar目录/config/下 -->
<build>
<resources>
<!-- 先指定 src/main/resources下所有文件及文件夹为资源文件 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<!-- 过滤不需要引用的文件 -->
<excludes>
<exclude>package.xml</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<!-- 添加index则不从mainfest中读取classpath,而是从Index.list中读取 -->
<!-- <index>true</index> -->
<manifest>
<mainClass>com.yeejoin.amos.YeeAmosIec104IntfStart</mainClass>
<!-- to create a class path to your dependecies you have to fill true
in this field -->
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<!--<classpathLayoutType>custom</classpathLayoutType> <customClasspathLayout>
lib/ artifact.groupId. {artifact.artifactId}.$${artifact.extension} </customClasspathLayout> -->
</manifest>
<manifestEntries>
<Class-Path>./</Class-Path>
</manifestEntries>
</archive>
<!-- <excludes> <exclude>config/**</exclude> </excludes> -->
<includes>
<include>**/**.class</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!-- not append assembly id in release file name -->
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package com.yeejoin.amos;
import java.io.IOException;
import java.net.URISyntaxException;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import com.yeejoin.amos.iec104.context.FireAutoIntfContext;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* amosfireAutoIntf启动类
*
* @author as-gaodongdong
*/
@SpringBootApplication
@EnableTransactionManagement
@EnableConfigurationProperties
@EnableSwagger2
@ServletComponentScan
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrix
@EnableScheduling
public class YeeAmosIec104IntfStart implements ApplicationContextAware {
/**
* 启动FireAutoIntf-server
*
* @param args
* @throws IOException
* @throws URISyntaxException
*/
public static void main(String[] args) {
System.out.println("FireAutoIntf server starting...");
try {
SpringApplication application = new SpringApplication(
YeeAmosIec104IntfStart.class);
Environment environment = application.run(args).getEnvironment();
System.out.println("FireAutoIntf server is running...");
System.out.println("SwaggerUI: http://localhost:"
+ environment.getProperty("server.port")
+ "/swagger-ui.html");
} catch (Exception e) {
System.out.println("error occur when run FireAutoIntf server! " + e);
}
}
/**
* 获取并缓存上下文
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
// 1.缓存spring上下文
FireAutoIntfContext.getInstance().setApplicationContext(applicationContext);
}
/**
* 跨域过滤器
*
* @return
*/
@Bean
@Order(0)
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);// 允许cookies跨域
config.addAllowedOrigin("*");// #允许向该服务器提交请求的URI,*表示全部允许,在SpringMVC中,如果设成*,会自动转成当前请求头中的Origin
config.addAllowedHeader("*");// #允许访问的头信息,*表示全部
config.setMaxAge(3600L);// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
\ No newline at end of file
package com.yeejoin.amos.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
/**
* <pre>
* 跨域处理
* </pre>
*
* @author SmartRay
* @version CrossDomainFilter.java v0.1
* @time 2016-9-7 9:48:10
*/
@Component(value = "crossDomainFilter")
@EnableScheduling
@Order(0)
public class CrossDomainFilter implements Filter
{
public void destroy()
{
}
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chain) throws IOException, ServletException
{
HttpServletResponse response = (HttpServletResponse) res;
// 允许所有域进行访问
response.setHeader("Access-Control-Allow-Origin", "*");
// 允许的方法
response.setHeader("Access-Control-Allow-Methods","GET,POST,DELETE,OPTIONS,PUT");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers","Origin, X-Requested-With, X-Access-Token, X-Api-Key, Content-Type, Accept, Cache-Control");
chain.doFilter(req, res);
}
public void init(FilterConfig arg0) throws ServletException
{
}
}
app.id=YeeAmosFireAutoIntf
\ No newline at end of file
eureka.client.serviceUrl.defaultZone = http://172.16.10.99:10001/eureka/
eureka.client.register-with-eureka = false
eureka.client.fetch-registry = false
eureka.client.healthcheck.enabled = false
eureka.instance.hostname = ${spring.cloud.client.ipAddress}
eureka.instance.statusPageUrlPath = ${management.context-path}/info
eureka.instance.healthCheckUrlPath = ${management.context-path}/health
eureka.instance.preferIpAddress = false
eureka.instance.instance-id = ${spring.cloud.client.ipAddress}:${server.port}
eureka.instance.lease-expiration-duration-in-seconds = 10
eureka.instance.lease-renewal-interval-in-seconds = 5
#\u8BF7\u6C42\u5904\u7406\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ReadTimeout = 120000
#\u8BF7\u6C42\u8FDE\u63A5\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ConnectTimeout = 30000
#DB properties:
#spring.datasource.url = jdbc:mysql://172.233.0.6:3306/amos_beijing_command_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.url = jdbc:mysql://172.16.11.33:3306/amos_iec_test?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.username = root
spring.datasource.password = admin_1234
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.jpa.hibernate.ddl-auto=none
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#JPA Configuration:
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
# Naming strategy
#spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
#mybatis mapper file
mybatis.mapper-locations = classpath:db/mapper/*.xml
# mybatis entity package
mybatis.type-aliases-package = com.yeejoin.amos.fireAutoIntf.business.entity.mybatis
#equipment check
param.protocol.not.check = HTTP
#enable Gzip compression
server.compression.enabled = true
server.compression.mime-types = application/json,application/xml,text/html,text/xml,text/plain\u3001
server.compression.min-response-size = 2048
#liquibase
liquibase.change-log = classpath:/db/changelog/changelog-master.xml
liquibase.enabled: true
#redis database index
spring.redis.database=5
#redis ip
spring.redis.host=172.16.11.33
spring.redis.port=6379
#redis password (default is empty)
spring.redis.password=1234560
#max connect number
spring.redis.pool.max-active=200
# redis max wait time ( -1 is not limit)
spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=10
spring.redis.pool.min-idle=0
spring.redis.timeout=1000
#iec104.debug = false
#iec104.tcp.service.reomteIp=172.233.0.4
#iec104.tcp.service.reomtePort=2404
#iec104.server.Id=1
#iec104.tcp.bind.port=2404
#iec104.client.commonAddress=0000
#iec104.server.start.infomation.address = 1
#iec104.server.consecutive.transmissions.number = 6
#iec104.server.zz.max.transmissions.number = 100
#iec104.server.soe.max.transmissions.number = 10
#iec104.server.sec.max.transmissions.number = 10
\ No newline at end of file
eureka.client.serviceUrl.defaultZone = http://172.233.0.7:10500/eureka/
eureka.client.register-with-eureka = false
eureka.client.fetch-registry = false
eureka.client.healthcheck.enabled = false
eureka.instance.hostname = ${spring.cloud.client.ipAddress}
eureka.instance.statusPageUrlPath = ${management.context-path}/info
eureka.instance.healthCheckUrlPath = ${management.context-path}/health
eureka.instance.preferIpAddress = false
eureka.instance.instance-id = ${spring.cloud.client.ipAddress}:${server.port}
eureka.instance.lease-expiration-duration-in-seconds = 10
eureka.instance.lease-renewal-interval-in-seconds = 5
#\u8BF7\u6C42\u5904\u7406\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ReadTimeout = 120000
#\u8BF7\u6C42\u8FDE\u63A5\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ConnectTimeout = 30000
#DB properties:
#spring.datasource.url = jdbc:mysql://172.233.0.6:3306/amos_beijing_command_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.url = jdbc:mysql://localhost:3306/nr_db?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.username = root
spring.datasource.password = root_123
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#JPA Configuration:
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
# Naming strategy
#spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
#mybatis mapper file
mybatis.mapper-locations = classpath:db/mapper/*.xml
# mybatis entity package
mybatis.type-aliases-package = com.yeejoin.amos.fireAutoIntf.business.entity.mybatis
#equipment check
param.protocol.not.check = HTTP
#enable Gzip compression
server.compression.enabled = true
server.compression.mime-types = application/json,application/xml,text/html,text/xml,text/plain\u3001
server.compression.min-response-size = 2048
#liquibase
liquibase.change-log = classpath:/db/changelog/changelog-master.xml
liquibase.enabled: false
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0
# Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=172.16.11.33
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-active=200
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-wait=-1
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.max-idle=10
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.min-idle=0
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=1000
\ No newline at end of file
eureka.client.serviceUrl.defaultZone = http://172.233.0.7:10500/eureka/
eureka.client.register-with-eureka = false
eureka.client.fetch-registry = false
eureka.client.healthcheck.enabled = false
eureka.instance.hostname = ${spring.cloud.client.ipAddress}
eureka.instance.statusPageUrlPath = ${management.context-path}/info
eureka.instance.healthCheckUrlPath = ${management.context-path}/health
eureka.instance.preferIpAddress = false
eureka.instance.instance-id = ${spring.cloud.client.ipAddress}:${server.port}
eureka.instance.lease-expiration-duration-in-seconds = 10
eureka.instance.lease-renewal-interval-in-seconds = 5
#\u8BF7\u6C42\u5904\u7406\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ReadTimeout = 120000
#\u8BF7\u6C42\u8FDE\u63A5\u7684\u8D85\u65F6\u65F6\u95F4
ribbon.ConnectTimeout = 30000
#DB properties:
#spring.datasource.url = jdbc:mysql://172.233.0.6:3306/amos_beijing_command_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.url = jdbc:mysql://localhost:3306/nr_db?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.username = root
spring.datasource.password = root_123
spring.datasource.driver-class-name = com.mysql.jdbc.Driver
#spring.datasource.username = his
#spring.datasource.username = root
#spring.datasource.username = root
#spring.datasource.password = admin_1234
#spring.datasource.password = His@9700
# HikariCP settings
# spring.datasource.hikari.*
# contection life time (ms)
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.jpa.hibernate.ddl-auto=update
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=15
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.idle-timeout=30000
spring.datasource.hikari.pool-name=DatebookHikariCP
spring.datasource.hikari.max-lifetime=1800000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query=SELECT 1
#JPA Configuration:
# Show or not log for each sql query
spring.jpa.show-sql = true
# Hibernate ddl auto (create, create-drop, update): with "update" the database
# schema will be automatically updated accordingly to java entities found in
# the project
# Naming strategy
#spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
# Allows Hibernate to generate SQL optimized for a particular DBMS
spring.jpa.database-platform = org.hibernate.dialect.MySQLDialect
#mybatis mapper file
mybatis.mapper-locations = classpath:db/mapper/*.xml
# mybatis entity package
mybatis.type-aliases-package = com.yeejoin.amos.fireAutoIntf.business.entity.mybatis
#equipment check
param.protocol.not.check = HTTP
#enable Gzip compression
server.compression.enabled = true
server.compression.mime-types = application/json,application/xml,text/html,text/xml,text/plain\u3001
server.compression.min-response-size = 2048
#liquibase
liquibase.change-log = classpath:/db/changelog/changelog-master.xml
liquibase.enabled: false
# Redis\u6570\u636E\u5E93\u7D22\u5F15\uFF08\u9ED8\u8BA4\u4E3A0\uFF09
spring.redis.database=0
# Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=172.16.11.33
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
# Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=
# \u8FDE\u63A5\u6C60\u6700\u5927\u8FDE\u63A5\u6570\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-active=200
# \u8FDE\u63A5\u6C60\u6700\u5927\u963B\u585E\u7B49\u5F85\u65F6\u95F4\uFF08\u4F7F\u7528\u8D1F\u503C\u8868\u793A\u6CA1\u6709\u9650\u5236\uFF09
spring.redis.pool.max-wait=-1
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.max-idle=10
# \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5
spring.redis.pool.min-idle=0
# \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=1000
spring.application.name = YeeAmosIec104Intf
server.port = 9007
#environment
spring.profiles.active=dev
#netty
so.keepalive = true
so.backlog = 128
#redis
params.remoteurl = http://172.16.11.33:8800/
#params.remoteurl = http://172.16.10.74:8800/
params.time = 5
params.period = 1800
\ No newline at end of file
#周期、循环 - 上行
#PERIODIC = 1,
1=周期、循环
#<para>背景扫描 - 上行</para>
#BACKGROUND_SCAN = 2,
2=背景扫描
#突发(自发) - 上行
#SPONTANEOUS = 3,
3=突发(自发)
#初始化 - 上行
#INITIALIZED = 4,
4=初始化
#请求或者被请求 - 上行、下行
#REQUEST = 5,
5=请求或者被请求
#激活 - 下行
#ACTIVATION = 6,
6=激活
#激活确认 - 上行
#ACTIVATION_CON = 7,
7=激活确认
#停止激活 - 下行
#DEACTIVATION = 8,
8=停止激活
# 停止激活确认 - 上行
#DEACTIVATION_CON = 9,
9=停止激活确认
#激活终止 - 下行
#ACTIVATION_TERMINATION = 10,
10=激活结束
#远方命令引起的返送信息 - 上行
#RETURN_INFO_REMOTE = 11,
11=远方命令引起的返送信息
#当地命令引起的返送信息 - 上行
#RETURN_INFO_LOCAL = 12,
12=当地命令引起的返送信息
# 文件传输
#FILE_TRANSFER = 13,
13=文件传输
#AUTHENTICATION = 14,
14=AUTHENTICATION
#MAINTENANCE_OF_AUTH_SESSION_KEY = 15,
15=MAINTENANCE_OF_AUTH_SESSION_KEY
#MAINTENANCE_OF_USER_ROLE_AND_UPDATE_KEY = 16,
16=MAINTENANCE_OF_USER_ROLE_AND_UPDATE_KEY
#响应站召唤 - 上行
#INTERROGATED_BY_STATION = 20,
20=响应站召唤
#响应第 1 组召唤 - 上行
#INTERROGATED_BY_GROUP_1 = 21,
21=响应第 1 组召唤
#响应第 2 组召唤 - 上行
#INTERROGATED_BY_GROUP_2 = 22,
22=响应第 2 组召唤
#响应第 3 组召唤 - 上行
#INTERROGATED_BY_GROUP_3 = 23,
23=响应第 3 组召唤
#响应第 4 组召唤 - 上行
#INTERROGATED_BY_GROUP_4 = 24,
24=响应第 4 组召唤
#响应第 5 组召唤 - 上行
#INTERROGATED_BY_GROUP_5 = 25,
25=响应第 5 组召唤
#响应第 6 组召唤 - 上行
#INTERROGATED_BY_GROUP_6 = 26,
26=响应第 6 组召唤
#响应第 7 组召唤 - 上行
#INTERROGATED_BY_GROUP_7 = 27,
27=响应第 7 组召唤
#响应第 8 组召唤 - 上行
#INTERROGATED_BY_GROUP_8 = 28,
28=响应第 8 组召唤
#响应第 9 组召唤 - 上行
#INTERROGATED_BY_GROUP_9 = 29,
29=响应第 9 组召唤
#响应第 10 组召唤 - 上行
#INTERROGATED_BY_GROUP_10 = 30,
30=响应第 10 组召唤 - 上行
#响应第 11 组召唤 - 上行
#INTERROGATED_BY_GROUP_11 = 31,
31=响应第 11 组召唤 - 上行
#/// 响应第 12 组召唤 - 上行
#INTERROGATED_BY_GROUP_12 = 32,
32=响应第 12 组召唤 - 上行
info=1
expireDate=2018-4-1,
mac=,
ip=,
licenseType=2
<licenseKey>[-57,-28,-8,41,-121,-46,29,-41,-112,-13,63,-66,-26,-101,24,-69]
#周期、循环 - 上行
#PERIODIC = 1,
1=周期、循环
#<para>背景扫描 - 上行</para>
#BACKGROUND_SCAN = 2,
2=背景扫描
#突发(自发) - 上行
#SPONTANEOUS = 3,
3=突发(自发)
#初始化 - 上行
#INITIALIZED = 4,
4=初始化
#请求或者被请求 - 上行、下行
#REQUEST = 5,
5=请求或者被请求
#激活 - 下行
#ACTIVATION = 6,
6=激活
#激活确认 - 上行
#ACTIVATION_CON = 7,
7=激活确认
#停止激活 - 下行
#DEACTIVATION = 8,
8=停止激活
# 停止激活确认 - 上行
#DEACTIVATION_CON = 9,
9=停止激活确认
#激活终止 - 下行
#ACTIVATION_TERMINATION = 10,
10=激活结束
#远方命令引起的返送信息 - 上行
#RETURN_INFO_REMOTE = 11,
11=远方命令引起的返送信息
#当地命令引起的返送信息 - 上行
#RETURN_INFO_LOCAL = 12,
12=当地命令引起的返送信息
# 文件传输
#FILE_TRANSFER = 13,
13=文件传输
#AUTHENTICATION = 14,
14=AUTHENTICATION
#MAINTENANCE_OF_AUTH_SESSION_KEY = 15,
15=MAINTENANCE_OF_AUTH_SESSION_KEY
#MAINTENANCE_OF_USER_ROLE_AND_UPDATE_KEY = 16,
16=MAINTENANCE_OF_USER_ROLE_AND_UPDATE_KEY
#响应站召唤 - 上行
#INTERROGATED_BY_STATION = 20,
20=响应站召唤
#响应第 1 组召唤 - 上行
#INTERROGATED_BY_GROUP_1 = 21,
21=响应第 1 组召唤
#响应第 2 组召唤 - 上行
#INTERROGATED_BY_GROUP_2 = 22,
22=响应第 2 组召唤
#响应第 3 组召唤 - 上行
#INTERROGATED_BY_GROUP_3 = 23,
23=响应第 3 组召唤
#响应第 4 组召唤 - 上行
#INTERROGATED_BY_GROUP_4 = 24,
24=响应第 4 组召唤
#响应第 5 组召唤 - 上行
#INTERROGATED_BY_GROUP_5 = 25,
25=响应第 5 组召唤
#响应第 6 组召唤 - 上行
#INTERROGATED_BY_GROUP_6 = 26,
26=响应第 6 组召唤
#响应第 7 组召唤 - 上行
#INTERROGATED_BY_GROUP_7 = 27,
27=响应第 7 组召唤
#响应第 8 组召唤 - 上行
#INTERROGATED_BY_GROUP_8 = 28,
28=响应第 8 组召唤
#响应第 9 组召唤 - 上行
#INTERROGATED_BY_GROUP_9 = 29,
29=响应第 9 组召唤
#响应第 10 组召唤 - 上行
#INTERROGATED_BY_GROUP_10 = 30,
30=响应第 10 组召唤 - 上行
#响应第 11 组召唤 - 上行
#INTERROGATED_BY_GROUP_11 = 31,
31=响应第 11 组召唤 - 上行
#/// 响应第 12 组召唤 - 上行
#INTERROGATED_BY_GROUP_12 = 32,
32=响应第 12 组召唤 - 上行
soe.time=60
status.time=20
\ No newline at end of file
1=单点信息
3=双点信息
5=步位置信息
7=32比特串
9=测量值,归一化值
11=测量值,标度化值
13=测量值,短浮点数
15=累计量
20=带状态检出的成组单点信息
21=不带品质描述的归一化测量值
30=带时标CP56Time2a的单点信息
31=带时标CP56Time2a的双点信息
32=带时标CP56Time2a的步位置信息
33=带时标CP56Time2a的32比特串
34=带时标CP56Time2a的测量值,归一化值
35=带时标CP56Time2a的测量值,标度化值
36=带时标CP56Time2a的测量值,短浮点数
37=带时标CP56Time2a的累计量
38=带时标CP56Time2a的继电保护装置事件
39=带时标CP56Time2a的继电保护装置成组启动事件
40=带时标CP56Time2a的继电保护装置成组输出电路信息
45=单命令
46=双命令
47=步调节命令
48=设点命令,归一化值
49=设点命令,标度化值
50=设点命令,短浮点数
51=32比特串
58=带时标CP56Time2a的单命令
59=带时标CP56Time2a的双命令
60=带时标CP56Time2a的步调节命令
61=带时标CP56Time2a的设点命令,归一化值
62=带时标CP56Time2a的设点命令,标度化值
63=带时标CP56Time2a的设点命令,短浮点数
64=带时标CP56Time2a的32比特串
100=总召唤命令
101=计数量召唤命令
102=读命令
103=时钟同步命令
105=复位进程命令
107=带时标CP56Time2a的测试命令
<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<include file="i_client_linsten.sql" relativeToChangelogFile="true"/>
<include file="i_transmit_mapper.sql" relativeToChangelogFile="true"/>
</databaseChangeLog>
\ No newline at end of file
/*
Navicat MySQL Data Transfer
Source Server : 172.16.11.33
Source Server Version : 50717
Source Host : 172.16.11.33:3306
Source Database : amos_iec
Target Server Type : MYSQL
Target Server Version : 50717
File Encoding : 65001
Date: 2019-11-07 15:05:38
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for i_client_linsten
-- ----------------------------
DROP TABLE IF EXISTS `i_client_linsten`;
CREATE TABLE `i_client_linsten` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`channle_no` varchar(255) DEFAULT NULL,
`data_type` varchar(255) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for i_ip_port_conf
-- ----------------------------
DROP TABLE IF EXISTS `i_ip_port_conf`;
CREATE TABLE `i_ip_port_conf` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`channel_no` varchar(255) DEFAULT NULL,
`common_address` varchar(255) DEFAULT NULL,
`ip` varchar(255) DEFAULT NULL,
`is_delete` int(11) NOT NULL,
`last_update_time` datetime DEFAULT NULL,
`port` varchar(255) DEFAULT NULL,
`service_id` varchar(255) DEFAULT NULL,
`service_type` varchar(255) DEFAULT NULL,
`name` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4;
-- ----------------------------
-- Table structure for i_point_config
-- ----------------------------
DROP TABLE IF EXISTS `i_point_config`;
CREATE TABLE `i_point_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`channel_no` varchar(255) DEFAULT NULL,
`common_address` bigint(20) DEFAULT NULL,
`invalid` bit(1) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`originator_address` int(11) DEFAULT NULL,
`point_code` varchar(255) DEFAULT NULL,
`remark` varchar(255) DEFAULT NULL,
`value` varchar(255) DEFAULT NULL,
`point_type` varchar(255) DEFAULT NULL,
`point_classify` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2988 DEFAULT CHARSET=utf8mb4;
SET FOREIGN_KEY_CHECKS=1;
/*
Navicat Premium Data Transfer
Source Server : 172.16.11.33
Source Server Type : MySQL
Source Server Version : 50717
Source Host : 172.16.11.33:3306
Source Schema : amos_iec_test
Target Server Type : MySQL
Target Server Version : 50717
File Encoding : 65001
Date: 25/11/2019 19:50:58
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for i_transmit_mapper
-- ----------------------------
DROP TABLE IF EXISTS `i_transmit_mapper`;
CREATE TABLE `i_transmit_mapper` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mapper_id` bigint(20) NULL DEFAULT NULL,
`mapper_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`transmit_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`transmit_port` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`transmit_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`transmit_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of i_transmit_mapper
-- ----------------------------
INSERT INTO `i_transmit_mapper` VALUES (1, 2, 'UART', '172.16.3.3', NULL, 'TCP', '172.16.3.3');
-- ----------------------------
-- Table structure for i_uart_config
-- ----------------------------
DROP TABLE IF EXISTS `i_uart_config`;
CREATE TABLE `i_uart_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`baud_rate` int(11) NOT NULL,
`create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`created_time` datetime(0) NULL DEFAULT NULL,
`data_bits` int(11) NOT NULL,
`is_delete` int(11) NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`parity` int(11) NOT NULL,
`remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`serial_port` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`stop_bits` int(11) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of i_uart_config
-- ----------------------------
INSERT INTO `i_uart_config` VALUES (2, 9600, NULL, NULL, 8, 0, 'COM4', 1, NULL, 'COM4', 1);
INSERT INTO `i_uart_config` VALUES (3, 9600, NULL, NULL, 8, 0, 'COM3', 1, NULL, 'COM3', 1);
SET FOREIGN_KEY_CHECKS = 1;
Wed Mar 1 12:05:10 MST 2006
We forgot to update the Mac OS X binary. Previously, it was an old version
(RXTX-2.1-7pre20). This has now been corrected.
log4j.rootLogger=DEBUG, stdout, logfile
log4j.logger.io.netty=info
log4j.logger.org.hibernate=info
log4j.logger.com.mchange=info
log4j.logger.org.springframework=info
log4j.logger.com.mangofactory=info
log4j.logger.org.apache=info
log4j.logger.com.zaxxer.hikari.pool=info
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %t %-5p [%c{1}:%L] %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=logs/fireAutoIntf.log
log4j.appender.logfile.MaxFileSize=10240KB
log4j.appender.logfile.MaxBackupIndex=30
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d %t %-5p [%c{1}:%L] %m%n
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>package</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>bin</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/config</directory>
<outputDirectory>/config/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/db</directory>
<outputDirectory>/db</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/lib</directory>
<outputDirectory>/lib</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
<include>application-dev.properties</include>
<include>application-prod.properties</include>
<include>application-test.properties</include>
<include>cause.properties</include>
<include>debug.properties</include>
<include>typeId.properties</include>
<include>point.json</include>
<include>soe.json</include>
<include>log4j.properties</include>
<include>META-INF/app.properties</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<scope>runtime</scope>
<!-- <unpack>false</unpack> -->
<excludes>
<!-- <exclude>${project.name}-${project.version}</exclude> -->
<exclude>${groupId}:${artifactId}</exclude>
</excludes>
</dependencySet>
</dependencySets>
</assembly>
\ No newline at end of file
1=单点信息
3=双点信息
5=步位置信息
7=32比特串
9=测量值,归一化值
11=测量值,标度化值
13=测量值,短浮点数
15=累计量
20=带状态检出的成组单点信息
21=不带品质描述的归一化测量值
30=带时标CP56Time2a的单点信息
31=带时标CP56Time2a的双点信息
32=带时标CP56Time2a的步位置信息
33=带时标CP56Time2a的32比特串
34=带时标CP56Time2a的测量值,归一化值
35=带时标CP56Time2a的测量值,标度化值
36=带时标CP56Time2a的测量值,短浮点数
37=带时标CP56Time2a的累计量
38=带时标CP56Time2a的继电保护装置事件
39=带时标CP56Time2a的继电保护装置成组启动事件
40=带时标CP56Time2a的继电保护装置成组输出电路信息
45=单命令
46=双命令
47=步调节命令
48=设点命令,归一化值
49=设点命令,标度化值
50=设点命令,短浮点数
51=32比特串
58=带时标CP56Time2a的单命令
59=带时标CP56Time2a的双命令
60=带时标CP56Time2a的步调节命令
61=带时标CP56Time2a的设点命令,归一化值
62=带时标CP56Time2a的设点命令,标度化值
63=带时标CP56Time2a的设点命令,短浮点数
64=带时标CP56Time2a的32比特串
100=总召唤命令
101=计数量召唤命令
102=读命令
103=时钟同步命令
105=复位进程命令
107=带时标CP56Time2a的测试命令
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>YeeAmosIec104IntfServer</artifactId>
<name>YeeAmosIec104IntfServer</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools.version>6.5.0.Final</drools.version>
</properties>
<parent>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosIec104IntfRoot</artifactId>
<version>1.0.0</version>
</parent>
<dependencies>
<!-- 安全模块jar -->
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>AmosOPService</artifactId>
<version>${YeeOp.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosConnentCommon</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>amos-authtoken</artifactId>
<version>${YeeSecurity.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAmosConnentCommon</artifactId>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/**
*
*/
package com.yeejoin.amos.iec104.business.constants;
import org.apache.log4j.Logger;
import java.text.SimpleDateFormat;
/**
* iot常量
*
* @author as-youjun
*/
public class IEC104Constant {
/**
* 构造方法
*/
private IEC104Constant() {
Logger.getLogger(this.getClass()).debug(IEC104Constant.CONSTRUCTOR);
}
/**
* 网络服务ip
*/
public static final String NET_SERVER_HOST = "0.0.0.0";
/**
* 时间格式(yyyy-MM-dd HH:mm:ss)
*/
public static final SimpleDateFormat SIMPLEDATAFORMAT_YMDHMS = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 构造方法字符串
*/
public static final String CONSTRUCTOR = "constructor...";
/**
* 轮询job最大线程数
*/
public static final int POLLING_JOB_THREAD_MAX_NUM = 20;
/**
* amos线程池数量
*/
public static final int AMOS_THREAD_NUM = 20;
/**
* 设备测试最大线程数
*/
public static final int TEST_EQUIPMENT_THREAD_MAX_NUM = 5;
/**
* 时间格式字符串:yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_TIME_STR_YMDHMS = "yyyy-MM-dd HH:mm:ss";
/**
* bar
*/
public static final String BAR = "-";
/**
* Underline
*/
public static final String UNDERLINE = "_";
/**
* user
*/
public static final String USER = "user";
/**
* token
*/
public static final String TOKEN = "token";
/**
* loginType
*/
public static final String LOGIN_TYPE = "loginType";
/**
* subGraphId
*/
public static final String SUB_GRAPH_ID = "subGraphId";
public static final String ADMIN_ID = "1";
/**
* 帧报文异常
*/
public static final String FRAME_EXECPTION = "FRAME";
/**
* 性能指标
*/
public static final String METRIC = "METRIC";
/**
* 报文通道
*/
public static final String CHANNEL = "CHANNEL";
/**
* 设备状态(掉线)告警
*/
public static final String EQUIPMENT_STATUS = "EQUIPMENT_STATUS";
/**
* 设备连通性告警告警
*/
public static final String EQUIPMENT_CONNECTION = "EQUIPMENT_CONNECTION";
/**
* 通道注册
*/
public static final String REGISTER = "REGISTER";
/**
* 通道注销
*/
public static final String UNREGISTER = "UNREGISTER";
/**
* 报文正常
*/
public static final String NORMAL = "NORMAL";
/**
* 报文异常
*/
public static final String UNNORMAL = "UNNORMAL";
/**
* 告警socket类型
*/
public static final String ALARM_SOCKET = "ALARM_SOCKET";
/**
* 数据socket类型
*/
public static final String METRIC_SOCKET = "METRIC_SOCKET";
/**
* 数据socket类型
*/
public static final String MORPHIC_SOCKET = "MORPHIC_SOCKET";
/**
* false
*/
public static final Boolean FAIL_BOOLEAN_VALUE = Boolean.FALSE;
/**
* 0
*/
public static final Integer ZERO_INT_VALUE = Integer.parseInt("0");
/**
* -1
*/
public static final Integer FAIL_INT_VALUE = Integer.parseInt("-1");
/**
* -1
*/
public static final Long FAIL_LONG_VALUE = Long.parseLong("-1");
/**
* -1
*/
public static final Short FAIL_SHORT_VALUE = Short.parseShort("-1");
/**
*
*/
public static final Float FAIL_FLOAT_VALUE = Float.parseFloat("-1");
/**
* -1
*/
public static final Double FAIL_DOUBLE_VALUE = Double.parseDouble("-1");
/**
* 空格
*/
public static final Character FAIL_CHARACTER_VALUE = Character.valueOf(' ');
/**
* 失败
*/
public static final int FAILURE = 0;
/**
* 成功
*/
public static final int SUCCESS = 1;
/**
* 在线
*/
public static final String ONLINE = "在线";
/**
* 掉线
*/
public static final String OFFLINE = "掉线";
/**
* 通
*/
public static final String OPEN = "通";
/**
* 不通
*/
public static final String OFF = "不通";
/**
* ip
*/
public static final String IP = "ip";
/**
* #
*/
public static final String SHARP = "#";
/**
* 设备相关常量
*
* @author as-youjun
*/
public static final class EquipmentConstant {
/**
* 下划线
*/
public static final String UNDERLINE = "_";
/**
* 设备属性key前缀
*/
public static final String KEY_PREFIX_EQUIP = "equip_";
/**
* 能力属性key前缀
*/
public static final String KEY_PREFIX_CPBL = "cpbl_";
/**
* 接口属性key前缀
*/
public static final String KEY_PREFIX_INTFC = "intfc_";
/**
* 测试设备标识
*/
public static final String TEST_EQUIPMENT = "test_equipment";
/**
* 选择接口key
*/
public static final String KEY_SELINTFCIDS = "selIntfcIds";
/**
* 选择能力key
*/
public static final String KEY_SELCPBLIDS = "selCpblIds";
/**
* 测试接口标识
*/
public static final String CONNECT = "connect";
/**
* 测试指标标识
*/
public static final String METRIC = "metric";
/**
* 测试接口key
*/
public static final String CONNECTDATA = "connectData";
/**
* 测试指标key
*/
public static final String METRICDATA = "metricData";
/**
* sourceId
*/
public static final String SOURCEID = "sourceId";
/**
* frameType
*/
public static final String FRAMETYPE = "frameType";
/**
* labelType
*/
public static final String LABELTYPE = "labelType";
/**
* quotaSelected
*/
public static final String QUOTASELECTED = "quotaSelected";
/**
* eqpId设备id
*/
public static final String EQPID = "eqpId";
/**
* 设备连通性判断时长:超过eqp_connected_time_span毫秒的缓存数据无效!!!
*/
public static final long EQP_CONNECTED_TIME_SPAN = 120000;//2分钟
}
/**
* TCP
*/
public static final String TCP = "TCP";
public static final String PIE_CHAR = "pieChar";
public static final String BAR_CHAR = "barChar";
public static final String HBAR_CHAR = "hbarChar";
public static final String LINE_CHAR = "lineChar";
public static final String DOUGHUNT_CHAR = "doughuntChar";
public static final String ROSE_CHAR = "roseChar";
public static final String AREA_CHAR = "areaChar";
public static final String DIMENSION = "dimension";
public static final String MEASURE = "measure";
public static final String ALARM_MESSAGE = "alarm";
public static final String GENERAL_MESSAGE = "general";
}
package com.yeejoin.amos.iec104.business.controller;
import java.util.HashMap;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.security.authorization.Authorization;
import com.yeejoin.amos.security.common.remote.RemoteSecurityServer;
import com.yeejoin.amos.security.entity.User;
import springfox.documentation.annotations.ApiIgnore;
/**
* 基础控制器
*
* @author
*
*/
@ApiIgnore
@RestController
@RequestMapping("/base")
@Authorization
public class BaseController {
@Autowired
private RemoteSecurityServer remoteSecurityServer;
@Autowired
protected HttpServletRequest request;
/**
* 成功返回状态
*/
protected static final String SUCCESS = "SUCCESS";
/**
* 失败返回状态
*/
protected static final String FAILED = "FAILED";
/**
* 默认页大小
*/
protected static final int DEFAULT_PAGE_SIZE = 10;
protected String getToken()
{
/* Get token from header */
String authToken = request.getHeader("X-Access-Token");
/* If token not found get it from request parameter */
if (authToken == null)
{
authToken = request.getParameter("token");
}
return authToken;
}
/**
*
* <pre>
* 判断当前用户角色级别:true:主管/false:装备管理员
* </pre>
*
* @return
*/
protected boolean isDirector()
{
if(getUserInfo() == null){
return false;
}
return getUserInfo().getRole().getRoleType() != 3;
}
/**
* 获取用户角色id
* @return
*/
protected String getRoleId()
{
if(getUserInfo() == null){
return "";
}
return getUserInfo().getRole().getRoleType().toString();
}
/**
* 当前登录用户信息
*/
protected User getUserInfo() {
if(getToken() == null){
return null;
}
return remoteSecurityServer.loginAuthentication(getToken());
}
protected Long getUserId()
{
Long userId = null;
if (getUserInfo() != null)
{
userId = getUserInfo().getId();
}
return userId;
}
/**
* 获取当前用户所属公司名称
* @return
*/
protected String getCurrentCompanyNameOfUser(){
if(getUserInfo() == null){
return "";
}
return getUserInfo().getCompany().getCompanyName();
}
/**
* 获取请求的cookies
* @return
*/
protected HashMap<String,String> getCookInfoMap(){
HashMap<String,String> map = new HashMap<String,String>();
Cookie[] cookies = request.getCookies();
if(cookies!=null){
for(Cookie ck:cookies){
map.put(ck.getName(), ck.getValue());
}
}
return map;
}
/**
* 获取公司orgcode
* @return
*/
protected String getOrgCode(){
if(getUserInfo() == null){
return "";
}
return getUserInfo().getCompany().getCompCode();
}
}
package com.yeejoin.amos.iec104.business.controller;
import java.util.Date;
import com.yeejoin.amos.connect.dao.entity.ClientListenVo;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iec104.business.param.ClientParam;
import com.yeejoin.amos.iec104.business.service.intfc.IClientListenService;
import com.yeejoin.amos.iec104.business.service.intfc.IConfService;
import com.yeejoin.amos.iec104.tcp.TcpServer;
import com.yeejoin.amos.iec104.tcp.client.IEC104ClientManager;
import com.yeejoin.amos.iec104.utils.NetUtil;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.authorization.Authorization;
import io.swagger.annotations.Api;
@RestController
@RequestMapping(value = "/iec")
@Api(tags="客户端api")
public class ClientController extends BaseController{
private final Logger log = LoggerFactory.getLogger(ClientController.class);
@Autowired
IEC104ClientManager clientManager;
@Autowired
IConfService confService;
@Autowired
IClientListenService clientListenService;
@Autowired
TcpServer tcpServer;
@PostMapping(value="/create",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse createClient(@RequestBody ClientParam client) {
try {
String no = confService.getMaxNo();
ConfigVo vo = new ConfigVo();
vo.setIp(client.getIp());
vo.setPort(client.getPort());
vo.setCommonAddress(client.getCommonAddress());
vo.setIsDelete(0);
vo.setLastUpdateTime(new Date());
vo.setServiceType(client.getServiceType());
vo.setServiceId(String.format("S%06d", Integer.valueOf(no)+1));
vo.setChannelNo(String.format("N%06d", Integer.valueOf(no)+1));
vo.setName(client.getName());
if ("IEC_CLIENT".equals(vo.getServiceType())) {
if (NetUtil.isLoclePortUsing(Integer.valueOf(client.getPort()))) {
return CommonResponseUtil.failure("端口已经被占用");
}
}
confService.add(vo);
if ("IEC_SERVER".equals(vo.getServiceType())) {
clientManager.createClient(vo.getIp(), vo.getPort(), vo.getCommonAddress());
} else if ("IEC_CLIENT".equals(vo.getServiceType())) {
tcpServer.createIecService(vo.getId(), vo.getPort());
}
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("创建客户端失败");
}
}
@PostMapping(value="/save",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse save(@RequestBody ConfigVo vo) {
try {
if (ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.failure("参数错误");
}
if ("IEC_SERVER".equals(vo.getServiceType()) && !ObjectUtils.isEmpty(vo.getId())) {
clientManager.closeClient(vo.getIp(), vo.getPort());
}
ConfigVo oldVo = confService.getServerById(vo.getId());
confService.add(vo);
if ("IEC_SERVER".equals(vo.getServiceType())) {
clientManager.createClient(vo.getIp(), vo.getPort(), vo.getCommonAddress());
}
if ("IEC_CLIENT".equals(vo.getServiceType())) {
if (oldVo.getPort().equals(vo.getPort())) {
tcpServer.closeIecService(vo.getId());
tcpServer.createIecService(vo.getId(), vo.getPort());
} else {
if (NetUtil.isLoclePortUsing(Integer.valueOf(vo.getPort()))) {
return CommonResponseUtil.failure("端口已经被占用");
}
tcpServer.createIecService(vo.getId(), vo.getPort());
}
}
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("创建客户端失败");
}
}
@GetMapping(value="/getAllClient",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse getAllClients() {
try {
return CommonResponseUtil.success(confService.getServerByType("IEC_CLIENT"));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("创建客户端失败");
}
}
@GetMapping(value="/getAllService",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse getAllService() {
try {
return CommonResponseUtil.success(confService.getServerByType("IEC_SERVER"));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("创建客户端失败");
}
}
@GetMapping(value="/client/{serviceId}",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse getService(@PathVariable("serviceId") String serviceId) {
try {
return CommonResponseUtil.success(confService.getServerByServiceId(serviceId));
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("客户端详情获取失败");
}
}
@GetMapping(value="/subscriber/{serviceId}",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse getSubscriber(@PathVariable("serviceId") String serviceId) {
try {
return CommonResponseUtil.success(clientListenService.getDataByServiceId(serviceId));
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure(e.getMessage());
}
}
@PostMapping(value="/subscriber/add",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse addSubscriber(@RequestBody ClientListenVo listener) {
try {
clientListenService.add(listener);
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure(e.getMessage());
}
}
@DeleteMapping(value="/subscriber/delete/{id}",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse deleteSubscriber(@PathVariable("id") Long id) {
try {
clientListenService.del(id);
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure(e.getMessage());
}
}
@PutMapping(value="/subscriber/update",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse updateSubscriber(@RequestBody ClientListenVo listener) {
try {
clientListenService.add(listener);
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure(e.getMessage());
}
}
@PostMapping(value="/close",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse closeClient(@RequestBody ConfigVo vo) {
try {
confService.delete(vo.getId());
clientManager.closeClient(vo.getIp(), vo.getPort());
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("关闭客户端失败");
}
}
@DeleteMapping(value="/delete/{id}",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse deleteClient(@PathVariable("id") Long id) {
try {
ConfigVo vo = confService.findById(id);
if ("IEC_SERVER".equals(vo.getServiceType())) {
clientManager.closeClient(vo.getIp(), vo.getPort());
} else {
tcpServer.closeIecService(vo.getId());
}
confService.delete(id);
return CommonResponseUtil.success();
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure(e.getMessage());
}
}
@PostMapping(value="/reset",produces = "application/json;charset=UTF-8")
@Authorization(ingore=true)
public CommonResponse reset() {
try {
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("关闭客户端失败");
}
}
}
package com.yeejoin.amos.iec104.business.controller;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.yeejoin.amos.iec104.business.param.PointParam;
import com.yeejoin.amos.iec104.business.service.intfc.IConfService;
import com.yeejoin.amos.iec104.business.service.intfc.IPointConfigService;
import com.yeejoin.amos.iec104.tcp.server.session.Session;
import com.yeejoin.amos.iec104.tcp.server.session.SessionManager;
import com.yeejoin.amos.iec104.utils.ExcelUtils;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.authorization.Authorization;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping(value = "/point")
@Api(tags="转发表配置")
public class PointController extends BaseController{
private final Logger log = LoggerFactory.getLogger(PointController.class);
@Autowired
private IConfService confService;
@Autowired
private IPointConfigService pointConfigService;
/**
* 巡检点状态发生变化
*
* @param ids
* @return
*/
// @ApiOperation(value = "巡检点状态发生变化", notes = "巡检点状态发生变化")
// @PostMapping(value = "/noticePointChange", produces = "application/json;charset=UTF-8")
// @Authorization(ingore=true)
// public CommonResponse noticePointChange(@ApiParam(value = "巡检点ID", required = true)@RequestBody(required = false) List<Long> ids) {
// try {
// log.debug("巡检点ID pointId======="+ids);
// if (ObjectUtils.isEmpty(ids)) {
// return CommonResponseUtil.failure("巡检点ID不可以为空");
// }
// return CommonResponseUtil.success();
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// return CommonResponseUtil.failure("消息通知失败");
// }
// }
@ApiOperation(value = "导出模板", notes = "导出模板")
@RequestMapping(value = "/export/model", method = RequestMethod.GET)
@Authorization(ingore=true)
public CommonResponse exportModel(HttpServletResponse response) {
List<PointConfigVo> list = new ArrayList<>();
list.add(new PointConfigVo());
try {
ExcelUtils.writeExcel(response, null, PointConfigVo.class);
} catch (Exception e) {
e.printStackTrace();
}
return CommonResponseUtil.success();
}
@ApiOperation(value = "导入转发表", notes = "导入转发表")
@RequestMapping(value = "/import", method = RequestMethod.POST)
@Authorization(ingore=true)
public CommonResponse importClientPoint(@RequestParam(value="file", required = false) MultipartFile file, @RequestParam("serviceId") String serviceId,@RequestParam("pointType") String pointType) {
if (ObjectUtils.isEmpty(serviceId)) {
return CommonResponseUtil.success();
}
ConfigVo vo = confService.getServerByServiceId(serviceId);
List<PointConfigVo> list = ExcelUtils.readExcel("", PointConfigVo.class, file);
list.forEach(
b -> {
b.setChannelNo(vo.getChannelNo());
b.setPointType(pointType);
}
);
pointConfigService.save(list);
return CommonResponseUtil.success();
}
@ApiOperation(value = "导入转发表", notes = "导入转发表")
@RequestMapping(value = "/delete/{serviceId}", method = RequestMethod.DELETE)
@Authorization(ingore=true)
public CommonResponse deleteClientPoint(@PathVariable("serviceId") String serviceId) {
if (ObjectUtils.isEmpty(serviceId)) {
return CommonResponseUtil.success();
}
ConfigVo vo = confService.getServerByServiceId(serviceId);
pointConfigService.deleteByChannelNo(vo.getChannelNo());
return CommonResponseUtil.success();
}
// @ApiOperation(value = "导入转发表", notes = "导入转发表")
// @RequestMapping(value = "/service/import", method = RequestMethod.POST)
// @Authorization(ingore=true)
// public CommonResponse importServicePoint(@RequestParam(value="uploadFile", required = false) MultipartFile file, @RequestParam("serviceId") String serviceId,@RequestParam("pointType") String pointType) {
// ConfigVo vo = confService.getServerByTypeAndServiceId("IEC_SERVER", serviceId);
// List<PointConfigVo> list = ExcelUtils.readExcel("", PointConfigVo.class, file);
//
// list.forEach(
// b -> {
// b.setChannelNo(vo.getChannelNo());
// b.setPointType(pointType);
// }
// );
// pointConfigService.save(list);
// return CommonResponseUtil.success();
// }
@ApiOperation(value = "根据通道编码获取摇信点数据", notes = "根据通道编码获取点数据")
@RequestMapping(value = "/yx/{serviceId}", method = RequestMethod.GET)
@Authorization(ingore=true)
public CommonResponse getYxPointByChannelNo(@PathVariable("serviceId") String serviceId) {
if (ObjectUtils.isEmpty(serviceId)) {
return CommonResponseUtil.success();
}
ConfigVo vo = confService.getServerByServiceId(serviceId);
if (ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.success();
}
return CommonResponseUtil.success(pointConfigService.getAllYXPointData(vo.getChannelNo()));
}
@ApiOperation(value = "根据通道编码获取摇信点数据", notes = "根据通道编码获取点数据")
@RequestMapping(value = "/pointType/{serviceId}", method = RequestMethod.GET)
@Authorization(ingore=true)
public CommonResponse getYxPointType(@PathVariable("serviceId") String serviceId) {
if (ObjectUtils.isEmpty(serviceId)) {
return CommonResponseUtil.success();
}
ConfigVo vo = confService.getServerByServiceId(serviceId);
if (ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.failure("没有相关服务接口");
}
List<String> list = pointConfigService.getYcPointType(vo.getChannelNo());
return CommonResponseUtil.success(list);
}
@ApiOperation(value = "根据通道编码获取遥测点数据", notes = "根据通道编码获取点数据")
@RequestMapping(value = "/yc/{serviceId}", method = RequestMethod.GET)
@Authorization(ingore=true)
public CommonResponse getYcPointByChannelNo(@PathVariable("serviceId") String serviceId) {
if (ObjectUtils.isEmpty(serviceId)) {
return CommonResponseUtil.success();
}
ConfigVo vo = confService.getServerByServiceId(serviceId);
if (ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.success();
}
return CommonResponseUtil.success(pointConfigService.getAllYCPointData(vo.getChannelNo()));
}
@ApiOperation(value = "触发告警", notes = "触发告警")
@RequestMapping(value = "/trigger/soe", method = RequestMethod.PUT)
@Authorization(ingore=true)
public CommonResponse triggerSOE(@RequestBody PointParam point) {
log.info(point.toString());
PointConfigVo vo = pointConfigService.findPointByPointCode(point.getPointCode());
if(ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.failure("該點位不存在");
}
if ("yc".equals(vo.getPointType())) {
return CommonResponseUtil.failure("該點位為遙測點位");
}
vo.setValue(point.getValue());
// ConfigVo config = confService.getServerByChannleNoId(vo.getChannelNo());
Collection<Session> c = SessionManager.getInstance().getClients();
for (Session s : c) {
s.addSOE(vo);
s.addSEC(vo);
}
pointConfigService.updatePoint(vo);
return CommonResponseUtil.success(vo);
}
@ApiOperation(value = "触发变位", notes = "触发变位")
@RequestMapping(value = "/trigger/sec", method = RequestMethod.PUT)
@Authorization(ingore=true)
public CommonResponse triggerSEC(@RequestBody PointParam point) {
log.info(point.toString());
PointConfigVo vo = pointConfigService.findPointByPointCode(point.getPointCode());
if(ObjectUtils.isEmpty(vo)) {
return CommonResponseUtil.failure("該點位不存在");
}
vo.setValue(point.getValue());
// ConfigVo config = confService.getServerByChannleNoId(vo.getChannelNo());
Collection<Session> c = SessionManager.getInstance().getClients();
for (Session s : c) {
s.addSEC(vo);
}
pointConfigService.updatePoint(vo);
return CommonResponseUtil.success(vo);
}
}
package com.yeejoin.amos.iec104.business.dao.repository;
import java.io.Serializable;
import java.util.List;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* 基础dao
*
* @param <T>
* @param <ID>
*/
@NoRepositoryBean
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, CrudRepository<T, ID>,
PagingAndSortingRepository<T, ID>, JpaSpecificationExecutor<T> {
public default T getOneBySpecification(Specification<T> specification) {
List<T> list = findAll(specification);
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
}
package com.yeejoin.amos.iec104.business.dao.repository;
import com.yeejoin.amos.connect.dao.entity.ClientListenVo;
import org.springframework.stereotype.Repository;
@Repository("iClientListenDao")
public interface IClientListenDao extends BaseDao<ClientListenVo, Long>{
}
package com.yeejoin.amos.iec104.business.dao.repository;
import java.util.List;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository("iPointConfigDao")
public interface IPointConfigDao extends BaseDao<PointConfigVo, Long> {
List<PointConfigVo> findAllByChannelNoAndPointType(String channelNo, String pointType);
@Update(value="delete from PointConfigVo where channelNo=?1")
void deleteAllByChannelNo(String channelNo);
@Query(value="select pointClassify from PointConfigVo where channelNo=?1 group by pointClassify")
List<String> getYcPointType(String channelNo);
@Query(value="select new com.yeejoin.amos.connect.dao.entity.PointConfigVo(p.id, p.commonAddress, p.originatorAddress, p.pointType, p.pointClassify, p.invalid, p.channelNo, p.name, p.pointCode ) from PointConfigVo p , ConfigVo c where p.channelNo=c.channelNo and c.serviceId=?1 and p.originatorAddress=?2 and p.pointClassify=?3")
PointConfigVo findOneByServicesIdAndInfoAddress(String serviceId, int address, String pointType);
PointConfigVo findOneByPointCode(String pointCode);
}
package com.yeejoin.amos.iec104.business.dao.repository;
import java.util.List;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
@Repository("iServiceConfDao")
public interface IServiceConfDao extends BaseDao<ConfigVo, Long>{
List<ConfigVo> findAllByServiceType(String serviceType);
ConfigVo findOneByServiceTypeAndPort(String serviceType, String port);
ConfigVo findOneByServiceTypeAndServiceId(String serviceType, String serverId);
@Query(value="select max(id) from ConfigVo")
String findMaxId();
ConfigVo findOneByServiceId(String serviceId);
}
package com.yeejoin.amos.iec104.business.entity.mybatis;
import java.util.Date;
public class RecData {
private int commonAddress;
private int informationAddress;
private String value;
private int DataType;
private Date createdTime;
private Date occurTime;
private String quality;
private int soe;
private long equitpmentPointId;
private String equitpmentPointName;
private long equitmentId;
private String equitmentName;
private String pointUnit;
private int isBlocked;
private int isSubstituted;
private int isNotTopical;
private int isInvalid;
private int isOverflow;
private String type;
private String serverId;
private String pointCode;
public RecData() {};
public RecData(String serverId) {
this.serverId = serverId;
}
public String getPointCode() {
return pointCode;
}
public void setPointCode(String pointCode) {
this.pointCode = pointCode;
}
public String getServerId() {
return serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
}
public int getCommonAddress() {
return commonAddress;
}
public void setCommonAddress(int commonAddress) {
this.commonAddress = commonAddress;
}
public int getInformationAddress() {
return informationAddress;
}
public void setInformationAddress(int informationAddress) {
this.informationAddress = informationAddress;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getDataType() {
return DataType;
}
public void setDataType(int dataType) {
DataType = dataType;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Date getOccurTime() {
return occurTime;
}
public void setOccurTime(Date occurTime) {
this.occurTime = occurTime;
}
public String getQuality() {
return quality;
}
public void setQuality(String quality) {
this.quality = quality;
}
public int getSoe() {
return soe;
}
public void setSoe(int soe) {
this.soe = soe;
}
public long getEquitpmentPointId() {
return equitpmentPointId;
}
public void setEquitpmentPointId(long equitpmentPointId) {
this.equitpmentPointId = equitpmentPointId;
}
public String getEquitpmentPointName() {
return equitpmentPointName;
}
public void setEquitpmentPointName(String equitpmentPointName) {
this.equitpmentPointName = equitpmentPointName;
}
public long getEquitmentId() {
return equitmentId;
}
public void setEquitmentId(long equitmentId) {
this.equitmentId = equitmentId;
}
public int getIsBlocked() {
return isBlocked;
}
public void setIsBlocked(int isBlocked) {
this.isBlocked = isBlocked;
}
public int getIsSubstituted() {
return isSubstituted;
}
public void setIsSubstituted(int isSubstituted) {
this.isSubstituted = isSubstituted;
}
public int getIsNotTopical() {
return isNotTopical;
}
public void setIsNotTopical(int isNotTopical) {
this.isNotTopical = isNotTopical;
}
public int getIsInvalid() {
return isInvalid;
}
public void setIsInvalid(int isInvalid) {
this.isInvalid = isInvalid;
}
public int getIsOverflow() {
return isOverflow;
}
public void setIsOverflow(int isOverflow) {
this.isOverflow = isOverflow;
}
public String getPointUnit() {
return pointUnit;
}
public void setPointUnit(String pointUnit) {
this.pointUnit = pointUnit;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return "RecData [commonAddress=" + commonAddress + ", informationAddress=" + informationAddress + ", value="
+ value + ", DataType=" + DataType + ", createdTime=" + createdTime + ", occurTime=" + occurTime
+ ", quality=" + quality + ", soe=" + soe + ", equitpmentPointId=" + equitpmentPointId
+ ", equitpmentPointName=" + equitpmentPointName + ", equitmentId=" + equitmentId + ", pointUnit="
+ pointUnit + ", isBlocked=" + isBlocked + ", isSubstituted=" + isSubstituted + ", isNotTopical="
+ isNotTopical + ", isInvalid=" + isInvalid + ", isOverflow=" + isOverflow + ", type=" + type + "]";
}
public String getEquitmentName() {
return equitmentName;
}
public void setEquitmentName(String equitmentName) {
this.equitmentName = equitmentName;
}
}
package com.yeejoin.amos.iec104.business.param;
public class AlarmParam {
private String informationAddress; //转发码
private int soe;
private String state; // 值
private String serviceId; //服务ID
private int isInvalid; // 是否有效
private String pointCode;
public int getSoe() {
return soe;
}
public void setSoe(int soe) {
this.soe = soe;
}
public String getPointCode() {
return pointCode;
}
public void setPointCode(String pointCode) {
this.pointCode = pointCode;
}
public String getState() {
return state;
}
public String getInformationAddress() {
return informationAddress;
}
public void setInformationAddress(String informationAddress) {
this.informationAddress = informationAddress;
}
public void setState(String state) {
this.state = state;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public int getIsInvalid() {
return isInvalid;
}
public void setIsInvalid(int isInvalid) {
this.isInvalid = isInvalid;
}
@Override
public String toString() {
return "AlarmParam [informationAddress=" + informationAddress + ", soe=" + soe + ", state=" + state
+ ", serviceId=" + serviceId + ", isInvalid=" + isInvalid + ", pointCode=" + pointCode + "]";
}
}
package com.yeejoin.amos.iec104.business.param;
public class ClientParam {
private String name;
private String ip;
private String port;
private String commonAddress;
private String serviceType;
private String serviceId;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPort() {
return port;
}
public void setPort(String port) {
this.port = port;
}
public String getCommonAddress() {
return commonAddress;
}
public void setCommonAddress(String commonAddress) {
this.commonAddress = commonAddress;
}
public String getServiceType() {
return serviceType;
}
public void setServiceType(String serviceType) {
this.serviceType = serviceType;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package com.yeejoin.amos.iec104.business.param;
public class PacketParam {
private String type;
private String date;
private String conent;
private String serviceId;
private String packateType;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getConent() {
return conent;
}
public void setConent(String conent) {
this.conent = conent;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getPackateType() {
return packateType;
}
public void setPackateType(String packateType) {
this.packateType = packateType;
}
}
package com.yeejoin.amos.iec104.business.param;
public class PointParam {
private String pointCode;
private String value;
public String getPointCode() {
return pointCode;
}
public void setPointCode(String pointCode) {
this.pointCode = pointCode;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
return "PointParam [pointCode=" + pointCode + ", value=" + value + "]";
}
}
package com.yeejoin.amos.iec104.business.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import com.yeejoin.amos.connect.dao.entity.ClientListenVo;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.springframework.web.client.RestTemplate;
import com.yeejoin.amos.iec104.business.dao.repository.IClientListenDao;
import com.yeejoin.amos.iec104.business.dao.repository.IServiceConfDao;
import com.yeejoin.amos.iec104.business.param.AlarmParam;
import com.yeejoin.amos.iec104.business.service.intfc.IClientListenService;
@Service
public class ClientListenServiceImpl implements IClientListenService {
@Autowired
IClientListenDao iClientListenDao;
@Autowired
private IServiceConfDao iServiceConfDao;
@Override
@Transactional
public void del(Long id) {
iClientListenDao.delete(id);
}
@Override
@Transactional
public void add(ClientListenVo vo) {
iClientListenDao.save(vo);
}
@Override
public ClientListenVo findById(Long id) {
return iClientListenDao.findOne(id);
}
@Override
public void edit(ClientListenVo vo) {
}
@Override
public ClientListenVo findOne(ClientListenVo vo) {
return iClientListenDao.findOne(getSpecification(vo));
}
@Override
public List<ClientListenVo> findAll(ClientListenVo vo) {
return iClientListenDao.findAll(getSpecification(vo));
}
@Override
public void sendDatas(String dataType, LinkedList<AlarmParam> params) {
List<ConfigVo> clinets = iServiceConfDao.findAllByServiceType("IEC_SERVER");
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
for (ConfigVo c : clinets) {
HashMap<String, Object> param = new HashMap<>();
param.put("dataType", dataType);
param.put("channleNo", c.getChannelNo());
List<ClientListenVo> clientList = iClientListenDao.findAll(getSpecification(param));
for (ClientListenVo vo : clientList) {
if (ObjectUtils.isEmpty(vo.getUrl())) {
continue;
}
LinkedList<AlarmParam> list = filter(params, (p) -> p.getServiceId().equals(c.getServiceId()));
HttpEntity<LinkedList<AlarmParam>> request = new HttpEntity<>(list, headers);
try {
restTemplate.postForEntity( vo.getUrl(), request , String.class );
} catch (Exception e) {
}
}
}
}
public static LinkedList<AlarmParam> filter(List<AlarmParam> clints, java.util.function.Predicate<AlarmParam> condition) {
LinkedList<AlarmParam> results = new LinkedList<AlarmParam>();
for (AlarmParam c : clints) {
if(condition.test(c)) {
results.add(c);
}
}
return results;
}
@Override
public void sendData(String dataType, String channelNo, AlarmParam params) {
RestTemplate restTemplate = new RestTemplate();
HashMap<String, Object> param = new HashMap<>();
param.put("dataType", dataType);
param.put("channleNo", channelNo);
List<ClientListenVo> clientList = iClientListenDao.findAll(getSpecification(param));
for (ClientListenVo vo : clientList) {
if (ObjectUtils.isEmpty(vo.getUrl())) {
continue;
}
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<AlarmParam> request = new HttpEntity<>(params, headers);
try {
Logger.getLogger(this.getClass()).debug("send "+dataType+" data to " + vo.getUrl() + " . param is" + params.toString());
restTemplate.postForEntity( vo.getUrl(), request , String.class );
// restTemplate.postForEntity( "http://172.16.10.183:8083/api/risksource/data/fireqeuiment/soe", request , String.class );
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* 根据任务id构建查询任务回复信息查询条件
* @param
* @return Specification
*/
private Specification getSpecification(ClientListenVo vo) {
return new Specification<ClientListenVo>() { // 构建查询条件
@Override
public Predicate toPredicate(Root<ClientListenVo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicate = new ArrayList<>();
if (!ObjectUtils.isEmpty(vo.getChannleNo())) {
predicate.add(cb.equal(root.get("channleNo").as(String.class), vo.getChannleNo()));
}
if (!ObjectUtils.isEmpty(vo.getDataType())) {
predicate.add(cb.equal(root.get("dataType").as(String.class), vo.getDataType()));
}
if (!ObjectUtils.isEmpty(vo.getUrl())) {
predicate.add(cb.equal(root.get("url").as(String.class), vo.getUrl()));
}
Predicate[] pre = new Predicate[predicate.size()];
return query.where(predicate.toArray(pre)).getRestriction();
}
};
}
private Specification getSpecification(Map<String, Object> param) {
return new Specification<ClientListenVo>() { // 构建查询条件
@Override
public Predicate toPredicate(Root<ClientListenVo> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
List<Predicate> predicate = new ArrayList<>();
for (String key: param.keySet()) {
predicate.add(cb.equal(root.get(key).as(String.class), param.get(key)+""));
}
Predicate[] pre = new Predicate[predicate.size()];
return query.where(predicate.toArray(pre)).getRestriction();
}
};
}
@Override
public List<ClientListenVo> getDataByServiceId(String serviceId) {
ConfigVo vo = iServiceConfDao.findOneByServiceId(serviceId);
HashMap<String, Object> param = new HashMap<>();
param.put("channleNo", vo.getChannelNo());
return iClientListenDao.findAll(getSpecification(param));
}
}
package com.yeejoin.amos.iec104.business.service.impl;
import java.util.List;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yeejoin.amos.iec104.business.dao.repository.IServiceConfDao;
import com.yeejoin.amos.iec104.business.service.intfc.IConfService;
@Service
public class ConfServiceImpl implements IConfService {
@Autowired
private IServiceConfDao iServiceConfDao;
@Override
public void add(ConfigVo vo) {
iServiceConfDao.save(vo);
}
@Override
public void delete(Long id) {
iServiceConfDao.delete(id);
}
@Override
public List<ConfigVo> getServerByType(String type) {
return iServiceConfDao.findAllByServiceType(type);
}
@Override
public void updateServer(ConfigVo vo) {
iServiceConfDao.save(vo);
}
@Override
public ConfigVo getServerByPort(String port) {
return iServiceConfDao.findOneByServiceTypeAndPort("IEC_CLIENT",port);
}
@Override
public ConfigVo getServerByTypeAndServiceId(String type, String serverId) {
return iServiceConfDao.findOneByServiceTypeAndServiceId(type,serverId);
}
@Override
public String getMaxNo() {
return iServiceConfDao.findMaxId();
}
@Override
public ConfigVo getServerByServiceId(String serviceId) {
return iServiceConfDao.findOneByServiceId(serviceId);
}
@Override
public ConfigVo getServerById(Long id) {
return iServiceConfDao.findOne(id);
}
@Override
public ConfigVo findById(Long id) {
return iServiceConfDao.findOne(id);
}
@Override
public ConfigVo getServerByChannleNoId(String channelNo) {
// TODO Auto-generated method stub
return null;
}
}
package com.yeejoin.amos.iec104.business.service.impl;
import java.util.HashMap;
import java.util.List;
import javax.annotation.PostConstruct;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iec104.business.dao.repository.IPointConfigDao;
import com.yeejoin.amos.iec104.business.service.intfc.IPointConfigService;
@Service
public class PointConfigServiceImpl implements IPointConfigService{
@Autowired
private IPointConfigDao iPointConfigDao;
@Autowired
private RedisTemplate redisTemplate;
// @Override
// public List<PointConfigVo> getAllPointData(String channelNo) {
// return iPointConfigDao.findAllByChannelNo(channelNo);
// }
@Override
public List<PointConfigVo> getAllYXPointData(String channelNo) {
return iPointConfigDao.findAllByChannelNoAndPointType(channelNo, "yx");
}
@Override
public List<PointConfigVo> getAllYCPointData(String channelNo) {
return iPointConfigDao.findAllByChannelNoAndPointType(channelNo, "yc");
}
@Override
@Transactional
public void save(List<PointConfigVo> list) {
iPointConfigDao.save(list);
}
@Override
@Transactional
public void deleteByChannelNo(String channelNo) {
iPointConfigDao.deleteAllByChannelNo(channelNo);
}
@Override
public List<String> getYcPointType(String channelNo) {
return iPointConfigDao.getYcPointType(channelNo);
}
@Override
public PointConfigVo findByServicesIdAndInfoAddress(String serviceId, int address) {
String pointType = "";
if (address < 0x4000) {
pointType = "yx";
} else {
pointType = "yc";
address = address - 0x4000;
}
Pageable pageable = new PageRequest(0, 1);
return findPointfromRedis(serviceId+pointType+address);
// return iPointConfigDao.findOneByServicesIdAndInfoAddress(serviceId, address, pointType);
}
@Override
@PostConstruct
public void loadRedisData() {
HashMap<String, PointConfigVo> map = new HashMap<String, PointConfigVo>();
long count = iPointConfigDao.count();
for (int i = 0; i < (count/100000 + 1); i++) {
//分页信息
Pageable pageable = new PageRequest(i, 100000*(i+1));
iPointConfigDao.findAll().stream().forEach((PointConfigVo v) -> {
map.put(v.getChannelNo().replace("N", "S") + v.getPointType() +v.getOriginatorAddress(), v);
});
redisTemplate.opsForHash().putAll("pointConfig", map);
}
}
@Override
public PointConfigVo findPointfromRedis(String key) {
return (PointConfigVo) redisTemplate.opsForHash().get("pointConfig", key);
}
@Override
public PointConfigVo findPointByPointCode(String pointCode) {
return iPointConfigDao.findOneByPointCode(pointCode);
}
@Override
public void updatePoint(PointConfigVo vo) {
String key = vo.getChannelNo().replace("N", "S") + vo.getPointType() +vo.getOriginatorAddress();
redisTemplate.opsForHash().put("pointConfig", key, vo);
iPointConfigDao.save(vo);
}
}
package com.yeejoin.amos.iec104.business.service.intfc;
import java.util.LinkedList;
import java.util.List;
import com.yeejoin.amos.connect.dao.entity.ClientListenVo;
import com.yeejoin.amos.iec104.business.param.AlarmParam;
public interface IClientListenService {
public void del(Long id);
public void add(ClientListenVo vo);
public ClientListenVo findById(Long id);
public void edit(ClientListenVo vo);
public ClientListenVo findOne(ClientListenVo vo);
public List<ClientListenVo> findAll(ClientListenVo vo);
public void sendDatas(String dataType, LinkedList<AlarmParam> params);
public void sendData(String dataType, String channelNo,AlarmParam params);
public List<ClientListenVo> getDataByServiceId(String serviceId);
}
package com.yeejoin.amos.iec104.business.service.intfc;
import com.yeejoin.amos.connect.dao.entity.ConfigVo;
import java.util.List;
public interface IConfService {
public void add(ConfigVo vo);
public void delete(Long id);
public List<ConfigVo> getServerByType(String type);
public void updateServer(ConfigVo vo);
public ConfigVo getServerByPort(String port);
public ConfigVo getServerByTypeAndServiceId(String string, String serverId);
public String getMaxNo();
public ConfigVo getServerByServiceId(String serviceId);
public ConfigVo getServerById(Long id);
public ConfigVo findById(Long id);
public ConfigVo getServerByChannleNoId(String channelNo);
}
package com.yeejoin.amos.iec104.business.service.intfc;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import java.util.List;
public interface IPointConfigService {
// public List<PointConfigVo> getAllPointData(String channelNo);
public List<PointConfigVo> getAllYXPointData(String channelNo);
public List<PointConfigVo> getAllYCPointData(String channelNo);
public void save(List<PointConfigVo> list);
public void deleteByChannelNo(String channelNo);
public List<String> getYcPointType(String channelNo);
public PointConfigVo findByServicesIdAndInfoAddress(String serviceId, int address);
public void loadRedisData();
public PointConfigVo findPointfromRedis(String key);
public PointConfigVo findPointByPointCode(String pointCode);
public void updatePoint(PointConfigVo vo);
}
package com.yeejoin.amos.iec104.business.service.intfc;
import java.util.List;
public interface IPointService {
void noticePointChange(List<Long> ids);
void noticePointChangeTest();
void syncPointStatus();
}
package com.yeejoin.amos.iec104.context;
import java.lang.reflect.Method;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
@Configuration
@EnableCaching
public class CacheConfig extends CachingConfigurerSupport {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private int port;
@Value("${spring.redis.timeout}")
private int timeout;
@Value("${spring.redis.database}")
private int database;
@Value("${spring.redis.password}")
private String password;
/**
* 键的生成策略
* @return
* 规则:目标类名称+方法名+参数名
*/
@Bean
public KeyGenerator wiselyKeyGenerator() {
return new KeyGenerator() {
@Override
public Object generate(Object target, Method method, Object... params) {
StringBuilder sb = new StringBuilder();
sb.append(target.getClass().getName());
sb.append(method.getName());
for (Object obj : params) {
sb.append(obj.toString());
}
return sb.toString();
}
};
}
@Bean
public JedisConnectionFactory redisConnectionFactory() {
JedisConnectionFactory factory = new JedisConnectionFactory();
factory.setHostName(host);
factory.setPort(port);
factory.setTimeout(timeout);
factory.setDatabase(database);
factory.setPassword(password);
return factory;
}
/**
* 配置CacheManager 管理cache
* @param redisTemplate
* @return
*/
@Bean
public CacheManager cacheManager(RedisTemplate redisTemplate) {
RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
cacheManager.setDefaultExpiration(60*60); // 设置key-value超时时间
return cacheManager;
}
@Bean
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<Object, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值
Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
}
/**
*
*/
package com.yeejoin.amos.iec104.context;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import com.yeejoin.amos.iec104.business.constants.IEC104Constant;
/**
* iot-spring上下文
*
* @author as-youjun
*
*/
public class FireAutoIntfContext {
/**
* 实例
*/
private static FireAutoIntfContext instance;
/**
* spring上下文
*/
private ApplicationContext applicationContext;
/**
* 构造方法
*/
private FireAutoIntfContext() {
Logger.getLogger(this.getClass()).debug(IEC104Constant.CONSTRUCTOR);
}
/**
* 获取单例
*
* @return
*/
public static synchronized FireAutoIntfContext getInstance() {
if (instance == null) {
instance = new FireAutoIntfContext();
}
return instance;
}
/**
* 设置上下文
*
* @param applicationContext
*/
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
/**
* 获取上下文
*
* @param beanName
* @return
*/
public Object getBean(String beanName) {
return applicationContext.getBean(beanName);
}
/**
* 获取上下文
*
* @param requiredType
* @return
*/
public Object getBean(Class<?> requiredType) {
return applicationContext.getBean(requiredType);
}
}
package com.yeejoin.amos.iec104.context;
import javax.annotation.PostConstruct;
import org.springframework.stereotype.Component;
import com.yeejoin.amos.iec104.core.util.DateUtil;
import com.yeejoin.amos.op.core.entity.BusinessEntity;
import com.yeejoin.amos.op.core.entity.handler.EntityHandler;
import com.yeejoin.amos.op.core.entity.handler.EntityListener;
import com.yeejoin.amos.security.context.CurrentAuthentication;
/**
*
* <pre>
* 实体变化
* </pre>
*
* @author as-chenjiajun
* @version $Id: FireAutoIntfEntityHandler.java, v 0.1 2018年5月29日 下午3:42:41 as-chenjiajun Exp $
*/
@Component
public class FireAutoIntfEntityHandler extends EntityHandler
{
@PostConstruct
private void init()
{
EntityListener.addModelHandler(this);
}
public void prePersist(BusinessEntity model)
{
model.setCreateUser(CurrentAuthentication.getAuthenticatedUserId());
model.setCreateDate(DateUtil.getCurrentDate());
}
public void preUpdate(BusinessEntity model)
{
model.setUpdateUser(CurrentAuthentication.getAuthenticatedUserId());
model.setUpdateDate(DateUtil.getCurrentDate());
}
}
package com.yeejoin.amos.iec104.context;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class LoadDataUtil implements CommandLineRunner{
@Override
public void run(String... arg0) throws Exception {
}
}
package com.yeejoin.amos.iec104.context;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
//@Configuration
//@AutoConfigureAfter(RedisAutoConfiguration.class)
public class RedisConfig {
// @Bean
// @SuppressWarnings("all")
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
template.setConnectionFactory(factory);
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jackson2JsonRedisSerializer.setObjectMapper(om);
StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
// key采用String的序列化方式
template.setKeySerializer(stringRedisSerializer);
// hash的key也采用String的序列化方式
template.setHashKeySerializer(stringRedisSerializer);
// value序列化方式采用jackson
template.setValueSerializer(jackson2JsonRedisSerializer);
// hash的value序列化方式采用jackson
template.setHashValueSerializer(jackson2JsonRedisSerializer);
template.afterPropertiesSet();
return template;
}
}
package com.yeejoin.amos.iec104.core.common.datastructure;
import java.util.List;
/**
*
* <pre>
* 树节点
* </pre>
*
* @author as-chenjiajun
* @version $Id: TreeNode.java, v 0.1 2018年3月8日 下午5:36:46 as-chenjiajun Exp $
*/
public class TreeNode
{
//数据库数据ID
private Long sourceId;
//界面key
private String key;
//界面父节点key
private String parentKey;
//显示名称
private String title;
//子节点
private List<TreeNode> children;
//值
private String value;
public TreeNode(String key, String title, String parentKey)
{
this.key = key;
this.title = title;
this.parentKey = parentKey;
this.value = title;
}
public TreeNode(String key, String title, TreeNode parent)
{
this.key = key;
this.title = title;
this.parentKey = parent.getParentKey();
this.value = title;
}
public String getKey()
{
return key;
}
public void setKey(String key)
{
this.key = key;
}
public String getParentKey()
{
return parentKey;
}
public void setParentKey(String parentKey)
{
this.parentKey = parentKey;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public List<TreeNode> getChildren()
{
return children;
}
public void setChildren(List<TreeNode> children)
{
this.children = children;
}
public Long getSourceId()
{
return sourceId;
}
public void setSourceId(Long sourceId)
{
this.sourceId = sourceId;
}
public String getValue()
{
return value;
}
public void setValue(String value)
{
this.value = value;
}
}
package com.yeejoin.amos.iec104.core.common.request;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
/**
*
* <pre>
* 分页实体
* </pre>
*
* @author as-chenjiajun
* @version $Id: CommonPageable.java, v 0.1 2016-12-14 上午10:42:44 as-chenjiajun
* Exp $
*/
public class CommonPageable implements Pageable {
/**
* 页号(大于等于0)
*/
protected int pageNumber = 0;
/**
* 每页大小(大于等于0)
*/
protected int pageSize = 10;
/**
* 起始索引
*/
protected int offset = 0;
/**
* 排序
*/
protected Sort sort = null;
public CommonPageable() {
this.pageNumber = 0;
this.pageSize = 10;
this.offset = pageSize * pageNumber;
}
public CommonPageable(int pageNumber, int pageSize) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.offset = pageSize * pageNumber;
}
public CommonPageable(int pageNumber, int pageSize, Sort sort) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
this.sort = sort;
this.offset = pageSize * pageNumber;
}
public int getPageNumber() {
return this.pageNumber;
}
public int getPageSize() {
return pageSize;
}
public int getOffset() {
offset = pageSize * pageNumber;
return offset;
}
public Sort getSort() {
return sort;
}
public Pageable next() {
return null;
}
public Pageable previousOrFirst() {
return null;
}
public Pageable first() {
return null;
}
public boolean hasPrevious() {
return false;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public void setSort(Sort sort) {
this.sort = sort;
}
public void setOffset(int offset) {
this.offset = offset;
}
}
package com.yeejoin.amos.iec104.core.common.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* <pre>
* 公共请求对象
* </pre>
*
* @author as-shibaobao
* @version $Id: CommonRequest.java, v 0.1 2018年1月26日 上午10:59:19 as-shibaobao Exp $
*/
@ApiModel
public class CommonRequest {
/**
* 字段名称
*/
@ApiModelProperty(value="字段名称",required=true)
private String name;
/**
* 字段值
*/
@ApiModelProperty(value="字段值",required=true)
private Object value;
/**
* 查询类型
*/
@ApiModelProperty(value="查询类型",notes="空值时,默认为等于;其它类型按QueryOperatorEnum",required=false)
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.amos.iec104.core.common.response;
import java.util.List;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
/**
* <pre>
* 分页数据
* </pre>
*
* @author as-youjun
* @version $Id: CompanyPage.java, v 0.1 2017年4月13日 上午11:35:25 as-youjun Exp $
*/
public final class CommonPage<T> extends PageImpl<T> {
/**
* <pre>
* uid
* </pre>
*/
private static final long serialVersionUID = -5533124806408380886L;
/**
*
*/
private String message;
/**
* 返回结果状态
*/
private String result;
public CommonPage(List<T> content, Pageable pageable, long total) {
super(content, pageable, total);
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getResult()
{
return result;
}
public void setResult(String result)
{
this.result = result;
}
}
package com.yeejoin.amos.iec104.core.enums;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.enums.ValuedEnum;
/**
* 操作枚举
*
* @author as-youjun
*
*/
@SuppressWarnings("all")
public final class QueryOperatorEnum extends ValuedEnum {
private static final long serialVersionUID = -375127751242109017L;
public static final int LESS_VALUE = 1; // 小于
public static final int BIGGER_VALUE = 2; // 大于
public static final int EQUAL_VALUE = 3; // 等于
public static final int LESS_EQUAL_VALUE = 4; // 小于等于
public static final int BIGGER_EQUAL_VALUE = 5; // 大于等于
public static final int NOT_EQUAL_VALUE = 6; // 不等于
public static final int IN_VALUE = 7; // 包含
public static final int LIKE_VALUE = 8; // like
public static final int OR_VALUE = 9; // 或者
public static final int ORDER_VALUE = 10; // 排序
public static final int NOT_IN_VALUE = 11; // 不包含
public static final int IS_VALUE= 12; //是
public static final QueryOperatorEnum LESS = new QueryOperatorEnum("LESS", 1, "<");
public static final QueryOperatorEnum BIGGER = new QueryOperatorEnum("BIGGER", 2, ">");
public static final QueryOperatorEnum EQUAL = new QueryOperatorEnum("EQUAL", 3, "=");
public static final QueryOperatorEnum LESS_EQUAL = new QueryOperatorEnum("LESS_EQUAL", 4, "<=");
public static final QueryOperatorEnum BIGGER_EQUAL = new QueryOperatorEnum("BIGGER_EQUAL", 5, ">=");
public static final QueryOperatorEnum NOT_EQUAL = new QueryOperatorEnum("NOT_EQUAL", 6, "<>");
public static final QueryOperatorEnum IN = new QueryOperatorEnum("IN", 7, "IN");
public static final QueryOperatorEnum LIKE = new QueryOperatorEnum("LIKE", 8, "LIKE");
public static final QueryOperatorEnum OR = new QueryOperatorEnum("OR", 9, "OR");
public static final QueryOperatorEnum ORDER_BY = new QueryOperatorEnum("ORDER BY", 10, "ORDER BY");
public static final QueryOperatorEnum NOT_IN = new QueryOperatorEnum("NOT IN", 11, "NOT IN");
public static final QueryOperatorEnum IS = new QueryOperatorEnum("IS", 12, "IS");
public String condition;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
protected QueryOperatorEnum(String arg0, int arg1, String condition) {
super(arg0, arg1);
this.condition = condition;
}
public static QueryOperatorEnum getEnum(String name) {
try {
return ((QueryOperatorEnum) getEnum(QueryOperatorEnum.class, name));
} catch (Exception ex) {
return null;
}
}
public static QueryOperatorEnum getEnum(int name) {
try {
return ((QueryOperatorEnum) getEnum(QueryOperatorEnum.class, name));
} catch (Exception ex) {
return null;
}
}
public static Map getMap() {
try {
return getEnumMap(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
public static List getList() {
try {
return getEnumList(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
public static Iterator iterator() {
try {
return iterator(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
}
package com.yeejoin.amos.iec104.core.listener;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
/**
*
* <pre>
* 配置信息获取
* </pre>
*
* @author as-chenjiajun
* @version $Id: PortConfigListener.java, v 0.1 2018年3月14日 下午3:10:15 as-chenjiajun Exp $
*/
@Component
public class PortConfigListener implements ApplicationListener<EmbeddedServletContainerInitializedEvent>
{
/**
* 服务器端口号
*/
private int serverPort;
@Override
public void onApplicationEvent(
EmbeddedServletContainerInitializedEvent event)
{
this.serverPort = event.getEmbeddedServletContainer().getPort();
}
public int getServerPort()
{
return serverPort;
}
}
package com.yeejoin.amos.iec104.core.threadpool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.log4j.Logger;
import com.yeejoin.amos.iec104.business.constants.IEC104Constant;
/**
* 线程池
*/
public class AmosThreadPool {
/**
* 日志记录器
*/
private static final Logger logger = Logger
.getLogger(AmosThreadPool.class);
/**
* 单例
*/
private static AmosThreadPool instance;
/**
* 执行服务
*/
private static ExecutorService executorService;
/**
* 获取单例
*
* @return
*/
public static AmosThreadPool getInstance() {
if (instance == null) {
synchronized (AmosThreadPool.class) {
if (instance == null) {
instance = new AmosThreadPool();
}
}
}
return instance;
}
static {
executorService = Executors
.newFixedThreadPool(IEC104Constant.AMOS_THREAD_NUM);
}
/**
* 执行线程
*
* @param task
*/
public void execute(Runnable task) {
executorService.execute(task);
}
}
package com.yeejoin.amos.iec104.core.util;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
/**
*
* <pre>
* 日期
* </pre>
*
* @author as-chenjiajun
* @version $Id: DateUtil.java, v 0.1 2018年1月29日 下午5:08:40 as-chenjiajun Exp $
*/
public class DateUtil
{
private static String LONG_PATTERN = "yyyy-MM-dd HH:mm:ss";
private static String MID_PATTERN = "yyyy-MM-dd HH:mm";
private static String SHORT_PATTERN = "yyyy-MM-dd";
public static long THREE_DAY_MILLSEC = 259200000L;
public static long ONE_DAY_MILLSEC = 86400000L;
public static long ONE_HOUR_MILLSEC = 3600000L;
public static long THREE_HOURS_MILLSEC = 10800000L;
public static long TWELVE_HOURS_MILLSEC = 43200000L;
public static Date EMPTY_DATE = null;
static
{
Calendar calendar = Calendar.getInstance();
calendar.set(9999, 0, 0);
EMPTY_DATE = calendar.getTime();
}
/**
*
* <pre>
* 获取当前北京时间
* </pre>
*
* @return
*/
public static Date getCurrentDate()
{
return getCurrentCalendar().getTime();
}
public static String getLongCurrentDate()
{
return new SimpleDateFormat(LONG_PATTERN)
.format(getCurrentCalendar().getTime());
}
public static String getLongDate(Date date)
{
if (null == date)
return getLongCurrentDate();
else
return new SimpleDateFormat(LONG_PATTERN).format(date);
}
public static String getLongDate(long value)
{
return new SimpleDateFormat(LONG_PATTERN).format(new Date(value));
}
public static String getShortCurrentDate()
{
return new SimpleDateFormat(SHORT_PATTERN).format(new Date());
}
public static String getShortDate(Date date)
{
if (null == date)
return getShortCurrentDate();
else
return new SimpleDateFormat(SHORT_PATTERN).format(date);
}
public static String getShortDate(long value)
{
return new SimpleDateFormat(SHORT_PATTERN).format(new Date(value));
}
public static Date getShortCurrentDate(String shortDateStr) throws ParseException
{
return new SimpleDateFormat(SHORT_PATTERN).parse(shortDateStr);
}
public static Date getLongDate(String longDateStr) throws ParseException
{
return new SimpleDateFormat(LONG_PATTERN).parse(longDateStr);
}
public static String getMidCurrentDate()
{
return new SimpleDateFormat(MID_PATTERN).format(new Date());
}
public static String getMidDate(Date date)
{
if (null == date)
return getMidCurrentDate();
else
return new SimpleDateFormat(MID_PATTERN).format(new Date());
}
public static String getMidDate(long value)
{
return new SimpleDateFormat(MID_PATTERN).format(new Date(value));
}
public static Date str2Date(String strDate, String dateFormat)
{
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
public static int getYear(Date date)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
return year;
}
public static int getMonth(Date date)
{
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;
return month;
}
public static int getDay(Date date)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
int day = c.get(Calendar.DATE);
return day;
}
public static int getHour(Date date)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
int hour = c.get(Calendar.HOUR_OF_DAY);
return hour;
}
public static int getMinite(Date date)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
int minite = c.get(Calendar.MINUTE);
return minite;
}
/**
*
* <pre>
* 获取当前北京时间
* </pre>
*
* @return
*/
public static Calendar getCurrentCalendar()
{
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
return Calendar.getInstance();
}
/**
*
* <pre>
* 获取当前两个时间差
* </pre>
*
* @return
*/
public static String getTimeDifference(Date dateBefore, Date dateAfter )
{
long l=dateAfter.getTime()-dateBefore.getTime();
long day=l/(24*60*60*1000);
long hour=(l/(60*60*1000)-day*24);
long min=((l/(60*1000))-day*24*60-hour*60);
long s=(l/1000-day*24*60*60-hour*60*60-min*60);
return ""+day+"天"+hour+"小时"+min+"分"+s+"秒";
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment