| | |
| | | private AgvBasDevpService agvBasDevpService; |
| | | |
| | | |
| | | /* |
| | | 组托 + 绑定暂存位 |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public String comb(CombParam param, Long userId) { |
| | |
| | | throw new CoolException(BaseRes.PARAM); |
| | | } |
| | | |
| | | //检查是否已存在相同的托盘条码,存在则抛出异常 |
| | | if (agvWaitPakinService.selectCount(new EntityWrapper<AgvWaitPakin>(). |
| | | eq("zpallet", param.getBarcode()).eq("io_status", "N")) > 0) { |
| | | throw new CoolException(param.getBarcode() + "数据正在进行入库"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | //无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | //无单组托 |
| | | NoOrderComb(param,userId); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | |
| | | detlDtos.forEach(detlDto -> { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | AgvWaitPakin waitPakin = new AgvWaitPakin(); |
| | | waitPakin.setBatch(detlDto.getBatch());//批号 |
| | | |
| | | waitPakin.sync(mat); |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!agvWaitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | }); |
| | | }else { |
| | | //关联组托 |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 生成入库通知档 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(elem -> { |
| | | |
| | | // 订单明细数量校验 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), elem.getMatnr(), elem.getBatch()); |
| | | if (elem.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单明细数量 |
| | | if (!orderDetlService.increase(order.getId(), elem.getMatnr(), elem.getBatch(), elem.getAnfme())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | AgvWaitPakin waitPakin = new AgvWaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(order.getOrderNo()); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(param.getBarcode()); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!agvWaitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | //有单组托 |
| | | OrderComb(param,userId); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(param.getLocno())){ |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | /* |
| | | AGV无单组托 |
| | | */ |
| | | private void NoOrderComb(CombParam param, Long userId){ |
| | | List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,null); |
| | | |
| | | //用于统一一个托盘下的入库通知档的生成时间 |
| | | Date now = new Date(); |
| | | detlDtos.forEach(detlDto -> { |
| | | syncWaitPakin(detlDto,"",param.getBarcode(),userId,now); |
| | | }); |
| | | } |
| | | |
| | | /* |
| | | AGV有单组托 |
| | | */ |
| | | private void OrderComb(CombParam param, Long userId){ |
| | | //关联组托 |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if(Cools.isEmpty(order)){ |
| | | throw new CoolException("单据编号不存在"); |
| | | } |
| | | //订单状态2以上为完成或者取消的订单 |
| | | if (order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 用于生成入库通知档所需参数 |
| | | List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order); |
| | | //用于统一一个托盘下的入库通知档的生成时间 |
| | | Date now = new Date(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | //同步生成入库通知档 |
| | | syncWaitPakin(detlDto,order.getOrderNo(),param.getBarcode(),userId,now); |
| | | } |
| | | //修改单据状态为2.作业中 |
| | | orderService.updateSettle(order.getId(), 2L, userId); |
| | | } |
| | | |
| | | /* |
| | | 根据PDA扫码所传的物料信息参数映射为DetlDto |
| | | */ |
| | | private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order){ |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(combMat -> { |
| | | |
| | | if(!Cools.isEmpty(order)){ |
| | | //检查入库数量 |
| | | checkOrderQty(order,combMat); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme()); |
| | | //同一托盘下相同物料信息和批号转为一个入库通知档 |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | |
| | | return detlDtos; |
| | | } |
| | | |
| | | /* |
| | | 检查入库数量是否小于等于单据数量,合理则修改OrderDetl作业数量信息,否则抛出异常 |
| | | */ |
| | | private void checkOrderQty(Order order, CombParam.CombMat combMat){ |
| | | // 订单明细数量校验,如果作业数量大于单据数量则抛出异常 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch()); |
| | | if(Cools.isEmpty(orderDetl)){ |
| | | throw new CoolException("未匹配到该单据下的物料"); |
| | | } |
| | | if (combMat.getAnfme() > orderDetl.getEnableQty()) { |
| | | throw new CoolException(orderDetl.getMatnr() + "入库数量不合法"); |
| | | } |
| | | // 修改订单明细数量 |
| | | if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 同步生成AGV入库通知档数据 |
| | | */ |
| | | private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now ){ |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | AgvWaitPakin waitPakin = new AgvWaitPakin(); |
| | | waitPakin.sync(mat); |
| | | waitPakin.setOrderNo(orderNo); // 单据编号 |
| | | waitPakin.setBatch(detlDto.getBatch()); // 序列码 |
| | | waitPakin.setZpallet(zpallet); // 托盘码 |
| | | waitPakin.setIoStatus("N"); // 入出状态 |
| | | waitPakin.setAnfme(detlDto.getAnfme()); // 数量 |
| | | waitPakin.setStatus("Y"); // 状态 |
| | | waitPakin.setAppeUser(userId); |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | if (!agvWaitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | |
| | | @Override |
| | | public void combBinding(String barcode, String stationCode) { |
| | | EntityWrapper<AgvBasDevp> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("dev_no",stationCode); |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(wrapper); |
| | | |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", barcode)); |
| | | |
| | | if(!Cools.isEmpty(agvBasDevp)){ |
| | | throw new CoolException(barcode + "已经绑定在"+ agvBasDevp.getDevNo() +"站点"); |
| | | } |
| | | |
| | | agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode)); |
| | | if(agvBasDevp == null){ |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | |
| | | |
| | | agvBasDevp.setBarcode(barcode); |
| | | agvBasDevp.setLocSts("F"); |
| | | agvBasDevpService.update(agvBasDevp,wrapper); |
| | | agvBasDevpService.update(agvBasDevp,(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode))); |
| | | } |
| | | |
| | | public List<AgvBasDevp> getAgvBasDevpByFloor(int floor) { |