| | |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.impl.ConfigServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private BasContainerService basContainerService; |
| | | @Autowired |
| | | private ConfigServiceImpl configService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + "单次最大组托上限为:" + mat.getUpQty()); |
| | | } |
| | | // if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) { |
| | | // throw new CoolException("物料:" + detlDto.getMatnr() + "单次最大组托上限为:" + mat.getUpQty()); |
| | | // } |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | BeanUtils.copyProperties(mat, waitPakin); |
| | | waitPakin.setBatch(detlDto.getBatch()); |
| | |
| | | waitPakin.setModiTime(now); |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | }else { |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>() |
| | | .eq("barcode", param.getBarcode()) |
| | | .eq("io_type",110)); |
| | | if (wrkMast != null) { |
| | | wrkMast.setWrkSts(15L);//空板出库任务转历史档 |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | } |
| | | } |
| | | // 关联组托 |
| | |
| | | param.getCombMats().forEach(elem -> { |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, elem.getOrderNo()); |
| | | if (Cools.isEmpty(order) || order.getSettle() > 2) { |
| | | throw new CoolException("单据编号已过期"); |
| | | throw new CoolException("订单号不存在或者已执行完成"); |
| | | } |
| | | // 订单明细数量校验 |
| | | // OrderDetl orderDetl = OrderInAndOutUtil.selectItem(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(), |
| | |
| | | } |
| | | }); |
| | | |
| | | BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | if (Objects.isNull(container)) { |
| | | throw new CoolException("数据错误:容器码不存在!!"); |
| | | } |
| | | if (container.getMixMax() < detlDtos.size()) { |
| | | throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | } |
| | | Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet()); |
| | | List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs)); |
| | | Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | if (tagIds.size() > 1) { |
| | | throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | } |
| | | // BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode())); |
| | | // if (Objects.isNull(container)) { |
| | | // throw new CoolException("数据错误:容器码不存在!!"); |
| | | // } |
| | | // if (container.getMixMax() < detlDtos.size()) { |
| | | // throw new CoolException("超出容器最大混装数量,当前容器最大数量为:" + container.getMixMax() + "!!"); |
| | | // } |
| | | // Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet()); |
| | | // List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs)); |
| | | // Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet()); |
| | | // if (tagIds.size() > 1) { |
| | | // throw new CoolException("组托物料类型不一致,只有相同的物料分类才可以组托!!"); |
| | | // } |
| | | //还可以放入多少种物料 |
| | | Integer suplus = container.getMixMax(); |
| | | // Integer suplus = container.getMixMax(); |
| | | for (DetlDto detlDto : detlDtos) { |
| | | Mat mat = matService.selectByMatnr(detlDto.getMatnr()); |
| | | if (Cools.isEmpty(mat)) { |
| | | throw new CoolException(detlDto.getMatnr() + "商品档案不存在"); |
| | | } |
| | | //最多可放数量 |
| | | Double singleMax = mat.getUpQty() * suplus; |
| | | if (singleMax.compareTo(detlDto.getAnfme()) < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + "单次组托上限为:" + mat.getUpQty() + ",当前总量超出托盘装载上限!!"); |
| | | } |
| | | BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty()); |
| | | //当前物料需要占用料箱格数 |
| | | Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue(); |
| | | suplus = suplus - curr; |
| | | if (suplus < 0) { |
| | | throw new CoolException("物料:" + detlDto.getMatnr() + ", 超出当前托盘装载上限!!"); |
| | | } |
| | | // Double singleMax = mat.getUpQty() * suplus; |
| | | // if (singleMax.compareTo(detlDto.getAnfme()) < 0) { |
| | | // throw new CoolException("物料:" + detlDto.getMatnr() + "单次组托上限为:" + mat.getUpQty() + ",当前总量超出托盘装载上限!!"); |
| | | // } |
| | | // BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty()); |
| | | // //当前物料需要占用料箱格数 |
| | | // Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue(); |
| | | // suplus = suplus - curr; |
| | | // if (suplus < 0) { |
| | | // throw new CoolException("物料:" + detlDto.getMatnr() + ", 超出当前托盘装载上限!!"); |
| | | // } |
| | | OrderDetlPakin detls = orderDetlPakinService.selectOne(new EntityWrapper<OrderDetlPakin>() |
| | | .eq("order_no", param.getOrderNo()) |
| | | .eq("matnr", detlDto.getMatnr())); |
| | | |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | BeanUtils.copyProperties(mat, waitPakin); |
| | |
| | | waitPakin.setAppeTime(now); |
| | | waitPakin.setModiUser(userId); |
| | | waitPakin.setModiTime(now); |
| | | waitPakin.setStandby1(detls.getStandby1());//配盘号 |
| | | if (!waitPakinService.insert(waitPakin)) { |
| | | throw new CoolException("保存入库通知档失败"); |
| | | } |
| | |
| | | Order order = OrderInAndOutUtil.selectByNo(Boolean.TRUE, orderNo); |
| | | OrderInAndOutUtil.updateOrder(Boolean.TRUE, order.getId(), 2L, userId); |
| | | }); |
| | | } |
| | | if(!Cools.isEmpty(param.getRsta()) && param.getRsta().contains("-")){ |
| | | //生成AGV搬运任务 |
| | | //生成AGV搬运出库任务 |
| | | // 保存工作档 |
| | | Task task = new Task(); |
| | | Date date = new Date(); |
| | | String s = ""; |
| | | if (param.getBarcode().charAt(0) == '3'){ |
| | | s = "307"; |
| | | }else if (param.getBarcode().charAt(0) == '4'){ |
| | | s = "402"; |
| | | }else if (param.getBarcode().charAt(0) == '5'){ |
| | | s = "401"; |
| | | } |
| | | String TaskNo = param.getBarcode()+"aa"+date.getTime(); |
| | | task.setWrkNo((int) date.getTime()) |
| | | .setTaskNo(TaskNo) |
| | | .setIoTime(date) |
| | | .setWrkSts(301L) // 工作状态:301.任务下发 |
| | | .setIoType(3) // 入出库状态: 3.站到站 |
| | | .setTaskType("agv") |
| | | .setIoPri(10D) |
| | | .setFullPlt("Y") // 满板:Y |
| | | .setPicking("N") // 拣料 |
| | | .setExitMk("N")// 退出 |
| | | .setStaNo(s) |
| | | .setSourceStaNo(param.getRsta())//agv取货位 |
| | | .setEmptyMk("N")// 空板 |
| | | .setBarcode(param.getBarcode())// 托盘码 |
| | | .setLinkMis("N") |
| | | .setAppeUser(9945L) |
| | | .setAppeTime(date) |
| | | .setModiUser(9945L) |
| | | .setModiTime(date); |
| | | if (!taskService.insert(task)) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | // 商品上架 |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R callEmptyBinOutBound(String staNo, String locType, Long userId) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_sts", 'D').eq("loc_type2", locType)); |
| | | if(locMast == null) { |
| | | return R.parse("该类型:" + locType +"空托盘不存在"); |
| | | } |
| | | String sta=""; |
| | | //滑块库 |
| | | if(locMast.getLocType3()==1){ |
| | | if(locMast.getLocType2()==1){ |
| | | sta = "402"; |
| | | }else if(locMast.getLocType2()==2){ |
| | | sta = "401"; |
| | | } |
| | | }else if(locMast.getLocType3()==2){ |
| | | sta="307"; |
| | | } |
| | | |
| | | // 获取路径 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 110) |
| | | .eq("stn_no", sta) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (staDesc == null) { |
| | | R.parse("出库路径不存在,站点:" + sta); |
| | | } |
| | | Date now = new Date(); |
| | | // 生成工作档 |
| | | int workNo = commonService.getWorkNo(WorkNoType.PAKOUT.type); |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(now); |
| | | wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID |
| | | wrkMast.setIoType(110); // 入出库状态: 110.空板出库 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setSourceStaNo(sta); // 源站 |
| | | wrkMast.setStaNo(sta); // 目标站 |
| | | wrkMast.setCrnNo(staDesc.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locMast.getLocNo()); // 源库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setMemo(staNo); |
| | | wrkMastService.insert(wrkMast); |
| | | |
| | | // 更新库位状态 |
| | | if (locMast.getLocSts().equals("D")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(now); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | |
| | | return R.ok("出库成功"); |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/25 |