diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 43fc5808d..0760ceba9 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -22,6 +22,7 @@ import org.nl.acs.device.service.*; import org.nl.acs.device.service.dto.*; import org.nl.acs.device_driver.DeviceDriverDefination; import org.nl.acs.device_driver.ScannerDeviceDriver; +import org.nl.acs.device_driver.basedriver.slit_two_manipulator.SlitTwoManipulatorDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; @@ -868,6 +869,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial throw new BadRequestException("未找到对应设备:" + device_code); } StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; + SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; //检测站点 StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { @@ -926,6 +928,9 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial standardInspectSiteDeviceDriver.setBatch(batch); device.setMaterial_type(material_type); device.setBatch(batch); + } else if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver){ + slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); + slitTwoManipulatorDeviceDriver.setDeviceStatus(form); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java index cd1a6a1c5..a347f2f0c 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/box_palletizing_manipulator/BoxPalletizingManipulatorDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.basedriver.box_palletizing_manipulator; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -218,6 +219,9 @@ public class BoxPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriv //将扩展表中的字符串数据转换成集合 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(","); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java index ff9f350a3..cc9ec22f7 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java @@ -1,6 +1,7 @@ package org.nl.acs.device_driver.basedriver.hongxiang_device; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; @@ -28,10 +29,7 @@ import org.nl.modules.wql.util.SpringContextHolder; import org.openscada.opc.lib.da.Server; import org.springframework.beans.factory.annotation.Autowired; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; /** * 烘箱对接位 @@ -226,6 +224,22 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple 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; + } + public void writing(String param, String value) { String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 7374f9735..3e4a2a631 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -99,6 +99,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i String device_code; + //0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成 + int now_steps_type = 0; + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + @Override public Device getDevice() { @@ -154,8 +160,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i inst1.setInstruction_status("1"); instructionService.update(inst1); TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code()); - if (ObjectUtil.isNotEmpty(taskDto)){ - if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){ + if (ObjectUtil.isNotEmpty(taskDto)) { + if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) { JSONArray array = new JSONArray(); JSONObject map = new JSONObject(); map.put("task_id", taskDto.getExt_task_id()); @@ -180,11 +186,41 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); if (hongXiangConveyorDeviceDriver.getDoor() == 1 && hongXiangConveyorDeviceDriver.getAction() == 1 && hongXiangConveyorDeviceDriver.getError1() == 0) { this.writing("to_command", "2"); + this.setNow_steps_type(3); + } else { + if (this.getNow_steps_type() == 2) { + feedMessage = "请检查烘箱:door=1&&action==1&&error1=0"; + } } } else { this.writing("to_command", "2"); + this.setNow_steps_type(3); } } + } else { + if (this.getNow_steps_type() == 2) { + feedMessage = "请检查:mode == 3 && action == 1 && move == 0 && task > 0"; + } + } + + //取货完成关闭烘箱门 + if (mode == 3 && action == 2 && move == 1 && task > 0) { + Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task)); + if (ObjectUtil.isNotEmpty(inst2)) { + String start_device_code = inst2.getStart_device_code(); + Device device = deviceAppService.findDeviceByCode(start_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); + hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); + } + this.writing("to_command", "3"); + this.setNow_steps_type(4); + } + } else { + if (this.getNow_steps_type() == 3) { + feedMessage = "请检查:mode == 3 && action == 2 && move == 1 && task > 0"; + } } //申请放货 @@ -197,10 +233,18 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); hongXiangConveyorDeviceDriver.writing("to_open_door", "1"); if (hongXiangConveyorDeviceDriver.getDoor() == 1 && hongXiangConveyorDeviceDriver.getAction() == 1 && hongXiangConveyorDeviceDriver.getError1() == 0) { - this.writing("to_command", "3"); + this.writing("to_command", "4"); + this.setNow_steps_type(5); + } else { + feedMessage = "请检查烘箱:door=1&&action==1&&error1=0"; } } else { - this.writing("to_command", "3"); + this.writing("to_command", "4"); + this.setNow_steps_type(5); + } + } else { + if (this.getNow_steps_type() == 4) { + feedMessage = "请检查:mode == 3 && action == 3 && move == 1 && task > 0"; } } @@ -215,8 +259,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i e.printStackTrace(); } TaskDto taskDto = taskserver.findByCode(inst2.getTask_code()); - if (ObjectUtil.isNotEmpty(taskDto)){ - if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){ + if (ObjectUtil.isNotEmpty(taskDto)) { + if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) { JSONArray array = new JSONArray(); JSONObject map = new JSONObject(); map.put("task_id", taskDto.getTask_id()); @@ -226,24 +270,31 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } } String next_device_code = taskDto.getNext_device_code(); - String start_device_code = taskDto.getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + //String start_device_code = taskDto.getStart_device_code(); + //Device startDevice = deviceAppService.findDeviceByCode(start_device_code); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; - if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { - hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); - hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); - } +// if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { +// hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); +// hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); +// } if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); hongXiangConveyorDeviceDriver.writing("to_close_door", "1"); } - this.writing("to_command", "0"); - this.writing("to_onset", "0"); - this.writing("to_target", "0"); - this.writing("to_task", "0"); + this.writing("to_command", "5"); + this.setNow_steps_type(6); + this.setNow_steps_type(0); + feedMessage = ""; +// this.writing("to_onset", "0"); +// this.writing("to_target", "0"); +// this.writing("to_task", "0"); } } + } else { + if (this.getNow_steps_type() == 5) { + feedMessage = "请检查:mode == 3 && action == 4 && move == 0 && task > 0"; + } } } catch (Exception var17) { @@ -275,6 +326,20 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //行架机械手申请任务 if (mode == 2 && move == 0 && task == 0 && !requireSucess) { applyTask(); + } else { + if (!requireSucess) { + String remark = ""; + if (mode != 2) { + remark = remark + "mode不为2,"; + } + if (move != 0) { + remark = remark + "move不为0,"; + } + if (task != 0) { + remark = remark + "task不为0,"; + } + this.setNotCreateTaskMessage(remark); + } } } @@ -318,21 +383,27 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i String startDeviceCode = getDeviceCodeList.get(i); List taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode); if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); TaskDto taskDto = taskDtos.get(0); Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code()); + String start_device_code = instruction.getStart_device_code(); + String next_device_code = instruction.getNext_device_code(); + //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true + boolean isCloseDoor = this.judgeCloseDoor(start_device_code,next_device_code); + //未关门结束 + if (isCloseDoor){ + return false; + } instruction.setInstruction_status("1"); instruction.setUpdate_time(DateUtil.now()); instructionService.update(instruction); -// int start_addrIndex = getDeviceCodeList.indexOf(instruction.getStart_device_code()); -// int next_addrIndex = putDeviceCodeList.indexOf(instruction.getNext_device_code()); -// writing("to_onset", String.valueOf(start_addrIndex + 1)); -// writing("to_target", String.valueOf(next_addrIndex + 1)); - Device startDevice = deviceAppService.findDeviceByCode(instruction.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instruction.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))){ + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))){ + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); } String start_addr = startDevice.getExtraValue().get("address").toString(); @@ -341,11 +412,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i this.writing("to_target", next_addr); this.writing("to_task", instruction.getInstruction_code()); this.writing("to_command", "1"); + this.setNow_steps_type(2); this.setRequireSucess(true); return true; } else { List taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode); if (ObjectUtil.isNotEmpty(taskDtoList)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtoList = this.sortTask(taskDtoList); task = taskDtoList.get(0); } if (ObjectUtil.isNotEmpty(task)) break; @@ -382,26 +456,33 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i instdto.setInstruction_status("0"); instdto.setExecute_device_code(start_point_code); + //判断关联的同一列烘箱设备是否都关门 都关门返回false,有一个不关门就返回true + boolean isCloseDoor = this.judgeCloseDoor(instdto.getStart_device_code(),instdto.getNext_device_code()); + //如果未关门结束 + if (isCloseDoor){ + return false; + } + try { instructionService.create(instdto); } catch (Exception e) { + notCreateInstMessage = e.getMessage(); e.printStackTrace(); + return false; } //创建指令后修改任务状态 task.setTask_status("1"); task.setUpdate_time(DateUtil.now()); taskserver.update(task); - //根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置 -// int start_addrIndex = getDeviceCodeList.indexOf(start_device_code); -// int next_addrIndex = putDeviceCodeList.indexOf(next_device_code); -// writing("to_onset", String.valueOf(start_addrIndex + 1)); -// writing("to_target", String.valueOf(next_addrIndex + 1)); + Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))){ + if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"; throw new BadRequestException("设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))){ + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"; throw new BadRequestException("设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); } String start_addr = startDevice.getExtraValue().get("address").toString(); @@ -410,7 +491,12 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i this.writing("to_target", next_addr); this.writing("to_task", instdto.getInstruction_code()); this.writing("to_command", "1"); + this.setNow_steps_type(2); this.setRequireSucess(true); + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + } else { + notCreateInstMessage = "未找到关联设备的任务,指令无法创建"; } return true; } @@ -442,8 +528,54 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i ReadUtil.write(itemMap, server); } - public void writing(int command) { + //判断取货位或放货位为烘箱设备时关联的同一列烘箱设备是否有开门 + public boolean judgeCloseDoor(String start_device_code,String next_device_code) { + Boolean isClose = false; + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; + if (startDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startDevice.getDeviceDriver(); + List deviceCodes = hongXiangConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); + if (ObjectUtil.isNotEmpty(deviceCodes)) { + for (String deviceCode : deviceCodes) { + Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); + if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); + //判断关联设备是否开门 + if (hongXiangConveyorDeviceDriver.getDoor() == 1) { + isClose = true; + notCreateInstMessage = start_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; + break; + } + } + } + return isClose; + } + } + if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); + List deviceCodes = hongXiangConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); + if (ObjectUtil.isNotEmpty(deviceCodes)) { + for (String deviceCode : deviceCodes) { + Device linkDevice = deviceAppService.findDeviceByCode(deviceCode); + if (linkDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { + hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) linkDevice.getDeviceDriver(); + //判断关联设备是否开门 + if (hongXiangConveyorDeviceDriver.getDoor() == 1) { + isClose = true; + notCreateInstMessage = next_device_code + "关联设备->" + deviceCode + "烘箱门未关闭!"; + break; + } + } + } + return isClose; + } + } + return isClose; + } + public void writing(int command) { String opcservcerid = this.getDevice().getOpc_server_id(); Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); @@ -454,6 +586,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i //将扩展表中的字符串数据转换成集合 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(","); @@ -464,6 +599,23 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i return devicesList; } + public List sortTask(List taskDtos) { + Collections.sort(taskDtos, new Comparator() { + @Override + public int compare(TaskDto t1, TaskDto t2) { + //优先级从大到小 + int i = t2.getPriority().compareTo(t1.getPriority()); + //如果优先级相等 + if (i == 0) { + //时间从早到晚 + i = t1.getCreate_time().compareTo(t2.getCreate_time()); + } + return i; + } + }); + return taskDtos; + } + @Override public JSONObject getDeviceStatusName() { @@ -508,6 +660,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i jo.put("error", this.getError()); jo.put("isError", this.getIserror()); jo.put("message", this.getMessage()); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); return jo; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index aea14f73b..d6c8b0bea 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -58,6 +58,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + //分切行架机械手是否禁用 0否 1是 + private int is_disable = 0; + //工作模式 int mode = 0; int last_mode = 0; @@ -103,16 +106,33 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 int flag; + //前工位任务执行当前步骤 + //0未执行 1更改指令状态 2下发电气任务信息 3前工位允许取货 4前工位允许放货 5放货完成 + int now_steps_type1 = 0; + //后工位当前执行步骤 + //0未执行 1更改指令状态 2下发电气任务信息 3后工位允许取货 4后工位允许放货 5放货完成 + int now_steps_type2 = 0; + //双工位任务当前执行步骤 + //0未执行 1更改指令状态 2下发电气任务信息 3后工位允许取货 4前工位允许取货 5后工位允许放货 6后工位放货完成 7前工位允许放货 8前工位放货完成 + int now_steps_type3 = 0; + String device_code; + //请求超时时间 private int instruction_require_time_out = 3000; + //后工位申请任务请求时间 private Date instruction_require_time = new Date(); //前工位申请任务请求时间 private Date instruction_head_time = new Date(); + String notCreateTaskMessage = ""; + String notCreateInstMessage = ""; + String feedMessage = ""; + + @Override public Device getDevice() { return this.device; @@ -189,6 +209,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1)); if (inst1 != null) { if (StrUtil.equals(inst1.getInstruction_status(), "0")) { + //当前执行步骤为更新任务状态 inst1.setInstruction_status("1"); instructionService.update(inst1); TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code()); @@ -203,6 +224,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } ; + //this.setNow_steps_type1(1); } } } @@ -213,6 +235,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task2)); if (inst2 != null) { if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + //当前指令更新状态 + now_steps_type2 = 1; inst2.setInstruction_status("1"); instructionService.update(inst2); TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code()); @@ -227,6 +251,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } ; + // this.setNow_steps_type2(1); } } } @@ -237,6 +262,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl Instruction inst2 = instructionService.findByCodeFromCache(String.valueOf(task1)); if (inst2 != null) { if (StrUtil.equals(inst2.getInstruction_status(), "0")) { + //当前指令更新状态 inst2.setInstruction_status("1"); instructionService.update(inst2); TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code()); @@ -251,6 +277,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } } ; + // this.setNow_steps_type3(1); } } } @@ -275,12 +302,18 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } ; this.writing("to_command1", "4"); + this.setNow_steps_type1(5); + this.setNow_steps_type1(0); // this.writing("to_onset1", "0"); // this.writing("to_target1", "0"); // this.writing("to_task1", "0"); // this.writing("to_type", "0"); } } + } else { + if (this.getNow_steps_type1() == 4) { + feedMessage = "请检查:mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && type == 1"; + } } //单任务 后工位放货完成 任务完成 @@ -303,17 +336,28 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } ; this.writing("to_command2", "4"); - this.writing("to_onset2", "0"); - this.writing("to_target2", "0"); - this.writing("to_task2", "0"); - this.writing("to_type", "0"); + this.setNow_steps_type2(5); + this.setNow_steps_type2(0); +// this.writing("to_onset2", "0"); +// this.writing("to_target2", "0"); +// this.writing("to_task2", "0"); +// this.writing("to_type", "0"); } } + } else { + if (this.getNow_steps_type2() == 4) { + feedMessage = "请检查:mode == 3 && action2 == 4 && move2 == 0 && task2 > 0 && type == 2"; + } } //双任务后工位反馈4 - if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3 ){ + if (mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3) { this.writing("to_command2", "4"); + this.setNow_steps_type3(6); + } else { + if (this.getNow_steps_type3() == 5) { + feedMessage = "请检查:mode == 3 && action2 == 4 && move2 == 0 && task1 > 0 && task2 > 0 && type == 3"; + } } //双工位 任务完成 前工位反馈4 @@ -333,8 +377,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl array.add(map); acsToWmsService.feedbackTaskStatusToWms(array); } - }; + } + ; this.writing("to_command1", "4"); + this.setNow_steps_type3(8); + this.setNow_steps_type3(0); // this.writing("to_onset1", "0"); // this.writing("to_target1", "0"); // this.writing("to_task1", "0"); @@ -344,6 +391,10 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl // this.writing("to_type", "0"); } } + } else { + if (this.getNow_steps_type3() == 7) { + feedMessage = "请检查:mode == 3 && action1 == 4 && move1 == 0 && task1 > 0 && task2 > 0 && type == 3"; + } } @@ -351,10 +402,10 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl if (mode == 3 && action2 == 1 && move2 == 0 && task2 > 0) { Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2)); String start_device_code = ""; - if (type == 2){ + if (type == 2) { start_device_code = inst1.getStart_device_code(); } - if (type == 3){ + if (type == 3) { start_device_code = inst1.getStart_device_code2(); } Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); @@ -365,20 +416,50 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl int mode = siemensConveyorDeviceDriver.getMode(); if (mode == 2 && move == 1) { this.writing("to_command2", "2"); + if (type == 2) { + this.setNow_steps_type2(3); + } else if (type == 3) { + this.setNow_steps_type3(3); + } } else { log.warn("前工位取货位无货,取货位:{},mode:{},move:{}", start_device_code, mode, move); + if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { + feedMessage = "请检查输送线:mode == 2 && move == 1"; + } } } + } else { + if (this.getNow_steps_type2() == 2 || this.getNow_steps_type3() == 2) { + feedMessage = "请检查:mode == 3 && action2 == 1 && move2 == 0 && task2 > 0"; + } } //后工位允许放货 if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) { this.writing("to_command2", "3"); + if (type == 2) { + this.setNow_steps_type2(4); + } else if (type == 3) { + this.setNow_steps_type3(5); + } + } else { + if (this.getNow_steps_type2() == 3 || this.getNow_steps_type3() == 4) { + feedMessage = "请检查:mode == 3 && action2 == 3 && move2 == 1 && task2 > 0"; + } } //前工位允许取货 if (mode == 3 && action1 == 1 && move1 == 0 && task1 > 0) { this.writing("to_command1", "2"); + if (type == 1) { + this.setNow_steps_type1(3); + } else if (type == 2) { + this.setNow_steps_type3(4); + } + } else { + if (this.getNow_steps_type1() == 2 || this.getNow_steps_type3() == 3) { + feedMessage = "请检查mode == 3 && action1 == 1 && move1 == 0 && task1 > 0"; + } } //前工位放货时判断放货位光电信号 @@ -393,10 +474,22 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl int mode = siemensConveyorDeviceDriver.getMode(); if (move == 0 && mode == 2) { this.writing("to_command1", "3"); + if (type == 1) { + this.setNow_steps_type1(4); + } else if (type == 2) { + this.setNow_steps_type3(7); + } } else { log.warn("后工位放货位有货,放货位:{},mode:{},move:{}", next_device_code, mode, move); + if (this.getNow_steps_type1() == 3 || this.getNow_steps_type3() == 6) { + feedMessage = "请检查输送线:move == 0 && mode == 2"; + } } } + } else { + if (this.getNow_steps_type1() == 3 || this.getNow_steps_type3() == 6) { + feedMessage = "请检查:mode == 3 && action1 == 3 && move1 == 1 && task1 > 0"; + } } } catch (Exception var17) { @@ -428,8 +521,58 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl case 2: //申请任务 if (mode == 2 && move1 == 0 && move2 == 0 && action1 == 0 && action2 == 0 && task1 == 0 && task2 == 0 && !requireSucess) { + //获取关联设备驱动信息 判断关联设备是否禁用 + Device device = deviceAppservice.findDeviceByCode(device_code); + SlitTwoManipulatorDeviceDriver slitTwoManipulatorDeviceDriver; + if (device.getDeviceDriver() instanceof SlitTwoManipulatorDeviceDriver) { + slitTwoManipulatorDeviceDriver = (SlitTwoManipulatorDeviceDriver) device.getDeviceDriver(); + //如果禁用 + if (slitTwoManipulatorDeviceDriver.getIs_disable() == 1) { + boolean flag = false; + try { + //就去走关联设备异常取放货工位的任务 任务生成成功返回true 就不会走下面正常生成任务的逻辑 + flag = instruction_require2(); + } catch (Exception e) { + flag = false; + } + if (flag) { + break; + } + } + } + //没有生成异常取放货工位的任务 就生成正常关联取放货工位的任务 instruction_require(); + feedMessage = ""; logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",action1:" + action1 + ",requireSucess:" + requireSucess); + } else { +// if (!requireSucess) { +// remark = remark + "请求标记为true,请检查mode是否由其他值变为2!"; +// } + if (!requireSucess) { + String remark = ""; + if (mode != 2) { + remark = remark + "mode不为2,"; + } + if (move1 != 0) { + remark = remark + "move1不为0,"; + } + if (move2 != 0) { + remark = remark + "move2不为0,"; + } + if (action1 != 0) { + remark = remark + "action1不为0,"; + } + if (action2 != 0) { + remark = remark + "action2不为0,"; + } + if (task1 != 0) { + remark = remark + "task1不为0,"; + } + if (task2 != 0) { + remark = remark + "task2不为0,"; + } + this.setNotCreateTaskMessage(remark); + } } break; case 3: @@ -450,8 +593,82 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl last_task2 = task2; } - //申请任务 + //关联设备异常申请任务 + public synchronized boolean instruction_require2() { + Boolean flag = false; + 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("error_head_get_device_code"); + //后工位取货关联设备 + List backGetDeviceCodeList = this.getExtraDeviceCodes("error_back_get_device_code"); + TaskDto taskDto = null; + //遍历前工位取货点设备 + for (String getDeviceCode : getDeviceCodeList) { + //去任务表中查询是否有前工位关联设备的重新创建指令的任务 + List taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode); + //如果有 + if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); + taskDto = taskDtos.get(0); + flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + return flag; + } else { + //去任务表中查询是否有前工位关联设备的就绪状态下的任务 + taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); + taskDto = taskDtos.get(0); + break; + } + } + } + //如果任务表中起点1或起点2中 无前工位取货点关联设备 + //就去查询任务表中查找起点1或起点2为后工位取货点关联设备的任务 + if (ObjectUtil.isEmpty(taskDto)) { + for (String backGetDeviceCode : backGetDeviceCodeList) { + //去任务表中查询是否有前工位关联设备的重新创建指令的任务 + List taskDtos = taskserver.queryTaskByNextAndIntStatus(backGetDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); + taskDto = taskDtos.get(0); + flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + return flag; + } else { + //去任务表中查询是否有后工位关联设备的就绪状态下的任务 + taskDtos = taskserver.queryTaskByStartDeviceCode(backGetDeviceCode); + if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); + taskDto = taskDtos.get(0); + break; + } + } + } + } + if (!ObjectUtil.isEmpty(taskDto)) { + flag = this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + if (flag) { + notCreateInstMessage = ""; + } + } else { + notCreateTaskMessage = ""; + notCreateInstMessage = "未找到关联设备禁用的任务!"; + } + } + return flag; + } + + //正常申请任务 public synchronized boolean instruction_require() { + boolean flag = false; Date date = new Date(); if (date.getTime() - this.instruction_head_time.getTime() < (long) this.instruction_require_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_head_time); @@ -469,13 +686,17 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl List taskDtos = taskserver.queryTaskByStartAndIntStatus(getDeviceCode); //如果有 if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return true; + flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + return flag; } else { //去任务表中查询是否有前工位关联设备的就绪状态下的任务 taskDtos = taskserver.queryTaskByStartDeviceCode(getDeviceCode); if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); break; } @@ -488,28 +709,40 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //去任务表中查询是否有前工位关联设备的重新创建指令的任务 List taskDtos = taskserver.queryTaskByNextAndIntStatus(backGetDeviceCode); if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); - this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); - return true; + flag = this.executeBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + return flag; } else { //去任务表中查询是否有后工位关联设备的就绪状态下的任务 taskDtos = taskserver.queryTaskByStartDeviceCode(backGetDeviceCode); if (ObjectUtil.isNotEmpty(taskDtos)) { + //按照优先级排序 优先级相等按照创建时间排序 + taskDtos = this.sortTask(taskDtos); taskDto = taskDtos.get(0); break; } } } } + if (!ObjectUtil.isEmpty(taskDto)) { - this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + flag = this.executeReadyBusiness(taskDto, getDeviceCodeList, backGetDeviceCodeList); + if (flag) { + notCreateInstMessage = ""; + } + } else { + notCreateTaskMessage = ""; + notCreateInstMessage = "未找到正常关联设备的任务!"; } } - return true; + return flag; } //执行重新生成指令的任务 - public void executeBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { + public synchronized boolean executeBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { + boolean flag = false; //任务类型 1.前工位任务 2.后工位任务 3.双工位任务 String type = ""; //获取指令信息 @@ -552,17 +785,33 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //修改指令状态 instructionDto.setInstruction_status("1"); instructionDto.setUpdate_time(DateUtil.now()); - instructionService.update(instructionDto); + try { + instructionService.update(instructionDto); + if (StrUtil.equals(type, "1")) { + this.setNow_steps_type1(1); + } + if (StrUtil.equals(type, "2")) { + this.setNow_steps_type2(1); + } + if (StrUtil.equals(type, "3")) { + this.setNow_steps_type3(1); + } + flag = true; + } catch (Exception e) { + logServer.deviceExecuteLog(device_code, "", instructionDto.getInstruction_code(), "执行重新生成指令的任务失败,原因->" + e.getMessage()); + } //下发电气信号 this.sendSignalType(instructionDto, type); //请求任务成功 this.setRequireSucess(true); + return flag; } //执行就绪状态下的任务 - public void executeReadyBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { + public synchronized boolean executeReadyBusiness(TaskDto taskDto, List getDeviceCodeList, List backGetDeviceCodeList) { + boolean flag = false; //任务类型 1.前工位任务 2.后工位任务 3.双工位任务 String type = ""; //获取任务表中的取货点1 @@ -639,8 +888,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl try { instructionService.create(instdto); + flag = true; } catch (Exception e) { - e.printStackTrace(); + notCreateInstMessage = e.getMessage(); logServer.deviceExecuteLog(device_code, "", instdto.getInstruction_code(), "指令创建失败,原因->" + e.getMessage()); } @@ -654,10 +904,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //请求任务成功 this.setRequireSucess(true); + return flag; } //下发电气信号 - public void sendSignalType(Instruction dto, String type) { + public synchronized void sendSignalType(Instruction dto, String type) { String start_device_code = dto.getStart_device_code(); String next_device_code = dto.getNext_device_code(); Device startDevice = deviceAppservice.findDeviceByCode(start_device_code); @@ -670,12 +921,14 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl this.writing("to_task1", dto.getInstruction_code()); this.writing("to_command1", "1"); this.writing("to_type", "1"); + this.setNow_steps_type1(2); } else if (StrUtil.equals(type, "2")) { 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_type", "2"); + this.setNow_steps_type2(2); } else if (StrUtil.equals(type, "3")) { String start_device_code2 = dto.getStart_device_code2(); String next_device_code2 = dto.getNext_device_code2(); @@ -692,6 +945,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl this.writing("to_task2", dto.getInstruction_code()); this.writing("to_command2", "1"); this.writing("to_type", "3"); + this.setNow_steps_type3(2); } } @@ -699,6 +953,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl public void isSetAddress(Device device) { if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) { logServer.deviceExecuteLog(device_code, "", "task1:" + task1 + ",task2:" + task2, "设备:" + device.getDevice_code() + "未设置电气调度号!"); + notCreateInstMessage = "设备:" + device.getDevice_code() + "未设置电气调度号!"; throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!"); } } @@ -785,6 +1040,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl //将扩展表中的字符串数组数据转换成集合 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(","); @@ -795,16 +1053,35 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl return devicesList; } + public List sortTask(List taskDtos){ + Collections.sort(taskDtos, new Comparator() { + @Override + public int compare(TaskDto t1, TaskDto t2) { + //优先级从大到小 + int i = t2.getPriority().compareTo(t1.getPriority()); + //如果优先级相等 + if (i == 0){ + //时间从早到晚 + i = t1.getCreate_time().compareTo(t2.getCreate_time()); + } + return i; + } + }); + return taskDtos; + } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); - String move1 = ""; - String move2 = ""; + String move_1 = ""; + String move_2 = ""; String action1 = ""; String action2 = ""; String walk_y = ""; String mode = ""; String status = ""; + String is_disable = ""; + if (this.getMode() == 0) { mode = "脱机"; @@ -816,7 +1093,9 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl mode = "运行中"; } - if (this.getStatus() == 1) { + if (this.getStatus() == 0) { + status = "0"; + } else if (this.getStatus() == 1) { status = "待机"; } else if (this.getStatus() == 2) { status = "生产中"; @@ -825,15 +1104,15 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl } if (this.getMove1() == 0) { - move1 = "无货"; + move_1 = "无货"; } else if (this.getMove1() == 1) { - move1 = "有货"; + move_1 = "有货"; } if (this.getMove2() == 0) { - move2 = "无货"; + move_2 = "无货"; } else if (this.getMove2() == 1) { - move2 = "有货"; + move_2 = "有货"; } if (this.getAction1() == 1) { @@ -862,25 +1141,41 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl walk_y = "非原位"; } + if (this.getIs_disable() == 0) { + is_disable = "正常"; + } else if (this.getIs_disable() == 1) { + is_disable = "禁用"; + } + 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("move_1", move_1); + jo.put("move_2", move_2); + jo.put("action_1", action1); + jo.put("action_2", action2); jo.put("walk_y", walk_y); jo.put("error", this.getError()); jo.put("task1", this.getTask1()); jo.put("task2", this.getTask2()); jo.put("isOnline", this.getIsonline()); jo.put("isError", this.getIserror()); + jo.put("is_disable1", this.getIs_disable()); + jo.put("is_disable", is_disable); jo.put("message", this.getMessage()); + jo.put("is_click", true); + jo.put("driver_type", "slit_two_manipulator"); + jo.put("notCreateTaskMessage", notCreateTaskMessage); + jo.put("notCreateInstMessage", notCreateInstMessage); + jo.put("feedMessage", feedMessage); return jo; } @Override public void setDeviceStatus(JSONObject data) { - + String is_disable = data.getString("is_disable"); + if (StrUtil.isNotEmpty(is_disable)) { + this.setIs_disable(Integer.parseInt(is_disable)); + } } } diff --git a/acs/nladmin-ui/.env.production b/acs/nladmin-ui/.env.production index 786bd4276..762ac12e7 100644 --- a/acs/nladmin-ui/.env.production +++ b/acs/nladmin-ui/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'http://47.97.157.227:8010' +VUE_APP_BASE_API = 'http://127.0.0.1:8010' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'ws://47.97.157.227:8010' +VUE_APP_WS_API = 'ws://127.0.0.1:8010' diff --git a/acs/nladmin-ui/src/views/acs/device/driver/slit_two_manipulator.vue b/acs/nladmin-ui/src/views/acs/device/driver/slit_two_manipulator.vue index 038258353..4f31ec24f 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/slit_two_manipulator.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/slit_two_manipulator.vue @@ -101,7 +101,6 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -377,7 +450,11 @@ export default { head_get_device_code: [], back_get_device_code: [], head_put_device_code: [], - back_put_device_code: [] + back_put_device_code: [], + error_head_get_device_code: [], + error_back_get_device_code: [], + error_head_put_device_code: [], + error_back_put_device_code: [] }, rules: {} } diff --git a/acs/nladmin-ui/src/views/acs/monitor/device/index.vue b/acs/nladmin-ui/src/views/acs/monitor/device/index.vue index b94839715..a06ec01b7 100644 --- a/acs/nladmin-ui/src/views/acs/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/acs/monitor/device/index.vue @@ -485,6 +485,9 @@ export default { } else if (val === 'error_num') { const obj = { name: '故障次数', value: data[val] } arr.push(obj) + } else if (val === 'is_disable') { + const obj = { name: '是否禁用', value: data[val] } + arr.push(obj) } } return arr diff --git a/acs/nladmin-ui/src/views/acs/monitor/device/index2.vue b/acs/nladmin-ui/src/views/acs/monitor/device/index2.vue index b94839715..a06ec01b7 100644 --- a/acs/nladmin-ui/src/views/acs/monitor/device/index2.vue +++ b/acs/nladmin-ui/src/views/acs/monitor/device/index2.vue @@ -485,6 +485,9 @@ export default { } else if (val === 'error_num') { const obj = { name: '故障次数', value: data[val] } arr.push(obj) + } else if (val === 'is_disable') { + const obj = { name: '是否禁用', value: data[val] } + arr.push(obj) } } return arr diff --git a/acs/nladmin-ui/src/views/system/monitor/device/index.vue b/acs/nladmin-ui/src/views/system/monitor/device/index.vue index 28c16ab2c..fcace411e 100644 --- a/acs/nladmin-ui/src/views/system/monitor/device/index.vue +++ b/acs/nladmin-ui/src/views/system/monitor/device/index.vue @@ -79,16 +79,10 @@ - - - - - - - - - - + + + 正常 + 禁用 @@ -127,6 +121,7 @@ import '@logicflow/extension/lib/style/index.css' import { LogicFlow } from '@logicflow/core' import { registerCustomElement } from '@/views/system/logicflow/editor/components/node' + let data = {} let lf = '' export default { @@ -152,7 +147,8 @@ export default { suspended: null, material_type: '', requireSucess: '', - fullrequireSucess: '' + fullrequireSucess: '', + is_disable: '' }, allDeviceMsg: [], msgTop: '200px', @@ -210,7 +206,7 @@ export default { nodeMenu: false }) lf.on('node:click', (data, e) => { // 鼠标点击节点 - console.log("data: ", data) + console.log('data: ', data) // 展开显示设备信息 if (data.data.type !== 'pro-rect' && data.data.type !== 'pro-circle' && data.data.type !== 'triangle' && data.data.type !== 'rect-radius') { if (data.data.properties.device) { @@ -280,6 +276,8 @@ export default { this.dialogFormVisible4 = true } else if (clickObj.data.driver_type === 'hailiang_xj_plc_test') { this.$refs.child1.setForm(clickObj) + } else if (clickObj.data.driver_type === 'slit_two_manipulator') { + this.dialogFormVisible4 = true } else { this.dialogFormVisible = true } @@ -291,6 +289,7 @@ export default { this.form.material_type = clickObj.data.material_type this.form.requireSucess = clickObj.data.requireSucess this.form.fullrequireSucess = clickObj.data.fullrequireSucess + this.form.is_disable = clickObj.data.is_disable1 }, moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息 let item = '' @@ -505,6 +504,18 @@ export default { } else if (val === 'Wthickness') { const obj = { name: 'W厚度', value: data[val] } this.arr.push(obj) + } else if (val === 'is_disable') { + const obj = { name: '是否禁用', value: data[val] } + this.arr.push(obj) + } else if (val === 'notCreateTaskMessage') { + const obj = { name: '任务创建失败原因', value: data[val] } + this.arr.push(obj) + } else if (val === 'notCreateInstMessage') { + const obj = { name: '指令创建失败原因', value: data[val] } + this.arr.push(obj) + } else if (val === 'feedMessage') { + const obj = { name: '未反馈电气信号原因', value: data[val] } + this.arr.push(obj) } } } @@ -588,12 +599,15 @@ body { background-color: #f8f9fa; height: 100%; } + .newDialog /deep/ .el-dialog__header { padding: 1vh 1vw 0 1vw; } + .newDialog /deep/ .el-dialog__body { padding: 1vh 1vw; } + .toolbar-sty { position: absolute; margin-top: 5px; diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/crm/service/impl/CrmToLmsServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/ext/crm/service/impl/CrmToLmsServiceImpl.java index df6ea208b..92029505e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/crm/service/impl/CrmToLmsServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/crm/service/impl/CrmToLmsServiceImpl.java @@ -108,6 +108,7 @@ public class CrmToLmsServiceImpl implements CrmToLmsService { String warehouse_code = jo.getString("warehouse_code"); String dateoffginbound = jo.getString("dateoffginbound"); String packageboxsn = jo.getString("packageboxsn"); + String container_name = jo.getString("container_name"); HashMap map = new HashMap<>(); if (StrUtil.isNotEmpty(material_code)) { @@ -146,6 +147,9 @@ public class CrmToLmsServiceImpl implements CrmToLmsService { if (StrUtil.isNotEmpty(warehouse_code)) { map.put("warehouse_code", warehouse_code); } + if (StrUtil.isNotEmpty(container_name)) { + map.put("container_name", container_name); + } //将查询条件带入,查询LMS成品库库存信息 JSONArray rows = WQL.getWO("QCRM_001").addParamMap(map).addParam("flag", "1").process().getResultJSONArray(0); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/QCRM_001.wql b/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/QCRM_001.wql index 070f97000..b485e161f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/QCRM_001.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/ext/wql/QCRM_001.wql @@ -22,6 +22,7 @@ 输入.dateoffginbound TYPEAS s_string 输入.warehouse_code TYPEAS s_string 输入.customerdescription TYPEAS s_string + 输入.container_name TYPEAS s_string 输入.width TYPEAS f_string @@ -64,6 +65,7 @@ sub.length, stor.ext_id AS warehouse_code, sub.date_of_production AS dateofproduction, + sub.container_name, CONCAT(sub.un_plan_product_property1,sub.un_plan_product_property2,sub.un_plan_product_property3) AS unplanproductproperty FROM pdm_bi_subpackagerelation sub diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java index 35fdec630..9e682078e 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/pda/st/service/impl/PrintServiceImpl.java @@ -55,14 +55,20 @@ public class PrintServiceImpl implements PrintService { if (ObjectUtil.isEmpty(box_jo)) { throw new BadRequestException("未查询到木箱相关信息!"); } - //组织木箱打印信息 //箱号 String package_box_sn = box_jo.getString("package_box_sn"); - // 木箱1 - String package_box_sn1 = package_box_sn.substring(0,package_box_sn.indexOf("@")+1); - // 木箱2 - String package_box_sn2 = package_box_sn.substring(package_box_sn.indexOf("@") + 1, package_box_sn.length()); + + String package_box_sn1 = ""; + String package_box_sn2 = ""; + try { + // 木箱1 + package_box_sn1 = package_box_sn.substring(0,package_box_sn.indexOf("@")+1); + // 木箱2 + package_box_sn2 = package_box_sn.substring(package_box_sn.indexOf("@") + 1, package_box_sn.length()); + } catch (Exception e) { + package_box_sn2 = package_box_sn; + } //订单号 String sale_order_name = box_jo.getString("sale_order_name"); //品名 @@ -132,13 +138,13 @@ public class PrintServiceImpl implements PrintService { + width + "," + pcsn + "," + date_of_FG_inbound + "," - + box_weight + "," + + box_weight + "KG," + date_of_production + "," + quanlity_in_box + "," + quality_guaran_period + "," + nspector + "," + storage_conditions + "," - + NumberUtil.round(weight,2).toString() + "," + + NumberUtil.round(weight,2).toString() + "KG," + box_jo.getString("customer_name") + "," + box_jo.getString("customer_description") + "," + box_jo.getString("thickness") + "," diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java index 8c488cbd3..68ec531a3 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/CheckOutBillService.java @@ -106,6 +106,11 @@ public interface CheckOutBillService { * @param whereJson / */ void allCancel(JSONObject whereJson); + /** + * 取消一个 + * @param whereJson / + */ + void oneCancel(JSONObject whereJson); /** * 设置检验站点 * @param whereJson / diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/InchargeServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/InchargeServiceImpl.java index 1f7444f79..0ee6477b0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/InchargeServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/inbill/service/impl/InchargeServiceImpl.java @@ -193,6 +193,7 @@ public class InchargeServiceImpl implements InchargeService { WQLObject disTab = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); // 出入库分配表 WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_StructIvt"); // 仓位库存表 WQLObject attrTab = WQLObject.getWQLObject("ST_IVT_StructAttr"); // 仓位表 + WQLObject wo_sect = WQLObject.getWQLObject("st_ivt_sectattr"); // 库区表 Long currentUserId = SecurityUtils.getCurrentUserId(); String nickName = SecurityUtils.getCurrentNickName(); @@ -274,7 +275,8 @@ public class InchargeServiceImpl implements InchargeService { jsonOutDis.put("box_no", json2.getString("box_no")); jsonOutDis.put("quality_scode", "01"); // 如果是虚拟库区则将执行状态改为生成:01 - if (StrUtil.equals(jsonOutDis.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + json2.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { jsonOutDis.put("work_status", "01"); } else { jsonOutDis.put("work_status", "00"); diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java index 4de247ff6..a8ae10b71 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/rest/CheckOutBillController.java @@ -98,6 +98,13 @@ public class CheckOutBillController { checkOutBillService.allCancel(whereJson); return new ResponseEntity<>(HttpStatus.NO_CONTENT); } + @PostMapping("/oneCancel") + @Log("出库单全部取消") + @ApiOperation("出库单全部取消") + public ResponseEntity oneCancel(@RequestBody JSONObject whereJson) { + checkOutBillService.oneCancel(whereJson); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } @GetMapping("/getOutBillDis") @Log("查询出库单分配") @ApiOperation("查询出库单分配") diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java index 33df6b742..0731d81d7 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/service/impl/CheckOutBillServiceImpl.java @@ -703,6 +703,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); //出库主表 WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //库区表 + WQLObject wo_sect = WQLObject.getWQLObject("st_ivt_sectattr"); //定义需要更新的仓位集合 HashMap Struct_map = new HashMap(); @@ -741,6 +743,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { is_top3 = true; } JSONObject jsonMap = new JSONObject(); + // 已分配重量 + double assign_qty = dtl.getDoubleValue("assign_qty"); if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) { while (unassign_qty > 0) { @@ -762,6 +766,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int j = 0; j < ivtAllArr.size(); j++) { JSONObject ivt = ivtAllArr.getJSONObject(j); double canuse_qty = ivt.getDoubleValue("canuse_qty"); + assign_qty = NumberUtil.add(assign_qty,canuse_qty); if (unassign_qty >= canuse_qty) { unassign_qty = NumberUtil.sub(unassign_qty,canuse_qty); @@ -803,7 +808,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { dtl.put("plan_qty", ivt2.getDoubleValue("change_qty")); dtl.put("real_qty", ivt2.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(ivt2.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { dtl.put("work_status", "01"); } else { dtl.put("work_status", "00"); @@ -832,6 +838,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { double canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); jsonIvt.put("change_qty", canuse_qty + ""); unassign_qty = 0; + assign_qty = NumberUtil.add(assign_qty,canuse_qty); //更新库存 jsonIvt.put("bill_type_scode", jo_mst.getString("bill_type")); @@ -856,7 +863,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty")); dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(jsonIvt.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { dtl.put("work_status", "01"); } else { dtl.put("work_status", "00"); @@ -877,7 +885,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { HashMap map_dtl = new HashMap(); //更新明细 map_dtl.put("unassign_qty", unassign_qty + ""); - map_dtl.put("assign_qty", (plan_qty - unassign_qty) + ""); + map_dtl.put("assign_qty", assign_qty + ""); if (unassign_qty == 0) { map_dtl.put("bill_status", "40"); } else { @@ -913,6 +921,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); //出库主表 WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //库区表 + WQLObject wo_sect = WQLObject.getWQLObject("st_ivt_sectattr"); //定义需要更新的仓位集合 HashMap Struct_map = new HashMap(); @@ -951,7 +961,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { is_top3 = true; } JSONObject jsonMap = new JSONObject(); - + // 已分配数量 + double assign_qty = dtl.getDoubleValue("assign_qty"); if (ObjectUtil.isNotEmpty(dtl.getString("source_bill_code")) || is_top3) { while (unassign_qty > 0) { // 1.有销售订单号 @@ -972,6 +983,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { for (int j = 0; j < ivtAllArr.size(); j++) { JSONObject ivt = ivtAllArr.getJSONObject(j); double canuse_qty = ivt.getDoubleValue("canuse_qty"); + assign_qty = NumberUtil.add(assign_qty,canuse_qty); if (unassign_qty >= canuse_qty) { unassign_qty = unassign_qty - canuse_qty; @@ -1013,7 +1025,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { dtl.put("plan_qty", ivt2.getDoubleValue("change_qty")); dtl.put("real_qty", ivt2.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(ivt2.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt2.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { dtl.put("work_status", "01"); } else { dtl.put("work_status", "00"); @@ -1040,6 +1053,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { if (ObjectUtil.isEmpty(jsonIvt)) throw new BadRequestException("库存不足"); double canuse_qty = jsonIvt.getDoubleValue("canuse_qty"); + assign_qty = NumberUtil.add(assign_qty,canuse_qty); jsonIvt.put("change_qty", canuse_qty + ""); unassign_qty = 0; @@ -1066,7 +1080,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { dtl.put("plan_qty", jsonIvt.getDoubleValue("change_qty")); dtl.put("real_qty", jsonIvt.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(jsonIvt.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + jsonIvt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { dtl.put("work_status", "01"); } else { dtl.put("work_status", "00"); @@ -1079,7 +1094,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { HashMap map_dtl = new HashMap(); //更新明细 map_dtl.put("unassign_qty", unassign_qty + ""); - map_dtl.put("assign_qty", (plan_qty - unassign_qty) + ""); + map_dtl.put("assign_qty", assign_qty + ""); if (unassign_qty == 0) { map_dtl.put("bill_status", "40"); } else { @@ -1128,7 +1143,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { json.put("plan_qty", ivt.getDoubleValue("change_qty")); json.put("real_qty", ivt.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(ivt.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { json.put("work_status", "01"); } else { json.put("work_status", "00"); @@ -1160,7 +1176,6 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } } - @Override @Transactional(rollbackFor = Exception.class) public void allCancel(JSONObject whereJson) { @@ -1218,8 +1233,115 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { //更新【出入库单明细表】中分配记录 JSONObject jo_dtl = wo_dtl.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0); - jo_dtl.put("assign_qty", jo_dtl.getDoubleValue("assign_qty") - plan_qty); - jo_dtl.put("unassign_qty", jo_dtl.getDoubleValue("unassign_qty") + plan_qty); + + jo_dtl.put("assign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("assign_qty") ,plan_qty)); + jo_dtl.put("unassign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("plan_qty"),jo_dtl.getDoubleValue("assign_qty"))); + + if (jo_dtl.getDoubleValue("assign_qty") < 0) { + jo_dtl.put("assign_qty", 0); + } + + if (jo_dtl.getDoubleValue("unassign_qty") > jo_dtl.getDoubleValue("plan_qty")) { + jo_dtl.put("unassign_qty", jo_dtl.getDoubleValue("plan_qty")); + } + + if (jo_dtl.getDoubleValue("unassign_qty") == jo_dtl.getDoubleValue("plan_qty")) { + jo_dtl.put("bill_status", "10"); + } else { + jo_dtl.put("bill_status", "30"); + } + wo_dtl.update(jo_dtl); + //更新主表状态 + this.updateMststatus(iostorinv_id); + //判断是否存在同单据的同起点仓位的分配 + JSONArray flag = WQL.getWO("QST_IVT_CHECKOUTBILL") + .addParam("flag", "5") + .addParam("is_issued", "0") + .addParam("struct_id", dis.getString("struct_id")) + .addParam("iostorinv_id", iostorinv_id) + .addParam("bill_status", "01") + .process() + .getResultJSONArray(0); + if (flag.size() == 0) {//仓位载具冻结数为0 + //任务号不为空 + if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) { + //更新对应任务为删除 + map.put("is_delete", "1"); + wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'"); + } + //解锁起点仓位点位 + JSONObject from_start = new JSONObject(); + from_start.put("struct_id", dis.getString("struct_id")); + from_start.put("lock_type", "1"); + storPublicService.updateStructAndPoint2(from_start); + //解锁终点仓位点位 + if (StrUtil.isNotEmpty(dis.getString("point_code"))) { + JSONObject from_end = new JSONObject(); + from_end.put("point_code", dis.getString("point_code")); + from_end.put("lock_type", "1"); + storPublicService.updateStructAndPoint2(from_end); + } + } else {//仓位载具扔有冻结数,需改任务类型为拣选出库 + //任务号不为空 + /* if (ObjectUtil.isNotEmpty(dis.getString("task_id"))) { + //更新对应任务为拣选出库 + map.put("taskdtl_type", "05"); + wo_Task.update(map, "task_id='" + dis.getString("task_id") + "'"); + }*/ + } + } + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void oneCancel(JSONObject whereJson) { + //出库分配表 + WQLObject wo_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis"); + //出库明细表 + WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); + //出库主表 + WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //任务表 + WQLObject wo_Task = WQLObject.getWQLObject("SCH_BASE_Task"); + + String iostorinv_id = whereJson.getString("iostorinv_id"); + //查询主表信息 + JSONObject jo_mst = wo_mst.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0); + // 查询此分配明细下的所有相同箱号的分配明细 + JSONArray diss = wo_dis.query("box_no = '" + whereJson.getString("storagevehicle_code") + "' and iostorinv_id = '"+iostorinv_id+"'").getResultJSONArray(0); + + for (int i = 0; i < diss.size(); i++) { + JSONObject dis = diss.getJSONObject(i); + HashMap map = new HashMap<>(); + + String iostorinvdtl_id = dis.getString("iostorinvdtl_id"); + //统计【出入库单分配表】执行状态大于等于执行中,或【任务指令表】任务状态大于等于下发时的记录和 + JSONArray dtl = WQL.getWO("QST_IVT_CHECKOUTBILL") + .addParam("flag", "4") + .addParam("iostorinvdtl_id", iostorinvdtl_id) + .process() + .getResultJSONArray(0); + //若存在记录,则不可取消该出库明细对应的任何分配记录 + if (dtl.size() != 0) { + throw new BadRequestException("存在出库明细对应任务执行中或完成!"); + } + double plan_qty = dis.getDoubleValue("plan_qty"); + //更新库存 + dis.put("change_qty", plan_qty + ""); + dis.put("bill_type_scode", jo_mst.getString("bill_type")); + dis.put("inv_id", iostorinv_id); + dis.put("bill_code", jo_mst.getString("bill_code")); + dis.put("bill_table", "ST_IVT_IOStorInv"); + storPublicService.IOStor(dis, "12"); + //删除【出入库单分配表】中分配记录 + wo_dis.delete("iostorinvdis_id='" + dis.getString("iostorinvdis_id") + "'"); + //更新【出入库单明细表】中分配记录 + JSONObject jo_dtl = wo_dtl.query("iostorinvdtl_id = '" + iostorinvdtl_id + "'").uniqueResult(0); + + + jo_dtl.put("assign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("assign_qty") ,plan_qty)); + jo_dtl.put("unassign_qty", NumberUtil.sub(jo_dtl.getDoubleValue("plan_qty"),jo_dtl.getDoubleValue("assign_qty"))); if (jo_dtl.getDoubleValue("assign_qty") < 0) { jo_dtl.put("assign_qty", 0); @@ -1668,6 +1790,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { WQLObject wo_dtl = WQLObject.getWQLObject("ST_IVT_IOStorInvDtl"); //出库主表 WQLObject wo_mst = WQLObject.getWQLObject("ST_IVT_IOStorInv"); + //库区表 + WQLObject wo_sect = WQLObject.getWQLObject("st_ivt_sectattr"); //定义需要更新的仓位集合 HashMap Struct_map = new HashMap<>(); @@ -1693,6 +1817,30 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { throw new BadRequestException("当前订单无可分配出库明细"); } + // 判断此明细是否有子卷号:没有则过滤箱号、将此箱子里的所有子卷带出来 + if (ObjectUtil.isEmpty(dtl.getString("pcsn"))) { + HashSet boxSet = new HashSet<>(); + JSONArray boxArr = new JSONArray(); + + for (int i = 0; i < rows.size(); i++) { + JSONObject json = rows.getJSONObject(i); + boxSet.add(json.getString("storagevehicle_code")); + } + + for (String box_no : boxSet) { + JSONArray boxIvtArr = WQL.getWO("QST_IVT_CHECKOUTBILL") + .addParam("flag", "3") + .addParam("box_no", box_no) + .process() + .getResultJSONArray(0); + + boxArr.addAll(boxIvtArr); + } + rows.clear(); + rows.addAll(boxArr); + } + + double assign_qty = dtl.getDoubleValue("assign_qty"); double unassign_qty = dtl.getDoubleValue("unassign_qty"); double plan_qty = dtl.getDoubleValue("plan_qty"); @@ -1701,6 +1849,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { JSONObject ivt = rows.getJSONObject(j); double canuse_qty = ivt.getDoubleValue("ivt_qty"); + assign_qty = NumberUtil.add(assign_qty,canuse_qty); + if (unassign_qty >= canuse_qty) { unassign_qty = unassign_qty - canuse_qty; ivt.put("change_qty", canuse_qty + ""); @@ -1731,7 +1881,8 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { dtl.put("plan_qty", ivt.getDoubleValue("change_qty")); dtl.put("real_qty", ivt.getDoubleValue("change_qty")); // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(ivt.getString("sect_code"), "XN01")) { + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { dtl.put("work_status", "01"); } else { dtl.put("work_status", "00"); @@ -1746,7 +1897,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { HashMap map_dtl = new HashMap(); //更新明细 map_dtl.put("unassign_qty", unassign_qty + ""); - map_dtl.put("assign_qty", (plan_qty - unassign_qty) + ""); + map_dtl.put("assign_qty", assign_qty + ""); if (unassign_qty == 0) { map_dtl.put("bill_status", "40"); } else { @@ -1756,59 +1907,62 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { } // 判断是否还有相同物料相同仓位的明细 - JSONObject jsonMap = new JSONObject(); - jsonMap.put("flag", "4"); - jsonMap.put("material_id", dtl.getString("material_id")); - jsonMap.put("iostorinv_id", iostorinv_id); - jsonMap.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")); + if (ObjectUtil.isNotEmpty(dtl.getString("pcsn"))) { + JSONObject jsonMap = new JSONObject(); + jsonMap.put("flag", "4"); + jsonMap.put("material_id", dtl.getString("material_id")); + jsonMap.put("iostorinv_id", iostorinv_id); + jsonMap.put("iostorinvdtl_id", whereJson.getString("iostorinvdtl_id")); - JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0); - for (int i = 0; i < dtlArr.size(); i++) { - JSONObject json = dtlArr.getJSONObject(i); + JSONArray dtlArr = WQL.getWO("ST_OUTIVT01").addParamMap(jsonMap).process().getResultJSONArray(0); + for (int i = 0; i < dtlArr.size(); i++) { + JSONObject json = dtlArr.getJSONObject(i); - JSONObject ivt = WQL.getWO("ST_OUTIVT01") - .addParam("flag", "1") - .addParam("material_id", json.getString("material_id")) - .addParam("pcsn", json.getString("pcsn")) - .process().uniqueResult(0); + JSONObject ivt = WQL.getWO("ST_OUTIVT01") + .addParam("flag", "1") + .addParam("material_id", json.getString("material_id")) + .addParam("pcsn", json.getString("pcsn")) + .process().uniqueResult(0); - //更新库存 - ivt.put("change_qty", ivt.getDoubleValue("canuse_qty")); - ivt.put("bill_type_scode", jo_mst.getString("bill_type")); - ivt.put("inv_id", json.getString("iostorinv_id")); - ivt.put("bill_code", jo_mst.getString("bill_code")); - ivt.put("bill_table", "ST_IVT_IOStorInv"); - storPublicService.IOStor(ivt, "11"); - //生成分配明细 - json.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); - json.put("sect_id", ivt.getString("sect_id")); - json.put("sect_code", ivt.getString("sect_code")); - json.put("sect_name", ivt.getString("sect_name")); - json.put("struct_id", ivt.getString("struct_id")); - json.put("struct_code", ivt.getString("struct_code")); - json.put("struct_name", ivt.getString("struct_name")); - json.put("pcsn", ivt.getString("pcsn")); - json.put("box_no", ivt.getString("storagevehicle_code")); - json.put("storagevehicle_id", ivt.getString("storagevehicle_id")); - json.put("storagevehicle_code", ivt.getString("storagevehicle_code")); - json.put("storagevehicle_type", ivt.getString("storagevehicle_type")); - json.put("is_issued", "0"); - json.put("plan_qty", ivt.getDoubleValue("change_qty")); - json.put("real_qty", ivt.getDoubleValue("change_qty")); - // 如果所属仓位是虚拟区 则将分配明细状态变为生成 - if (StrUtil.equals(ivt.getString("sect_code"), "XN01")) { - json.put("work_status", "01"); - } else { - json.put("work_status", "00"); + //更新库存 + ivt.put("change_qty", ivt.getDoubleValue("canuse_qty")); + ivt.put("bill_type_scode", jo_mst.getString("bill_type")); + ivt.put("inv_id", json.getString("iostorinv_id")); + ivt.put("bill_code", jo_mst.getString("bill_code")); + ivt.put("bill_table", "ST_IVT_IOStorInv"); + storPublicService.IOStor(ivt, "11"); + //生成分配明细 + json.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); + json.put("sect_id", ivt.getString("sect_id")); + json.put("sect_code", ivt.getString("sect_code")); + json.put("sect_name", ivt.getString("sect_name")); + json.put("struct_id", ivt.getString("struct_id")); + json.put("struct_code", ivt.getString("struct_code")); + json.put("struct_name", ivt.getString("struct_name")); + json.put("pcsn", ivt.getString("pcsn")); + json.put("box_no", ivt.getString("storagevehicle_code")); + json.put("storagevehicle_id", ivt.getString("storagevehicle_id")); + json.put("storagevehicle_code", ivt.getString("storagevehicle_code")); + json.put("storagevehicle_type", ivt.getString("storagevehicle_type")); + json.put("is_issued", "0"); + json.put("plan_qty", ivt.getDoubleValue("change_qty")); + json.put("real_qty", ivt.getDoubleValue("change_qty")); + // 如果所属仓位是虚拟区 则将分配明细状态变为生成 + JSONObject jsonSect = wo_sect.query("sect_id = '" + ivt.getString("sect_id") + "'").uniqueResult(0); + if (StrUtil.equals(jsonSect.getString("sect_type_attr"), "09")) { + json.put("work_status", "01"); + } else { + json.put("work_status", "00"); + } + wo_dis.insert(json); + + // 更新明细 + HashMap map_dtl = new HashMap(); + map_dtl.put("unassign_qty", "0"); + map_dtl.put("assign_qty", ivt.getString("change_qty")); + map_dtl.put("bill_status", "40"); + wo_dtl.update(map_dtl, "iostorinvdtl_id='" + json.getString("iostorinvdtl_id") + "'"); } - wo_dis.insert(json); - - // 更新明细 - HashMap map_dtl = new HashMap(); - map_dtl.put("unassign_qty", "0"); - map_dtl.put("assign_qty", ivt.getString("change_qty")); - map_dtl.put("bill_status", "40"); - wo_dtl.update(map_dtl, "iostorinvdtl_id='" + json.getString("iostorinvdtl_id") + "'"); } //更新主表状态 diff --git a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql index 821e65fd5..3d79d237a 100644 --- a/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql +++ b/lms/nladmin-system/src/main/java/org/nl/wms/st/outbill/wql/QST_IVT_CHECKOUTBILL.wql @@ -219,6 +219,9 @@ OPTION 输入.stor_id <> "" struct.stor_id = 输入.stor_id ENDOPTION + OPTION 输入.box_no <> "" + sub.package_box_sn = 输入.box_no + ENDOPTION order by ivt.canuse_qty,ivt.pcsn desc ) t1 UNION @@ -269,6 +272,9 @@ OPTION 输入.stor_id <> "" struct.stor_id = 输入.stor_id ENDOPTION + OPTION 输入.box_no <> "" + sub.package_box_sn = 输入.box_no + ENDOPTION order by ivt2.canuse_qty,ivt2.pcsn desc ) t2 ENDSELECT diff --git a/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue b/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue index f8558542e..7b0768cf0 100644 --- a/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue +++ b/lms/nladmin-ui/src/views/wms/basedata/st/ivt/index.vue @@ -96,21 +96,21 @@ - - - - + + + + + + - - - - - + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/change/AddDialog.vue b/lms/nladmin-ui/src/views/wms/st/inStor/change/AddDialog.vue index 060f8aa39..de4fb0fbd 100644 --- a/lms/nladmin-ui/src/views/wms/st/inStor/change/AddDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/inStor/change/AddDialog.vue @@ -131,17 +131,18 @@ - + - + - + @@ -150,6 +151,7 @@ @@ -161,6 +163,7 @@ active-value="1" inactive-value="0" active-color="#13ce66" + :disabled="crud.status.view > 0" inactive-color="#ff4949"> @@ -170,11 +173,12 @@ active-value="1" inactive-value="0" active-color="#13ce66" + :disabled="crud.status.view > 0" inactive-color="#ff4949"> - 一键填充 + 一键填充
变更明细 diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue index fbead8137..c5c57f77c 100644 --- a/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue +++ b/lms/nladmin-ui/src/views/wms/st/inStor/check/AddDtl.vue @@ -47,6 +47,7 @@ +
- - - - + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/AddDtl.vue index f1bd68e11..4d27080f7 100644 --- a/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/AddDtl.vue +++ b/lms/nladmin-ui/src/views/wms/st/inStor/moveStor/AddDtl.vue @@ -59,6 +59,7 @@ +
- - - - - - + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/AddDtl.vue b/lms/nladmin-ui/src/views/wms/st/outbill/AddDtl.vue index 5baaff16e..2aa1692db 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/AddDtl.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/AddDtl.vue @@ -53,13 +53,13 @@ :header-cell-style="{background:'#f5f7fa',color:'#606266'}" > - - - - - - - + + + + + + + diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue index 9c92aedf4..12fd1de34 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue +++ b/lms/nladmin-ui/src/views/wms/st/outbill/DivDialog.vue @@ -100,6 +100,7 @@ style="width: 100%;" max-height="300" border + :cell-style="cellStyle" :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}" @current-change="handleDtlCurrentChange" @@ -180,7 +181,7 @@ ref="table2" :data="tabledis" style="width: 100%;" - max-height="300" + max-height="400" border :highlight-current-row="true" :header-cell-style="{background:'#f5f7fa',color:'#606266'}" @@ -202,9 +203,10 @@ - - - + + + + @@ -396,7 +398,7 @@ export default { } }, deleteRow(row) { - checkoutbill.allCancel(row).then(res => { + checkoutbill.oneCancel(row).then(res => { this.queryTableDtl() }) }, @@ -504,6 +506,16 @@ export default { }).catch(() => { this.tabledis = [] }) + }, + cellStyle({ row, column, rowIndex, columnIndex }) { + const assign_qty = parseInt(row.assign_qty) + const plan_qty = parseInt(row.plan_qty) + + if (column.property === 'assign_qty') { + if (assign_qty > plan_qty) { + return 'background: yellow' + } + } } } } diff --git a/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js b/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js index bcaffd69e..d024711b5 100644 --- a/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js +++ b/lms/nladmin-ui/src/views/wms/st/outbill/checkoutbill.js @@ -86,6 +86,13 @@ export function allCancel(data) { data }) } +export function oneCancel(data) { + return request({ + url: '/api/checkoutbill/oneCancel', + method: 'post', + data + }) +} export function setPoint(data) { return request({ url: '/api/checkoutbill/setPoint', @@ -190,4 +197,4 @@ export function getOutBillTask2(data) { data }) } -export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, setPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit, getDisNum, queryBox, getOutBillTask2 } +export default { add, edit, del, allDiv, allCancel, getOutBillDtl, getOutBillDis, setPoint, getOutBillTask, getStructIvt, manualDiv, confirm, issueTask, finishTask, cancleTaskfinish, getInvTypes, paramByCodeType, schAreaType, backConfirm, getOutBillDisDtl, getType, allDivOne, moneySubmit, getDisNum, queryBox, getOutBillTask2, oneCancel }