Commit eb833983 authored by wujiang's avatar wujiang

修改采集问题

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