diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index 207ff62..ff039e3 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -387,6 +387,12 @@ UserAgentUtils 1.21 + + + org.bouncycastle + bcprov-jdk15on + 1.50 + 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 c90d7ad..0371161 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 @@ -37,7 +37,21 @@ public enum DriverTypeEnum { HF_STATION(14, "hf_station", "宏丰-工位(交互模板)", "conveyor"), - HF_TWO_RGV(15, "hf_two_rgv", "宏丰-双工位RGV", "rgv"); + HF_TWO_RGV(15, "hf_two_rgv", "宏丰-双工位RGV", "rgv"), + + HF_PACKAGE_PALLET_MANIPULATOR(16, "hf_package_pallet_manipulator", "宏丰-包装码垛机械手", "station"), + + HF_SPLIT_MANIPULATOR(17, "hf_split_manipulator", "宏丰-拆垛机械手", "station"), + + HF_STATION_TWO(18, "hf_station_two", "宏丰-工位二期", "conveyor"), + + HF_KILN_TRUSS(19, "hf_kiln_truss", "宏丰-入出窑桁架", "conveyor"), + + HF_KILN_MANIPULATOR(20, "hf_kiln_manipulator", "宏丰-码垛机械手", "conveyor"), + + HF_RGV_TWO(21, "hf_rgv_two", "宏丰-RGV二期", "rgv"); + + //驱动索引 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_plcscanner/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_plcscanner/ItemProtocol.java index 8854280..6a4d8fc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_plcscanner/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_conveyor_control_with_plcscanner/ItemProtocol.java @@ -101,7 +101,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java index 7b189c7..5f95502 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/ItemProtocol.java @@ -74,7 +74,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDefination.java new file mode 100644 index 0000000..2e294af --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDefination.java @@ -0,0 +1,77 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_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.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 宏丰码垛机械手 + * + */ +@Service +public class HfKilnManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hf_kiln_manipulator"; + } + + @Override + public String getDriverName() { + return "宏丰-码垛机械手"; + } + + @Override + public String getDriverDescription() { + return "宏丰-码垛机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HfKilnManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HfKilnManipulatorDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB200.B0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作模式", "DB200.B1")); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "DB200.B2")); + list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB200.B3")); + list.add(new ItemDto(ItemProtocol.item_walk_y, "行走列", "DB200.D4")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB200.B5")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB200.D6")); + list.add(new ItemDto(ItemProtocol.item_locate, "当前位置", "DB200.W10")); + list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB200.W12")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java new file mode 100644 index 0000000..b0164b2 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/HfKilnManipulatorDeviceDriver.java @@ -0,0 +1,449 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_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.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_station.HfStationDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_station_two.HfStationTwoDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.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.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 宏丰码垛机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HfKilnManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + + AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); + + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + + int mode = 0; + int error = 0; + int action = 0; + int last_action = 0; + int last_mode = 0; + int last_error = 0; + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + Integer heartbeat_tag; + private Date instruction_require_time = new Date(); + private Date instruction_finished_time = new Date(); + + private int instruction_require_time_out; + boolean requireSucess = false; + + private int instruction_finished_time_out; + + int branchProtocol = 0; + + float a = 0f; + float b = 0f; + + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + int move = 0; + int last_move = 0; + int walk_y = 0; + int last_walk_y = 0; + int task = 0; + int last_task = 0; + int locate = 0; + int last_locate = 0; + int barcode = 0; + int last_barcode = 0; + + @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(); + error = this.itemProtocol.getError(); + walk_y = this.itemProtocol.getWalk_y(); + task = this.itemProtocol.getTask(); + locate = this.itemProtocol.getLocate(); + barcode = this.itemProtocol.getBarcode(); + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "action:" + last_action + "->" + action); + } + if (error != last_move) { + 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 (locate != last_locate) { + logServer.deviceItemValue(this.device_code, "locate", String.valueOf(locate)); + logServer.deviceExecuteLog(this.device_code, "", "", "locate:" + last_locate + "->" + locate); + } + if (barcode != last_barcode) { + logServer.deviceItemValue(this.device_code, "barcode", String.valueOf(barcode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode); + } + + //更改任务状态 + if (task > 0) { + //inst_message + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + instructionService.update(inst1); + } + } + } + + //申请取货 判断取货位是否有货 有货就下发允许取货命令 + if (mode == 3 && action == 1 && move == 0 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isNotEmpty(inst2)) { + String start_device_code = inst2.getStart_device_code(); + Device device = appService.findDeviceByCode(start_device_code); + HfStationDeviceDriver hfStationDeviceDriver; + if (device.getDeviceDriver() instanceof HfStationDeviceDriver) { + hfStationDeviceDriver = (HfStationDeviceDriver) device.getDeviceDriver(); + if (hfStationDeviceDriver.getMove() == 1) { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手取货时,开始反馈电气信号"); + this.writing("to_command", "2"); + } else { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手取货时,取货位不满足有货条件"); + } + } + } + } + + //行架机械手取货时校验条码 校验失败,取消任务 + if (mode == 4 && action == 1 && move == 0 && task > 0) { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手取货时条码校验失败,开始反馈电气信号"); + Instruction instructionDto = instructionService.findByCodeFromCache(String.valueOf(task)); + instructionService.cancel(instructionDto.getInstruction_id()); + taskserver.cancel(instructionDto.getTask_id()); + this.writing("to_onset", "0"); + this.writing("to_target", "0"); + this.writing("to_task", "0"); + this.writing("to_barcode", "0"); + this.writing("to_command", "99"); + } + + //申请放货 + if (mode == 3 && action == 3 && move == 1 && task > 0) { + Instruction instructionDto = instructionService.findByCodeFromCache(String.valueOf(task)); + String next_device_code = instructionDto.getNext_device_code(); + Device nextDevice = appService.findDeviceByCode(next_device_code); + HfStationTwoDeviceDriver hfStationDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + hfStationDeviceDriver = (HfStationTwoDeviceDriver) nextDevice.getDeviceDriver(); + int move = hfStationDeviceDriver.getMove(); + if (move == 0) { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手放货时,开始反馈电气信号"); + this.writing("to_command", "3"); + } else { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手放货时,放货位不满足无货条件"); + } + } + } + + //放货完成 + if (mode == 3 && action == 4 && move == 0 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (inst2 != null) { + if (StrUtil.equals(inst2.getInstruction_status(), "1")) { + this.finish_instruction(inst2); + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "机械手任务完成,开始反馈电气信号"); + this.writing("to_onset", "0"); + this.writing("to_target", "0"); + this.writing("to_task", "0"); + this.writing("to_barcode", "0"); + this.writing("to_command", "0"); + } + } + } + + + + } catch (Exception e) { + log.error(e.getMessage()); + return; + } + + //急停 + if (this.isStop()) { + + //未在线无心跳 + } else if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + //行架机械手申请任务 + if (mode == 2) { + if (move == 0 && task == 0 && !requireSucess) { + logServer.queryTask("机械手申请任务", this.getDevice_code(), "机械手开始申请任务!满足信号->mode == 2 && move == 0 && task == 0"); + applyTask(); + } else { + logServer.queryTask("机械手申请任务", this.getDevice_code(), "机械手不满足申请任务!此时:mode = " + mode + "move = " + move + "task = " + task + "requireSucess = " + requireSucess); + } + //条码比对失败,取消任务 + } + } + + last_mode = mode; + last_move = move; + last_action = action; + last_error = error; + last_walk_y = walk_y; + last_task = task; + last_locate = locate; + last_barcode = barcode; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + 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; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_param, value); + ReadUtil.write(itemMap, server); + logServer.writeLog("下发电气信号", this.getDevice_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; + //抓取工位 + List getDeviceCodeList = this.getExtraDeviceCodes("head_get_device_code"); + //放货工位 + List putDeviceCodeList = this.getExtraDeviceCodes("head_put_device_code"); + TaskDto task = null; + for (int i = 0; i < getDeviceCodeList.size(); i++) { + String startDeviceCode = getDeviceCodeList.get(i); + List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + TaskDto taskDto = taskDtos.get(0); + Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); + instruction.setInstruction_status("1"); + instruction.setUpdate_time(DateUtil.now()); + instructionService.update(instruction); + this.sendSignalType(instruction); + this.setRequireSucess(true); + logServer.deviceInfo("机械手申请任务", this.getDevice_code(), "机械手申请任务任务成功,任务为重新创建指令的任务,指令号:" + instruction.getInstruction_code()); + return true; + } else { + List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + task = taskDtoList.get(0); + } + if (ObjectUtil.isNotEmpty(task)) break; + } + } + if (!ObjectUtil.isEmpty(task)) { + 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) { + e.printStackTrace(); + } + //创建指令后修改任务状态 + task.setTask_status("1"); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + + this.sendSignalType(instdto); + this.setRequireSucess(true); + logServer.deviceInfo("机械手申请任务", this.getDevice_code(), "机械手申请任务成功,任务为就绪状态下的任务,指令号:" + instdto.getInstruction_code()); + } else { + this.writing("to_command", "99"); + logServer.deviceInfo("机械手申请任务", this.getDevice_code(), "机械手申请任务失败,未找到机械手取货位关联设备的起点任务!"); + } + return true; + } + } + + //将扩展表中的字符串数据转换成集合 + 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 synchronized void sendSignalType(Instruction dto) { + logServer.deviceInfo("机械手申请任务", this.getDevice_code(), "机械手申请任务指令创建成功,开始写入信号"); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = appService.findDeviceByCode(start_device_code); + Device nextDevice = appService.findDeviceByCode(next_device_code); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + this.writing("to_onset", start_addr); + this.writing("to_target", next_addr); + this.writing("to_task", dto.getInstruction_code()); + this.writing("to_barcode", dto.getVehicle_code()); + this.writing("to_command", "1"); + logServer.deviceInfo("机械手申请任务", this.getDevice_code(), "机械手申请任务指令创建成功,信号写入成功"); + } + + //判断点位是否设置电气值 + public void isSetAddress(Device device) { + if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) { + logServer.deviceError("未设置电气调度号", this.getDevice_code(), "下发指令,设备: '" + device.getDevice_code() + "'未查询到电气调度号"); + throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); + } + } + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/ItemProtocol.java new file mode 100644 index 0000000..6bfcab9 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_manipulator/ItemProtocol.java @@ -0,0 +1,123 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_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_error ="error"; + public static String item_task ="task"; + public static String item_locate ="locate"; + public static String item_barcode ="barcode"; + 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_barcode ="to_barcode"; + + + private HfKilnManipulatorDeviceDriver driver; + + public ItemProtocol(HfKilnManipulatorDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getWalk_y() { + return this.getOpcIntegerValue(item_walk_y); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getLocate() { + return this.getOpcIntegerValue(item_locate); + } + + public int getBarcode() { + return this.getOpcIntegerValue(item_barcode); + } + + 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)) { +// log.error("读取错误!"); + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB200.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB200.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB200.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB200.B3")); + list.add(new ItemDto(item_walk_y, "行走列", "DB200.D4")); + list.add(new ItemDto(item_error, "报警信号", "DB200.B5")); + list.add(new ItemDto(item_task, "任务号", "DB200.D6")); + list.add(new ItemDto(item_locate, "当前位置", "DB200.W10")); + list.add(new ItemDto(item_barcode, "条码", "DB200.W12")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "下发命令反馈", "DB201.W0", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB201.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB201.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB201.D6")); + list.add(new ItemDto(item_to_barcode, "条码", "DB201.W10")); + return list; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDefination.java new file mode 100644 index 0000000..b02ad56 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDefination.java @@ -0,0 +1,74 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_truss; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 宏丰入出窑桁架 + */ +@Service +public class HfKilnTrussDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hf_kiln_truss"; + } + + @Override + public String getDriverName() { + return "宏丰-入出窑桁架"; + } + + @Override + public String getDriverDescription() { + return "宏丰-入出窑桁架"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HfKilnTrussDeviceDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return HfKilnTrussDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB200.B0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作模式", "DB200.B1")); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "DB200.B2")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB200.B3")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB200.D4")); + list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB200.W8")); + list.add(new ItemDto(ItemProtocol.item_number,"数量","DB200.W10")); + list.add(new ItemDto(ItemProtocol.item_kiln_id,"窑号","DB200.W12")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java new file mode 100644 index 0000000..3577f62 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/HfKilnTrussDeviceDriver.java @@ -0,0 +1,293 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_truss; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.opc.Device; +import org.nl.acs.order.service.dto.ProduceshiftorderDto; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.nl.modules.wql.util.SpringContextHolder.getBean; + +/** + * 宏丰入出窑桁架 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HfKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + + DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); + + RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); + + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + + AcsToWmsService acsToWmsService=getBean("acsToWmsServiceImpl"); + + private Date instruction_require_time = new Date(); + + private int instruction_require_time_out = 3000; + + String device_code; + int mode = 0; + int error = 0; + int move = 0; + int last_mode = 0; + int last_error = 0; + int last_move = 0; + Boolean isonline = true; + int hasGoods = 0; + Boolean iserror = false; + + boolean requireSucess = false; + + private Date checkHeartbeattime = new Date(); + private Date last_checkHeartbeattime = new Date(); + + int branchProtocol = 0; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + String message; + int task = 0; + int last_task = 0; + int barcode = 0; + int last_barcode = 0; + int number = 0; + int last_number = 0; + int kiln_id =0; + int last_kiln_id=0; + + //入窑标记 + Boolean inTrussSucess = false; + //出窑标记 + Boolean outTrussSucess = false; + + + @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(); + task = this.itemProtocol.getTask(); + barcode = this.itemProtocol.getBarcode(); + number = this.itemProtocol.getNumber(); + kiln_id =this.itemProtocol.getKilnId(); + + if (mode != last_mode) { + if (mode == 3) { + this.setInTrussSucess(false); + } + if (mode == 4) { + this.setOutTrussSucess(false); + } + } + + if (mode != last_mode) { + this.setRequireSucess(false); + logServer.deviceItemValue(this.device_code,"mode" ,String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code,"","","信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + logServer.deviceItemValue(this.device_code,"move" ,String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code,"","","move:" + last_move + "->" + move); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code,"task" ,String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code,"","","信号task:" + last_task + "->" + task); + } + if (barcode != last_barcode) { + logServer.deviceItemValue(this.device_code,"barcode" ,String.valueOf(barcode)); + logServer.deviceExecuteLog(this.device_code,"","","信号barcode:" + last_barcode + "->" + barcode); + } + if (number != last_number) { + logServer.deviceItemValue(this.device_code,"number" ,String.valueOf(number)); + logServer.deviceExecuteLog(this.device_code,"","","信号number:" + last_number + "->" + number); + } + if (kiln_id != last_kiln_id) { + logServer.deviceItemValue(this.device_code,"kiln_id" ,String.valueOf(kiln_id)); + logServer.deviceExecuteLog(this.device_code,"","","信号kiln_id:" + last_kiln_id + "->" + kiln_id); + } + + } catch (Exception e) { + log.error(e.getMessage()); + return; + } + + //急停 + if (this.isStop()) { + + //未在线无心跳 + } else if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 2: + + break; + case 3: + //上报LMS,将对应托盘置为指定窑号中 + uploadKilnInJson(); + break; + case 4: + //上报LMS,将对应窑号中的所有托盘都设置为已出窑 + uploadKilnOutJson(); + break; + } + } + + last_mode = mode; + last_move = move; + last_task = task; + last_barcode = barcode; + last_number = number; + } + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + /** + * 组盘入窑 + * + * @param + */ + public synchronized boolean uploadKilnInJson() { + 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 { + if(barcode==0) { + return false; + } + logServer.deviceInfo("组盘入窑", this.getDevice_code(), "开始组盘入窑!"); + JSONObject json = new JSONObject(); + //任务号 + json.put("task",this.task); + //条码 + json.put("barcode",this.barcode); + //窑号 + json.put("kiln_id",this.kiln_id); + //0-入窑 + json.put("state",0); + JSONObject resp = acsToWmsService.updateKiln(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + this.writing(3); + logServer.deviceInfo("acs组盘入窑", this.getDevice_code(), "组盘入窑成功!"); + }else{ + this.writing(99); + message = "窑道外冷却区存在存留托盘,无法出窑"; + } + this.setInTrussSucess(true); + return true; + } + } + + public synchronized boolean uploadKilnOutJson() { + 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 { +// if(barcode==0) { +// return false; +// } + logServer.deviceInfo("组盘出窑", this.getDevice_code(), "开始组盘出窑!"); + JSONObject json = new JSONObject(); +// //任务号 +// json.put("task",this.task); + //组盘数量 + json.put("number",this.number); + //窑号 + json.put("kiln_id",this.kiln_id); + //1-出窑 + json.put("state",1); + JSONObject resp = acsToWmsService.updateKiln(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + this.writing(4); + logServer.deviceInfo("acs组盘出窑", this.getDevice_code(), "组盘出窑成功!"); + }else{ + this.writing(99); + logServer.deviceInfo("acs组盘出窑", this.getDevice_code(), "组盘出窑成功!"); + } + this.setOutTrussSucess(true); + return true; + } + } + + 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.hongfeng.hf_station_two.ItemProtocol.item_to_command; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_command + "信号值:" + command); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/ItemProtocol.java new file mode 100644 index 0000000..08b2831 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_kiln_truss/ItemProtocol.java @@ -0,0 +1,114 @@ +package org.nl.acs.device_driver.hongfeng.hf_kiln_truss; + +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_task = "task"; + public static String item_error = "error"; + public static String item_barcode = "barcode"; + public static String item_number = "number"; + public static String item_kiln_id= "kiln_id"; + + public static String item_to_command = "to_command"; + public static String item_to_target = "to_target"; + public static String item_to_task = "to_task"; + Boolean isonline; + + private HfKilnTrussDeviceDriver driver; + + public ItemProtocol(HfKilnTrussDeviceDriver 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 getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getBarcode() { + return this.getOpcIntegerValue(item_barcode); + } + + public int getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getKilnId() { + return this.getOpcIntegerValue(item_kiln_id); + } + + 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 hasGoods(int move) { + return move; + } + + + 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, "心跳", "DB200.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB200.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB200.B2")); + list.add(new ItemDto(item_error, "报警信号", "DB200.B3")); + list.add(new ItemDto(item_task, "任务号", "DB200.D4")); + list.add(new ItemDto(item_barcode, "条码", "DB200.W8")); + list.add(new ItemDto(item_number,"数量","DB200.W10")); + list.add(new ItemDto(item_kiln_id,"窑号","DB200.W12")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "下发命令反馈", "DB201.W0", Boolean.valueOf(true))); + list.add(new ItemDto(item_to_target, "下发目标站", "DB201.W2")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB201.D4")); + return list; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/ItemProtocol.java index b3e856b..87a35ba 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_manipulator/ItemProtocol.java @@ -79,7 +79,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDefination.java new file mode 100644 index 0000000..4843f62 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDefination.java @@ -0,0 +1,62 @@ +package org.nl.acs.device_driver.hongfeng.hf_rgv_two; + +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; + +/** + * 宏丰二期RGV + * + */ +@Service +public class HfRGVTwoDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hf_rgv_two"; + } + + @Override + public String getDriverName() { + return "宏丰RGV二期"; + } + + @Override + public String getDriverDescription() { + return "宏丰RGV二期"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HfRGVTwoDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HfRGVTwoDeviceDriver.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/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java new file mode 100644 index 0000000..a7cea95 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/HfRGVTwoDeviceDriver.java @@ -0,0 +1,717 @@ +package org.nl.acs.device_driver.hongfeng.hf_rgv_two; + +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.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_station.HfStationDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.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.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; + +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.nl.modules.wql.util.SpringContextHolder.*; + +/** + * 宏丰二期RGV + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HfRGVTwoDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + + InstructionService instructionService = getBean("instructionServiceImpl"); + + DeviceService deviceservice = getBean("deviceServiceImpl"); + + RouteLineService routelineserver = getBean("routeLineServiceImpl"); + + TaskService taskserver = getBean("taskServiceImpl"); + + AcsToWmsService acsToWmsService = getBean("acsToWmsServiceImpl"); + + DeviceAppService deviceAppservice = getBean(DeviceAppServiceImpl.class); + + //当前指令1 + Instruction inst1 = null; + + DeviceExecuteLogService logServer = getBean("deviceExecuteLogServiceImpl"); + + //工作模式 + int mode = 0; + int last_mode = 0; + //设备状态 + int status = 0; + int last_status = 0; + //前后工位光电信号 + int move1 = 0; + int last_move1 = 0; + //前后工位动作信号 + int action1 = 0; + int last_action1 = 0; + //报警信号 + int error = 0; + int last_error = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //前后工位任务号 + int task1 = 0; + int last_task1 = 0; + + + Boolean isonline = true; + //后工位申请任务请求标记 + Boolean requireBackSucess = false; + //前工位申请任务请求标记 + Boolean requireHeadSucess = false; + + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + int branchProtocol = 0; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + + String device_code; + + + //后工位申请任务请求时间 + private Date instruction_require_time = new Date(); + //前工位申请任务请求时间 + private Date instruction_head_time = new Date(); + //请求超时时间 + private int instruction_require_time_out = 3000; + + @Override + public Device getDevice() { + return this.device; + } + + + @Override + public void execute() throws Exception { + String message = null; + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + status = this.itemProtocol.getStatus(); + move1 = this.itemProtocol.getMove1(); + action1 = this.itemProtocol.getAction1(); + walk_y = this.itemProtocol.getWalk_y(); + error = this.itemProtocol.getError(); + task1 = this.itemProtocol.getTask1(); + + if (mode != last_mode) { + if (mode == 0) { + this.setRequireHeadSucess(false); + this.setRequireBackSucess(false); + } + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (status != last_status) { + logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status); + } + if (move1 != last_move1) { + if (move1 == 0) { + this.setRequireHeadSucess(false); + } + logServer.deviceItemValue(this.device_code, "move1", String.valueOf(move1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move1:" + last_move1 + "->" + move1); + } + if (action1 != last_action1) { + logServer.deviceItemValue(this.device_code, "action1", String.valueOf(action1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action1:" + last_action1 + "->" + action1); + } + 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 (task1 != last_task1) { + logServer.deviceItemValue(this.device_code, "task1", String.valueOf(task1)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task1:" + last_task1 + "->" + task1); + } + + //前工位任务就绪->执行 + if (task1 > 0) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + inst1.setInstruction_status("1"); + instructionService.update(inst1); + } + } + } + //前工位放货完成 任务完成 + if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0) { + //inst_message + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + if (inst1 != null) { + if (StrUtil.equals(inst1.getInstruction_status(), "1")) { + finish_instruction(inst1); +// JSONArray array = new JSONArray(); +// TaskDto taskDto = taskserver.findByCode(inst1.getTask_code()); +// if (ObjectUtil.isNotEmpty(taskDto)) { +// if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) { +// JSONObject map = new JSONObject(); +// map.put("task_id", taskDto.getExt_task_id()); +// map.put("task_status", "2"); +// map.put("finished_type", "1"); +// array.add(map); +// acsToWmsService.feedbackTaskStatusToWms(array); +// } +// } + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "RGV前工位任务完成,开始反馈电气信号"); + this.writing("to_command1", "0"); + this.writing("to_onset1", "0"); + this.writing("to_target1", "0"); + this.writing("to_task1", "0"); + this.writing("to_command1", "0"); + this.writing("to_onset1", "0"); + this.writing("to_target1", "0"); + this.writing("to_task1", "0"); + this.setRequireHeadSucess(false); + } + } + } + + //前工位取货时判断取货位光电信号 + if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0 ) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + String start_device_code = inst1.getStart_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + HfStationDeviceDriver hfStationDeviceDriver; + if (startDevice.getDeviceDriver() instanceof HfStationDeviceDriver) { + hfStationDeviceDriver = (HfStationDeviceDriver) startDevice.getDeviceDriver(); + int move = hfStationDeviceDriver.getMove(); + if (move != 0) { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "RGV前工位取货时,开始反馈电气信号"); + this.writing("to_command1", "2"); + } else { + logServer.deviceError("反馈电气信号", this.getDevice_code(), "RGV前工位取货时,取货位光电信号不满足有货条件,反馈失败!"); + } + } + } + //前工位放货时判断放货位光电信号 + if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0) { + Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); + String next_device_code = inst1.getNext_device_code(); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + HfStationDeviceDriver hfStationDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof HfStationDeviceDriver) { + hfStationDeviceDriver = (HfStationDeviceDriver) nextDevice.getDeviceDriver(); + int move = hfStationDeviceDriver.getMove(); + if (move == 0) { + logServer.deviceInfo("反馈电气信号", this.getDevice_code(), "RGV前工位放货时,开始反馈电气信号"); + this.writing("to_command1", "3"); + } else { + logServer.deviceError("反馈电气信号", this.getDevice_code(), "RGV前工位放货时,放货位光电信号不满足无货条件,反馈失败!"); + } + } + } + + } catch (Exception var17) { + return; + } + + if (!this.itemProtocol.getIsonline()) { + this.setIsonline(false); + this.setIserror(true); + message = "信号量同步异常"; + //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + return; + case 2: + //前工位申请任务 + if (mode == 2 && move1 == 0 && !requireHeadSucess && !requireBackSucess && task1 == 0) { + logServer.queryTask("RGV申请前工位任务", this.getDevice_code(), "RGV开始申请前工位任务!满足信号->mode == 2 && move2 == 0 && action2 == 0 && task2 == 0 && move1 == 0"); + instruction_require(); + if (!requireHeadSucess) + logServer.queryTask("RGV申请前工位任务", this.getDevice_code(), "RGV不满足申请前工位任务!此时:mode = " + mode + "task2 = " + move1 + "requireHeadSucess = " + requireHeadSucess); + } + break; + case 3: + //前工位申请任务 + if (mode == 3 && move1 == 0 && !requireHeadSucess && task1 == 0) { + logServer.queryTask("RGV申请前工位任务", this.getDevice_code(), "RGV开始申请前工位任务!满足信号->mode == 3 && move2 == 1 && action2 == 1 && move1 == 0"); + instruction_require(); + if (!requireHeadSucess) + logServer.queryTask("RGV申请前工位任务", this.getDevice_code(), "RGV不满足申请前工位任务!此时:mode = " + mode + "move1 = " + move1 + "requireHeadSucess = " + requireHeadSucess); + } + } + + } + last_mode = mode; + last_error = error; + last_status = status; + last_move1 = move1; + last_action1 = action1; + last_walk_y = walk_y; + last_task1 = task1; +} + + + //申请前工位任务 + public synchronized boolean instruction_require() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time); + return false; + } else { + this.instruction_head_time = date; + //前工位取货关联设备 + List getDeviceCodeList = this.getExtraDeviceCodes("head_get_device_code"); + //前工位放货关联设备 + List putDeviceCodeList = this.getExtraDeviceCodes("head_put_device_code"); + //前工位重复关联设备 + List repeatDeviceCodeList = this.getExtraDeviceCodes("head_repeat_device_code"); + //前工位重复关联设备放货设备 + List repeatPutDeviceCodeList = this.getExtraDeviceCodes("head_repeat_put_device_code"); + TaskDto task = null; + for (int i = 0; i < getDeviceCodeList.size(); i++) { + String startDeviceCode = getDeviceCodeList.get(i); + List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + TaskDto taskDto = taskDtos.get(0); + if (repeatDeviceCodeList.contains(startDeviceCode)) { + String next_device_code = taskDto.getNext_device_code(); + if (!repeatPutDeviceCodeList.contains(next_device_code)) { + continue; + } + } + Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); + instruction.setInstruction_status("1"); + instruction.setUpdate_time(DateUtil.now()); + instructionService.update(instruction); + this.sendHeadSignalType(instruction); + requireHeadSucess = true; + logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV申请前工位任务成功,任务为重新创建指令的任务,指令号:" + instruction.getInstruction_code()); + return true; + } else { + List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + task = taskDtoList.get(0); + String next_device_code = task.getNext_device_code(); + if (repeatDeviceCodeList.contains(startDeviceCode)) { + if (!repeatPutDeviceCodeList.contains(next_device_code)) { + task = null; + continue; + } else { + if (ObjectUtil.isNotEmpty(task)) break; + } + } + } + if (ObjectUtil.isNotEmpty(task)) break; + } + } + + if (!ObjectUtil.isEmpty(task)) { + 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) { + e.printStackTrace(); + } + + //创建指令后修改任务状态 + task.setTask_status("1"); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + this.sendHeadSignalType(instdto); + requireHeadSucess = true; + logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV申请前工位任务成功,任务为就绪状态下的任务,指令号:" + instdto.getInstruction_code()); + } else { + logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV申请前工位任务失败,未找到前工位取货位关联设备的起点任务!"); + } + } + return true; + } + + //申请后工位任务 + public synchronized boolean instruction_require2() throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time); + return false; + } else { + this.instruction_require_time = date; + + //后工位取货关联设备 + List getDeviceCodeList = this.getExtraDeviceCodes("back_get_device_code"); + //后工位放货关联设备 + List putDeviceCodeList = this.getExtraDeviceCodes("back_put_device_code"); + //后工位重复关联设备 + List repeatDeviceCodeList = this.getExtraDeviceCodes("back_repeat_device_code"); + //后工位重复关联设备放货设备 + List repeatPutDeviceCodeList = this.getExtraDeviceCodes("back_repeat_put_device_code"); + + TaskDto task = null; + for (int i = 0; i < getDeviceCodeList.size(); i++) { + String startDeviceCode = getDeviceCodeList.get(i); + List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + TaskDto taskDto = taskDtos.get(0); + if (repeatDeviceCodeList.contains(startDeviceCode)) { + String next_device_code = taskDto.getNext_device_code(); + if (!repeatPutDeviceCodeList.contains(next_device_code)) { + continue; + } + } + Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); + instruction.setInstruction_status("1"); + instruction.setUpdate_time(DateUtil.now()); + instructionService.update(instruction); + this.sendBackSignalType(instruction); + requireBackSucess = true; + logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV申请后工位任务成功,任务为重新创建指令的任务,指令号:" + instruction.getInstruction_code()); + return true; + } else { + List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + task = taskDtoList.get(0); + String next_device_code = task.getNext_device_code(); + if (repeatDeviceCodeList.contains(startDeviceCode)) { + if (!repeatPutDeviceCodeList.contains(next_device_code)) { + task = null; + continue; + } else { + if (ObjectUtil.isNotEmpty(task)) break; + } + } + } + if (ObjectUtil.isNotEmpty(task)) ; + } + } + + if (!ObjectUtil.isEmpty(task)) { + 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) { + e.printStackTrace(); + } + + //创建指令后修改任务状态 + task.setTask_status("1"); + taskserver.update(task); + this.sendBackSignalType(instdto); + logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV申请后工位任务成功,任务为就绪状态下的任务,指令号:" + instdto.getInstruction_code()); + } else { + logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV申请后工位任务失败,未找到后工位取货位关联设备的起点任务!"); + } + } + return true; + } + + public synchronized void sendHeadSignalType(Instruction dto) { + logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV前工位任务指令创建成功,开始写入信号"); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + this.writing("to_onset1", start_addr); + this.writing("to_target1", next_addr); + this.writing("to_task1", dto.getInstruction_code()); + this.writing("to_command1", "1"); + this.writing("to_onset1", start_addr); + this.writing("to_target1", next_addr); + this.writing("to_task1", dto.getInstruction_code()); + this.writing("to_command1", "1"); + logServer.deviceInfo("RGV申请前工位任务", this.getDevice_code(), "RGV前工位任务指令创建成功,信号写入成功"); + } + + public synchronized void sendBackSignalType(Instruction dto) { + logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV后工位任务指令创建成功,开始写入信号"); + String start_device_code = dto.getStart_device_code(); + String next_device_code = dto.getNext_device_code(); + Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code); + this.isSetAddress(startDevice); + this.isSetAddress(nextDevice); + String start_addr = startDevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); + this.writing("to_onset2", start_addr); + this.writing("to_target2", next_addr); + this.writing("to_task2", dto.getInstruction_code()); + this.writing("to_command2", "1"); + this.writing("to_onset2", start_addr); + this.writing("to_target2", next_addr); + this.writing("to_task2", dto.getInstruction_code()); + this.writing("to_command2", "1"); + logServer.deviceInfo("RGV申请后工位任务", this.getDevice_code(), "RGV后工位任务指令创建成功,信号写入成功"); + } + + //判断点位是否设置电气值 + public void isSetAddress(Device device) { + if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) { + logServer.deviceError("未设置电气调度号", this.getDevice_code(), "下发指令,设备: '" + device.getDevice_code() + "'未查询到电气调度号"); + throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); + } + } + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + 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)); + + ReadUtil.write(itemMap, server); + logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); + } + + public boolean exe_business() { + return true; + } + + protected void executing(Instruction instruction) { + this.executing(1, instruction, ""); + } + + public void executing(int command, Instruction instruction, String appendMessage) { + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + ReadUtil.write(itemMap, server); + + } + + + public synchronized boolean finish_instruction(Instruction inst) throws Exception { + instructionService.finish(inst); + return true; + } + + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing1(int command) { + String to_command1 = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command1; + + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command1, command); + ReadUtil.write(itemMap, server); + + } + + + //将扩展表中的字符串数组数据转换成集合 + 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 move1 = ""; + String move2 = ""; + String action1 = ""; + String action2 = ""; + String walk_y = ""; + String mode = ""; + String status = ""; + + 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.getStatus() == 1) { + status = "待机"; + } else if (this.getStatus() == 2) { + status = "生产中"; + } else if (this.getStatus() == 3) { + status = "故障"; + } + + if (this.getMove1() == 0) { + move1 = "无货"; + } else if (this.getMove1() == 1) { + move1 = "有货"; + } + + if (this.getAction1() == 1) { + action1 = "取货中"; + } else if (this.getAction1() == 2) { + action1 = "取货完成"; + } else if (this.getAction1() == 3) { + action1 = "放货中"; + } else if (this.getAction1() == 4) { + action1 = "放货完成"; + } + + if (this.getWalk_y() == 0) { + walk_y = "原位"; + } else if (this.getWalk_y() == 2) { + walk_y = "非原位"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("status", status); + jo.put("move1", move1); + jo.put("move2", move2); + jo.put("action1", action1); + jo.put("action2", action2); + jo.put("walk_y", walk_y); + jo.put("error", this.getError()); + jo.put("task1", this.getTask1()); + jo.put("isOnline", this.getIsonline()); + jo.put("isError", this.getIserror()); + jo.put("message", this.getMessage()); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/ItemProtocol.java new file mode 100644 index 0000000..4decf33 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_rgv_two/ItemProtocol.java @@ -0,0 +1,136 @@ +package org.nl.acs.device_driver.hongfeng.hf_rgv_two; + +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_status = "status"; + //前工位光电信号 + public static String item_move1 = "move1"; + //前工位动作信号 + public static String item_action1 = "action1"; + //行走列 + public static String item_walk_y = "walk_y"; + //报警信号 + public static String item_error = "error"; + //前工位任务号 + public static String item_task1 = "task1"; + + + //前工位下发命令 + public static String item_to_command1 = "to_command1"; + //前工位下发起始站 + public static String item_to_onset1 = "to_onset1"; + //前工位下发目标站 + public static String item_to_target1 = "to_target1"; + //前工位下发任务号 + public static String item_to_task1 = "to_task1"; + + + + private HfRGVTwoDeviceDriver driver; + + public ItemProtocol(HfRGVTwoDeviceDriver driver) { + this.driver = driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getStatus() { + return this.getOpcIntegerValue(item_status); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getMove1() { + return this.getOpcIntegerValue(item_move1); + } + + public int getAction1() { + return this.getOpcIntegerValue(item_action1); + } + + public int getWalk_y() { + return this.getOpcIntegerValue(item_walk_y); + } + + public int getTask1() { + return this.getOpcIntegerValue(item_task1); + } + + + //是否有货 + 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 String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isEmpty(value)) { + + } else { + return value; + } + return "0"; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB2.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB2.B1")); + list.add(new ItemDto(item_status, "设备状态", "DB2.B2")); + list.add(new ItemDto(item_move1, "前工位光电信号", "DB2.B3")); + list.add(new ItemDto(item_action1, "前工位动作信号", "DB2.B5")); + list.add(new ItemDto(item_walk_y, "行走列", "DB2.B7")); + list.add(new ItemDto(item_error, "报警信号", "DB2.B8")); + list.add(new ItemDto(item_task1, "前工位任务号", "DB2.D10")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command1, "前工位下发命令", "DB3.W0")); + list.add(new ItemDto(item_to_onset1, "前工位下发起始站", "DB3.W2")); + list.add(new ItemDto(item_to_target1, "前工位下发目标站", "DB3.W4")); + list.add(new ItemDto(item_to_task1, "前工位下发任务号", "DB3.D6")); + return list; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/ItemProtocol.java index 990f1eb..02a0924 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station/ItemProtocol.java @@ -125,7 +125,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDefination.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDefination.java new file mode 100644 index 0000000..925dbdb --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDefination.java @@ -0,0 +1,82 @@ +package org.nl.acs.device_driver.hongfeng.hf_station_two; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceType; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * 宏丰-工位二期 + * + */ +@Service +public class HfStationTwoDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "hf_station_two"; + } + + @Override + public String getDriverName() { + return "宏丰-工位二期"; + } + + @Override + public String getDriverDescription() { + return "宏丰-工位二期"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new HfStationTwoDeviceDriver()).setDevice(device).setDriverDefination(this); + + } + + @Override + public Class getDeviceDriverType() { + return HfStationTwoDeviceDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.station); + return types; + } + + @Override + public List getReadableItemDtos() { + return getReadableItemDtos2(); + } + + public static List getReadableItemDtos2() { + List list = new ArrayList(); + list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB101.B0")); + list.add(new ItemDto(ItemProtocol.item_mode, "工作模式", "DB101.B1")); + list.add(new ItemDto(ItemProtocol.item_move, "光电信号", "DB101.B2")); + list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB101.B3")); + list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB101.B4")); + list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB101.B5")); + list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB101.D6")); + list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB101.B10")); + list.add(new ItemDto(ItemProtocol.item_current_order_num, "当前工单数量", "DB101.D12")); + list.add(new ItemDto(ItemProtocol.item_order, "工单号", "DB200.STRING20.50")); + list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB200.STRING72.50")); + list.add(new ItemDto(ItemProtocol.item_material_code, "物料号", "DB200.B72")); + list.add(new ItemDto(ItemProtocol.item_product_code,"产品编号","DB200.B124")); + list.add(new ItemDto(ItemProtocol.item_number,"托盘砖数量","DB200.B16")); + return list; + } + + @Override + public List getWriteableItemDtos() { + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java new file mode 100644 index 0000000..333176d --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/HfStationTwoDeviceDriver.java @@ -0,0 +1,704 @@ +package org.nl.acs.device_driver.hongfeng.hf_station_two; + +import cn.hutool.core.date.DateUtil; +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.device.device_driver.DriverTypeEnum; +import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; +import org.nl.acs.device.service.DeviceService; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_kiln_manipulator.HfKilnManipulatorDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_station.HfStationDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.order.service.ProduceshiftorderService; +import org.nl.acs.order.service.dto.ProduceshiftorderDto; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.task.service.TaskService; +import org.nl.modules.wql.util.SpringContextHolder; +import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static org.nl.modules.wql.util.SpringContextHolder.getBean; + +/** + * 宏丰-工位(交互模板二期) + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class HfStationTwoDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor { + protected ItemProtocol itemProtocol = new ItemProtocol(this); + + InstructionService instructionService=getBean("instructionServiceImpl"); + + DeviceService deviceService=getBean("deviceServiceImpl"); + + RouteLineService routeLineServer=getBean("routeLineServiceImpl"); + + TaskService taskServer=getBean("taskServiceImpl"); + + DeviceExecuteLogService logServer=getBean("deviceExecuteLogServiceImpl"); + + AcsToWmsService acsToWmsService=getBean("acsToWmsServiceImpl"); + + ProduceshiftorderService produceshiftorderService=getBean("produceshiftorderServiceImpl"); + + DeviceAppService deviceAppService=getBean("deviceAppServiceImpl"); + + + String device_code; + + //心跳 + int heartbeat; + int last_heartbeat; + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //取放信号 + int action = 0; + int last_action = 0; + //进出信号 + int io_action = 0; + int last_ioaction = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + //设备状态 + int status = 0; + int last_status = 0; + //当前工单数量 + int current_order_num = 0; + int last_current_order_num = 0; + //工单号 + String order = "0"; + String last_order = "0"; + //产品编码 + String material_code = "0"; + String last_material_code = "0"; + //条码 + int barcode = 0; + int last_barcode = 0; + //重量 + int weight = 0; + int last_weight = 0; + + //托盘砖数量 + int number = 0; + int last_number =0; + + int product_code =0; + int last_product_code=0; + + + Boolean isonline = true; + int hasGoods = 0; + Boolean iserror = false; + + protected int instruction_num = 0; + protected int instruction_num_truth = 0; + Integer heartbeat_tag; + //人工排产确认请求时间 + private Date instruction_require_time = new Date(); + //工单完成请求时间 + private Date instruction_finished_time = new Date(); + //呼叫空盅请求时间 + private Date instruction_call_empty_time = new Date(); + //满盅入库请求时间 + private Date instruction_full_in_time = new Date(); + //叫料请求时间 + private Date instruction_call_material_time = new Date(); + //空料盅对接位有货时请求时间 + private Date instruction_empty_hasGoods_time = new Date(); + //条码改变请求标记 + private Date instruction_update_barcode_time = new Date(); + + + private int instruction_require_time_out = 3000; + //人工排产确认请求标记 + boolean requireSucess = false; + //工单完成请求标记 + boolean finishRequireSucess = false; + //呼叫空盅请求标记 + boolean callEmptyRequireSucess = false; + //满盅入库请求标记 + boolean fullInRequireSucess = false; + //叫料请求标记 + boolean callMaterialRequireSucess = false; + //空料盅对接位有货时请求标记 + boolean emptyHasGoodsRequireSucess = true; + //条码改变请求标记 + boolean updateBarcodeRequireSucess = true; + //光电变更 + boolean moveUpdateSuccess = true; + //托盘砖数量变更 + boolean numberUpdateSuccess = false; + + private int instruction_finished_time_out; + + + int branchProtocol = 0; + //当前指令 + Instruction inst = null; + //上次指令 + Instruction last_inst = null; + + //触摸屏手动触发任务 + private Boolean is_has_task = false; + + //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 + int flag; + int last_flag; + + String message; + + int container_type = 0; + + + @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(); + io_action = this.itemProtocol.getIoAction(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + status = this.itemProtocol.getStatus(); + current_order_num = this.itemProtocol.getCurrent_order_num(); + barcode = this.itemProtocol.getBarcode(); + weight = this.itemProtocol.getWeight(); + material_code = this.itemProtocol.getMaterial_code(); + order = this.itemProtocol.getOrder(); + number =this.itemProtocol.getNumber(); + product_code=this.itemProtocol.getProduct_code(); + + if (mode != last_mode) { + if (mode == 3) { + this.setRequireSucess(false); + } + if (mode == 4) { + this.setFinishRequireSucess(false); + } + if (mode == 6) { + this.setCallEmptyRequireSucess(false); + } + if (mode == 7) { + this.setFullInRequireSucess(false); + } + if (mode == 8) { + this.setCallMaterialRequireSucess(false); + } + logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode); + } + if (move != last_move) { + Object apply_task = this.getDevice().getExtraValue().get("apply_task"); + if (ObjectUtil.isEmpty(apply_task)) { + apply_task = "false"; + } + if (apply_task.toString().equals("true") && move == 1) { + this.setEmptyHasGoodsRequireSucess(false); + } + this.setMoveUpdateSuccess(false); + logServer.deviceItemValue(this.device_code, "move", String.valueOf(move)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move); + } + if (action != last_action) { + logServer.deviceItemValue(this.device_code, "action", String.valueOf(action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action); + } + if (io_action != last_ioaction) { + logServer.deviceItemValue(this.device_code, "io_action", String.valueOf(io_action)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号io_action: " + last_ioaction + "->" + io_action); + } + if (error != last_error) { + logServer.deviceItemValue(this.device_code, "error", String.valueOf(error)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error); + } + if (task != last_task) { + logServer.deviceItemValue(this.device_code, "task", String.valueOf(task)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task); + } + if (status != last_status) { + logServer.deviceItemValue(this.device_code, "status", String.valueOf(status)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号status: " + last_status + "->" + status); + } + if (current_order_num != last_current_order_num) { + logServer.deviceItemValue(this.device_code, "current_order_num", String.valueOf(current_order_num)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号current_order_num: " + last_current_order_num + "->" + current_order_num); + } + if (weight != last_weight) { + logServer.deviceItemValue(this.device_code, "weight", String.valueOf(weight)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号weight: " + last_weight + "->" + weight); + } + if (!order.equals(last_order)) { + logServer.deviceItemValue(this.device_code, "order", order); + logServer.deviceExecuteLog(this.device_code, "", "", "信号order:" + last_order + "->" + order); + } + if (barcode != last_barcode) { + this.setUpdateBarcodeRequireSucess(false); + logServer.deviceItemValue(this.device_code, "barcode", String.valueOf(barcode)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode); + } + if (!material_code.equals(last_material_code)) { + logServer.deviceItemValue(this.device_code, "material_code", material_code); + logServer.deviceExecuteLog(this.device_code, "", "", "信号material_code:" + last_material_code + "->" + material_code); + } + if (number != last_number) { + this.setNumberUpdateSuccess(true); + logServer.deviceItemValue(this.device_code, "number", String.valueOf(number)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号number:" + last_number + "->" + number); + } + if (!Objects.equals(product_code, last_product_code)) { + logServer.deviceItemValue(this.device_code, "product_code", String.valueOf(product_code)); + logServer.deviceExecuteLog(this.device_code, "", "", "信号product_code:" + last_product_code + "->" + product_code); + } + + + } catch (Exception var17) { + return; + } + + //急停 + if (this.isStop()) { + //未在线无心跳 +// } else if (!this.itemProtocol.getIsonline()) { +// this.setIsonline(false); +// this.setIserror(true); +// message = "信号量同步异常"; +// //未联机 + } else if (mode == 0) { + this.setIsonline(false); + this.setIserror(true); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIsonline(false); + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 3: + //人工排产确认 + if (!requireSucess && StrUtil.isNotEmpty(order)) { + enterOrder(); + } + break; + case 4: + //工单完成 + if (!finishRequireSucess && StrUtil.isNotEmpty(order)) { + finish(); + } + break; + case 6: + //满跺完成,请求呼叫 + if (!callEmptyRequireSucess && move != 0) { + //上报lms组盘完毕 + //反馈电气组盘成功 + uploadPalletizing(); + log.info("电气上报组盘完毕"); + } + case 7: + //满盅入库 + if (!fullInRequireSucess && move == 0) { + fullIn(); + + } + break; + default: + break; + } + + } + + last_mode = mode; + last_move = move; + last_action = action; + last_ioaction = io_action; + last_error = error; + last_task = task; + last_status = status; + last_current_order_num = current_order_num; + last_order = order; + last_barcode = barcode; + last_weight = weight; + last_material_code = material_code; + last_product_code = product_code; + } + + /** + * 出窑缓存区托盘 + * + * @param + */ + public synchronized boolean fullIn() { + Date date = new Date(); + if (date.getTime() - this.instruction_full_in_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_full_in_time); + return false; + } else { + logServer.deviceInfo("acs申请任务", this.getDevice_code(), "开始申请满盅入库任务!"); + this.instruction_full_in_time = date; + JSONObject json = new JSONObject(); + json.put("device_code", device_code); + json.put("barcode", barcode); + json.put("weight", weight); + json.put("material_code",material_code); + json.put("create_mode", "2"); + json.put("is_auto_issue", "0"); + json.put("type", "5"); + JSONObject resp = acsToWmsService.apply(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + this.writing(7); + this.setFullInRequireSucess(true); + logServer.deviceInfo("acs申请任务", this.getDevice_code(), "满盅入库任务申请成功!"); + }else{ + this.writing(99); + } + return true; + } + } + + /** + * 组盘信息上报 + * + * @param + */ + public synchronized boolean uploadPalletizing() { + 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 { + logServer.deviceInfo("组盘信息上报", this.getDevice_code(), "开始组盘信息上报!"); + ProduceshiftorderDto dto = produceshiftorderService.findByCode(order); + JSONObject json = new JSONObject(); + //设备号 + json.put("vehicle_code",this.barcode); + //工单号 + json.put("order_code",this.order); + //托盘砖数量 + json.put("number",this.number); + //产品编号 + json.put("product_code",this.product_code); + //物料号 + json.put("material_code",this.material_code); + JSONObject resp = acsToWmsService.uploadPalletizing(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + this.writing(6); + this.setCallEmptyRequireSucess(true); + logServer.deviceInfo("acs组盘信息上报", this.getDevice_code(), "组盘信息上报成功!"); + }else{ + log.error("操作失败,{}",json); + this.writing(99); + } + return true; + } + + } + + + + + public boolean exe_error() { + if (this.error == 0) { + return true; + } else { + log.debug("设备报警"); + return false; + } + } + + public boolean exe_business() { + return true; + } + + public String autoGenericCode(String vehicle_code) { + return String.format("%0" + 4 + "d", Integer.parseInt(vehicle_code)); + } + + protected void executing(Instruction instruction) { + this.executing(1, instruction, ""); + } + + public void executing(int command, Instruction instruction, String appendMessage) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_task; + if (appendMessage == null) { + appendMessage = ""; + } + if (instruction != null) { + instruction_num = Integer.parseInt(instruction.getInstruction_code()); + } + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, 1); + itemMap.put(to_task, instruction_num); + ReadUtil.write(itemMap, server); + + } + + public void executing(Server server, Map itemMap) { + ReadUtil.write(itemMap, server); + } + + public void writing(int type, int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_command; + String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_target; + String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + org.nl.acs.device_driver.hongfeng.hf_station.ItemProtocol.item_to_task; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + if (type == 1) { + itemMap.put(to_command, command); + } else if (type == 2) { + itemMap.put(to_target, command); + + } else if (type == 3) { + itemMap.put(to_task, command); + } + ReadUtil.write(itemMap, server); + } + + public void writing(int command) { + String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + + "." + ItemProtocol.item_to_command; + String opcservcerid = this.getDevice().getOpc_server_id(); + Server server = ReadUtil.getServer(opcservcerid); + Map itemMap = new HashMap(); + itemMap.put(to_command, command); + ReadUtil.write(itemMap, server); + logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_command + "信号值:" + command); + } + + 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, value); + ReadUtil.write(itemMap, server); + logServer.writeLog("下发电气信号", this.getDevice_code(), "下发信号:" + to_param + "信号值:" + value); + } + + public synchronized boolean finish_instruction() throws Exception { + instructionService.finish(inst); + return true; + } + + public synchronized void OpenOrClose(String type) { + + //进入区域 +// if ("1".equals(type)) { +// writing(5); +// } else { +// //离开区域 +// writing(6); +// } + } + + + @Override + public String toString() { + return ""; + } + + @Override + public JSONObject getDeviceStatusName() { + JSONObject jo = new JSONObject(); + String mode = ""; + String action = ""; + String io_action = ""; + String move = ""; + String status = ""; + 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 = "工单完成"; + } else if (this.getMode() == 5) { + mode = "工单强制完成"; + } else if (this.getMode() == 6) { + mode = "呼叫空盅"; + } else if (this.getMode() == 7) { + mode = "满盅入库"; + } else if (this.getMode() == 8) { + mode = "叫料"; + } + + if (this.getStatus() == 1) { + status = "待机"; + } else if (this.getStatus() == 2) { + status = "生产中"; + } else { + status = "故障"; + } + + if (this.getAction() == 1) { + action = "允许取货"; + } else if (this.getAction() == 2) { + action = "允许放货"; + } else if (this.getAction() == 3) { + action = "允许取放"; + } + + if (this.getIo_action() == 1) { + io_action = "允许进入"; + } else if (this.getIo_action() == 2) { + io_action = "允许离开"; + } else if (this.getIo_action() == 3) { + io_action = "允许进出"; + } + + if (this.getMove() == 0) { + move = "无货"; + } else if (this.getMove() == 1) { + move = "有货"; + } else if (this.getMove() == 2) { + move = "有托盘有货"; + } + + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("move", move); + jo.put("action", action); + jo.put("io_action", io_action); + jo.put("hasGoods", this.getHasGoods()); + jo.put("isOnline", this.getIsonline()); + jo.put("error", this.getError()); + jo.put("status", status); + jo.put("message", this.getMessage()); + jo.put("task", this.getTask()); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + + } + + /** + * 工单完成 + * + * @param + */ + public synchronized boolean finish() { + Date date = new Date(); + if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time); + return false; + } else { + logServer.deviceInfo("反馈工单状态", this.getDevice_code(), "开始反馈设备完成状态!"); + this.instruction_finished_time = date; + ProduceshiftorderDto dto = produceshiftorderService.findByCode(order); + JSONObject json = new JSONObject(); + json.put("device_code", device_code); + json.put("order_code", order); + json.put("ext_order_id", dto.getExt_order_id()); + json.put("qty", current_order_num); + json.put("type", "3"); + JSONObject resp = acsToWmsService.feedbackOrderStatus(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + dto.setOrder_status("2"); + dto.setUpdate_time(DateUtil.now()); + produceshiftorderService.update(dto); + this.writing(4); + this.setFinishRequireSucess(true); + logServer.deviceInfo("反馈工单状态", this.getDevice_code(), "反馈设备完成状态成功!"); + } + return true; + } + } + + /** + * 人工排产确认 + * + * @param + */ + public synchronized boolean enterOrder() { + 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 { + logServer.deviceInfo("人工排产确认", this.getDevice_code(), "开始人工排产确认!"); + this.instruction_require_time = date; + ProduceshiftorderDto dto = produceshiftorderService.findByCode(order); + JSONObject json = new JSONObject(); + json.put("device_code", device_code); + json.put("material_code", dto.getMaterial_code()); + json.put("ext_order_id", dto.getExt_order_id()); + json.put("order_code", order); + JSONObject resp = acsToWmsService.orderConfirm(json); + if (StrUtil.equals(resp.getString("status"), "200")) { + dto.setOrder_status("1"); + dto.setUpdate_time(DateUtil.now()); + produceshiftorderService.update(dto); + this.setRequireSucess(true); + this.writing(8); + this.writing(8); + logServer.deviceInfo("人工排产确认", this.getDevice_code(), "人工排产确认成功!"); + } + return true; + } + } + + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/ItemProtocol.java new file mode 100644 index 0000000..cef551c --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_station_two/ItemProtocol.java @@ -0,0 +1,212 @@ +package org.nl.acs.device_driver.hongfeng.hf_station_two; + +import lombok.extern.slf4j.Slf4j; + +import cn.hutool.core.util.StrUtil; +import lombok.Data; +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_ioaction = "ioaction"; + //报警信号 + public static String item_error = "error"; + //任务号 + public static String item_task = "task"; + //设备状态 + public static String item_status = "status"; + //当前工单数量 + public static String item_current_order_num = "current_order_num"; + //工单号 + public static String item_order = "order"; + //物料号 + public static String item_material_code = "material_code"; + //条码 + public static String item_barcode = "barcode"; + //重量 + public static String item_weight = "weight"; + //产品编号 + public static String item_product_code="product_code"; + //托盘砖数量 + public static String item_number ="number"; + + + + //下发命令 + 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_error = "to_error"; + //当前工单数量 + public static String item_to_order_num = "to_order_num"; + //物料号 + public static String item_to_material_code = "to_material_code"; + //产品编号 + public static String item_to_product_code = "to_product_code"; + //工单号 + public static String item_to_order = "to_order"; + //A长边 + public static String item_to_a = "to_a"; + //B短边 + public static String item_to_b = "to_b"; + //H梯形高 + public static String item_to_h = "to_h"; + //W厚度 + public static String item_to_w = "to_w"; + //托盘砖数量 + public static String item_to_number = "to_number"; + + + Boolean isonline; + + private HfStationTwoDeviceDriver driver; + + public ItemProtocol(HfStationTwoDeviceDriver 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 getIoAction() { + return this.getOpcIntegerValue(item_ioaction); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getStatus() { + return this.getOpcIntegerValue(item_status); + } + + public int getNumber() { + return this.getOpcIntegerValue(item_number); + } + + public int getProduct_code() { + return this.getOpcIntegerValue(item_product_code); + } + + public int getCurrent_order_num() { + return this.getOpcIntegerValue(item_current_order_num); + } + + public String getOrder() { + return this.getOpcStringValue(item_order); + } + + public int getBarcode() { + return this.getOpcIntegerValue(item_barcode); + } + + public int getWeight() { + return this.getOpcIntegerValue(item_weight); + } + + public String getMaterial_code() { + return this.getOpcStringValue(item_material_code); + } + + //是否有货 + public int hasGoods(int move) { + return move; + } + + + 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 ""; + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB101.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB101.B2")); + list.add(new ItemDto(item_action, "取放信号", "DB101.B3")); + list.add(new ItemDto(item_ioaction, "进出信号", "DB101.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB101.B5")); + list.add(new ItemDto(item_task, "任务号", "DB101.D6")); + list.add(new ItemDto(item_status, "设备状态", "DB101.B10")); + list.add(new ItemDto(item_current_order_num, "当前工单数量", "DB101.D12")); + list.add(new ItemDto(item_order, "工单号", "DB200.STRING20.50")); + list.add(new ItemDto(item_barcode, "条码", "DB200.STRING72.50")); + list.add(new ItemDto(item_material_code, "物料号", "DB200.B72")); + list.add(new ItemDto(item_product_code,"产品编号","DB200.B124")); + list.add(new ItemDto(item_number,"托盘砖数量","DB200.B16")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList(); + list.add(new ItemDto(item_to_command, "作业命令", "DB201.W0")); + list.add(new ItemDto(item_to_target, "目标站", "DB201.W2")); + list.add(new ItemDto(item_to_task, "任务号", "DB201.D4")); + list.add(new ItemDto(item_to_error, "故障代码", "DB201.B8")); + list.add(new ItemDto(item_to_order_num, "工单数量", "DB201.D10")); + list.add(new ItemDto(item_to_material_code, "下发物料号", "DB201.STRING14.50")); + list.add(new ItemDto(item_to_order, "工单号", "DB201.STRING66.50")); + list.add(new ItemDto(item_to_a, "A长边", "DB201.W118")); + list.add(new ItemDto(item_to_b, "B短边", "DB201.W120")); + list.add(new ItemDto(item_to_h, "H梯形高", "DB201.W122")); + list.add(new ItemDto(item_to_w, "W厚度", "DB201.W124")); + list.add(new ItemDto(item_to_number, "托盘砖数量", "DB201.W126")); + list.add(new ItemDto(item_to_product_code, "产品编号", "DB201.W128")); + return list; + } + +} + diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_two_rgv/ItemProtocol.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_two_rgv/ItemProtocol.java index b6d9651..ff48fe2 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_two_rgv/ItemProtocol.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/hongfeng/hf_two_rgv/ItemProtocol.java @@ -115,7 +115,7 @@ public class ItemProtocol { public int getOpcIntegerValue(String protocol) { Integer value = this.driver.getIntegeregerValue(protocol); if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); +// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); setIsonline(false); } else { setIsonline(true); 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 1169942..bbf48bc 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 @@ -47,4 +47,26 @@ public interface AcsToWmsService { * @return */ JSONObject updateBarcode(JSONObject param); + + /** + * 组盘信息上报 + * @param param + * @return + */ + JSONObject uploadPalletizing(JSONObject param); + + /** + * 更新托盘状态 + * @param param + * @return + */ + JSONObject updateKiln(JSONObject param); + + /** + * 查找出窑缓存区托盘 + * @param param + * @return + */ + JSONObject findVehicle(JSONObject 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 3eb4332..ae6ca7e 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 @@ -172,4 +172,79 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } } + @Override + public JSONObject uploadPalletizing(JSONObject param) { + String url = ""; + try { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("uploadPalletizing"); + String methods_url = addressDto.getMethods_url(); + url = wmsUrl + methods_url; + HttpResponse result = + HttpRequest + .post(url) + .body(JSON.toJSONString(param)) + .execute(); + JSONObject jsonObject = JSONObject.parseObject(result.body()); + logServer.acsToLms("组盘信息上报", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } catch (Exception e) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "400"); + jsonObject.put("message", e.getMessage()); + logServer.acsToLms("组盘信息上报", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } + } + + @Override + public JSONObject updateKiln(JSONObject param) { + String url = ""; + try { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("updateKiln"); + String methods_url = addressDto.getMethods_url(); + url = wmsUrl + methods_url; + HttpResponse result = + HttpRequest + .post(url) + .body(JSON.toJSONString(param)) + .execute(); + JSONObject jsonObject = JSONObject.parseObject(result.body()); + logServer.acsToLms("更新托盘状态", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } catch (Exception e) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "400"); + jsonObject.put("message", e.getMessage()); + logServer.acsToLms("更新托盘状态", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } + } + + @Override + public JSONObject findVehicle(JSONObject param) { + String url = ""; + try { + String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("findVehicle"); + String methods_url = addressDto.getMethods_url(); + url = wmsUrl + methods_url; + HttpResponse result = + HttpRequest + .post(url) + .body(JSON.toJSONString(param)) + .execute(); + JSONObject jsonObject = JSONObject.parseObject(result.body()); + logServer.acsToLms("查找出窑缓存区托盘", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } catch (Exception e) { + JSONObject jsonObject = new JSONObject(); + jsonObject.put("status", "400"); + jsonObject.put("message", e.getMessage()); + logServer.acsToLms("查找出窑缓存区托盘", url, String.valueOf(param), jsonObject.getString("status"), jsonObject.getString("message")); + return jsonObject; + } + } + } 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 53eb802..ee87eb2 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 @@ -191,7 +191,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { String order_code = order.getString("order_code"); String qty = order.getString("qty"); String material_code = order.getString("material_code"); + String material_name = order.getString("material_name"); String device_code = order.getString("device_code"); + String a=order.getString("a"); + String b=order.getString("b"); + String h=order.getString("h"); + String w=order.getString("w"); + String product_code=order.getString("product_code"); + String number=order.getString("number"); if (StrUtil.isEmpty(ext_order_id)) { throw new WDKException("工单外部标识不能为空"); } @@ -220,10 +227,16 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { dto.setQty(new BigDecimal(qty)); dto.setExt_order_id(ext_order_id); dto.setMaterial_code(material_code); - dto.setMaterial_name(""); + dto.setMaterial_name(material_name); dto.setDevice_code(device_code); dto.setCreate_by("lms"); dto.setUpdate_by("lms"); + dto.setA(a); + dto.setB(b); + dto.setH(h); + dto.setW(w); + dto.setProduct_code(product_code); + dto.setNumber(number); produceshiftorderService.create(dto); } JSONObject resultJson = new JSONObject(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java new file mode 100644 index 0000000..7ad1c7e --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcServerServiceImpl.java @@ -0,0 +1,193 @@ +package org.nl.acs.opc; + +import cn.hutool.core.util.StrUtil; +import org.jinterop.dcom.common.JIException; +import org.nl.acs.auto.initial.ApplicationAutoInitial; +import org.nl.acs.device_driver.driver.ItemValue; +import org.nl.modules.common.exception.BadRequestException; +import org.openscada.opc.lib.common.NotConnectedException; +import org.openscada.opc.lib.da.Group; +import org.openscada.opc.lib.da.Server; +import org.openscada.opc.lib.da.UnknownGroupException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.net.UnknownHostException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +/** + * @author ldjun + * @version 1.0 + * @date 2023年02月01日 11:27 + * @desc desc + */ +@Service +public class OpcServerServiceImpl implements OpcServerService, ApplicationAutoInitial { + + private static final Logger log = LoggerFactory.getLogger(OpcServerServiceImpl.class); + @Autowired + OpcServerManageService opcServerManageService; + Map opcServerManageDtos = new HashMap(); + Map servers = Collections.synchronizedMap(new HashMap()); + Map groups = Collections.synchronizedMap(new HashMap()); + + public OpcServerServiceImpl() {} + + @Override + public void autoInitial() throws Exception { + this.reload(); + if (OpcConfig.auto_start_opc) { + Thread t = + new Thread() { + public void run() { + Iterator var1 = OpcServerServiceImpl.this.opcServerManageDtos.values().iterator(); + + while (var1.hasNext()) { + OpcServerManageDto dto = (OpcServerManageDto) var1.next(); + + try { + OpcServerServiceImpl.this.getServer(dto.getOpc_code()); + OpcServerServiceImpl.log.info("加载opc server {}", dto.getOpc_code()); + } catch (Exception var4) { + OpcServerServiceImpl.log.warn("启动无法载入servers", var4); + } + } + } + }; + t.start(); + } + } + + public synchronized void reload() { + this.opcServerManageDtos = this.opcServerManageService.queryAllServerMap(); + this.opcServerManageDtos = Collections.synchronizedMap(this.opcServerManageDtos); + } + + public Group getServer(String code) { + synchronized(this.buildLock(code)) { + Group group = null; +// group = (Group)this.groups.get(code); +// if (group != null) { +// label68: { +// Group var10000; +// try { +// if (!group.isActive()) { +// break label68; +// } +// +// var10000 = group; +// } catch (JIException var14) { +// log.error(code, var14); +// break label68; +// } +// +// return var10000; +// } +// } + + Server server = (Server)this.servers.get(code); + boolean needcreate = false; + String groupName = code; + if (server == null) { + needcreate = true; + } else { + try { + group = server.findGroup(groupName); + } catch (UnknownHostException | JIException | UnknownGroupException | NotConnectedException | IllegalArgumentException var13) { + log.error(code, var13); + needcreate = true; + } + } + + if (needcreate) { + OpcServerManageDto dto = (OpcServerManageDto)this.opcServerManageDtos.get(code); + if (dto == null) { + throw new BadRequestException(code + "{} 不存在"); + } + + if (server == null) { + server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain())); + } + + try { + group = server.addGroup(groupName); + } catch (Exception var12) { + this.clearServer(code); + ThreadUtl.sleep(5000L); + log.warn("获取opc出错重新获取", code, var12); + server = OpcServerUtl.getServerWithOutException(dto.getOpc_host(), StrUtil.trim(dto.getCls_id()), dto.getUser(), dto.getPassword(), StrUtil.trim(dto.getDomain())); + + try { + group = server.addGroup(groupName); + } catch (Exception var11) { + var11.printStackTrace(); + } + } + + this.servers.put(code, server); + this.groups.put(code, group); + } + + return group; + } + } + + public void clearServer(String code) { + synchronized(this.buildLock(code)) { + try { + Server server = (Server)this.servers.get(code); + server.disconnect(); + } catch (Exception var5) { + } + + this.servers.remove(code); + this.groups.remove(code); + } + } + + public void writeInteger(String code, ItemValue... values) { + try { + Group group = this.getServer(code); + OpcUtl.writeValue(group, values); + } catch (Exception var4) { + this.clearServer(code); + log.warn("写入出错opc server {} 重新加载", code, var4); + ThreadUtl.sleep(5000L); + throw var4; + } + } + + private String buildLock(String key) { + if (StrUtil.isEmpty(key)) { + key = ""; + } + StringBuilder builder = new StringBuilder(); + builder.append("OpcServerService."); + builder.append(key); + String lock = builder.toString().intern(); + return lock; + } + + public void cleanGroups(String opcCode) { + Group group = (Group)this.groups.get(opcCode); + if (group != null) { + Server server = group.getServer(); + + try { + group.remove(); + } catch (JIException var5) { + var5.printStackTrace(); + } + + this.groups.remove(opcCode); + server.disconnect(); + this.servers.remove(opcCode); + } + + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java index d792a96..c38ba5a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/opc/OpcUtl.java @@ -230,7 +230,7 @@ public class OpcUtl { }finally{ System.out.println("successNum:"+successNum); System.out.println("errNum:"+errNum); - System.out.println(11); +// System.out.println(11); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java index 946bab9..9bfabbc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/dto/ProduceshiftorderDto.java @@ -69,4 +69,22 @@ public class ProduceshiftorderDto implements Serializable { //托盘总量 private String tray_num; + //A长边 + private String a; + + //B短边 + private String b; + + //H梯形高 + private String h; + + //W厚度 + private String w; + + //产品编号 + private String product_code; + + //托盘砖数量 + private String number; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index b369a75..1bdc939 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -7,7 +7,9 @@ import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import org.nl.acs.auto.initial.ApplicationAutoInitial; import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device_driver.hongfeng.hf_kiln_manipulator.HfKilnManipulatorDeviceDriver; import org.nl.acs.device_driver.hongfeng.hf_station.HfStationDeviceDriver; +import org.nl.acs.device_driver.hongfeng.hf_station_two.HfStationTwoDeviceDriver; import org.nl.acs.device_driver.hongfeng.hf_two_rgv.HfTwoRGVDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.opc.Device; @@ -151,6 +153,58 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationDeviceDriver.writing("to_product_number", dto.getMaterial_code()); hfStationDeviceDriver.writing("to_command", "3"); hfStationDeviceDriver.writing("to_command", "3"); + //压力机下发工单同时下发到关联的码盘工位 + String device_code=hfStationDeviceDriver.getExtraValue().get("link_device_code").toString(); + Device linkDevice = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isNotEmpty(linkDevice)&&linkDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) linkDevice.getDeviceDriver(); + if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { + throw new BadRequestException("设备正在生产"); + } + hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); + hfStationTwoDeviceDriver.writing("to_a", dto.getA()); + hfStationTwoDeviceDriver.writing("to_b", dto.getB()); + hfStationTwoDeviceDriver.writing("to_h", dto.getH()); + hfStationTwoDeviceDriver.writing("to_w", dto.getW()); + hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); + hfStationTwoDeviceDriver.writing("to_a", dto.getA()); + hfStationTwoDeviceDriver.writing("to_b", dto.getB()); + hfStationTwoDeviceDriver.writing("to_h", dto.getH()); + hfStationTwoDeviceDriver.writing("to_w", dto.getW()); + hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_command", "3"); + hfStationTwoDeviceDriver.writing("to_command", "3"); + } + }else if (device.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) device.getDeviceDriver(); + if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { + throw new BadRequestException("设备正在生产"); + } + hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", dto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", dto.getA()); + hfStationTwoDeviceDriver.writing("to_b", dto.getB()); + hfStationTwoDeviceDriver.writing("to_h", dto.getH()); + hfStationTwoDeviceDriver.writing("to_w", dto.getW()); + hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_order", dto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(dto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", dto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", dto.getA()); + hfStationTwoDeviceDriver.writing("to_b", dto.getB()); + hfStationTwoDeviceDriver.writing("to_h", dto.getH()); + hfStationTwoDeviceDriver.writing("to_w", dto.getW()); + hfStationTwoDeviceDriver.writing("to_number", dto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", dto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_command", "3"); + hfStationTwoDeviceDriver.writing("to_command", "3"); } JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.insert(json); @@ -312,6 +366,90 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A hfStationDeviceDriver.writing("to_product_number", produceshiftorderDto.getMaterial_code()); hfStationDeviceDriver.writing("to_command", "3"); hfStationDeviceDriver.writing("to_command", "3"); + //压力机下发工单同时下发到关联的码盘工位 + String link_device_code=hfStationDeviceDriver.getExtraValue().get("link_device_code").toString(); + Device linkDevice = deviceAppService.findDeviceByCode(link_device_code); + if (linkDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) linkDevice.getDeviceDriver(); + if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { + throw new BadRequestException("设备正在生产"); + } + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_command", "3"); + hfStationTwoDeviceDriver.writing("to_command", "3"); + }else if (linkDevice.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) linkDevice.getDeviceDriver(); + if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { + throw new BadRequestException("设备正在生产"); + } + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_command", "3"); + hfStationTwoDeviceDriver.writing("to_command", "3"); + } + } if (device.getDeviceDriver() instanceof HfStationTwoDeviceDriver) { + HfStationTwoDeviceDriver hfStationTwoDeviceDriver = (HfStationTwoDeviceDriver) device.getDeviceDriver(); + if (StrUtil.isNotBlank(hfStationTwoDeviceDriver.getOrder())) { + throw new BadRequestException("设备正在生产"); + } + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_order", produceshiftorderDto.getOrder_code()); + hfStationTwoDeviceDriver.writing("to_order_num", String.valueOf(produceshiftorderDto.getQty())); + hfStationTwoDeviceDriver.writing("to_material_code", produceshiftorderDto.getMaterial_code()); + hfStationTwoDeviceDriver.writing("to_a", produceshiftorderDto.getA()); + hfStationTwoDeviceDriver.writing("to_b", produceshiftorderDto.getB()); + hfStationTwoDeviceDriver.writing("to_h", produceshiftorderDto.getH()); + hfStationTwoDeviceDriver.writing("to_w", produceshiftorderDto.getW()); + hfStationTwoDeviceDriver.writing("to_number", produceshiftorderDto.getNumber()); + hfStationTwoDeviceDriver.writing("to_product_code", produceshiftorderDto.getProduct_code()); + hfStationTwoDeviceDriver.writing("to_command", "3"); + hfStationTwoDeviceDriver.writing("to_command", "3"); + }else if (device.getDeviceDriver() instanceof HfKilnManipulatorDeviceDriver) { + HfKilnManipulatorDeviceDriver hfKilnManipulatorDeviceDriver = (HfKilnManipulatorDeviceDriver) device.getDeviceDriver(); + + hfKilnManipulatorDeviceDriver.writing("to_command", "1"); + hfKilnManipulatorDeviceDriver.writing("to_command", "1"); } } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls index 23a5943..a502c84 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/order/service/wql/order.xls differ diff --git a/acs/nladmin-system/src/main/resources/config/application-dev.yml b/acs/nladmin-system/src/main/resources/config/application-dev.yml index fdc072b..a49f51d 100644 --- a/acs/nladmin-system/src/main/resources/config/application-dev.yml +++ b/acs/nladmin-system/src/main/resources/config/application-dev.yml @@ -6,11 +6,11 @@ spring: druid: db-type: com.alibaba.druid.pool.DruidDataSource driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hongfeng_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true + url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hf_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:yongyu_acs2}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true username: ${DB_USER:root} #password: ${DB_PWD:P@ssw0rd} - password: ${DB_PWD:password} + password: ${DB_PWD:123456} # 初始连接数 initial-size: 5 # 最小连接数 @@ -128,7 +128,7 @@ file: avatarMaxSize: 5 logging: file: - path: C:\log\wms + path: C:\log\acs config: classpath:logback-spring.xml # Sa-Token配置 diff --git a/acs/nladmin-system/src/main/resources/config/application.yml b/acs/nladmin-system/src/main/resources/config/application.yml index a4d00ab..e56175e 100644 --- a/acs/nladmin-system/src/main/resources/config/application.yml +++ b/acs/nladmin-system/src/main/resources/config/application.yml @@ -2,7 +2,7 @@ spring: freemarker: check-template-location: false profiles: - active: prod + active: dev jackson: time-zone: GMT+8 data: @@ -44,7 +44,7 @@ rsa: private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== logging: file: - path: C:\log\wms + path: C:\log\acs config: classpath:logback-spring.xml # sa-token白名单配置 security: diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 85e8ca0..4d97715 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -84,21 +84,21 @@ https://juejin.cn/post/6844903775631572999 - + - + - + - + - + @@ -130,7 +130,7 @@ https://juejin.cn/post/6844903775631572999 - + @@ -138,44 +138,44 @@ https://juejin.cn/post/6844903775631572999 - + - + - + - + - + - + - + - + - + - + diff --git a/acs/nladmin-ui/src/views/acs/device/config.vue b/acs/nladmin-ui/src/views/acs/device/config.vue index 7943258..4b379f7 100644 --- a/acs/nladmin-ui/src/views/acs/device/config.vue +++ b/acs/nladmin-ui/src/views/acs/device/config.vue @@ -90,6 +90,11 @@ import hf_two_rgv from '@/views/acs/device/driver/hongfeng/hf_two_rgv' import hf_station from '@/views/acs/device/driver/hongfeng/hf_station' import hf_manipulator from '@/views/acs/device/driver/hongfeng/hf_manipulator' +import hf_station_two from '@/views/acs/device/driver/hongfeng/hf_station_two' +import hf_kiln_truss from '@/views/acs/device/driver/hongfeng/hf_kiln_truss' +import hf_kiln_manipulator from '@/views/acs/device/driver/hongfeng/hf_kiln_manipulator' +import hf_rgv_two from '@/views/acs/device/driver/hongfeng/hf_rgv_two' + export default { name: 'DeviceConfig', components: { @@ -107,7 +112,12 @@ export default { empty_vehicle_stacking_position, hf_manipulator, hf_station, - hf_two_rgv + hf_two_rgv, + hf_station_two, + hf_kiln_truss, + hf_kiln_manipulator, + hf_rgv_two + }, dicts: ['device_type'], mixins: [crud], diff --git a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_manipulator.vue new file mode 100644 index 0000000..8222d4d --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_manipulator.vue @@ -0,0 +1,522 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_truss.vue b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_truss.vue new file mode 100644 index 0000000..ddfdf60 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_kiln_truss.vue @@ -0,0 +1,484 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_rgv_two.vue b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_rgv_two.vue new file mode 100644 index 0000000..f0fbdbc --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_rgv_two.vue @@ -0,0 +1,641 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station.vue b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station.vue index 2975a8e..96a788a 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station.vue @@ -113,6 +113,23 @@ + + + + + + + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station_two.vue b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station_two.vue new file mode 100644 index 0000000..4a23ae3 --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/driver/hongfeng/hf_station_two.vue @@ -0,0 +1,484 @@ + + + + + diff --git a/acs/nladmin-ui/src/views/acs/order/index.vue b/acs/nladmin-ui/src/views/acs/order/index.vue index 3f2c69f..4fffac3 100644 --- a/acs/nladmin-ui/src/views/acs/order/index.vue +++ b/acs/nladmin-ui/src/views/acs/order/index.vue @@ -97,6 +97,12 @@ + + + + + + diff --git a/acs/nladmin-ui/src/views/login.vue b/acs/nladmin-ui/src/views/login.vue index 74db7e2..58087e8 100644 --- a/acs/nladmin-ui/src/views/login.vue +++ b/acs/nladmin-ui/src/views/login.vue @@ -2,14 +2,14 @@