| | |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.transaction.interceptor.TransactionAspectSupport; |
| | | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 立体仓库WCS系统主流程业务 |
| | |
| | | continue; |
| | | } |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | if (Cools.isEmpty(barcode)){ |
| | | continue; |
| | | } |
| | | |
| | | if (staProtocol.isAutoing() |
| | | && staProtocol.isInEnable() |
| | | && !staProtocol.isEmptyMk() |
| | |
| | | && staProtocol.isPakMk()) { |
| | | News.warnNoLog("" + mark + " - 0" + " - 开始执行"); |
| | | |
| | | String barcode = barcodeThread.getBarcode(); |
| | | |
| | | if (!Cools.isEmpty(barcode)) { |
| | | News.info("" + mark + " - 1" + " - {}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode); |
| | | if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) { |
| | | if ("NG".endsWith(barcode) || "No Read".equals(barcode) || "empty".equals(barcode)) { |
| | | News.info("" + mark + " - 2" + " - 扫码失败1 ===>> {}号条码扫描器检测条码信息:{},站点:{}", inSta.getBarcode(), barcode, inSta.getStaNo()); |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | |
| | | //过滤判断,防止拣料再入库货物,经过入库站再入库时,被退回到退库站 |
| | | WrkMast wrkMast1 = wrkMastMapper.selectPakInStepBarcode(barcode); |
| | | if (wrkMast1 != null) { |
| | | if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104) { |
| | | if (wrkMast1.getIoType() == 103 || wrkMast1.getIoType() == 107 || wrkMast1.getIoType() == 104|| wrkMast1.getIoType() == 53 || wrkMast1.getIoType() == 57 || wrkMast1.getIoType() == 54) { |
| | | continue; |
| | | } |
| | | } |
| | | if (wrkMast != null) { |
| | | News.error("" + mark + " - 4" + " - 工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | News.error("" + mark + " - 4" + " - 工作档中已存在该站状态为( 3.开始执行入库任务 )的数据,工作号={}", wrkMast.getWrkNo()); |
| | | |
| | | // led 异常显示 |
| | | if (ledThread != null) { |
| | |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, command)); |
| | | if (result) { |
| | | News.info("WCS--->PLC下发任务成功:{}",command.toString()); |
| | | } |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | currentWrkMast.setWrkSts(3L);// 3.设备执行中 |
| | | currentWrkMast.setCrnStrTime(new Date()); |
| | | wrkMastService.updateById(currentWrkMast); |
| | | Thread.sleep(3000); // 延时3S |
| | | } else { |
| | | News.error("" + mark + " - 5" + " - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | |
| | |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | | MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg)); |
| | | } |
| | | |
| | | //托盘退回 |
| | | // LiftCommand command = new LiftCommand(); |
| | | // command.setWorkNo(9998); |
| | | // command.setSourceStaNo(inSta.getStaNo()); |
| | | // command.setTargetStaNo(inSta.getBackSta()); |
| | | Integer back = 999; |
| | | |
| | | barcodeThread.setBarcode(""); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(4, back)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | | } |
| | | |
| | |
| | | continue; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode); |
| | | // WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue()); |
| | | // if (wrkMast == null) { |
| | | // // 无拣料数据 |
| | | // continue; |
| | | // } |
| | | if (wrkMast == null) { |
| | | // 无拣料数据 |
| | | continue; |
| | | } |
| | | |
| | | if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) |
| | | || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | // 获取目标站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | |
| | | param.setLocType1(locTypeDto.getLocType1()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/pakin/pick/loc/v1") |
| | | .setPath("/rpc/pakin/loc/returnWarehouse") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | |
| | | continue; |
| | | } |
| | | |
| | | if(newWrkMast.getWrkSts() != 53 && newWrkMast.getWrkSts() != 57) { |
| | | if(newWrkMast.getIoType() != 53 && newWrkMast.getIoType() != 57) { |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库工作档类型异常!!! [plc编号:{}]", devp.getId()); |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() != 2) { |
| | | if (newWrkMast.getWrkSts() != 2) { |
| | | News.error("" + mark + " - 3" + " - 拣选盘点回库工作档状态异常!!! [plc编号:{}]", devp.getId()); |
| | | continue; |
| | | } |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!staProtocol.isOutEnable()) { |
| | | return; |
| | | } |
| | | // if (!staProtocol.isOutEnable()) { |
| | | // return; |
| | | // } |
| | | |
| | | //检查是否有正在执行的任务 |
| | | List<WrkMast> workingWrkMast = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", 3, 12)); |
| | |
| | | return; |
| | | } |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 11)); |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 11).orderBy("create_time")); |
| | | if (wrkMasts.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (liftProtocol.getWorkNo() <= 0) { |
| | | continue; |
| | | } |
| | | // if (liftProtocol.getWorkNo() <= 0) { |
| | | // continue; |
| | | // } |
| | | |
| | | if (liftProtocol.getMode() != 1) { |
| | | continue; |
| | |
| | | continue; |
| | | } |
| | | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", liftProtocol.getWorkNo())); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | // WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", liftProtocol.getWorkNo())); |
| | | // if (wrkMast == null) { |
| | | // continue; |
| | | // } |
| | | |
| | | if (wrkMast.getWrkSts() == 3) { |
| | | wrkMast.setWrkSts(4L); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | }else if (wrkMast.getWrkSts() == 12) { |
| | | wrkMast.setWrkSts(14L); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | }else { |
| | | News.error("未知的工作状态"); |
| | | List<WrkMast> wrkMastList = wrkMastService.selectList(new EntityWrapper<WrkMast>().in("wrk_sts", 3,12)); |
| | | for (WrkMast wrkMast : wrkMastList) { |
| | | if (wrkMast.getWrkSts() == 3) { |
| | | String locNo = wrkMast.getLocNo(); |
| | | Integer staNo = Utils.getStaNoByLocNo(locNo); |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | if (staProtocol.getWorkNo() <= 0 || !staProtocol.isLoading() || !staProtocol.isAutoing() || !Integer.valueOf(staProtocol.getWorkNo()).equals(wrkMast.getWrkNo())){ |
| | | continue; |
| | | } |
| | | wrkMast.setWrkSts(4L); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | //wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | }else if (wrkMast.getWrkSts() == 12) { |
| | | Integer targetStaNo = wrkMast.getStaNo(); |
| | | StaProtocol staProtocol = devpThread.getStation().get(targetStaNo); |
| | | if (staProtocol.getWorkNo() <= 0 || !staProtocol.isLoading() || !staProtocol.isAutoing() || !Integer.valueOf(staProtocol.getWorkNo()).equals(wrkMast.getWrkNo())){ |
| | | continue; |
| | | } |
| | | wrkMast.setWrkSts(14L); |
| | | wrkMast.setCrnEndTime(new Date()); |
| | | //wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | }else { |
| | | News.error("未知的工作状态"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId()); |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // // 工作档集合 |
| | | // List<WrkMast> wrkMasts = new ArrayList<>(); |
| | | List<Integer> workNoList = new ArrayList<>(); |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | |
| | | String barcode = null; |
| | | |
| | | // 获取工作档数据 |
| | | WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo()); |
| | | // if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no",staProtocol.getWorkNo()).in("io_type",101,103,104,107)); |
| | | if (null == wrkMast) { |
| | | List<WrkMastLog> wrkMastLogs = wrkMastLogService.selectList(new EntityWrapper<WrkMastLog>() |
| | | .eq("wrk_no", staProtocol.getWorkNo()) |
| | |
| | | ledCommand.setLocNo(locNo); |
| | | ledCommand.setStaNo(targetStaNo); |
| | | ledCommand.setBarcode(barcode); |
| | | // ledCommand.setSourceStaNo(wrkMast.getSourceStaNo()); |
| | | |
| | | // 修改开始:处理多个wrkDetl,不合并 |
| | | if (ioType != 110 && ioType != 10) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkNo); |
| | | |
| | | if (!wrkDetls.isEmpty()) { |
| | | WrkDetl wrkDetl = wrkDetls.get(0); |
| | | double anfme = 0D; |
| | | double weight = 0D; |
| | | for (WrkDetl detl : wrkDetls) { |
| | | anfme += detl.getAnfme(); |
| | | weight += detl.getWeight(); |
| | | wrkDetl.setAnfme(anfme); |
| | | wrkDetl.setWeight(weight); |
| | | } |
| | | |
| | | // 获取库存信息 |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", wrkMast.getSourceLocNo())); |
| | | double totalAnfme = 0D; |
| | | double totalWeight = 0D; |
| | | for (LocDetl locDetl : locDetls) { |
| | | totalAnfme += locDetl.getAnfme(); |
| | | totalWeight += locDetl.getWeight(); |
| | | // totalWeight += locDetl.getWeight(); |
| | | } |
| | | wrkDetl.setStockNum(totalAnfme); |
| | | wrkDetl.setStockNum2(totalWeight); |
| | | |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetl.getMatnr() |
| | | , wrkDetl.getMaktx() |
| | | , wrkDetl.getAnfme() |
| | | , wrkDetl.getWeight() |
| | | , wrkDetl.getStockNum() |
| | | , wrkDetl.getStockNum2() |
| | | , wrkDetl.getSpecs() |
| | | , wrkDetl.getSku() |
| | | , wrkDetl.getZpallet() |
| | | , wrkDetl.getModel() |
| | | , wrkDetl.getSupp() |
| | | , wrkDetl.getKpCstmrName() |
| | | , wrkDetl.getOrderNo() |
| | | , wrkDetl.getCstateid$() |
| | | )); |
| | | |
| | | }else { |
| | | // 为每个WrkDetl创建独立的MatDto |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | // 注意:这里使用每个wrkDetl的原始数据,不合并 |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetl.getMatnr() |
| | | , wrkDetl.getMaktx() |
| | | , wrkDetl.getAnfme() // 使用单个物料的数量,不累加 |
| | | , wrkDetl.getWeight() // 使用单个物料的重量,不累加 |
| | | , totalAnfme // 库存总数(这个是正常的) |
| | | , totalWeight // 库存总重量(这个是正常的) |
| | | , wrkDetl.getSpecs() |
| | | , wrkDetl.getSku() |
| | | , wrkDetl.getZpallet() |
| | | , wrkDetl.getModel() |
| | | , wrkDetl.getSupp() |
| | | , wrkDetl.getKpCstmrName() |
| | | , wrkDetl.getOrderNo() |
| | | , wrkDetl.getBatch() |
| | | // , wrkDetl.getCstateid$() |
| | | )); |
| | | } |
| | | } else { |
| | | List<WrkDetlLog> wrkDetlLogs = wrkDetlLogService.selectTodayByWrkNo(wrkNo); |
| | | if(!wrkDetlLogs.isEmpty()) { |
| | | WrkDetlLog wrkDetlLog = wrkDetlLogs.get(0); |
| | | |
| | | double anfme = 0D; |
| | | double weight = 0D; |
| | | for (WrkDetlLog detl : wrkDetlLogs) { |
| | | anfme += detl.getAnfme(); |
| | | weight += detl.getWeight(); |
| | | wrkDetlLog.setAnfme(anfme); |
| | | wrkDetlLog.setWeight(weight); |
| | | } |
| | | |
| | | if (!wrkDetlLogs.isEmpty()) { |
| | | // 获取库存信息 |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", sourceLocNo)); |
| | | double totalAnfme = 0D; |
| | |
| | | totalAnfme += locDetl.getAnfme(); |
| | | totalWeight += locDetl.getWeight(); |
| | | } |
| | | wrkDetlLog.setStockNum(totalAnfme); |
| | | wrkDetlLog.setStockNum2(totalWeight); |
| | | |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetlLog.getMatnr() |
| | | , wrkDetlLog.getMaktx() |
| | | , wrkDetlLog.getAnfme() |
| | | , wrkDetlLog.getWeight() |
| | | , wrkDetlLog.getStockNum() |
| | | , wrkDetlLog.getStockNum2() |
| | | , wrkDetlLog.getSpecs() |
| | | , wrkDetlLog.getSku() |
| | | , wrkDetlLog.getZpallet() |
| | | , wrkDetlLog.getModel() |
| | | , wrkDetlLog.getSupp() |
| | | , wrkDetlLog.getKpCstmrName() |
| | | , wrkDetlLog.getOrderNo() |
| | | , wrkDetlLog.getCstateid$() |
| | | )); |
| | | // 为每个WrkDetlLog创建独立的MatDto |
| | | for (WrkDetlLog wrkDetlLog : wrkDetlLogs) { |
| | | // 注意:这里使用每个wrkDetlLog的原始数据,不合并 |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetlLog.getMatnr() |
| | | , wrkDetlLog.getMaktx() |
| | | , wrkDetlLog.getAnfme() // 使用单个物料的数量,不累加 |
| | | , wrkDetlLog.getWeight() // 使用单个物料的重量,不累加 |
| | | , totalAnfme // 库存总数 |
| | | , totalWeight // 库存总重量 |
| | | , wrkDetlLog.getSpecs() |
| | | , wrkDetlLog.getSku() |
| | | , wrkDetlLog.getZpallet() |
| | | , wrkDetlLog.getModel() |
| | | , wrkDetlLog.getSupp() |
| | | , wrkDetlLog.getKpCstmrName() |
| | | , wrkDetlLog.getOrderNo() |
| | | , wrkDetlLog.getBatch() |
| | | // , wrkDetlLog.getCstateid$() |
| | | )); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | // 修改结束 |
| | | |
| | | commands.add(ledCommand); |
| | | } |
| | | Set<Integer> workNos = new HashSet<>(workNoList); |
| | |
| | | if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | continue; |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | // if (!commands.isEmpty()) { |
| | | // if (led.getId() < 7) { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | // News.error(""+mark+" - 2"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // } else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } else { |
| | | // if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | // News.error(""+mark+" - 3"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | // continue; |
| | | // } else { |
| | | // ledThread.setLedMk(false); |
| | | // } |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | News.error("{}号LED命令下发失败--->出库!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | |
| | | for (Integer staNo : led.getStaArr()) { |
| | | // 获取叉车站点 |
| | | StaProtocol staProtocol = devpThread.getStation().get(staNo); |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(122); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } |
| | | if (staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) { |
| | | if (staProtocol1 == null) { |
| | | continue; |
| | | } |
| | | if ((staProtocol.getWorkNo() != 0 && staProtocol.isLoading()) || (staProtocol1.getWorkNo() != 0 || staProtocol1.isLoading())) { |
| | | reset = false; |
| | | break; |
| | | } |
| | |
| | | if (reset && !ledThread.isLedMk()) { |
| | | ledThread.setLedMk(true); |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) { |
| | | News.error("" + mark + " - 1" + " - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | News.error("" + mark + " - 1" + " - {}号LED命令下发失败--->复位!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | } else { |
| | | |
| | | } |
| | |
| | | } |
| | | News.infoNoLog("" + mark + " - 0" + " - 执行完成:其他 ===>> LED显示器复位,显示默认信息"); |
| | | } |
| | | } |
| | | |
| | | public void ledExecuteIn(Integer mark) { |
| | | for (LedSlave led : slaveProperties.getLed()) { |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | List<Integer> workNoList = new ArrayList<>(); |
| | | |
| | | // 入库工作档 - 这里可能需要添加更多查询条件,确保只获取该LED对应的工作档 |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("wrk_sts", 3) |
| | | .in("io_type", 1, 53, 54, 57) |
| | | // 可能需要添加LED关联条件,例如站点编号等 |
| | | ); |
| | | |
| | | if (wrkMast == null) { |
| | | continue; // 没有工作档,继续处理下一个LED |
| | | } |
| | | |
| | | Integer wrkNo = wrkMast.getWrkNo(); |
| | | Integer ioType = wrkMast.getIoType(); |
| | | String sourceLocNo = wrkMast.getSourceLocNo(); |
| | | String locNo = wrkMast.getLocNo(); |
| | | Integer targetStaNo = wrkMast.getStaNo(); |
| | | String barcode = wrkMast.getBarcode(); |
| | | |
| | | workNoList.add(wrkNo); |
| | | |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(wrkNo); |
| | | ledCommand.setIoType(ioType); |
| | | |
| | | // 入库模式 - 修复了case 54和57的描述 |
| | | switch (ioType) { |
| | | case 1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | | case 53: |
| | | ledCommand.setTitle("拣料入库"); |
| | | break; |
| | | case 54: |
| | | ledCommand.setTitle("并板入库"); // 修正:应该是并板入库,不是盘点入库 |
| | | break; |
| | | case 57: |
| | | ledCommand.setTitle("盘点入库"); // 修正:应该是盘点入库,不是并板入库 |
| | | break; |
| | | default: |
| | | // 可选的错误处理 |
| | | continue; // 跳过不支持的ioType |
| | | } |
| | | |
| | | ledCommand.setSourceLocNo(sourceLocNo); |
| | | ledCommand.setLocNo(locNo); |
| | | ledCommand.setStaNo(targetStaNo); |
| | | ledCommand.setBarcode(barcode); |
| | | |
| | | List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkNo); |
| | | |
| | | // 即使wrkDetls为空,也应该处理LED命令(可能某些入库类型不需要物料明细) |
| | | if (!wrkDetls.isEmpty()) { |
| | | // 获取库存信息 |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>() |
| | | .eq("loc_no", sourceLocNo)); // 使用sourceLocNo而不是wrkMast.getSourceLocNo() |
| | | double totalAnfme = 0D; |
| | | double totalWeight = 0D; |
| | | for (LocDetl locDetl : locDetls) { |
| | | totalAnfme += locDetl.getAnfme(); |
| | | totalWeight += locDetl.getWeight(); // 如果数据库有weight字段,应该加上 |
| | | } |
| | | |
| | | // 为每个WrkDetl创建独立的MatDto |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | ledCommand.getMatDtos().add(new MatDto( |
| | | wrkDetl.getMatnr(), |
| | | wrkDetl.getMaktx(), |
| | | wrkDetl.getAnfme(), // 使用单个物料的数量 |
| | | wrkDetl.getWeight(), // 使用单个物料的重量 |
| | | totalAnfme, // 库存总数 |
| | | totalWeight, // 库存总重量 |
| | | wrkDetl.getSpecs(), |
| | | wrkDetl.getSku(), |
| | | wrkDetl.getZpallet(), |
| | | wrkDetl.getModel(), |
| | | wrkDetl.getSupp(), |
| | | wrkDetl.getKpCstmrName(), |
| | | wrkDetl.getOrderNo(), |
| | | wrkDetl.getBatch() |
| | | )); |
| | | } |
| | | } |
| | | |
| | | // 即使没有物料明细,也应该添加LED命令(某些入库类型可能不需要显示物料) |
| | | commands.add(ledCommand); |
| | | |
| | | Set<Integer> workNos = new HashSet<>(workNoList); |
| | | // 获取LED线程 |
| | | LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId()); |
| | | |
| | | if (ledThread == null) { |
| | | News.error("未找到LED线程:[id:{}]", led.getId()); |
| | | continue; |
| | | } |
| | | |
| | | // 相同工作号集合则过滤 |
| | | if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) { |
| | | continue; |
| | | } |
| | | |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) { |
| | | News.error("{}号LED命令下发失败--->入库!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | | ledThread.setLedMk(false); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | // 修改主档led标记 |
| | | // 注意:这里只需要更新当前工作档,不需要循环 |
| | | WrkMast wrkMastToUpdate = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkNo)); |
| | | if (wrkMastToUpdate != null) { |
| | | wrkMastToUpdate.setOveMk("Y"); |
| | | wrkMastToUpdate.setModiTime(new Date()); |
| | | if (wrkMastMapper.updateById(wrkMastToUpdate) == 0) { |
| | | News.errorNoLog("" + mark + " - 4" + " - 更新工作档失败"); |
| | | throw new CoolException("更新工作档失败"); |
| | | } |
| | | } |
| | | |
| | | // 更新线程当前工作号集合 |
| | | ledThread.setWorkNos(workNos); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | } |
| | | } |
| | | } |
| | | } |