Jelajahi Sumber

1.client代码优化

wangtao 3 tahun lalu
induk
melakukan
14b0261aff

+ 2 - 2
ipfcst-client/src/main/java/com/jiayue/client/controller/ConsoleController.java

@@ -5,7 +5,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 
-import java.util.HashMap;
+import java.util.Map;
 
 /**
  * 青海集中功率预测首页
@@ -14,7 +14,7 @@ import java.util.HashMap;
 @Slf4j
 public class ConsoleController {
     @RequestMapping("/common")
-    public String common(HashMap<String, Object> map, Model model) {
+    public String common(Map<String, Object> map, Model model) {
         model.addAttribute("say", "欢迎欢迎,热烈欢迎");
         map.put("hello", "欢迎进入HTML页面");
         return "index";

+ 39 - 42
ipfcst-client/src/main/java/com/jiayue/client/job/DownloadFileJob.java

@@ -30,11 +30,7 @@ import java.util.Properties;
 @Slf4j
 public class DownloadFileJob {
 
-    public final QueryDataService queryDataService;
-    //获取下载到文件,从临时目录移动到目标目录
-    public static List<String> filedownLoadList = new ArrayList<>();
-    public static List<String> isDownFileId = new ArrayList<>();
-    public static Properties properties;
+    protected final static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -42,6 +38,11 @@ public class DownloadFileJob {
         properties = yaml.getObject();
     }
 
+    public final QueryDataService queryDataService;
+    //获取下载到文件,从临时目录移动到目标目录
+    public final List<String> filedownLoadList = new ArrayList<>();
+    public final List<String> isDownFileId = new ArrayList<>();
+
     public DownloadFileJob(QueryDataService queryDataService) {
         this.queryDataService = queryDataService;
     }
@@ -54,57 +55,53 @@ public class DownloadFileJob {
         log.info("上午文件下载定时任务开始");
         List<Map<String, Object>> stations = queryDataService.getStations();
         for (Map<String, Object> station : stations) {
-            String stationCode = Convert.toStr(station.get("C_STATION_CODE"));
-            log.info("开始执行定时任务:http下载场站:{} 的文件。", stationCode);
-            String body = HttpRequest.get(properties.getProperty("v3cloud.filelogUrl") + stationCode).execute().body();
-            JSONObject json = JSONUtil.parseObj(body);
-            String code = json.get("code").toString();
-            String data = json.get("data").toString();
-            if (code.equals("0") && data.length() > 0) {
-                JSONArray array = JSONUtil.parseArray(data);
-                List<FileCreateLog> list = array.toList(FileCreateLog.class);
-                String path = FileUtil.judeDirExists(properties.getProperty("local.downFilePath"));
-
-                try {
+            try {
+                String stationCode = Convert.toStr(station.get("C_STATION_CODE"));
+                log.info("开始执行定时任务:http下载场站:{} 的文件。", stationCode);
+                String body = HttpRequest.get(properties.getProperty("v3cloud.filelogUrl") + stationCode).execute().body();
+                JSONObject json = JSONUtil.parseObj(body);
+                String code = json.get("code").toString();
+                String data = json.get("data").toString();
+                if (code.equals("0") && data.length() > 0) {
+                    JSONArray array = JSONUtil.parseArray(data);
+                    List<FileCreateLog> list = array.toList(FileCreateLog.class);
+                    String path = FileUtil.judeDirExists(properties.getProperty("local.downFilePath"));
                     for (FileCreateLog fileCreateLog : list) {
                         if (isDownFileId.contains(fileCreateLog.getId())) {
                             log.info("文件:{}已下载。", fileCreateLog.getFileName());
                             continue;
                         }
                         log.info("开始下载文件:{}。", fileCreateLog.getFileName());
-                        String url = properties.getProperty("v3cloud.fileDownUrl") + fileCreateLog.getId();// "https://117.78.19.70:9010/client/getFileById?id=" + fileCreateLog.getId();
-                        String targetPath = path + File.separatorChar +stationCode+File.separatorChar +"new"+File.separatorChar+ fileCreateLog.getFileName();
-                        long size = HttpUtil.downloadFile(url,targetPath);
+                        String url = properties.getProperty("v3cloud.fileDownUrl") + fileCreateLog.getId();
+                        String targetPath = path + File.separatorChar + stationCode + File.separatorChar + "new" + File.separatorChar + fileCreateLog.getFileName();
+
+                        long size = HttpUtil.downloadFile(url, targetPath);
                         if (size > 0) {
                             isDownFileId.add(fileCreateLog.getId());
-                            log.info("成功下载文件:{}", targetPath);
+                            log.debug("成功下载文件:{}", targetPath);
                             filedownLoadList.add(targetPath);
                         }
                     }
-                } catch (Exception e) {
-                    log.error("文件下载失败:{}", e);
-                } finally {
-                    //把下载的文件挪到功率预测服务器文件夹
-                    if (filedownLoadList.size() > 0) {
-                        log.info("开始移动下载文件到功率预测,共:{} 个文件。", filedownLoadList.size());
-                        for (String fpath : filedownLoadList) {
-                            try {
-                                Scpclient scpclient = Scpclient.getInstance(properties.getProperty("remote.ip"),
-                                        Convert.toInt(properties.getProperty("remote.port")), properties.getProperty("remote.user"),
-                                        properties.getProperty("remote.pwd"));
+                }
+                if (!filedownLoadList.isEmpty()) {
+                    log.debug("开始移动下载文件到功率预测,共:{} 个文件。", filedownLoadList.size());
+                    for (String filePath : filedownLoadList) {
+
+                        Scpclient scpclient = Scpclient.getInstance(properties.getProperty("remote.ip"),
+                                Convert.toInt(properties.getProperty("remote.port")), properties.getProperty("remote.user"),
+                                properties.getProperty("remote.pwd"));
+
+                        scpclient.putFile(filePath, properties.getProperty("remote.path") + stationCode + "/new/");
+                        log.info("移动文件:{} 到远程服务器 {} 成功", filePath, properties.getProperty("remote.path") + stationCode + "/new/");
 
-                                scpclient.putFile(fpath, properties.getProperty("remote.path") + stationCode + "/new/");
-                                log.info("移动文件:{} 到远程服务器 {} 成功", fpath, properties.getProperty("remote.path") + stationCode + "/new/");
-                            } catch (Exception e) {
-                                log.error("移动文件到功率预测服务器失败:{}", e);
-                            }
-                        }
-                        log.info("所有文件移动完成,清空文件临时filedownLoadList");
-                        filedownLoadList.clear();
-                    } else {
-                        log.info("没有新文件下载,不需要移动到远程功率预测服务器。");
                     }
+                    log.debug("所有文件移动完成,清空文件临时filedownLoadList");
+                    filedownLoadList.clear();
+                } else {
+                    log.info("没有新文件下载,不需要移动到远程功率预测服务器。");
                 }
+            } catch (Exception e) {
+                log.error("文件下载失败:{}", e);
             }
         }
 

+ 14 - 16
ipfcst-client/src/main/java/com/jiayue/client/job/SendDataToDcJob.java

@@ -18,30 +18,19 @@ import java.util.Date;
 @Slf4j
 public class SendDataToDcJob {
 
+    public final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     public final SendDataService sendDataService;
-    public static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     public SendDataToDcJob(SendDataService sendDataService) {
         this.sendDataService = sendDataService;
     }
 
-
-    /**
-     * 每天凌晨2点执行
-     */
-    @Scheduled(cron = "0 0/5 * * * ?")
-    public void sendJob() {
-        log.info("时间 【" + System.currentTimeMillis() + "】 向数据中心发送青海集中功率预测前一天的实际功率等数据。数据范围:【{}--{}】", getDayStartTime(), getDayLastTime());
-        sendDataService.send(getDayStartTime(), getDayLastTime(), "all");
-    }
-
-
     /**
      * 获取当前时间所在天的0点0分
      *
      * @return 0点0分的毫秒
      */
-    public static String getDayStartTime() {
+    public String getDayStartTime() {
         Calendar date = Calendar.getInstance();
         date.setTime(new Date());
         date.set(Calendar.HOUR_OF_DAY, 0);
@@ -49,7 +38,7 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 0);
         date.set(Calendar.MILLISECOND, 0);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        return formatter.format(date.getTime());
+        return this.formatter.format(date.getTime());
     }
 
     /**
@@ -57,7 +46,7 @@ public class SendDataToDcJob {
      *
      * @return 23点59分59秒的毫秒
      */
-    public static String getDayLastTime() {
+    public String getDayLastTime() {
         Calendar date = Calendar.getInstance();
         date.setTime(new Date());
         date.set(Calendar.HOUR_OF_DAY, 23);
@@ -65,6 +54,15 @@ public class SendDataToDcJob {
         date.set(Calendar.SECOND, 59);
         date.set(Calendar.MILLISECOND, 999);
         date.add(Calendar.DAY_OF_MONTH, -1);
-        return formatter.format(date.getTime());
+        return this.formatter.format(date.getTime());
+    }
+
+    /**
+     * 每天凌晨2点执行
+     */
+    @Scheduled(cron = "0 0/5 * * * ?")
+    public void sendJob() {
+        log.info("时间 【" + System.currentTimeMillis() + "】 向数据中心发送青海集中功率预测前一天的实际功率等数据。数据范围:【{}--{}】", getDayStartTime(), getDayLastTime());
+        sendDataService.send(getDayStartTime(), getDayLastTime(), "all");
     }
 }

+ 13 - 6
ipfcst-client/src/main/java/com/jiayue/client/service/QueryDataService.java

@@ -13,6 +13,7 @@ import java.util.Map;
 @Repository
 @Slf4j
 public class QueryDataService {
+    private final static String WHITH_AND_SQL_STR = "'and '";
     private final JdbcTemplate jdbcTemplate;
 
     public QueryDataService(JdbcTemplate jdbcTemplate) {
@@ -53,7 +54,7 @@ public class QueryDataService {
     public List<Map<String, Object>> getRps(String startTime, String endTime, String stationCode) {
         String rpsSql = "SELECT C_TIME,C_STATION_CODE,C_REAL_VALUE " +
                 "from t_power_station_status_data where C_STATION_CODE='" + stationCode +
-                "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+                "' and C_TIME between '" + startTime + WHITH_AND_SQL_STR + endTime + "'";
         log.info("实际功率回传数据查询sql:{}", rpsSql);
         return jdbcTemplate.queryForList(rpsSql);
     }
@@ -70,7 +71,7 @@ public class QueryDataService {
         String dqsSql = "SELECT C_FORECAST_TIME,C_STATION_CODE,C_ABLE_VALUE " +
                 "from t_forecast_power_short_term_his where C_STATION_CODE='" + stationCode +
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
-                "'and '" + changStrTimeToLongTime(endTime) + "'";
+                WHITH_AND_SQL_STR + changStrTimeToLongTime(endTime) + "'";
         log.info("短期回传数据查询sql:{}", dqsSql);
         return jdbcTemplate.queryForList(dqsSql);
     }
@@ -87,7 +88,7 @@ public class QueryDataService {
         String cdqsSql = "SELECT C_FORECAST_TIME,C_STATION_CODE,C_ABLE_VALUE " +
                 "from t_forecast_power_ultra_short_term_his where C_STATION_CODE='" + stationCode +
                 "' and C_FORECAST_TIME between '" + changStrTimeToLongTime(startTime) +
-                "'and '" + changStrTimeToLongTime(endTime) + "'";
+                WHITH_AND_SQL_STR + changStrTimeToLongTime(endTime) + "'";
         log.info("超短期回传数据查询sql:{}", cdqsSql);
         return jdbcTemplate.queryForList(cdqsSql);
     }
@@ -102,7 +103,9 @@ public class QueryDataService {
      */
     public List<Map<String, Object>> getWeatherds(String startTime, String endTime, String equirpmentNo) {
         String wedSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_GLOBALR,C_AIRT " +
-                "from t_weather_station_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+                "from t_weather_station_status_data where C_EQUIPMENT_ID='" + equirpmentNo
+                + "' and C_TIME between '" + startTime
+                + WHITH_AND_SQL_STR + endTime + "'";
         log.info("超短期回传数据查询sql:{}", wedSql);
         return jdbcTemplate.queryForList(wedSql);
     }
@@ -117,7 +120,9 @@ public class QueryDataService {
      */
     public List<Map<String, Object>> getCfts(String startTime, String endTime, String equirpmentNo) {
         String cftsSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_WS_INST_HUB_HEIGHT,C_WD_INST_HUB_HEIGHT " +
-                "from t_wind_tower_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+                "from t_wind_tower_status_data where C_EQUIPMENT_ID='" + equirpmentNo
+                + "' and C_TIME between '" + startTime
+                + WHITH_AND_SQL_STR + endTime + "'";
         log.info("测风塔回传数据查询sql:{}", cftsSql);
 
         return jdbcTemplate.queryForList(cftsSql);
@@ -133,7 +138,9 @@ public class QueryDataService {
      */
     public List<Map<String, Object>> getFjs(String startTime, String endTime, String equirpmentNo) {
         String fjsSql = "SELECT C_TIME,C_EQUIPMENT_ID,C_WS,C_WD " +
-                "from t_wind_turbine_status_data where C_EQUIPMENT_ID='" + equirpmentNo + "' and C_TIME between '" + startTime + "'and '" + endTime + "'";
+                "from t_wind_turbine_status_data where C_EQUIPMENT_ID='" + equirpmentNo
+                + "' and C_TIME between '" + startTime
+                + WHITH_AND_SQL_STR + endTime + "'";
         log.info("风机回传数据查询sql:{}", fjsSql);
         return jdbcTemplate.queryForList(fjsSql);
     }

+ 41 - 41
ipfcst-client/src/main/java/com/jiayue/client/service/SendDataService.java

@@ -6,6 +6,7 @@ import cn.hutool.core.util.CharsetUtil;
 import cn.hutool.core.util.ZipUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONUtil;
+import com.jiayue.client.util.Constants;
 import com.jiayue.client.util.MD5Util;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
@@ -18,11 +19,9 @@ import java.util.*;
 @Repository
 @Slf4j
 public class SendDataService {
-    public final QueryDataService queryDataService;
     //青海回传数据通用签名key
-    private final static String qinghaiKey = "Syjy*3377";
-
-    public static Properties properties;
+    private final static String QINGHAIKEY = "Syjy*3377";
+    protected static Properties properties;
 
     static {
         YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
@@ -30,6 +29,8 @@ public class SendDataService {
         properties = yaml.getObject();
     }
 
+    public final QueryDataService queryDataService;
+
     public SendDataService(QueryDataService queryDataService) {
         this.queryDataService = queryDataService;
     }
@@ -46,7 +47,7 @@ public class SendDataService {
         try {
             List<Map<String, Object>> stations = queryDataService.getStations();
             for (Map<String, Object> station : stations) {
-                String stationCode = Convert.toStr(station.get("C_STATION_CODE"));
+                String stationCode = Convert.toStr(station.get(Constants.C_STATION_CODE_FIELD));
 
                 if ("".equals(flag) || "all".equals(flag)) {
                     sendAll(startTime, endTime, stationCode);
@@ -115,18 +116,18 @@ public class SendDataService {
             List<Map<String, Object>> valueList = new ArrayList<>();
             for (Map<String, Object> powerStationStatusData : rps) {
                 Map<String, Object> valueMap = new HashMap<>();
-                valueMap.put("time", powerStationStatusData.get("C_TIME"));
-                valueMap.put("stationCode", powerStationStatusData.get("C_STATION_CODE"));
+                valueMap.put("time", powerStationStatusData.get(Constants.C_TIME_FIELD));
+                valueMap.put(Constants.stationCode_FIELD, powerStationStatusData.get(Constants.C_STATION_CODE_FIELD));
                 valueMap.put("value", powerStationStatusData.get("C_REAL_VALUE"));
                 valueList.add(valueMap);
             }
 
-            if (valueList.size() > 0) {
+            if (!valueList.isEmpty()) {
                 createReqAndSend("rp", JSONUtil.toJsonStr(valueList));
             }
 
         } catch (Exception e) {
-            log.error("向数据中心发送短期数据出现错误:{}", e);
+            log.error("向数据中心发送实际功率数据出现错误:{}", e);
             //TODO 微信警告
         }
     }
@@ -147,11 +148,11 @@ public class SendDataService {
             for (Map<String, Object> forecastPowerUltraShortTermHis : dqs) {
                 Map<String, Object> valueMap = new HashMap<>();
                 valueMap.put("time", forecastPowerUltraShortTermHis.get("C_FORECAST_TIME"));
-                valueMap.put("value", forecastPowerUltraShortTermHis.get("C_ABLE_VALUE"));
-                valueMap.put("stationCode", forecastPowerUltraShortTermHis.get("C_STATION_CODE"));
+                valueMap.put("value", forecastPowerUltraShortTermHis.get(Constants.C_ABLE_VALUE_FIELD));
+                valueMap.put(Constants.stationCode_FIELD, forecastPowerUltraShortTermHis.get(Constants.C_STATION_CODE_FIELD));
                 valueList.add(valueMap);
             }
-            if (valueList.size() > 0) {
+            if (!valueList.isEmpty()) {
                 createReqAndSend("dq", JSONUtil.toJsonStr(valueList));
             }
 
@@ -176,17 +177,17 @@ public class SendDataService {
             for (Map<String, Object> forecastPowerShortTermHis : cdqs) {
                 Map<String, Object> valueMap = new HashMap<>();
                 valueMap.put("time", forecastPowerShortTermHis.get("C_FORECAST_TIME"));
-                valueMap.put("valueK", forecastPowerShortTermHis.get("C_ABLE_VALUE"));
-                valueMap.put("valueX", forecastPowerShortTermHis.get("C_ABLE_VALUE"));
-                valueMap.put("stationCode", forecastPowerShortTermHis.get("C_STATION_CODE"));
+                valueMap.put("valueK", forecastPowerShortTermHis.get(Constants.C_ABLE_VALUE_FIELD));
+                valueMap.put("valueX", forecastPowerShortTermHis.get(Constants.C_ABLE_VALUE_FIELD));
+                valueMap.put(Constants.stationCode_FIELD, forecastPowerShortTermHis.get(Constants.C_STATION_CODE_FIELD));
                 valueList.add(valueMap);
             }
-            if (valueList.size() > 0) {
+            if (!valueList.isEmpty()) {
                 createReqAndSend("cdq", JSONUtil.toJsonStr(valueList));
             }
 
         } catch (Exception e) {
-            log.error("向数据中心发送短期数据出现错误:{}", e);
+            log.error("向数据中心发送短期数据出现错误:{}", e);
             //TODO 微信警告
         }
     }
@@ -206,22 +207,22 @@ public class SendDataService {
         //遍历设备列表
         for (Map<String, Object> weatherStationInfo : weatherStationInfos) {
             //判断是否为检测仪设备
-            if (Convert.toStr(weatherStationInfo.get("C_EQUIPMENT_TYPE")).equals("1")) {
-                String equipmentNo = Convert.toStr(weatherStationInfo.get("C_EQUIPMENT_NO"));
+            if (Convert.toStr(weatherStationInfo.get(Constants.C_EQUIPMENT_TYPE_FIELD)).equals(Constants.C_EQUIPMENT_TYPE_1)) {
+                String equipmentNo = Convert.toStr(weatherStationInfo.get(Constants.C_EQUIPMENT_NO_FIELD));
                 //根据时间和设备号查询环境检测仪数据
                 List<Map<String, Object>> cdqs = queryDataService.getWeatherds(startTime, endTime, equipmentNo);
                 for (Map<String, Object> weatherStationStatusData : cdqs) {
                     Map<String, Object> valueMap = new HashMap<>();
-                    valueMap.put("time", weatherStationStatusData.get("C_TIME"));
+                    valueMap.put("time", weatherStationStatusData.get(Constants.C_TIME_FIELD));
                     valueMap.put("wsNo", equipmentNo);
-                    valueMap.put("stationCode", stationCode);
+                    valueMap.put(Constants.stationCode_FIELD, stationCode);
                     valueMap.put("globalr", weatherStationStatusData.get("C_GLOBALR"));
                     valueMap.put("airt", weatherStationStatusData.get("C_AIRT"));
                     valueList.add(valueMap);
                 }
             }
         }
-        if (valueList.size() > 0) {
+        if (!valueList.isEmpty()) {
             createReqAndSend("qxz", JSONUtil.toJsonStr(valueList));
         }
 
@@ -243,22 +244,22 @@ public class SendDataService {
         //遍历设备列表
         for (Map<String, Object> windTowerInfo : windTowerInfos) {
             //判断是否为测风塔设备
-            if (Convert.toStr(windTowerInfo.get("C_EQUIPMENT_TYPE")).equals("3")) {
-                String equipmentNo = Convert.toStr(windTowerInfo.get("C_EQUIPMENT_NO"));
+            if (Convert.toStr(windTowerInfo.get(Constants.C_EQUIPMENT_TYPE_FIELD)).equals(Constants.C_EQUIPMENT_TYPE_3)) {
+                String equipmentNo = Convert.toStr(windTowerInfo.get(Constants.C_EQUIPMENT_NO_FIELD));
                 //根据时间和设备号查询风速数据
                 List<Map<String, Object>> windTowerStatusDatas = queryDataService.getCfts(startTime, endTime, equipmentNo);
                 for (Map<String, Object> windTowerStatusData : windTowerStatusDatas) {
                     Map<String, Object> valueMap = new HashMap<>();
                     valueMap.put("time", windTowerStatusData.get("C_TIME"));
                     valueMap.put("atNo", equipmentNo);
-                    valueMap.put("stationCode", stationCode);
+                    valueMap.put(Constants.stationCode_FIELD, stationCode);
                     valueMap.put("speed", windTowerStatusData.get("C_WS_INST_HUB_HEIGHT"));
                     valueMap.put("direction", windTowerStatusData.get("C_WD_INST_HUB_HEIGHT"));
                     valueList.add(valueMap);
                 }
             }
         }
-        if (valueList.size() > 0) {
+        if (!valueList.isEmpty()) {
             createReqAndSend("cft", JSONUtil.toJsonStr(valueList));
         }
 
@@ -280,22 +281,22 @@ public class SendDataService {
         //遍历设备列表
         for (Map<String, Object> windTurbineInfo : windTurbineInfos) {
             //判断是否为测风塔设备
-            if (Convert.toStr(windTurbineInfo.get("C_EQUIPMENT_TYPE")).equals("4")) {
-                String equipmentNo = Convert.toStr(windTurbineInfo.get("C_EQUIPMENT_NO"));
+            if (Convert.toStr(windTurbineInfo.get(Constants.C_EQUIPMENT_TYPE_FIELD)).equals("4")) {
+                String equipmentNo = Convert.toStr(windTurbineInfo.get(Constants.C_EQUIPMENT_NO_FIELD));
                 //根据时间和设备号查询风速数据
                 List<Map<String, Object>> windTurbineDatas = queryDataService.getFjs(startTime, endTime, equipmentNo);
                 for (Map<String, Object> windTurbineData : windTurbineDatas) {
                     Map<String, Object> valueMap = new HashMap<>();
                     valueMap.put("time", windTurbineData.get("C_TIME"));
                     valueMap.put("atNo", equipmentNo);
-                    valueMap.put("stationCode", stationCode);
+                    valueMap.put(Constants.stationCode_FIELD, stationCode);
                     valueMap.put("speed", windTurbineData.get("C_WS"));
                     valueMap.put("direction", windTurbineData.get("C_WD"));
                     valueList.add(valueMap);
                 }
             }
         }
-        if (valueList.size() > 0) {
+        if (!valueList.isEmpty()) {
             createReqAndSend("fj", JSONUtil.toJsonStr(valueList));
         }
     }
@@ -311,23 +312,22 @@ public class SendDataService {
         Map<String, Object> resultMap = new HashMap<>();
         resultMap.put("type", dataType);
         resultMap.put("body", valueList);
-        String sign = MD5Util.encode(valueList + qinghaiKey, "MD5");
+        String sign = MD5Util.encode(valueList + QINGHAIKEY, "MD5");
         resultMap.put("sign", sign);
 
         String reqStr = JSONUtil.toJsonStr(resultMap);
-        log.info("回传数据给数据中心,请求原报文:{}", reqStr);
-        log.info("回传数据给数据中心,请求地址:{}", properties.getProperty("remote.dcUrl")+"");
+        log.debug("回传数据给数据中心,请求原报文:{}", reqStr);
+        log.debug("回传数据给数据中心,请求地址:{}", properties.getProperty("remote.dcUrl") + "");
         Map<String, Object> reqMap = new HashMap<>();
         reqMap.put("reqMsg", Base64.encode(ZipUtil.gzip(reqStr, CharsetUtil.CHARSET_UTF_8.name())));
-        log.info("回传数据给数据中心,压缩加密后报文:{}", reqMap);
-        String resp = HttpUtil.get(properties.getProperty("remote.dcUrl"),reqMap);
-       // String resp = HttpUtil.post(properties.getProperty("remote.dcUrl")+"", reqStr);
-        if (resp.length() > 0) {
-            if (!"0".equals(JSONUtil.parseObj(resp).get("code"))) {
-                new Exception("回传数据给数据中心错误:" + resp);
-            }
+        log.debug("回传数据给数据中心,压缩加密后报文:{}", reqMap);
+        String resp = HttpUtil.get(properties.getProperty("remote.dcUrl"), reqMap);
+        if (resp.length() > 0 && (0 == JSONUtil.parseObj(resp).getInt("code"))) {
+            log.info("回传数据给数据中心成功,获得响应报文:{}", resp);
+        } else {
+            log.error("回传数据给数据中心错误:{}", resp);
         }
-        log.info("回传数据给数据中心,获得响应报文:{}", resp);
+
     }
 
 }

+ 13 - 0
ipfcst-client/src/main/java/com/jiayue/client/util/Constants.java

@@ -0,0 +1,13 @@
+package com.jiayue.client.util;
+
+public class Constants {
+    public static final String C_STATION_CODE_FIELD = "C_STATION_CODE";
+    public static final String C_ABLE_VALUE_FIELD = "C_ABLE_VALUE";
+    public static final String C_EQUIPMENT_TYPE_FIELD = "C_EQUIPMENT_TYPE";
+    public static final String C_EQUIPMENT_TYPE_1 = "1";
+    public static final String C_EQUIPMENT_TYPE_2 = "2";
+    public static final String C_EQUIPMENT_TYPE_3 = "3";
+    public static final String C_EQUIPMENT_NO_FIELD = "C_EQUIPMENT_NO";
+    public static final String stationCode_FIELD = "stationCode";
+    public static final String C_TIME_FIELD = "C_TIME";
+}

+ 1 - 7
ipfcst-client/src/main/java/com/jiayue/client/util/MD5Util.java

@@ -8,13 +8,7 @@ import java.security.MessageDigest;
  * @author Administrator
  */
 public class MD5Util {
-
-
-    //工具类不允许被实例化
-    private MD5Util() throws Exception {
-        throw new Exception("异常");
-    }
-
+    
     public static String encode(String str) {
         MessageDigest md5;
         try {

+ 4 - 7
ipfcst-client/src/main/java/com/jiayue/client/util/Scpclient.java

@@ -44,16 +44,13 @@ public class Scpclient {
             conn.connect();
             boolean isAuthenticated = conn.authenticateWithPassword(username,
                     password);
-            if (!isAuthenticated) {
-                log.info("authentication failed");
-                return null;
+            if (isAuthenticated) {
+                SCPClient client = new SCPClient(conn);
+                client.get(remoteFile, localTargetDirectory);
+                conn.close();
             }
-            SCPClient client = new SCPClient(conn);
-            client.get(remoteFile, localTargetDirectory);
-            conn.close();
         } catch (IOException e) {
             log.info(e.getMessage());
-            return null;
         }
         return null;
     }

+ 2 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerShortTermController.java

@@ -38,7 +38,7 @@ public class ForecastPowerShortTermController {
       map = forecastPowerShortTermService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
+      log.error("按时间查询实时预测短期错误:{}",e);
       return ResponseVO.fail(e.getMessage());
     }
   }
@@ -65,7 +65,7 @@ public class ForecastPowerShortTermController {
       map = forecastPowerShortTermService.findByTimeBetweenAndNoForPaging(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
+      log.error("按时间查询实时预测短期错误-分页查询:{}",e);
       return ResponseVO.fail(e.toString());
     }
   }

+ 1 - 1
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerShortTermHisController.java

@@ -42,7 +42,7 @@ public class ForecastPowerShortTermHisController {
       map = forecastPowerShortTermHisService.findByForecastTimeBetweenAndStationCode(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
+      log.error("按时间查询历史预测短期错误:{}",e);
       return ResponseVO.fail(e.toString());
     }
   }

+ 2 - 2
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/ForecastPowerUltraShortTermHisController.java

@@ -43,7 +43,7 @@ public class ForecastPowerUltraShortTermHisController {
       map = forecastPowerUltraShortTermService.findByForecastTimeBetweenAndForecastHowLongAgoOrderByForecastTime(startTime, endTime, ago);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
+      log.error("按时间查询历史预测超短期错误:{}",e);
       return ResponseVO.fail(e.toString());
     }
   }
@@ -62,7 +62,7 @@ public class ForecastPowerUltraShortTermHisController {
       map = forecastPowerUltraShortTermService.findByForecastRealTimeUltraShortTerm16(startTime, stationCode);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
+      log.error("查询超短期16个点的信息错误:{}",e);
       return ResponseVO.fail(e.toString());
     }
   }

+ 2 - 4
ipfcst-console/src/main/java/com/jiayue/ipfcst/console/controller/NwpController.java

@@ -43,8 +43,7 @@ public class NwpController {
       map = nwpService.findByForecastTimeBetween(startTime, endTime, stationCode);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
-      log.error("nwp实时查询错误");
+      log.error("nwp实时查询错误:{}", e);
       return ResponseVO.fail(e.toString());
     }
   }
@@ -71,8 +70,7 @@ public class NwpController {
       map = nwpService.findByTimeBetweenAndNoForPaging(startTime, endTime, stationCode, page, size, sortOrder);
       return ResponseVO.success(map);
     } catch (Exception e) {
-      e.printStackTrace();
-      log.error("nwp实时分页查询错误");
+      log.error("nwp实时分页查询错误:{}", e);
       return ResponseVO.fail(e.toString());
     }
   }