main
wenhua.zhou 2 years ago
parent 6806673b96
commit 1d39ab3c93

@ -0,0 +1,113 @@
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xydl</groupId>
<artifactId>mqtt</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.1</version>
<relativePath/>
</parent>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- MQTT依赖 -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.1</version>
</dependency>
<!--mysql驱动依赖-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<!-- 阿里巴巴JSON -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.31_noneautotype</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</dependency>
<!--mybatis-plus相关依赖-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.10</version>
</dependency>
<!--数据连接池druid-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,18 @@
package com.xydl;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@MapperScan(basePackages = "com.xydl.mapper")
@SpringBootApplication//标识该类为主程序启动类
public class MqttApplication {
//主程序启动方法
public static void main(String[] args) {
SpringApplication.run(MqttApplication.class,args);
}
}

@ -0,0 +1,15 @@
package com.xydl.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class DruidConfig {
@ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DruidDataSource getDurid(){
return new DruidDataSource();
}
}

@ -0,0 +1,20 @@
package com.xydl.config;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MyBatisConfig {
public ConfigurationCustomizer configurationCustomizer(){
return new ConfigurationCustomizer() {
@Override
public void customize(MybatisConfiguration configuration) {
//下划线与驼峰命名进行自动映射
configuration.setMapUnderscoreToCamelCase(true);
}
};
}
}

@ -0,0 +1,44 @@
package com.xydl.controller;
import com.xydl.util.DataSourceUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.sql.DataSource;
import java.sql.*;
@RestController
public class JDBCController {
private static final Logger logger = LoggerFactory.getLogger(DataSourceUtils.class);
@RequestMapping("/data")
public void getData() {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = DataSourceUtils.getConnection();
String sql = "insert into pop_id(node_id,id) values(?,?)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "");
pstmt.setInt(2, 100);
pstmt.executeUpdate();
} catch (Exception e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(pstmt, conn);
}
}
}

@ -0,0 +1,26 @@
package com.xydl.controller;
import com.xydl.model.Eia;
import com.xydl.service.EiaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
@Controller
public class TestController {
@Autowired
private EiaService eiaService;
@RequestMapping("/eia")
@ResponseBody
public List<Eia> eia() {
System.out.println("get eia");
return eiaService.getEia();
}
}

@ -0,0 +1,21 @@
package com.xydl.mapper;
import com.xydl.model.Eaif;
import com.xydl.model.Epa;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface EaifMapper {
//红外测温
List<Eaif> getEaif();
}

@ -0,0 +1,21 @@
package com.xydl.mapper;
import com.xydl.model.Eia;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface EiaMapper {
//铁芯、夹件、电容性设备
List<Eia> getEia();
}

@ -0,0 +1,34 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.SuperModel;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface EpaMapper {
//油色谱
List<Epa> getEpa(int devid);
List<SuperModel> getData(String sql);
List<Integer> getEqmidsByTableName(String tableName);
List<String> getTableNamesBySyncTable(String syncTable);
String getSqlBySyncTable(String syncTable, String tableName);
}

@ -0,0 +1,21 @@
package com.xydl.mapper;
import com.xydl.model.Etp;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface EtpMapper {
//绕组测温
List<Etp> getEtp();
}

@ -0,0 +1,24 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Microclimate;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface MicMapper {
//微气象
List<Microclimate> getMicroclimate();
}

@ -0,0 +1,24 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Moa;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface MoaMapper {
//绝缘监测-金属氧化物
List<Moa> getMoa();
}

@ -0,0 +1,25 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Pd;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface PdMapper {
//局放监测
List<Pd> getPd();
}

@ -0,0 +1,24 @@
package com.xydl.mapper;
import com.xydl.model.Eia;
import com.xydl.model.Epa;
import com.xydl.model.Etp;
import com.xydl.model.RptTemper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface RptTemperMapper {
//测温点
List<RptTemper> getRptTemper();
}

@ -0,0 +1,25 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Scur;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface ScurMapper {
//电缆环流
List<Scur> getScur();
}

@ -0,0 +1,22 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Sf6;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface Sf6Mapper {
//SF6监测
List<Sf6> getSf6();
}

@ -0,0 +1,22 @@
package com.xydl.mapper;
import com.xydl.model.Epa;
import com.xydl.model.Sf6env;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Mapper
@Repository
public interface Sf6envMapper {
//SF6环境
List<Sf6env> getSf6env();
}

@ -0,0 +1,30 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Eaif {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String captureTime;
@JsonProperty("MaxTmp")
private double maxTemp;
@JsonProperty("MinTmp")
private double minTemp;
@JsonProperty("AvgTmp")
private double avgTemp;
}

@ -0,0 +1,33 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.Date;
@Data
public class Eia {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String captureTime;
@JsonProperty("MaxTmp")
private String maxTemp;
@JsonProperty("MinTmp")
private String minTemp;
@JsonProperty("AvgTmp")
private String avgTemp;
@JsonProperty("Phase")
private String phase;
}

@ -0,0 +1,65 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
/*
*/
@Data
public class Epa {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime ;
@JsonProperty("H2")
private double h2ppm;
@JsonProperty("CH4")
private double ch4ppm;
@JsonProperty("C2H6")
private double c2h6ppm;
@JsonProperty("C2H4")
private double c2h4ppm;
@JsonProperty("C2H2")
private double c2h2ppm;
@JsonProperty("CO")
private double coppm;
@JsonProperty("CO2")
private double co2ppm;
@JsonProperty("O2")
private double o2ppm;
@JsonProperty("N2")
private double n2ppm;
@JsonProperty("TotalHydrocarbon")
private double totalHydroCarbon;
@JsonProperty("GasPress")
private double gaspress;
@JsonProperty("H2O")
private double h2oppm;
@JsonProperty("Phase")
private String phase;
}

@ -0,0 +1,33 @@
package com.xydl.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Etp {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("MaxTmp")
private double t1;
}

@ -0,0 +1,42 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Microclimate {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("AirTemperature")
private double envTmp;
@JsonProperty("AirPressure")
private double envPres;
@JsonProperty("Humidity")
private double envHum;
@JsonProperty("Precipitation")
private double rnfll;
@JsonProperty("PrecipitationIntensity")
private double PreciInten = 0;
@JsonProperty("RadiationIntensity")
private double radiInten = 0;
}

@ -0,0 +1,36 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Moa {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String captureTime;
@JsonProperty("SystemVoltage")
private double pt1;
@JsonProperty("TotalCurrent")
private double lc1;
@JsonProperty("ResistiveCurrent")
private double rc1;
@JsonProperty("ActionCount")
private double ligcnt1;
@JsonProperty("LastActionTime")
private String lastligtm1;
}

@ -0,0 +1,30 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Pd {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("DischargeCapacity")
private double waveForm;
@JsonProperty("DischargePosition")
private double apppadsch;
@JsonProperty("PulseCount")
private double plsNum;
}

@ -0,0 +1,42 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class RptTemper {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String createTime;
@JsonProperty("OlTmpA")
private double aoTemper;
@JsonProperty("OlTmpB")
private double boTemper;
@JsonProperty("OlTmpC")
private double coTemper;
@JsonProperty("IlTmpA")
private double aiTemper;
@JsonProperty("IlTmpB")
private double biTemper;
@JsonProperty("IlTmpC")
private double ciTemper;
@JsonProperty("OntologyTmp")
private double boxTemper;
}

@ -0,0 +1,22 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Scur {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("CoreCurrent")
private double currentVal;
}

@ -0,0 +1,35 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Sf6 {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("Temperature")
private double temp1;
@JsonProperty("Pressure20C")
private double pressure1;
@JsonProperty("AbsolutePressure")
private double AbsolutePressure = pressure1 + 900;
@JsonProperty("Density")
private double md1;
@JsonProperty("Moisture")
private double pm1;
}

@ -0,0 +1,43 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.util.Date;
@Data
public class Sf6env {
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime;
@JsonProperty("gas1")
private double gas1;
@JsonProperty("yq1")
private double yq1;
@JsonProperty("md1")
private double md1;
@JsonProperty("pm1")
private double pm1;
@JsonProperty("gascnt1")
private double gascnt1;
@JsonProperty("hmcnt1")
private double hmcnt1;
@JsonProperty("sf6warn1")
private double sf6warn1;
@JsonProperty("o2warn1")
private double o2warn1;
}

@ -0,0 +1,231 @@
package com.xydl.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class SuperModel {
/**
* EPA
*/
@JsonProperty("SubDeviceID")
private String subDeviceID;
@JsonProperty("SensorCode")
private String sensorId;
@JsonProperty("AcquisitionTime")
private String dTime ;
@JsonProperty("H2")
private double h2ppm;
@JsonProperty("CH4")
private double ch4ppm;
@JsonProperty("C2H6")
private double c2h6ppm;
@JsonProperty("C2H4")
private double c2h4ppm;
@JsonProperty("C2H2")
private double c2h2ppm;
@JsonProperty("CO")
private double coppm;
@JsonProperty("CO2")
private double co2ppm;
@JsonProperty("O2")
private double o2ppm;
@JsonProperty("N2")
private double n2ppm;
@JsonProperty("TotalHydrocarbon")
private double totalHydroCarbon;
@JsonProperty("GasPress")
private double gaspress;
@JsonProperty("H2O")
private double h2oppm;
@JsonProperty("Phase")
private String phase;
/**
* Eaif
*/
// @JsonProperty("AcquisitionTime")
// private String captureTime;
@JsonProperty("MaxTmp")
private double maxTemp;
@JsonProperty("MinTmp")
private double minTemp;
@JsonProperty("AvgTmp")
private double avgTemp;
/**
* Eia
*/
/**
* Etp
*/
// @JsonProperty("MaxTmp")
// private double t1;
/**
* Microclimate
*/
@JsonProperty("AirTemperature")
private double envTmp;
@JsonProperty("AirPressure")
private double envPres;
@JsonProperty("Humidity")
private double envHum;
@JsonProperty("Precipitation")
private double rnfll;
@JsonProperty("PrecipitationIntensity")
private double PreciInten = 0;
@JsonProperty("RadiationIntensity")
private double radiInten = 0;
/**
* Moa
*/
@JsonProperty("SystemVoltage")
private double pt1;
@JsonProperty("TotalCurrent")
private double lc1;
@JsonProperty("ResistiveCurrent")
private double rc1;
@JsonProperty("ActionCount")
private double ligcnt1;
@JsonProperty("LastActionTime")
private String lastligtm1;
/**
* Pd
*/
@JsonProperty("DischargeCapacity")
private double waveForm;
@JsonProperty("DischargePosition")
private double apppadsch;
@JsonProperty("PulseCount")
private double plsNum;
/**
* RptTemper
*/
// @JsonProperty("AcquisitionTime")
// private String createTime;
@JsonProperty("OlTmpA")
private double aoTemper;
@JsonProperty("OlTmpB")
private double boTemper;
@JsonProperty("OlTmpC")
private double coTemper;
@JsonProperty("IlTmpA")
private double aiTemper;
@JsonProperty("IlTmpB")
private double biTemper;
@JsonProperty("IlTmpC")
private double ciTemper;
@JsonProperty("OntologyTmp")
private double boxTemper;
/**
* Scur
*/
@JsonProperty("CoreCurrent")
private double currentVal;
/**
* Sf6
*/
@JsonProperty("Temperature")
private double temp1;
@JsonProperty("Pressure20C")
private double pressure1;
@JsonProperty("AbsolutePressure")
private double AbsolutePressure = pressure1 + 900;
@JsonProperty("Density")
private double md1Sf6;
@JsonProperty("Moisture")
private double pm1Sf6;
/**
* Sf6env
*/
@JsonProperty("gas1")
private double gas1;
@JsonProperty("yq1")
private double yq1;
@JsonProperty("md1")
private double md1;
@JsonProperty("pm1")
private double pm1;
@JsonProperty("gascnt1")
private double gascnt1;
@JsonProperty("hmcnt1")
private double hmcnt1;
@JsonProperty("sf6warn1")
private double sf6warn1;
@JsonProperty("o2warn1")
private double o2warn1;
}

@ -0,0 +1,33 @@
package com.xydl.service;
import com.xydl.model.*;
import java.util.List;
import java.util.Map;
public interface EiaService {
List<Eaif> getEaif();
List<Eia> getEia();
void getEpa();
List<Etp> getEtp();
List<Microclimate> getMic();
List<Moa> getMoa();
List<Pd> getPd();
List<RptTemper> getRptTemper();
List<Scur> getScur();
List<Sf6> getSf6();
List<Sf6env> getSf6env();
}

@ -0,0 +1,438 @@
package com.xydl.service.impl;
import com.xydl.mapper.*;
import com.xydl.model.*;
import com.xydl.service.EiaService;
import com.xydl.util.CommonUtils;
import com.xydl.util.DataSourceUtils;
import com.xydl.util.FormatUtil;
import com.xydl.util.MqttUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
@Service
public class EiaServiceImpl implements EiaService {
private static final Logger logger = LoggerFactory.getLogger(EiaServiceImpl.class);
private static final String SYNC_TABLE = "sync_tables_info";
@Autowired
private EaifMapper eaifMapper;
@Autowired
private EpaMapper epaMapper;
@Autowired
private EiaMapper eiaMapper;
@Autowired
private EtpMapper etpMapper;
@Autowired
private MicMapper micMapper;
@Autowired
private MoaMapper moaMapper;
@Autowired
private PdMapper pdMapper;
@Autowired
private RptTemperMapper rptTemperMapper;
@Autowired
private ScurMapper scurMapper;
@Autowired
private Sf6Mapper sf6Mapper;
@Autowired
private Sf6envMapper sf6envMapper;
@Override
public List<Eaif> getEaif() {
return eaifMapper.getEaif();
//
}
@Override
public List<Eia> getEia() {
return eiaMapper.getEia();
}
@Override
public void getEpa() {
List<String> tableNames = epaMapper.getTableNamesBySyncTable(SYNC_TABLE);
// for(String tableName : tableNames){
// System.out.println(tableName);
// List<Integer> eqmids = epaMapper.getEqmidsByTableName(tableName);
// for(int eqmid : eqmids){
// List<Epa> epas = epaMapper.getEpa(eqmid);
// String jsonStringEpa = FormatUtil.list2Json(epas);
// MqttUtil.publish2MQTT(jsonStringEpa);
// }
// }
for(String tableName : tableNames){
String sql = epaMapper.getSqlBySyncTable(SYNC_TABLE,tableName);
List<Integer> eqmids = epaMapper.getEqmidsByTableName(tableName);
if(sql.contains("?")){
for(int eqmid : eqmids){
String newSql = sql.replaceAll("\\?",eqmid+"");
List<SuperModel> epas = epaMapper.getData(newSql);
String jsonStringEpa = FormatUtil.list2Json(epas);
MqttUtil.publish2MQTT(jsonStringEpa);
}
}
}
}
@Override
public List<Etp> getEtp() {
return etpMapper.getEtp();
}
@Override
public List<Microclimate> getMic() {
return micMapper.getMicroclimate();
}
@Override
public List<Moa> getMoa() {
return moaMapper.getMoa();
}
@Override
public List<Pd> getPd() {
return pdMapper.getPd();
}
@Override
public List<RptTemper> getRptTemper() {
return rptTemperMapper.getRptTemper();
}
@Override
public List<Scur> getScur() {
return scurMapper.getScur();
}
@Override
public List<Sf6> getSf6() {
return sf6Mapper.getSf6();
}
@Override
public List<Sf6env> getSf6env() {
return sf6envMapper.getSf6env();
}
public List<String> getAllTableName() {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List<String> tableNames = new ArrayList<>();
try {
conn = DataSourceUtils.getConnection();
String sql = "select DISTINCT table_name from sync_tables_info";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
tableNames.add(rs.getString("table_name"));
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return tableNames;
}
public Map<String,String> getFieldMap(String tableName) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Map<String,String> fieldsMap = new HashMap<>();
try {
conn = DataSourceUtils.getConnection();
String sql = "select sync_fields_info.field_name, sync_fields_info.dest_field_name " +
"from sync_fields_info,sync_tables_info " +
"where sync_fields_info.client_id = 10 and sync_fields_info.table_name = sync_tables_info.table_name and sync_tables_info.table_name=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName);
rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
while(rs.next()){
fieldsMap.put(rs.getString("field_name"),rs.getString("dest_field_name"));
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return fieldsMap;
}
public String getLastRecordTimeSended(String tableName,String deviceId) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Timestamp timeStamp = null;
try {
conn = DataSourceUtils.getConnection();
String sql = "select field_val2 from sync_records where table_name =? and devid_val=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName);
pstmt.setString(2, deviceId);
rs = pstmt.executeQuery();
if(rs.next()){
timeStamp = rs.getTimestamp("field_val2");
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeStamp);
}
public List<String> getDeviceID(String tableName) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sqlExecuting = null ;
List<String> deviceIDs = new ArrayList<>();
try {
conn = DataSourceUtils.getConnection();
String sql = "select distinct devid_val from sync_records where table_name =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName);
rs = pstmt.executeQuery();
while(rs.next()){
deviceIDs.add(rs.getString("devid_val"));
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return deviceIDs;
}
public String getSQL(String tableName) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sqlExecuting = null ;
try {
conn = DataSourceUtils.getConnection();
String sql = "select * from sync_tables_info where table_name =?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName);
rs = pstmt.executeQuery();
if(rs.next()){
sqlExecuting = rs.getString("sql");
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return sqlExecuting;
}
public List<Map<String,Object>> getData(String sqlExecuting, String deviceId, String timeStamp) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
List<Map<String,Object>> records = new ArrayList<>();
try {
conn = DataSourceUtils.getConnection();
String sql = sqlExecuting;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, deviceId);
pstmt.setString(2,timeStamp);
rs = pstmt.executeQuery();
int columnCount = rs.getMetaData().getColumnCount(); //获取列的数量
while(rs.next()){
Map<String,Object> record = new HashMap<>();
for (int col = 0; col < columnCount; col++) {
String columnName = rs.getMetaData().getColumnName(col + 1);
String columnValue = rs.getString(columnName);
record.put(columnName,columnValue);
}
records.add(record);
}
} catch (SQLException e) {
logger.error("execute sql exception:", e);
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return records;
}
@Scheduled(initialDelay=1000, fixedRate = 1000 * 3600) //通过@Scheduled声明该方法是计划任务使用fixedRate属性每隔固定时间执行
public void reportRecord(){
List<String> allTableNames = getAllTableName();
Map<String,Map<String,String>> tableFieldMap = new HashMap<>();
Map<String, List<Map<String,List<Map<String,Object>>>>> allTableData = new HashMap<>();
for(String tablenName : allTableNames){
//if用来测试
if(!"data_eaif_h".equals(tablenName)){
Map<String,String> fieldMap = getFieldMap(tablenName);
tableFieldMap.put(tablenName,fieldMap);
String sqlExecuting = getSQL(tablenName);
List<String> deviceIDs = getDeviceID(tablenName);
List<Map<String,List<Map<String,Object>>>> dataOfoneTable = new ArrayList<>();
for(String deviceID : deviceIDs){
Map<String,List<Map<String,Object>>> deviceIDMap = new HashMap<>();
String timeStamp = getLastRecordTimeSended(tablenName,deviceID);
List<Map<String,Object>> dataOfoneDeviceID = getData(sqlExecuting,deviceID,timeStamp);
deviceIDMap.put(deviceID,dataOfoneDeviceID);
dataOfoneTable.add(deviceIDMap);
}
allTableData.put(tablenName,dataOfoneTable);
}
}
System.out.println("旧数据: "+allTableData);
System.out.println("===============================");
Map<String,List<Map<String, List<Map<String, Object>>>>> newAllData = new HashMap<>();
for(Map.Entry<String, List<Map<String,List<Map<String,Object>>>>> dataEntry : allTableData.entrySet()){
List<Map<String, List<Map<String, Object>>>> newRecords = transformFields(dataEntry.getKey(),tableFieldMap,dataEntry.getValue());
newAllData.put(dataEntry.getKey(),newRecords);
}
for(String tableName : newAllData.keySet()){
List<Map<String, List<Map<String, Object>>>> records = newAllData.get(tableName);
String jsonStringData = FormatUtil.list2Json(records);
if(MqttUtil.publish2MQTT(jsonStringData)){
updateLastRecordTimeSended(tableName,records);
}else{
System.out.println("消息推送失败");
}
}
}
//返回替换字段名的records
private List<Map<String,List<Map<String,Object>>>> transformFields(String recordTableName, Map<String,Map<String,String>> tableFieldMap, List<Map<String,List<Map<String,Object>>>> records) {
List<Map<String,List<Map<String,Object>>>> newRecords = new ArrayList<>();
if(tableFieldMap.containsKey(recordTableName)){
for(Map<String,List<Map<String,Object>>> record : records ){
newRecords.add(transformMore(tableFieldMap.get(recordTableName),record));
}
}
return newRecords;
}
private Map<String,List<Map<String,Object>>> transformMore(Map<String,String> fieldMap, Map<String,List<Map<String,Object>>> deviceIDDataMap) {
Map<String,List<Map<String,Object>>> newDeviceIDData = new HashMap<>();
for(Map.Entry<String,List<Map<String,Object>>> entry : deviceIDDataMap.entrySet()){
newDeviceIDData.put(entry.getKey(),transformMoreAgain(fieldMap, entry.getValue()));
}
return newDeviceIDData;
}
private List<Map<String,Object>> transformMoreAgain(Map<String,String> fieldMap, List<Map<String,Object>> deviceIDData) {
List<Map<String,Object>> newDeviceIDData = new ArrayList<>();
for(Map<String,Object> fieldValueMap : deviceIDData){
newDeviceIDData.add(transformMoreAgain2(fieldMap,fieldValueMap));
}
return newDeviceIDData;
}
private Map<String,Object> transformMoreAgain2(Map<String,String> fieldMap, Map<String,Object> fieldValueMap) {
Map<String,Object> newFieldValueMap = new HashMap<>();
for(String field : fieldMap.keySet()){
for(String columnName : fieldValueMap.keySet() ){
if(Objects.equals(field,columnName)){
newFieldValueMap.put(fieldMap.get(field),fieldValueMap.get(columnName) );
}
}
}
return newFieldValueMap;
}
public void updateLastRecordTimeSended(String tableName, List<Map<String,List<Map<String, Object>>>> records) {
List<String> deviceIDs = getDeviceID(tableName);
for(String deviceID : deviceIDs){
String lastRecordTimesJustSended = null;
for(Map<String,List<Map<String, Object>>> recordMap : records){
if(recordMap.get(deviceID) != null){
List<Map<String, Object>> deviceIDData = recordMap.get(deviceID);
lastRecordTimesJustSended = (String) deviceIDData.get(deviceIDData.size()-1).get("AcquisitionTime");
System.out.println(tableName+"表"+deviceID+"最后一条记录时间: "+lastRecordTimesJustSended);
}
}
// updateSyncRecordsTable(tableName, deviceID, lastRecordTimesJustSended);
}
}
public boolean updateSyncRecordsTable(String tableName, String deviceID, String time) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = DataSourceUtils.getConnection();
String sql = "update sync_records set field_val2 = ? where table_name = ? and devid_val = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, time);
pstmt.setString(2, tableName);
pstmt.setString(3, deviceID);
pstmt.executeUpdate();
} catch (SQLException e) {
logger.error("execute sql exception:", e);
return false;
} finally {
DataSourceUtils.closeResource(rs, pstmt, conn);
}
return true;
}
@Scheduled(fixedDelay = Long.MAX_VALUE) // 用一个非常大的延迟值,确保只执行一次
public void subScribeSamle() {
System.out.println("subScribe执行一次 "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
MqttUtil.subScribeMQTT();
}
}

@ -0,0 +1,259 @@
package com.xydl.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
public class CommonUtils {
private static final Logger logger = LoggerFactory.getLogger(CommonUtils.class);
private static final boolean languageZh = getPropertyValue("system.language", "zh").equals("zh");
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final long startupTime = System.currentTimeMillis();
private static final int startingTime = Integer.parseInt(getPropertyValue("system.startup.time", "60000"));
public static long getStartupTime() {
return startupTime;
}
public static boolean started() {
return System.currentTimeMillis() - startupTime > startingTime;
}
public static boolean isLanguageZh() {
return languageZh;
}
private static boolean updateConfig(String name, Map<String, Object> value) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = DataSourceUtils.getConnection();
String sql = "update global_configuration set value=?::json where name=?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, CommonUtils.getJsonFromObject(value));
pstmt.setString(2, name);
pstmt.executeUpdate();
} catch (Exception e) {
logger.error("execute sql exception:", e);
return false;
} finally {
DataSourceUtils.closeResource(pstmt, conn);
}
return true;
}
private static boolean addConfig(String name, Map<String, Object> value) {
Connection conn = null;
PreparedStatement pstmt = null;
try {
conn = DataSourceUtils.getConnection();
String sql = "INSERT INTO global_configuration(name, value) VALUES (?, ?::json)";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setString(2, CommonUtils.getJsonFromObject(value));
pstmt.executeUpdate();
} catch (Exception e) {
logger.error("execute sql exception:", e);
return false;
} finally {
DataSourceUtils.closeResource(pstmt, conn);
}
return true;
}
public static ObjectMapper getObjectMapper() {
return objectMapper;
}
public static <T> T convertJsonToObject(String content, Class<T> valueType) {
if (content == null) {
return null;
}
try {
return objectMapper.readValue(content.getBytes(StandardCharsets.UTF_8), valueType);
} catch (IOException e) {
logger.error("convert json to Object exception:", e);
}
return null;
}
public static <T> List<T> convertJsonToList(String content, Class<T> valueType) {
if (content == null || content.length() == 0) {
return new ArrayList<>();
}
try {
List<T> list = objectMapper.readValue(content.getBytes(StandardCharsets.UTF_8), new TypeReference<List<T>>() {
});
List<T> ret = new ArrayList<>();
for (T t : list) {
ret.add(objectMapper.convertValue(t, valueType));
}
return ret;
} catch (IOException e) {
logger.error("convert json to Object exception:", e);
}
return null;
}
public static String getJsonFromObject(Object object) {
String json = null;
try {
json = CommonUtils.getObjectMapper().writeValueAsString(object);
} catch (JsonProcessingException ignored) {
}
return json;
}
public static String getJsonValue(String jsonString, String key) {
Map<String, String> jsonMap;
try {
jsonMap = objectMapper.readValue(jsonString, new TypeReference<Map<String, String>>() {
});
} catch (IOException ignored) {
return null;
}
return jsonMap.get(key);
}
public static String getJsonString(Map<String, Object> map) {
String result = "";
try {
result = objectMapper.writeValueAsString(map);
} catch (JsonProcessingException ignored) {
}
return result;
}
public static Map<String, String> getJsonMap(String jsonString) {
Map<String, String> jsonMap;
try {
jsonMap = objectMapper.readValue(jsonString, new TypeReference<Map<String, String>>() {
});
} catch (IOException ignored) {
jsonMap = new HashMap<>();
}
return jsonMap;
}
public static Map<String, Object> getMapFromJson(String jsonString) {
try {
return objectMapper.readValue(jsonString, new TypeReference<Map<String, Object>>() {
});
} catch (IOException ignored) {
}
return new HashMap<>();
}
public static String getPropertyValue(String propertyName) {
Properties properties = loadPropertyFile("sdwan.common.cfg");
if (properties != null) {
return properties.getProperty(propertyName);
}
return null;
}
public static String getPropertyValue(String propertyName, String defaultValue) {
Properties properties = loadPropertyFile("sdwan.common.cfg");
if (properties != null) {
String value = properties.getProperty(propertyName);
return value == null ? defaultValue : value;
}
return defaultValue;
}
public static Properties loadPropertyFile(String fileName) {
String filePath = System.getProperty("user.dir").concat("/etc/").concat(fileName);
File file = new File(filePath);
if (!file.exists()) {
return null;
}
try (InputStream is = new FileInputStream(file)) {
Properties properties = new Properties();
properties.load(is);
return properties;
} catch (IOException e) {
logger.error("load property file exception:", e);
}
return null;
}
public static boolean setProperty(String fileName, String key, String value) {
Properties properties = loadPropertyFile(fileName);
if (properties == null) {
properties = new Properties();
}
properties.setProperty(key, value);
return savePropertyFile(fileName, properties);
}
public static boolean savePropertyFile(String fileName, Properties properties) {
String filePath = System.getProperty("user.dir").concat("/etc/").concat(fileName);
File file = new File(filePath);
if (!file.exists()) {
return false;
}
try (OutputStream os = new FileOutputStream(file)) {
properties.store(os, null);
} catch (IOException e) {
logger.error("write file exception:", e);
return false;
}
return true;
}
@SuppressWarnings("unchecked")
public static <T> List<T> getListFromArray(Array array) {
if (array == null) {
return null;
}
try {
return Arrays.asList((T[]) array.getArray());
} catch (SQLException ignored) {
}
return null;
}
public static String formatDate(Date date) {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
}
// public static void main(String args[]) {
// System.out.println(CommonUtils.getLanguage());
// }
}

@ -0,0 +1,101 @@
package com.xydl.util;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.sql.DataSource;
import java.sql.*;
import java.util.Properties;
public class DataSourceUtils {
private static final Logger logger = LoggerFactory.getLogger(DataSourceUtils.class);
private static DataSource dataSource;
private static String url;
static {
initDataSource();
}
private static void initDataSource() {
Properties properties = CommonUtils.loadPropertyFile("sdwan.datasource.druid.cfg");
if (properties == null) {
logger.error("init dataSource failed, no config found.");
properties = new Properties();
properties.setProperty("driverClassName", "com.mysql.cj.jdbc.Driver");
properties.setProperty("url", "jdbc:mysql://localhost:3306/cac");
properties.setProperty("username", "root");
properties.setProperty("password", "root");
}
try {
dataSource = DruidDataSourceFactory.createDataSource(properties);
url = ((DruidDataSource) dataSource).getUrl();
} catch (Exception e) {
logger.error("init dataSource exception:", e);
}
logger.info("Data source has been initialized successfully!");
}
// 提供获取连接的方法
public static Connection getConnection() throws SQLException {
return dataSource.getConnection();
}
public static String getDatabaseIp() {
try {
return url.substring(url.indexOf("//") + 2, url.lastIndexOf(":"));
} catch (IndexOutOfBoundsException ignored) {
}
return "";
}
// 提供关闭资源的方法【connection是归还到连接池】
// 提供关闭资源的方法 【方法重载】3 dql
public static void closeResource(ResultSet resultSet, Statement statement, Connection connection) {
// 关闭结果集
closeResultSet(resultSet);
// 关闭语句执行者
closeStatement(statement);
// 关闭连接
closeConnection(connection);
}
// 提供关闭资源的方法 【方法重载】 2 dml
public static void closeResource(Statement statement, Connection connection) {
// 关闭语句执行者
closeStatement(statement);
// 关闭连接
closeConnection(connection);
}
private static void closeConnection(Connection connection) {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
logger.error("closeConnection exception", e);
}
}
}
private static void closeStatement(Statement statement) {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
logger.error("closeStatement exception", e);
}
}
}
private static void closeResultSet(ResultSet resultSet) {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
logger.error("closeResultSet exception", e);
}
}
}
}

@ -0,0 +1,34 @@
package com.xydl.util;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FormatUtil {
public static String list2Json(List list){
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String,Object>> assetList = new ArrayList<>();
assetList.add(new HashMap<String,Object>(){{
put("AssetCode","ironCore");
put("AttributeList",list);
put("Timestamp", 1606800979591089792L);
}});
Map<String,Object> resultMap = new HashMap<String,Object>(){{
put("AssetList",assetList);
}};
String jsonString = null;
try {
jsonString = objectMapper.writeValueAsString(resultMap);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return jsonString;
}
}

@ -0,0 +1,106 @@
package com.xydl.util;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MqttUtil {
public static boolean publish2MQTT(String content){
String broker = "tcp://139.196.211.222:10883";
String topic = "mqtt/test";
// String content = "Hello MQTT";
int qos = 0;
String username = "test";
String password = "AliOS%1688";
String clientid = "publish_client";
MqttClient client;
MqttDeliveryToken token;
try {
client = new MqttClient(broker, clientid, new MemoryPersistence());
} catch (MqttException e) {
throw new RuntimeException(e);
}
MqttConnectOptions options = new MqttConnectOptions();
options.setUserName(username);
options.setPassword(password.toCharArray());
options.setConnectionTimeout(60);
options.setKeepAliveInterval(30);
// connect
try {
client.connect(options);
} catch (MqttException e) {
throw new RuntimeException(e);
}
// create message and setup QoS
MqttMessage message = new MqttMessage(content.getBytes());
message.setQos(qos);
// publish message
try {
token = client.getTopic(topic).publish(message);
token.waitForCompletion();
//打印发送状态
System.out.println("messagei is published completely!" + token.isComplete());
// client.publish(topic, message);
} catch (MqttException e) {
throw new RuntimeException(e);
}
System.out.println("Message published");
System.out.println("topic: " + topic);
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+ " message content推送: " + content);
// disconnect
try {
client.disconnect();
} catch (MqttException e) {
throw new RuntimeException(e);
}
// close client
try {
client.close();
} catch (MqttException e) {
throw new RuntimeException(e);
}
return token.isComplete();
}
public static void subScribeMQTT(){
String broker = "tcp://139.196.211.222:10883";
String topic = "mqtt/test";
String username = "test";
String password = "AliOS%1688";
String clientid = "subscribe_client";
int qos = 0;
try {
MqttClient client = new MqttClient(broker, clientid, new MemoryPersistence());
// connect options
MqttConnectOptions options = new MqttConnectOptions();
options.setUserName(username);
options.setPassword(password.toCharArray());
options.setConnectionTimeout(60);
options.setKeepAliveInterval(30);
// setup callback
client.setCallback(new MqttCallback() {
public void connectionLost(Throwable cause) {
System.out.println("connectionLost: " + cause.getMessage());
}
public void messageArrived(String topic, MqttMessage message) {
System.out.println("topic: " + topic);
System.out.println("Qos: " + message.getQos());
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+" message content接收: " + new String(message.getPayload()));
}
public void deliveryComplete(IMqttDeliveryToken token) {
System.out.println("deliveryComplete---------" + token.isComplete());
}
});
client.connect(options);
client.subscribe(topic, qos);
} catch (Exception e) {
e.printStackTrace(); }
}
}

@ -0,0 +1,27 @@
#端口号
server:
port: 8088
#数据源配置
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/cac?characterEncoding=utf-8&serverTimezone=UTC
username: root
password: root
#sql:
#init:
#指定脚本文件位置
#schema-locations: classpath:user.sql
#初始化方式
#mode: always
#设置数据源类型C
type: com.alibaba.druid.pool.DruidDataSource
mybatis:
configuration:
map-underscore-to-camel-case: true
#mybatis:
#指定mybatis配置文件的位置
#config-location: classpath:mybatis/mybatis-config.xml
#指定映射文件的位置
mapper-locations: classpath:mybatis/mapper/*.xml

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.EaifMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<select id="getEaif" resultType="com.xydl.model.Eaif">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime, t1.maxtemp, t1.mintemp, t1.avgtemp, t2.phase
FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=165 AND t1.capturetime>'2017-01-17 16:00:00' ORDER BY t1.capturetime LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.EiaMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getEia" resultType="com.xydl.model.Eia">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.d_ct_1, t2.phase
FROM `data_eia_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=152 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.EpaMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getEpa" resultType="com.xydl.model.Epa">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time,t1.h2ppm,t1.ch4ppm,t1.c2h6ppm,t1.c2h4ppm,t1.c2h2ppm,t1.coppm,t1.co2ppm,t1.o2ppm,t1.n2ppm,t1.totalhydrocarbon,t1.gaspress,t1.h2oppm,t2.`Phase`
FROM `data_epa_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=#{devid} AND t1.d_time>(select DISTINCT syrec.field_val2 from sync_records as syrec, sync_tables_info as sytab, data_epa_h as epa
where sytab.client_id = 10 and syrec.client_id = sytab.client_id and syrec.table_name = sytab.table_name and epa.eqmid = syrec.devid_val and epa.eqmid = #{devid})
ORDER BY t1.d_time LIMIT 1000
</select>
<select id="getData" resultType="com.xydl.model.SuperModel">
${value}
</select>
<select id="getEqmidsByTableName" resultType="java.lang.Integer">
select DISTINCT tableName.eqmid from ${tableName} as tableName
</select>
<select id="getTableNamesBySyncTable" resultType="java.lang.String">
select DISTINCT syncTableName.table_name from ${sycTableName} as syncTableName
</select>
<select id="getSqlBySyncTable" resultType="java.lang.String">
select syncTable.sql from ${syncTable} as syncTable where table_name=#{tableName}
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.EtpMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getEtp" resultType="com.xydl.model.Etp">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time,t1.t1
FROM `data_etp_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=160 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.MicMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getMicroclimate" resultType="com.xydl.model.Microclimate">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.envtmp, t1.envpres, t1.envhum, t1.rnfll, t2.phase
FROM `data_microclimate_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=152 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.MoaMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getMoa" resultType="com.xydl.model.Moa">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.pt1, t1.lc1, t1.rc1, t1.ligcnt1, t1.lastligtm1, t2.phase
FROM `data_moa_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=163 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.PdMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getPd" resultType="com.xydl.model.Pd">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.waveform, t1.plsnum, t1.apppadsch, t2.phase
FROM `data_pd_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=242 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.RptTemperMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getRptTemper" resultType="com.xydl.model.RptTemper">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid, t1.create_time, t1.a_o_temper, t1.b_o_temper, t1.c_o_temper, t1.a_i_temper, t1.b_i_temper, t1.c_i_temper, t1.box_temper,t2.phase
FROM `rpt_temper` AS t1 JOIN i2relation AS t2 ON t1.eqm_id=t2.eqmid
WHERE t1.eqm_id=165 AND t1.create_time>'2017-01-17 16:00:00' ORDER BY t1.create_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.ScurMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getScur" resultType="com.xydl.model.Scur">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.current_val, t2.phase
FROM `data_scur_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=395 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.Sf6Mapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getSf6" resultType="com.xydl.model.Sf6">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.temp1, t1.md1, t1.pressure1+900, t1.pressure1, t1.pm1, t2.phase
FROM `data_sf6_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=164 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--MyBatis的映射文件 编写sql-->
<!--一个数据表对应一个实体类一个实体类对应一个mapper映射文件-->
<mapper namespace="com.xydl.mapper.Sf6envMapper">
<!-- <resultMap id="EiaResultMap" type="com.xydl.model.Eia">-->
<!-- <result column="SubDeviceID" property="subDeviceID"/>-->
<!-- <result column="sensorid" property="sensorId"/>-->
<!-- <result column="capturetime" property="captureTime"/>-->
<!-- <result column="maxtemp" property="maxTemp"/>-->
<!-- <result column="mintemp" property="minTemp"/>-->
<!-- <result column="avgtemp" property="avgTemp"/>-->
<!-- <result column="Phase" property="phase"/>-->
<!-- </resultMap>-->
<!-- <select id="getEia" resultType="com.xydl.model.Eia">-->
<!-- SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.capturetime,t1.maxtemp,t1.mintemp,t1.avgtemp,t2.`Phase`-->
<!-- FROM `data_eaif_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid-->
<!-- WHERE t1.eqmid=394 AND t1.capturetime>'2019-12-19 04:55:31' ORDER BY t1.capturetime LIMIT 1000-->
<!-- </select>-->
<select id="getSf6env" resultType="com.xydl.model.Sf6env">
SELECT t2.equipmentid AS SubDeviceID, t2.sensorid,t1.d_time, t1.gas1, t1.yq1, t1.md1, t1.pm1, t1.gascnt1, t1.hmcnt1,t1.sf6warn1, t1.o2warn1,t2.phase
FROM `data_sf6env_h` AS t1 JOIN i2relation AS t2 ON t1.eqmid=t2.eqmid
WHERE t1.eqmid=165 AND t1.d_time>'2017-01-17 16:00:00' ORDER BY t1.d_time LIMIT 10
</select>
<!--int insertEmp(Employee employee);-->
<insert id="insertEmp">
insert into employee values (#{id},#{lastName},#{email},#{gender},#{department.id})
</insert>
<update id="update">
update employee
<set>
<if test="employee.lastName!=null">
last_name=#{employee.lastName},
</if>
<if test="employee.email!=null">
email=#{employee.email},
</if>
<if test="employee.gender!=null">
gender=#{employee.gender},
</if>
<if test="employee.department!=null">
d_id=#{employee.department.id}
</if>
</set>
where id = #{id}
</update>
<!--int deleteEmpById(Integer id);-->
<delete id="deleteEmpById">
delete from employee where id=#{id}
</delete>
</mapper>

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> ${list}</h1>
<h1> ${name}</h1>
</body>
</html>
Loading…
Cancel
Save