|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
package com.foreverwin.mesnac.equip.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.foreverwin.mesnac.common.enums.HandleEnum;
|
|
|
|
|
import com.foreverwin.mesnac.common.util.StringUtil;
|
|
|
|
@ -22,7 +20,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
@ -66,21 +63,23 @@ public class ResourceFaultReceiveServiceImpl extends ServiceImpl<ResourceFaultRe
|
|
|
|
|
String handle = jsonObject.getString("TRANID");
|
|
|
|
|
String site = jsonObject.getString("SITE");
|
|
|
|
|
String resource = jsonObject.getString("RESOURCE");
|
|
|
|
|
String faultList = jsonObject.getString("FAULT_LIST");
|
|
|
|
|
|
|
|
|
|
String sendTime = jsonObject.getString("SEND_TIME");
|
|
|
|
|
DateTimeFormatter dataFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
LocalDateTime sendDate = LocalDateTime.parse(sendTime, dataFormatter);
|
|
|
|
|
|
|
|
|
|
String faultCode = jsonObject.getString("FAULT_CODE");
|
|
|
|
|
String description = jsonObject.getString("CONTENT");
|
|
|
|
|
|
|
|
|
|
String dateTime = jsonObject.getString("DATE_TIME");
|
|
|
|
|
LocalDateTime faultDate = LocalDateTime.parse(dateTime, dataFormatter);
|
|
|
|
|
|
|
|
|
|
if (StringUtil.isBlank(handle)) {
|
|
|
|
|
throw BusinessException.build("唯一标识不能为空!");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isBlank(site)) {
|
|
|
|
|
throw BusinessException.build("站点不能为空!");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isBlank(faultList)) {
|
|
|
|
|
throw BusinessException.build("故障参数列表不能为空!");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtil.isBlank(resource)) {
|
|
|
|
|
throw BusinessException.build("设备编号不能为空!");
|
|
|
|
|
}
|
|
|
|
@ -90,32 +89,19 @@ public class ResourceFaultReceiveServiceImpl extends ServiceImpl<ResourceFaultRe
|
|
|
|
|
throw BusinessException.build("未找到设备编号为" + resource + "的设备!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ResourceFaultReceive> list = new ArrayList<>();
|
|
|
|
|
// 故障编码及故障时间
|
|
|
|
|
JSONArray jsonArray = JSON.parseArray(faultList);
|
|
|
|
|
if (jsonArray == null || jsonArray.size() < 1){
|
|
|
|
|
throw BusinessException.build("设备编号:" + resource + ",故障参数列表不能为空!");
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
ResourceFaultReceive resourceFaultReceive = new ResourceFaultReceive();
|
|
|
|
|
// 设备编号、站点、创建时间-使用SEND_TIME、创建用户
|
|
|
|
|
resourceFaultReceive.setResrce(resource);
|
|
|
|
|
resourceFaultReceive.setSite(site);
|
|
|
|
|
resourceFaultReceive.setCreatedDateTime(sendDate);
|
|
|
|
|
resourceFaultReceive.setCreateUser(user);
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObj = (JSONObject) jsonArray.get(i);
|
|
|
|
|
String faultCode = jsonObj.getString("FAULT_CODE");
|
|
|
|
|
resourceFaultReceive.setFaultCode(faultCode);
|
|
|
|
|
String description = jsonObj.getString("CONTENT");
|
|
|
|
|
resourceFaultReceive.setDescription(description);
|
|
|
|
|
String dateTime = jsonObj.getString("DATE_TIME");
|
|
|
|
|
LocalDateTime faultDate = LocalDateTime.parse(dateTime, dataFormatter);
|
|
|
|
|
resourceFaultReceive.setFaultDate(faultDate);
|
|
|
|
|
resourceFaultReceive.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
list.add(resourceFaultReceive);
|
|
|
|
|
}
|
|
|
|
|
resourceFaultReceiveService.saveBatch(list);
|
|
|
|
|
ResourceFaultReceive resourceFaultReceive = new ResourceFaultReceive();
|
|
|
|
|
// 设备编号、站点、创建时间-使用SEND_TIME、创建用户
|
|
|
|
|
resourceFaultReceive.setResrce(resource);
|
|
|
|
|
resourceFaultReceive.setSite(site);
|
|
|
|
|
resourceFaultReceive.setCreatedDateTime(sendDate);
|
|
|
|
|
resourceFaultReceive.setCreateUser(user);
|
|
|
|
|
|
|
|
|
|
resourceFaultReceive.setFaultCode(faultCode);
|
|
|
|
|
resourceFaultReceive.setDescription(description);
|
|
|
|
|
resourceFaultReceive.setFaultDate(faultDate);
|
|
|
|
|
resourceFaultReceive.setHandle(UUID.randomUUID().toString());
|
|
|
|
|
|
|
|
|
|
resourceFaultReceiveService.save(resourceFaultReceive);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|