|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.CharsetUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.http.HttpUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.jiayue.client.util.Constants;
|
|
import com.jiayue.client.util.MD5Util;
|
|
import com.jiayue.client.util.MD5Util;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
|
@@ -18,11 +19,9 @@ import java.util.*;
|
|
@Repository
|
|
@Repository
|
|
@Slf4j
|
|
@Slf4j
|
|
public class SendDataService {
|
|
public class SendDataService {
|
|
- public final QueryDataService queryDataService;
|
|
|
|
//青海回传数据通用签名key
|
|
//青海回传数据通用签名key
|
|
- private final static String qinghaiKey = "Syjy*3377";
|
|
|
|
-
|
|
|
|
- public static Properties properties;
|
|
|
|
|
|
+ private final static String QINGHAIKEY = "Syjy*3377";
|
|
|
|
+ protected static Properties properties;
|
|
|
|
|
|
static {
|
|
static {
|
|
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
|
|
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
|
|
@@ -30,6 +29,8 @@ public class SendDataService {
|
|
properties = yaml.getObject();
|
|
properties = yaml.getObject();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public final QueryDataService queryDataService;
|
|
|
|
+
|
|
public SendDataService(QueryDataService queryDataService) {
|
|
public SendDataService(QueryDataService queryDataService) {
|
|
this.queryDataService = queryDataService;
|
|
this.queryDataService = queryDataService;
|
|
}
|
|
}
|
|
@@ -46,7 +47,7 @@ public class SendDataService {
|
|
try {
|
|
try {
|
|
List<Map<String, Object>> stations = queryDataService.getStations();
|
|
List<Map<String, Object>> stations = queryDataService.getStations();
|
|
for (Map<String, Object> station : stations) {
|
|
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)) {
|
|
if ("".equals(flag) || "all".equals(flag)) {
|
|
sendAll(startTime, endTime, stationCode);
|
|
sendAll(startTime, endTime, stationCode);
|
|
@@ -115,18 +116,18 @@ public class SendDataService {
|
|
List<Map<String, Object>> valueList = new ArrayList<>();
|
|
List<Map<String, Object>> valueList = new ArrayList<>();
|
|
for (Map<String, Object> powerStationStatusData : rps) {
|
|
for (Map<String, Object> powerStationStatusData : rps) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
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"));
|
|
valueMap.put("value", powerStationStatusData.get("C_REAL_VALUE"));
|
|
valueList.add(valueMap);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
|
|
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("rp", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("rp", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("向数据中心发送短期数据出现错误:{}", e);
|
|
|
|
|
|
+ log.error("向数据中心发送实际功率数据出现错误:{}", e);
|
|
//TODO 微信警告
|
|
//TODO 微信警告
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -147,11 +148,11 @@ public class SendDataService {
|
|
for (Map<String, Object> forecastPowerUltraShortTermHis : dqs) {
|
|
for (Map<String, Object> forecastPowerUltraShortTermHis : dqs) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
valueMap.put("time", forecastPowerUltraShortTermHis.get("C_FORECAST_TIME"));
|
|
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);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("dq", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("dq", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -176,17 +177,17 @@ public class SendDataService {
|
|
for (Map<String, Object> forecastPowerShortTermHis : cdqs) {
|
|
for (Map<String, Object> forecastPowerShortTermHis : cdqs) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
valueMap.put("time", forecastPowerShortTermHis.get("C_FORECAST_TIME"));
|
|
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);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("cdq", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("cdq", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("向数据中心发送短期数据出现错误:{}", e);
|
|
|
|
|
|
+ log.error("向数据中心发送超短期数据出现错误:{}", e);
|
|
//TODO 微信警告
|
|
//TODO 微信警告
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -206,22 +207,22 @@ public class SendDataService {
|
|
//遍历设备列表
|
|
//遍历设备列表
|
|
for (Map<String, Object> weatherStationInfo : weatherStationInfos) {
|
|
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);
|
|
List<Map<String, Object>> cdqs = queryDataService.getWeatherds(startTime, endTime, equipmentNo);
|
|
for (Map<String, Object> weatherStationStatusData : cdqs) {
|
|
for (Map<String, Object> weatherStationStatusData : cdqs) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
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("wsNo", equipmentNo);
|
|
- valueMap.put("stationCode", stationCode);
|
|
|
|
|
|
+ valueMap.put(Constants.stationCode_FIELD, stationCode);
|
|
valueMap.put("globalr", weatherStationStatusData.get("C_GLOBALR"));
|
|
valueMap.put("globalr", weatherStationStatusData.get("C_GLOBALR"));
|
|
valueMap.put("airt", weatherStationStatusData.get("C_AIRT"));
|
|
valueMap.put("airt", weatherStationStatusData.get("C_AIRT"));
|
|
valueList.add(valueMap);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("qxz", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("qxz", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -243,22 +244,22 @@ public class SendDataService {
|
|
//遍历设备列表
|
|
//遍历设备列表
|
|
for (Map<String, Object> windTowerInfo : windTowerInfos) {
|
|
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);
|
|
List<Map<String, Object>> windTowerStatusDatas = queryDataService.getCfts(startTime, endTime, equipmentNo);
|
|
for (Map<String, Object> windTowerStatusData : windTowerStatusDatas) {
|
|
for (Map<String, Object> windTowerStatusData : windTowerStatusDatas) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
valueMap.put("time", windTowerStatusData.get("C_TIME"));
|
|
valueMap.put("time", windTowerStatusData.get("C_TIME"));
|
|
valueMap.put("atNo", equipmentNo);
|
|
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("speed", windTowerStatusData.get("C_WS_INST_HUB_HEIGHT"));
|
|
valueMap.put("direction", windTowerStatusData.get("C_WD_INST_HUB_HEIGHT"));
|
|
valueMap.put("direction", windTowerStatusData.get("C_WD_INST_HUB_HEIGHT"));
|
|
valueList.add(valueMap);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("cft", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("cft", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -280,22 +281,22 @@ public class SendDataService {
|
|
//遍历设备列表
|
|
//遍历设备列表
|
|
for (Map<String, Object> windTurbineInfo : windTurbineInfos) {
|
|
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);
|
|
List<Map<String, Object>> windTurbineDatas = queryDataService.getFjs(startTime, endTime, equipmentNo);
|
|
for (Map<String, Object> windTurbineData : windTurbineDatas) {
|
|
for (Map<String, Object> windTurbineData : windTurbineDatas) {
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
Map<String, Object> valueMap = new HashMap<>();
|
|
valueMap.put("time", windTurbineData.get("C_TIME"));
|
|
valueMap.put("time", windTurbineData.get("C_TIME"));
|
|
valueMap.put("atNo", equipmentNo);
|
|
valueMap.put("atNo", equipmentNo);
|
|
- valueMap.put("stationCode", stationCode);
|
|
|
|
|
|
+ valueMap.put(Constants.stationCode_FIELD, stationCode);
|
|
valueMap.put("speed", windTurbineData.get("C_WS"));
|
|
valueMap.put("speed", windTurbineData.get("C_WS"));
|
|
valueMap.put("direction", windTurbineData.get("C_WD"));
|
|
valueMap.put("direction", windTurbineData.get("C_WD"));
|
|
valueList.add(valueMap);
|
|
valueList.add(valueMap);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (valueList.size() > 0) {
|
|
|
|
|
|
+ if (!valueList.isEmpty()) {
|
|
createReqAndSend("fj", JSONUtil.toJsonStr(valueList));
|
|
createReqAndSend("fj", JSONUtil.toJsonStr(valueList));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -311,23 +312,22 @@ public class SendDataService {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
resultMap.put("type", dataType);
|
|
resultMap.put("type", dataType);
|
|
resultMap.put("body", valueList);
|
|
resultMap.put("body", valueList);
|
|
- String sign = MD5Util.encode(valueList + qinghaiKey, "MD5");
|
|
|
|
|
|
+ String sign = MD5Util.encode(valueList + QINGHAIKEY, "MD5");
|
|
resultMap.put("sign", sign);
|
|
resultMap.put("sign", sign);
|
|
|
|
|
|
String reqStr = JSONUtil.toJsonStr(resultMap);
|
|
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<>();
|
|
Map<String, Object> reqMap = new HashMap<>();
|
|
reqMap.put("reqMsg", Base64.encode(ZipUtil.gzip(reqStr, CharsetUtil.CHARSET_UTF_8.name())));
|
|
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);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|