From f150c02aa99450de913f9340dc641e0b3e6d0672 Mon Sep 17 00:00:00 2001 From: tuqiang <437016993@qq.com> Date: Thu, 28 Dec 2023 14:11:07 +0800 Subject: [PATCH] =?UTF-8?q?add:=E6=96=B0=E5=A2=9E=E6=A0=87=E5=87=86?= =?UTF-8?q?=E7=89=88=E8=A1=8C=E6=9E=B6=E6=9C=BA=E6=A2=B0=E6=89=8B=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../device/device_driver/DriverTypeEnum.java | 5 +- .../DoubleBeltConveyorDeviceDriver.java | 25 +- .../DoubleStationStackerDeviceDriver.java | 20 +- .../standard_manipulator/ItemProtocol.java | 167 ++ .../StandardManipulatorDefination.java | 61 + .../StandardManipulatorDeviceDriver.java | 396 +++ .../wms/service/impl/WmsToAcsServiceImpl.java | 2303 ++++++++--------- .../src/views/acs/device/config.vue | 4 +- .../device/driver/standard_manipulator.vue | 546 ++++ 9 files changed, 2226 insertions(+), 1301 deletions(-) create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java create mode 100644 acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java create mode 100644 acs/nladmin-ui/src/views/acs/device/driver/standard_manipulator.vue diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index cec88dc..22fa1f1 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -43,7 +43,10 @@ public enum DriverTypeEnum { DOUBLE_STATION_STACKER(16, "double_station_stacker", "标准版-双工位堆垛机", "double_station_stacker"), DOUBLE_BELT_CONVEYOR(17, "double_belt_conveyor", "双工位输送线", "conveyor"), - WITH_STATION_DEVICE_DRIVER(18, "with_station_device_driver", "输送线关联站点", "conveyor"); + + WITH_STATION_DEVICE_DRIVER(18, "with_station_device_driver", "输送线关联站点", "conveyor"), + + STANDARD_MANIPULATOR(19, "standard_manipulator", "标准版-行架机械手", "station"); /** diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java index b278745..d9116a7 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_belt_conveyor/DoubleBeltConveyorDeviceDriver.java @@ -402,14 +402,13 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl if (ObjectUtil.isEmpty(inst)) { return false; } - Map map = new HashMap(); + Map map = new LinkedHashMap<>(); map.put("to_target", next_addr); map.put("to_task", inst.getInstruction_code()); map.put("to_command", "1"); map.put("to_container_type", "1"); map.put("to_container_no", "1"); - list.add(map); - this.writing(list); + this.writing(map); led_message = getLedMessage(inst); requireSucess = true; return true; @@ -498,15 +497,14 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl taskdto.setTask_status("1"); taskserver.update(taskdto); requireSucess = true; - Map map = new HashMap(); + Map map = new LinkedHashMap<>(); String next_addr = nextdevice.getExtraValue().get("address").toString(); map.put("to_target", next_addr); map.put("to_task", instdto.getInstruction_code()); map.put("to_command", "1"); map.put("to_container_type", "1"); map.put("to_container_no", "1"); - list.add(map); - this.writing(list); + this.writing(map); led_message = getLedMessage(instdto); requireSucess = true; return true; @@ -525,6 +523,21 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl } + public void writing(Map map) { + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + this.control(itemMap); + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } + + public void writing(String key, String param) { diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java index ff95322..5c0b4c2 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/double_station_stacker/DoubleStationStackerDeviceDriver.java @@ -263,8 +263,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im } else if (frontZerror != 0 || backZerror != 0) { message = "有报警"; } else { - HashMap map = new HashMap<>(); - List list = new ArrayList<>(); + Map map = new LinkedHashMap<>(); if (CommandEnum.STANDY.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STANDY.getStatus())){ applyTask(); requireSucess = true; @@ -350,8 +349,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im requireSucess = true; } if (ObjectUtil.isNotNull(map)) { - list.add(map); - this.writing(list); + this.writing(map); } } lastHeartbeat = heartbeat; @@ -809,6 +807,20 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im } } + public void writing(Map map) { + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + Map itemMap = new LinkedHashMap<>(); + map.forEach((key, value) -> { + if (ObjectUtil.isNotEmpty(value)) { + itemMap.put(getToParam() + key, value); + } + }); + if (ObjectUtil.isNotEmpty(itemMap)) { + this.control(itemMap); + logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); + } + } + /** * 将扩展表中的字符串数据转换成集合 diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java new file mode 100644 index 0000000..4e87380 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/ItemProtocol.java @@ -0,0 +1,167 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +public class ItemProtocol { + //心跳 + public static String item_heartbeat = "heartbeat"; + //工作模式 + public static String item_mode = "mode"; + //光电信号 + public static String item_move = "move"; + //动作信号 + public static String item_action = "action"; + //行走列 + public static String item_walk_y = "walk_y"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //x轴坐标 + public static String item_x_position = "x_position"; + //y轴坐标 + public static String item_y_position = "y_position"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发起始站 + public static String item_to_onset = "to_onset"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + + + private StandardManipulatorDeviceDriver driver; + + public ItemProtocol(StandardManipulatorDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getWalk_y() { + return this.getOpcIntegerValue(item_walk_y); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset); + } + + public float getX_position() { + return this.getOpcFloatValue(item_x_position); + } + + public float getY_position() { + return this.getOpcFloatValue(item_y_position); + } + + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isEmpty(value)) { + + } else { + return value; + } + return "0"; + } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB1.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); + list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); + list.add(new ItemDto(item_task, "任务号", "DB1.D6")); + list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10")); + list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0")); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6")); + return list; + } + + @Override + public String toString() { + return ""; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java new file mode 100644 index 0000000..b8fd9b8 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDefination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class StandardManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "standard_manipulator"; + } + + @Override + public String getDriverName() { + return "标准版-行架机械手"; + } + + @Override + public String getDriverDescription() { + return "标准版-行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new StandardStackerDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return StandardManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java new file mode 100644 index 0000000..a00eb99 --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/manipulator/standard_manipulator/StandardManipulatorDeviceDriver.java @@ -0,0 +1,396 @@ +package org.nl.acs.device_driver.manipulator.standard_manipulator; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +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.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.List; + +/** + * 标准版-行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + private Date instruction_update_time = new Date(); + private int instruction_update_time_out = 1000; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + private String error_type = "hxhj_error_type"; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + //当前指令 + Instruction inst = null; + + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + + List getDeviceCodeList = null; + + List putDeviceCodeList = null; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + walk_y = this.itemProtocol.getWalk_y(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_onset = this.itemProtocol.getTo_onset(); + x_position = this.itemProtocol.getX_position(); + y_position = this.itemProtocol.getY_position(); + + if (to_onset != last_to_onset) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset); + } + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (to_target != last_to_target) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target); + } + if (to_task != last_to_task) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task); + } + if (mode != last_mode) { + requireSucess = false; + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (walk_y != last_walk_y) { + logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (x_position != last_x_position) { + logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position); + } + if (y_position != last_y_position) { + logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position); + } + + // 更新指令状态 + if (mode == 3 && task > 0) { + Date date = new Date(); + if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); + + } else { + this.instruction_update_time = date; + //更改指令状态 + if (task > 0) { + Instruction inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0")) { + inst.setInstruction_status(CommonFinalParam.ONE); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + } + } + } + } + } + + } catch (Exception var17) { + var17.printStackTrace(); + feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { +// boolean res = applyTask(); +// if (res) { +// notCreateInstMessage = ""; +// notCreateTaskMessage = ""; +// feedMessage = ""; +// } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = "未查找任务原因为:"; + if (mode != 2) { + remark = remark + "工作模式(mode)不是待机状态,"; + } + if (move != 0) { + remark = remark + "光电信号(move)为有货状态,"; + } + if (task != 0) { + remark = remark + "当前上报任务号(task)应该为0,"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。"; + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = "脱机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "待机"; + } else if (this.getMode() == 3) { + mode = "运行中"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } + + String requireSucess = "0"; + if (this.requireSucess) { + requireSucess = "1"; + } + jo.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = "取货中"; + } else if (this.getAction() == 2) { + action = "取货完成"; + } else if (this.getAction() == 3) { + action = "放货中"; + } else if (this.getAction() == 4) { + action = "放货完成"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("task", task); + jo.put("walk_y", walk_y); + jo.put("isOnline", this.getIsonline()); + jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError()))); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); + jo.put("driver_type", "siemens_conveyor"); + jo.put("is_click", true); + jo.put("x", x_position); + jo.put("y", y_position); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } + + + + public Instruction checkInst() { + if (ObjectUtil.isNotEmpty(this.inst)) { + if (this.task > 0) { + if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) { + return this.inst; + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + } + } else { + inst = instructionService.findByCodeFromCache(String.valueOf(task)); + return inst; + } + return null; + } +} diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 0046b3b..b651484 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -7,18 +7,22 @@ import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.impl.NDCAgvServiceImpl; import org.nl.acs.common.IDriverService; +import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.agv.ndcone.AgvNdcOneDeviceDriver; import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver; import org.nl.acs.device_driver.conveyor.hongxiang_conveyor.HongXiangStationDeviceDriver; import org.nl.acs.device_driver.conveyor.hongxiang_device.HongXiangConveyorDeviceDriver; +import org.nl.acs.device_driver.manipulator.standard_manipulator.StandardManipulatorDeviceDriver; import org.nl.acs.device_driver.three_color.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.conveyor.oven_manipulator.OvenGantryManipulatorDeviceDriver; import org.nl.acs.device_driver.conveyor.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver; @@ -40,9 +44,13 @@ import org.nl.acs.monitor.DeviceStageMonitor; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceExtraManageDto; import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.storage_cell.domain.StorageCell; +import org.nl.acs.storage_cell.service.mapper.StorageCellMapper; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.common.exception.BadRequestException; import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -57,6 +65,16 @@ import java.util.stream.Collectors; @RequiredArgsConstructor @Slf4j public class WmsToAcsServiceImpl implements WmsToAcsService { + + @Autowired + private StorageCellMapper storageCellMapper; + + @Autowired + private DeviceAppService deviceAppService; + + private String log_file_type = "log_file_type"; + private String log_type = "LMS请求ACS"; + @Override public CreateTaskResponse crateTask(String param) { return null; @@ -89,7 +107,55 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public Map queryDevice(String jsonObject) throws Exception { - return null; + try { + MDC.put(log_file_type, log_type); + JSONArray backja = new JSONArray(); + JSONArray datas = JSONArray.parseArray(jsonObject); + //标准版行架机械手 + StandardManipulatorDeviceDriver standardManipulatorDeviceDriver; + + if (datas.size() == 0) { + throw new BadRequestException("缺少输入参数!"); + } + for (int i = 0; i < datas.size(); i++) { + JSONObject jo = new JSONObject(); + JSONObject data = datas.getJSONObject(i); + String parent_device_code = data.getString("device_code"); + String device_code = ""; + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.like(StringUtils.isNotBlank(parent_device_code), StorageCell::getParent_storage_code, parent_device_code); + StorageCell storageCell = storageCellMapper.selectOne(wrapper); + final JSONObject device_json = (JSONObject) JSON.toJSON(storageCell); + if (!ObjectUtil.isEmpty(device_json)) { + device_code = device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code"); + } else { + device_code = parent_device_code; + } + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + throw new Exception("未找到对应设备:" + parent_device_code); + } + if (device.getDeviceDriver() instanceof StandardManipulatorDeviceDriver) { + standardManipulatorDeviceDriver = (StandardManipulatorDeviceDriver) device.getDeviceDriver(); + jo.put("device_code", standardManipulatorDeviceDriver.getDevice().getDevice_code()); + jo.put("device_name", standardManipulatorDeviceDriver.getDevice().getDevice_name()); + jo.put("status", Math.min(3, standardManipulatorDeviceDriver.getMode())); + jo.put("x", standardManipulatorDeviceDriver.getX_position()); + jo.put("y", standardManipulatorDeviceDriver.getY_position()); + jo.put("error", standardManipulatorDeviceDriver.getError()); + } else { + jo.put("device_code", parent_device_code); + } + backja.add(jo); + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + resultJson.put("data", backja); + return resultJson; + } finally { + MDC.remove(log_file_type); + } } @Override @@ -112,1293 +178,952 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { return null; } /** - private final ApplicationContext applicationContext; - - private final InstructionService instructionService; - private final TaskService taskService; - private final DeviceService deviceService; - private final DeviceAppService deviceAppService; - private final RouteLineService routeLineService; - private final AcsToLiKuService acsToLiKuService; - private final DictDetailService dictDetailService; - private final DictService dictService; - - - private String log_file_type = "log_file_type"; - private String log_type = "LMS请求ACS"; - - @Override - public CancelTaskResponse cancelFromWms(String param) throws Exception { - ParamService paramService = SpringContextHolder.getBean(ParamService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - JSONArray datas = JSONArray.parseArray(param); - CancelTaskResponse response = new CancelTaskResponse(); - JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class); - - String task_uuid = request.getExt_task_id(); - String task_code = request.getTask_code(); - String vehicle_code = request.getVehicle_code(); - - if (StrUtil.isEmpty(task_uuid)) { - throw new WDKException("任务标识不能为空"); - } - if (StrUtil.isEmpty(task_code)) { - throw new WDKException("任务号不能为空"); - } - String cancelTaskCheck = paramService.findByCode(AcsConfig.CANCELTASKCHECK).getValue(); - if (StrUtil.equals(cancelTaskCheck, CommonFinalParam.ONE)) { - taskService.cancel(task_uuid); - } else if (StrUtil.equals(cancelTaskCheck, "0")) { - Instruction inst = instructionService.findByTaskcode(task_code); - if (inst == null) { - taskService.cancel(task_uuid); - } else { - throw new RuntimeException("指令正在执行中,操作失败!"); - } - } - - } - - if (ObjectUtil.isEmpty(errArr)) { - response.setStatus(200); - } else { - response.setStatus(400); - } - response.setMessage("success"); - response.setErrArr(errArr); - log.info("cancelFromWms--------------:输出参数:" + response); - - return response; - } - - @Override - public Map updateDeviceGoodsFromWms(String param) { - JSONArray datas = JSONArray.parseArray(param); - log.info("updateDeviceGoodsFromWms--------------:输入参数" + datas.toString()); - for (int i = 0; i < datas.size(); i++) { - JSONObject data = datas.getJSONObject(i); - String device_code = data.getString("point_code"); - String has_goods = data.getString("has_goods"); - - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - jo.put("hasGoodStatus", has_goods); - deviceService.changeDeviceStatus(jo); - - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map areaControl(JSONObject form) { - String device_code = form.getString("device_code"); - String type = form.getString("type"); - - Device device = deviceAppService.findDeviceByCode(device_code); - - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public PutActionResponse putAction(String jsonObject) throws Exception { - try { - MDC.put(log_file_type, log_type); - log.info("putAction--------------:输出参数" + jsonObject); - JSONArray datas = JSONArray.parseArray(jsonObject); - PutActionResponse response = new PutActionResponse(); - JSONArray errArr = new JSONArray(); - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - PutActionRequest request = JsonUtl.format(data, PutActionRequest.class); - String device_code = request.getDevice_code(); - String code = request.getCode(); - String value = request.getValue(); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + device_code); - } - HongXiangStationDeviceDriver hongXiangStationDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { - hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - hongXiangStationDeviceDriver.writing(code, value); - } - if (device.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) device.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(code, value); - } - - - } - response.setStatus(200); - response.setMessage("success"); - log.info("putAction--------------:输出参数:" + response); - return response; - } finally { - MDC.remove(log_file_type); - } - - } - - @Override - public Map queryDevice(String jsonObject) throws Exception { - try { - MDC.put(log_file_type, log_type); -// log.info("queryDevice--------------:输入参数" + jsonObject.toString()); - JSONArray backja = new JSONArray(); - JSONArray datas = JSONArray.parseArray(jsonObject); - - //AGV烘箱对接位 - HongXiangStationDeviceDriver hongXiangStationDeviceDriver; - //烘箱工位 - HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - //货梯对接线-带扫码器 - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - //纸管库 - PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver; - //纸管库2 - PaperTubeConveyor2DeviceDriver paperTubeConveyor2DeviceDriver; - //立库设备 - DeviceStatusDeviceDriver deviceStatusDeviceDriver; - //插拔轴机 - PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver; - //内包间行架机械手 - IndoorManipulatorDeviceDriver indoorManipulatorDeviceDriver; - //套管工位 - CasingStationConveyorDeviceDriver casingStationConveyorDeviceDriver; - - if (datas.size() == 0) { - throw new BadRequestException("缺少输入参数!"); - } - - for (int i = 0; i < datas.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject data = datas.getJSONObject(i); - String parent_device_code = data.getString("device_code"); - String device_code = ""; - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + parent_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(device_json)) { - device_code = device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code"); - } else { - device_code = parent_device_code; - } - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + parent_device_code); - } - - if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { - hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("mode", hongXiangStationDeviceDriver.getMode()); - jo.put("move", hongXiangStationDeviceDriver.getMove()); - - } else if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("mode", hongXiangConveyorDeviceDriver.getMode()); - jo.put("status", Math.min(3, hongXiangConveyorDeviceDriver.getMode())); - jo.put("move", hongXiangConveyorDeviceDriver.getMove()); - jo.put("countdown_house", hongXiangConveyorDeviceDriver.getCountdown_house()); - jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min()); - jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec()); - //温度需要除以10 - jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature() / 10); - jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature() / 10); - - jo.put("door", hongXiangConveyorDeviceDriver.getDoor()); - jo.put("finish", hongXiangConveyorDeviceDriver.getFinish()); - jo.put("task", hongXiangConveyorDeviceDriver.getTask()); - jo.put("error", hongXiangConveyorDeviceDriver.getError()); - jo.put("isError", hongXiangConveyorDeviceDriver.getError()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - - } else if (device.getDeviceDriver() instanceof CasingStationConveyorDeviceDriver) { - casingStationConveyorDeviceDriver = (CasingStationConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("mode", casingStationConveyorDeviceDriver.getMode()); - jo.put("move", casingStationConveyorDeviceDriver.getMove()); - jo.put("heartbeat", casingStationConveyorDeviceDriver.getHeartbeat()); - jo.put("carrier_direction", casingStationConveyorDeviceDriver.getCarrier_direction()); - jo.put("error", casingStationConveyorDeviceDriver.getError()); - jo.put("task", casingStationConveyorDeviceDriver.getTask()); - jo.put("material1", casingStationConveyorDeviceDriver.getMaterial1()); - jo.put("material2", casingStationConveyorDeviceDriver.getMaterial2()); - - - } else if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { - paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("qty", paperTubeConveyorDeviceDriver.getInventory_qty()); - jo.put("mode", paperTubeConveyorDeviceDriver.getMode()); - jo.put("error", paperTubeConveyorDeviceDriver.getError()); - jo.put("material_code", ObjectUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial()) ? "" : paperTubeConveyorDeviceDriver.getMaterial()); - jo.put("out_finish", paperTubeConveyorDeviceDriver.getOut_finish()); - - } else if (device.getDeviceDriver() instanceof DeviceStatusDeviceDriver) { - deviceStatusDeviceDriver = (DeviceStatusDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", deviceStatusDeviceDriver.getDevice().getDevice_code()); - jo.put("device_name", deviceStatusDeviceDriver.getDevice().getDevice_name()); - jo.put("x", deviceStatusDeviceDriver.getX()); - jo.put("y", deviceStatusDeviceDriver.getY()); - jo.put("power", deviceStatusDeviceDriver.getPower()); - jo.put("error", deviceStatusDeviceDriver.getAlarm()); - String errorInfo = ErrorUtil.getDictDetail("rgv_error_type", String.valueOf(deviceStatusDeviceDriver.getAlarm())); - jo.put("error_name", errorInfo); - jo.put("error_msg", errorInfo); - //楼层 - jo.put("map_id", deviceStatusDeviceDriver.getMap_id()); - jo.put("z", deviceStatusDeviceDriver.getMap_id()); - jo.put("pallet", deviceStatusDeviceDriver.getPallet()); - jo.put("move", deviceStatusDeviceDriver.getHasGoods() == false ? 0 : 1); - jo.put("status", StrUtil.isBlank(deviceStatusDeviceDriver.getTask_id()) ? 2 : 3); - - } else if (device.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - AgvNdcOneDeviceDriver driver = (AgvNdcOneDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", driver.getStatus()); - jo.put("power", driver.getElectric_qty()); - jo.put("x", driver.getX()); - jo.put("y", driver.getY()); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : driver.getError_message()); - } else if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - AgvNdcTwoDeviceDriver driver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", driver.getStatus()); - jo.put("power", driver.getElectric_qty()); - jo.put("x", driver.getX()); - jo.put("y", driver.getY()); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : driver.getError_message()); - } else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) { - OvenGantryManipulatorDeviceDriver driver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("x", driver.getX_position()); - jo.put("y", driver.getY_position()); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(driver.getError()))); - } else if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { - SlitTwoManipulatorDeviceDriver driver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("x", driver.getX_position()); - jo.put("y", driver.getY_position()); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("fqhj_error_type", String.valueOf(driver.getError()))); - }else if (device.getDeviceDriver() instanceof PaperTubeConveyor2DeviceDriver) { - paperTubeConveyor2DeviceDriver = (PaperTubeConveyor2DeviceDriver) device.getDeviceDriver(); - jo.put("device_code", parent_device_code); - jo.put("heartbeat",paperTubeConveyor2DeviceDriver.getHeartbeat()); - jo.put("mode",paperTubeConveyor2DeviceDriver.getMode()); - jo.put("move",paperTubeConveyor2DeviceDriver.getMove()); - jo.put("carrier_direction",paperTubeConveyor2DeviceDriver.getCarrier_direction()); - jo.put("error",paperTubeConveyor2DeviceDriver.getError()); - jo.put("task",paperTubeConveyor2DeviceDriver.getTask()); - jo.put("out_seq_arr",paperTubeConveyor2DeviceDriver.getItem_out_seq_arr()); - jo.put("out_qty_arr",paperTubeConveyor2DeviceDriver.getItem_out_qty_arr()); - jo.put("material1",paperTubeConveyor2DeviceDriver.getItem_material1()); - jo.put("qty1",paperTubeConveyor2DeviceDriver.getItem_qty1()); - jo.put("material2",paperTubeConveyor2DeviceDriver.getItem_material2()); - jo.put("qty2",paperTubeConveyor2DeviceDriver.getItem_qty2()); - jo.put("material3",paperTubeConveyor2DeviceDriver.getItem_material3()); - jo.put("qty3",paperTubeConveyor2DeviceDriver.getItem_qty3()); - jo.put("material4",paperTubeConveyor2DeviceDriver.getItem_material4()); - jo.put("qty4",paperTubeConveyor2DeviceDriver.getItem_qty4()); - jo.put("material5",paperTubeConveyor2DeviceDriver.getItem_material5()); - jo.put("qty5",paperTubeConveyor2DeviceDriver.getItem_qty5()); - jo.put("material6",paperTubeConveyor2DeviceDriver.getItem_material6()); - jo.put("qty6",paperTubeConveyor2DeviceDriver.getItem_qty6()); - jo.put("material7",paperTubeConveyor2DeviceDriver.getItem_material7()); - jo.put("qty7",paperTubeConveyor2DeviceDriver.getItem_qty7()); - jo.put("material8",paperTubeConveyor2DeviceDriver.getItem_material8()); - jo.put("qty8",paperTubeConveyor2DeviceDriver.getItem_qty8()); - jo.put("material9",paperTubeConveyor2DeviceDriver.getItem_material9()); - jo.put("qty9",paperTubeConveyor2DeviceDriver.getItem_qty9()); - jo.put("material10",paperTubeConveyor2DeviceDriver.getItem_material10()); - jo.put("qty10",paperTubeConveyor2DeviceDriver.getItem_qty10()); - jo.put("material11",paperTubeConveyor2DeviceDriver.getItem_material11()); - jo.put("qty11",paperTubeConveyor2DeviceDriver.getItem_qty11()); - jo.put("material12",paperTubeConveyor2DeviceDriver.getItem_material12()); - jo.put("qty12",paperTubeConveyor2DeviceDriver.getItem_qty12()); - - } else if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - SiemensConveyorDeviceDriver driver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - } else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) { - SiemensConveyorCkkDeviceDriver driver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - } else if (device.getDeviceDriver() instanceof SiemensConveyorLabelingDeviceDriver) { - SiemensConveyorLabelingDeviceDriver driver = (SiemensConveyorLabelingDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - } else if (device.getDeviceDriver() instanceof SiemensOneFloorAGVConveyorDeviceDriver) { - SiemensOneFloorAGVConveyorDeviceDriver driver = (SiemensOneFloorAGVConveyorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - } else if (device.getDeviceDriver() instanceof IndoorManipulatorDeviceDriver) { - IndoorManipulatorDeviceDriver driver = (IndoorManipulatorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("mode", driver.getMode()); - jo.put("move", driver.getMove()); - jo.put("action", driver.getAction()); - jo.put("walk_y", driver.getWalk_y()); - jo.put("task", driver.getTask()); - jo.put("x_position", driver.getX_position()); - jo.put("y_position", driver.getY_position()); - jo.put("inflatable_shaft_size", driver.getInflatable_shaft_size()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - }else if (device.getDeviceDriver() instanceof PluggingUnpluggingMachineDeviceDriver) { - PluggingUnpluggingMachineDeviceDriver driver = (PluggingUnpluggingMachineDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", driver.getDevice().getDevice_code()); - jo.put("device_name", driver.getDevice().getDevice_name()); - jo.put("status", Math.min(3, driver.getMode())); - jo.put("mode", driver.getMode()); - jo.put("move", driver.getMove()); - jo.put("task1", driver.getTask1()); - jo.put("task2", driver.getTask2()); - jo.put("error", driver.getError()); - jo.put("error_msg", driver.getError() == 0 ? "" : ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(driver.getError()))); - } else { - jo.put("device_code", parent_device_code); - } - backja.add(jo); - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - resultJson.put("data", backja); -// log.info("queryDevice--------------:输出参数" + resultJson.toString()); - return resultJson; - - } finally { - MDC.remove(log_file_type); - } - - - } - - - @Override - public Map queryDeviceDBValue(String whereJson) { - JSONArray datas = JSONArray.parseArray(whereJson); - log.info("orderStatusUpdate--------------:输入参数" + datas.toString()); - JSONObject map = new JSONObject(); - if (datas.size() > 0) { - for (int i = 0; i < datas.size(); i++) { - JSONObject jsonObject = datas.getJSONObject(i); - String device_code = jsonObject.getString("device_code"); - String dbName = jsonObject.getString("DB"); - Device device = deviceAppService.findDeviceByCode(device_code); - List extra = device.getExtra(); - for (int j = 0; j < extra.size(); j++) { - DeviceExtraManageDto deviceExtraManageDto = extra.get(j); - String deviceCode = deviceExtraManageDto.getDevice_code(); - String extra_name = deviceExtraManageDto.getExtra_name(); - if (deviceCode.equals(device_code) && extra_name.equals(dbName)) { - String extra_code = deviceExtraManageDto.getExtra_code(); - String[] split = extra_code.split("\\."); - extra_code = split[split.length - 1]; - extra_code = extra_code.substring(0, 1).toUpperCase() + extra_code.substring(1); - IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class); - Integer dbValue = driverService.getDbValue(device, extra_code); - map.put(dbName, dbValue); - break; - } - } - } - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", map); - return resultJson; - } - - @Override - public Map querydevice(String whereJson) { - return null; - } - - - @Override - public Map putPlusPullAction(String param) { - try { - MDC.put(log_file_type, log_type); - log.info("putPlusPullAction-----输入参数{}", param); - JSONObject jo = JSON.parseObject(param); - String device_code = jo.getString("device_code"); - String size = jo.getString("size"); - String type = jo.getString("type"); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "未找到对应的设备:" + device_code); - return resultJson; - } - PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver; - if (device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { - plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) device.getDeviceDriver(); - // 0 穿轴 1拔轴 - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - - if (plugPullDeviceSiteDeviceDriver.getMode() == 1) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求拔轴,当前设备工作模式未自动"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getAction() == 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求拔轴,当前设备未全自动"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getStatus() != 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求拔轴,当前设备未待机"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getControl() != 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求拔轴,当前设备未远程控制"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getMove() != 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求拔轴,当前设备有轴"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getMode() == 0 && plugPullDeviceSiteDeviceDriver.getAction() == 1 - && plugPullDeviceSiteDeviceDriver.getStatus() == 0 && plugPullDeviceSiteDeviceDriver.getMove() == 0 - && plugPullDeviceSiteDeviceDriver.getControl() == 0) { - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_size"); - map.put("value", size); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_type"); - map2.put("value", type); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", CommonFinalParam.ONE); - list.add(map3); - plugPullDeviceSiteDeviceDriver.writing(list); - - } else { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "当前设备状态不满足下发条件"); - return resultJson; - } - - } else if (StrUtil.equals(type, "0")) { - - if (plugPullDeviceSiteDeviceDriver.getMode() == 1) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求插轴,当前设备工作模式未自动"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getAction() == 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求插轴,当前设备未全自动"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getStatus() != 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求插轴,当前设备未待机"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getControl() != 0) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求插轴,当前设备未远程控制"); - return resultJson; - } - if (plugPullDeviceSiteDeviceDriver.getMove() != 1) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "请求插轴,当前设备没有轴"); - return resultJson; - } - - if (plugPullDeviceSiteDeviceDriver.getMode() == 0 && plugPullDeviceSiteDeviceDriver.getAction() == 1 - && plugPullDeviceSiteDeviceDriver.getStatus() == 0 && plugPullDeviceSiteDeviceDriver.getMove() == 1 - && plugPullDeviceSiteDeviceDriver.getControl() == 0) { - - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_size"); - map.put("value", size); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_type"); - map2.put("value", type); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", CommonFinalParam.ONE); - list.add(map3); - plugPullDeviceSiteDeviceDriver.writing(list); - - } else { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "当前设备状态不满足下发条件"); - return resultJson; - } - } - } - - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - log.info("putPlusPullAction--------------:输出参数" + resultJson.toString()); - return resultJson; - - } finally { - MDC.remove(log_file_type); - } - } - - - @Override - public CreateTaskResponse crateTask(String param) { - try { - MDC.put(log_file_type, log_type); - log.info("crateTask-----输入参数{}", param); - JSONArray datas = JSONArray.parseArray(param); - CreateTaskResponse response = new CreateTaskResponse(); - ParamService paramService = SpringContextHolder.getBean(ParamService.class); - String cancelTaskCheck = paramService.findByCode(AcsConfig.ISALLOWTASK).getValue(); - JSONArray errArr = new JSONArray(); - if (StrUtil.equals(cancelTaskCheck, "0")) { - response.setStatus(400); - response.setMessage("ACS系统需要更新,请稍等"); - response.setErrArr(datas); - return response; - } - for (int i = 0; i < datas.size(); i++) { - String data = datas.get(i).toString(); - CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); - String paper_array = request.getPaper_array(); - String ext_task_id = request.getExt_task_id(); - String task_code = request.getTask_code(); - String start_device_code = request.getStart_device_code(); - String start_device_code2 = request.getStart_device_code2(); - String next_device_code = request.getNext_device_code(); - String next_device_code2 = request.getNext_device_code2(); - String put_device_code = request.getPut_device_code(); - String priority = request.getPriority(); - String vehicle_code = request.getVehicle_code(); - String vehicle_type = request.getVehicle_type(); - String route_plan_code = request.getRoute_plan_code(); - String task_type = request.getTask_type(); - String truss_type = request.getTruss_type(); - String is_bushing = request.getIs_bushing(); - String version = request.getVersion(); - String bushing_num = request.getBushing_num(); - String storage_task_type = request.getDtl_type(); - String agv_system_type = request.getAgv_system_type(); - String remark = request.getRemark(); - double oven_time = 0.00d; - if (StrUtil.isNotEmpty(request.getOven_time())) { - oven_time = Double.parseDouble(request.getOven_time()); - } - String temperature = request.getTemperature(); - String start_height = request.getStart_height(); - String next_height = request.getNext_height(); - Map params = request.getParams(); - - String start_point_code = ""; - String start_point_code2 = ""; - String next_point_code = ""; - String next_point_code2 = ""; - String put_point_code = ""; - if (StrUtil.isEmpty(task_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "任务号不能为空"); - errArr.add(json); - continue; - } - if (StrUtil.isEmpty(start_device_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "起点不能为空"); - errArr.add(json); - continue; - } - if (StrUtil.isEmpty(next_device_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "终点不能为空"); - errArr.add(json); - continue; - } - - if (StrUtil.equals(task_type, "8")) { - next_device_code = request.getPut_device_code(); - put_device_code = request.getNext_device_code(); - } - - JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json)) { - start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); - } - JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json)) { - next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code"); - } - JSONObject start_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json2)) { - start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code"); - } - JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code2 + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json2)) { - next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code"); - } - JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(put_device_json)) { - 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) { - String[] str = start_point_code.split("-"); - start_device_code = str[0]; - } else { - start_device_code = start_point_code; - } - - if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) { - String[] str = next_point_code.split("-"); - next_device_code = str[0]; - } else { - next_device_code = next_point_code; - } - - if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) { - String[] str = start_point_code2.split("-"); - start_device_code2 = str[0]; - } else { - start_device_code2 = start_point_code2; - } - - if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) { - String[] str = next_point_code2.split("-"); - next_device_code2 = str[0]; - } else { - next_device_code2 = next_point_code2; - } - - if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { - String[] str = put_point_code.split("-"); - put_device_code = str[0]; - } else { - put_device_code = put_point_code; - } - - if (StrUtil.isEmpty(route_plan_code)) { - route_plan_code = "normal"; - } - - if (StrUtil.equals(task_type, "5")) { - Device device = deviceAppService.findDeviceByCode(next_device_code); - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); - if (ObjectUtil.equal("true", siemensConveyorDeviceDriver.getExtraValue().get("inspect_in_stock"))) { - if (siemensConveyorDeviceDriver.getMove() == 1) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "终点" + siemensConveyorDeviceDriver.getDevice_code() + "有货无法生成任务"); - errArr.add(json); - continue; - } - } - } - - if (taskService.querySameDeviceReadyTask(start_device_code, next_device_code, "0") > 1) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "已存在相同的起点:" + start_device_code + "终点:" + next_device_code + "未执行的输送任务"); - errArr.add(json); - continue; - } - } - - TaskDto taskDto = taskService.findByCodeFromCache(task_code); - if (taskDto != null) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "存在相同的任务号:" + task_code); - errArr.add(json); - continue; - } - if (!StrUtil.isEmpty(vehicle_code)) { - TaskDto vehicle_dto = taskService.findByContainer(vehicle_code); - if (vehicle_dto != null) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code); - errArr.add(json); - continue; - } - } - - if (StrUtil.isEmpty(start_point_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位"); - errArr.add(json); - continue; - } - if (StrUtil.isEmpty(next_point_code)) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位"); - errArr.add(json); - continue; - } - - JSONObject jo = new JSONObject(); - jo.put("task_id", IdUtil.simpleUUID()); - jo.put("task_code", task_code); - jo.put("start_point_code", start_point_code); - jo.put("next_point_code", next_point_code); - jo.put("start_point_code2", start_point_code2); - jo.put("next_point_code2", next_point_code2); - jo.put("put_point_code", put_point_code); - jo.put("start_parent_code", start_point_code); - jo.put("next_parent_code", next_point_code); - jo.put("start_device_code", start_device_code); - jo.put("next_device_code", next_device_code); - jo.put("start_device_code2", start_device_code2); - jo.put("next_device_code2", next_device_code2); - jo.put("put_device_code", put_device_code); - jo.put("priority", priority); - jo.put("vehicle_code", vehicle_code); - jo.put("vehicle_type", vehicle_type); - jo.put("storage_task_type", storage_task_type); - jo.put("agv_system_type", agv_system_type); - jo.put("start_height", start_height); - jo.put("next_height", next_height); - jo.put("oven_time", (int) Math.ceil(oven_time)); - jo.put("remark", remark); - jo.put("params", params); - jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); - jo.put("paper_array", JSONUtil.toJsonStr(paper_array)); - jo.put("truss_type", JSONUtil.toJsonStr(truss_type)); - jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing)); - jo.put("version", JSONUtil.toJsonStr(version)); - jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num)); - - - if (!StrUtil.isEmpty(ext_task_id)) { - jo.put("ext_task_id", ext_task_id); - } - - TaskDto task_dto = jo.toJavaObject(TaskDto.class); - try { - // task_type=7 则是立库任务需要下刻下发 - if (StrUtil.equals(task_dto.getTask_type(), "7")) { - //创建临时指令 不创建、不生成 - //等立库反馈成功才能创建任务和指令 - Instruction inst = null; - try { - inst = taskService.createTemporaryInst(task_dto); - } catch (Exception e) { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", "起始点:"+ task_dto.getStart_point_code() + ",终点:"+ - task_dto.getNext_point_code()+",条码:" + task_dto.getVehicle_code() + - "," + e.getMessage()); - errArr.add(json); - continue; - } - Resp resp = acsToLiKuService.sendInst(task_dto.getStorage_task_type(), inst); - - if (StrUtil.equals(resp.result, "true")) { - //创建任务和指令 - taskService.create(task_dto); - inst.setSend_status(CommonFinalParam.ONE); - taskService.extCreateInst(inst); - - } else { - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", resp.getComment()); - json.put("code", resp.code); - json.put("data", data); - errArr.add(json); - continue; - } - - } else { - taskService.create(task_dto); - } - } catch (Exception e) { -// e.printStackTrace(); - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("ext_task_id", ext_task_id); - json.put("message", e.getMessage()); - errArr.add(json); - continue; - } - } - if (ObjectUtil.isEmpty(errArr)) { - response.setStatus(200); - response.setMessage("success"); - } else { - response.setStatus(400); - if (ObjectUtil.isNotEmpty(errArr)) { - response.setMessage(errArr.getJSONObject(0).getString("message")); - } else { - response.setMessage("false"); - } - response.setErrArr(errArr); - } - log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response)); - - return response; - } finally { - MDC.remove(log_file_type); - } - - } - - @Override - public Map unLock(String param) { - try { - MDC.put(log_file_type, log_type); - log.info("unLock--------------:输入参数" + param); - JSONObject jo = JSONObject.parseObject(param); - String task_code = String.valueOf(jo.get("task_code")); - if (StrUtil.isEmpty(task_code)) { - throw new BadRequestException("任务号不能为空"); - } - String device_code = String.valueOf(jo.get("device_code")); - if (StrUtil.isEmpty(device_code)) { - throw new BadRequestException("设备号不能为空"); - } - String vehicle_code = String.valueOf(jo.get("vehicle_code")); - if (StrUtil.isEmpty(vehicle_code)) { - throw new BadRequestException("载具号不能为空"); - } - OutConfirmRequest outConfirmRequest = new OutConfirmRequest(); - outConfirmRequest.setOutPortNo(device_code); - outConfirmRequest.setPalletCode(vehicle_code); - Instruction instruction = instructionService.findByCode(String.valueOf(task_code)); - if (ObjectUtil.isNotEmpty(instruction)) { - task_code = instruction.getInstruction_code(); - outConfirmRequest.setOrderId(task_code); - } - Resp resp = acsToLiKuService.outConfirm(outConfirmRequest); - if (StrUtil.equals(resp.getResult(), "false")) { - JSONObject resultJson = new JSONObject(); - resultJson.put("status", 400); - resultJson.put("message", resp.getComment()); - log.info("unLock--------------:输出参数" + resultJson); - return resultJson; - } - } catch (Exception e) { - e.printStackTrace(); - JSONObject resultJson = new JSONObject(); - resultJson.put("status", 400); - resultJson.put("message", e.getMessage()); - log.info("unLock--------------:输出参数" + resultJson); - return resultJson; - } finally { - MDC.remove(log_file_type); - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - log.info("unLock--------------:输出参数" + resultJson); - return resultJson; - } - - - @Override - public Map updateTask(String whereJson) { - JSONArray datas = JSONArray.parseArray(whereJson); - log.info("updateTask--------------:输入参数" + datas.toString()); - JSONArray errArr = new JSONArray(); - if (datas.size() > 0) { - for (int i = 0; i < datas.size(); i++) { - JSONObject jsonObject = datas.getJSONObject(i); - String device_code = jsonObject.getString("device_code"); - String task_code = jsonObject.getString("task_code"); - //1-允许取放; 2-允许离开 - String option = jsonObject.getString("option"); - Instruction inst = instructionService.findByTaskcode(task_code); - if (ObjectUtil.isEmpty(inst)) { - JSONObject jo = new JSONObject(); - jo.put("task_code", task_code); - jo.put("message", "未找到对应任务"); - errArr.add(jo); - continue; - } else { - String carNo = inst.getCarno(); - if (ObjectUtil.isEmpty(carNo)) { - JSONObject jo = new JSONObject(); - jo.put("task_code", task_code); - jo.put("message", "未找到任务对应车号"); - errArr.add(jo); - continue; - } else { - Device device = deviceAppService.findDeviceByCode(carNo); - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - if (device.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) device.getDeviceDriver(); - int phase = agvNdcTwoDeviceDriver.getPhase(); - if (phase == 0x03 || phase == 0x05 || phase == 0x08) { - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - Device device_k = deviceAppService.findDeviceByCode(device_code + "_K"); - Device device_m = deviceAppService.findDeviceByCode(device_code + "_M"); - if (device_k.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_k.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); - standardOrdinarySiteDeviceDriver.setTask_code(task_code); - } - if (device_m.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device_m.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); - standardOrdinarySiteDeviceDriver.setTask_code(task_code); - } - } else { - JSONObject jo = new JSONObject(); - jo.put("task_code", task_code); - jo.put("message", "AGV未就绪无法设置"); - errArr.add(jo); - continue; - } - } - } - - } - } - } - JSONObject resultJson = new JSONObject(); - if (ObjectUtil.isEmpty(errArr)) { - resultJson.put("status", HttpStatus.OK.value()); - resultJson.put("message", "操作成功"); - } else { - resultJson.put("status", HttpStatus.BAD_REQUEST.value()); - resultJson.put("message", "操作失败"); - if (ObjectUtil.isNotEmpty(errArr)) { - resultJson.put("errArr", errArr); - } - } - return resultJson; - } - - @Override - public Map sendAgvChargeTask(JSONObject param) { - log.info("sendAgvChargeTask--------------:输入参数" + param.toString()); - String agv_system = param.getString("agv_system"); - String car_no = param.getString("car_no"); - if (StrUtil.isEmpty(agv_system)) { - throw new BadRequestException("AGV系统类型不能为空"); - } - if (StrUtil.isEmpty(car_no)) { - throw new BadRequestException("AGV车号不能为空"); - } - Device device = deviceAppService.findDeviceByCode(car_no); - if (device == null) { - throw new BadRequestException("agv车号在ACS系统中不存在!"); - } - NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class); - agvService.createChargingTaskToNDC(agv_system, car_no); - JSONObject resp = new JSONObject(); - resp.put("status", 200); - resp.put("message", "操作成功"); - return resp; - } - - @Override - public Map queryDeviceInfo(JSONObject param) { - log.info("queryDeviceInfo--------------:输入参数" + param.toString()); - String region_code = param.getString("region_code"); -// if (StrUtil.isEmpty(region_code)) { -// throw new BadRequestException("区域编码不能为空"); -// } - AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; - AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; - List devices = deviceAppService.findDevice(DeviceType.agv); - JSONArray data = new JSONArray(); - if (StrUtil.isEmpty(region_code)) { - if (ObjectUtil.isNotEmpty(devices)) { - for (int i = 0; i < devices.size(); i++) { - Device device = devices.get(i); - Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); - if (agvDevice.getDeviceDriver() instanceof DeviceStageMonitor) { - DeviceStageMonitor deviceStageMonitor = (DeviceStageMonitor) agvDevice.getDeviceDriver(); - try { - JSONObject jo = deviceStageMonitor.getDeviceStatusName(); - data.add(jo); - } catch (Exception e) { - log.error("反馈AGV信息失败:{}", e.getMessage()); - } - } - } - } - } else { - if (ObjectUtil.isNotEmpty(devices)) { - for (int i = 0; i < devices.size(); i++) { - Device device = devices.get(i); - Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); - if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { - if (StrUtil.equals(region_code, CommonFinalParam.ONE)) { - agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver(); - JSONObject jo = agvNdcTwoDeviceDriver.getDeviceStatusName(); - data.add(jo); - } - } - if (agvDevice.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { - if (StrUtil.equals(region_code, "5")) { - agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) agvDevice.getDeviceDriver(); - JSONObject jo = agvNdcOneDeviceDriver.getDeviceStatusName(); - data.add(jo); - } - } - } - } - } - JSONObject resp = new JSONObject(); - resp.put("status", 200); - resp.put("message", "操作成功"); - resp.put("data", data); - return resp; - } - - @Override - public Map syncfaultInfo() { - log.info("syncfaultInfo--------------:输入参数"); - JSONArray data = new JSONArray(); - List dicts = dictService.queryAll(); - if (ObjectUtil.isNotEmpty(dicts)) { - List error_dists = dicts - .stream() - .filter(dict -> dict.getName().contains("error_type")) - .collect(Collectors.toList()); - if (ObjectUtil.isNotEmpty(error_dists)) { - for (int i = 0; i < error_dists.size(); i++) { - Dict dict = error_dists.get(i); - String dictName = dict.getName(); - List dictDetailDtos = dictDetailService.getDictByName(dictName); - for (DictDetailDto dictDetailDto : dictDetailDtos) { - JSONObject faultInfo = new JSONObject(); - faultInfo.put("fault_type", dictName); - faultInfo.put("fault_code", dictDetailDto.getValue()); - faultInfo.put("fault_info", dictDetailDto.getLabel()); - data.add(faultInfo); - } - } - } - } - JSONObject resp = new JSONObject(); - resp.put("status", 200); - resp.put("message", "操作成功"); - resp.put("data", data); - return resp; - } - - @Override - public Map realTimefaultInfo(JSONObject param) { - log.info("realTimefaultInfo--------------:输入参数" + param.toString()); - String device_code = param.getString("device_code"); - JSONArray data = new JSONArray(); - if (StrUtil.isNotEmpty(device_code)) { - String[] devices = device_code.split(","); - Device device = null; - for (String deviceCode : devices) { - device = deviceAppService.findDeviceByCode(deviceCode); - if (device == null) { - continue; - } - if (device.getDeviceDriver() instanceof FeedLmsRealFailed) { - FeedLmsRealFailed feedLmsRealFailed = (FeedLmsRealFailed) device.getDeviceDriver(); - JSONObject jsonObject = feedLmsRealFailed.feedLmsRealFailedInfo(); - data.add(jsonObject); - } - } - } - JSONObject resp = new JSONObject(); - resp.put("status", 200); - resp.put("message", "操作成功"); - resp.put("data", data); - return resp; - } - - - @Override - public Map paperTubeAction(JSONObject param) { - log.info("paperTubeAction--------------:输入参数" + param.toString()); - JSONObject resp = new JSONObject(); - String device_code = param.getString("device_code"); - String type = param.getString("type"); - String material_code = param.getString("material_code"); - String qty = param.getString("qty"); - - if (StrUtil.isNotEmpty(device_code)) { - - Device device = deviceAppService.findDeviceByCode(device_code); - if (device == null) { - resp.put("status", 400); - resp.put("message", "未找到对应设备"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { - PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); - if (paperTubeConveyorDeviceDriver.getMode() != 2) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "未待机,无法下发信号"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - if (StrUtil.equals(type, CommonFinalParam.ONE)) { - if (paperTubeConveyorDeviceDriver.getInventory_qty() > 0) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "无法设置物料"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - try{ - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_material"); - map.put("value", material_code); - list.add(map); - paperTubeConveyorDeviceDriver.writing(list); - - } catch (Exception e){ - e.printStackTrace(); - } - } else if (StrUtil.equals(type, "2")) { - if (paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "小于出库数量" + qty); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - if (StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "设备上报物料为空无法出库"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } else { - if (!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(), material_code)) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "设备上报物料为" + paperTubeConveyorDeviceDriver.getMaterial() + "与出库物料" + material_code + "不匹配"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - } - if (paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0) { - resp.put("status", 400); - resp.put("message", "设备:" + device_code + "下发命令信号值为" + paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() + ",已存在待执行的任务"); - log.info("paperTubeAction--------------:输出参数" + resp.toString()); - return resp; - } - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_out_qty"); - map.put("value", qty); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_target"); - map2.put("value", device.getAddress()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_command"); - map3.put("value", 2); - list.add(map3); - try{ -// paperTubeConveyorDeviceDriver.writing("to_out_qty", qty); -// paperTubeConveyorDeviceDriver.writing("to_target", device.getAddress()); -// paperTubeConveyorDeviceDriver.writing("to_command", "2"); - paperTubeConveyorDeviceDriver.writing(list); - } catch (Exception e){ - e.printStackTrace(); - } - - } else if(StrUtil.equals(type, "3")){ - List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 3); - list.add(map); - paperTubeConveyorDeviceDriver.writing(list); - } - } - - } - resp.put("status", 200); - resp.put("message", "操作成功"); - return resp; - } - **/ + private final ApplicationContext applicationContext; + + private final InstructionService instructionService; + private final TaskService taskService; + private final DeviceService deviceService; + private final DeviceAppService deviceAppService; + private final RouteLineService routeLineService; + private final AcsToLiKuService acsToLiKuService; + private final DictDetailService dictDetailService; + private final DictService dictService; + + + private String log_file_type = "log_file_type"; + private String log_type = "LMS请求ACS"; + + @Override public CancelTaskResponse cancelFromWms(String param) throws Exception { + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + JSONArray datas = JSONArray.parseArray(param); + CancelTaskResponse response = new CancelTaskResponse(); + JSONArray errArr = new JSONArray(); + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + CancelTaskRequest request = JsonUtl.format(param, CancelTaskRequest.class); + + String task_uuid = request.getExt_task_id(); + String task_code = request.getTask_code(); + String vehicle_code = request.getVehicle_code(); + + if (StrUtil.isEmpty(task_uuid)) { + throw new WDKException("任务标识不能为空"); + } + if (StrUtil.isEmpty(task_code)) { + throw new WDKException("任务号不能为空"); + } + String cancelTaskCheck = paramService.findByCode(AcsConfig.CANCELTASKCHECK).getValue(); + if (StrUtil.equals(cancelTaskCheck, CommonFinalParam.ONE)) { + taskService.cancel(task_uuid); + } else if (StrUtil.equals(cancelTaskCheck, "0")) { + Instruction inst = instructionService.findByTaskcode(task_code); + if (inst == null) { + taskService.cancel(task_uuid); + } else { + throw new RuntimeException("指令正在执行中,操作失败!"); + } + } + + } + + if (ObjectUtil.isEmpty(errArr)) { + response.setStatus(200); + } else { + response.setStatus(400); + } + response.setMessage("success"); + response.setErrArr(errArr); + log.info("cancelFromWms--------------:输出参数:" + response); + + return response; + } + + @Override public Map updateDeviceGoodsFromWms(String param) { + JSONArray datas = JSONArray.parseArray(param); + log.info("updateDeviceGoodsFromWms--------------:输入参数" + datas.toString()); + for (int i = 0; i < datas.size(); i++) { + JSONObject data = datas.getJSONObject(i); + String device_code = data.getString("point_code"); + String has_goods = data.getString("has_goods"); + + JSONObject jo = new JSONObject(); + jo.put("device_code", device_code); + jo.put("hasGoodStatus", has_goods); + deviceService.changeDeviceStatus(jo); + + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK); + resultJson.put("message", "操作成功"); + resultJson.put("data", new JSONObject()); + log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); + return resultJson; + } + + @Override public Map areaControl(JSONObject form) { + String device_code = form.getString("device_code"); + String type = form.getString("type"); + + Device device = deviceAppService.findDeviceByCode(device_code); + + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK); + resultJson.put("message", "操作成功"); + resultJson.put("data", new JSONObject()); + log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); + return resultJson; + } + + @Override public PutActionResponse putAction(String jsonObject) throws Exception { + try { + MDC.put(log_file_type, log_type); + log.info("putAction--------------:输出参数" + jsonObject); + JSONArray datas = JSONArray.parseArray(jsonObject); + PutActionResponse response = new PutActionResponse(); + JSONArray errArr = new JSONArray(); + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + PutActionRequest request = JsonUtl.format(data, PutActionRequest.class); + String device_code = request.getDevice_code(); + String code = request.getCode(); + String value = request.getValue(); + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + throw new Exception("未找到对应设备:" + device_code); + } + HongXiangStationDeviceDriver hongXiangStationDeviceDriver; + LampThreecolorDeviceDriver lampThreecolorDeviceDriver; + if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) { + hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver(); + hongXiangStationDeviceDriver.writing(code, value); + } + if (device.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { + lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) device.getDeviceDriver(); + lampThreecolorDeviceDriver.writing(code, value); + } + + + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + resultJson.put("data", backja); + // log.info("queryDevice--------------:输出参数" + resultJson.toString()); + return resultJson; + + } finally { + MDC.remove(log_file_type); + } + + + } + + + @Override public Map queryDeviceDBValue(String whereJson) { + JSONArray datas = JSONArray.parseArray(whereJson); + log.info("orderStatusUpdate--------------:输入参数" + datas.toString()); + JSONObject map = new JSONObject(); + if (datas.size() > 0) { + for (int i = 0; i < datas.size(); i++) { + JSONObject jsonObject = datas.getJSONObject(i); + String device_code = jsonObject.getString("device_code"); + String dbName = jsonObject.getString("DB"); + Device device = deviceAppService.findDeviceByCode(device_code); + List extra = device.getExtra(); + for (int j = 0; j < extra.size(); j++) { + DeviceExtraManageDto deviceExtraManageDto = extra.get(j); + String deviceCode = deviceExtraManageDto.getDevice_code(); + String extra_name = deviceExtraManageDto.getExtra_name(); + if (deviceCode.equals(device_code) && extra_name.equals(dbName)) { + String extra_code = deviceExtraManageDto.getExtra_code(); + String[] split = extra_code.split("\\."); + extra_code = split[split.length - 1]; + extra_code = extra_code.substring(0, 1).toUpperCase() + extra_code.substring(1); + IDriverService driverService = applicationContext.getBean(device.getDeviceDriverDefination().getDriverCode(), IDriverService.class); + Integer dbValue = driverService.getDbValue(device, extra_code); + map.put(dbName, dbValue); + break; + } + } + } + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK); + resultJson.put("message", "操作成功"); + resultJson.put("data", map); + return resultJson; + } + + @Override public Map querydevice(String whereJson) { + return null; + } + + + @Override public Map putPlusPullAction(String param) { + try { + MDC.put(log_file_type, log_type); + log.info("putPlusPullAction-----输入参数{}", param); + JSONObject jo = JSON.parseObject(param); + String device_code = jo.getString("device_code"); + String size = jo.getString("size"); + String type = jo.getString("type"); + Device device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device)) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "未找到对应的设备:" + device_code); + return resultJson; + } + PlugPullDeviceSiteDeviceDriver plugPullDeviceSiteDeviceDriver; + if (device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { + plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) device.getDeviceDriver(); + // 0 穿轴 1拔轴 + if (StrUtil.equals(type, CommonFinalParam.ONE)) { + + if (plugPullDeviceSiteDeviceDriver.getMode() == 1) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求拔轴,当前设备工作模式未自动"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getAction() == 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求拔轴,当前设备未全自动"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getStatus() != 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求拔轴,当前设备未待机"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getControl() != 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求拔轴,当前设备未远程控制"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getMove() != 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求拔轴,当前设备有轴"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getMode() == 0 && plugPullDeviceSiteDeviceDriver.getAction() == 1 + && plugPullDeviceSiteDeviceDriver.getStatus() == 0 && plugPullDeviceSiteDeviceDriver.getMove() == 0 + && plugPullDeviceSiteDeviceDriver.getControl() == 0) { + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_size"); + map.put("value", size); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_type"); + map2.put("value", type); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + plugPullDeviceSiteDeviceDriver.writing(list); + + } else { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "当前设备状态不满足下发条件"); + return resultJson; + } + + } else if (StrUtil.equals(type, "0")) { + + if (plugPullDeviceSiteDeviceDriver.getMode() == 1) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求插轴,当前设备工作模式未自动"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getAction() == 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求插轴,当前设备未全自动"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getStatus() != 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求插轴,当前设备未待机"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getControl() != 0) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求插轴,当前设备未远程控制"); + return resultJson; + } + if (plugPullDeviceSiteDeviceDriver.getMove() != 1) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "请求插轴,当前设备没有轴"); + return resultJson; + } + + if (plugPullDeviceSiteDeviceDriver.getMode() == 0 && plugPullDeviceSiteDeviceDriver.getAction() == 1 + && plugPullDeviceSiteDeviceDriver.getStatus() == 0 && plugPullDeviceSiteDeviceDriver.getMove() == 1 + && plugPullDeviceSiteDeviceDriver.getControl() == 0) { + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_size"); + map.put("value", size); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_type"); + map2.put("value", type); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", CommonFinalParam.ONE); + list.add(map3); + plugPullDeviceSiteDeviceDriver.writing(list); + + } else { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.BAD_REQUEST.value()); + resultJson.put("message", "当前设备状态不满足下发条件"); + return resultJson; + } + } + } + + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + log.info("putPlusPullAction--------------:输出参数" + resultJson.toString()); + return resultJson; + + } finally { + MDC.remove(log_file_type); + } + } + + + @Override public CreateTaskResponse crateTask(String param) { + try { + MDC.put(log_file_type, log_type); + log.info("crateTask-----输入参数{}", param); + JSONArray datas = JSONArray.parseArray(param); + CreateTaskResponse response = new CreateTaskResponse(); + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + String cancelTaskCheck = paramService.findByCode(AcsConfig.ISALLOWTASK).getValue(); + JSONArray errArr = new JSONArray(); + if (StrUtil.equals(cancelTaskCheck, "0")) { + response.setStatus(400); + response.setMessage("ACS系统需要更新,请稍等"); + response.setErrArr(datas); + return response; + } + for (int i = 0; i < datas.size(); i++) { + String data = datas.get(i).toString(); + CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); + String paper_array = request.getPaper_array(); + String ext_task_id = request.getExt_task_id(); + String task_code = request.getTask_code(); + String start_device_code = request.getStart_device_code(); + String start_device_code2 = request.getStart_device_code2(); + String next_device_code = request.getNext_device_code(); + String next_device_code2 = request.getNext_device_code2(); + String put_device_code = request.getPut_device_code(); + String priority = request.getPriority(); + String vehicle_code = request.getVehicle_code(); + String vehicle_type = request.getVehicle_type(); + String route_plan_code = request.getRoute_plan_code(); + String task_type = request.getTask_type(); + String truss_type = request.getTruss_type(); + String is_bushing = request.getIs_bushing(); + String version = request.getVersion(); + String bushing_num = request.getBushing_num(); + String storage_task_type = request.getDtl_type(); + String agv_system_type = request.getAgv_system_type(); + String remark = request.getRemark(); + double oven_time = 0.00d; + if (StrUtil.isNotEmpty(request.getOven_time())) { + oven_time = Double.parseDouble(request.getOven_time()); + } + String temperature = request.getTemperature(); + String start_height = request.getStart_height(); + String next_height = request.getNext_height(); + Map params = request.getParams(); + + String start_point_code = ""; + String start_point_code2 = ""; + String next_point_code = ""; + String next_point_code2 = ""; + String put_point_code = ""; + if (StrUtil.isEmpty(task_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "任务号不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(start_device_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "起点不能为空"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(next_device_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "终点不能为空"); + errArr.add(json); + continue; + } + + if (StrUtil.equals(task_type, "8")) { + next_device_code = request.getPut_device_code(); + put_device_code = request.getNext_device_code(); + } + + JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(start_device_json)) { + start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_device_code : (String) start_device_json.get("storage_code"); + } + JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(next_device_json)) { + next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code"); + } + JSONObject start_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_device_code2 + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(start_device_json2)) { + start_point_code2 = (String) start_device_json2.get("parent_storage_code") == null ? start_device_code2 : (String) start_device_json2.get("storage_code"); + } + JSONObject next_device_json2 = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_device_code2 + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(next_device_json2)) { + next_point_code2 = (String) next_device_json2.get("parent_storage_code") == null ? next_device_code2 : (String) next_device_json2.get("storage_code"); + } + JSONObject put_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + put_device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(put_device_json)) { + 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) { + String str[] = start_point_code.split("-"); + start_device_code = str[0]; + } else { + start_device_code = start_point_code; + } + + if (StrUtil.isNotEmpty(next_point_code) && next_point_code.indexOf("-") > 0) { + String str[] = next_point_code.split("-"); + next_device_code = str[0]; + } else { + next_device_code = next_point_code; + } + + if (StrUtil.isNotEmpty(start_point_code2) && start_point_code2.indexOf("-") > 0) { + String str[] = start_point_code2.split("-"); + start_device_code2 = str[0]; + } else { + start_device_code2 = start_point_code2; + } + + if (StrUtil.isNotEmpty(next_point_code2) && next_point_code2.indexOf("-") > 0) { + String str[] = next_point_code2.split("-"); + next_device_code2 = str[0]; + } else { + next_device_code2 = next_point_code2; + } + + if (StrUtil.isNotEmpty(put_point_code) && put_point_code.indexOf("-") > 0) { + String str[] = put_point_code.split("-"); + put_device_code = str[0]; + } else { + put_device_code = put_point_code; + } + + if (StrUtil.isEmpty(route_plan_code)) { + route_plan_code = "normal"; + } + + if (StrUtil.equals(task_type, "5")) { + Device device = deviceAppService.findDeviceByCode(next_device_code); + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); + if (ObjectUtil.equal("true", siemensConveyorDeviceDriver.getExtraValue().get("inspect_in_stock"))) { + if (siemensConveyorDeviceDriver.getMove() == 1) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "终点" + siemensConveyorDeviceDriver.getDevice_code() + "有货无法生成任务"); + errArr.add(json); + continue; + } + } + } + + if (taskService.querySameDeviceReadyTask(start_device_code, next_device_code, "0") > 1) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "已存在相同的起点:" + start_device_code + "终点:" + next_device_code + "未执行的输送任务"); + errArr.add(json); + continue; + } + } + + TaskDto taskDto = taskService.findByCodeFromCache(task_code); + if (taskDto != null) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "存在相同的任务号:" + task_code); + errArr.add(json); + continue; + } + if (!StrUtil.isEmpty(vehicle_code)) { + TaskDto vehicle_dto = taskService.findByContainer(vehicle_code); + if (vehicle_dto != null) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "已存在任务编号为" + vehicle_dto.getTask_code() + "托盘号:" + vehicle_code); + errArr.add(json); + continue; + } + } + + if (StrUtil.isEmpty(start_point_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", request.getStart_device_code() + " 该设备号未找到对应点位"); + errArr.add(json); + continue; + } + if (StrUtil.isEmpty(next_point_code)) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", request.getNext_device_code() + " 该设备号未找到对应点位"); + errArr.add(json); + continue; + } + + JSONObject jo = new JSONObject(); + jo.put("task_id", IdUtil.simpleUUID()); + jo.put("task_code", task_code); + jo.put("start_point_code", start_point_code); + jo.put("next_point_code", next_point_code); + jo.put("start_point_code2", start_point_code2); + jo.put("next_point_code2", next_point_code2); + jo.put("put_point_code", put_point_code); + jo.put("start_parent_code", start_point_code); + jo.put("next_parent_code", next_point_code); + jo.put("start_device_code", start_device_code); + jo.put("next_device_code", next_device_code); + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("put_device_code", put_device_code); + jo.put("priority", priority); + jo.put("vehicle_code", vehicle_code); + jo.put("vehicle_type", vehicle_type); + jo.put("storage_task_type", storage_task_type); + jo.put("agv_system_type", agv_system_type); + jo.put("start_height", start_height); + jo.put("next_height", next_height); + jo.put("oven_time", (int) Math.ceil(oven_time)); + jo.put("remark", remark); + jo.put("params", params); + jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); + jo.put("paper_array", JSONUtil.toJsonStr(paper_array)); + jo.put("truss_type", JSONUtil.toJsonStr(truss_type)); + jo.put("is_bushing", JSONUtil.toJsonStr(is_bushing)); + jo.put("version", JSONUtil.toJsonStr(version)); + jo.put("bushing_num", JSONUtil.toJsonStr(bushing_num)); + + + if (!StrUtil.isEmpty(ext_task_id)) { + jo.put("ext_task_id", ext_task_id); + } + + TaskDto task_dto = jo.toJavaObject(TaskDto.class); + try { + // task_type=7 则是立库任务需要下刻下发 + if (StrUtil.equals(task_dto.getTask_type(), "7")) { + //创建临时指令 不创建、不生成 + //等立库反馈成功才能创建任务和指令 + Instruction inst = null; + try { + inst = taskService.createTemporaryInst(task_dto); + } catch (Exception e) { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", "起始点:"+ task_dto.getStart_point_code() + ",终点:"+ + task_dto.getNext_point_code()+",条码:" + task_dto.getVehicle_code() + + "," + e.getMessage()); + errArr.add(json); + continue; + } + Resp resp = acsToLiKuService.sendInst(task_dto.getStorage_task_type(), inst); + + if (StrUtil.equals(resp.result, "true")) { + //创建任务和指令 + taskService.create(task_dto); + inst.setSend_status(CommonFinalParam.ONE); + taskService.extCreateInst(inst); + + } else { + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", resp.getComment()); + json.put("code", resp.code); + json.put("data", data); + errArr.add(json); + continue; + } + + } else { + taskService.create(task_dto); + } + } catch (Exception e) { + // e.printStackTrace(); + JSONObject json = new JSONObject(); + json.put("task_code", task_code); + json.put("ext_task_id", ext_task_id); + json.put("message", e.getMessage()); + errArr.add(json); + continue; + } + } + if (ObjectUtil.isEmpty(errArr)) { + response.setStatus(200); + response.setMessage("success"); + } else { + response.setStatus(400); + if (ObjectUtil.isNotEmpty(errArr)) { + response.setMessage(errArr.getJSONObject(0).getString("message")); + } else { + response.setMessage("false"); + } + response.setErrArr(errArr); + } + log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response)); + + return response; + } finally { + MDC.remove(log_file_type); + } + + } + + @Override public Map unLock(String param) { + try { + MDC.put(log_file_type, log_type); + log.info("unLock--------------:输入参数" + param); + JSONObject jo = JSONObject.parseObject(param); + String task_code = String.valueOf(jo.get("task_code")); + if (StrUtil.isEmpty(task_code)) { + throw new BadRequestException("任务号不能为空"); + } + String device_code = String.valueOf(jo.get("device_code")); + if (StrUtil.isEmpty(device_code)) { + throw new BadRequestException("设备号不能为空"); + } + String vehicle_code = String.valueOf(jo.get("vehicle_code")); + if (StrUtil.isEmpty(vehicle_code)) { + throw new BadRequestException("载具号不能为空"); + } + OutConfirmRequest outConfirmRequest = new OutConfirmRequest(); + outConfirmRequest.setOutPortNo(device_code); + outConfirmRequest.setPalletCode(vehicle_code); + Instruction instruction = instructionService.findByCode(String.valueOf(task_code)); + if (ObjectUtil.isNotEmpty(instruction)) { + task_code = instruction.getInstruction_code(); + outConfirmRequest.setOrderId(task_code); + } + Resp resp = acsToLiKuService.outConfirm(outConfirmRequest); + if (StrUtil.equals(resp.getResult(), "false")) { + JSONObject resultJson = new JSONObject(); + resultJson.put("status", 400); + resultJson.put("message", resp.getComment()); + log.info("unLock--------------:输出参数" + resultJson); + return resultJson; + } + } catch (Exception e) { + e.printStackTrace(); + JSONObject resultJson = new JSONObject(); + resultJson.put("status", 400); + resultJson.put("message", e.getMessage()); + log.info("unLock--------------:输出参数" + resultJson); + return resultJson; + } finally { + MDC.remove(log_file_type); + } + JSONObject resultJson = new JSONObject(); + resultJson.put("status", HttpStatus.OK.value()); + resultJson.put("message", "操作成功"); + log.info("unLock--------------:输出参数" + resultJson); + return resultJson; + } + + // @Override + // public Map sendAgvChargeTask(JSONObject param) { + // log.info("sendAgvChargeTask--------------:输入参数" + param.toString()); + // String agv_system = param.getString("agv_system"); + // String car_no = param.getString("car_no"); + // if (StrUtil.isEmpty(agv_system)) { + // throw new BadRequestException("AGV系统类型不能为空"); + // } + // if (StrUtil.isEmpty(car_no)) { + // throw new BadRequestException("AGV车号不能为空"); + // } + // Device device = deviceAppService.findDeviceByCode(car_no); + // if (device == null) { + // throw new BadRequestException("agv车号在ACS系统中不存在!"); + // } + // NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class); + // agvService.createChargingTaskToNDC(agv_system, car_no); + // JSONObject resp = new JSONObject(); + // resp.put("status", 200); + // resp.put("message", "操作成功"); + // return resp; + // } + // + // @Override + // public Map queryDeviceInfo(JSONObject param) { + // log.info("queryDeviceInfo--------------:输入参数" + param.toString()); + // String region_code = param.getString("region_code"); + //// if (StrUtil.isEmpty(region_code)) { + //// throw new BadRequestException("区域编码不能为空"); + //// } + // AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; + // AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; + // List devices = deviceAppService.findDevice(DeviceType.agv); + // JSONArray data = new JSONArray(); + // if (StrUtil.isEmpty(region_code)) { + // throw new BadRequestException("区域编码不能为空"); + // } + AgvNdcTwoDeviceDriver agvNdcTwoDeviceDriver; + AgvNdcOneDeviceDriver agvNdcOneDeviceDriver; + List devices = deviceAppService.findDevice(DeviceType.agv); + JSONArray data = new JSONArray(); + if (StrUtil.isEmpty(region_code)) { + if (ObjectUtil.isNotEmpty(devices)) { + for (int i = 0; i < devices.size(); i++) { + Device device = devices.get(i); + Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); + if (agvDevice.getDeviceDriver() instanceof DeviceStageMonitor) { + DeviceStageMonitor deviceStageMonitor = (DeviceStageMonitor) agvDevice.getDeviceDriver(); + try { + JSONObject jo = deviceStageMonitor.getDeviceStatusName(); + data.add(jo); + } catch (Exception e) { + log.error("反馈AGV信息失败:{}", e.getMessage()); + } + } + } + } + } else { + if (ObjectUtil.isNotEmpty(devices)) { + for (int i = 0; i < devices.size(); i++) { + Device device = devices.get(i); + Device agvDevice = deviceAppService.findDeviceByCode(device.getDevice_code()); + if (agvDevice.getDeviceDriver() instanceof AgvNdcTwoDeviceDriver) { + if (StrUtil.equals(region_code, "1")) { + agvNdcTwoDeviceDriver = (AgvNdcTwoDeviceDriver) agvDevice.getDeviceDriver(); + JSONObject jo = agvNdcTwoDeviceDriver.getDeviceStatusName(); + data.add(jo); + } + } + if (agvDevice.getDeviceDriver() instanceof AgvNdcOneDeviceDriver) { + if (StrUtil.equals(region_code, "5")) { + agvNdcOneDeviceDriver = (AgvNdcOneDeviceDriver) agvDevice.getDeviceDriver(); + JSONObject jo = agvNdcOneDeviceDriver.getDeviceStatusName(); + data.add(jo); + } + } + } + } + } + JSONObject resp = new JSONObject(); + resp.put("status", 200); + resp.put("message", "操作成功"); + resp.put("data", data); + return resp; + } + + @Override public Map syncfaultInfo() { + log.info("syncfaultInfo--------------:输入参数"); + JSONArray data = new JSONArray(); + List dicts = dictService.queryAll(); + if (ObjectUtil.isNotEmpty(dicts)) { + List error_dists = dicts + .stream() + .filter(dict -> dict.getName().contains("error_type")) + .collect(Collectors.toList()); + if (ObjectUtil.isNotEmpty(error_dists)) { + for (int i = 0; i < error_dists.size(); i++) { + Dict dict = error_dists.get(i); + String dictName = dict.getName(); + List dictDetailDtos = dictDetailService.getDictByName(dictName); + for (DictDetailDto dictDetailDto : dictDetailDtos) { + JSONObject faultInfo = new JSONObject(); + faultInfo.put("fault_type", dictName); + faultInfo.put("fault_code", dictDetailDto.getValue()); + faultInfo.put("fault_info", dictDetailDto.getLabel()); + data.add(faultInfo); + } + } + } + } + JSONObject resp = new JSONObject(); + resp.put("status", 200); + resp.put("message", "操作成功"); + resp.put("data", data); + return resp; + } + + @Override public Map realTimefaultInfo(JSONObject param) { + log.info("realTimefaultInfo--------------:输入参数" + param.toString()); + String device_code = param.getString("device_code"); + JSONArray data = new JSONArray(); + if (StrUtil.isNotEmpty(device_code)) { + String[] devices = device_code.split(","); + Device device = null; + for (String deviceCode : devices) { + device = deviceAppService.findDeviceByCode(deviceCode); + if (device == null) { + continue; + } + if (device.getDeviceDriver() instanceof FeedLmsRealFailed) { + FeedLmsRealFailed feedLmsRealFailed = (FeedLmsRealFailed) device.getDeviceDriver(); + JSONObject jsonObject = feedLmsRealFailed.feedLmsRealFailedInfo(); + data.add(jsonObject); + } + } + } + JSONObject resp = new JSONObject(); + resp.put("status", 200); + resp.put("message", "操作成功"); + resp.put("data", data); + return resp; + } + + + @Override public Map paperTubeAction(JSONObject param) { + log.info("paperTubeAction--------------:输入参数" + param.toString()); + JSONObject resp = new JSONObject(); + String device_code = param.getString("device_code"); + String type = param.getString("type"); + String material_code = param.getString("material_code"); + String qty = param.getString("qty"); + + if (StrUtil.isNotEmpty(device_code)) { + + Device device = deviceAppService.findDeviceByCode(device_code); + if (device == null) { + resp.put("status", 400); + resp.put("message", "未找到对应设备"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if (device.getDeviceDriver() instanceof PaperTubeConveyorDeviceDriver) { + PaperTubeConveyorDeviceDriver paperTubeConveyorDeviceDriver = (PaperTubeConveyorDeviceDriver) device.getDeviceDriver(); + if (paperTubeConveyorDeviceDriver.getMode() != 2) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "未待机,无法下发信号"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if (StrUtil.equals(type, "1")) { + if (paperTubeConveyorDeviceDriver.getInventory_qty() > 0) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "无法设置物料"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + try{ + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_material"); + map.put("value", material_code); + list.add(map); + paperTubeConveyorDeviceDriver.writing(list); + + } catch (Exception e){ + e.printStackTrace(); + } + } else if (StrUtil.equals(type, "2")) { + if (paperTubeConveyorDeviceDriver.getInventory_qty() < Integer.parseInt(qty)) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "当前数量为" + paperTubeConveyorDeviceDriver.getInventory_qty() + "小于出库数量" + qty); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + if (StrUtil.isEmpty(paperTubeConveyorDeviceDriver.getMaterial())) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "设备上报物料为空无法出库"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } else { + if (!StrUtil.equals(paperTubeConveyorDeviceDriver.getMaterial(), material_code)) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "设备上报物料为" + paperTubeConveyorDeviceDriver.getMaterial() + "与出库物料" + material_code + "不匹配"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + } + if (paperTubeConveyorDeviceDriver.getTo_command() != 0 || paperTubeConveyorDeviceDriver.getTo_target() != 0) { + resp.put("status", 400); + resp.put("message", "设备:" + device_code + "下发命令信号值为" + paperTubeConveyorDeviceDriver.getTo_command() + ",下发目标站:" + paperTubeConveyorDeviceDriver.getTo_target() + ",已存在待执行的任务"); + log.info("paperTubeAction--------------:输出参数" + resp.toString()); + return resp; + } + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_out_qty"); + map.put("value", qty); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_target"); + map2.put("value", device.getAddress()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", 2); + list.add(map3); + try{ + // paperTubeConveyorDeviceDriver.writing("to_out_qty", qty); + // paperTubeConveyorDeviceDriver.writing("to_target", device.getAddress()); + // paperTubeConveyorDeviceDriver.writing("to_command", "2"); + paperTubeConveyorDeviceDriver.writing(list); + } catch (Exception e){ + e.printStackTrace(); + } + + } else if(StrUtil.equals(type, "3")){ + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 3); + list.add(map); + paperTubeConveyorDeviceDriver.writing(list); + } + } + + } + resp.put("status", 200); + resp.put("message", "操作成功"); + return resp; + }**/ } diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 7f3a5dd..903780e 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -103,6 +103,7 @@ import led_screen from './driver/led_screen' import standard_station from '@/views/acs/device/driver/standard_station' import double_belt_conveyor from '@/views/acs/device/driver/double_belt_conveyor.vue' import with_station_device from '@/views/acs/device/driver/with_station_device.vue' +import standard_manipulator from '@/views/acs/device/driver/standard_manipulator.vue' export default { name: 'DeviceConfig', components: { @@ -135,7 +136,8 @@ export default { plug_pull_device_site, slit_two_manipulator, double_belt_conveyor, - with_station_device + with_station_device, + standard_manipulator }, dicts: ['device_type'], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/standard_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/standard_manipulator.vue new file mode 100644 index 0000000..89ec131 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/standard_manipulator.vue @@ -0,0 +1,546 @@ + + + + +