|
@@ -7,11 +7,10 @@ import com.platform.common.util.IdGeneratorUtils;
|
|
|
import com.platform.common.util.StringUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import java.sql.Connection;
|
|
|
-import java.sql.DriverManager;
|
|
|
-import java.sql.SQLException;
|
|
|
-import java.sql.Statement;
|
|
|
+import java.sql.*;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Slf4j
|
|
|
public class MySqlUtil {
|
|
@@ -25,7 +24,12 @@ public class MySqlUtil {
|
|
|
public static String mysql_password = "mysql?MYSQLmoniu123";//admindljjk
|
|
|
//驱动名称
|
|
|
public static String mysql_driver = "com.mysql.cj.jdbc.Driver";
|
|
|
-
|
|
|
+ // 采集数据,结构:遥测最低,遥测最高;电度最低,电度最高
|
|
|
+ public static String remote_config = "REMOTE_CONFIG";
|
|
|
+ public static int remote_config_measure_min = 11;
|
|
|
+ public static int remote_config_measure_max = 11;
|
|
|
+ public static int remote_config_degree_min = 11;
|
|
|
+ public static int remote_config_degree_max = 11;
|
|
|
private static Connection conn = null;
|
|
|
|
|
|
public static Connection getConnection() {
|
|
@@ -51,6 +55,11 @@ public class MySqlUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新遥测数据
|
|
|
+ * @param positionNum
|
|
|
+ * @param result
|
|
|
+ */
|
|
|
public static void updateRemoteMeasureByPositionNum(Integer positionNum, String result) {
|
|
|
Statement stmt = null;
|
|
|
StringBuffer updateSql = new StringBuffer("update " + "t_remote_measure" + " set " +
|
|
@@ -85,6 +94,12 @@ public class MySqlUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 记录电度数据-每一条新增保存
|
|
|
+ * @param positionNum
|
|
|
+ * @param result
|
|
|
+ * @param time
|
|
|
+ */
|
|
|
public static void addRemoteDegreeByPositionNum(Integer positionNum, String result, String time) {
|
|
|
Statement stmt = null;
|
|
|
try {
|
|
@@ -116,4 +131,60 @@ public class MySqlUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 查询遥测最高最低点位
|
|
|
+ * 查询电度最高最低点位
|
|
|
+ * @param type 1 遥测
|
|
|
+ * 2 电度
|
|
|
+ */
|
|
|
+ public static Map<String, Integer> selectRemotePositionMap(int type) {
|
|
|
+ Statement stmt = null;
|
|
|
+ ResultSet rs = null;
|
|
|
+ Map<String, Integer> map= new HashMap<>();
|
|
|
+ if(type==1){
|
|
|
+ map.put("low", remote_config_measure_min);
|
|
|
+ map.put("max", remote_config_measure_max);
|
|
|
+ }else{
|
|
|
+ map.put("low", remote_config_degree_min);
|
|
|
+ map.put("max", remote_config_degree_max);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ StringBuffer sql = new StringBuffer("select content");
|
|
|
+ sql.append(" from t_sys_config where ");
|
|
|
+ sql.append(" code = '" + remote_config + "' ");
|
|
|
+ log.info("----------" + sql.toString());
|
|
|
+ conn = getConnection();
|
|
|
+ stmt = conn.createStatement();
|
|
|
+ rs = stmt.executeQuery(sql.toString());
|
|
|
+ rs.next();
|
|
|
+ String content = rs.getString(1);
|
|
|
+ if(StringUtils.isBlank(content)){
|
|
|
+ log.error("点位最低最高未配置,将使用默认配置,请联系管理员配置,结构:遥测最低,遥测最高;电度最低,电度最高");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+ String[] arr = content.split(";");
|
|
|
+ if(type==1){
|
|
|
+ map.put("min", Integer.valueOf(arr[0].split(",")[0]));
|
|
|
+ map.put("max", Integer.valueOf(arr[0].split(",")[1]));
|
|
|
+ }else{
|
|
|
+ map.put("min", Integer.valueOf(arr[1].split(",")[0]));
|
|
|
+ map.put("max", Integer.valueOf(arr[1].split(",")[1]));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ stmt.close();
|
|
|
+ rs.close();
|
|
|
+ closeConn();
|
|
|
+ } catch (Exception e1) {
|
|
|
+ e1.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void handler(){
|
|
|
+
|
|
|
+ }
|
|
|
}
|