wenhua.zhou 2 years ago
parent 1d39ab3c93
commit 4fbb9c22b7

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# 默认忽略的文件
/shelf/
/workspace.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="mqtt" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="mqtt" options="-parameters" />
</option>
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" defaultCharsetForPropertiesFiles="UTF-8">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="LossyEncoding" enabled="false" level="WARNING" enabled_by_default="false" />
</profile>
</component>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,13 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

@ -24,6 +24,12 @@
<dependencies> <dependencies>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.4.0</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
@ -108,6 +114,6 @@
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -146,7 +146,7 @@ public class EiaServiceImpl implements EiaService {
List<String> tableNames = new ArrayList<>(); List<String> tableNames = new ArrayList<>();
try { try {
conn = DataSourceUtils.getConnection(); conn = DataSourceUtils.getConnection();
String sql = "select DISTINCT table_name from sync_tables_info"; String sql = "select table_name from sync_tables_info";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
@ -189,45 +189,69 @@ public class EiaServiceImpl implements EiaService {
return fieldsMap; return fieldsMap;
} }
public String getLastRecordTimeSended(String tableName,String deviceId) { // public String getLastRecordTimeSended(String tableName,String deviceId) {
Connection conn = null; // Connection conn = null;
PreparedStatement pstmt = null; // PreparedStatement pstmt = null;
ResultSet rs = null; // ResultSet rs = null;
Timestamp timeStamp = null; // Timestamp timeStamp = null;
try { // try {
conn = DataSourceUtils.getConnection(); // conn = DataSourceUtils.getConnection();
String sql = "select field_val2 from sync_records where table_name =? and devid_val=?"; // String sql = "select field_val2 from sync_records where table_name =? and devid_val=?";
pstmt = conn.prepareStatement(sql); // pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName); // pstmt.setString(1, tableName);
pstmt.setString(2, deviceId); // pstmt.setString(2, deviceId);
rs = pstmt.executeQuery(); // rs = pstmt.executeQuery();
if(rs.next()){ // if(rs.next()){
timeStamp = rs.getTimestamp("field_val2"); // timeStamp = rs.getTimestamp("field_val2");
//
} // }
} catch (SQLException e) { // } catch (SQLException e) {
logger.error("execute sql exception:", e); // logger.error("execute sql exception:", e);
} finally { // } finally {
DataSourceUtils.closeResource(rs, pstmt, conn); // DataSourceUtils.closeResource(rs, pstmt, conn);
} // }
//
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timeStamp); // 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 List<String> getDeviceID(String tableName) { public Map<String,Object> getDeviceID1(String tableName) {
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
String sqlExecuting = null ; String sqlExecuting = null ;
List<String> deviceIDs = new ArrayList<>(); Map<String,Object> devIDTimeMap = new HashMap<>();
try { try {
conn = DataSourceUtils.getConnection(); conn = DataSourceUtils.getConnection();
String sql = "select distinct devid_val from sync_records where table_name =?"; String sql = "select devid_val,field_val2 from sync_records where table_name =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tableName); pstmt.setString(1, tableName);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()){ while(rs.next()){
deviceIDs.add(rs.getString("devid_val")); devIDTimeMap.put(rs.getString("devid_val"),rs.getString("field_val2"));
} }
} catch (SQLException e) { } catch (SQLException e) {
logger.error("execute sql exception:", e); logger.error("execute sql exception:", e);
@ -235,7 +259,7 @@ public class EiaServiceImpl implements EiaService {
DataSourceUtils.closeResource(rs, pstmt, conn); DataSourceUtils.closeResource(rs, pstmt, conn);
} }
return deviceIDs; return devIDTimeMap;
} }
public String getSQL(String tableName) { public String getSQL(String tableName) {
@ -293,111 +317,177 @@ public class EiaServiceImpl implements EiaService {
} }
// @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("消息推送失败");
// }
// }
//
// }
@Scheduled(initialDelay=1000, fixedRate = 1000 * 3600) //通过@Scheduled声明该方法是计划任务使用fixedRate属性每隔固定时间执行 @Scheduled(initialDelay=1000, fixedRate = 1000 * 3600) //通过@Scheduled声明该方法是计划任务使用fixedRate属性每隔固定时间执行
public void reportRecord(){ public void reportRecord1(){
List<String> allTableNames = getAllTableName(); List<String> allTableNames = getAllTableName();
Map<String,Map<String,String>> tableFieldMap = new HashMap<>(); Map<String,Map<String,String>> tableFieldMap = new HashMap<>();
Map<String, List<Map<String,List<Map<String,Object>>>>> allTableData = new HashMap<>(); Map<String, List<Map<String,List<Map<String,Object>>>>> allTableData = new HashMap<>();
for(String tablenName : allTableNames){ for(String tableName : allTableNames){
//if用来测试 //if用来测试
if(!"data_eaif_h".equals(tablenName)){ if(!"data_eaif_h".equals(tableName)){
Map<String,String> fieldMap = getFieldMap(tablenName); Map<String,String> fieldMap = getFieldMap(tableName);
tableFieldMap.put(tablenName,fieldMap); String sqlExecuting = getSQL(tableName);
Map<String,Object> devIDLastTimeMap = getDeviceID1(tableName);
String sqlExecuting = getSQL(tablenName); for(String deviceID : devIDLastTimeMap.keySet()){
List<String> deviceIDs = getDeviceID(tablenName); List<Map<String,Object>> dataOfoneDeviceID = getData(sqlExecuting,deviceID, (String) devIDLastTimeMap.get(deviceID));
List<Map<String,List<Map<String,Object>>>> dataOfoneTable = new ArrayList<>();
for(String deviceID : deviceIDs){ List<Map<String,Object>> newDataOfoneDeviceID = transformList(fieldMap,dataOfoneDeviceID);
Map<String,List<Map<String,Object>>> deviceIDMap = new HashMap<>();
String timeStamp = getLastRecordTimeSended(tablenName,deviceID); String jsonStringData = FormatUtil.list2Json(newDataOfoneDeviceID);
List<Map<String,Object>> dataOfoneDeviceID = getData(sqlExecuting,deviceID,timeStamp); if(MqttUtil.publish2MQTT(jsonStringData)){
deviceIDMap.put(deviceID,dataOfoneDeviceID); updateSyncRecordsTable(tableName,deviceID, (String) devIDLastTimeMap.get(deviceID));
dataOfoneTable.add(deviceIDMap); }else{
System.out.println("消息推送失败");
}
} }
allTableData.put(tablenName,dataOfoneTable);
} }
} }
System.out.println("旧数据: "+allTableData); // System.out.println("旧数据: "+allTableData);
System.out.println("==============================="); // System.out.println("===============================");
Map<String,List<Map<String, List<Map<String, Object>>>>> newAllData = new HashMap<>(); // 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()){ // 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()); // List<Map<String, List<Map<String, Object>>>> newRecords = transformFields(dataEntry.getKey(),tableFieldMap,dataEntry.getValue());
newAllData.put(dataEntry.getKey(),newRecords); // newAllData.put(dataEntry.getKey(),newRecords);
} // }
for(String tableName : newAllData.keySet()){ // for(String tableName : newAllData.keySet()){
List<Map<String, List<Map<String, Object>>>> records = newAllData.get(tableName); // List<Map<String, List<Map<String, Object>>>> records = newAllData.get(tableName);
String jsonStringData = FormatUtil.list2Json(records); // String jsonStringData = FormatUtil.list2Json(records);
if(MqttUtil.publish2MQTT(jsonStringData)){ // if(MqttUtil.publish2MQTT(jsonStringData)){
updateLastRecordTimeSended(tableName,records); // updateLastRecordTimeSended(tableName,records);
}else{ // }else{
System.out.println("消息推送失败"); // System.out.println("消息推送失败");
} // }
} // }
} }
//返回替换字段名的records // //返回替换字段名的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) { // 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<>(); // List<Map<String,List<Map<String,Object>>>> newRecords = new ArrayList<>();
if(tableFieldMap.containsKey(recordTableName)){ // if(tableFieldMap.containsKey(recordTableName)){
for(Map<String,List<Map<String,Object>>> record : records ){ // for(Map<String,List<Map<String,Object>>> record : records ){
newRecords.add(transformMore(tableFieldMap.get(recordTableName),record)); // newRecords.add(transformMore(tableFieldMap.get(recordTableName),record));
} // }
} // }
return newRecords; // return newRecords;
} // }
//
private Map<String,List<Map<String,Object>>> transformMore(Map<String,String> fieldMap, Map<String,List<Map<String,Object>>> deviceIDDataMap) { // 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<>(); // Map<String,List<Map<String,Object>>> newDeviceIDData = new HashMap<>();
for(Map.Entry<String,List<Map<String,Object>>> entry : deviceIDDataMap.entrySet()){ // for(Map.Entry<String,List<Map<String,Object>>> entry : deviceIDDataMap.entrySet()){
newDeviceIDData.put(entry.getKey(),transformMoreAgain(fieldMap, entry.getValue())); // newDeviceIDData.put(entry.getKey(),transformMoreAgain(fieldMap, entry.getValue()));
} // }
return newDeviceIDData; // 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;
// }
private List<Map<String,Object>> transformMoreAgain(Map<String,String> fieldMap, List<Map<String,Object>> deviceIDData) { private List<Map<String,Object>> transformList(Map<String,String> fieldMap, List<Map<String,Object>> deviceIDData) {
List<Map<String,Object>> newDeviceIDData = new ArrayList<>(); List<Map<String,Object>> newDeviceIDData = new ArrayList<>();
for(Map<String,Object> fieldValueMap : deviceIDData){ for(Map<String,Object> fieldValueMap : deviceIDData){
newDeviceIDData.add(transformMoreAgain2(fieldMap,fieldValueMap)); newDeviceIDData.add(transformOneRecord(fieldMap,fieldValueMap));
} }
return newDeviceIDData; return newDeviceIDData;
} }
private Map<String,Object> transformMoreAgain2(Map<String,String> fieldMap, Map<String,Object> fieldValueMap) { private Map<String,Object> transformOneRecord(Map<String,String> fieldMap, Map<String,Object> fieldValueMap) {
Map<String,Object> newFieldValueMap = new HashMap<>(); Map<String,Object> newFieldValueMap = new HashMap<>();
for(String field : fieldMap.keySet()){ for(String field : fieldMap.keySet()){
for(String columnName : fieldValueMap.keySet() ){ if(fieldValueMap.containsKey(field)){
if(Objects.equals(field,columnName)){ newFieldValueMap.put(fieldMap.get(field),fieldValueMap.get(field) );
newFieldValueMap.put(fieldMap.get(field),fieldValueMap.get(columnName) );
}
} }
} }
return newFieldValueMap; return newFieldValueMap;
} }
//
public void updateLastRecordTimeSended(String tableName, List<Map<String,List<Map<String, Object>>>> records) { // public void updateLastRecordTimeSended(String tableName, List<Map<String,List<Map<String, Object>>>> records) {
List<String> deviceIDs = getDeviceID(tableName); // List<String> deviceIDs = getDeviceID(tableName);
for(String deviceID : deviceIDs){ // for(String deviceID : deviceIDs){
String lastRecordTimesJustSended = null; // String lastRecordTimesJustSended = null;
for(Map<String,List<Map<String, Object>>> recordMap : records){ // for(Map<String,List<Map<String, Object>>> recordMap : records){
if(recordMap.get(deviceID) != null){ // if(recordMap.get(deviceID) != null){
List<Map<String, Object>> deviceIDData = recordMap.get(deviceID); // List<Map<String, Object>> deviceIDData = recordMap.get(deviceID);
lastRecordTimesJustSended = (String) deviceIDData.get(deviceIDData.size()-1).get("AcquisitionTime"); // lastRecordTimesJustSended = (String) deviceIDData.get(deviceIDData.size()-1).get("AcquisitionTime");
System.out.println(tableName+"表"+deviceID+"最后一条记录时间: "+lastRecordTimesJustSended); // System.out.println(tableName+"表"+deviceID+"最后一条记录时间: "+lastRecordTimesJustSended);
} // }
//
} // }
// updateSyncRecordsTable(tableName, deviceID, lastRecordTimesJustSended); //// updateSyncRecordsTable(tableName, deviceID, lastRecordTimesJustSended);
//
} // }
//
} // }
public boolean updateSyncRecordsTable(String tableName, String deviceID, String time) { public boolean updateSyncRecordsTable(String tableName, String deviceID, String time) {

@ -3,10 +3,7 @@ package com.xydl.util;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class FormatUtil { public class FormatUtil {
@ -16,7 +13,7 @@ public class FormatUtil {
assetList.add(new HashMap<String,Object>(){{ assetList.add(new HashMap<String,Object>(){{
put("AssetCode","ironCore"); put("AssetCode","ironCore");
put("AttributeList",list); put("AttributeList",list);
put("Timestamp", 1606800979591089792L); put("Timestamp", new Date().getTime());
}}); }});
Map<String,Object> resultMap = new HashMap<String,Object>(){{ Map<String,Object> resultMap = new HashMap<String,Object>(){{
put("AssetList",assetList); put("AssetList",assetList);
@ -30,5 +27,9 @@ public class FormatUtil {
return jsonString; return jsonString;
} }
public static void main(String[] args) {
System.out.println(new Date().getTime());
}
} }

@ -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>

@ -0,0 +1,3 @@
artifactId=mqtt
groupId=com.xydl
version=1.0-SNAPSHOT
Loading…
Cancel
Save