add: 历史模块添加设备报警记录

This commit is contained in:
yanps
2023-12-06 16:08:37 +08:00
parent cdd6be9f89
commit 17d364714e
27 changed files with 984 additions and 104 deletions

View File

@@ -200,7 +200,7 @@ public class AddressServiceImpl extends CommonServiceImpl<AddressMapper, Address
public void create(AddressDto dto) { public void create(AddressDto dto) {
String Methods_code = dto.getMethods_code(); String Methods_code = dto.getMethods_code();
AddressDto methodsDto = this.findByCode(Methods_code); AddressDto methodsDto = this.findByCode(Methods_code);
if (methodsDto != null && methodsDto.getIs_delete().equals("0") && dto.getMethods_code().equals(methodsDto.getMethods_code())) { if (methodsDto != null && "0".equals(methodsDto.getIs_delete()) && dto.getMethods_code().equals(methodsDto.getMethods_code())) {
throw new BadRequestException(LangProcess.msg("error_checkExist", methodsDto.getMethods_code())); throw new BadRequestException(LangProcess.msg("error_checkExist", methodsDto.getMethods_code()));
} }
Long userId = Long.valueOf(SecurityUtils.getCurrentUserId()); Long userId = Long.valueOf(SecurityUtils.getCurrentUserId());

View File

@@ -43,6 +43,8 @@ public class AgvServiceImpl implements AgvService {
Map<String, AgvDto> AGVDeviceStatus = new HashMap(); Map<String, AgvDto> AGVDeviceStatus = new HashMap();
private static final String my_separator = "-";
@Override @Override
public Map<String, AgvDto> findAllAgvFromCache() { public Map<String, AgvDto> findAllAgvFromCache() {
return AGVDeviceStatus; return AGVDeviceStatus;
@@ -94,7 +96,7 @@ public class AgvServiceImpl implements AgvService {
public static void main(String[] args) { public static void main(String[] args) {
String address = "L1-01-01"; String address = "L1-01-01";
if (address.indexOf("-") > 0) { if (address.indexOf(my_separator) > 0) {
String str = address.substring(address.indexOf("-"), address.length()); String str = address.substring(address.indexOf("-"), address.length());
address = address.substring(0, address.indexOf("-")); address = address.substring(0, address.indexOf("-"));
} }

View File

@@ -192,7 +192,7 @@ public class MagicAgvServiceImpl implements MagicAgvService {
destinationOrder.put("locationName", locationName); destinationOrder.put("locationName", locationName);
//机器人在工作站要执行的操作 //机器人在工作站要执行的操作
destinationOrder.put("operation", operation); destinationOrder.put("operation", operation);
if (propertiesType.equals("1")) {//取货前等待、取货后等待 if ("1".equals(propertiesType)) {//取货前等待、取货后等待
//pro 1 进入离开等待 //pro 1 进入离开等待
if ("1".equals(pro)) { if ("1".equals(pro)) {
@@ -251,7 +251,7 @@ public class MagicAgvServiceImpl implements MagicAgvService {
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} }
} else if (propertiesType.equals("2")) {//Spin转动 } else if ("2".equals(propertiesType)) {//Spin转动
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系 pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系
@@ -262,14 +262,14 @@ public class MagicAgvServiceImpl implements MagicAgvService {
pro2.put("value", "0");//弧度值如0 pro2.put("value", "0");//弧度值如0
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作 } else if ("3".equals(propertiesType)) {//JackUnload,Jackload不操作
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "recognize");//固定值 pro1.put("key", "recognize");//固定值
pro1.put("value", "false");//固定值 pro1.put("value", "false");//固定值
properties.add(pro1); properties.add(pro1);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("4")) { } else if ("4".equals(propertiesType)) {
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系 pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系

View File

@@ -332,8 +332,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String nextAddress = inst.getNext_device_code(); String nextAddress = inst.getNext_device_code();
Device startdevice = deviceAppService.findDeviceByCode(startAddress); Device startdevice = deviceAppService.findDeviceByCode(startAddress);
Device nextdevice = deviceAppService.findDeviceByCode(nextAddress); Device nextdevice = deviceAppService.findDeviceByCode(nextAddress);
break; break;
default:
break;
} }
orderjo.put("destinations", ja); orderjo.put("destinations", ja);
@@ -369,14 +370,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
destinationOrder.put("locationName", locationName); destinationOrder.put("locationName", locationName);
//机器人在工作站要执行的操作 //机器人在工作站要执行的操作
destinationOrder.put("operation", operation); destinationOrder.put("operation", operation);
if (propertiesType.equals("1")) {//Wait请求是否继续 if ("1".equals(propertiesType)) {//Wait请求是否继续
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro2 = new JSONObject(); JSONObject pro2 = new JSONObject();
pro2.put("key", "device:queryAtExecuted");//固定值 pro2.put("key", "device:queryAtExecuted");//固定值
pro2.put("value", pro + ":wait");//pro为wait请求的标识一般用点位拼接的字符串 pro2.put("value", pro + ":wait");//pro为wait请求的标识一般用点位拼接的字符串
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("2")) {//Spin转动 } else if ("2".equals(propertiesType)) {//Spin转动
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系 pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系
@@ -387,14 +388,14 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
pro2.put("value", "0");//弧度值如0 pro2.put("value", "0");//弧度值如0
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作 } else if ("3".equals(propertiesType)) {//JackUnload,Jackload不操作
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "recognize");//固定值 pro1.put("key", "recognize");//固定值
pro1.put("value", "false");//固定值 pro1.put("value", "false");//固定值
properties.add(pro1); properties.add(pro1);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("4")) { } else if ("4".equals(propertiesType)) {
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系 pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系
@@ -405,7 +406,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
pro2.put("value", "0");//弧度值如0 pro2.put("value", "0");//弧度值如0
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("5")) {//Wait请求是否继续 } else if ("5".equals(propertiesType)) {//Wait请求是否继续
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro2 = new JSONObject(); JSONObject pro2 = new JSONObject();

View File

@@ -45,7 +45,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
String task_type = inst.getInstruction_type(); String task_type = inst.getInstruction_type();
jo.put("deadline", AgvUtil.getNextDay(1)); jo.put("deadline", AgvUtil.getNextDay(1));
//判断是否追加任务 //判断是否追加任务
if (task_type.equals("3") || task_type.equals("4")) { if ("3".equals(task_type) || "4".equals(task_type)) {
jo.put("complete", "false"); jo.put("complete", "false");
} else { } else {
jo.put("complete", "true"); jo.put("complete", "true");
@@ -53,9 +53,9 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
jo.put("task_code", inst.getInstruction_code()); jo.put("task_code", inst.getInstruction_code());
//根据任务,下发指令类型 //根据任务,下发指令类型
JSONArray destinations = new JSONArray(); JSONArray destinations = new JSONArray();
if (task_type.equals("3")) { if ("3".equals(task_type)) {
destinations.add(destination(start_point_code, "Wait", "5", "1")); destinations.add(destination(start_point_code, "Wait", "5", "1"));
} else if (task_type.equals("4")) { } else if ("4".equals(task_type)) {
destinations.add(destination(start_point_code, "Load", "1", "1")); destinations.add(destination(start_point_code, "Load", "1", "1"));
destinations.add(destination(next_point_code, "Wait", "5", "1")); destinations.add(destination(next_point_code, "Wait", "5", "1"));
} else { } else {
@@ -73,7 +73,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
//不同楼层下发不同的agv系统 //不同楼层下发不同的agv系统
if (task_type.equals("1")) { if ("1".equals(task_type)) {
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code(); agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code();
} else { } else {
agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code(); agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code();
@@ -98,11 +98,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
String agvurl = ""; String agvurl = "";
String agvport = ""; String agvport = "";
if (type.equals("1")) { if ("1".equals(type)) {
agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
} }
if (type.equals("2")) { if ("2".equals(type)) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue(); agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue(); agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
} }
@@ -147,7 +147,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
//取货的进入前等待和离开等待 //取货的进入前等待和离开等待
if (action.equals("Load")) { if ("Load".equals(action)) {
if ("EntryRequired".equals(type)) { if ("EntryRequired".equals(type)) {
//豪凯自动线对接位 //豪凯自动线对接位
@@ -172,7 +172,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
} }
} }
//等待点等待 //等待点等待
if (action.equals("Wait")) { if ("Wait".equals(action)) {
if ("Wait".equals(type)) { if ("Wait".equals(type)) {
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
jo.put("task_code", inst.getInstruction_code()); jo.put("task_code", inst.getInstruction_code());
@@ -239,7 +239,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
} }
} }
//放货的进入前等待和离开等待 //放货的进入前等待和离开等待
if (action.equals("Unload")) { if ("Unload".equals(action)) {
if ("EntryRequired".equals(type)) { if ("EntryRequired".equals(type)) {
if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { if (addressdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver(); hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) addressdevice.getDeviceDriver();
@@ -262,7 +262,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
if (is_feedback) { if (is_feedback) {
requestjo.put("task_code", jobno); requestjo.put("task_code", jobno);
requestjo.put("operation", action); requestjo.put("operation", action);
if (type.equals("entryRequired") || type.equals("EntryRequired")) { if ("entryRequired".equals(type) || "EntryRequired".equals(type)) {
requestjo.put("entryRequired", "true"); requestjo.put("entryRequired", "true");
} else { } else {
requestjo.put("pauseOnStation", "true"); requestjo.put("pauseOnStation", "true");
@@ -273,7 +273,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
if (inst.getInstruction_type().equals("4")) { if ("4".equals(inst.getInstruction_type())) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue(); agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
} }
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact"; agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
@@ -332,7 +332,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
destinationOrder.put("locationName", locationName); destinationOrder.put("locationName", locationName);
//机器人在工作站要执行的操作 //机器人在工作站要执行的操作
destinationOrder.put("operation", operation); destinationOrder.put("operation", operation);
if (propertiesType.equals("1")) {//取货前等待、取货后等待 if ("1".equals(propertiesType)) {//取货前等待、取货后等待
//pro 1 进入离开等待 //pro 1 进入离开等待
if ("1".equals(pro)) { if ("1".equals(pro)) {
@@ -384,7 +384,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} }
} else if (propertiesType.equals("2")) {//Spin转动 } else if ("2".equals(propertiesType)) {//Spin转动
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系 pro1.put("key", "global_spin_angle");//坐标系类型global_spin_angle为全局坐标系
@@ -395,14 +395,14 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
pro2.put("value", "0");//弧度值如0 pro2.put("value", "0");//弧度值如0
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作 } else if ("3".equals(propertiesType)) {//JackUnload,Jackload不操作
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "recognize");//固定值 pro1.put("key", "recognize");//固定值
pro1.put("value", "false");//固定值 pro1.put("value", "false");//固定值
properties.add(pro1); properties.add(pro1);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("4")) { } else if ("4".equals(propertiesType)) {
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系 pro1.put("key", "robot_spin_angle");//坐标系类型robot_spin_angle为机器人坐标系
@@ -413,7 +413,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
pro2.put("value", "0");//弧度值如0 pro2.put("value", "0");//弧度值如0
properties.add(pro2); properties.add(pro2);
destinationOrder.put("properties", properties); destinationOrder.put("properties", properties);
} else if (propertiesType.equals("5")) {//在该点进行等待 } else if ("5".equals(propertiesType)) {//在该点进行等待
JSONArray properties = new JSONArray(); JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject(); JSONObject pro1 = new JSONObject();
pro1.put("key", "Wait"); pro1.put("key", "Wait");

View File

@@ -0,0 +1,23 @@
package org.nl.acs.device.enums;
public enum ErrorType {
AGV_ERROR("agv_error_type","AGV错误类型"),
CONVEYOR_ERROR("conveyor_error_type","输送机错误类型"),
STACKER_ERROR("stacker_error_type","堆垛机错误类型"),
STATION_ERROR("station_error_type","货台错误类型"),
RGV_ERROR("rgv_error_type","有轨制导搬运车辆错误类型"),
AGV_SYSTEM_ERROR("agv_system_error_type","AGV系统错误类型");
private String errorType;
private String errorTypeName;
ErrorType(String errorType, String errorTypeName) {
this.errorType = errorType;
this.errorTypeName = errorTypeName;
}
public String getErrorType() {
return errorType;
}
}

View File

@@ -230,7 +230,7 @@ public class DeviceExtraServiceImpl extends CommonServiceImpl<DeviceExtraMapper,
public void createByDeviceConfig(JSONObject json, String filed_type) { public void createByDeviceConfig(JSONObject json, String filed_type) {
//设备标识 //设备标识
String device_id = json.getString("device_id"); String device_id = json.getString("device_id");
String deviceIds[] = {device_id}; String[] deviceIds = {device_id};
this.deleteAllByDeviceIds(deviceIds); this.deleteAllByDeviceIds(deviceIds);
//设备标识不算扩展属性 //设备标识不算扩展属性
json.remove("device_id"); json.remove("device_id");

View File

@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.agv.server.AgvService; import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.ErrorType;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver;
@@ -18,6 +19,9 @@ import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -58,6 +62,8 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired @Autowired
AgvService agvService = SpringContextHolder.getBean(AgvService.class); AgvService agvService = SpringContextHolder.getBean(AgvService.class);
@Autowired
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean("acsDeviceErrorLogServiceImpl");
private Date instruction_update_time = new Date(); private Date instruction_update_time = new Date();
private Date require_apply_strangulation_time = new Date(); private Date require_apply_strangulation_time = new Date();
@@ -220,7 +226,12 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
} }
if (error != last_error) { if (error != last_error) {
if (error != 0) { if (error != 0) {
DeviceErrorLogDto acsDeviceErrorLog = new DeviceErrorLogDto();
acsDeviceErrorLog.setDevice_code(this.device_code);
acsDeviceErrorLog.setError_code(String.valueOf(error));
String errorInfo = ErrorUtil.getDictDetail(ErrorType.CONVEYOR_ERROR.getErrorType(), String.valueOf(error));
acsDeviceErrorLog.setError_info(errorInfo);
errorLogServer.create(acsDeviceErrorLog);
} }
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error); logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);

View File

@@ -128,7 +128,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator(); Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue p2[]; ItemValue[] p2;
p2 = new ItemValue[itemValues.size()]; p2 = new ItemValue[itemValues.size()];
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {
@@ -147,7 +147,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator(); Iterator<Map.Entry<String, Object>> it = itemValues.entrySet().iterator();
ItemValue p2[]; ItemValue[] p2;
p2 = new ItemValue[itemValues.size()]; p2 = new ItemValue[itemValues.size()];
int i = 0; int i = 0;
while (it.hasNext()) { while (it.hasNext()) {

View File

@@ -1,6 +1,8 @@
package org.nl.acs.device_driver.stacker.standard_stacker; package org.nl.acs.device_driver.stacker.standard_stacker;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@@ -9,6 +11,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.DeviceType; import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device.enums.ErrorType;
import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.DeviceExtraService;
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriver;
@@ -17,6 +20,10 @@ import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.domain.AcsDeviceErrorLog;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.acs.instruction.domain.Instruction; import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.log.service.DeviceExecuteLogService;
@@ -54,6 +61,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
@Autowired @Autowired
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
@Autowired
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean("acsDeviceErrorLogServiceImpl");
//心跳 //心跳
Integer heartbeat = 0; Integer heartbeat = 0;
@@ -242,6 +251,12 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
} }
if (!error.equals(last_error)) { if (!error.equals(last_error)) {
if (0 != error) { if (0 != error) {
DeviceErrorLogDto acsDeviceErrorLog = new DeviceErrorLogDto();
acsDeviceErrorLog.setDevice_code(this.device_code);
acsDeviceErrorLog.setError_code(String.valueOf(error));
String errorInfo = ErrorUtil.getDictDetail(ErrorType.STACKER_ERROR.getErrorType(), String.valueOf(error));
acsDeviceErrorLog.setError_info(errorInfo);
errorLogServer.create(acsDeviceErrorLog);
} }
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(error)); logServer.deviceItemValue(this.device_code, "mode", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error); logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
@@ -620,13 +635,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
map.put("to_task", inst.getInstruction_code()); map.put("to_task", inst.getInstruction_code());
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z")) ) { if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) {
map.put("to_x", startDevice.getExtraValue().get("z")); map.put("to_x", startDevice.getExtraValue().get("z"));
} }
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("x")) ) { if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("x"))) {
map.put("to_z", startDevice.getExtraValue().get("x")); map.put("to_z", startDevice.getExtraValue().get("x"));
} }
if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("y")) ) { if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("y"))) {
map.put("to_y", startDevice.getExtraValue().get("y")); map.put("to_y", startDevice.getExtraValue().get("y"));
} }
} }

View File

@@ -783,35 +783,35 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_device_json.get("storage_code"); put_point_code = (String) put_device_json.get("parent_storage_code") == null ? put_device_code : (String) put_device_json.get("storage_code");
} }
if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) { if (StrUtil.isNotEmpty(start_point_code) && start_point_code.indexOf("-") > 0) {
String str[] = start_point_code.split("-"); String[] str = start_point_code.split("-");
start_device_code = str[0]; start_device_code = str[0];
} else { } else {
start_device_code = start_point_code; start_device_code = start_point_code;
} }
if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) { if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) {
String str[] = next_point_code.split("-"); String[] str = next_point_code.split("-");
next_device_code = str[0]; next_device_code = str[0];
} else { } else {
next_device_code = next_point_code; next_device_code = next_point_code;
} }
if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) { if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) {
String str[] = start_point_code2.split("-"); String[] str = start_point_code2.split("-");
start_device_code2 = str[0]; start_device_code2 = str[0];
} else { } else {
start_device_code2 = start_point_code2; start_device_code2 = start_point_code2;
} }
if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) { if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) {
String str[] = next_point_code2.split("-"); String[] str = next_point_code2.split("-");
next_device_code2 = str[0]; next_device_code2 = str[0];
} else { } else {
next_device_code2 = next_point_code2; next_device_code2 = next_point_code2;
} }
if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) {
String str[] = put_point_code.split("-"); String[] str = put_point_code.split("-");
put_device_code = str[0]; put_device_code = str[0];
} else { } else {
put_device_code = put_point_code; put_device_code = put_point_code;

View File

@@ -0,0 +1,142 @@
package org.nl.acs.history;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.dict.dao.Dict;
import org.nl.system.service.dict.dto.DictDetailDto;
import org.nl.system.service.dict.impl.SysDictServiceImpl;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @author: geng by
* @createDate: 2023/3/15
*/
public class ErrorUtil {
public static ConcurrentHashMap<String, List<Dict>> dictMap = new ConcurrentHashMap<>();
public static String getDictDetail(String type, String error_code) {
getDict();
List<Dict> dictDetailDtos = dictMap.get(type);
String detail = null;
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
for (int i = 0; i < dictDetailDtos.size(); i++) {
Dict dictDetailDto = dictDetailDtos.get(i);
String value = dictDetailDto.getValue();
String label = dictDetailDto.getLabel();
if (StrUtil.equals(value, error_code)) {
detail = label;
break;
}
}
}
return detail == null ? "字典表未配置对应的报警信息" : detail;
}
public static Map<Integer, String> getDictDetailByName(String type) {
getDict();
List<Dict> dictDetailDtos = dictMap.get(type);
Map<Integer, String> map = new HashMap<>();
if (ObjectUtil.isNotEmpty(dictDetailDtos)) {
List<Dict> dtos = dictDetailDtos
.stream()
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("0"))
.filter(dictDetailDto -> !dictDetailDto.getValue().equals("-1"))
.collect(Collectors.toList());
dtos.forEach(dictDetailDto -> map.put(Integer.parseInt(dictDetailDto.getValue()), dictDetailDto.getLabel()));
}
return map;
}
public static void getDict() {
if (ObjectUtil.isEmpty(dictMap)) {
ISysDictService dictDetailService = SpringContextHolder.getBean(SysDictServiceImpl.class);
//DictService dictService = SpringContextHolder.getBean(DictServiceImpl.class);
List<Dict> dictDtos = dictDetailService.queryAll();
for (int i = 0; i < dictDtos.size(); i++) {
Dict dictDto = dictDtos.get(i);
dictMap.put(dictDto.getName(), getDict(dictDto.getName(), dictDetailService::getDictByName));
}
}
}
public static List<Dict> getDict(String name, Function<String, List<Dict>> f) {
return f.apply(name);
}
public static Map<String, String> getAgvErrorMsg(Integer agvErrorNum) {
String code;
String message;
if (agvErrorNum == 0) {
code = "0";
message = "正常";
} else if (agvErrorNum < 0) {
code = "-1";
message = "AGV上报报警代码有误";
} else {
Map<Integer, String> agvMap = getDictDetailByName("agv_error_type");
if (agvMap.isEmpty()) {
code = "-1";
message = "字典表未配置 [agv_error_type]";
} else {
List<Map.Entry<Integer, String>> errors = agvMap.entrySet().stream().filter(e -> e.getKey() > 0).sorted(Comparator.comparingInt(Map.Entry::getKey)).collect(Collectors.toList());
if (errors.isEmpty()) {
code = "-1";
message = "字典表 [agv_error_type] 配置有误";
} else if (agvErrorNum >= (int) Math.pow(2, errors.get(errors.size() - 1).getKey())) {
code = "-1";
message = "AGV上报报警代码有误";
} else {
int index = 0;
StringBuilder errorCode = new StringBuilder();
StringBuilder errorMessage = new StringBuilder();
for (int i = agvErrorNum; i != 0; i = i >> 1) {
if (index == errors.size()) {
errorCode.setLength(0);
errorCode.append("-1");
errorMessage.setLength(0);
errorMessage.append("字典表 [agv_error_type] 配置有误");
break;
}
if (i % 2 == 1) {
errorCode.append(errors.get(index).getKey()).append(",");
errorMessage.append(errors.get(index).getValue()).append("");
}
index++;
}
code = errorCode.toString();
message = errorMessage.toString();
}
}
}
Map<String, String> map = new HashMap<>();
map.put("code", replace(code));
map.put("info", replace(message));
return map;
}
public static String replace(String message) {
if (StrUtil.isEmpty(message)) {
return null;
}
if (message.endsWith(",") || message.endsWith("")) {
return message.substring(0, message.length() - 1);
}
return message;
}
}

View File

@@ -0,0 +1,39 @@
package org.nl.acs.history.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import java.io.Serializable;
@Data
@Builder
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("acs_device_error_log")
public class AcsDeviceErrorLog implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "设备报警记录标识")
@TableId(type = IdType.ASSIGN_ID)
private String error_log_uuid;
@ApiModelProperty(value = "设备编码")
private String device_code;
@ApiModelProperty(value = "错误码")
private String error_code;
@ApiModelProperty(value = "错误信息")
private String error_info;
@ApiModelProperty(value = "错误时间")
private String error_time;
}

View File

@@ -0,0 +1,77 @@
package org.nl.acs.history.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.common.logging.annotation.Log;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
/**
* @author gengby
* @date 2023-03-15
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "设备报警记录管理")
@RequestMapping("/api/deviceErrorLog")
@Slf4j
public class DeviceErrorLogController {
private final DeviceErrorLogService acsDeviceErrorLogService;
@GetMapping
@Log("查询设备报警记录")
@ApiOperation("查询设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page){
return new ResponseEntity<>(acsDeviceErrorLogService.queryAll(whereJson,page),HttpStatus.OK);
}
@PostMapping
@Log("新增设备报警记录")
@ApiOperation("新增设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:add')")
public ResponseEntity<Object> create(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.create(dto);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping
@Log("修改设备报警记录")
@ApiOperation("修改设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody DeviceErrorLogDto dto){
acsDeviceErrorLogService.update(dto);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除设备报警记录")
@ApiOperation("删除设备报警记录")
//@PreAuthorize("@el.check('acsDeviceErrorLog:del')")
@DeleteMapping
public ResponseEntity<Object> delete(@RequestBody String[] ids) {
acsDeviceErrorLogService.deleteAll(ids);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("导出设备报警记录")
@ApiOperation("导出设备报警记录")
@GetMapping(value = "/download")
//@PreAuthorize("@el.check('acsDeviceErrorLog:list')")
public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException {
acsDeviceErrorLogService.download(acsDeviceErrorLogService.queryAll(whereJson), response);
}
}

View File

@@ -0,0 +1,76 @@
package org.nl.acs.history.service;
import org.nl.acs.common.base.CommonService;
import org.nl.acs.history.domain.AcsDeviceErrorLog;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @description 服务接口
* @author gengby
* @date 2023-03-15
**/
public interface DeviceErrorLogService extends CommonService<AcsDeviceErrorLog> {
/**
* 查询数据分页
* @param whereJson 条件
* @param page 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(Map whereJson, Pageable page);
/**
* 查询所有数据不分页
* @param whereJson 条件参数
* @return List<AcsDeviceErrorLogDto>
*/
List<DeviceErrorLogDto> queryAll(Map whereJson);
/**
* 根据ID查询
* @param error_log_uuid ID
* @return AcsDeviceErrorLog
*/
DeviceErrorLogDto findById(String error_log_uuid);
/**
* 根据编码查询
* @param code code
* @return AcsDeviceErrorLog
*/
DeviceErrorLogDto findByCode(String code);
/**
* 创建
* @param dto /
*/
void create(DeviceErrorLogDto dto);
/**
* 编辑
* @param dto /
*/
void update(DeviceErrorLogDto dto);
/**
* 多选删除
* @param ids /
*/
void deleteAll(String[] ids);
/**
* 导出数据
* @param dtos 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<DeviceErrorLogDto> dtos, HttpServletResponse response) throws IOException;
}

View File

@@ -0,0 +1,31 @@
package org.nl.acs.history.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @description /
* @author gengby
* @date 2023-03-15
**/
@Data
public class DeviceErrorLogDto implements Serializable {
private static final long serialVersionUID = 1L;
/** 报警日志标识 */
private String error_log_uuid;
/** 设备编码 */
private String device_code;
/** 报警编码 */
private String error_code;
/** 报警信息 */
private String error_info;
/** 报警时间 */
private String error_time;
}

View File

@@ -0,0 +1,153 @@
package org.nl.acs.history.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
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.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.nl.acs.common.base.impl.CommonServiceImpl;
import org.nl.acs.history.domain.AcsDeviceErrorLog;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
import org.nl.acs.history.service.mapper.AcsDeviceErrorLogMapper;
import org.nl.acs.utils.PageUtil;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.FileUtil;
import org.nl.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
/**
* @author gengby
* @description 服务实现
* @date 2023-03-15
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class DeviceErrorLogServiceImpl extends CommonServiceImpl<AcsDeviceErrorLogMapper, AcsDeviceErrorLog> implements DeviceErrorLogService {
@Autowired
private AcsDeviceErrorLogMapper acsDeviceErrorLogMapper;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page1) {
LambdaQueryWrapper<AcsDeviceErrorLog> wrapper = getAcsDeviceErrorLogLambdaQueryWrapper(whereJson);
IPage<AcsDeviceErrorLog> objectIPage = PageUtil.toMybatisPage(page1);
IPage<AcsDeviceErrorLog> acsDeviceErrorLogIPage = acsDeviceErrorLogMapper.selectPage(objectIPage, wrapper);
List<AcsDeviceErrorLog> records = acsDeviceErrorLogIPage.getRecords();
long total = acsDeviceErrorLogIPage.getTotal();
HashMap<String, Object> json = new HashMap<>();
json.put("content", records);
json.put("totalElements", total);
return json;
}
@NotNull
private LambdaQueryWrapper<AcsDeviceErrorLog> getAcsDeviceErrorLogLambdaQueryWrapper(Map whereJson) {
String device_code = MapUtil.getStr(whereJson, "device_code");
String error_code = MapUtil.getStr(whereJson, "error_code");
String error_info = MapUtil.getStr(whereJson, "error_info");
LambdaQueryWrapper<AcsDeviceErrorLog> wrapper = new LambdaQueryWrapper<>();
if (StrUtil.isNotEmpty(device_code)) {
wrapper.like(AcsDeviceErrorLog::getDevice_code, device_code);
}
if (StrUtil.isNotEmpty(error_code)) {
wrapper.like(AcsDeviceErrorLog::getError_code, error_code);
}
if (StrUtil.isNotEmpty(error_info)) {
wrapper.like(AcsDeviceErrorLog::getError_info, error_info);
}
return wrapper;
}
@Override
public List<DeviceErrorLogDto> queryAll(Map whereJson) {
LambdaQueryWrapper<AcsDeviceErrorLog> wrapper = getAcsDeviceErrorLogLambdaQueryWrapper(whereJson);
List<AcsDeviceErrorLog> list = list(wrapper);
return BeanUtil.copyToList(list, DeviceErrorLogDto.class);
}
@Override
public DeviceErrorLogDto findById(String error_log_uuid) {
AcsDeviceErrorLog one = getOne(Wrappers.lambdaQuery(AcsDeviceErrorLog.class).eq(AcsDeviceErrorLog::getError_log_uuid, error_log_uuid));
/*WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = wo.query("error_log_uuid ='" + error_log_uuid + "'").uniqueResult(0);
final DeviceErrorLogDto obj = (DeviceErrorLogDto) JSONObject.toJavaObject(json, DeviceErrorLogDto.class);*/
return BeanUtil.copyProperties(one, DeviceErrorLogDto.class);
}
@Override
public DeviceErrorLogDto findByCode(String code) {
AcsDeviceErrorLog one = getOne(Wrappers.lambdaQuery(AcsDeviceErrorLog.class).eq(AcsDeviceErrorLog::getDevice_code, code));
/*WQLObject wo = WQLObject.getWQLObject("acs_device_error_log");
JSONObject json = wo.query("code ='" + code + "'").uniqueResult(0);
final DeviceErrorLogDto obj = (DeviceErrorLogDto) JSONObject.toJavaObject(json, DeviceErrorLogDto.class);*/
return BeanUtil.copyProperties(one, DeviceErrorLogDto.class);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(DeviceErrorLogDto dto) {
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
dto.setError_log_uuid(IdUtil.simpleUUID());
dto.setDevice_code(dto.getDevice_code());
dto.setError_code(dto.getError_code());
dto.setError_info(dto.getError_info());
dto.setError_time(now);
acsDeviceErrorLogMapper.insert(BeanUtil.copyProperties(dto, AcsDeviceErrorLog.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(DeviceErrorLogDto dto) {
DeviceErrorLogDto entity = this.findById(dto.getError_log_uuid());
if (entity == null) {throw new BadRequestException("被删除或无权限,操作失败!");}
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
updateById(BeanUtil.copyProperties(dto, AcsDeviceErrorLog.class));
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(String[] ids) {
if (ids == null || ids.length == 0) {throw new BadRequestException("被删除或无权限,操作失败!");}
for (String id : ids) {
this.removeById(id);
}
}
@Override
public void download(List<DeviceErrorLogDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (DeviceErrorLogDto acsDeviceErrorLog : all) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("设备编码", acsDeviceErrorLog.getDevice_code());
map.put("报警编码", acsDeviceErrorLog.getError_code());
map.put("报警信息", acsDeviceErrorLog.getError_info());
map.put("报警时间", acsDeviceErrorLog.getError_time());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
}

View File

@@ -0,0 +1,9 @@
package org.nl.acs.history.service.mapper;
import org.nl.acs.common.base.CommonMapper;
import org.nl.acs.history.domain.AcsDeviceErrorLog;
import org.springframework.stereotype.Repository;
@Repository
public interface AcsDeviceErrorLogMapper extends CommonMapper<AcsDeviceErrorLog> {
}

View File

@@ -71,7 +71,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
Map<String, List> routeLines = new HashMap(); Map<String, List> routeLines = new HashMap();
Map<String, Integer> deviceCoordinate = null;//用来确定设备在 路由二维数组中的坐标 Map<String, Integer> deviceCoordinate = null;//用来确定设备在 路由二维数组中的坐标
Map<String, String> routeChart[][] = null;//路由二维数组 Map<String, String>[][] routeChart = null;//路由二维数组
List<Map> routePlansList = new ArrayList<>(); List<Map> routePlansList = new ArrayList<>();
// private final RedisUtils redisUtils; // private final RedisUtils redisUtils;
private final RouteLineMapper routeLineMapper; private final RouteLineMapper routeLineMapper;
@@ -431,7 +431,7 @@ public class RouteLineServiceImpl extends CommonServiceImpl<RouteLineMapper, Rou
.eq(RouteLine::getRoute_plan_id, route_plan_id) .eq(RouteLine::getRoute_plan_id, route_plan_id)
.list(); .list();
JSONArray route = JSONArray.parseArray(JSON.toJSONString(routeLineList)); JSONArray route = JSONArray.parseArray(JSON.toJSONString(routeLineList));
Map n[][] = new HashMap[size][size]; Map[][] n = new HashMap[size][size];
//建二维数组 //建二维数组
for (int i = 0; i < route.size(); i++) { for (int i = 0; i < route.size(); i++) {
JSONObject jo = (JSONObject) route.get(i); JSONObject jo = (JSONObject) route.get(i);

View File

@@ -378,14 +378,12 @@ public interface TaskService extends CommonService<Task> {
/** /**
* 条件查询任务和指令 * 条件查询任务和指令
* @param whereJson * @param whereJson
* @param page
* @return * @return
*/ */
List<JSONObject> getTaskAndInst(Map whereJson); List<JSONObject> getTaskAndInst(Map whereJson);
/** /**
* 导出任务树形记录 * 导出任务树形记录
* @param taskAndInst
* @param response * @param response
*/ */
void downloadTaskTreeLogging(List<JSONObject> list, HttpServletResponse response) throws IOException; void downloadTaskTreeLogging(List<JSONObject> list, HttpServletResponse response) throws IOException;

View File

@@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.nl.acs.AcsConfig; import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial; import org.nl.acs.auto.initial.ApplicationAutoInitial;
@@ -1681,33 +1682,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override @Override
public List<JSONObject> getTaskAndInst(Map whereJson) { public List<JSONObject> getTaskAndInst(Map whereJson) {
String task_code = (String) whereJson.get("task_code"); LambdaQueryWrapper<Task> wrapper = getTaskLambdaQueryWrapper(whereJson);
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.eq(Task::getTask_code, task_code);
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(Task::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(Task::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(Task::getTask_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(Task::getStart_point_code, point_code).or().like(Task::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(Task::getCreate_time, create_time, end_time);
}
List<Task> taskList = taskMapper.selectList(wrapper); List<Task> taskList = taskMapper.selectList(wrapper);
List<JSONObject> array = new ArrayList<>(); List<JSONObject> array = new ArrayList<>();
if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) { if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) {
@@ -1752,6 +1727,38 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
return array; return array;
} }
@NotNull
private LambdaQueryWrapper<Task> getTaskLambdaQueryWrapper(Map whereJson) {
String task_code = (String) whereJson.get("task_code");
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.eq(Task::getTask_code, task_code);
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(Task::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(Task::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(Task::getTask_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(Task::getStart_point_code, point_code).or().like(Task::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(Task::getCreate_time, create_time, end_time);
}
return wrapper;
}
@Override @Override
public void downloadTaskTreeLogging(List<JSONObject> taskAndInst, HttpServletResponse response) throws IOException { public void downloadTaskTreeLogging(List<JSONObject> taskAndInst, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>(); List<Map<String, Object>> list = new ArrayList<>();
@@ -1799,33 +1806,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override @Override
public List<JSONObject> getTaskList(Map whereJson) { public List<JSONObject> getTaskList(Map whereJson) {
String task_code = (String) whereJson.get("task_code"); LambdaQueryWrapper<Task> wrapper = getTaskLambdaQueryWrapper(whereJson);
String vehicle_code = (String) whereJson.get("vehicle_code");
String material_type = (String) whereJson.get("material_type");
String status = (String) whereJson.get("status");
String point_code = (String) whereJson.get("point_code");
String create_time = (String) whereJson.get("createTime");
String end_time = (String) whereJson.get("end_time");
LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>();
if (!StrUtil.isEmpty(task_code)) {
wrapper.eq(Task::getTask_code, task_code);
}
if (!StrUtil.isEmpty(vehicle_code)) {
wrapper.like(Task::getVehicle_code, vehicle_code);
}
if (!StrUtil.isEmpty(material_type)) {
wrapper.eq(Task::getMaterial, material_type);
}
if (!StrUtil.isEmpty(status)) {
wrapper.eq(Task::getTask_status, status);
}
if (!StrUtil.isEmpty(point_code)) {
wrapper.and(task -> task.like(Task::getStart_point_code, point_code).or().like(Task::getNext_point_code, point_code));
}
if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) {
wrapper.between(Task::getCreate_time, create_time, end_time);
}
List<Task> taskList = taskMapper.selectList(wrapper); List<Task> taskList = taskMapper.selectList(wrapper);
List<JSONObject> array = new ArrayList<>(); List<JSONObject> array = new ArrayList<>();
if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) { if (CollUtil.isNotEmpty(taskList) && taskList.size() > 0) {

View File

@@ -222,7 +222,7 @@ public class DateUtil {
String hour = "00"; String hour = "00";
String minute = "00"; String minute = "00";
String second = "00"; String second = "00";
if (value != null && !value.trim().equals("")) { if (value != null && !"".equals(value.trim())) {
int v_int = Integer.valueOf(value); int v_int = Integer.valueOf(value);
hour = v_int / 3600 + "";//获得小时; hour = v_int / 3600 + "";//获得小时;
minute = v_int % 3600 / 60 + "";//获得小时; minute = v_int % 3600 / 60 + "";//获得小时;

View File

@@ -54,7 +54,7 @@ public class BaseQuery<T> {
Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments(); Type[] types = ((ParameterizedTypeImpl) this.getClass().getGenericSuperclass()).getActualTypeArguments();
Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]); Map<String, ColumnCache> columnMap = LambdaUtils.getColumnMap((Class<?>) types[0]);
json.forEach((key, vel) -> { json.forEach((key, vel) -> {
if (vel != null && !key.equals("doP")){ if (vel != null && !"doP".equals(key)){
QParam qParam = doP.get(key); QParam qParam = doP.get(key);
if (qParam != null){ if (qParam != null){
QueryTEnum.build(qParam.type,wrapper,qParam.k,vel); QueryTEnum.build(qParam.type,wrapper,qParam.k,vel);

View File

@@ -210,10 +210,10 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
File file = new File(tempPath); File file = new File(tempPath);
BigExcelWriter writer = ExcelUtil.getBigWriter(file); BigExcelWriter writer = ExcelUtil.getBigWriter(file);
// 一次性写出内容,使用默认样式,强制输出标题 // 一次性写出内容,使用默认样式,强制输出标题
for (Object item : list) {
writer.writeRow(item, true); writer.write(list, true);
}
SXSSFSheet sheet = (SXSSFSheet)writer.getSheet(); SXSSFSheet sheet = (SXSSFSheet) writer.getSheet();
//上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法 //上面需要强转SXSSFSheet 不然没有trackAllColumnsForAutoSizing方法
sheet.trackAllColumnsForAutoSizing(); sheet.trackAllColumnsForAutoSizing();
//列宽自适应 //列宽自适应

View File

@@ -0,0 +1,41 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.system.service.dict.dto;
import lombok.Getter;
import lombok.Setter;
import org.nl.common.base.BaseDTO;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Getter
@Setter
public class DictDetailDto extends BaseDTO implements Serializable {
private Long id;
private DictSmallDto dict;
private String label;
private String value;
private Integer dictSort;
}

View File

@@ -0,0 +1,32 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.nl.system.service.dict.dto;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* @author Zheng Jie
* @date 2019-04-10
*/
@Getter
@Setter
public class DictSmallDto implements Serializable {
private Long id;
}

View File

@@ -0,0 +1,249 @@
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<div v-if="crud.props.searchToggle">
<!-- 搜索 -->
<label class="el-form-item-label">设备编码</label>
<el-input
v-model="query.device_code"
clearable
placeholder="设备编码"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<el-input
v-model="query.error_code"
clearable
placeholder="报警编码"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<el-input
v-model="query.error_info"
clearable
placeholder="报警信息"
style="width: 185px;"
class="filter-item"
@keyup.enter.native="crud.toQuery"
/>
<!-- <el-date-picker
v-model="query.error_time"
clearable
placeholder="错误时间"
format="yyyy-MM-dd HH:mm:ss"
:range-separator="'至'"
:start-placeholder="'开始时间'"
:end-placeholder="'结束时间'"
class="date-item"
@change="handleDateChange"
@keyup.enter.native="crud.toQuery"
/> -->
<!-- <el-date-picker
v-model="query.start_time"
clearable
placeholder="错误时间"
format="yyyy-MM-dd HH:mm:ss"
class="date-item"
@keyup.enter.native="crud.toQuery"
/> -->
<el-date-picker
v-model="query.timeRange"
type="daterange"
clearable
range-separator=""
start-placeholder="开始时间"
end-placeholder="结束时间"
format="yyyy-MM-dd HH:mm:ss"
class="date-item"
@keyup.enter.native="crud.toQuery"
/>
<!-- <el-date-picker
v-model="timeRange"
type="datetimerange"
clearable
picker-options="{
format: 'yyyy-MM-dd HH:mm:ss',
shortcuts: [{
text: '最近一小时',
onClick(picker) {
const end = new Date();
const start = new Date(end.getTime() - 3600000);
picker.$emit('pick', [start, end]);
// 将时间范围值赋值给start_time和end_time
this.start_time = start;
this.end_time = end;
}
}, {
text: '最近一天',
onClick(picker) {
const end = new Date();
const start = new Date(end.getTime() - 24 * 3600000);
picker.$emit('pick', [start, end]);
// 将时间范围值赋值给start_time和end_time
this.start_time = start;
this.end_time = end;
}
}, {
text: '最近一周',
onClick(picker) {
const end = new Date();
const start = new Date(end.getTime() - 7 * 24 * 3600000);
picker.$emit('pick', [start, end]);
// 将时间范围值赋值给start_time和end_time
this.start_time = start;
this.end_time = end;
}
}]
}"
/> -->
<rrOperation :crud="crud" />
</div>
<!--如果想在工具栏加入更多按钮可以使用插槽方式 slot = 'left' or 'right'-->
<crudOperation :permission="permission">
<el-button
slot="left"
class="filter-item"
type="warning"
icon="el-icon-download"
size="mini"
:loading="downLoadDeviceErrorLogging"
@click="doExportDeviceErrorLogging()"
>
{{ $t('common.Export') }}
</el-button>
</crudOperation>
<!--表单组件-->
<el-dialog
:close-on-click-modal="false"
:before-close="crud.cancelCU"
:visible.sync="crud.status.cu"
:title="crud.status.title"
width="500px"
>
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px" />
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<!--表格渲染-->
<el-table
ref="table"
v-loading="crud.loading"
:data="crud.data"
size="small"
style="width: 100%;"
@selection-change="crud.selectionChangeHandler"
>
<el-table-column type="selection" width="55" />
<el-table-column prop="device_code" label="设备编码" />
<el-table-column prop="error_code" label="报警编码" />
<el-table-column prop="error_info" label="报警信息" />
<el-table-column prop="error_time" label="报警时间" />
<el-table-column
v-permission="['admin','acsDeviceErrorLog:edit','acsDeviceErrorLog:del']"
label="操作"
width="150px"
align="center"
>
<template slot-scope="scope">
<udOperation
:data="scope.row"
:permission="permission"
:disabled-edit="true"
/>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</div>
</div>
</template>
<script>
import CRUD, { crud, form, header, presenter } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import crudAcsDeviceErrorLog from '@/api/acs/history/acsDeviceErrorLog'
import { download } from '@/api/data'
import { downloadFile } from '@/utils'
const defaultForm = { error_log_uuid: null, device_code: null, error_code: null, error_info: null, error_time: null }
export default {
name: 'DeviceErrorLog',
components: { pagination, crudOperation, rrOperation, udOperation },
mixins: [presenter(), header(), form(defaultForm), crud()],
cruds() {
return CRUD({
title: '设备报警记录',
url: 'api/deviceErrorLog',
idField: 'error_log_uuid',
sort: 'error_log_uuid,desc',
crudMethod: {
...crudAcsDeviceErrorLog },
optShow: {
add: false,
edit: false,
del: false,
download: false
}
})
},
data() {
return {
permission: {
add: ['admin', 'deviceErrorLog:add'],
edit: ['admin', 'deviceErrorLog:edit'],
del: ['admin', 'adeviceErrorLog:del']
},
rules: {},
queryTypeOptions: [
{ key: 'device_code', display_name: '设备编码' },
{ key: 'error_code', display_name: '报警编码' },
{ key: 'error_info', display_name: '报警信息' }
]
}
},
methods: {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
handleDateChange() {
/* if (this.timeRange && this.timeRange.length === 2) {
this.crud.url = 'api/deviceErrorLog?page=0&size=10&sort=error_log_uuid,desc' +
'&start_time=' + this.timeRange[0] + '&end_time=' + this.timeRange[1]
} else {
this.crud.url = 'api/deviceErrorLog?page=0&size=10&sort=error_log_uuid,desc'
} */
},
doExportDeviceErrorLogging() {
this.downLoadTaskLogging = true
const params = {
device_code: this.query.device_code,
error_code: this.query.error_code,
error_info: this.query.error_info,
start_time: this.crud.createTime,
end_time: this.crud.endTime
}
const url = '/api/deviceErrorLog/download'
download(url, params).then(result => {
downloadFile(result, this.crud.title + '数据', 'csv')
this.downLoadTaskTreeLogging = false
}).catch(() => {
this.downLoadTaskTreeLogging = false
})
}
}
}
</script>
<style scoped>
</style>