Commit 554a1b0c authored by wujiang's avatar wujiang

修改采集报错问题

parent 1268801e
...@@ -212,7 +212,7 @@ public class ImasterUtils { ...@@ -212,7 +212,7 @@ public class ImasterUtils {
JSONObject jsonObject = JSONObject.parseObject(response); JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
JSONArray jsonArrayRet = new JSONArray(); JSONArray jsonArrayRet = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) { if (ObjectUtil.isNotEmpty(resultResovle)&&ObjectUtil.isNotEmpty(jsonObject)) {
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++) {
...@@ -222,9 +222,6 @@ public class ImasterUtils { ...@@ -222,9 +222,6 @@ public class ImasterUtils {
} }
try { try {
jsonObject = (JSONObject) jsonObject.get(rules[i]); jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) { } catch (Exception exception) {
try { try {
jsonArray = (JSONArray) jsonObject.get(rules[i]); jsonArray = (JSONArray) jsonObject.get(rules[i]);
......
...@@ -46,6 +46,8 @@ import java.util.concurrent.TimeUnit; ...@@ -46,6 +46,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @author DELL * @author DELL
*/ */
...@@ -549,12 +551,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -549,12 +551,13 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
} }
} }
} }
logger.info("-------科士达同步采集器开始" + ts + "------- " + sdf.format(new Date())); logger.info("-------科士达同步采集器结束" + ts + "------- " + sdf.format(new Date()));
} }
@Scheduled(cron = "${dataRequstScheduled.keshida}") @Scheduled(cron = "${dataRequstScheduled.keshida}")
@Override @Override
@Async @Async
@PostConstruct
public void collectorDetail() { public void collectorDetail() {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
logger.info("-------科士达同步采集器详情/逆变器开始" + ts + "------- " + sdf.format(new Date())); logger.info("-------科士达同步采集器详情/逆变器开始" + ts + "------- " + sdf.format(new Date()));
...@@ -623,10 +626,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -623,10 +626,9 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) { if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter); jpInverterMapper.updateById(jpInverter);
} else { } else {
if (StringUtils.isNotEmpty(jpInverter.getSnCode())) { if (StringUtils.isNotEmpty(jpInverter.getSnCode().trim())) {
jpInverterMapper.insert(jpInverter); jpInverterMapper.insert(jpInverter);
} }
} }
for (int k1 = 1; k1 < 13; k1++) { for (int k1 = 1; k1 < 13; k1++) {
...@@ -735,9 +737,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -735,9 +737,15 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
// 逆变器历史 // 逆变器历史
String today = DateUtil.today(); String today = DateUtil.today();
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper HYGFJPInverterHistory hygfjpInverterHistory =null;
try {
hygfjpInverterHistory = hygfjpInverterHistoryMapper
.selectOne(new QueryWrapper<HYGFJPInverterHistory>() .selectOne(new QueryWrapper<HYGFJPInverterHistory>()
.eq("sn_code", jpInverter.getSnCode().trim()).eq("date", today)); .eq("sn_code", jpInverter.getSnCode().trim()).eq("date", today));
} catch (Exception e) {
e.printStackTrace();
logger.error("科士达逆变器日历史数据错误:"+jpInverter.getSnCode().trim()+","+today);
}
if (ObjectUtils.isEmpty(hygfjpInverterHistory)) { if (ObjectUtils.isEmpty(hygfjpInverterHistory)) {
hygfjpInverterHistory = new HYGFJPInverterHistory(); hygfjpInverterHistory = new HYGFJPInverterHistory();
} }
...@@ -764,8 +772,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -764,8 +772,8 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
.eq("third_station_id", .eq("third_station_id",
ksolarStationCollectList.getThirdStationId()) ksolarStationCollectList.getThirdStationId())
.eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()) .eq("third_code", PVProducerInfoEnum.KSOLAR.getCode())
.like("sn_code", ksolarStationCollectData.getInverterId().trim()) .eq("sn_code", ksolarStationCollectData.getInverterId().trim())
.isNotNull("sn_code").orderByDesc("update_time")); .orderByDesc("update_time"));
JpInverter jpInverter = new JpInverter(); JpInverter jpInverter = new JpInverter();
if (jpInverterList.size() > 0) { if (jpInverterList.size() > 0) {
jpInverter = jpInverterList.get(0); jpInverter = jpInverterList.get(0);
...@@ -812,7 +820,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe ...@@ -812,7 +820,7 @@ public class KsolarDataAcquisitionServiceImpl implements KSolarDataAcquisitionSe
if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) { if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter); jpInverterMapper.updateById(jpInverter);
} else { } else {
if (StringUtils.isNotEmpty(jpInverter.getSnCode())) { if (StringUtils.isNotEmpty(jpInverter.getSnCode().trim())) {
jpInverterMapper.insert(jpInverter); jpInverterMapper.insert(jpInverter);
} }
} }
......
...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.qiniu.util.Json; import com.qiniu.util.Json;
...@@ -45,6 +46,8 @@ import java.util.concurrent.TimeUnit; ...@@ -45,6 +46,8 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -248,7 +251,8 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -248,7 +251,8 @@ public class SunlightServiceImpl implements SunlightService {
if ("0".equals(sunlightDto.getPs_status().toString())) { if ("0".equals(sunlightDto.getPs_status().toString())) {
jpStation.setState("离线"); jpStation.setState("离线");
} else if ("1".equals(sunlightDto.getPs_status().toString())) { } else if ("1".equals(sunlightDto.getPs_status().toString())) {
if ("1".equals(sunlightDto.getPs_fault_status().toString()) || "2".equals(sunlightDto.getPs_fault_status().toString())) { if ("1".equals(sunlightDto.getPs_fault_status().toString())
|| "2".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("报警"); jpStation.setState("报警");
} else if ("4".equals(sunlightDto.getPs_fault_status().toString())) { } else if ("4".equals(sunlightDto.getPs_fault_status().toString())) {
jpStation.setState("在线"); jpStation.setState("在线");
...@@ -402,8 +406,12 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -402,8 +406,12 @@ public class SunlightServiceImpl implements SunlightService {
// tdJpStationMapper.insert(tdJpStation); // tdJpStationMapper.insert(tdJpStation);
// } // }
} }
JpStation jpStationOld = jpStationMapper.selectOne(
new LambdaQueryWrapper<JpStation>().eq(JpStation::getThirdStationId, jpStation.getThirdStationId())
.eq(JpStation::getThirdCode, PVProducerInfoEnum.YG.getCode()));
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) { if (jpStationOld != null) {
jpStation.setSequenceNbr(jpStationOld.getSequenceNbr());
jpStationMapper.updateById(jpStation); jpStationMapper.updateById(jpStation);
} else { } else {
jpStationMapper.insert(jpStation); jpStationMapper.insert(jpStation);
......
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