Commit eb833983 authored by wujiang's avatar wujiang

修改采集问题

parent aefbd010
...@@ -147,7 +147,12 @@ public class ImasterUtils { ...@@ -147,7 +147,12 @@ public class ImasterUtils {
} else { } else {
jsonArray = handlerResponseByResultResolveruleOther(ResultResolveRule, respone); jsonArray = handlerResponseByResultResolveruleOther(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) { if (!ObjectUtils.isEmpty(jsonArray)) {
try {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass); result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
} catch (Exception e) {
e.printStackTrace();
logger.error("华为数据解析错误(getResPonseOther):" + jsonArray.toJSONString());
}
} }
} }
} else { } else {
...@@ -211,6 +216,10 @@ public class ImasterUtils { ...@@ -211,6 +216,10 @@ public class ImasterUtils {
String[] rules = resultResovle.split(","); String[] rules = resultResovle.split(",");
if (rules.length > 0) { if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) { for (int i = 0; i < rules.length; i++) {
if ("ACCESS_FREQUENCY_IS_TOO_HIGH".equals(jsonObject.get(rules[i]))) {
logger.error("华为数据解析错误():请求系统次数太频繁,无法获取接口数据");
continue;
}
try { try {
jsonObject = (JSONObject) jsonObject.get(rules[i]); jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) { if (jsonObject == null) {
......
...@@ -116,7 +116,14 @@ public class SunlightUtil { ...@@ -116,7 +116,14 @@ public class SunlightUtil {
{ {
put("1", "在线"); put("1", "在线");
put("0", "离线"); put("0", "离线");
put("2","报警" ); }
};
public static final HashMap<String, String> gzzt= new HashMap<String, String>() {
{
put("1", "故障");
put("2", "报警");
put("4", "正常" );
} }
}; };
......
...@@ -6,6 +6,8 @@ import cn.hutool.json.JSONObject; ...@@ -6,6 +6,8 @@ import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.JsonObject;
import com.qiniu.util.Json;
import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil; import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.ImasterConstant; import com.yeejoin.amos.api.householdapi.constant.ImasterConstant;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant; import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
...@@ -114,7 +116,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -114,7 +116,6 @@ public class SunlightServiceImpl implements SunlightService {
for (Sunlight sunlight : list) { for (Sunlight sunlight : list) {
sunlight.setCreatedTime(System.currentTimeMillis()); sunlight.setCreatedTime(System.currentTimeMillis());
sunlightMapper.insert(sunlight); sunlightMapper.insert(sunlight);
} }
logger.info("-------阳光同步电站/逆变器/采集器结束" + ts + "------- " + sdf.format(new Date())); logger.info("-------阳光同步电站/逆变器/采集器结束" + ts + "------- " + sdf.format(new Date()));
...@@ -194,36 +195,68 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -194,36 +195,68 @@ public class SunlightServiceImpl implements SunlightService {
jpStation.setSnCode(sunlightDto.getPs_id().toString());// sncode jpStation.setSnCode(sunlightDto.getPs_id().toString());// sncode
try {
Map<String, String> map = sunlightDto.getTotal_capcity(); Map<String, String> map = sunlightDto.getTotal_capcity();
jpStation.setCapacity( if (map != null && map.get("unit") != null && !map.get("unit").isEmpty()
map != null && map.get("unit") != null ? SunlightUtil.zj.get(String.valueOf(map.get("unit"))) && !"--".equals(map.get("value"))) {
* Double.valueOf(String.valueOf(map.get("value"))) : null);// 装机容量 jpStation.setCapacity(SunlightUtil.zj.get(String.valueOf(map.get("unit")))
* Double.valueOf(String.valueOf(map.get("value"))));// 装机容量
}
Map<String, String> map1 = sunlightDto.getCurr_power(); Map<String, String> map1 = sunlightDto.getCurr_power();
jpStation.setRealTimePower( if (map1 != null && map1.get("unit") != null && !map1.get("unit").isEmpty()
map1 != null && map1.get("unit") != null ? SunlightUtil.GL.get(String.valueOf(map1.get("unit"))) && !"--".equals(map1.get("value"))) {
* Double.valueOf(String.valueOf(map1.get("value"))) : null);// 实时功率 jpStation.setRealTimePower(SunlightUtil.GL.get(String.valueOf(map1.get("unit")))
* Double.valueOf(String.valueOf(map1.get("value"))));// 实时功率
}
Map<String, String> map2 = sunlightDto.getToday_energy(); Map<String, String> map2 = sunlightDto.getToday_energy();
jpStation.setDayGenerate( if (map2 != null && map2.get("unit") != null && !map2.get("unit").isEmpty()
map2 != null && map2.get("unit") != null ? SunlightUtil.fd.get(String.valueOf(map2.get("unit"))) && !"--".equals(map2.get("value"))) {
* Double.valueOf(String.valueOf(map2.get("value"))) : null);// 日发电量 jpStation.setDayGenerate(SunlightUtil.fd.get(String.valueOf(map2.get("unit")))
* Double.valueOf(String.valueOf(map2.get("value"))));// 日发电量
}
Map<String, String> map3 = sunlightDto.getTotal_energy(); Map<String, String> map3 = sunlightDto.getTotal_energy();
jpStation.setAccumulatedPower( if (map3 != null && map3.get("unit") != null && !map3.get("unit").isEmpty()
map3 != null && map3.get("unit") != null ? SunlightUtil.fd.get(String.valueOf(map3.get("unit"))) && !"--".equals(map3.get("value"))) {
* Double.valueOf(String.valueOf(map3.get("value"))) : null);// 累计发电量 jpStation.setAccumulatedPower(SunlightUtil.fd.get(String.valueOf(map3.get("unit")))
* Double.valueOf(String.valueOf(map3.get("value"))));// 累计发电量
}
Map<String, String> map4 = sunlightDto.getToday_income(); Map<String, String> map4 = sunlightDto.getToday_income();
jpStation.setDayIncome( if (map4 != null && map4.get("unit") != null && !map4.get("unit").isEmpty()
map4 != null && map4.get("unit") != null ? SunlightUtil.sy.get(String.valueOf(map4.get("unit"))) && !"--".equals(map4.get("value"))) {
* Double.valueOf(String.valueOf(map4.get("value"))) : null);// 日收益 jpStation.setDayIncome(SunlightUtil.sy.get(String.valueOf(map4.get("unit")))
* Double.valueOf(String.valueOf(map4.get("value"))));// 日收益
}
Map<String, String> map5 = sunlightDto.getTotal_income(); Map<String, String> map5 = sunlightDto.getTotal_income();
jpStation.setCumulativeIncome( if (map5 != null && map5.get("unit") != null && !map5.get("unit").isEmpty()
map5 != null && map5.get("unit") != null ? SunlightUtil.sy.get(String.valueOf(map5.get("unit"))) && !"--".equals(map5.get("value"))) {
* Double.valueOf(String.valueOf(map5.get("value"))) : null);// 累计收益 jpStation.setCumulativeIncome(SunlightUtil.sy.get(String.valueOf(map5.get("unit")))
if (sunlightDto.getPs_fault_status() > 2) { * Double.valueOf(String.valueOf(map5.get("value"))));// 累计收益
jpStation.setState(SunlightUtil.zt.get(sunlightDto.getPs_status() + ""));// 电站状态 }
} catch (Exception e) {
e.printStackTrace();
logger.error("阳光数据错误:" + com.alibaba.fastjson.JSONObject.toJSONString(sunlightDto));
}
// 0离线 1在线
// 1故障 2告警 4正常
if ("0".equals(sunlightDto.getPs_status().toString())) {
jpStation.setState("离线");
} else if ("1".equals(sunlightDto.getPs_status().toString())) {
if ("1".equals(sunlightDto.getPs_fault_status().toString()) || "2".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("报警");
} else if ("4".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("在线");
} else { } else {
jpStation.setState("报警");// 电站状态 jpStation.setState("在线");
}
} else {
jpStation.setState("在线");
} }
// 获取电站下通讯模块 // 获取电站下通讯模块
...@@ -307,11 +340,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -307,11 +340,6 @@ public class SunlightServiceImpl implements SunlightService {
jpStation.setYearGenerate(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null); jpStation.setYearGenerate(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null);
// 年收益 // 年收益
jpStation.setYearIncome(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null); jpStation.setYearIncome(js != null ? Double.valueOf(js.get(0).get("4") + "") / 1000 : null);
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
String today = DateUtil.today(); String today = DateUtil.today();
String hour = new Date().getHours() + ":00"; String hour = new Date().getHours() + ":00";
...@@ -373,10 +401,17 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -373,10 +401,17 @@ public class SunlightServiceImpl implements SunlightService {
// tdJpStation.setCreatedTime(System.currentTimeMillis()); // tdJpStation.setCreatedTime(System.currentTimeMillis());
// tdJpStationMapper.insert(tdJpStation); // tdJpStationMapper.insert(tdJpStation);
// } // }
}
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
this.setJpInverte(listd, jpStation, listdtx); this.setJpInverte(listd, jpStation, listdtx);
this.collectorDetail(listd, jpStation); this.collectorDetail(listd, jpStation);
}
// 电站报表 // 电站报表
// 户用场站日发电量 // 户用场站日发电量
...@@ -490,7 +525,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -490,7 +525,6 @@ public class SunlightServiceImpl implements SunlightService {
@Override @Override
public void run() { public void run() {
try { try {
for (Device device : devices) { for (Device device : devices) {
if (device != null) { if (device != null) {
// 获取逆变器信息存库 // 获取逆变器信息存库
...@@ -505,12 +539,24 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -505,12 +539,24 @@ public class SunlightServiceImpl implements SunlightService {
jpInverter.setSnCode(device.getDevice_sn()); jpInverter.setSnCode(device.getDevice_sn());
jpInverter.setId(device.getUuid().toString()); jpInverter.setId(device.getUuid().toString());
if (device.getGetPs_fault_status() > 2) { // 0离线 1在线
jpInverter.setState(SunlightUtil.zt.get(device.getDev_status() + "")); // 1故障 2告警 4正常
if ("0".equals(device.getDev_status())) {
jpInverter.setState("离线");
} else if ("1".equals(device.getDev_status())) {
if ("1".equals(device.getDev_fault_status())
|| "2".equals(device.getDev_fault_status())) {
jpInverter.setState("报警");
} else if ("4".equals(device.getDev_fault_status())) {
jpInverter.setState("在线");
} else { } else {
jpInverter.setState("报警");// 电站状态 jpInverter.setState("在线");
} }
} else {
jpInverter.setState("在线");
}
// logger.error("阳光数据解析(逆变器),无法获取状态:" +
// com.alibaba.fastjson.JSONObject.toJSONString(device));
jpInverter.setUpdateTime(new Date()); jpInverter.setUpdateTime(new Date());
jpInverter.setDayPowerGeneration(jpStation.getDayGenerate()); jpInverter.setDayPowerGeneration(jpStation.getDayGenerate());
jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate()); jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate());
...@@ -916,7 +962,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -916,7 +962,7 @@ public class SunlightServiceImpl implements SunlightService {
jpCollector.setState("报警");// 电站状态 jpCollector.setState("报警");// 电站状态
} }
} else { } else {
//如果获取不了逆变器状态 并且逆变器没状态就默认离线 // 如果获取不了逆变器状态 并且逆变器没状态就默认离线
if (jpCollector.getState() == null) { if (jpCollector.getState() == null) {
jpCollector.setState("离线"); jpCollector.setState("离线");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment