diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 03bfc86..281ae20 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -10,7 +10,7 @@ import org.nl.acs.agv.server.AgvService; import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.log.service.DeviceExecuteLogService; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java index 0dc6ee5..6bcf917 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/MagicAgvServiceImpl.java @@ -12,8 +12,8 @@ import org.nl.acs.agv.server.MagicAgvService; import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 73860fa..a53f2e9 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -12,7 +12,7 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index 5e45841..138c649 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -12,17 +12,15 @@ import org.nl.acs.agv.server.XianGongAgvService; import org.nl.acs.agv.server.dto.AgvDto; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceType; -import org.nl.acs.task.service.TaskService; import org.nl.exception.BadRequestException; import org.slf4j.MDC; import org.springframework.stereotype.Service; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 2c10437..c84b7b1 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -41,7 +41,11 @@ public enum DriverTypeEnum { TRAFFIC_LIGHT(34, "traffic_light", "标准版-交通灯-欧姆龙plc", "alarmLamp"), - STANDARD_RGV(35, "standard_rgv", "标准版-RGV", "rgv"); + STANDARD_RGV(35, "standard_rgv", "标准版-RGV", "rgv"), + + MODBUS_AUTODOOR(36, "modbus_autodoor", "modbus-自动门", "autodoor"), + + MODBUS_INSPECT_SITE(37, "modbus_inspect_site", "modbus-检测站点", "station"); //驱动索引 private int index; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 5c7a4fe..7c56df5 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -22,7 +22,7 @@ import org.nl.acs.device_driver.ScannerDeviceDriver; import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; import org.nl.acs.opc.Device; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ItemProtocol.java new file mode 100644 index 0000000..57852ee --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ItemProtocol.java @@ -0,0 +1,69 @@ +package org.nl.acs.device_driver.autodoor.modbus_autodoor; + +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +public class ItemProtocol { + public static String item_heartbeat = "heartbeat"; + public static String item_mode = "mode"; + public static String item_action = "action"; + public static String item_error = "error"; + public static String item_to_command = "to_command"; + + + private final ModbusAutodoorDeviceDriver driver; + + public ItemProtocol(ModbusAutodoorDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value != null) { + return value; + } + return 0; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_heartbeat, "心跳", "30002")); + list.add(new ItemDto(item_mode, "工作状态", "30004", Boolean.TRUE)); + list.add(new ItemDto(item_action, "动作信号", "30006")); + list.add(new ItemDto(item_error, "报警信号", "30008")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "作业命令", "40002", Boolean.TRUE)); + return list; + } + +} + diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDefination.java new file mode 100644 index 0000000..a7c5255 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDefination.java @@ -0,0 +1,71 @@ +package org.nl.acs.device_driver.autodoor.modbus_autodoor; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 自动门驱动定义 + */ +@Service +public class ModbusAutodoorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "modbus_autodoor"; + } + + @Override + public String getDriverName() { + return "modbus-自动门"; + } + + @Override + public String getDriverDescription() { + return "modbus-自动门"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new ModbusAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return ModbusAutodoorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList<>(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "30002")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "30004", Boolean.TRUE)); + list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "30006")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "30008")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDeviceDriver.java new file mode 100644 index 0000000..66f708f --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/modbus_autodoor/ModbusAutodoorDeviceDriver.java @@ -0,0 +1,163 @@ +package org.nl.acs.device_driver.autodoor.modbus_autodoor; + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.opc.Device; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.utils.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * 自动门驱动 + */ +@EqualsAndHashCode(callSuper = true) +@Slf4j +@Data +@RequiredArgsConstructor +public class ModbusAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + String devicecode; + int mode = 0; + int action = 0; + int error = 0; + Boolean iserror = false; + + int move = 0; + int task = 0; + int last_action = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + protected boolean hasGoods = false; + boolean isFold = false; + private String assemble_check_tag; + private Boolean sampleMode0; + private Boolean sampleMode3; + private Integer sampleError; + private Boolean sampleOnline; + protected String displayMessage = null; + public int display_message_time_out = 30000; + public Date display_message_time; + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + + mode = this.itemProtocol.getMode(); + action = this.itemProtocol.getAction(); + error = this.itemProtocol.getError(); + if (mode != last_mode) { + } + if (action != last_action) { + } + if (error != last_error) { + //this.execute_log.setContainer(""); + } + last_action = action; + last_mode = mode; + last_error = error; + //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); + +// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); + + } + + public synchronized String getStatus() { + JSONObject jo = new JSONObject(); + + if (action == 1) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "OPEN"); + + } else if (action == 2) { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "CLOSE"); + + } else { + jo.put("name", this.getDevice().getDevice_code()); + jo.put("status", "ERROR"); + } + return jo.toString(); + } + + + public void writeing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + log.info("下发PLC信号:{},{}", to_command, command); + System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); + + } + + public synchronized void OpenOrClose(String type) { + + //开门 + if ("1".equals(type)) { + writeing(1); + } else { + writeing(2); + } + + } + +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java similarity index 96% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java index bd81d1b..80e96ef 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_autodoor; +package org.nl.acs.device_driver.autodoor.standard_autodoor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDefination.java similarity index 97% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDefination.java index 5b6b3fd..c1749b8 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_autodoor; +package org.nl.acs.device_driver.autodoor.standard_autodoor; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device_driver.DeviceDriver; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java similarity index 98% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java index 4f1c09f..441f808 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/autodoor/standard_autodoor/StandardAutodoorDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_autodoor; +package org.nl.acs.device_driver.autodoor.standard_autodoor; import com.alibaba.fastjson.JSONObject; import lombok.Data; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ItemProtocol.java new file mode 100644 index 0000000..c572e27 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ItemProtocol.java @@ -0,0 +1,106 @@ +package org.nl.acs.device_driver.inspect_site.modbus_inspect_site; + +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_error = "error"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + + private ModbusInspectSiteDeviceDriver driver; + + public ItemProtocol(ModbusInspectSiteDeviceDriver 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 getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getToCommand() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getToTarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getToTask() { + return this.getOpcIntegerValue(item_to_task); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + 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 static List getReadableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_heartbeat, "心跳", "30002")); + list.add(new ItemDto(item_mode, "工作状态", "30004", Boolean.TRUE)); + list.add(new ItemDto(item_move, "光电开关信号", "30006")); + list.add(new ItemDto(item_action, "取放信号", "30008")); + list.add(new ItemDto(item_error, "报警信号", "30010")); + list.add(new ItemDto(item_task, "任务号", "30012")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "作业命令", "40002", Boolean.TRUE)); + list.add(new ItemDto(item_to_target, "目标站", "40004")); + list.add(new ItemDto(item_to_task, "任务号", "40008")); + return list; + } + +} + diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDefination.java new file mode 100644 index 0000000..f4f67bf --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDefination.java @@ -0,0 +1,74 @@ +package org.nl.acs.device_driver.inspect_site.modbus_inspect_site; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 检测站点驱动定义 + * 说明:该站点为普通带光电检测站点 + */ +@Service +public class ModbusInspectSiteDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "modbus_inspect_site"; + } + + @Override + public String getDriverName() { + return "modbus-检测站点"; + } + + @Override + public String getDriverDescription() { + return "modbus-检测站点"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new ModbusInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return ModbusInspectSiteDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList<>(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "30002")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "30004", Boolean.TRUE)); + list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "30006")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "30008")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "30010")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "30014")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDeviceDriver.java new file mode 100644 index 0000000..d2109e8 --- /dev/null +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/modbus_inspect_site/ModbusInspectSiteDeviceDriver.java @@ -0,0 +1,455 @@ +package org.nl.acs.device_driver.inspect_site.modbus_inspect_site; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +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.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +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.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.opc.WcsConfig; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.dto.RouteLineDto; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.util.CodeUtil; +import org.nl.utils.SpringContextHolder; +import org.nl.wql.core.bean.WQLObject; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 检测站点驱动 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class ModbusInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + @Autowired + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + + String container; + String container_type_desc; + String last_container_type_desc; + String last_container; + //放货准备锁 + String putReadyLock = null; + //有货标记 + protected boolean has_goods_tag = false; + + int mode = 0; + int error = 0; + int move = 0; + int task = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + int last_task = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + + boolean hasVehicle = false; + boolean isReady = false; + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + boolean isFold = false; + private String assemble_check_tag; + + protected String current_stage_instruction_message; + protected String last_stage_instruction_message; + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + //备注 + String remark; + //数量 + String qty; + //物料 + String material; + //批次 + String batch; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //申请搬运任务 + private Boolean apply_handling = false; + //申请物料 + private Boolean apply_material = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + error = this.itemProtocol.getError(); + move = this.itemProtocol.getMove(); + task = this.itemProtocol.getTask(); + hasGoods = this.itemProtocol.getMove(); + + if (mode != last_mode) { + this.setRequireSucess(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 (error != last_error) { + logServer.deviceItemValue(this.device_code,"error" ,String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code,"","","信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code,"task",String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code,"","","信号task:" + last_task + "->" + task); + } + + if (this.getApply_handling()) { + String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device link_device = appService.findDeviceByCode(link_device_code); + ModbusInspectSiteDeviceDriver standardInspectSiteDevicedriver; + if (link_device.getDeviceDriver() instanceof ModbusInspectSiteDeviceDriver) { + standardInspectSiteDevicedriver = (ModbusInspectSiteDeviceDriver) link_device.getDeviceDriver(); +// if(standardInspectSiteDevicedriver.getMode() != 2){ +// log.debug("设备未待机"); +// return; +// } +// if(standardInspectSiteDevicedriver.getMove() != 0){ +// log.debug("设备不满足放货条件"); +// return; +// } + + //如果目标设备申请叫料 则允许生成任务 + if (standardInspectSiteDevicedriver.getApply_material()) { + TaskDto dto = new TaskDto(); + String now = DateUtil.now(); + dto.setTask_id(IdUtil.simpleUUID()); + dto.setCreate_by(this.getDevice().getDevice_code()); + dto.setUpdate_by(this.getDevice().getDevice_code()); + dto.setStart_point_code(this.getDevice().getDevice_code()); + + String taskcode = CodeUtil.getNewCode("TASK_NO"); + dto.setTask_code("-" + taskcode); + dto.setTask_status("0"); + dto.setPriority("101"); +// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); +// String next_device_codecode = jo.getNext_device_code(); +// if(StrUtil.isEmpty(next_device_codecode)){ +// throw new RuntimeException("该设备未找到对应路由"); +// } + dto.setNext_point_code(this.getDeviceCode()); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + standardInspectSiteDevicedriver.setApply_material(false); + } + } + this.setApply_handling(false); + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + //申请任务 +// if (this.getApply_handling()) { +// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); +// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); +// Device link_device = appService.findDeviceByCode(link_device_code); +// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; +// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { +// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver(); +// if(standardInspectSiteDevicedriver.getMode() != 2){ +// log.debug("设备未待机"); +// return; +// } +// if(standardInspectSiteDevicedriver.getMove() != 0){ +// log.debug("设备不满足放货条件"); +// return; +// } +// +// //如果目标设备申请叫料 则允许生成任务 +// if(standardInspectSiteDevicedriver.getApply_material()){ +// TaskDto dto = new TaskDto(); +// String now = DateUtil.now(); +// dto.setTask_id(IdUtil.simpleUUID()); +// dto.setCreate_by(this.getDevice().getDevice_code()); +// dto.setUpdate_by(this.getDevice().getDevice_code()); +// dto.setStart_point_code(this.getDevice().getDevice_code()); +// +// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO"); +// dto.setTask_code("-"+taskcode); +// dto.setTask_status("0"); +// dto.setPriority("101"); +// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); +// String next_device_codecode = jo.getNext_device_code(); +// if(StrUtil.isEmpty(next_device_codecode)){ +// throw new RuntimeException("该设备未找到对应路由"); +// } +// dto.setNext_point_code(next_device_codecode); +// dto.setUpdate_time(now); +// dto.setCreate_time(now); +// +// WQLObject wo = WQLObject.getWQLObject("acs_task"); +// JSONObject json = (JSONObject) JSONObject.toJSON(dto); + +// wo.insert(json); +// standardInspectSiteDevicedriver.setApply_material(false); +// } +// } +// this.setApply_handling(false); +// } + + if (material.length() > 0 && qty.length() > 0 && !requireSucess) { + this.instruction_require(container); + } + } + + switch (flag) { + //取货完成 + case 1: + writing(2); + return; + //放货完成 + case 2: + writing(3); + return; + + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + protected void thingToNothing() { + log.debug("从有货到无货 清理数据"); + this.set_last_container(container, container_type_desc); + } + + public void set_last_container(String barcode, String type_desc) { + this.set_last_container(barcode); + this.set_last_container_type_desc(type_desc); + } + + public void set_last_container(String barcode) { + } + + public void set_last_container_type_desc(String type) { + } + + public boolean exe_business() { + return true; + } + + protected void executing(Instruction instruction) { + this.executing(1, instruction, ""); + } + + public void executing(int command, Instruction instruction, String appendMessage) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + if (appendMessage == null) { + appendMessage = ""; + } + if (instruction != null) { + instruction_num = Integer.parseInt(instruction.getInstruction_code()); + } + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, 1); + itemMap.put(to_task, instruction_num); + ReadUtil.write(itemMap, server); + + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + + } + + public boolean instruction_require(String container_code) { + return instruction_require(container_code, WcsConfig.task_container_type_default_desc); + } + + /** + * 请求指令 + * + * @param container_code + * @param container_type + */ + public synchronized boolean instruction_require(String container_code, String container_type) { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + this.instruction_require_time = date; + TaskDto dto = new TaskDto(); + String now = DateUtil.now(); + dto.setTask_id(IdUtil.simpleUUID()); + dto.setCreate_by(this.getDevice().getDevice_code()); + dto.setUpdate_by(this.getDevice().getDevice_code()); + dto.setStart_point_code(this.getDevice().getDevice_code()); + dto.setVehicle_code(container_code); + dto.setVehicle_type(container_type); + + String taskcode = CodeUtil.getNewCode("TASK_NO"); + dto.setTask_code("-" + taskcode); + dto.setTask_status("0"); + dto.setPriority("101"); + RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); + String next_device_codecode = jo.getNext_device_code(); + if (StrUtil.isEmpty(next_device_codecode)) { + throw new RuntimeException("该设备未找到对应路由"); + } + dto.setNext_point_code(next_device_codecode); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + requireSucess = false; + return true; + } + } + + +} diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/ItemProtocol.java similarity index 97% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/ItemProtocol.java index c280d3d..824568d 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/ItemProtocol.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_inspect_site; +package org.nl.acs.device_driver.inspect_site.standard_inspect_site; import lombok.Data; import lombok.extern.slf4j.Slf4j; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDefination.java similarity index 96% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDefination.java index 2b81d41..19816ee 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDefination.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_inspect_site; +package org.nl.acs.device_driver.inspect_site.standard_inspect_site; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; import org.nl.acs.device_driver.DeviceDriver; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDeviceDriver.java similarity index 99% rename from acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java rename to acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDeviceDriver.java index 6bfa198..70e2703 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/inspect_site/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -1,4 +1,4 @@ -package org.nl.acs.device_driver.standard_inspect_site; +package org.nl.acs.device_driver.inspect_site.standard_inspect_site; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java index 8b2e6a7..c37bd96 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java @@ -135,7 +135,7 @@ public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implemen public void writing(int command) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command; + + "." + org.nl.acs.device_driver.inspect_site.standard_inspect_site.ItemProtocol.item_to_command; String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java index 526dbe7..64ae5af 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java @@ -12,7 +12,7 @@ import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 86ea295..91ff84e 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -9,7 +9,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index d76a648..66b48bd 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -21,7 +21,7 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.opc.Device; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index 12f3429..453a2d7 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -20,7 +20,7 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.StorageCellService; import org.nl.acs.device.service.dto.DeviceAssignedDto; import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.instruction.service.InstructionService; @@ -29,7 +29,6 @@ import org.nl.acs.instruction.service.dto.InstructionDto; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.dto.RouteLineDto; import org.nl.acs.task.service.TaskFeedbackService; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/logicflow/service/impl/StageServiceImpl.java b/acs/hd/nladmin-system/src/main/java/org/nl/logicflow/service/impl/StageServiceImpl.java index e53e4ca..02a46b5 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/logicflow/service/impl/StageServiceImpl.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/logicflow/service/impl/StageServiceImpl.java @@ -8,13 +8,13 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; +import org.nl.acs.device_driver.autodoor.standard_autodoor.StandardAutodoorDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver; import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.standard_rgv.StandardRGVDeviceDriver; import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; diff --git a/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 70e69ed..f29f787 100644 --- a/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -9,7 +9,7 @@ import org.nl.acs.config.AcsConfig; import org.nl.acs.config.server.AcsConfigService; import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.inspect_site.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.dto.Instruction; diff --git a/acs/qd/src/views/acs/device/config.vue b/acs/qd/src/views/acs/device/config.vue index 22358a9..9fa0526 100644 --- a/acs/qd/src/views/acs/device/config.vue +++ b/acs/qd/src/views/acs/device/config.vue @@ -95,6 +95,8 @@ import manipulator_inspect_site_NDC from '@/views/acs/device/driver/manipulator_ import standard_manipulator_stacking_site from '@/views/acs/device/driver/standard_manipulator_stacking_site' import standard_photoelectric_inspect_site from '@/views/acs/device/driver/standard_photoelectric_inspect_site' import electric_fence from '@/views/acs/device/driver/electric_fence' +import modbus_autodoor from '@/views/acs/device/driver/modbus_autodoor' +import modbus_inspect_site from '@/views/acs/device/driver/modbus_inspect_site' export default { name: 'DeviceConfig', @@ -103,7 +105,7 @@ export default { lamp_three_color, standard_storage, special_ordinary_site, standard_scanner, standard_conveyor_control_with_scanner, standard_conveyor_control_with_plcscanner, standard_conveyor_control, standard_conveyor_monitor, weighing_site, machines_site, non_line_manipulator_inspect_site, non_line_inspect_site, manipulator_inspect_site_NDC, standard_manipulator_stacking_site, - standard_photoelectric_inspect_site, electric_fence }, + standard_photoelectric_inspect_site, electric_fence, modbus_autodoor, modbus_inspect_site }, dicts: ['device_type'], mixins: [crud], data() { diff --git a/acs/qd/src/views/acs/device/driver/modbus_autodoor.vue b/acs/qd/src/views/acs/device/driver/modbus_autodoor.vue new file mode 100644 index 0000000..41e2f46 --- /dev/null +++ b/acs/qd/src/views/acs/device/driver/modbus_autodoor.vue @@ -0,0 +1,352 @@ + + + + + diff --git a/acs/qd/src/views/acs/device/driver/modbus_inspect_site.vue b/acs/qd/src/views/acs/device/driver/modbus_inspect_site.vue new file mode 100644 index 0000000..a6ab788 --- /dev/null +++ b/acs/qd/src/views/acs/device/driver/modbus_inspect_site.vue @@ -0,0 +1,490 @@ + + + + + diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/rest/PadController.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/rest/PadController.java index b9d24dd..c56db9d 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/rest/PadController.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/rest/PadController.java @@ -103,13 +103,23 @@ public class PadController { /** * 查询物料 * - * @return 所有物料 + * @param param String device_id 点位标识 + * @return 点位可以选择的物料 */ @PostMapping("/matrial") @Log("查询物料") @ApiOperation("查询物料") - public ResponseEntity material() { - return new ResponseEntity<>(padService.material(), HttpStatus.OK); + public ResponseEntity material(@RequestBody JSONObject param) { + // 参数校验 + String point_id = param.getString("device_id"); + if (StrUtil.isEmpty(point_id)) { + JSONObject resultJSON = new JSONObject(); + resultJSON.put("code", "0"); + resultJSON.put("desc", "点位不能为空"); + return new ResponseEntity<>(resultJSON, HttpStatus.OK); + } + + return new ResponseEntity<>(padService.material(point_id), HttpStatus.OK); } /** diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/PadService.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/PadService.java index 98e80a3..03187e8 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/PadService.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/PadService.java @@ -41,9 +41,10 @@ public interface PadService { /** * 查询物料 * - * @return 所有物料 + * @param point_id 点位标识 + * @return 点位可以选择的物料 */ - JSONObject material(); + JSONObject material(String point_id); /** * 点位状态绑定 diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/impl/PadServiceImpl.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/impl/PadServiceImpl.java index 508d682..ddb53f1 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/impl/PadServiceImpl.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/service/impl/PadServiceImpl.java @@ -179,15 +179,22 @@ public class PadServiceImpl implements PadService { /** * 查询物料 * - * @return 所有物料 + * @param point_id 点位标识 + * @return 点位可以选择的物料 */ @Override - public JSONObject material() { + public JSONObject material(String point_id) { // 返回值 JSONObject resultJSON = new JSONObject(); // 查询物料 - resultJSON.put("result", WQL.getWO("PAD").addParam("flag", "3").process().getResultJSONArray(0)); + resultJSON.put("result", + WQL + .getWO("PAD") + .addParam("flag", "3") + .addParam("point_id", point_id) + .process() + .getResultJSONArray(0)); // 返回 resultJSON.put("code", "1"); diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/wql/PAD.wql b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/wql/PAD.wql index fadeca2..e6b5d19 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/wql/PAD.wql +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/pad/wql/PAD.wql @@ -15,6 +15,7 @@ ################################################# 输入.flag TYPEAS s_string 输入.region_id TYPEAS s_string + 输入.point_id TYPEAS s_string 输入.lock_type TYPEAS s_string 输入.col TYPEAS s_string @@ -86,12 +87,15 @@ IF 输入.flag = "3" QUERY SELECT - `value`, - label + dd.label, + dd.`value` FROM - sys_dict_detail + sch_base_point point + LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id + LEFT JOIN sys_dict_detail dd ON pm.material = dd.`value` + AND dd.`name` = 'material_type' WHERE - `name` = 'current_material_type' + point.point_id = 输入.point_id ENDSELECT ENDQUERY ENDIF diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/rest/PointController.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/rest/PointController.java index b6b9284..95f2068 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/rest/PointController.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/rest/PointController.java @@ -43,7 +43,7 @@ public class PointController { @Log("新增点位") @ApiOperation("新增点位") //@PreAuthorize("@el.check('point:add')") - public ResponseEntity create(@Validated @RequestBody PointDto dto) { + public ResponseEntity create(@Validated @RequestBody JSONObject dto) { pointService.create(dto); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -52,7 +52,7 @@ public class PointController { @Log("修改点位") @ApiOperation("修改点位") //@PreAuthorize("@el.check('point:edit')") - public ResponseEntity update(@Validated @RequestBody PointDto dto) { + public ResponseEntity updatePoint(@Validated @RequestBody JSONObject dto) { pointService.update(dto); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/PointService.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/PointService.java index eb9280f..d5d321c 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/PointService.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/PointService.java @@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONObject; import org.nl.wms.sch.service.dto.PointDto; import org.springframework.data.domain.Pageable; -import java.util.List; import java.util.Map; /** @@ -22,21 +21,21 @@ public interface PointService { * @param page 分页参数 * @return Map */ - Map queryAll(Map whereJson, Pageable page); + Map queryAll(Map whereJson, Pageable page); /** * 查询所有数据不分页 * @param whereJson 条件参数 * @return List */ - List queryAll(Map whereJson); + JSONArray queryAll(Map whereJson); /** * 根据ID查询 * @param point_id ID * @return Point */ - PointDto findById(Long point_id); + JSONObject findById(Long point_id); /** * 根据编码查询 @@ -50,13 +49,13 @@ public interface PointService { * 创建 * @param dto / */ - void create(PointDto dto); + void create(JSONObject dto); /** * 编辑 * @param dto / */ - void update(PointDto dto); + void update(JSONObject dto); /** * 多选删除 diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/dto/PointDto.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/dto/PointDto.java index d41c0af..7c83b5a 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/dto/PointDto.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/dto/PointDto.java @@ -131,11 +131,6 @@ public class PointDto implements Serializable { */ private String material_code; - /** - * 物料类型 - */ - private String material_type; - /** * 上一区域id */ diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/PointServiceImpl.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/PointServiceImpl.java index 9666b16..8b77991 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/PointServiceImpl.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/impl/PointServiceImpl.java @@ -8,7 +8,6 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.mchange.lang.DoubleUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.exception.BadRequestException; @@ -25,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @author ldjun @@ -36,8 +36,8 @@ import java.util.Map; @Slf4j public class PointServiceImpl implements PointService { @Override - public Map queryAll(Map whereJson, Pageable page) { - HashMap map = new HashMap(); + public Map queryAll(Map whereJson, Pageable page) { + HashMap map = new HashMap<>(); map.put("flag", "1"); map.put("region_id", whereJson.get("region_id")); map.put("ids", whereJson.get("ids")); @@ -46,27 +46,34 @@ public class PointServiceImpl implements PointService { map.put("is_used", whereJson.get("is_used")); map.put("point_type", whereJson.get("point_type")); map.put("name", whereJson.get("name")); - JSONObject json = WQL.getWO("QSCH_BASE_POINT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "point_code asc"); - return json; + JSONObject result = WQL.getWO("QSCH_BASE_POINT").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "point_code asc"); + + JSONArray content = result.getJSONArray("content"); + WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material"); + for (Object o : content) { + JSONObject point = (JSONObject) o; + List material_type = pm_table + .query("point_id = " + point.getString("point_id")) + .getResultJSONArray(0) + .stream() + .map(pm -> ((JSONObject) pm).getString("material")) + .collect(Collectors.toList()); + point.put("material_type", material_type); + } + + return result; } @Override - public List queryAll(Map whereJson) { + public JSONArray queryAll(Map whereJson) { WQLObject wo = WQLObject.getWQLObject("sch_base_point"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(PointDto.class); - return list; + return wo.query().getResultJSONArray(0); } @Override - public PointDto findById(Long point_id) { + public JSONObject findById(Long point_id) { WQLObject wo = WQLObject.getWQLObject("sch_base_point"); - JSONObject json = wo.query("point_id =" + point_id + "").uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) { - return json.toJavaObject(PointDto.class); - } - final PointDto obj = json.toJavaObject(PointDto.class); - return obj; + return wo.query("point_id =" + point_id + "").uniqueResult(0); } @@ -82,103 +89,134 @@ public class PointServiceImpl implements PointService { @Override @Transactional(rollbackFor = Exception.class) - public void create(PointDto dto) { + public void create(JSONObject dto) { // 参数校验 - PointDto byCode = this.findByCode(dto.getPoint_code()); + PointDto byCode = this.findByCode(dto.getString("point_code")); if (ObjectUtil.isNotEmpty(byCode)) { throw new BadRequestException("存在相同的点位编码"); } - if (!StrUtil.equals(dto.getMaterial_type(), "14")) { - int count = WQLObject.getWQLObject("sch_base_point") - .query("is_delete = '0' AND seq = " + dto.getSeq() + " AND region_id = " + dto.getRegion_id() + "'") - .getResultJSONArray(0) - .size(); - if (count > 0) { - throw new BadRequestException("该区域存在相同的出入库顺序"); - } + int count = WQLObject.getWQLObject("sch_base_point") + .query("is_delete = '0' AND seq = " + dto.getLong("seq") + " AND region_id = '" + dto.getString("region_id") + "'") + .getResultJSONArray(0) + .size(); + if (count > 0) { + throw new BadRequestException("该区域存在相同的出入库顺序"); } - if (StrUtil.equals(dto.getPoint_status(), "00") && !StrUtil.equals(dto.getCurrent_material_type(), "14")) { + String current_material_type = dto.getString("current_material_type"); + if (StrUtil.equals(dto.getString("point_status"), "00") && StrUtil.isNotBlank(current_material_type)) { throw new BadRequestException("当前为空位但是存放物料类型不为空"); } - if (StrUtil.equals(dto.getPoint_status(), "01") && StrUtil.equals(dto.getCurrent_material_type(), "14")) { + if (StrUtil.equals(dto.getString("point_status"), "01") && StrUtil.isBlank(current_material_type)) { throw new BadRequestException("当前为有货但是存放物料类型为空"); } - if (dto.getSeq() < 0L) { + if (dto.getLongValue("seq") < 0L) { throw new BadRequestException("出入库顺序号不能小于0"); } - if (dto.getCol() < 0L) { + if (dto.getLongValue("col") < 0L) { throw new BadRequestException("排号不能小于0"); } - JSONObject colPoint = WQLObject.getWQLObject("sch_base_point").query("region_id = '" + dto.getRegion_id() + "' AND col = " + dto.getCol()).uniqueResult(0); - if (ObjectUtil.isNotEmpty(colPoint) && !StrUtil.equals(colPoint.getString("material_type"), dto.getMaterial_type())) { - throw new BadRequestException("当前排不能限定这种物料"); - } - if (!StrUtil.equals(dto.getCurrent_material_type(), "14") - && !StrUtil.equals(dto.getMaterial_type(), "14") - && !StrUtil.equals(dto.getMaterial_type(), dto.getCurrent_material_type())) { - throw new BadRequestException("当前存放物料与限定物料不一致"); + List material_types = dto.getJSONArray("material_type").stream().map(Object::toString).collect(Collectors.toList()); + if (StrUtil.isNotBlank(current_material_type) && !material_types.contains(current_material_type)) { + throw new BadRequestException("该点位不能存放这种物料"); } - Long currentUserId = SecurityUtils.getCurrentUserId(); - String nickName = SecurityUtils.getNickName(); - String now = DateUtil.now(); - dto.setPoint_id(IdUtil.getSnowflake(1, 1).nextId()); - dto.setCreate_id(currentUserId); - dto.setCreate_name(nickName); - dto.setUpdate_optid(currentUserId); - dto.setUpdate_optname(nickName); - dto.setUpdate_time(now); - dto.setCreate_time(now); + WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material"); + long point_id = IdUtil.createSnowflake(1L, 1L).nextId(); + JSONObject pm = new JSONObject(); + pm.put("point_id", point_id); + for (String material_type : material_types) { + pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId()); + pm.put("material", material_type); + pm_table.insert(pm); + } - WQLObject wo = WQLObject.getWQLObject("sch_base_point"); - JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); - wo.insert(json); + JSONObject point = new JSONObject(); + point.put("point_id", point_id); + point.put("point_code", dto.getString("point_code")); + point.put("point_name", dto.getString("point_name")); + point.put("point_status", dto.getString("point_status")); + point.put("lock_type", dto.getString("lock_type")); + point.put("current_material_type", dto.getString("current_material_type")); + point.put("col", dto.getString("col")); + point.put("region_id", dto.getString("region_id")); + point.put("prev_region_id", dto.getString("prev_region_id")); + point.put("next_region_id", dto.getString("next_region_id")); + point.put("seq", dto.getString("seq")); + point.put("remark", dto.getString("remark")); + point.put("create_id", SecurityUtils.getCurrentUserId()); + point.put("create_name", SecurityUtils.getNickName()); + point.put("create_time", DateUtil.now()); + WQLObject.getWQLObject("sch_base_point").insert(point); } @Override @Transactional(rollbackFor = Exception.class) - public void update(PointDto dto) { - Long pointId = dto.getPoint_id(); - PointDto entity = this.findById(pointId); + public void update(JSONObject dto) { + Long point_id = dto.getLong("point_id"); + JSONObject entity = this.findById(point_id); if (entity == null) { throw new BadRequestException("被删除或无权限,操作失败!"); } // 参数校验 - PointDto byCode = this.findByCode(dto.getPoint_code()); - if (!byCode.getPoint_id().equals(pointId)) { + PointDto byCode = this.findByCode(dto.getString("point_code")); + if (!byCode.getPoint_id().equals(point_id)) { throw new BadRequestException("该点位编码已被其他点位占用"); } - if (!StrUtil.equals(dto.getMaterial_type(), "14")) { - int count = WQLObject.getWQLObject("sch_base_point") - .query("is_delete = '0' AND seq = " + dto.getSeq() + " AND region_id = " + dto.getRegion_id() + " AND point_id <> " + pointId) - .getResultJSONArray(0) - .size(); - if (count > 0) { - throw new BadRequestException("该区域的其他点位中存在相同的出入库顺序"); - } + int count = WQLObject.getWQLObject("sch_base_point") + .query("is_delete = '0' AND seq = " + dto.getString("seq") + " AND region_id = " + dto.getLongValue("region_id") + " AND point_id <> " + point_id) + .getResultJSONArray(0) + .size(); + if (count > 0) { + throw new BadRequestException("该区域的其他点位中存在相同的出入库顺序"); } - if (StrUtil.equals(dto.getPoint_status(), "00") && !StrUtil.equals(dto.getCurrent_material_type(), "14")) { + + String current_material_type = dto.getString("current_material_type"); + if (StrUtil.equals(dto.getString("point_status"), "00") && StrUtil.isNotBlank(current_material_type)) { throw new BadRequestException("当前为空位但是存放物料类型不为空"); } - if (StrUtil.equals(dto.getPoint_status(), "01") && StrUtil.equals(dto.getCurrent_material_type(), "14")) { + if (StrUtil.equals(dto.getString("point_status"), "01") && StrUtil.isBlank(current_material_type)) { throw new BadRequestException("当前为有货但是存放物料类型为空"); } - if (!StrUtil.equals(dto.getMaterial_type(), "14") && StrUtil.equals(dto.getCurrent_material_type(), dto.getMaterial_type())) { - throw new BadRequestException("当前存放物料类型与限定物料类型不一致"); + if (dto.getLongValue("seq") < 0L) { + throw new BadRequestException("出入库顺序号不能小于0"); + } + if (dto.getLongValue("col") < 0L) { + throw new BadRequestException("排号不能小于0"); + } + List material_types = dto.getJSONArray("material_type").stream().map(Object::toString).collect(Collectors.toList()); + if (StrUtil.isNotBlank(current_material_type) && !material_types.contains(current_material_type)) { + throw new BadRequestException("该点位不能存放这种物料"); + } + WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material"); + pm_table.delete("point_id = " + point_id); + JSONObject pm = new JSONObject(); + pm.put("point_id", point_id); + for (String material_type : material_types) { + pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId()); + pm.put("material", material_type); + pm_table.insert(pm); } - Long currentUserId = SecurityUtils.getCurrentUserId(); - String nickName = SecurityUtils.getNickName(); - - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_optid(currentUserId); - dto.setUpdate_optname(nickName); + JSONObject point = new JSONObject(); + point.put("point_code", dto.getString("point_code")); + point.put("point_name", dto.getString("point_name")); + point.put("point_status", dto.getString("point_status")); + point.put("lock_type", dto.getString("lock_type")); + point.put("current_material_type", dto.getString("current_material_type")); + point.put("col", dto.getString("col")); + point.put("region_id", dto.getString("region_id")); + point.put("prev_region_id", dto.getString("prev_region_id")); + point.put("next_region_id", dto.getString("next_region_id")); + point.put("seq", dto.getString("seq")); + point.put("remark", dto.getString("remark")); + point.put("update_optid", SecurityUtils.getCurrentUserId()); + point.put("update_optname", SecurityUtils.getNickName()); + point.put("update_time", DateUtil.now()); - WQLObject wo = WQLObject.getWQLObject("sch_base_point"); - JSONObject json = JSONObject.parseObject(JSON.toJSONString(dto)); - wo.update(json); + WQLObject + .getWQLObject("sch_base_point") + .update(point, "point_id = " + point_id); } diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/QSCH_BASE_POINT.wql b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/QSCH_BASE_POINT.wql index 8d18d4d..5e5c9a0 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/QSCH_BASE_POINT.wql +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/QSCH_BASE_POINT.wql @@ -82,10 +82,8 @@ point.next_region_id, prev_region.region_name AS prev_region_name, next_region.region_name AS next_region_name, - d5.label AS material_type_name, point.seq, d6.label AS current_material_type_name, - point.material_type, point.current_material_type, point.col FROM @@ -96,7 +94,6 @@ LEFT JOIN sys_dict_detail d4 ON point.point_status = d4.value and d4.name='sch_point_status' LEFT JOIN SCH_BASE_Region prev_region ON point.prev_region_id = prev_region.region_id LEFT JOIN SCH_BASE_Region next_region ON point.next_region_id = next_region.region_id - LEFT JOIN sys_dict_detail d5 ON point.material_type = d5.`value` AND d5.`name` = 'material_type' LEFT JOIN sys_dict_detail d6 ON point.current_material_type = d6.`value` AND d6.`name` = 'current_material_type' WHERE point.is_delete = '0' diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/sch.xls b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/sch.xls index c1221c6..f2678ce 100644 Binary files a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/sch.xls and b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/service/wql/sch.xls differ diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallTask.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallTask.java index 2bbef30..630590b 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallTask.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/CallTask.java @@ -8,12 +8,16 @@ import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.exception.BadRequestException; import org.nl.modules.system.util.CodeUtil; +import org.nl.utils.SpringContextHolder; import org.nl.wms.sch.manage.AbstractAcsTask; import org.nl.wql.WQL; import org.nl.wql.core.bean.WQLObject; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; +import java.util.stream.Collectors; + /** * 徐工叫料任务类 * @@ -25,8 +29,6 @@ import org.springframework.transaction.annotation.Transactional; @Slf4j public class CallTask extends AbstractAcsTask { - private final SendTask sendTask = new SendTask(); - /** * 更新任务状态 * @@ -36,7 +38,7 @@ public class CallTask extends AbstractAcsTask { @Transactional(rollbackFor = Exception.class) @Override public void updateTaskStatus(JSONObject taskJSON, String status) { - sendTask.updateTaskStatus(taskJSON, status); + SpringContextHolder.getBean(SendTask.class).updateTaskStatus(taskJSON, status); } @Override @@ -60,12 +62,7 @@ public class CallTask extends AbstractAcsTask { @Override public String createTask(JSONObject param) { String nextPointCode = param.getString("next_point_code"); - String materialType = param.getString("material_type"); - - // 判断呼叫的物料类型 - if (StrUtil.equals(materialType, "14")) { - throw new BadRequestException("不能呼叫空物料"); - } + String materialType = param.getString("call_material_type"); // 判断点位是否存在 JSONObject nextPoint = WQLObject @@ -83,8 +80,14 @@ public class CallTask extends AbstractAcsTask { } // 判断叫的物料是否为点位的限定物料 - String nextPointMaterialType = nextPoint.getString("material_type"); - if (!StrUtil.equals(nextPointMaterialType, "14") && !StrUtil.equals(nextPointMaterialType, materialType)) { + List materialTypes = WQLObject + .getWQLObject("sch_base_point_material") + .query("point_id = " + nextPoint.getLong("point_id")) + .getResultJSONArray(0) + .stream() + .map(o -> ((JSONObject) o).getString("material")) + .collect(Collectors.toList()); + if (!materialTypes.contains(materialType)) { throw new BadRequestException("该点位不能呼叫这种物料"); } @@ -98,10 +101,7 @@ public class CallTask extends AbstractAcsTask { throw new BadRequestException("该点位不是空位"); } - // 起点 - JSONObject startPoint = null; - - // 查询该区域存放此物料的排 + // 查询叫料区域存放此物料的排 JSONArray colArray = WQL .getWO("SEND_TASK") .addParam("flag", "2") @@ -111,9 +111,10 @@ public class CallTask extends AbstractAcsTask { .getResultJSONArray(0); // 遍历该区域存放此物料的排寻找合适的点位 + JSONObject startPoint = null; for (Object o : colArray) { // 查找该排有货 或 已锁定的点位(出入库顺序降序) - startPoint = WQL + JSONObject tempPoint = WQL .getWO("SEND_TASK") .addParam("flag", "3") .addParam("region_id", startRegionId) @@ -122,19 +123,17 @@ public class CallTask extends AbstractAcsTask { .uniqueResult(0); // 点位不为空 且 点位未锁定,则为合适的叫料点位 - if (ObjectUtil.isNotEmpty(startPoint) && StrUtil.equals(startPoint.getString("lock_type"), "00")) { + if (ObjectUtil.isNotEmpty(tempPoint) && StrUtil.equals(tempPoint.getString("lock_type"), "00")) { + startPoint = tempPoint; break; } - - // 如果不合适重置为null - startPoint = null; } if (ObjectUtil.isEmpty(startPoint)) { throw new BadRequestException("未找到合适的叫料点位"); } assert startPoint != null; - return sendTask.createTaskRelated( + return SpringContextHolder.getBean(SendTask.class).createTaskRelated( startPoint, nextPoint, param, @@ -151,7 +150,7 @@ public class CallTask extends AbstractAcsTask { */ @Override public void forceFinish(String task_id) { - sendTask.forceFinish(task_id); + SpringContextHolder.getBean(SendTask.class).forceFinish(task_id); } @Override diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendTask.java b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendTask.java index d67878d..831359e 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendTask.java +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/tasks/SendTask.java @@ -194,32 +194,16 @@ public class SendTask extends AbstractAcsTask { throw new BadRequestException("该点位是空位"); } - // 如果起点是大吨位装配线下线区这根据物料类型给终点 + // 查送料点位(出入库顺序升序) JSONObject nextPoint; - String startRegionId = startPoint.getString("region_id"); String currentMaterialType = startPoint.getString("current_material_type"); - if (StrUtil.equals(startRegionId, "1578917189698850816") || StrUtil.equals(startRegionId, "1578917627470942208")) { - String nextPointCode = null; - if (StrUtil.equals(currentMaterialType, "08")) { - nextPointCode = "TZSXDCP1"; - } - if (StrUtil.equals(currentMaterialType, "09")) { - nextPointCode = "TZSXDCP2"; - } - nextPoint = WQLObject - .getWQLObject("sch_base_point") - .query("is_delete = '0' AND is_used = '1' AND point_code = '" + nextPointCode + "'") - .uniqueResult(0); - } else { - // 查送料点位(出入库顺序升序) - nextPoint = WQL - .getWO("SEND_TASK") - .addParam("flag", "1") - .addParam("region_id", nextRegionId) - .addParam("material_type", currentMaterialType) - .process() - .uniqueResult(0); - } + nextPoint = WQL + .getWO("SEND_TASK") + .addParam("flag", "1") + .addParam("region_id", nextRegionId) + .addParam("material_type", currentMaterialType) + .process() + .uniqueResult(0); if (ObjectUtil.isEmpty(nextPoint)) { throw new BadRequestException("未找到合适的送料点位"); } diff --git a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/wql/SEND_TASK.wql b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/wql/SEND_TASK.wql index b825593..886f1d0 100644 --- a/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/wql/SEND_TASK.wql +++ b/lms/hd/nladmin-system/src/main/java/org/nl/wms/sch/wql/SEND_TASK.wql @@ -45,17 +45,18 @@ SELECT * FROM - sch_base_point + sch_base_point point + LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id WHERE - point_status = '00' - AND lock_type = '00' - AND is_delete = '0' - AND is_used = '1' + point.point_status = '00' + AND point.lock_type = '00' + AND point.is_delete = '0' + AND point.is_used = '1' OPTION 输入.region_id <> "" - region_id = 输入.region_id + point.region_id = 输入.region_id ENDOPTION OPTION 输入.material_type <> "" - material_type = 输入.material_type + pm.material = 输入.material_type ENDOPTION ORDER BY seq ASC @@ -66,17 +67,18 @@ IF 输入.flag = "2" QUERY SELECT DISTINCT - col + point.col FROM - `sch_base_point` + `sch_base_point` point + LEFT JOIN sch_base_point_material pm ON point.point_id = pm.point_id WHERE - is_delete = '0' - AND is_used = '1' + point.is_delete = '0' + AND point.is_used = '1' OPTION 输入.region_id <> "" - region_id = 输入.region_id + point.region_id = 输入.region_id ENDOPTION OPTION 输入.material_type <> "" - material_type = 输入.material_type + pm.material = 输入.material_type ENDOPTION ORDER BY col diff --git a/lms/hd/nladmin-system/src/test/java/org/nl/PointTest.java b/lms/hd/nladmin-system/src/test/java/org/nl/PointTest.java index 10d9dfe..8626ea5 100644 --- a/lms/hd/nladmin-system/src/test/java/org/nl/PointTest.java +++ b/lms/hd/nladmin-system/src/test/java/org/nl/PointTest.java @@ -3,13 +3,16 @@ package org.nl; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.junit.Test; import org.junit.runner.RunWith; +import org.nl.utils.SecurityUtils; import org.nl.wms.sch.service.dto.PointDto; import org.nl.wql.core.bean.WQLObject; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.transaction.annotation.Transactional; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @RunWith(SpringRunner.class) @@ -17,40 +20,48 @@ public class PointTest { @Test public void test01() { - for (int i = 0; i < 21; i++) { - int nameSeq = i + 1; - PointDto point = new PointDto(); - - point.setMaterial_type("10"); - if (nameSeq < 10) { - point.setPoint_code("XCPM0" + nameSeq); - } else { - point.setPoint_code("XCPM" + nameSeq); + WQLObject point_table = WQLObject.getWQLObject("sch_base_point"); +// JSONObject point = new JSONObject(); +// point.put("region_id", "1628275194667864064"); +// point.put("point_type", "00"); +// point.put("point_status", "00"); +// point.put("lock_type", "00"); +// point.put("is_used", "1"); +// point.put("is_delete", "0"); +// String now = DateUtil.now(); +// point.put("create_id", 1); +// point.put("create_name", "管理员"); +// point.put("create_time", now); +// point.put("update_optid", 1); +// point.put("update_optname", "管理员"); +// point.put("update_time", now); +// point.put("current_material_type", "14"); +// +// int seq = 0; +// for (int i = 1; i < 6; i++) { +// for (int j = 1; j < 6; j++) { +// point.put("point_id", IdUtil.createSnowflake(1L, 1L).nextId()); +// point.put("point_code", "HC" + i + "-0" + j + "-01"); +// point.put("point_name", "缓存周转区" + i + "排" + j + "列"); +// point.put("seq", ++seq); +// point.put("col", i); +// point.put("seq_num", ((i - 1) * 10) + j); +// point_table.insert(point); +// } +// } + JSONArray points = point_table + .query("region_id = 1628275194667864064") + .getResultJSONArray(0); + WQLObject pm_table = WQLObject.getWQLObject("sch_base_point_material"); + JSONObject pm = new JSONObject(); + String[] materials = new String[]{"08", "09", "10", "11", "12", "13"}; + for (Object o : points) { + pm.put("point_id", ((JSONObject) o).getLongValue("point_id")); + for (String material : materials) { + pm.put("pm_id", IdUtil.getSnowflake(1L, 1L).nextId()); + pm.put("material", material); + pm_table.insert(pm); } - point.setPoint_name("小吨位成品满框" + nameSeq + "号位"); - -//--------------------------------------------------------------------------------------------------------- - point.setRegion_id(1578915492142387200L); - -//--------------------------------------------------------------------------------------------------------- - point.setSeq((long) i); - point.setPoint_status("00"); - point.setPoint_type("00"); - point.setLock_type("00"); - Long currentUserId = 1L; - String nickName = "管理员"; - String now = DateUtil.now(); - point.setPoint_id(IdUtil.getSnowflake(1, 1).nextId()); - point.setCreate_id(currentUserId); - point.setCreate_name(nickName); - point.setUpdate_optid(currentUserId); - point.setUpdate_optname(nickName); - point.setUpdate_time(now); - point.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("sch_base_point"); - JSONObject json = JSONObject.parseObject(JSON.toJSONString(point)); - wo.insert(json); } } } diff --git a/lms/qd/src/views/wms/sch/point/index.vue b/lms/qd/src/views/wms/sch/point/index.vue index f3fb313..e6ce5de 100644 --- a/lms/qd/src/views/wms/sch/point/index.vue +++ b/lms/qd/src/views/wms/sch/point/index.vue @@ -117,6 +117,7 @@ - + - - - - - - - - - - - - + + + + + + + + + + + +