| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | //检查库存是否有相同料箱,存在则抛出异常 |
| | | if(!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code",param.getBarcode())))){ |
| | | if (!Cools.isEmpty(agvLocDetlService.selectOne(new EntityWrapper<AgvLocDetl>().eq("supp_code", param.getBarcode())))) { |
| | | throw new CoolException(param.getBarcode() + "料箱码已存在AGV库存明细中"); |
| | | } |
| | | |
| | | //查看工作档是否有相同料箱,存在则抛出异常 |
| | | if(!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))){ |
| | | if (!Cools.isEmpty(agvWrkMastService.selectByContainerCode(param.getBarcode()))) { |
| | | throw new CoolException(param.getBarcode() + "料箱码已存在AGV工作档中"); |
| | | } |
| | | List<CombParam.CombMat> combMats = param.getCombMats(); |
| | | Map<String, String> map = new HashMap<>(); |
| | | for (CombParam.CombMat combMat : combMats) { |
| | | String batch = Cools.isEmpty(combMat.getBatch()) ? "" : combMat.getBatch(); |
| | | if (!Cools.isEmpty(map.get(combMat.getMatnr() + batch))) { |
| | | throw new CoolException(param.getBarcode() + "组托的物料明细重复,请检查是否重复扫码"); |
| | | } else { |
| | | map.put(combMat.getMatnr() + batch, combMat.getMatnr()); |
| | | } |
| | | } |
| | | |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | //无单组托 |
| | | NoOrderComb(param,userId); |
| | | }else { |
| | | NoOrderComb(param, userId); |
| | | } else { |
| | | //有单组托 |
| | | OrderComb(param,userId); |
| | | OrderComb(param, userId); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(param.getLocno())){ |
| | | if (StringUtils.isEmpty(param.getLocno())) { |
| | | return "组托成功"; |
| | | }else { |
| | | combBinding(param.getBarcode(),param.getLocno()); |
| | | } else { |
| | | combBinding(param.getBarcode(), param.getLocno()); |
| | | return "组托成功,绑定站点成功"; |
| | | } |
| | | |
| | |
| | | /* |
| | | AGV无单组托 |
| | | */ |
| | | private void NoOrderComb(CombParam param, Long userId){ |
| | | List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,null); |
| | | 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); |
| | | syncWaitPakin(detlDto, "", param.getBarcode(), userId, now); |
| | | }); |
| | | } |
| | | |
| | | /* |
| | | AGV有单组托 |
| | | */ |
| | | private void OrderComb(CombParam param, Long userId){ |
| | | private void OrderComb(CombParam param, Long userId) { |
| | | //关联组托 |
| | | Order order = orderService.selectByNo(param.getOrderNo()); |
| | | if(Cools.isEmpty(order)){ |
| | | if (Cools.isEmpty(order)) { |
| | | throw new CoolException("单据编号不存在"); |
| | | } |
| | | //订单状态2以上为完成或者取消的订单 |
| | |
| | | throw new CoolException("单据编号已过期"); |
| | | } |
| | | // 用于生成入库通知档所需参数 |
| | | List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param,order); |
| | | List<DetlDto> detlDtos = mappingDetlDtoByCombMat(param, order); |
| | | //用于统一一个托盘下的入库通知档的生成时间 |
| | | Date now = new Date(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | //同步生成入库通知档 |
| | | syncWaitPakin(detlDto,order.getOrderNo(),param.getBarcode(),userId,now); |
| | | 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){ |
| | | private List<DetlDto> mappingDetlDtoByCombMat(CombParam param, Order order) { |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getCombMats().forEach(combMat -> { |
| | | |
| | | if(!Cools.isEmpty(order)){ |
| | | if (!Cools.isEmpty(order)) { |
| | | //检查入库数量 |
| | | checkOrderQty(order,combMat); |
| | | checkOrderQty(order, combMat); |
| | | } |
| | | |
| | | DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(),combMat.getContainerCode()); |
| | | DetlDto detlDto = new DetlDto(combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq(), combMat.getContainerCode()); |
| | | //同一托盘下相同物料信息和批号转为一个入库通知档 |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(),null); |
| | | DetlDto one = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch(), detlDto.getCsocode(), detlDto.getIsoseq(), null); |
| | | assert one != null; |
| | | one.setAnfme(one.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | |
| | | /* |
| | | 检查入库数量是否小于等于单据数量,合理则修改OrderDetl作业数量信息,否则抛出异常 |
| | | */ |
| | | private void checkOrderQty(Order order, CombParam.CombMat combMat){ |
| | | private void checkOrderQty(Order order, CombParam.CombMat combMat) { |
| | | // 订单明细数量校验,如果作业数量大于单据数量则抛出异常 |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(),combMat.getIsoseq()); |
| | | if(Cools.isEmpty(orderDetl)){ |
| | | OrderDetl orderDetl = orderDetlService.selectItem(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getCsocode(), combMat.getIsoseq()); |
| | | 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(), combMat.getCsocode(),combMat.getIsoseq())) { |
| | | if (!orderDetlService.increase(order.getId(), combMat.getMatnr(), combMat.getBatch(), combMat.getAnfme(), combMat.getCsocode(), combMat.getIsoseq())) { |
| | | throw new CoolException("修改单据明细数量失败"); |
| | | } |
| | | } |
| | |
| | | /* |
| | | 同步生成AGV入库通知档数据 |
| | | */ |
| | | private void syncWaitPakin(DetlDto detlDto, String orderNo, String zpallet, Long userId, Date now ){ |
| | | 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() + "商品档案不存在"); |
| | |
| | | @Override |
| | | public void combBinding(String barcode, String stationCode) { |
| | | |
| | | if(Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))){ |
| | | if (Cools.isEmpty(agvWaitPakinService.selectByContainerCode(barcode))) { |
| | | throw new CoolException("该料箱未组托,无法绑定站点"); |
| | | } |
| | | |
| | | AgvBasDevp agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("barcode", barcode)); |
| | | |
| | | if(!Cools.isEmpty(agvBasDevp)){ |
| | | throw new CoolException(barcode + "已经绑定在"+ agvBasDevp.getDevNo() +"站点"); |
| | | if (!Cools.isEmpty(agvBasDevp)) { |
| | | throw new CoolException(barcode + "已经绑定在" + agvBasDevp.getDevNo() + "站点"); |
| | | } |
| | | |
| | | agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode)); |
| | | if(agvBasDevp == null){ |
| | | agvBasDevp = agvBasDevpService.selectOne(new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode)); |
| | | if (agvBasDevp == null) { |
| | | throw new CoolException(stationCode + "站点信息错误"); |
| | | } |
| | | if(!"O".equals(agvBasDevp.getLocSts())){ |
| | | if (!"O".equals(agvBasDevp.getLocSts())) { |
| | | throw new CoolException(stationCode + "该站点货位状态非空"); |
| | | } |
| | | AgvWrkMast agvWrkMast = agvWrkMastService.selectOne(new EntityWrapper<AgvWrkMast>().eq("loc_no", agvBasDevp.getDevNo())); |
| | | if(!Cools.isEmpty(agvWrkMast)){ |
| | | if (!Cools.isEmpty(agvWrkMast)) { |
| | | throw new CoolException(stationCode + "该站点已被工作号为" + agvWrkMast.getWrkNo() + "占用,无法绑定"); |
| | | } |
| | | |
| | | agvBasDevp.setBarcode(barcode); |
| | | agvBasDevp.setLocSts("F"); |
| | | agvBasDevpService.update(agvBasDevp,(new EntityWrapper<AgvBasDevp>().eq("dev_no",stationCode))); |
| | | agvBasDevpService.update(agvBasDevp, (new EntityWrapper<AgvBasDevp>().eq("dev_no", stationCode))); |
| | | } |
| | | |
| | | public List<AgvBasDevp> getAgvBasDevpByFloor(int floor) { |
| | | EntityWrapper<AgvBasDevp> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("floor",floor).eq("cache_shelves","Y").eq("loc_sts","F"); |
| | | wrapper.eq("floor", floor).eq("cache_shelves", "Y").eq("loc_sts", "F"); |
| | | List<AgvBasDevp> agvBasDevpList = agvBasDevpService.selectList(wrapper); |
| | | return agvBasDevpList.stream().filter(agvBasDevp -> { |
| | | return !Cools.isEmpty(agvWaitPakinService.selectByContainerCode(agvBasDevp.getBarcode())); |