From 06214fa21c0c7dc7f40d75e9f1b85a1fdd8ba169 Mon Sep 17 00:00:00 2001 From: lishuai <1793460677@qq.com> Date: Tue, 4 Jun 2024 16:49:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BC=82=E6=AD=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E3=80=81=E5=85=A5=E5=BA=93=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BeltConveyorDeviceDriver.java | 11 +- ...ConveyorWithScannerWeightDeviceDriver.java | 3 - .../UnBoxLableConveyorDeviceDriver.java | 107 +++++++----------- .../service/InstructionService.java | 1 + .../service/impl/InstructionServiceImpl.java | 8 ++ .../service/quartz/task/CreateDDJInst.java | 2 + 6 files changed, 64 insertions(+), 68 deletions(-) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java index 0486d85b7..2d1ec0387 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/BeltConveyorDeviceDriver.java @@ -54,6 +54,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.CompletableFuture; import static redis.clients.jedis.HostAndPort.localhost; @@ -255,7 +256,15 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements } if (move != 0 && task > 0) { - update_instruction_status(); + CompletableFuture future = CompletableFuture.runAsync(() -> { + // 异步更新指令状态 + try { + update_instruction_status(); + } catch (Exception e) { + e.printStackTrace(); + } + }); + future.thenRun(() -> System.out.println("异步更新任务已完成")); } } catch (Exception var17) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index 07e371711..91b8b3fda 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -211,7 +211,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv @Override public void execute() { - System.out.println("in 开始时间"+ LocalDateTime.now() +this.getDeviceCode()); try { device_code = this.getDeviceCode(); @@ -392,7 +391,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv last_height = height; last_weight = weight; last_barcode = barcode; - System.out.println("out 开始时间"+ LocalDateTime.now() +this.getDeviceCode()); } private void applyErrorHeight() { @@ -638,7 +636,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv map.put("value", mode); list1.add(map); this.writing(list1); - this.requireSucess = true; }else { LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java index 33928539e..abc1f2cdc 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java @@ -4,13 +4,13 @@ import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.nl.acs.agv.server.NDCAgvService; -import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.device.domain.Device; import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; @@ -18,8 +18,6 @@ import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingRequest; -import org.nl.acs.ext.wms.data.one.ApplyLabelingAndBindingResponse; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.history.ErrorUtil; import org.nl.acs.history.service.DeviceErrorLogService; @@ -205,26 +203,15 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl message = "universal_message3"; } - List toInstructions; Instruction instruction = instructionService.findByCode(String.valueOf(task)); //空箱出库开盖位,申请开盖 - if (mode == 7 && move == 1 && task > 0) { + if (mode == 7 && move == 1 && task > 0 ) { //不允许开盖,完成出库任务,自动去扫码位 - if (!applyUnbox(instruction)){ - if (ObjectUtil.isNotEmpty(instruction)) { - try { -// instructionService.finish(instruction); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + if (StrUtil.isEmpty(instruction.getVehicle_code())){ + message = "universal_notCreateInstMessage8"; } - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 7); - list1.add(map); - this.writing(list1); + applyUnbox(instruction.getVehicle_code()); + } } @@ -245,7 +232,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl last_to_height =to_height; } - private Boolean applyUnbox(Instruction instruction) { + private Boolean applyUnbox(String vehicleCode) { Date date = new Date(); if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) { @@ -253,28 +240,45 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl return false; } else { try { - ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = new ApplyLabelingAndBindingRequest(); JSONObject param = new JSONObject(); param.put("device_code", device_code); + param.put("material_barcode", vehicleCode); param.put("task", task); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数:" + param) + .content("木箱开盖,参数:" + param) .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); - ApplyLabelingAndBindingResponse response = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest); - if (response == null || response.getstatus() == 200) { + String response = acsToWmsService.getBoxInfo(param); + JSONObject jo = JSON.parseObject(response); + if (jo.getInteger("status") == 200) { LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) - .content("木箱、子卷入库申请入库任务,参数,接口返回:" + response) + .content("木箱开盖,接口返回:" + response) .build(); logDto2.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto2); - Map datas = response.getData(); - packagePLCData(datas,instruction); - this.setRequireSucess(true); - return true; + String data = jo.getString("data"); + JSONObject datas = JSON.parseObject(data); + packagePLCData(datas); + String isUncap = datas.get("isUncap").toString(); + if ("1".equals(isUncap)){ + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 7); + list1.add(map); + this.writing(list1); + }else { + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 99); + list1.add(map); + this.writing(list1); + } + } @@ -285,36 +289,18 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl return false; } - private void packagePLCData(Map datas, Instruction instruction) { - String length = datas.get("length").toString(); - String weight = datas.get("weight").toString(); - String height = datas.get("height").toString(); - String printQty = datas.get("printQty").toString(); - String printDevice = datas.get("printDevice").toString(); - String bundleTimes = datas.get("bundleTimes").toString(); - String next_device_code = instruction.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - String next_addr = nextDevice.getExtraValue().get("address").toString(); - + private void packagePLCData(JSONObject datas) { + String length = datas.get("boxLength").toString(); + String weight = datas.get("boxWidth").toString(); + String height = datas.get("boxHigh").toString(); + String desiccant = datas.get("desiccantTemplat").toString(); List list = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_task"); - map.put("value", task); - list.add(map); - Map map2 = new HashMap(); - map2.put("code", "to_container_type"); - map2.put("value", instruction.getVehicle_code()); - list.add(map2); - Map map3 = new HashMap(); - map3.put("code", "to_target"); - map3.put("value", next_addr); - list.add(map3); Map map4 = new HashMap(); - map4.put("code", "to_leight"); + map4.put("code", "to_length"); map4.put("value", length); list.add(map4); Map map5 = new HashMap(); - map5.put("code", "to_wedth"); + map5.put("code", "to_width"); map5.put("value", weight); list.add(map5); Map map6 = new HashMap(); @@ -322,17 +308,10 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl map6.put("value", height); list.add(map6); Map map7 = new HashMap(); - map7.put("code", "to_print_qty"); - map7.put("value", printQty); + map7.put("code", "to_desiccant"); + map7.put("value", desiccant); list.add(map7); - Map map9 = new HashMap(); - map9.put("code", "to_print_device"); - map9.put("value", printDevice); - list.add(map9); - Map map11 = new HashMap(); - map11.put("code", "to_binding_times"); - map11.put("value", bundleTimes); - list.add(map11); + try { this.writing(list); } catch (Exception e) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 7e0f8d102..bf534eaa1 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -464,4 +464,5 @@ public interface InstructionService extends CommonService { */ Boolean querySameNextDeviceCodeInstByOut(String nextDeviceCode); + List findByCodeAndExcute(String nextDeviceCode); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 808732513..0e2fab15f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -1858,6 +1858,14 @@ public class InstructionServiceImpl extends CommonServiceImpl findByCodeAndExcute(String next_code) { + List instructionList = instructions.stream().filter(item -> item.getNext_device_code().equals(next_code)).collect(Collectors.toList()); + + return instructionList; + } + + private boolean regional(String start_device_code, String next_device_code) { Device startdevice = deviceAppService.findDeviceByCode(start_device_code); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java index 0c4a58042..267168b0c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/CreateDDJInst.java @@ -215,6 +215,8 @@ public class CreateDDJInst { List byDeviceCodes = instructionService.findByDeviceCodes(instruction, true); Instruction instdto = new Instruction(); if (CollUtil.isEmpty(byDeviceCodes)) { + //判断有没有DDJ对接位出入库的指令 + instructionService.findByCodeAndExcute(next_device_code); instdto.setInstruction_type(task_type); instdto.setInstruction_id(IdUtil.simpleUUID()); instdto.setRoute_plan_code(route_plan_code);