去掉不必要的定时任务
This commit is contained in:
parent
94026e1e85
commit
1c7ccf4a33
@ -93,25 +93,25 @@ public class ElectricalTask {
|
||||
/**
|
||||
* 获取电箱情况 每5分钟触发任务
|
||||
*/
|
||||
@Scheduled(cron = "0 30 * * * ?")
|
||||
@RequestMapping("/xmgl/task/getElectricData")
|
||||
public void getElectricData() {
|
||||
log.info("获取设备数据 每1分钟触发任务");
|
||||
JSONObject obj = getToken();
|
||||
if (obj == null) {
|
||||
log.error("获取token失败!");
|
||||
}
|
||||
String token = obj.getString("token");
|
||||
String hashId = obj.getJSONObject("account").getJSONObject("currentProject").getString("hashId");
|
||||
List<String> devList = doGetElectricalData(token, hashId);
|
||||
devList.forEach(dev -> CompletableFuture.supplyAsync(() -> {
|
||||
return doAddElectricalData(dev, token);
|
||||
}).exceptionally(throwable -> {
|
||||
log.error("err:", throwable);
|
||||
return null;
|
||||
})
|
||||
);
|
||||
}
|
||||
// @Scheduled(cron = "0 30 * * * ?")
|
||||
// @RequestMapping("/xmgl/task/getElectricData")
|
||||
// public void getElectricData() {
|
||||
// log.info("获取设备数据 每1分钟触发任务");
|
||||
// JSONObject obj = getToken();
|
||||
// if (obj == null) {
|
||||
// log.error("获取token失败!");
|
||||
// }
|
||||
// String token = obj.getString("token");
|
||||
// String hashId = obj.getJSONObject("account").getJSONObject("currentProject").getString("hashId");
|
||||
// List<String> devList = doGetElectricalData(token, hashId);
|
||||
// devList.forEach(dev -> CompletableFuture.supplyAsync(() -> {
|
||||
// return doAddElectricalData(dev, token);
|
||||
// }).exceptionally(throwable -> {
|
||||
// log.error("err:", throwable);
|
||||
// return null;
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
private List<String> doGetElectricalData(String token, String hashId) {
|
||||
HttpRequest post = HttpRequest.get(sadaHost + "/box/project/" + hashId);
|
||||
|
||||
@ -1,263 +1,263 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhgd.redis.lock.RedisRepository;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.sewage.entity.SewageAlarm;
|
||||
import com.zhgd.xmgl.modules.sewage.entity.SewageData;
|
||||
import com.zhgd.xmgl.modules.sewage.entity.SewageDev;
|
||||
import com.zhgd.xmgl.modules.sewage.service.ISewageAlarmService;
|
||||
import com.zhgd.xmgl.modules.sewage.service.ISewageDataService;
|
||||
import com.zhgd.xmgl.modules.sewage.service.ISewageDevService;
|
||||
import com.zhgd.xmgl.util.RenZhiUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("xmgl/task")
|
||||
public class SewageTask {
|
||||
public static final String REDIS_RAIN_ALARM_TASK_START_TIME = "getSewageAlarmTaskStartTime";
|
||||
public static final String DATA_VALUE = "dataValue";
|
||||
public static final String RECORD_TIME = "recordTime";
|
||||
@Resource
|
||||
@Lazy
|
||||
private ISewageDataService sewageDataService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private ISewageAlarmService sewageAlarmService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private ISewageDevService sewageDevService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectMapper projectMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private RedisRepository redisRepository;
|
||||
|
||||
/**
|
||||
* 获取实时数据
|
||||
*/
|
||||
@Scheduled(cron = "0 */2 * * * ?")
|
||||
@SchedulerLock(name = "getSewageRecordTask", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60)
|
||||
@RequestMapping("getSewageRecordTask")
|
||||
public void getSewageRecordTask() {
|
||||
List<Project> projectList = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
.ne(Project::getJnrzckAccount, "")
|
||||
.ne(Project::getJnrzckPw, "")
|
||||
);
|
||||
for (Project project : projectList) {
|
||||
try {
|
||||
saveAllRecord(project);
|
||||
} catch (Exception e) {
|
||||
log.error("获取污水实时数据错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveAllRecord(Project project) {
|
||||
List<SewageDev> devs = sewageDevService.list(new LambdaQueryWrapper<SewageDev>().eq(SewageDev::getProjectSn, project.getProjectSn()));
|
||||
if (CollUtil.isEmpty(devs)) {
|
||||
return;
|
||||
}
|
||||
Map<String, SewageDev> devSnMap = devs.stream().collect(Collectors.toMap(SewageDev::getDevSn, Function.identity()));
|
||||
JSONArray datas = RenZhiUtil.getRealTimeDataByDeviceAddr(StrUtil.join(",", devs.stream().map(SewageDev::getDevSn).collect(Collectors.toList())), project.getJnrzckAccount(), project.getJnrzckPw());
|
||||
if (CollUtil.isEmpty(datas)) {
|
||||
log.info("污水获取实时数据为空,项目名称:{}", project.getProjectName());
|
||||
return;
|
||||
}
|
||||
List<SewageData> records = new ArrayList<>();
|
||||
for (int i = 0; i < datas.size(); i++) {
|
||||
JSONObject dataJo = datas.getJSONObject(i);
|
||||
JSONArray dataItemJa = dataJo.getJSONArray("dataItem");
|
||||
String deviceAddr = dataJo.getString("deviceAddr");
|
||||
//normal:正常
|
||||
//alarming:报警
|
||||
//preAlarming:预警
|
||||
//offline:离线
|
||||
String deviceStatus = dataJo.getString("deviceStatus");
|
||||
SewageData record = new SewageData();
|
||||
SewageDev dev = devSnMap.get(deviceAddr);
|
||||
if (CollUtil.isNotEmpty(dataItemJa)) {
|
||||
for (int j = 0; j < dataItemJa.size(); j++) {
|
||||
JSONObject itemJo = dataItemJa.getJSONObject(j);
|
||||
Integer nodeId = itemJo.getInteger("nodeId");
|
||||
JSONArray registerItemJa = itemJo.getJSONArray("registerItem");
|
||||
if (nodeId == 7) {
|
||||
//工业 PH、工业 EC
|
||||
record.setPhValue(getDouble(registerItemJa, 0));
|
||||
record.setConductivity(getDouble(registerItemJa, 1));
|
||||
} else if (nodeId == 8) {
|
||||
//水质浊度、水质溶解氧
|
||||
record.setTurbidityValue(getDouble(registerItemJa, 0));
|
||||
record.setDissolvedOxygen(getDouble(registerItemJa, 1));
|
||||
} else if (nodeId == 29) {
|
||||
//实时流量、雷达流量计液位高
|
||||
record.setWaterLevel(Optional.ofNullable(getDouble(registerItemJa, 1)).map(m -> NumberUtil.div(m.doubleValue(), 1000D, 5)).orElse(null));
|
||||
} else if (nodeId == 31) {
|
||||
//累计水量、流速
|
||||
record.setFlowVelocity(Optional.ofNullable(getDouble(registerItemJa, 0)).map(m -> NumberUtil.div(m.doubleValue(), 100D, 5)).orElse(null));
|
||||
}
|
||||
// record.setWaterTemperature(getDouble(registerItemJa, 0));
|
||||
}
|
||||
record.setCreateDate(new Date(dataJo.getLong("timeStamp")));
|
||||
record.setDevSn(deviceAddr);
|
||||
record.setProjectSn(dev.getProjectSn());
|
||||
records.add(record);
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(records)) {
|
||||
for (SewageData record : records) {
|
||||
sewageDataService.add(record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getString(JSONArray registerItemJa, int index) {
|
||||
return Optional.ofNullable(registerItemJa.getJSONObject(index)).map(o -> o.getString("data")).orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Double getDouble(JSONArray registerItemJa, int index) {
|
||||
return Optional.ofNullable(registerItemJa.getJSONObject(index)).map(o -> o.getDouble("data")).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报警数据
|
||||
*/
|
||||
@Scheduled(cron = "0 */6 * * * ?")
|
||||
@SchedulerLock(name = "getSewageAlarmTask", lockAtMostFor = 1000 * 60 * 5, lockAtLeastFor = 1000 * 60 * 3)
|
||||
@RequestMapping("getSewageAlarmTask")
|
||||
public void getRainAlarmTask() {
|
||||
List<Project> projectList = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
.ne(Project::getJnrzckAccount, "")
|
||||
.ne(Project::getJnrzckPw, "")
|
||||
);
|
||||
String start;
|
||||
Object o = redisRepository.get(REDIS_RAIN_ALARM_TASK_START_TIME);
|
||||
if (o != null) {
|
||||
start = o.toString();
|
||||
} else {
|
||||
start = DateUtil.format(DateUtil.offsetMinute(new Date(), -5), "yyyy-MM-dd HH:mm");
|
||||
}
|
||||
String end = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm");
|
||||
redisRepository.set(REDIS_RAIN_ALARM_TASK_START_TIME, end);
|
||||
for (Project project : projectList) {
|
||||
try {
|
||||
saveAllAlarm(project, start, end);
|
||||
} catch (Exception e) {
|
||||
log.error("获取污水报警数据错误", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void saveAllAlarm(Project project, String start, String end) throws InterruptedException {
|
||||
List<SewageDev> devs = sewageDevService.list(new LambdaQueryWrapper<SewageDev>().eq(SewageDev::getProjectSn, project.getProjectSn()));
|
||||
if (CollUtil.isEmpty(devs)) {
|
||||
return;
|
||||
}
|
||||
ArrayList<SewageAlarm> alarms = new ArrayList<>();
|
||||
String token = RenZhiUtil.getToken(project.getJnrzckAccount(), project.getJnrzckPw());
|
||||
for (SewageDev dev : devs) {
|
||||
JSONArray dataJa = RenZhiUtil.getAlarmRecordList(dev.getDevSn(), token, -1, start, end);
|
||||
Thread.sleep(200);
|
||||
if (CollUtil.isEmpty(dataJa)) {
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < dataJa.size(); j++) {
|
||||
JSONObject jo = dataJa.getJSONObject(j);
|
||||
String recordId = jo.getString("recordId");
|
||||
SewageAlarm alarm = new SewageAlarm();
|
||||
alarm.setDevSn(jo.getString("deviceAddr"));
|
||||
alarm.setMonitorParam(jo.getString("factorName"));
|
||||
alarm.setMonitorValue(jo.getDouble("dataValue"));
|
||||
alarm.setAlarmDetail(getAlarmContent(jo));
|
||||
alarm.setAlarmTime(new Date(jo.getLong("recordTime")));
|
||||
alarm.setProjectSn(project.getProjectSn());
|
||||
alarm.setAlarmType(getAlarmType(jo));
|
||||
// alarm.setSewageDataId(0L);
|
||||
// alarm.setSewageType(0);
|
||||
alarms.add(alarm);
|
||||
}
|
||||
}
|
||||
sewageAlarmService.saveBatch(alarms);
|
||||
}
|
||||
|
||||
private Integer getAlarmType(JSONObject jo) {
|
||||
if (!Objects.equals(jo.get("alarmLevel"), 2) && !Objects.equals(jo.get("alarmLevel"), 3)) {
|
||||
return 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private String getAlarmContent(JSONObject jo) {
|
||||
/*
|
||||
alarmLevel int 报警级别:
|
||||
25
|
||||
1: 报警(超报警上限)
|
||||
2: 预警(超预警上限)
|
||||
3: 预警(超预警下限)
|
||||
4:报警(超报警下限)
|
||||
-1: 离线报警
|
||||
-2:遥调(开关量)报警
|
||||
dataValue Double 报警值
|
||||
alarmRange String 报警限值
|
||||
*/
|
||||
String factorName = jo.getString("factorName");
|
||||
Integer alarmLevel = jo.getInteger("alarmLevel");
|
||||
if (Objects.equals(alarmLevel, 1) || Objects.equals(alarmLevel, 2) || Objects.equals(alarmLevel, 3) || Objects.equals(alarmLevel, 4)) {
|
||||
return StrUtil.format("{} {},报警值:{},报警限值:{}", factorName, getAlarmLevelStr(alarmLevel), jo.getDouble(DATA_VALUE), jo.getString("alarmRange"));
|
||||
} else {
|
||||
return StrUtil.format("{} {},报警值:{}", factorName, getAlarmLevelStr(alarmLevel), jo.getString(DATA_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
private String getAlarmLevelStr(Integer alarmLevel) {
|
||||
String s = "";
|
||||
switch (alarmLevel) {
|
||||
case 1:
|
||||
s = "报警(超报警上限)";
|
||||
break;
|
||||
case 2:
|
||||
s = "预警(超预警上限)";
|
||||
break;
|
||||
case 3:
|
||||
s = "预警(超预警下限)";
|
||||
break;
|
||||
case 4:
|
||||
s = "报警(超报警下限)";
|
||||
break;
|
||||
case -1:
|
||||
s = "离线报警";
|
||||
break;
|
||||
case -2:
|
||||
s = "遥调(开关量)报警";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package com.zhgd.xmgl.task;
|
||||
//
|
||||
//import cn.hutool.core.collection.CollUtil;
|
||||
//import cn.hutool.core.date.DateUtil;
|
||||
//import cn.hutool.core.util.NumberUtil;
|
||||
//import cn.hutool.core.util.StrUtil;
|
||||
//import com.alibaba.fastjson.JSONArray;
|
||||
//import com.alibaba.fastjson.JSONObject;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.zhgd.redis.lock.RedisRepository;
|
||||
//import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
//import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
//import com.zhgd.xmgl.modules.sewage.entity.SewageAlarm;
|
||||
//import com.zhgd.xmgl.modules.sewage.entity.SewageData;
|
||||
//import com.zhgd.xmgl.modules.sewage.entity.SewageDev;
|
||||
//import com.zhgd.xmgl.modules.sewage.service.ISewageAlarmService;
|
||||
//import com.zhgd.xmgl.modules.sewage.service.ISewageDataService;
|
||||
//import com.zhgd.xmgl.modules.sewage.service.ISewageDevService;
|
||||
//import com.zhgd.xmgl.util.RenZhiUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.context.annotation.Lazy;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import javax.annotation.Resource;
|
||||
//import java.util.*;
|
||||
//import java.util.function.Function;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//@Slf4j
|
||||
//@RestController
|
||||
//@RequestMapping("xmgl/task")
|
||||
//public class SewageTask {
|
||||
// public static final String REDIS_RAIN_ALARM_TASK_START_TIME = "getSewageAlarmTaskStartTime";
|
||||
// public static final String DATA_VALUE = "dataValue";
|
||||
// public static final String RECORD_TIME = "recordTime";
|
||||
// @Resource
|
||||
// @Lazy
|
||||
// private ISewageDataService sewageDataService;
|
||||
// @Resource
|
||||
// @Lazy
|
||||
// private ISewageAlarmService sewageAlarmService;
|
||||
// @Resource
|
||||
// @Lazy
|
||||
// private ISewageDevService sewageDevService;
|
||||
// @Lazy
|
||||
// @Autowired
|
||||
// private ProjectMapper projectMapper;
|
||||
// @Lazy
|
||||
// @Autowired
|
||||
// private RedisRepository redisRepository;
|
||||
//
|
||||
// /**
|
||||
// * 获取实时数据
|
||||
// */
|
||||
// @Scheduled(cron = "0 */2 * * * ?")
|
||||
// @SchedulerLock(name = "getSewageRecordTask", lockAtMostFor = 1000 * 60, lockAtLeastFor = 1000 * 60)
|
||||
// @RequestMapping("getSewageRecordTask")
|
||||
// public void getSewageRecordTask() {
|
||||
// List<Project> projectList = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
// .ne(Project::getJnrzckAccount, "")
|
||||
// .ne(Project::getJnrzckPw, "")
|
||||
// );
|
||||
// for (Project project : projectList) {
|
||||
// try {
|
||||
// saveAllRecord(project);
|
||||
// } catch (Exception e) {
|
||||
// log.error("获取污水实时数据错误", e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void saveAllRecord(Project project) {
|
||||
// List<SewageDev> devs = sewageDevService.list(new LambdaQueryWrapper<SewageDev>().eq(SewageDev::getProjectSn, project.getProjectSn()));
|
||||
// if (CollUtil.isEmpty(devs)) {
|
||||
// return;
|
||||
// }
|
||||
// Map<String, SewageDev> devSnMap = devs.stream().collect(Collectors.toMap(SewageDev::getDevSn, Function.identity()));
|
||||
// JSONArray datas = RenZhiUtil.getRealTimeDataByDeviceAddr(StrUtil.join(",", devs.stream().map(SewageDev::getDevSn).collect(Collectors.toList())), project.getJnrzckAccount(), project.getJnrzckPw());
|
||||
// if (CollUtil.isEmpty(datas)) {
|
||||
// log.info("污水获取实时数据为空,项目名称:{}", project.getProjectName());
|
||||
// return;
|
||||
// }
|
||||
// List<SewageData> records = new ArrayList<>();
|
||||
// for (int i = 0; i < datas.size(); i++) {
|
||||
// JSONObject dataJo = datas.getJSONObject(i);
|
||||
// JSONArray dataItemJa = dataJo.getJSONArray("dataItem");
|
||||
// String deviceAddr = dataJo.getString("deviceAddr");
|
||||
// //normal:正常
|
||||
// //alarming:报警
|
||||
// //preAlarming:预警
|
||||
// //offline:离线
|
||||
// String deviceStatus = dataJo.getString("deviceStatus");
|
||||
// SewageData record = new SewageData();
|
||||
// SewageDev dev = devSnMap.get(deviceAddr);
|
||||
// if (CollUtil.isNotEmpty(dataItemJa)) {
|
||||
// for (int j = 0; j < dataItemJa.size(); j++) {
|
||||
// JSONObject itemJo = dataItemJa.getJSONObject(j);
|
||||
// Integer nodeId = itemJo.getInteger("nodeId");
|
||||
// JSONArray registerItemJa = itemJo.getJSONArray("registerItem");
|
||||
// if (nodeId == 7) {
|
||||
// //工业 PH、工业 EC
|
||||
// record.setPhValue(getDouble(registerItemJa, 0));
|
||||
// record.setConductivity(getDouble(registerItemJa, 1));
|
||||
// } else if (nodeId == 8) {
|
||||
// //水质浊度、水质溶解氧
|
||||
// record.setTurbidityValue(getDouble(registerItemJa, 0));
|
||||
// record.setDissolvedOxygen(getDouble(registerItemJa, 1));
|
||||
// } else if (nodeId == 29) {
|
||||
// //实时流量、雷达流量计液位高
|
||||
// record.setWaterLevel(Optional.ofNullable(getDouble(registerItemJa, 1)).map(m -> NumberUtil.div(m.doubleValue(), 1000D, 5)).orElse(null));
|
||||
// } else if (nodeId == 31) {
|
||||
// //累计水量、流速
|
||||
// record.setFlowVelocity(Optional.ofNullable(getDouble(registerItemJa, 0)).map(m -> NumberUtil.div(m.doubleValue(), 100D, 5)).orElse(null));
|
||||
// }
|
||||
//// record.setWaterTemperature(getDouble(registerItemJa, 0));
|
||||
// }
|
||||
// record.setCreateDate(new Date(dataJo.getLong("timeStamp")));
|
||||
// record.setDevSn(deviceAddr);
|
||||
// record.setProjectSn(dev.getProjectSn());
|
||||
// records.add(record);
|
||||
// }
|
||||
// }
|
||||
// if (CollUtil.isNotEmpty(records)) {
|
||||
// for (SewageData record : records) {
|
||||
// sewageDataService.add(record);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String getString(JSONArray registerItemJa, int index) {
|
||||
// return Optional.ofNullable(registerItemJa.getJSONObject(index)).map(o -> o.getString("data")).orElse(null);
|
||||
// }
|
||||
//
|
||||
// @Nullable
|
||||
// private Double getDouble(JSONArray registerItemJa, int index) {
|
||||
// return Optional.ofNullable(registerItemJa.getJSONObject(index)).map(o -> o.getDouble("data")).orElse(null);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 获取报警数据
|
||||
// */
|
||||
// @Scheduled(cron = "0 */6 * * * ?")
|
||||
// @SchedulerLock(name = "getSewageAlarmTask", lockAtMostFor = 1000 * 60 * 5, lockAtLeastFor = 1000 * 60 * 3)
|
||||
// @RequestMapping("getSewageAlarmTask")
|
||||
// public void getRainAlarmTask() {
|
||||
// List<Project> projectList = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
// .ne(Project::getJnrzckAccount, "")
|
||||
// .ne(Project::getJnrzckPw, "")
|
||||
// );
|
||||
// String start;
|
||||
// Object o = redisRepository.get(REDIS_RAIN_ALARM_TASK_START_TIME);
|
||||
// if (o != null) {
|
||||
// start = o.toString();
|
||||
// } else {
|
||||
// start = DateUtil.format(DateUtil.offsetMinute(new Date(), -5), "yyyy-MM-dd HH:mm");
|
||||
// }
|
||||
// String end = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm");
|
||||
// redisRepository.set(REDIS_RAIN_ALARM_TASK_START_TIME, end);
|
||||
// for (Project project : projectList) {
|
||||
// try {
|
||||
// saveAllAlarm(project, start, end);
|
||||
// } catch (Exception e) {
|
||||
// log.error("获取污水报警数据错误", e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private void saveAllAlarm(Project project, String start, String end) throws InterruptedException {
|
||||
// List<SewageDev> devs = sewageDevService.list(new LambdaQueryWrapper<SewageDev>().eq(SewageDev::getProjectSn, project.getProjectSn()));
|
||||
// if (CollUtil.isEmpty(devs)) {
|
||||
// return;
|
||||
// }
|
||||
// ArrayList<SewageAlarm> alarms = new ArrayList<>();
|
||||
// String token = RenZhiUtil.getToken(project.getJnrzckAccount(), project.getJnrzckPw());
|
||||
// for (SewageDev dev : devs) {
|
||||
// JSONArray dataJa = RenZhiUtil.getAlarmRecordList(dev.getDevSn(), token, -1, start, end);
|
||||
// Thread.sleep(200);
|
||||
// if (CollUtil.isEmpty(dataJa)) {
|
||||
// continue;
|
||||
// }
|
||||
// for (int j = 0; j < dataJa.size(); j++) {
|
||||
// JSONObject jo = dataJa.getJSONObject(j);
|
||||
// String recordId = jo.getString("recordId");
|
||||
// SewageAlarm alarm = new SewageAlarm();
|
||||
// alarm.setDevSn(jo.getString("deviceAddr"));
|
||||
// alarm.setMonitorParam(jo.getString("factorName"));
|
||||
// alarm.setMonitorValue(jo.getDouble("dataValue"));
|
||||
// alarm.setAlarmDetail(getAlarmContent(jo));
|
||||
// alarm.setAlarmTime(new Date(jo.getLong("recordTime")));
|
||||
// alarm.setProjectSn(project.getProjectSn());
|
||||
// alarm.setAlarmType(getAlarmType(jo));
|
||||
//// alarm.setSewageDataId(0L);
|
||||
//// alarm.setSewageType(0);
|
||||
// alarms.add(alarm);
|
||||
// }
|
||||
// }
|
||||
// sewageAlarmService.saveBatch(alarms);
|
||||
// }
|
||||
//
|
||||
// private Integer getAlarmType(JSONObject jo) {
|
||||
// if (!Objects.equals(jo.get("alarmLevel"), 2) && !Objects.equals(jo.get("alarmLevel"), 3)) {
|
||||
// return 2;
|
||||
// } else {
|
||||
// return 1;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String getAlarmContent(JSONObject jo) {
|
||||
// /*
|
||||
// alarmLevel int 报警级别:
|
||||
// 25
|
||||
// 1: 报警(超报警上限)
|
||||
// 2: 预警(超预警上限)
|
||||
// 3: 预警(超预警下限)
|
||||
// 4:报警(超报警下限)
|
||||
// -1: 离线报警
|
||||
// -2:遥调(开关量)报警
|
||||
// dataValue Double 报警值
|
||||
// alarmRange String 报警限值
|
||||
// */
|
||||
// String factorName = jo.getString("factorName");
|
||||
// Integer alarmLevel = jo.getInteger("alarmLevel");
|
||||
// if (Objects.equals(alarmLevel, 1) || Objects.equals(alarmLevel, 2) || Objects.equals(alarmLevel, 3) || Objects.equals(alarmLevel, 4)) {
|
||||
// return StrUtil.format("{} {},报警值:{},报警限值:{}", factorName, getAlarmLevelStr(alarmLevel), jo.getDouble(DATA_VALUE), jo.getString("alarmRange"));
|
||||
// } else {
|
||||
// return StrUtil.format("{} {},报警值:{}", factorName, getAlarmLevelStr(alarmLevel), jo.getString(DATA_VALUE));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String getAlarmLevelStr(Integer alarmLevel) {
|
||||
// String s = "";
|
||||
// switch (alarmLevel) {
|
||||
// case 1:
|
||||
// s = "报警(超报警上限)";
|
||||
// break;
|
||||
// case 2:
|
||||
// s = "预警(超预警上限)";
|
||||
// break;
|
||||
// case 3:
|
||||
// s = "预警(超预警下限)";
|
||||
// break;
|
||||
// case 4:
|
||||
// s = "报警(超报警下限)";
|
||||
// break;
|
||||
// case -1:
|
||||
// s = "离线报警";
|
||||
// break;
|
||||
// case -2:
|
||||
// s = "遥调(开关量)报警";
|
||||
// break;
|
||||
// default:
|
||||
// }
|
||||
// return s;
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@ -1,178 +1,178 @@
|
||||
package com.zhgd.xmgl.task;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.gexin.fastjson.JSONArray;
|
||||
import com.gexin.fastjson.JSONObject;
|
||||
import com.glodon.cloudt.rest.client.RestServiceClient;
|
||||
import com.glodon.cloudt.rest.client.data.HmacRestAuthInfo;
|
||||
import com.glodon.cloudt.rest.client.data.RestResponseInfo;
|
||||
import com.glodon.cloudt.rest.client.exception.AuthenticateException;
|
||||
import com.glodon.cloudt.rest.client.exception.InvalidUriException;
|
||||
import com.glodon.cloudt.rest.client.exception.NoAuthenticateException;
|
||||
import com.glodon.cloudt.rest.client.impl.HmacRestServiceClient;
|
||||
import com.google.common.base.Objects;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationRawMaterialData;
|
||||
import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationSetData;
|
||||
import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDataMapper;
|
||||
import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
|
||||
import com.zhgd.xmgl.util.ThirdPartRequestUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 水稳拌合站任务
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RestController
|
||||
public class StableWaterMixStationTask {
|
||||
@Autowired
|
||||
ThirdPartRequestUtil thirdPartRequestUtil;
|
||||
@Autowired
|
||||
IStableWaterMixStationDataService stableWaterMixStationDataService;
|
||||
@Autowired
|
||||
StableWaterMixStationDataMapper stableWaterMixStationDataMapper;
|
||||
@Autowired
|
||||
ProjectMapper projectMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 每5分钟拉取广联达的搅拌站数据,https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html
|
||||
*/
|
||||
@Scheduled(cron = "0 0/5 * * * ?")
|
||||
@SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1)
|
||||
@RequestMapping("xmgl/task/executeStableWaterMixStationTask")
|
||||
public void executeStableWaterMixStationTask() {
|
||||
log.info("定时拉取广联达的搅拌站数据任务开始");
|
||||
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
.isNotNull(Project::getGldLicPath)
|
||||
.ne(Project::getGldLicPath, "")
|
||||
);
|
||||
for (Project project : projects) {
|
||||
StableWaterMixStationData data = stableWaterMixStationDataMapper.selectOne(new LambdaQueryWrapper<StableWaterMixStationData>()
|
||||
.eq(StableWaterMixStationData::getProjectSn, project.getProjectSn())
|
||||
.orderByDesc(StableWaterMixStationData::getTimestamp)
|
||||
.last("limit 1")
|
||||
);
|
||||
String timestamp;
|
||||
if (data != null) {
|
||||
timestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(data.getTimestamp());
|
||||
} else {
|
||||
timestamp = "20230101141314082";
|
||||
}
|
||||
sendHttp(project, timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendHttp(Project project, String timestamp) {
|
||||
try {
|
||||
log.info("定时拉取广联达的搅拌站数据任务开始:项目名称:{} 项目sn:{} timestamp:{}", project.getProjectName(), project.getProjectSn(), timestamp);
|
||||
/**----------------准备 -------------------*/
|
||||
//第1步:下载授权文件
|
||||
//第2步:获取SDK
|
||||
/** ------------ 授权认证 --------------*/
|
||||
|
||||
//第3步:创建客户端实例
|
||||
RestServiceClient serviceClient = HmacRestServiceClient.getInstance();
|
||||
//第4步:加载/验证授权文件
|
||||
//4.1构建认证信息
|
||||
HmacRestAuthInfo restAuthInfo = new HmacRestAuthInfo();
|
||||
//4.2设置授权文件路径
|
||||
restAuthInfo.setLicPath(project.getGldLicPath());
|
||||
//4.3权限认证
|
||||
serviceClient.authenticate(restAuthInfo);
|
||||
|
||||
/** ------------ 拼接请求地址 --------------*/
|
||||
//第5步:获取授权文件关联的GYS系统地址hostAddress
|
||||
String hostAddress = serviceClient.getRestRootAddress();
|
||||
//第6步:设置请求接口的URI地址apiURI(以获取集成项目列表信息为例)
|
||||
String apiUri = String.format("/api/mix/v1.0/mix/product/getMachineProductList?beginTimestamp=%s", timestamp);
|
||||
//第7步:拼装完整的请求网址
|
||||
String fullUrl = hostAddress + apiUri;
|
||||
//第8步:请求数据准备(本例中为从GYS系统获取数据,无需进行请求数据的准备)
|
||||
|
||||
log.info("url:{}", fullUrl);
|
||||
//第9步:发送请求,用来推送/获取数据
|
||||
RestResponseInfo restResponseInfo = serviceClient.get(fullUrl);
|
||||
log.info("rs:{}", JSON.toJSONString(restResponseInfo));
|
||||
|
||||
|
||||
/** ------------ 处理请求返回结果 --------------*/
|
||||
if (restResponseInfo.isSuccess()) {
|
||||
//请求成功:
|
||||
//第10步:处理请求结果(第三方系统自行处理)
|
||||
String stringContent = restResponseInfo.getStringContent();
|
||||
JSONObject scjo = JSON.parseObject(stringContent);
|
||||
if (scjo.getBoolean("success")) {
|
||||
saveData(scjo.getJSONObject("data"), project);
|
||||
JSONObject dataJo = scjo.getJSONObject("data");
|
||||
//继续发送http查询未保存的数据
|
||||
if (!Objects.equal(dataJo.getInteger("PageSize"), 0)) {
|
||||
sendHttp(project, dataJo.getString("MaxTimestamp"));
|
||||
}
|
||||
} else {
|
||||
log.error("失败:未知原因1");
|
||||
}
|
||||
} else {
|
||||
//请求失败:
|
||||
//第11步:根据返回结果排查失败原因(数据原因第三方系统自行处理)
|
||||
log.error("失败:未知原因2");
|
||||
}
|
||||
} catch (AuthenticateException e) {
|
||||
log.error("error:", e);
|
||||
} catch (InvalidUriException e) {
|
||||
log.error("error:", e);
|
||||
} catch (NoAuthenticateException e) {
|
||||
log.error("error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveData(JSONObject dataJo, Project project) {
|
||||
//保存拌合站设备,一个项目级别的授权文件对应我们的一个项目,他们的一个项目有多个拌合站(属性是projectId)(和我们设备对应),一个拌合站有多个机组(我们不体现)
|
||||
//保存拌合站数据
|
||||
JSONArray bills = dataJo.getJSONArray("Bills");
|
||||
for (Object bill : bills) {
|
||||
StableWaterMixStationData data = new StableWaterMixStationData();
|
||||
List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
|
||||
data.setSetDataList(setDataList);
|
||||
BeanUtil.copyProperties(bill, data, true);
|
||||
data.setDevSn(((JSONObject) bill).getString("projectId"));
|
||||
JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
|
||||
for (Object pc : pcList) {
|
||||
StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
|
||||
BeanUtil.copyProperties(pc, setData, true);
|
||||
setDataList.add(setData);
|
||||
List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
|
||||
setData.setRawMaterialDataList(rawMaterialDataList);
|
||||
JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
|
||||
for (Object yc : ycList) {
|
||||
StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
|
||||
BeanUtil.copyProperties(yc, rawMaterialData, true);
|
||||
rawMaterialDataList.add(rawMaterialData);
|
||||
}
|
||||
}
|
||||
try {
|
||||
stableWaterMixStationDataService.add(data);
|
||||
} catch (Exception e) {
|
||||
log.error("error:", e);
|
||||
log.info("新增出错:{},编号:{}", e.getMessage(), data.getDevSn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package com.zhgd.xmgl.task;
|
||||
//
|
||||
//import cn.hutool.core.bean.BeanUtil;
|
||||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
//import com.gexin.fastjson.JSON;
|
||||
//import com.gexin.fastjson.JSONArray;
|
||||
//import com.gexin.fastjson.JSONObject;
|
||||
//import com.glodon.cloudt.rest.client.RestServiceClient;
|
||||
//import com.glodon.cloudt.rest.client.data.HmacRestAuthInfo;
|
||||
//import com.glodon.cloudt.rest.client.data.RestResponseInfo;
|
||||
//import com.glodon.cloudt.rest.client.exception.AuthenticateException;
|
||||
//import com.glodon.cloudt.rest.client.exception.InvalidUriException;
|
||||
//import com.glodon.cloudt.rest.client.exception.NoAuthenticateException;
|
||||
//import com.glodon.cloudt.rest.client.impl.HmacRestServiceClient;
|
||||
//import com.google.common.base.Objects;
|
||||
//import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
//import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
//import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationData;
|
||||
//import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationRawMaterialData;
|
||||
//import com.zhgd.xmgl.modules.stablewater.entity.StableWaterMixStationSetData;
|
||||
//import com.zhgd.xmgl.modules.stablewater.mapper.StableWaterMixStationDataMapper;
|
||||
//import com.zhgd.xmgl.modules.stablewater.service.IStableWaterMixStationDataService;
|
||||
//import com.zhgd.xmgl.util.ThirdPartRequestUtil;
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import net.javacrumbs.shedlock.core.SchedulerLock;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.scheduling.annotation.Scheduled;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||
//import org.springframework.web.bind.annotation.RestController;
|
||||
//
|
||||
//import java.text.SimpleDateFormat;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 水稳拌合站任务
|
||||
// */
|
||||
//@Slf4j
|
||||
//@Component
|
||||
//@RestController
|
||||
//public class StableWaterMixStationTask {
|
||||
// @Autowired
|
||||
// ThirdPartRequestUtil thirdPartRequestUtil;
|
||||
// @Autowired
|
||||
// IStableWaterMixStationDataService stableWaterMixStationDataService;
|
||||
// @Autowired
|
||||
// StableWaterMixStationDataMapper stableWaterMixStationDataMapper;
|
||||
// @Autowired
|
||||
// ProjectMapper projectMapper;
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 每5分钟拉取广联达的搅拌站数据,https://xmgl.glodon.com/wl/docs/third_help/part2/openapi/pull/mixTotal.html
|
||||
// */
|
||||
// @Scheduled(cron = "0 0/5 * * * ?")
|
||||
// @SchedulerLock(name = "executeStableWaterMixStationTask", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 60 * 1)
|
||||
// @RequestMapping("xmgl/task/executeStableWaterMixStationTask")
|
||||
// public void executeStableWaterMixStationTask() {
|
||||
// log.info("定时拉取广联达的搅拌站数据任务开始");
|
||||
// List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
||||
// .isNotNull(Project::getGldLicPath)
|
||||
// .ne(Project::getGldLicPath, "")
|
||||
// );
|
||||
// for (Project project : projects) {
|
||||
// StableWaterMixStationData data = stableWaterMixStationDataMapper.selectOne(new LambdaQueryWrapper<StableWaterMixStationData>()
|
||||
// .eq(StableWaterMixStationData::getProjectSn, project.getProjectSn())
|
||||
// .orderByDesc(StableWaterMixStationData::getTimestamp)
|
||||
// .last("limit 1")
|
||||
// );
|
||||
// String timestamp;
|
||||
// if (data != null) {
|
||||
// timestamp = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(data.getTimestamp());
|
||||
// } else {
|
||||
// timestamp = "20230101141314082";
|
||||
// }
|
||||
// sendHttp(project, timestamp);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void sendHttp(Project project, String timestamp) {
|
||||
// try {
|
||||
// log.info("定时拉取广联达的搅拌站数据任务开始:项目名称:{} 项目sn:{} timestamp:{}", project.getProjectName(), project.getProjectSn(), timestamp);
|
||||
// /**----------------准备 -------------------*/
|
||||
// //第1步:下载授权文件
|
||||
// //第2步:获取SDK
|
||||
// /** ------------ 授权认证 --------------*/
|
||||
//
|
||||
// //第3步:创建客户端实例
|
||||
// RestServiceClient serviceClient = HmacRestServiceClient.getInstance();
|
||||
// //第4步:加载/验证授权文件
|
||||
// //4.1构建认证信息
|
||||
// HmacRestAuthInfo restAuthInfo = new HmacRestAuthInfo();
|
||||
// //4.2设置授权文件路径
|
||||
// restAuthInfo.setLicPath(project.getGldLicPath());
|
||||
// //4.3权限认证
|
||||
// serviceClient.authenticate(restAuthInfo);
|
||||
//
|
||||
// /** ------------ 拼接请求地址 --------------*/
|
||||
// //第5步:获取授权文件关联的GYS系统地址hostAddress
|
||||
// String hostAddress = serviceClient.getRestRootAddress();
|
||||
// //第6步:设置请求接口的URI地址apiURI(以获取集成项目列表信息为例)
|
||||
// String apiUri = String.format("/api/mix/v1.0/mix/product/getMachineProductList?beginTimestamp=%s", timestamp);
|
||||
// //第7步:拼装完整的请求网址
|
||||
// String fullUrl = hostAddress + apiUri;
|
||||
// //第8步:请求数据准备(本例中为从GYS系统获取数据,无需进行请求数据的准备)
|
||||
//
|
||||
// log.info("url:{}", fullUrl);
|
||||
// //第9步:发送请求,用来推送/获取数据
|
||||
// RestResponseInfo restResponseInfo = serviceClient.get(fullUrl);
|
||||
// log.info("rs:{}", JSON.toJSONString(restResponseInfo));
|
||||
//
|
||||
//
|
||||
// /** ------------ 处理请求返回结果 --------------*/
|
||||
// if (restResponseInfo.isSuccess()) {
|
||||
// //请求成功:
|
||||
// //第10步:处理请求结果(第三方系统自行处理)
|
||||
// String stringContent = restResponseInfo.getStringContent();
|
||||
// JSONObject scjo = JSON.parseObject(stringContent);
|
||||
// if (scjo.getBoolean("success")) {
|
||||
// saveData(scjo.getJSONObject("data"), project);
|
||||
// JSONObject dataJo = scjo.getJSONObject("data");
|
||||
// //继续发送http查询未保存的数据
|
||||
// if (!Objects.equal(dataJo.getInteger("PageSize"), 0)) {
|
||||
// sendHttp(project, dataJo.getString("MaxTimestamp"));
|
||||
// }
|
||||
// } else {
|
||||
// log.error("失败:未知原因1");
|
||||
// }
|
||||
// } else {
|
||||
// //请求失败:
|
||||
// //第11步:根据返回结果排查失败原因(数据原因第三方系统自行处理)
|
||||
// log.error("失败:未知原因2");
|
||||
// }
|
||||
// } catch (AuthenticateException e) {
|
||||
// log.error("error:", e);
|
||||
// } catch (InvalidUriException e) {
|
||||
// log.error("error:", e);
|
||||
// } catch (NoAuthenticateException e) {
|
||||
// log.error("error:", e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void saveData(JSONObject dataJo, Project project) {
|
||||
// //保存拌合站设备,一个项目级别的授权文件对应我们的一个项目,他们的一个项目有多个拌合站(属性是projectId)(和我们设备对应),一个拌合站有多个机组(我们不体现)
|
||||
// //保存拌合站数据
|
||||
// JSONArray bills = dataJo.getJSONArray("Bills");
|
||||
// for (Object bill : bills) {
|
||||
// StableWaterMixStationData data = new StableWaterMixStationData();
|
||||
// List<StableWaterMixStationSetData> setDataList = new ArrayList<>();
|
||||
// data.setSetDataList(setDataList);
|
||||
// BeanUtil.copyProperties(bill, data, true);
|
||||
// data.setDevSn(((JSONObject) bill).getString("projectId"));
|
||||
// JSONArray pcList = ((JSONObject) bill).getJSONArray("PCList");
|
||||
// for (Object pc : pcList) {
|
||||
// StableWaterMixStationSetData setData = new StableWaterMixStationSetData();
|
||||
// BeanUtil.copyProperties(pc, setData, true);
|
||||
// setDataList.add(setData);
|
||||
// List<StableWaterMixStationRawMaterialData> rawMaterialDataList = new ArrayList<>();
|
||||
// setData.setRawMaterialDataList(rawMaterialDataList);
|
||||
// JSONArray ycList = ((JSONObject) pc).getJSONArray("YCList");
|
||||
// for (Object yc : ycList) {
|
||||
// StableWaterMixStationRawMaterialData rawMaterialData = new StableWaterMixStationRawMaterialData();
|
||||
// BeanUtil.copyProperties(yc, rawMaterialData, true);
|
||||
// rawMaterialDataList.add(rawMaterialData);
|
||||
// }
|
||||
// }
|
||||
// try {
|
||||
// stableWaterMixStationDataService.add(data);
|
||||
// } catch (Exception e) {
|
||||
// log.error("error:", e);
|
||||
// log.info("新增出错:{},编号:{}", e.getMessage(), data.getDevSn());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user