diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index aa9a18954..32af48f4c 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -40,11 +40,11 @@ jansi 1.9 - + org.apache.commons @@ -90,6 +90,12 @@ org.openscada.utgard org.openscada.opc.lib 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + com.squareup.okhttp3 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java index 998f6f584..10ccaae96 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/device_driver/DriverTypeEnum.java @@ -55,7 +55,12 @@ public enum DriverTypeEnum { PAPER_TUBE_DEVICE(22, "paper_tube_conveyor", "纸管库设备", "conveyor"), - DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"); + DEVICE_STATUS(23,"device_status","立库设备状态","conveyor"), + + INDOOR_MANIPULATOR(24,"indoor_manipulator","内包间-行架机械手","station"), + + PLUGGING_UNPLUGGING_MACHINE(25,"plugging_unplugging_machine","插拔轴机","station"); + //驱动索引 private int index; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls index 5861314cf..d3ad5b206 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java new file mode 100644 index 000000000..0c7406519 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationConveyorDeviceDriver.java @@ -0,0 +1,408 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +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.agv.server.AgvService; +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.ext.wms.data.ApplyPaperActionRequest; +import org.nl.acs.ext.wms.data.ApplyPaperActionResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.dto.DeviceErrorLogDto; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +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.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +/** + * 套管工位 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class CasingStationConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + private Date instruction_update_time = new Date(); + private Date require_apply_casing_time = new Date(); + private int instruction_update_time_out = 500; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + //心跳 + int heartbeat = 0; + int last_heartbeat = 0; + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + //报警 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + String material1 = null; + String last_material1 = null; + + String material2 = null; + String last_material2 = null; + + + //下发命令 + int to_command = 0; + int last_to_command = 0; + + //当前指令 + Instruction inst = null; + + Boolean isonline = true; + + Boolean iserror = false; + //请求成功标记 + Boolean requireSucess = false; + + String message = null; + String device_code; + + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + String message = null; + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + material1 = this.itemProtocol.getMaterial1(); + material2 = this.itemProtocol.getMaterial2(); + + to_command = this.itemProtocol.getTo_command(); + + + if (to_command != last_to_command) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command); + } + if (!material1.equals(last_material1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material1:" + last_material1 + "->" + material1); + } + if (!material2.equals(last_material2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material2:" + last_material2 + "->" + material2); + } + + if (carrier_direction != last_carrier_direction) { + logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (error != last_error) { + if (error != 0) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(device_code); + dto.setError_code(String.valueOf(error)); + String errorInfo = ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)); + dto.setError_info(errorInfo); + deviceErrorLogService.create(dto); + } + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (mode != last_mode) { + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("mode", Math.min(mode, 3)); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "1"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); + 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 (move != 0 && task > 1) { + update_instruction_status(); + } + + } catch (Exception var17) { + var17.printStackTrace(); + 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; + + //纸管库申请任务 + switch (mode) { + case 1: + log.debug("弃用(留作兼容)"); + break; + case 2: + //申请任务 + /*if (move > 0 && !requireSucess) { + instruction_require(); + }*/ + break; + case 3: + log.info("运行中"); + break; + default: + if (move == 1 && !requireSucess) { + //申请套管校验 + apply_for_casing_inspection(material1, material2); + } + break; + } + } + last_heartbeat = heartbeat; + last_mode = mode; + last_move = move; + last_error = error; + last_carrier_direction = carrier_direction; + last_task = task; + last_material1 = material1; + last_material2 = material2; + last_to_command = to_command; + } + + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + 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; + inst = checkInst(); + if (inst != null) { + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); + } + if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } + } + } + + /** + * 申请套管校验 + */ + public synchronized void apply_for_casing_inspection(String material1, String material2) { + Date date = new Date(); + if (date.getTime() - this.require_apply_casing_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + } else { + this.require_apply_casing_time = date; + ApplyPaperActionRequest applyPaperActionRequest = new ApplyPaperActionRequest(); + applyPaperActionRequest.setDevice_code(this.device_code); + applyPaperActionRequest.setType("2"); + applyPaperActionRequest.setTask_code(String.valueOf(task)); + //获取出库顺序 + applyPaperActionRequest.setMaterial1(material1); + applyPaperActionRequest.setMaterial2(material2); + ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest); + Map map = new HashMap(); + if (applyPaperActionResponse.getstatus() == 200) { + map.put("code", "to_command"); + map.put("value", "4"); + this.writing(map); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + applyPaperActionResponse); + message = "申请套管成功"; + } else { + message = applyPaperActionResponse.getMessage(); + map.put("code", "to_command"); + map.put("value", "99"); + this.writing(map); + requireSucess = false; + message = "纸管不匹配"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管,返回参数:" + applyPaperActionResponse); + } + } + } + + + /** + * 申请任务 + */ + public synchronized void instruction_require() { + 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; + } else { + //没有就绪状态的任务,查询就绪状态的指令 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isNull(taskdto) && ObjectUtil.isNotNull(inst)) { + + } + } + } + + /** + * 完成指令 + * + * @return + * @throws Exception + */ + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + + @Override + public JSONObject getDeviceStatusName() throws Exception { + return null; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + public void writing(List list) { + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try { + this.checkcontrol(itemMap); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + + 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 String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + 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/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java new file mode 100644 index 000000000..158e279d5 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/CasingStationDefination.java @@ -0,0 +1,59 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +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.LinkedList; +import java.util.List; + +/** + * 套管工位 + */ +@Service +public class CasingStationDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "casing_station"; + } + + @Override + public String getDriverName() { + return "套管工位"; + } + + @Override + public String getDriverDescription() { + return "套管工位"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new CasingStationConveyorDeviceDriver().setDevice(device).setDriverDefination(this)); + } + + @Override + public Class extends DeviceDriver> getDeviceDriverType() { + return CasingStationConveyorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java new file mode 100644 index 000000000..6e560b925 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/casing_station/ItemProtocol.java @@ -0,0 +1,125 @@ +package org.nl.acs.device_driver.basedriver.casing_station; + +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_carrier_direction = "carrier_direction"; + //报警 + public static String item_error = "error"; + //任务号 + public static String item_task = "task"; + //物料1 + public static String item_material1 = "material1"; + //物料2 + public static String item_material2 = "material2"; + + //下发命令 + public static String item_to_command = "to_command"; + + public ItemProtocol(CasingStationConveyorDeviceDriver 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 getCarrier_direction() { + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public String getMaterial1() { + return this.getOpcStringValue(item_material1); + } + + public String getMaterial2() { + return this.getOpcStringValue(item_material2); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + Boolean isonline; + + private CasingStationConveyorDeviceDriver driver; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); + list.add(new ItemDto(item_mode, "工作模式", "DB101.W2")); + list.add(new ItemDto(item_move, "光电信号", "DB101.W3")); + list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.W4")); + list.add(new ItemDto(item_error, "报警", "DB101.W58")); + list.add(new ItemDto(item_task, "任务号", "DB101.W6")); + list.add(new ItemDto(item_material1, "物料1", "DB101.W7")); + list.add(new ItemDto(item_material2, "物料2", "DB101.W8")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDefination.java new file mode 100644 index 000000000..16e1a20ec --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDefination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.basedriver.indoor_manipulator; + +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.LinkedList; +import java.util.List; + +/** + * 内包间-行架机械手 + * + */ +@Service +public class IndoorManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "indoor_manipulator"; + } + + @Override + public String getDriverName() { + return "内包间-行架机械手"; + } + + @Override + public String getDriverDescription() { + return "内包间-行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new IndoorManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class extends DeviceDriver> getDeviceDriverType() { + return IndoorManipulatorDeviceDriver.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/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java new file mode 100644 index 000000000..69e69deee --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/IndoorManipulatorDeviceDriver.java @@ -0,0 +1,1040 @@ +package org.nl.acs.device_driver.basedriver.indoor_manipulator; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.AcsConfig; +import org.nl.acs.device.service.DeviceService; +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.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver; +import org.nl.acs.device_driver.basedriver.photoelectric_inspection_site.PhotoelectricInspectionSiteDeviceDriver; +import org.nl.acs.device_driver.basedriver.plugging_unplugging_machine.PluggingUnpluggingMachineDeviceDriver; +import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest; +import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse; +import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest; +import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +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.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.impl.ParamServiceImpl; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + + +/** + * 内包间-行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class IndoorManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected org.nl.acs.device_driver.basedriver.indoor_manipulator.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"); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.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 inflatable_shaft_size = 0; + int last_inflatable_shaft_size = 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; + + int to_putpoint = 0; + int last_to_putpoint = 0; + + int to_new_getpoint = 0; + int last_to_new_getpoint = 0; + + int to_two_putpoint = 0; + int last_to_two_putpoint = 0; + + int to_task_type = 0; + int last_to_task_type = 0; + + //气胀轴代数 + int inflatableShaftVersion = 0; + int last_inflatableShaftVersion = 0; + + //套管数量 + int tube_num = 0; + int last_tube_num = 0; + + //是否套轴 + int is_wrapped = 0; + int last_is_wrapped = 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; + private Date instruction_apply_time = new Date(); + //行架机械手申请任务成功标识 + boolean requireSucess = false; + //反馈成功表示 + boolean feedbackSucess = 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(); + inflatable_shaft_size = this.itemProtocol.getInflatable_shaft_size(); + to_putpoint = this.itemProtocol.getTo_putpoint(); + to_new_getpoint = this.itemProtocol.getTo_new_getpoint(); + to_two_putpoint = this.itemProtocol.getTo_two_putpoint(); + to_task_type = this.itemProtocol.getTo_task_type(); + tube_num = this.itemProtocol.getTube_num(); + inflatableShaftVersion = this.itemProtocol.getInflatableShaftVersion(); + is_wrapped = this.itemProtocol.getIs_wrapped(); + + 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) { + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("mode", Math.min(mode, 3)); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "2"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + + if (mode == 2) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号复位前requireSuccess:" + requireSucess); + this.setRequireSucess(false); + logServer.deviceExecuteLog(this.device_code, "", "", "信号复位后requireSuccess:" + requireSucess); +// if (move == 0 && task == 0 && action == 0 && this.getNow_steps_type() != 0){ +// logServer.deviceExecuteLog(this.device_code, "", "", "当前执行步骤复位前:" + this.getNow_steps_type()); +// this.setNow_steps_type(0); +// logServer.deviceExecuteLog(this.device_code, "", "", "当前执行步骤复位后:" + this.getNow_steps_type()); +// } + feedMessage = ""; + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + inst = null; + message = null; + } + 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) { + this.setFeedbackSucess(false); + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (error != last_error) { + if (error != 0) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(device_code); + dto.setError_code(String.valueOf(error)); + String errorInfo = ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(error)); + dto.setError_info(errorInfo); + deviceErrorLogService.create(dto); + } + + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("error", error); + param.put("error_msg", error == 0 ? "" : ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(error))); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "2"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + + 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 (inflatable_shaft_size != last_inflatable_shaft_size) { + logServer.deviceItemValue(this.device_code, "inflatable_shaft_size", String.valueOf(inflatable_shaft_size)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号inflatable_shaft_size:" + last_inflatable_shaft_size + "->" + inflatable_shaft_size); + } + + if (task > 0 && getTo_task_type() == 1) { + update_instruction_status(); + } else if (task > 0 && getTo_task_type() == 2) {// + update_instruction_status2(); + } else if (task > 0 && getTo_task_type() == 6) { + update_instruction_status3(); + } else if (task > 0 && getTo_task_type() == 7) { + update_instruction_status4(); + } + + + } 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 && !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; + last_inflatable_shaft_size = inflatable_shaft_size; + } + + /** + * 抽取统一下发电气信号前缀 + * + * @return + */ + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + /** + * 多个信号一起下发电气 + * + * @param map + */ + 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 synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } + + private synchronized void update_instruction_status() { + 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) { + //inst_message + Instruction inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + //任务完成 + if (action == 8) { + Instruction inst2 = checkInst(); + if (inst2 != null) { + try { + finish_instruction(inst2); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 6) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + + + } + } + + private synchronized void update_instruction_status2() { + 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) { + //inst_message + Instruction inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; + //反馈气胀轴尺寸 + if (mode == 3) { + Instruction inst2 = checkInst(); + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + applyManipulatorActionRequest.setType(truss_type); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + map.put("to_task_type", "2"); + this.writing(map); + this.setFeedbackSucess(true); + } else { + requireSucess = true; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } + } + + //申请放货点 + if (action == 3) { + Instruction inst2 = checkInst(); + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + applyManipulatorActionRequest.setType(truss_type); + applyManipulatorActionRequest.setTask_code(String.valueOf(task)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + String detail_type = applyManipulatorActionResponse.getDetail_type(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "3"); + map.put("to_putpoint", put_device_code); + this.writing(map); + this.setFeedbackSucess(true); + } + + //任务完成 + if (action == 8) { + Instruction inst2 = checkInst(); + if (inst2 != null) { + try { + finish_instruction(inst2); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 6) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + + + } + } + + private synchronized void update_instruction_status3() { + 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) { + //inst_message + Instruction inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + + + + //任务完成 + if (action == 8) { + Instruction inst2 = checkInst(); + if (inst2 != null) { + try { + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + finish_instruction(inst2); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + + + } + } + + private synchronized void update_instruction_status4() { + 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) { + //inst_message + Instruction inst1 = checkInst(); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + inst1.setExecute_device_code(this.device_code); + instructionService.update(inst1); + } + } + } + + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; + //反馈尺寸 + if (action == 2) { + Instruction inst2 = checkInst(); + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + applyManipulatorActionRequest.setType(truss_type); + applyManipulatorActionRequest.setTask_code(task_code); + applyManipulatorActionRequest.setSize(String.valueOf(inflatable_shaft_size)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + requireSucess = true; + message = "反馈LMS成功..."; + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求成功,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + String version = applyManipulatorActionResponse.getVersion(); + String bushing_num = applyManipulatorActionResponse.getBushing_num(); + String is_bushing = applyManipulatorActionResponse.getIs_bushing(); + String detail_type = applyManipulatorActionResponse.getDetail_type(); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "2"); + map.put("inflatableShaftVersion", version); + map.put("tube_num", bushing_num); + map.put("is_wrapped", is_bushing); + map.put("to_putpoint", put_device_code); + this.writing(map); + this.setFeedbackSucess(true); + } else { + requireSucess = true; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } + } + + if (action == 3) { + Instruction inst2 = checkInst(); + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + applyManipulatorActionRequest.setType(truss_type); + applyManipulatorActionRequest.setTask_code(String.valueOf(task)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + String detail_type = applyManipulatorActionResponse.getDetail_type(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "3"); + map.put("to_task_type", detail_type); + map.put("to_putpoint", put_device_code); + this.writing(map); + this.setFeedbackSucess(true); + } + if (mode == 3 && action == 4 && task > 0) { + applyManipulatorActionRequest.setType("4"); + applyManipulatorActionRequest.setTask_code(String.valueOf(task)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String get_device_code = applyManipulatorActionResponse.getGet_device_code(); + String put_device_code = applyManipulatorActionResponse.getPut_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "4"); + map.put("to_new_getpoint", get_device_code); + map.put("to_putpoint", put_device_code); + this.writing(map); + this.setFeedbackSucess(true); + } + if (action == 5) { + applyManipulatorActionRequest.setType("5"); + applyManipulatorActionRequest.setTask_code(String.valueOf(task)); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + String put_device_code2 = applyManipulatorActionResponse.getPut_device_code2(); + String detail_type = applyManipulatorActionResponse.getDetail_type(); + String get_device_code = applyManipulatorActionResponse.getGet_device_code(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "5"); + map.put("to_task_type", detail_type); + map.put("to_two_putpoint", put_device_code2); + map.put("to_new_getpoint", get_device_code); + this.writing(map); + this.setFeedbackSucess(true); + } + + + //放货完成 + if (action == 8) { + Instruction inst2 = checkInst(); + if (inst2 != null) { + try { + String task_code = inst2.getTask_code(); + TaskDto taskDto = taskserver.findByCode(task_code); + String truss_type = taskDto.getTruss_type(); + finish_instruction(inst2); + this.writing("to_command", "8"); + } catch (Exception e) { + e.printStackTrace(); + } + feedMessage = ""; + } + } else { + feedMessage = "行架机械手:"; + if (mode != 3) { + feedMessage = feedMessage + "工作模式(mode)不为运行中状态,"; + } + if (action != 8) { + feedMessage = feedMessage + "动作信号(action)不为放货完成状态,"; + } + if (move != 0) { + feedMessage = feedMessage + "光电信号(move)不为无货状态,"; + } + if (task == 0) { + feedMessage = feedMessage + "当前上报任务号(task)不应该为0。"; + } + } + + + } + } + + 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; + } + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + //将扩展表中的字符串数据转换成集合 + public List getExtraDeviceCodes(String extraName) { + String extraValue = (String) this.getDevice().getExtraValue().get(extraName); + if (StrUtil.isEmpty(extraValue)) { + return new ArrayList<>(); + } + String devicesString = extraValue.substring(1, extraValue.length() - 1); + List devicesList = new ArrayList<>(); + String[] devices = devicesString.split(","); + for (int i = 0; i < devices.length; i++) { + String s = devices[i].replace("\"", "").replace("\"", ""); + devicesList.add(s); + } + return devicesList; + } + + public List sortTask(List taskDtos) { + Collections.sort(taskDtos, new Comparator() { + @Override + public int compare(TaskDto t1, TaskDto t2) { + //优先级从大到小 + int i = t2.getPriority().compareTo(t1.getPriority()); + //如果优先级相等 + if (i == 0) { + //时间从早到晚 + i = t1.getCreate_time().compareTo(t2.getCreate_time()); + } + return i; + } + }); + return taskDtos; + } + + public void writing(String param, String value) { + + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(value)); +// itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); + } + + /** + * 申请任务 + * + * @param + */ + public synchronized boolean applyTask() { + 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; + //抓取工位 + if (ObjectUtil.isEmpty(getDeviceCodeList)) { + getDeviceCodeList = this.getExtraDeviceCodes("get_device_code"); + } + //放货工位 + if (ObjectUtil.isEmpty(putDeviceCodeList)) { + putDeviceCodeList = this.getExtraDeviceCodes("put_device_code"); + } + TaskDto task = null; + for (int i = 0; i < getDeviceCodeList.size(); i++) { + String startDeviceCode = getDeviceCodeList.get(i); + List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus2(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); + TaskDto taskDto = taskDtos.get(0); + + //存在行架->暂存的AGV任务 需要过滤 + // 9 行架任务 + if (!StrUtil.equals(taskDto.getTask_type(), "9")) { + taskDto = null; + continue; + } + Instruction instruction = instructionService.findByTaskcodeAndStatus(taskDto.getTask_code()); + String start_device_code = instruction.getStart_device_code(); + String next_device_code = instruction.getNext_device_code(); + Device nextdevice = deviceAppService.findDeviceByCode(next_device_code); + Device startdevice = deviceAppService.findDeviceByCode(start_device_code); + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + instruction.setInstruction_status("1"); + instruction.setUpdate_time(DateUtil.now()); + instructionService.update(instruction); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instruction.getInstruction_code() + ",指令起点:" + instruction.getStart_device_code() + + ",指令终点:" + instruction.getNext_device_code()); + String is_bushing = taskDto.getIs_bushing(); + String version = taskDto.getVersion(); + String bushing_num = taskDto.getBushing_num(); + + Map map = new LinkedHashMap<>(); + map.put("to_command", "1"); + if (action == 2) { + map.put("inflatableShaftVersion", version); + map.put("tube_num", bushing_num); + map.put("is_wrapped", is_bushing); + } + if (taskDto.getTruss_type() == "1" || taskDto.getTruss_type() == "5") { + map.put("to_task_type", taskDto.getTruss_type()); + } + map.put("to_onset", start_addr); + map.put("to_task", instruction.getInstruction_code()); + map.put("to_target", next_addr); + this.writing(map); + this.setRequireSucess(true); + return true; + } else { + List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + for (int j = 0; j < taskDtoList.size(); j++) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtoList = this.sortTask(taskDtoList); + task = taskDtoList.get(j); + // 9 行架任务 + if (!StrUtil.equals(task.getTruss_type(), "9")) { + task = null; + continue; + } + if (ObjectUtil.isNotEmpty(task)) break; + } + } + } + } + if (!ObjectUtil.isEmpty(task)) { + Device nextdevice = deviceAppService.findDeviceByCode(task.getNext_device_code()); + Device startdevice = deviceAppService.findDeviceByCode(task.getStart_device_code()); + StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (startdevice.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) startdevice.getDeviceDriver(); + if (siemensConveyorDeviceDriver.getMove() != 1) { + notCreateInstMessage = "就绪任务未创建指令原因->取货位-分切输送线出口:" + siemensConveyorDeviceDriver.getDevice_code() + "光电无货,无法生成指令!"; + return false; + } + } + String taskid = task.getTask_id(); + String taskcode = task.getTask_code(); + String vehiclecode = task.getVehicle_code(); + String priority = task.getPriority(); + String start_point_code = task.getStart_point_code(); + String start_device_code = task.getStart_device_code(); + String route_plan_code = task.getRoute_plan_code(); + String next_point_code = task.getNext_point_code(); + String next_device_code = task.getNext_device_code(); + + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(task.getRemark()); + instdto.setMaterial(task.getMaterial()); + instdto.setQuantity(task.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + instdto.setVehicle_code(vehiclecode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(next_device_code); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(next_point_code); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "创建指令时出现异常:" + e.getMessage()); + return false; + } + //创建指令后修改任务状态 + task.setTask_status("1"); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + + Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); + Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); + if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + } + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + } + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" + + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + + ",指令终点:" + instdto.getNext_device_code()); + String is_bushing = task.getIs_bushing(); + String version = task.getVersion(); + String bushing_num = task.getBushing_num(); + Map map = new LinkedHashMap<>(); + map.put("to_command", "1"); + if (action == 2) { + map.put("inflatableShaftVersion", version); + map.put("tube_num", bushing_num); + map.put("is_wrapped", is_bushing); + } + if (task.getTruss_type() == "1" || task.getTruss_type() == "5") { + map.put("to_task_type", task.getTruss_type()); + } + map.put("to_onset", start_addr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_target", next_addr); + this.writing(map); + this.setRequireSucess(true); + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; + } + return true; + } + } +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/ItemProtocol.java new file mode 100644 index 000000000..ed425f955 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/indoor_manipulator/ItemProtocol.java @@ -0,0 +1,224 @@ +package org.nl.acs.device_driver.basedriver.indoor_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_inflatable_shaft_size = "inflatable_shaft_size"; + + //下发命令 + 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"; + //反馈放货点 + public static String item_to_putpoint = "to_putpoint"; + //反馈新取货点 + public static String item_to_new_getpoint = "to_new_getpoint"; + //反馈二次放货点 + public static String item_to_two_putpoint = "to_two_putpoint"; + //下发任务类型 + public static String item_to_task_type = "to_task_type"; + //气胀轴代数 + public static String item_inflatableShaftVersion = "inflatableShaftVersion"; + //套管数量 + public static String item_tube_num = "tube_num"; + //是否套轴 + public static String item_is_wrapped = "is_wrapped"; + + + private IndoorManipulatorDeviceDriver driver; + + public ItemProtocol(IndoorManipulatorDeviceDriver 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 getInflatable_shaft_size() { + return this.getOpcIntegerValue(item_inflatable_shaft_size); + } + + 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); + } + + public int getTo_putpoint() { + return this.getOpcIntegerValue(item_to_putpoint); + } + + public int getTo_new_getpoint() { + return (int) this.getOpcIntegerValue(item_to_new_getpoint); + } + + public int getTo_two_putpoint() { + return this.getOpcIntegerValue(item_to_two_putpoint); + } + + public int getTo_task_type() { + return this.getOpcIntegerValue(item_to_task_type); + } + + public int getTube_num() { + return this.getOpcIntegerValue(item_tube_num); + } + + public int getInflatableShaftVersion() { + return this.getOpcIntegerValue(item_inflatableShaftVersion); + } + + public int getIs_wrapped() { + return this.getOpcIntegerValue(item_is_wrapped); + } + + + 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")); + list.add(new ItemDto(item_inflatable_shaft_size, "气胀轴尺寸", "DB1.C1")); + 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.D1")); + list.add(new ItemDto(item_to_putpoint, "反馈放货点", "DB2.D2")); + list.add(new ItemDto(item_to_new_getpoint, "反馈新取货点", "DB2.D3")); + list.add(new ItemDto(item_to_two_putpoint, "反馈二次放货点", "DB2.D4")); + list.add(new ItemDto(item_to_task_type, "下发任务类型", "DB2.D5")); + list.add(new ItemDto(item_inflatableShaftVersion, "气胀轴代数", "DB2.D6")); + list.add(new ItemDto(item_tube_num, "套管数量", "DB2.D7")); + list.add(new ItemDto(item_is_wrapped, "是否套轴", "DB2.D8")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 745870ba0..c9a4b4fb0 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -383,7 +383,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //存在行架->暂存的AGV任务 需要过滤 // 6 行架任务 8烘箱任务 - if(!StrUtil.equals(taskDto.getTask_type(),"6") || StrUtil.equals(taskDto.getTask_type(),"8")){ + if(!StrUtil.equals(taskDto.getTask_type(),"6") && !StrUtil.equals(taskDto.getTask_type(),"8")){ taskDto = null; continue; } @@ -478,7 +478,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i taskDtoList = this.sortTask(taskDtoList); task = taskDtoList.get(j); // 6 行架任务 8烘箱任务 - if(!StrUtil.equals(task.getTask_type(),"6") || StrUtil.equals(task.getTask_type(),"8")){ + if(!StrUtil.equals(task.getTask_type(),"6") && !StrUtil.equals(task.getTask_type(),"8")){ task = null; continue; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java index fdabd5ac7..dd690e4e8 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/ItemProtocol.java @@ -4,6 +4,7 @@ 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 org.nl.acs.device_driver.basedriver.paper_tube_device2.PaperTubeConveyor2DeviceDriver; import java.util.ArrayList; import java.util.List; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java index 07e25a1dc..e0b5f3136 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device/PaperTubeConveyorDeviceDriver.java @@ -123,7 +123,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple } if (out_finish != last_out_finish) { if(out_finish == 1){ - this.writing(0); + //this.writing(0); this.writing("to_target","0"); this.writing("to_out_qty","0"); @@ -197,7 +197,7 @@ public class PaperTubeConveyorDeviceDriver extends AbstractOpcDeviceDriver imple itemMap.put(to_param, Integer.parseInt(param)); // itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); + //this.control(itemMap); logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java new file mode 100644 index 000000000..79da1956a --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/ItemProtocol.java @@ -0,0 +1,415 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.ss.formula.functions.T; +import org.jinterop.dcom.core.JIUnsignedInteger; +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_carrier_direction = "carrier_direction"; + //报警 + public static String item_error = "error"; + //任务号 + public static String item_task = "task"; + //出库顺序数组 + public static String item_out_seq_arr = "out_seq_arr"; + //出库数量数组 + public static String item_out_qty_arr = "out_qty_arr"; + //物料1 + public static String item_material1 = "material1"; + //物料2 + public static String item_material2 = "material2"; + //物料3 + public static String item_material3 = "material3"; + //物料4 + public static String item_material4 = "material4"; + //物料5 + public static String item_material5 = "material5"; + //物料6 + public static String item_material6 = "material6"; + //物料7 + public static String item_material7 = "material7"; + //物料8 + public static String item_material8 = "material8"; + //物料9 + public static String item_material9 = "material9"; + //物料10 + public static String item_material10 = "material10"; + //物料11 + public static String item_material11 = "material11"; + //物料12 + public static String item_material12 = "material12"; + //数量1 + public static String item_qty1 = "qty1"; + //数量2 + public static String item_qty2 = "qty2"; + //数量3 + public static String item_qty3 = "qty3"; + //数量4 + public static String item_qty4 = "qty4"; + //数量5 + public static String item_qty5 = "qty5"; + //数量6 + public static String item_qty6 = "qty6"; + //数量7 + public static String item_qty7 = "qty7"; + //数量8 + public static String item_qty8 = "qty8"; + //数量9 + public static String item_qty9 = "qty9"; + //数量10 + public static String item_qty10 = "qty10"; + //数量11 + public static String item_qty11 = "qty11"; + //数量12 + public static String item_qty12 = "qty12"; + + + //下发命令 + public static String item_to_command = "to_command"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + public static String item_to_material1 = "to_material1"; + public static String item_to_out_qty1 = "to_out_qty1"; + public static String item_to_seq1 = "to_seq1"; + public static String item_to_position1 = "to_position1"; + + public static String item_to_material2 = "to_material2"; + public static String item_to_out_qty2 = "to_out_qty2"; + public static String item_to_seq2 = "to_seq2"; + public static String item_to_position2 = "to_position2"; + + public static String item_to_material3 = "to_material3"; + public static String item_to_out_qty3 = "to_out_qty3"; + public static String item_to_seq3 = "to_seq3"; + public static String item_to_position3 = "to_position3"; + + + private PaperTubeConveyor2DeviceDriver driver; + + public ItemProtocol(PaperTubeConveyor2DeviceDriver driver) { + this.driver = driver; + } + + public String getTo_material1() { + return this.getOpcStringValue(item_to_material1); + } + public String getTo_material2() { + return this.getOpcStringValue(item_to_material2); + } + public String getTo_material3() { + return this.getOpcStringValue(item_to_material3); + } + + public int getTo_out_qty1() { + return this.getOpcIntegerValue(item_to_out_qty1); + } + public int getTo_out_qty2() { + return this.getOpcIntegerValue(item_to_out_qty2); + } + public int getTo_out_qty3() { + return this.getOpcIntegerValue(item_to_out_qty3); + } + + public int getTo_seq1() { + return this.getOpcIntegerValue(item_to_seq1); + } + public int getTo_seq2() { + return this.getOpcIntegerValue(item_to_seq2); + } + public int getTo_seq3() { + return this.getOpcIntegerValue(item_to_seq3); + } + + public int getTo_position1() { + return this.getOpcIntegerValue(item_to_position1); + } + public int getTo_position2() { + return this.getOpcIntegerValue(item_to_position2); + } + public int getTo_position3() { + return this.getOpcIntegerValue(item_to_position3); + } + + + 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 getCarrier_direction() { + return this.getOpcIntegerValue(item_carrier_direction); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public String getItem_out_seq_arr() { + return this.getOpcStringValue(item_out_seq_arr); + } + + public List getItem_out_seq_arr1() { + return this.getOpcArrayValue1(item_out_seq_arr); + } + + public int[] getItem_out_qty_arr() { + return this.getOpcArrayValue(item_out_qty_arr); + } + + + + public String getMaterial1() { + return this.getOpcStringValue(item_material1); + } + + public String getMaterial2() { + return this.getOpcStringValue(item_material2); + } + + public String getMaterial3() { + return this.getOpcStringValue(item_material3); + } + + public String getMaterial4() { + return this.getOpcStringValue(item_material4); + } + + public String getMaterial5() { + return this.getOpcStringValue(item_material5); + } + + public String getMaterial6() { + return this.getOpcStringValue(item_material6); + } + + public String getMaterial7() { + return this.getOpcStringValue(item_material7); + } + + public String getMaterial8() { + return this.getOpcStringValue(item_material8); + } + + public String getMaterial9() { + return this.getOpcStringValue(item_material9); + } + + public String getMaterial10() { + return this.getOpcStringValue(item_material10); + } + + public String getMaterial11() { + return this.getOpcStringValue(item_material11); + } + + public String getMaterial12() { + return this.getOpcStringValue(item_material12); + } + + + public int getQty1() { + return this.getOpcIntegerValue(item_qty1); + } + public int getQty2() { + return this.getOpcIntegerValue(item_qty2); + } + public int getQty3() { + return this.getOpcIntegerValue(item_qty3); + } + public int getQty4() { + return this.getOpcIntegerValue(item_qty4); + } + public int getQty5() { + return this.getOpcIntegerValue(item_qty5); + } + public int getQty6() { + return this.getOpcIntegerValue(item_qty6); + } + public int getQty7() { + return this.getOpcIntegerValue(item_qty7); + } + public int getQty8() { + return this.getOpcIntegerValue(item_qty8); + } + public int getQty9() { + return this.getOpcIntegerValue(item_qty9); + } + public int getQty10() { + return this.getOpcIntegerValue(item_qty10); + } + public int getQty11() { + return this.getOpcIntegerValue(item_qty11); + } + public int getQty12() { + return this.getOpcIntegerValue(item_qty12); + } + + + + + + + public int getTotarget() { + return this.getOpcIntegerValue(item_to_target); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + Boolean isonline; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + + } else { + return value; + } + return "0"; + } + + public int[] getOpcArrayValue(String protocol) { + int[] arrayValue = this.driver.getIntegeregerArrayValue(protocol); + if (ObjectUtil.isNull(arrayValue)) { + + } else { + return arrayValue; + } + return new int[3]; + } + + public int[] getJIUnsignedInteger(String protocol) { + int[] jiUnsignedIntegerArrayValue = this.driver.getJIUnsignedIntegerArrayValue(protocol); + if (ObjectUtil.isNull(jiUnsignedIntegerArrayValue)) { + + } else { + return jiUnsignedIntegerArrayValue; + } + return new int[3]; + } + + public List getOpcArrayValue1(String protocol) { + List arrayValue = this.driver.getArrayValue(protocol); + if (ObjectUtil.isNull(arrayValue)) { + + } else { + return arrayValue; + } + return new ArrayList(); + } + + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.W0")); + list.add(new ItemDto(item_mode, "工作模式", "DB101.W2")); + list.add(new ItemDto(item_move, "光电信号", "DB101.W3")); + list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.W4")); + list.add(new ItemDto(item_error, "报警", "DB101.W58")); + list.add(new ItemDto(item_task, "任务号", "DB101.W68")); + list.add(new ItemDto(item_out_seq_arr, "出库顺序数组", "DB101.W5")); + list.add(new ItemDto(item_out_qty_arr, "出库数量数组", "DB101.W6")); + list.add(new ItemDto(item_material1, "物料1", "DB101.W7")); + list.add(new ItemDto(item_qty1, "数量1", "DB101.W19")); + list.add(new ItemDto(item_material2, "物料2", "DB101.W8")); + list.add(new ItemDto(item_qty2, "数量2", "DB101.W20")); + list.add(new ItemDto(item_material3, "物料3", "DB101.W9")); + list.add(new ItemDto(item_qty3, "数量3", "DB101.W21")); + list.add(new ItemDto(item_material4, "物料4", "DB101.W10")); + list.add(new ItemDto(item_qty4, "数量4", "DB101.W22")); + list.add(new ItemDto(item_material5, "物料5", "DB101.W11")); + list.add(new ItemDto(item_qty5, "数量5", "DB101.W23")); + list.add(new ItemDto(item_material6, "物料6", "DB101.W12")); + list.add(new ItemDto(item_qty6, "数量6", "DB101.W24")); + list.add(new ItemDto(item_material7, "物料7", "DB101.W13")); + list.add(new ItemDto(item_qty7, "数量7", "DB101.W25")); + list.add(new ItemDto(item_material8, "物料8", "DB101.W14")); + list.add(new ItemDto(item_qty8, "数量8", "DB101.W26")); + list.add(new ItemDto(item_material9, "物料9", "DB101.W15")); + list.add(new ItemDto(item_qty9, "数量9", "DB101.W27")); + list.add(new ItemDto(item_material10, "物料10", "DB101.W16")); + list.add(new ItemDto(item_qty10, "数量10", "DB101.W28")); + list.add(new ItemDto(item_material11, "物料11", "DB101.W17")); + list.add(new ItemDto(item_qty11, "数量11", "DB101.W29")); + list.add(new ItemDto(item_material12, "物料12", "DB101.W18")); + list.add(new ItemDto(item_qty12, "数量12", "DB101.W30")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_target , "下发仓位号", "DB102.W2")); + list.add(new ItemDto(item_to_command, "下发命令", "DB102.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB102.W1")); + list.add(new ItemDto(item_to_material1, "下发物料1", "DB102.W3")); + list.add(new ItemDto(item_to_out_qty1, "下发物料1数量", "DB102.W7")); + list.add(new ItemDto(item_to_seq1, "出库顺序1", "DB102.W10")); + list.add(new ItemDto(item_to_position1, "仓位1", "DB102.W13")); + list.add(new ItemDto(item_to_material2, "下发物料2", "DB102.W5")); + list.add(new ItemDto(item_to_out_qty2, "下发物料2数量", "DB102.W8")); + list.add(new ItemDto(item_to_seq2, "出库顺序2", "DB102.W11")); + list.add(new ItemDto(item_to_position2, "仓位2", "DB102.W14")); + list.add(new ItemDto(item_to_material3, "下发物料3", "DB102.W6")); + list.add(new ItemDto(item_to_out_qty3, "下发物料3数量", "DB102.W9")); + list.add(new ItemDto(item_to_seq3, "出库顺序3", "DB102.W12")); + list.add(new ItemDto(item_to_position3, "仓位3", "DB102.W15")); + return list; + } + + @Override + public String toString() { + return ""; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java new file mode 100644 index 000000000..fad8e0cd6 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/Paper.java @@ -0,0 +1,19 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Paper implements Serializable { + //设备号 + private String device_code; + // + private String material_code; + private String qty; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java new file mode 100644 index 000000000..5ae32d885 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2Defination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +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.LinkedList; +import java.util.List; + +/** + * 油漆线 + */ +@Service +public class PaperTubeConveyor2Defination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "paper_tube_conveyor2"; + } + + @Override + public String getDriverName() { + return "纸管库2"; + } + + @Override + public String getDriverDescription() { + return "纸管库2"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PaperTubeConveyor2DeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class extends DeviceDriver> getDeviceDriverType() { + return PaperTubeConveyor2DeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return ItemProtocol.getReadableItemDtos(); + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java new file mode 100644 index 000000000..b522eb139 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/paper_tube_device2/PaperTubeConveyor2DeviceDriver.java @@ -0,0 +1,912 @@ +package org.nl.acs.device_driver.basedriver.paper_tube_device2; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSON; +import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.jinterop.dcom.core.JIUnsignedInteger; +import org.nl.acs.agv.server.AgvService; +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.ext.wms.data.ApplyPaperActionRequest; +import org.nl.acs.ext.wms.data.ApplyPaperActionResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.dto.DeviceErrorLogDto; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +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.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +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.service.ParamService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +/** + * 纸管库 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class PaperTubeConveyor2DeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); + @Autowired + DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); + @Autowired + TaskService taskserver = SpringContextHolder.getBean(TaskService.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamService.class); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class); + @Autowired + AgvService agvService = SpringContextHolder.getBean(AgvService.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + + private Date instruction_update_time = new Date(); + private Date require_apply_strangulation_time = new Date(); + private int instruction_update_time_out = 500; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + private Date instruction_apply_time = new Date(); + private int instruction_require_time_out = 3000; + + //心跳 + int heartbeat = 0; + int last_heartbeat = 0; + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //托盘方向 + int carrier_direction = 0; + int last_carrier_direction = 0; + //报警 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + + int inventory_qty = 0; + int out_finish = 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; + //出库顺序数组 + String item_out_seq_arr = null; + String last_item_out_seq_arr = null; + //出库数量数组 + int[] item_out_qty_arr = null; + int[] last_item_out_qty_arr = null; + + + String item_material1 = null; + String last_item_material1 = null; + String item_material2 = null; + String last_item_material2 = null; + String item_material3 = null; + String last_item_material3 = null; + String item_material4 = null; + String last_item_material4 = null; + String item_material5 = null; + String last_item_material5 = null; + String item_material6 = null; + String last_item_material6 = null; + String item_material7 = null; + String last_item_material7 = null; + String item_material8 = null; + String last_item_material8 = null; + String item_material9 = null; + String last_item_material9 = null; + String item_material10 = null; + String last_item_material10 = null; + String item_material11 = null; + String last_item_material11 = null; + String item_material12 = null; + String last_item_material12 = null; + + int item_qty1 = 0; + int last_item_qty1 = 0; + int item_qty2 = 0; + int last_item_qty2 = 0; + int item_qty3 = 0; + int last_item_qty3 = 0; + int item_qty4 = 0; + int last_item_qty4 = 0; + int item_qty5 = 0; + int last_item_qty5 = 0; + int item_qty6 = 0; + int last_item_qty6 = 0; + int item_qty7 = 0; + int last_item_qty7 = 0; + int item_qty8 = 0; + int last_item_qty8 = 0; + int item_qty9 = 0; + int last_item_qty9 = 0; + int item_qty10 = 0; + int last_item_qty10 = 0; + int item_qty11 = 0; + int last_item_qty11 = 0; + int item_qty12 = 0; + int last_item_qty12 = 0; + + String item_to_material1 = null; + String last_item_to_material1 = null; + String item_to_material2 = null; + String last_item_to_material2 = null; + String item_to_material3 = null; + String last_item_to_material3 = null; + + int item_to_out_qty1 = 0; + int last_item_to_out_qty1 = 0; + int item_to_out_qty2 = 0; + int last_item_to_out_qty2 = 0; + int item_to_out_qty3 = 0; + int last_item_to_out_qty3 = 0; + + int item_to_seq1 = 0; + int last_item_to_seq1 = 0; + int item_to_seq2 = 0; + int last_item_to_seq2 = 0; + int item_to_seq3 = 0; + int last_item_to_seq3 = 0; + + int item_to_position1 = 0; + int last_item_to_position1 = 0; + int item_to_position2 = 0; + int last_item_to_position2 = 0; + int item_to_position3 = 0; + int last_item_to_position3 = 0; + + + //当前指令 + Instruction inst = null; + + String material = null; + + Boolean isonline = true; + + Boolean iserror = false; + + //1-执行任务;2-取货完成;3-放货完成; + int flag; + + + int last_inventory_qty = 0; + int last_out_finish = 0; + + String last_material = null; + String message = null; + String device_code; + String task_code = null; + String vehicle_code; + String inst_message; + + @Override + public Device getDevice() { + return this.device; + } + + //请求成功标记 + Boolean requireSucess = false; + + @Override + public void execute() { + try { + device_code = this.getDeviceCode(); + heartbeat = this.itemProtocol.getHeartbeat(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + carrier_direction = this.itemProtocol.getCarrier_direction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTotarget(); + to_task = this.itemProtocol.getTo_task(); + item_out_seq_arr = this.itemProtocol.getItem_out_seq_arr(); + item_out_qty_arr = this.itemProtocol.getItem_out_qty_arr(); + item_material1 = this.itemProtocol.getMaterial1(); + item_material2 = this.itemProtocol.getMaterial2(); + item_material3 = this.itemProtocol.getMaterial3(); + item_material4 = this.itemProtocol.getMaterial4(); + item_material5 = this.itemProtocol.getMaterial5(); + item_material6 = this.itemProtocol.getMaterial6(); + item_material7 = this.itemProtocol.getMaterial7(); + item_material8 = this.itemProtocol.getMaterial8(); + item_material9 = this.itemProtocol.getMaterial9(); + item_material10 = this.itemProtocol.getMaterial10(); + item_material11 = this.itemProtocol.getMaterial11(); + item_material12 = this.itemProtocol.getMaterial12(); + item_qty1 = this.itemProtocol.getQty1(); + item_qty2 = this.itemProtocol.getQty2(); + item_qty3 = this.itemProtocol.getQty3(); + item_qty4 = this.itemProtocol.getQty4(); + item_qty5 = this.itemProtocol.getQty5(); + item_qty6 = this.itemProtocol.getQty6(); + item_qty7 = this.itemProtocol.getQty7(); + item_qty8 = this.itemProtocol.getQty8(); + item_qty9 = this.itemProtocol.getQty9(); + item_qty10 = this.itemProtocol.getQty10(); + item_qty11 = this.itemProtocol.getQty11(); + item_qty12 = this.itemProtocol.getQty12(); + item_to_material1 = this.itemProtocol.getTo_material1(); + item_to_material2 = this.itemProtocol.getTo_material2(); + item_to_material3 = this.itemProtocol.getTo_material3(); + item_to_out_qty1 = this.itemProtocol.getTo_out_qty1(); + item_to_out_qty2 = this.itemProtocol.getTo_out_qty2(); + item_to_out_qty3 = this.itemProtocol.getTo_out_qty3(); + item_to_seq1 = this.itemProtocol.getTo_seq1(); + item_to_seq2 = this.itemProtocol.getTo_seq2(); + item_to_seq3 = this.itemProtocol.getTo_seq3(); + item_to_position1 = this.itemProtocol.getTo_position1(); + item_to_position2 = this.itemProtocol.getTo_position2(); + item_to_position3 = this.itemProtocol.getTo_position3(); + + + //信号位置校验,记录日志 + signal_verification(); + + if (mode != last_mode) { + JSONObject param = new JSONObject(); + param.put("device_code", this.device_code); + param.put("mode", Math.min(mode, 3)); + param.put("device_name", this.getDevice().getDevice_name()); + param.put("device_type", "1"); + param.put("product_area", paramService.findByCode("productArea").getValue()); + acsToWmsService.sendDeviceStatus(param); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess); + 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 (carrier_direction != last_carrier_direction) { + logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction); + } + if (error != last_error) { + if (error != 0) { + DeviceErrorLogDto dto = new DeviceErrorLogDto(); + dto.setDevice_code(device_code); + dto.setError_code(String.valueOf(error)); + String errorInfo = ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)); + dto.setError_info(errorInfo); + deviceErrorLogService.create(dto); + } + 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 (move != 0 && task > 0) { + update_instruction_status(); + } + + } catch (Exception var17) { + var17.printStackTrace(); + 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; + + //纸管库申请任务 + switch (mode) { + case 1: + log.debug("弃用(留作兼容)"); + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + instruction_require(); + } + break; + case 3: + log.info("运行中"); + break; + case 4: + //申请出货 + if (move == 1 && !requireSucess) { + request_for_shipment(String.valueOf(mode), item_out_seq_arr, item_out_qty_arr); + } + break; + default: + break; + } + } + last_heartbeat = heartbeat; + last_mode = mode; + last_move = move; + last_error = error; + last_carrier_direction = carrier_direction; + last_task = task; + last_to_command = to_command; + last_to_target = to_target; + last_to_task = to_task; + last_item_out_seq_arr = item_out_seq_arr; + last_item_out_qty_arr = item_out_qty_arr; + last_item_material1 = item_material1; + last_item_material2 = item_material2; + last_item_material3 = item_material3; + last_item_material4 = item_material4; + last_item_material5 = item_material5; + last_item_material6 = item_material6; + last_item_material7 = item_material7; + last_item_material8 = item_material8; + last_item_material9 = item_material9; + last_item_material10 = item_material10; + last_item_material11 = item_material11; + last_item_material12 = item_material12; + last_item_qty1 = item_qty1; + last_item_qty2 = item_qty2; + last_item_qty3 = item_qty3; + last_item_qty4 = item_qty4; + last_item_qty5 = item_qty5; + last_item_qty6 = item_qty6; + last_item_qty7 = item_qty7; + last_item_qty8 = item_qty8; + last_item_qty9 = item_qty9; + last_item_qty10 = item_qty10; + last_item_qty11 = item_qty11; + last_item_qty12 = item_qty12; + last_item_to_material1 = item_to_material1; + last_item_to_material2 = item_to_material2; + last_item_to_material3 = item_to_material3; + last_item_to_out_qty1 = item_to_out_qty1; + last_item_to_out_qty2 = item_to_out_qty2; + last_item_to_out_qty3 = item_to_out_qty3; + last_item_to_seq1 = item_to_seq1; + last_item_to_seq2 = item_to_seq2; + last_item_to_seq3 = item_to_seq3; + last_item_to_position1 = item_to_position1; + last_item_to_position2 = item_to_position2; + last_item_to_position3 = item_to_position3; + + } + + + 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.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; + + Map itemMap = new HashMap(); + this.control(itemMap); + } + + + public void writing(List list) { + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try { + this.checkcontrol(itemMap); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + } + + 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 synchronized void request_for_shipment(String mode, String item_out_seq_arr, int[] item_out_qty_arr) { + Date date = new Date(); + if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + } else { + this.require_apply_strangulation_time = date; + ApplyPaperActionRequest applyPaperActionRequest = new ApplyPaperActionRequest(); + applyPaperActionRequest.setDevice_code(this.device_code); + applyPaperActionRequest.setType("1"); + applyPaperActionRequest.setTask_code(String.valueOf(task)); + //获取出库顺序 + boolean contains = item_out_seq_arr.contains(","); + boolean contains1 = item_out_seq_arr.contains(","); + + if (contains) { + String[] split = item_out_seq_arr.split(","); + applyPaperActionRequest.setMaterial1(split[0]); + applyPaperActionRequest.setMaterial1(split[1]); + } else if (contains1) { + String[] split = item_out_seq_arr.split(","); + applyPaperActionRequest.setMaterial1(split[0]); + applyPaperActionRequest.setMaterial1(split[1]); + } else { + applyPaperActionRequest.setMaterial1(item_out_seq_arr); + } + if (item_out_qty_arr.length >= 1 && item_out_qty_arr.length < 4) { + applyPaperActionRequest.setQty1(String.valueOf(item_out_qty_arr[0])); + applyPaperActionRequest.setQty2(String.valueOf(item_out_qty_arr[1])); + } + ApplyPaperActionResponse applyPaperActionResponse = acsToWmsService.applyPaperActionRequest(applyPaperActionRequest); + if (ObjectUtil.isNull(applyPaperActionResponse)) { + message = "请求失败"; + requireSucess = false; + return; + } + Map map3 = new HashMap(); + if (applyPaperActionResponse.getstatus() == 200) { + map3.put("to_command", "4"); + this.writing(map3); + requireSucess = true; + logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); + message = "申请出货成功"; + } else { + message = applyPaperActionResponse.getMessage(); + map3.put("to_command", "5"); + this.writing(map3); + requireSucess = false; + message = "出库顺序错误"; + logServer.deviceExecuteLog(this.device_code, "", "", "申请出纸管,返回参数:" + applyPaperActionResponse); + } + } + } + + + /** + * 申请任务 + */ + public synchronized Boolean instruction_require() { + 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; + //查找有没有对应的指令 + //找指令类型是10的 + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isNotNull(inst) && "10".equals(inst.getInstruction_type())) { + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + TaskDto taskDto = taskserver.findByCodeFromCache(inst.getTask_code()); + List paperArray = getPaperArray(taskDto.getPaper_array()); + if (ObjectUtil.isEmpty(inst)) { + return false; + } + Map map = new HashMap(); + if (paperArray.size() == 1) { + writeStatus(paperArray, map, 1); + } else if (paperArray.size() == 2) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + } else if (paperArray.size() == 3) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + writeStatus(paperArray, map, 3); + } + writeData(next_addr, inst, map); + this.writing(map); + requireSucess = true; + return true; + } else { + //判断是否有相同起点的,任务状态就绪的任务 + //任务类型是10 + TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code); + if (ObjectUtil.isNull(taskdto)) { + return false; + } + List paperArray = getPaperArray(taskdto.getPaper_array()); + if (ObjectUtil.isNotNull(taskdto) && "10".equals(taskdto.getTask_type())) { + //判断指令的起点和当前的设备号相同 + if (!taskdto.getStart_device_code().equals(device_code)) { + return false; + } + //判断当前任务号是否存在指令 + Instruction inst1 = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()); + /*if(ObjectUtil.isNotNull(inst1)){ + Device nextdevice = deviceAppservice.findDeviceByCode(inst1.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + Device pointdevice = deviceAppservice.findDeviceByCode(inst1.getNext_point_code()); + String point_addr = pointdevice.getExtraValue().get("address").toString(); + }*/ + //没有就创建指令 + String taskid = taskdto.getTask_id(); + String taskcode = taskdto.getTask_code(); + String priority = taskdto.getPriority(); + String start_point_code = taskdto.getStart_point_code(); + String start_device_code = taskdto.getStart_device_code(); + String route_plan_code = taskdto.getRoute_plan_code(); + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(route_plan_code); + instdto.setRemark(taskdto.getRemark()); + instdto.setMaterial(taskdto.getMaterial()); + instdto.setQuantity(taskdto.getQuantity()); + instdto.setTask_id(taskid); + instdto.setTask_code(taskcode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by("auto"); + instdto.setStart_device_code(start_device_code); + instdto.setNext_device_code(taskdto.getNext_device_code()); + instdto.setStart_point_code(start_point_code); + instdto.setNext_point_code(taskdto.getNext_point_code()); + instdto.setPriority(priority); + instdto.setInstruction_status("0"); + instdto.setExecute_device_code(start_point_code); + try { + instructionService.create(instdto); + } catch (Exception e) { + e.printStackTrace(); + log.error("指令创建失败!", e.getMessage()); + return false; + } + taskdto.setTask_status("1"); + taskserver.update(taskdto); + requireSucess = true; + Map map = new HashMap(); + if (paperArray.size() == 1) { + writeStatus(paperArray, map, 1); + } else if (paperArray.size() == 2) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + } else if (paperArray.size() == 3) { + writeStatus(paperArray, map, 1); + writeStatus(paperArray, map, 2); + writeStatus(paperArray, map, 3); + } + writeData(taskdto.getNext_device_code(), instdto, map); + this.writing(map); + requireSucess = true; + return true; + } + //并且指令的起点和当前的设备号相同 + //找到就要下发数据 + //查找就绪状态的任务 + //并且任务的起点和当前的设备号相同 + //找到创建指令 + //入库顺序 + } + return false; + } + } + + public void writeData(String next_addr, Instruction instdto, Map map) { + map.put("to_target", next_addr); + map.put("to_task", instdto.getInstruction_code()); + map.put("to_command", "1"); + } + + public String getToParam() { + return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; + } + + public void writeStatus(List paperArray, Map map, Integer status) { + Paper paper = paperArray.get(status - 1); + map.put("to_material" + status, paper.getMaterial_code()); + map.put("to_out_qty" + status, paper.getQty()); + map.put("to_seq" + status, status); + Device nextdevice = deviceAppservice.findDeviceByCode(paper.getDevice_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + map.put("to_position" + status, next_addr); + } + + + public void writing(String key, String param) { + + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + //String opcservcerid = this.getDevice().getOpc_server_id(); + //Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + + itemMap.put(to_param, Integer.parseInt(param)); + //itemMap.put(to_param, Integer.parseInt(value)); + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + param); + } + + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + + if (this.getMode() == 0) { + mode = "未联机"; + } else if (this.getMode() == 1) { + mode = "单机"; + } else if (this.getMode() == 2) { + mode = "联机"; + } else if (this.getMode() == 3) { + mode = "入库中"; + } else if (this.getMode() == 4) { + mode = "出库中"; + } + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); + jo.put("inventory_qty", inventory_qty); + jo.put("out_finish", out_finish); + jo.put("material", material); + jo.put("isOnline", this.getIsonline()); + + return jo; + } + + /** + * 解析出库的顺序 + */ + public List getPaperArray(String paper_array) { + List papers = JSONUtil.toList(paper_array, Paper.class); + return papers; + } + + + /** + * 更新指令状态 + */ + public synchronized void update_instruction_status() throws Exception { + 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; + inst = checkInst(); + if (inst != null) { + //a点到b点,给状态说允许取货 + if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { + inst.setInstruction_status("1"); + inst.setExecute_device_code(this.device_code); + instructionService.update(inst); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task); + } + //当货物到达b点,实现完成指令 + if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0")) { + if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { + inst.setExecute_device_code(this.device_code); + finish_instruction(); + logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task); + } + } + } + } + } + + 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; + } + + private void signal_verification() { + if (!item_out_seq_arr.equals(last_item_out_seq_arr)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号item_out_seq_arr:" + last_item_out_seq_arr + "->" + item_out_seq_arr); + } + if (!arrayEquals(item_out_qty_arr, last_item_out_qty_arr)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号item_out_qty_arr:" + Arrays.toString(last_item_out_qty_arr) + "->" + Arrays.toString(item_out_qty_arr)); + } + if (item_qty1 != (last_item_qty1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty1:" + last_item_qty1 + "->" + item_qty1); + } + if (item_qty2 != (last_item_qty2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty2:" + last_item_qty2 + "->" + item_qty2); + } + if (item_qty3 != (last_item_qty3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty3:" + last_item_qty3 + "->" + item_qty3); + } + if (item_qty4 != (last_item_qty4)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty4:" + last_item_qty4 + "->" + item_qty4); + } + if (item_qty5 != (last_item_qty5)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty5:" + last_item_qty5 + "->" + item_qty5); + } + if (item_qty6 != (last_item_qty6)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty6:" + last_item_qty6 + "->" + item_qty6); + } + if (item_qty7 != (last_item_qty7)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty7:" + last_item_qty7 + "->" + item_qty7); + } + if (item_qty8 != (last_item_qty8)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty8:" + last_item_qty8 + "->" + item_qty8); + } + if (item_qty9 != (last_item_qty9)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty9:" + last_item_qty9 + "->" + item_qty9); + } + if (item_qty10 != (last_item_qty10)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty10:" + last_item_qty10 + "->" + item_qty10); + } + if (item_qty11 != (last_item_qty11)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty11:" + last_item_qty11 + "->" + item_qty11); + } + if (item_qty12 != (last_item_qty12)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号qty12:" + last_item_qty12 + "->" + item_qty12); + } + if (item_material1.equals(last_item_material1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material1:" + last_item_material1 + "->" + item_material1); + } + if (!item_material2.equals(last_item_material2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material2:" + last_item_material2 + "->" + item_material2); + } + if (!item_material3.equals(last_item_material3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material3:" + last_item_material3 + "->" + item_material3); + } + if (!item_material4.equals(last_item_material4)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material4:" + last_item_material4 + "->" + item_material4); + } + if (!item_material5.equals(last_item_material5)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material5:" + last_item_material5 + "->" + item_material5); + } + if (!item_material6.equals(last_item_material6)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material6:" + last_item_material6 + "->" + item_material6); + } + if (!item_material7.equals(last_item_material7)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material7:" + last_item_material7 + "->" + item_material7); + } + if (!item_material8.equals(last_item_material8)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material8:" + last_item_material8 + "->" + item_material8); + } + if (!item_material9.equals(last_item_material9)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material9:" + last_item_material9 + "->" + item_material9); + } + if (!item_material10.equals(last_item_material10)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material10:" + last_item_material10 + "->" + item_material10); + } + if (!item_material11.equals(last_item_material11)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material11:" + last_item_material11 + "->" + item_material11); + } + if (!item_material12.equals(last_item_material12)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号material12:" + last_item_material12 + "->" + item_material12); + } + 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 (!item_to_material1.equals(last_item_to_material1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material1:" + last_item_to_material1 + "->" + item_to_material1); + } + if (!item_to_material2.equals(last_item_to_material2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material2:" + last_item_to_material2 + "->" + item_to_material2); + } + if (!item_to_material3.equals(last_item_to_material3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_material3:" + last_item_to_material2 + "->" + item_to_material2); + } + if (item_to_out_qty1 != (last_item_to_out_qty1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty1:" + last_item_to_out_qty1 + "->" + item_to_out_qty1); + } + if (item_to_out_qty2 != (last_item_to_out_qty2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty2:" + last_item_to_out_qty2 + "->" + item_to_out_qty2); + } + if (item_to_out_qty3 != (last_item_to_out_qty3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_out_qty3:" + last_item_to_out_qty3 + "->" + item_to_out_qty3); + } + if (item_to_seq1 != (last_item_to_seq1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq1:" + last_item_to_seq1 + "->" + item_to_seq1); + } + if (item_to_seq2 != (last_item_to_seq2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq2:" + last_item_to_seq2 + "->" + item_to_seq2); + } + if (item_to_seq3 != (last_item_to_seq3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq3:" + last_item_to_seq3 + "->" + item_to_seq3); + } + if (item_to_position1 != (last_item_to_position1)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position1:" + last_item_to_position1 + "->" + item_to_position1); + } + if (item_to_position2 != (last_item_to_position2)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position2:" + last_item_to_position2 + "->" + item_to_position2); + } + if (item_to_position3 != (last_item_to_position3)) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号to_position3:" + last_item_to_position3 + "->" + item_to_position3); + } + + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + public static boolean arrayEquals(int[] a, int[] b) { + // 判断两个数组长度是否相等 + if (a.length != b.length) { + return false; + } + // 判断两个数组对应位置上的元素是否相同 + for (int i = 0; i < a.length; i++) { + if (a[i] != b[i]) { + return false; + } + } + return true; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/ItemProtocol.java new file mode 100644 index 000000000..df30a3944 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/ItemProtocol.java @@ -0,0 +1,88 @@ +package org.nl.acs.device_driver.basedriver.plugging_unplugging_machine; + +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_error = "error"; + public static String item_task = "task"; + public static String item_to_command = "to_command"; + + private PluggingUnpluggingMachineDeviceDriver driver; + + public ItemProtocol(PluggingUnpluggingMachineDeviceDriver 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 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 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, "心跳", "DB600.B0")); + list.add(new ItemDto(item_mode, "工作状态", "DB600.B2")); + list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); + list.add(new ItemDto(item_error, "报警信号", "DB600.B5")); + list.add(new ItemDto(item_task, "任务号", "DB600.D6")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2")); + return list; + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDefination.java new file mode 100644 index 000000000..e38405519 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDefination.java @@ -0,0 +1,61 @@ +package org.nl.acs.device_driver.basedriver.plugging_unplugging_machine; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_inspect_site.ItemProtocol; +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.LinkedList; +import java.util.List; + +/** + * 插拔轴机驱动定义 + * 说明:该站点为插拔轴机 + */ +@Service +public class PluggingUnpluggingMachineDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "plugging_unplugging_machine"; + } + + @Override + public String getDriverName() { + return "插拔轴机"; + } + + @Override + public String getDriverDescription() { + return "插拔轴机"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new PluggingUnpluggingMachineDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class extends DeviceDriver> getDeviceDriverType() { + return PluggingUnpluggingMachineDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.conveyor); + return types; + } + + @Override + public List getReadableItemDtos() { + return org.nl.acs.device_driver.basedriver.standard_inspect_site.ItemProtocol.getReadableItemDtos(); + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java new file mode 100644 index 000000000..2b2e081aa --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/plugging_unplugging_machine/PluggingUnpluggingMachineDeviceDriver.java @@ -0,0 +1,280 @@ +package org.nl.acs.device_driver.basedriver.plugging_unplugging_machine; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +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.ext.wms.data.ApplyManipulatorActionRequest; +import org.nl.acs.ext.wms.data.ApplyManipulatorActionResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +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.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.modules.system.service.ParamService; +import org.nl.modules.system.service.impl.ParamServiceImpl; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.*; + +@Slf4j +@Data +@RequiredArgsConstructor +public class PluggingUnpluggingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + 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"); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + @Autowired + ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); + + + 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; + + Boolean iserror = false; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + //1-执行任务;2-取货完成;3-放货完成; + int flag; + + String device_code; + + String message = null; + + @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(); + + if (mode != last_mode) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记"); + } + if (move != last_move) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + + } catch (Exception var17) { + + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有报警"; + } + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + break; + case 3: + break; + case 4: + if (!requireSucess) { + feedback(); + } + break; + case 5: + if (!requireSucess) { + feedback1(); + } + break; + } + + } + last_mode = mode; + last_error = error; + last_move = move; + last_task = task; + } + + private synchronized void feedback1() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; + applyManipulatorActionRequest.setType("7"); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + + Map map = new LinkedHashMap<>(); + map.put("to_command", "5"); + requireSucess = true; + } else { + requireSucess = true; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } + } + + private synchronized void feedback() { + ApplyManipulatorActionRequest applyManipulatorActionRequest = new ApplyManipulatorActionRequest(); + ApplyManipulatorActionResponse applyManipulatorActionResponse; + applyManipulatorActionRequest.setType("6"); + applyManipulatorActionResponse = acsToWmsService.applyManipulatorActionRequest(applyManipulatorActionRequest); + if (applyManipulatorActionResponse.getstatus() == 200) { + + Map map = new LinkedHashMap<>(); + map.put("to_command", "4"); + requireSucess = true; + } else { + requireSucess = true; + message = "完成反馈LMS失败," + String.valueOf(applyManipulatorActionResponse); + logServer.deviceExecuteLog(this.device_code, "", "", "反馈完成请求失败,响应参数:" + JSON.toJSONString(applyManipulatorActionResponse)); + } + } + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + public void writing(List list) { + + //String opcservcerid = this.getDevice().getOpc_server_id(); +//Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + for (int i = 0; i < list.size(); i++) { + Object ob = list.get(i); + JSONObject json = (JSONObject) JSONObject.toJSON(ob); + if (!StrUtil.isEmpty(json.getString("value"))) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + json.getString("code"); + itemMap.put(to_param, json.getString("value")); + } + } + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); + this.control(itemMap); + } + + //将扩展表中的字符串数据转换成集合 + public List getExtraDeviceCodes(String extraName) { + String extraValue = (String) this.getDevice().getExtraValue().get(extraName); + if (StrUtil.isEmpty(extraValue)) { + return new ArrayList<>(); + } + String devicesString = extraValue.substring(1, extraValue.length() - 1); + List devicesList = new ArrayList<>(); + String[] devices = devicesString.split(","); + for (int i = 0; i < devices.length; i++) { + String s = devices[i].replace("\"", "").replace("\"", ""); + devicesList.add(s); + } + return devicesList; + } + + + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String action = ""; + String move = ""; + 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 = "无货"; + jo.put("hasGoods", false); + } else if (this.getMove() == 1) { + move = "有货"; + jo.put("hasGoods", true); + } else if (this.getMove() == 2) { + move = "有托盘有货"; + jo.put("hasGoods", true); + } + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("isOnline", this.getIsonline()); + jo.put("isError", this.getIserror()); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + public void writing(String param, String value) { + String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + param; + Map itemMap = new HashMap(); + itemMap.put(to_param, Integer.parseInt(value)); + + this.control(itemMap); + logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value); + } + + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java index 4b31e481c..23a9448d5 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java @@ -393,6 +393,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe last_error = error; last_move = move; last_task = task; + last_height = height; last_plcbarcode_length = plcbarcode_length; last_plcbarcode = plcbarcode; last_weight = weight; @@ -936,8 +937,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe + "." + param; Map itemMap = new HashMap(); itemMap.put(to_param, Integer.parseInt(value)); - this.control(itemMap); - + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } } // 申请贴标 @@ -1017,6 +1026,21 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } else { message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage(); logServer.deviceExecuteLog(this.device_code, "", "", "申请贴标,返回参数:" + JSON.toJSONString(applyLabelingAndBindingResponse)); + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", "1011"); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_command"); + map2.put("value", "1"); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_task"); + map3.put("value", "0"); + list.add(map3); + this.writing(list); + requireSucess = true; } } @@ -1034,7 +1058,16 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe } } logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap); - this.control(itemMap); + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + try{ + this.checkcontrol(itemMap); + } catch (Exception e1){ + e1.printStackTrace(); + } + } } @Override diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java index 04f4baedb..b51132023 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java @@ -4,6 +4,7 @@ package org.nl.acs.device_driver.driver; import cn.hutool.core.util.ObjectUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import org.jinterop.dcom.core.JIUnsignedInteger; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.opc.Device; import org.nl.acs.opc.OpcItemDto; @@ -77,10 +78,30 @@ public interface OpcDeviceDriver extends DeviceDriver { return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol)); } + + default int[] getJIUnsignedIntegerArrayValue(String protocol) { + JIUnsignedInteger[] jiUnsignedIntegers = (JIUnsignedInteger[]) this.getOpcValueAccessor().getValue(this.getItem(protocol)); + if(ObjectUtil.isNull(jiUnsignedIntegers)){ + return new int[3]; + } + // 将 JIUnsignedInteger[] 转换为 int[] + int[] intArray = new int[jiUnsignedIntegers.length]; + for (int i = 0; i < jiUnsignedIntegers.length; i++) { + intArray[i] = jiUnsignedIntegers[i].getValue().intValue(); + } + + return intArray; + } + default String getStringValue(String protocol) { return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol)); } + default List getArrayValue(String protocol) { + return (List) this.getOpcValueAccessor().getValue(this.getItem(protocol)); + } + + default Object getValue(String protocol) { return this.getOpcValueAccessor().getValue(this.getItem(protocol)); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java new file mode 100644 index 000000000..4fec7dd92 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionRequest.java @@ -0,0 +1,30 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +@Data +public class ApplyManipulatorActionRequest extends BaseRequest { + private String vehicle_code; + private String device_code; + /** + * 2-尺寸交互反馈,反馈任务类型 + * 3-反馈新放货点 + * 4-反馈新取货点 + * 5-反馈二次放货点 + * 6-套轴申请 + * 7-套轴完成 + */ + private String type; + + /** + * 任务号 + */ + private String task_code; + + /** + * 气胀轴尺寸 3/6寸 + */ + private String size; + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java new file mode 100644 index 000000000..be4283be7 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyManipulatorActionResponse.java @@ -0,0 +1,48 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ApplyManipulatorActionResponse extends BaseResponse { + + private Map data = new HashMap(); + + /** + * 放货点 + */ + private String put_device_code; + + /** + * 取货点 + */ + private String get_device_code; + + /** + * 二次放货点 + */ + private String put_device_code2; + + /** + * 下发的指令类型 + */ + private String detail_type; + + /** + * 气胀轴代数 + */ + private String version; + + /** + * 套管数量 + */ + private String bushing_num; + + /** + * 是否套管 + */ + private String is_bushing; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java new file mode 100644 index 000000000..c289be887 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionRequest.java @@ -0,0 +1,42 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +@Data +public class ApplyPaperActionRequest extends BaseRequest { + + private String device_code; + + /** + * 1 纸管库出库申请 + * 2 套管请求 + */ + private String type; + + /** + * 任务号:输送任务号 + */ + private String task_code; + + + /** + * 出库物料1 + */ + private String material1; + + /** + * 出库物料2 + */ + private String material2; + + /** + * 出库物料数量1 + */ + private String qty1; + + /** + * 出库物料数量2 + */ + private String qty2; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java new file mode 100644 index 000000000..71cd02ae2 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/ApplyPaperActionResponse.java @@ -0,0 +1,14 @@ +package org.nl.acs.ext.wms.data; + +import lombok.Data; + +import java.util.HashMap; +import java.util.Map; + +@Data +public class ApplyPaperActionResponse extends BaseResponse { + + private Map data = new HashMap(); + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java index d9b4cb330..226fb0a07 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/data/CreateTaskRequest.java @@ -1,7 +1,9 @@ package org.nl.acs.ext.wms.data; import lombok.Data; +import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper; +import java.util.List; import java.util.Map; @Data @@ -120,4 +122,6 @@ public class CreateTaskRequest extends BaseRequest { */ Map params; + private List paper_array; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java index 35965e4a6..41b51958b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java @@ -9,6 +9,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest; +import org.nl.acs.ext.wms.data.ApplyManipulatorActionRequest; import org.nl.acs.ext.wms.data.LiKuApplyTaskRequest; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.modules.logging.InterfaceLogType; @@ -99,6 +100,13 @@ public class AcsToWmsController { return new ResponseEntity<>(acstowmsService.applyLabelingAndBindingRequest(param), HttpStatus.OK); } + @PostMapping("/applyManipulatorActionRequest") + @Log(value = "申请行架任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS) + @ApiOperation("申请行架任务") + public ResponseEntity applyManipulatorActionRequest(@RequestBody ApplyManipulatorActionRequest param) { + return new ResponseEntity<>(acstowmsService.applyManipulatorActionRequest(param), HttpStatus.OK); + } + @PostMapping("/liKuApplyTaskRequest") @Log(value = "立库申请任务",isInterfaceLog = true,interfaceLogType= InterfaceLogType.ACS_TO_LMS) @ApiOperation("立库申请任务") diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 8fab0c4a7..e7765a03e 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -98,6 +98,13 @@ public interface AcsToWmsService { */ ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param); + /** + * 申请出纸管,套纸管 + * @param param + * @return + */ + ApplyPaperActionResponse applyPaperActionRequest(ApplyPaperActionRequest param); + LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest liKuApplyTaskRequest); UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest updateLKTaskRequest); @@ -106,4 +113,6 @@ public interface AcsToWmsService { HttpResponse shipDeviceUpdate(JSONObject param); void sendDeviceStatus(JSONObject param); + + ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 69a717c7f..1715b5d6a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -414,6 +414,40 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { return null; } + @Override + public ApplyManipulatorActionResponse applyManipulatorActionRequest(ApplyManipulatorActionRequest param) { + try { + MDC.put(log_file_type, log_type); + ApplyManipulatorActionResponse applyManipulatorActionResponse = new ApplyManipulatorActionResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyManipulatorAction"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("ApplyManipulatorActionRequest----请求参数{}", param); + try { +// String result = ""; + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("ApplyManipulatorActionResponse----返回参数{}", result); + applyManipulatorActionResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, ApplyManipulatorActionResponse.class); + } + } + return applyManipulatorActionResponse; + } finally { + MDC.remove(log_file_type); + } + + + } + @Override public ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param) { try { @@ -444,10 +478,45 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } finally { MDC.remove(log_file_type); } - - } + @Override + public ApplyPaperActionResponse applyPaperActionRequest(ApplyPaperActionRequest param) { + try { + MDC.put(log_file_type, log_type); + ApplyPaperActionResponse applyPaperActionResponse = new ApplyPaperActionResponse(); + if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("applyPaperAction"); + if(ObjectUtil.isNull(addressDto)){ + return null; + } + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + log.info("ApplyPaperActionRequest----请求参数{}", param); + try { +// String result = ""; + String result = HttpRequest.post(url) + .body(JSON.toJSONString(param)) + .execute().body(); + JSONObject jsonObject = JSONObject.parseObject(result); + log.info("ApplyPaperActionResponse----返回参数{}", result); + applyPaperActionResponse = JSONObject.toJavaObject(jsonObject, ApplyPaperActionResponse.class); + } catch (Exception e) { + JSONObject map = new JSONObject(); + map.put("status", 400); + map.put("message", e.getMessage()); + return JSONObject.toJavaObject(map, ApplyPaperActionResponse.class); + } + } + return applyPaperActionResponse; + } finally { + MDC.remove(log_file_type); + } + } + + + @Override public LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest param) { try { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index bfedc6cb0..3ae28e74c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -3,6 +3,7 @@ package org.nl.acs.ext.wms.service.impl; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; @@ -27,6 +28,7 @@ import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDev import org.nl.acs.device_driver.basedriver.lamp_three_color.LampThreecolorDeviceDriver; import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver; import org.nl.acs.device_driver.basedriver.paper_tube_device.PaperTubeConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper; import org.nl.acs.device_driver.basedriver.plug_pull_device_site.PlugPullDeviceSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver; @@ -614,6 +616,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { for (int i = 0; i < datas.size(); i++) { String data = datas.get(i).toString(); CreateTaskRequest request = JsonUtl.format(data, CreateTaskRequest.class); + List 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(); @@ -823,6 +826,8 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { 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)); + if (!StrUtil.isEmpty(ext_task_id)) { jo.put("ext_task_id", ext_task_id); @@ -1255,6 +1260,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { 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); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index e8d5b91fa..1dd5ef218 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -127,6 +127,21 @@ public interface TaskService { */ List queryTaskByDeviceCodeAndStatus(String device_code); + /** + * 根据设备号和任务状态查询 + * @param device_code + * @return + */ + List queryTaskByDeviceCodeAndStatus2(String device_code); + + /** + * 根据任务类型查询 + * @param task_type + * @return + */ + List queryTaskByType(String task_type); + + /** * 根据前工位取货点查找执行中的任务 * @param head_start_device_code diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index 7c5875db1..3db2e300a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -1,8 +1,16 @@ package org.nl.acs.task.service.dto; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import lombok.Data; +import org.jinterop.dcom.core.JIUnsignedFactory; +import org.jinterop.dcom.core.JIUnsignedInteger; +import org.nl.acs.device_driver.basedriver.paper_tube_device2.Paper; import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + /** * @author ldjun @@ -307,6 +315,32 @@ public class TaskDto implements Serializable { */ private String next_height = "0"; + /** + * 行架任务类型 + */ + private String truss_type; + + + /** + * 气胀轴代数 + */ + private String version; + + /** + * 是否套管 + */ + private String is_bushing; + + /** + * 套管数量 + */ + private String bushing_num; + + + //array device_code\material_code\qty + private String paper_array; + + @Override public String toString(){ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index e23b40625..7b4c6f652 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -402,6 +402,53 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return list; } + @Override + public List queryTaskByDeviceCodeAndStatus2(String device_code) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (task.getStart_device_code().equals(device_code) + && StrUtil.equals(task.getTask_status(), "1")) { + Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + list.add(task); + } + } else { + if (StrUtil.equals(task.getTask_type(), "9") && StrUtil.isNotEmpty(task.getPut_device_code())) { +// if(task.getNext_device_code().equals(device_code) +// && StrUtil.equals(task.getTask_status(), "1")){ +// Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code()); +// if (ObjectUtil.isNotEmpty(instruction)) { +// list.add(task); +// } +// } + Instruction instruction = instructionService.findByDeviceCodeFromCache(task.getNext_device_code()); + if (ObjectUtil.isNotEmpty(instruction)) { + if (StrUtil.equals(instruction.getStart_device_code(), device_code)) { + list.add(task); + } + } + } + } + } + return list; + } + + @Override + public List queryTaskByType(String task_type) { + List list = new ArrayList<>(); + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if (!StrUtil.equals(task.getTask_type(), task_type)) { + continue; + } + list.add(task); + } + return list; + } + public List queryTaskByStartAndIntStatus(String head_start_device_code) { List list = new ArrayList<>(); Iterator iterator = tasks.iterator(); @@ -1186,6 +1233,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { return null; } + /** + * 根据任务号查询任务 + * @param task_code + * @return + */ public TaskDto findByCodeFromCache(String task_code) { Iterator var3 = tasks.iterator(); diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 8ccbaac84..69bb4b800 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -101,6 +101,8 @@ import standard_autodoor from '@/views/acs/device/driver/standard_autodoor' import lamp_three_color from '@/views/acs/device/driver/lamp_three_color' import paper_tube_conveyor from '@/views/acs/device/driver/paper_tube_conveyor' import device_status from '@/views/acs/device/driver/device_status' +import indoor_manipulator from '@/views/acs/device/driver/indoor_manipulator' +import plugging_unplugging_machine from '@/views/acs/device/driver/plugging_unplugging_machine' export default { name: 'DeviceConfig', @@ -132,7 +134,9 @@ export default { standard_autodoor, lamp_three_color, paper_tube_conveyor, - device_status + device_status, + indoor_manipulator, + plugging_unplugging_machine }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue b/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue new file mode 100644 index 000000000..032907b97 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/casing_station.vue @@ -0,0 +1,500 @@ + + + + + + 设备协议: + + + + + OpcServer: + + + + + + PLC: + + + + + + + + + + + 输送系统: + + + + + + + + + + + + + + + 指令相关: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AGV相关: + + + + + + + + + + + + + + + + + + + + PLC读取字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + + + + + PLC写入字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + 测试写 + + + + + + + + + + + + + 保存 + + + + + + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/indoor_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/indoor_manipulator.vue new file mode 100644 index 000000000..f4fde1d6a --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/indoor_manipulator.vue @@ -0,0 +1,546 @@ + + + + + + 设备协议: + + + + + OpcServer: + + + + + + PLC: + + + + + + + + + + + 输送系统: + + + + + + + + + + + + + + + 指令相关: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AGV相关: + + + + + + + + + + + + + + + + + + + + PLC读取字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + + + + + PLC写入字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + 测试写 + + + + + + + + + + + + + 保存 + + + + + + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue b/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue new file mode 100644 index 000000000..032907b97 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/paper_tube_conveyor2.vue @@ -0,0 +1,500 @@ + + + + + + 设备协议: + + + + + OpcServer: + + + + + + PLC: + + + + + + + + + + + 输送系统: + + + + + + + + + + + + + + + 指令相关: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AGV相关: + + + + + + + + + + + + + + + + + + + + PLC读取字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + + + + + PLC写入字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + 测试写 + + + + + + + + + + + + + 保存 + + + + + + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/plugging_unplugging_machine.vue b/acs/nladmin-ui/src/views/acs/device/driver/plugging_unplugging_machine.vue new file mode 100644 index 000000000..29210e74c --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/plugging_unplugging_machine.vue @@ -0,0 +1,507 @@ + + + + + + 设备协议: + + + + + OpcServer: + + + + + + PLC: + + + + + + + + + + + 输送系统: + + + + + + + + + + + + + + + 指令相关: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AGV相关: + + + + + + + + + + + + + + + + + + + + PLC读取字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + + + + + PLC写入字段: + + + + + + + + + + + + + + 测试读 + + + + + + + + 测试写 + + + + + + + + + + + + + 保存 + + + + + + + + + + diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls index e0cc1c651..bc5a57a9d 100644 Binary files a/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls and b/lms/nladmin-system/src/main/java/org/nl/wms/basedata/st/wql/stivt.xls differ diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java new file mode 100644 index 000000000..34025866a --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/rest/ProductScrapController.java @@ -0,0 +1,79 @@ +package org.nl.wms.st.instor.rest; + +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.modules.logging.annotation.Log; +import org.nl.wms.st.instor.service.ProductScrapService; +import org.springframework.data.domain.Pageable; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +@RestController +@RequiredArgsConstructor +@Api(tags = "成品报废审核") +@RequestMapping("/api/productscrap") +@Slf4j +public class ProductScrapController { + private final ProductScrapService productScrapService; + + @GetMapping + @Log("查询成品报废审核单") + @ApiOperation("查询成品报废审核单") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(productScrapService.pageQuery(whereJson, page), HttpStatus.OK); + } + + @GetMapping("/getOutBillDtl") + @Log("查询明细") + @ApiOperation("查询明细") + public ResponseEntity getOutBillDtl(@RequestParam Map whereJson) { + return new ResponseEntity<>(productScrapService.getOutBillDtl(whereJson), HttpStatus.OK); + } + + @Log("删除") + @ApiOperation("删除") + @DeleteMapping + public ResponseEntity delete(@RequestBody Long[] ids) { + productScrapService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PutMapping + @Log("修改") + @ApiOperation("修改") + public ResponseEntity update(@RequestBody JSONObject whereJson) { + productScrapService.update(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @PostMapping() + @Log("新增") + @ApiOperation("新增") + public ResponseEntity insertDtl(@RequestBody JSONObject whereJson) { + productScrapService.insertDtl(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PostMapping("/auditPass") + @Log("审核通过") + @ApiOperation("审核通过") + public ResponseEntity auditPass(@RequestBody JSONObject whereJson) { + productScrapService.auditPass(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PostMapping("/auditOut") + @Log("不通过") + @ApiOperation("不通过") + public ResponseEntity auditOut(@RequestBody JSONObject whereJson) { + productScrapService.auditOut(whereJson); + return new ResponseEntity<>(HttpStatus.CREATED); + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java new file mode 100644 index 000000000..b4452140e --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/ProductScrapService.java @@ -0,0 +1,52 @@ +package org.nl.wms.st.instor.service; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import org.springframework.data.domain.Pageable; + +import java.util.Map; + +public interface ProductScrapService { + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map pageQuery(Map whereJson, Pageable page); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Long[] ids); + /** + * 新增出库单 + * @param whereJson / + */ + void insertDtl (JSONObject whereJson); + /** + * 查询出库单明细 + * @param whereJson / + * @return + */ + JSONArray getOutBillDtl(Map whereJson); + /** + * 修改出库单 + * @param whereJson / + */ + void update(JSONObject whereJson); + + /** + * 审核通过 + * @param whereJson / + */ + void auditPass(JSONObject whereJson); + + /** + * 不通过 + * @param whereJson / + */ + void auditOut(JSONObject whereJson); +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java new file mode 100644 index 000000000..d0c1eb0ed --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/service/impl/ProductScrapServiceImpl.java @@ -0,0 +1,287 @@ +package org.nl.wms.st.instor.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.utils.SecurityUtils; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.system.util.CodeUtil; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.WqlUtil; +import org.nl.wms.basedata.st.service.impl.UserStorServiceImpl; +import org.nl.wms.st.inbill.service.CheckOutBillService; +import org.nl.wms.st.instor.service.ProductScrapService; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * PC端成品报废审核 + */ +@Service +@RequiredArgsConstructor +@Slf4j +public class ProductScrapServiceImpl implements ProductScrapService { + private final CheckOutBillService checkOutBillService; + + @Override + public Map pageQuery(Map whereJson, Pageable page) { + HashMap map = new HashMap<>(whereJson); + map.put("flag", "1"); + if (StrUtil.isNotEmpty(map.get("bill_code"))) { + map.put("bill_code", "%" + map.get("bill_code") + "%"); + } + if (StrUtil.isNotEmpty(map.get("material_code"))) { + map.put("material_code", "%" + map.get("material_code") + "%"); + } + if (StrUtil.isNotEmpty(map.get("pcsn"))) { + map.put("pcsn", (String) whereJson.get("pcsn")); + } + + //获取人员对应的仓库 + UserStorServiceImpl userStorService = new UserStorServiceImpl(); + String in_stor_id = userStorService.getInStor(); + + if (ObjectUtil.isNotEmpty(in_stor_id)) map.put("in_stor_id", in_stor_id); + + JSONObject jo = WQL.getWO("QST_IVT_PRODUCTSCRAP").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "scrap_code desc"); + return jo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteAll(Long[] ids) { + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("is_delete", "1"); + for (Long scrap_id : ids) { + wo_mst.update(jsonObject,"scrap_id = '"+scrap_id+"'"); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void insertDtl(JSONObject map) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + JSONArray rows = map.getJSONArray("tableData"); + map.remove("tableData"); + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + String changeinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; + JSONObject mst_jo = new JSONObject(); + mst_jo.put("scrap_id", changeinv_id); + mst_jo.put("scrap_code", CodeUtil.getNewCode("SCRAP_CODE")); + mst_jo.put("biz_date", DateUtil.today()); + mst_jo.put("stor_id", MapUtil.getStr(map, "stor_id")); + mst_jo.put("stor_code", MapUtil.getStr(map, "stor_code")); + mst_jo.put("stor_name", MapUtil.getStr(map, "stor_name")); + mst_jo.put("bill_status", "10"); + mst_jo.put("input_optid", currentUserId + ""); + mst_jo.put("input_optname", nickName); + mst_jo.put("input_time", now); + mst_jo.put("is_delete", "0"); + mst_jo.put("detail_count", rows.size()); + + //调用明细处理方法 + JSONObject ret = this.insertDtlByRows(mst_jo, rows); + mst_jo.put("total_qty", ret.getDoubleValue("total_qty")); + wo_mst.insert(mst_jo); + } + + /** + * 根据传进来的载具物料明细,查询载具所有库存记录,并生成移库明细 + * + * @param rows + */ + @Transactional(rollbackFor = Exception.class) + JSONObject insertDtlByRows(JSONObject jsonMst, JSONArray rows) { + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + + //定义返回数据 + JSONObject ret = new JSONObject(); + double total_qty = 0; + for (int i = 0; i < rows.size(); i++) { + JSONObject json = rows.getJSONObject(i); + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("scrapdtl_id", IdUtil.getSnowflake(1, 1).nextId()); + jsonDtl.put("scrap_id", jsonMst.getLongValue("scrap_id")); + jsonDtl.put("seq_no", i); + jsonDtl.put("material_id", json.getLongValue("material_id")); + jsonDtl.put("pcsn", json.getString("pcsn")); + jsonDtl.put("package_box_sn", json.getString("storagevehicle_code")); + jsonDtl.put("fail_source", json.getString("fail_source")); + jsonDtl.put("qty_unit_id", json.getString("qty_unit_id")); + jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); + jsonDtl.put("qty", json.getDoubleValue("qty")); + jsonDtl.put("remark", json.getString("remark")); + wo_dtl.insert(jsonDtl); + + total_qty = NumberUtil.add(total_qty, json.getDoubleValue("qty")); + + } + ret.put("total_qty", total_qty); + return ret; + } + + @Override + public JSONArray getOutBillDtl(Map whereJson) { + whereJson.put("flag", "2"); + JSONArray jo = WQL.getWO("QST_IVT_PRODUCTSCRAP") + .addParamMap((HashMap) whereJson) + .process() + .getResultJSONArray(0); + return jo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(JSONObject whereJson) { + //主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + //主表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + + String currentUserId = SecurityUtils.getCurrentUserId(); + String nickName = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + String scrap_id = (String) whereJson.get("scrap_id"); + //查询主表 + JSONObject jo_mst = wo_mst.query("scrap_id='" + scrap_id + "'").uniqueResult(0); + + //删除所有明细 + wo_dtl.delete("scrap_id = '"+scrap_id+"'"); + + //获取明细 + JSONArray rows = whereJson.getJSONArray("tableData"); + //调用明细处理方法 + JSONObject ret = this.insertDtlByRows(jo_mst, rows); + jo_mst.put("remark", whereJson.get("remark")); + jo_mst.put("biz_date", whereJson.get("biz_date")); + jo_mst.put("detail_count", rows.size()); + jo_mst.put("total_qty", ret.getString("total_qty")); + jo_mst.put("update_optid", currentUserId + ""); + jo_mst.put("update_optname", nickName); + jo_mst.put("update_time", now); + //更新主表 + wo_mst.update(jo_mst); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void auditPass(JSONObject whereJson) { + /* + * 1.校验此些子卷是否都在库内并没有被锁定 + * 2.生成出库单 + * 3.更新单据 + */ + WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + WQLObject dtl = WQLObject.getWQLObject("ST_IVT_ProductScrapDtl"); + WQLObject ivt = WQLObject.getWQLObject("st_ivt_structivt"); + + // 查询所有明细 + JSONArray dtlArr = dtl.query("scrap_id = '" + whereJson.getString("scrap_id") + "'").getResultJSONArray(0); + + // 查询库存中这些子卷是否存在 + String pcsnJoining = dtlArr.stream() + .map(row -> JSON.parseObject(row.toString())) + .map(row -> row.getString("pcsn")) + .collect(Collectors.joining("','")); + + List ivtList = ivt.query("pcsn in ('" + pcsnJoining + "') and canuse_qty > 0") + .getResultJSONArray(0).toJavaList(JSONObject.class); + + if (dtlArr.size() != ivtList.size()) throw new BadRequestException("库存异常请检查!"); + + // 校验库存 + boolean is_pass = ivtList.stream() + .allMatch(row -> pcsnJoining.contains(row.getString("pcsn"))); + + if (!is_pass) throw new BadRequestException("库存异常请检查!"); + + /* List collect = ivtList.stream() + .filter(row -> !pcsnJoining.contains(row.getString("pcsn"))) + .map(row -> row.getString("pcsn")) + .collect(Collectors.toList()); + + if (ObjectUtil.isNotEmpty(collect)) { + throw new BadRequestException("子卷:"+collect.toString()+"异常请检查!"); + }*/ + + // 生成出库单 + JSONObject jsonOutMst = new JSONObject(); + jsonOutMst.put("stor_id",whereJson.getString("stor_id")); + jsonOutMst.put("stor_code", whereJson.getString("stor_code")); + jsonOutMst.put("stor_name", whereJson.getString("stor_name")); + jsonOutMst.put("detail_count", ivtList.size()); + jsonOutMst.put("bill_status", "10"); + jsonOutMst.put("create_mode", "03"); + jsonOutMst.put("biz_date", DateUtil.now()); + jsonOutMst.put("io_type", "1"); + jsonOutMst.put("buss_type", "1002"); + jsonOutMst.put("bill_type", "1002"); + jsonOutMst.put("source_name", "成品报废审核单"); + + JSONArray tableData = new JSONArray(); + for (int i = 0; i < dtlArr.size(); i++) { + JSONObject json = dtlArr.getJSONObject(i); + + JSONObject jsonDtl = new JSONObject(); + jsonDtl.put("pcsn", json.getString("pcsn")); + jsonDtl.put("box_no", json.getString("package_box_sn")); + jsonDtl.put("material_id", json.getString("material_id")); + jsonDtl.put("qty_unit_id", json.getLongValue("qty_unit_id")); + jsonDtl.put("qty_unit_name", json.getString("qty_unit_name")); + jsonDtl.put("plan_qty", json.getDoubleValue("qty")); + tableData.add(jsonDtl); + } + + // 调用出库新增并分配 + jsonOutMst.put("tableData", tableData); + String iostorinv_id = checkOutBillService.insertDtl(jsonOutMst); + JSONObject jsonObject = new JSONObject(); + jsonObject.put("iostorinv_id", iostorinv_id); + checkOutBillService.allDiv(jsonObject); + + // 更新主表为完成 + JSONObject param = new JSONObject(); + param.put("bill_status", "99"); + param.put("confirm_optid", SecurityUtils.getCurrentUserId()); + param.put("confirm_optname", SecurityUtils.getCurrentNickName()); + param.put("confirm_time", DateUtil.now()); + mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'"); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void auditOut(JSONObject whereJson) { + WQLObject mst = WQLObject.getWQLObject("ST_IVT_ProductScrapMst"); + + // 更新主表为完成 + JSONObject param = new JSONObject(); + param.put("bill_status", "99"); + param.put("confirm_optid", SecurityUtils.getCurrentUserId()); + param.put("confirm_optname", SecurityUtils.getCurrentNickName()); + param.put("confirm_time", DateUtil.now()); + mst.update(param,"scrap_id = '"+whereJson.getString("scrap_id")+"'"); + } + +} diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql new file mode 100644 index 000000000..d3dcb1ca1 --- /dev/null +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/instor/wql/QST_IVT_PRODUCTSCRAP.wql @@ -0,0 +1,112 @@ +[交易说明] + 交易名: 成品报废审核分页查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.material_code TYPEAS s_string + 输入.bill_status TYPEAS s_string + 输入.bill_code TYPEAS s_string + 输入.stor_id TYPEAS s_string + 输入.end_time TYPEAS s_string + 输入.begin_time TYPEAS s_string + 输入.pcsn TYPEAS s_string + 输入.scrap_id TYPEAS s_string + 输入.in_stor_id TYPEAS f_string +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + PAGEQUERY + SELECT DISTINCT + mst.* + FROM + ST_IVT_ProductScrapMst mst + LEFT JOIN ST_IVT_ProductScrapDtl dtl ON mst.scrap_id = dtl.scrap_id + WHERE + 1 = 1 + AND mst.is_delete = '0' + and mst.stor_id in 输入.in_stor_id + + OPTION 输入.bill_code <> "" + mst.scrap_code like 输入.bill_code + ENDOPTION + + OPTION 输入.pcsn <> "" + dtl.pcsn = 输入.pcsn + ENDOPTION + + OPTION 输入.stor_id <> "" + mst.stor_id = 输入.stor_id + ENDOPTION + + OPTION 输入.bill_status <> "" + mst.bill_status = 输入.bill_status + ENDOPTION + + OPTION 输入.begin_time <> "" + mst.input_time >= 输入.begin_time + ENDOPTION + + OPTION 输入.end_time <> "" + mst.input_time <= 输入.end_time + ENDOPTION + + ENDSELECT + ENDPAGEQUERY + ENDIF + + IF 输入.flag = "2" + QUERY + SELECT DISTINCT + dtl.*, + dtl.package_box_sn AS storagevehicle_code, + mater.material_code, + mater.material_name + FROM + ST_IVT_ProductScrapDtl dtl + LEFT JOIN ST_IVT_ProductScrapMst mst ON mst.scrap_id = dtl.scrap_id + LEFT JOIN md_me_materialbase mater ON mater.material_id = dtl.material_id + WHERE + 1 = 1 + OPTION 输入.scrap_id <> "" + dtl.scrap_id = 输入.scrap_id + ENDOPTION + + OPTION 输入.scrapdtl_id <> "" + dtl.scrapdtl_id = 输入.scrapdtl_id + ENDOPTION + + order by dtl.seq_no + ENDSELECT + ENDQUERY + ENDIF \ No newline at end of file diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue new file mode 100644 index 000000000..fac90b93f --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDialog.vue @@ -0,0 +1,491 @@ + + + + + + + + + 保存 + 关闭 + + + + + + + + + 单 据 号: + + + + 仓 库: + + + + + + + + + + + + 明 细 数: + + + + 总 重 量: + + + + + + + 备 注: + + + + + + + + + + + 填充 + + + 不合格品明细 + + + + + + 添加库存物料 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue new file mode 100644 index 000000000..a36dcb3ea --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/AddDtl.vue @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 关闭 + 保存 + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue new file mode 100644 index 000000000..6b8a33b65 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/index.vue @@ -0,0 +1,290 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 通过 + + + 不通过 + + + + + + + + + + + + + {{ scope.row.scrap_code }} + + + + + + + + + + + + + + + + + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js new file mode 100644 index 000000000..f5d578e96 --- /dev/null +++ b/lms/nladmin-ui/src/views/wms/st/inStor/productscrap/productscrap.js @@ -0,0 +1,55 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/productscrap', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/productscrap/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/productscrap', + method: 'put', + data + }) +} + +export function getOutBillDtl(params) { + return request({ + url: '/api/productscrap/getOutBillDtl', + method: 'get', + params + }) +} +export function insertDtl(data) { + return request({ + url: '/api/productscrap/insertDtl', + method: 'post', + data + }) +} +export function auditPass(data) { + return request({ + url: '/api/productscrap/auditPass', + method: 'post', + data + }) +} +export function auditOut(data) { + return request({ + url: '/api/productscrap/auditOut', + method: 'post', + data + }) +} +export default { add, edit, del, getOutBillDtl, auditPass, auditOut }