广深高速焊接bug修复
This commit is contained in:
parent
c43d8b3406
commit
1e4ef9ab25
@ -1,8 +1,6 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
@ -15,10 +13,8 @@ import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SysConfig;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ISysConfigService;
|
||||
import com.zhgd.xmgl.modules.gs.entity.GsWeldingDev;
|
||||
import com.zhgd.xmgl.modules.gs.entity.GsWeldingDevDailyRecord;
|
||||
import com.zhgd.xmgl.modules.gs.entity.GsWeldingRecord;
|
||||
import com.zhgd.xmgl.modules.gs.entity.GsWeldingWaveform;
|
||||
import com.zhgd.xmgl.modules.gs.service.IGsWeldingDevDailyRecordService;
|
||||
import com.zhgd.xmgl.modules.gs.service.IGsWeldingDevService;
|
||||
import com.zhgd.xmgl.modules.gs.service.IGsWeldingRecordService;
|
||||
import com.zhgd.xmgl.modules.gs.service.IGsWeldingWaveformService;
|
||||
@ -28,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -187,14 +182,15 @@ public class GsWeldingTask {
|
||||
List<GsWeldingWaveform> gsWeldingWaveformList = Lists.newArrayList();
|
||||
for (int i = 0; i < dates.size() - 1; i++) {
|
||||
JSONObject jsonObject = SxHttpUtil.getGsWaveforms(dates.get(i), dates.get(i + 1), dev.getDevSn(), token);
|
||||
if (!Objects.equals(jsonObject.getInteger("Execution"), 0)) {
|
||||
throw new OpenAlertException("请求获取设备实时数据历史异常");
|
||||
}
|
||||
checkErr(jsonObject, "请求获取设备实时数据历史异常");
|
||||
JSONArray dataList = jsonObject.getJSONArray("dataList");
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
return gsWeldingWaveformList;
|
||||
}
|
||||
JSONArray list = dataList.getJSONObject(0).getJSONArray("list");
|
||||
if (CollUtil.isEmpty(list) || CollUtil.isEmpty(list.getJSONObject(0))) {
|
||||
return gsWeldingWaveformList;
|
||||
}
|
||||
for (int j = 0; j < list.size(); j++) {
|
||||
JSONObject jo1 = list.getJSONObject(j);
|
||||
GsWeldingWaveform waveform = new GsWeldingWaveform();
|
||||
@ -214,14 +210,15 @@ public class GsWeldingTask {
|
||||
|
||||
private List<GsWeldingRecord> buildGsWeldingRecord(JSONObject jsonObject, GsWeldingDev dev) {
|
||||
List<GsWeldingRecord> gsWeldingRecordList = Lists.newArrayList();
|
||||
if (!Objects.equals(jsonObject.getInteger("Execution"), 0)) {
|
||||
throw new OpenAlertException("请求查询设备焊接记录历史异常");
|
||||
}
|
||||
checkErr(jsonObject, "请求查询设备焊接记录历史异常");
|
||||
JSONArray dataList = jsonObject.getJSONArray("dataList");
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
return gsWeldingRecordList;
|
||||
}
|
||||
JSONArray list = dataList.getJSONObject(0).getJSONArray("list");
|
||||
if (CollUtil.isEmpty(list) || CollUtil.isEmpty(list.getJSONObject(0))) {
|
||||
return gsWeldingRecordList;
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
JSONObject jo1 = list.getJSONObject(i);
|
||||
GsWeldingRecord record = new GsWeldingRecord();
|
||||
@ -241,6 +238,13 @@ public class GsWeldingTask {
|
||||
return gsWeldingRecordList;
|
||||
}
|
||||
|
||||
private void checkErr(JSONObject jsonObject, String errMsg) {
|
||||
Integer execution = jsonObject.getInteger("Execution");
|
||||
if (!Objects.equals(execution, 0) && !Objects.equals(execution, 3) && !Objects.equals(execution, 4)) {
|
||||
throw new OpenAlertException(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveToDb(String queryTimeKey, String end, List<GsWeldingRecord> addGsWeldingRecords, List<GsWeldingWaveform> addGsWeldingWaveforms) {
|
||||
if (CollUtil.isNotEmpty(addGsWeldingRecords)) {
|
||||
@ -347,11 +351,9 @@ public class GsWeldingTask {
|
||||
List<GsWeldingDev> devs = gsWeldingDevService.list(null);
|
||||
for (GsWeldingDev dev : devs) {
|
||||
JSONObject jsonObject = SxHttpUtil.getWeldingDevRealTimes(dev.getDevSn(), token);
|
||||
if (!Objects.equals(jsonObject.getInteger("Execution"), 0)) {
|
||||
throw new OpenAlertException("定时请求设备实时数据接口异常");
|
||||
}
|
||||
checkErr(jsonObject, "定时请求设备实时数据接口异常");
|
||||
JSONArray dataList = jsonObject.getJSONArray("dataList");
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
if (CollUtil.isEmpty(dataList) || CollUtil.isEmpty(dataList.getJSONObject(0))) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
@ -387,10 +389,14 @@ public class GsWeldingTask {
|
||||
private Integer getEquipmentStatus(String d03) {
|
||||
switch (d03) {
|
||||
//1待机、2焊接、3报警、4关机
|
||||
case "待机": return 1;
|
||||
case "焊接": return 2;
|
||||
case "报警": return 3;
|
||||
case "关机": return 4;
|
||||
case "待机":
|
||||
return 1;
|
||||
case "焊接":
|
||||
return 2;
|
||||
case "报警":
|
||||
return 3;
|
||||
case "关机":
|
||||
return 4;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user