| | |
| | | import zy.cloud.wms.common.service.MainService; |
| | | import zy.cloud.wms.common.service.asrs.AsrsService; |
| | | import zy.cloud.wms.common.service.asrs.entity.Result1; |
| | | import zy.cloud.wms.common.service.erp.ErpR; |
| | | import zy.cloud.wms.common.service.erp.ErpService; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.*; |
| | |
| | | private ErpService erpService; |
| | | @Autowired |
| | | private AsrsService asrsService; |
| | | @Autowired |
| | | private PakinService pakinService; |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stockPakin(PakinParam param, Long userId) { |
| | | Node node = nodeService.selectByUuid(param.getNodeId()); |
| | | if (node == null) { |
| | | node = nodeService.selectById(param.getNodeId()); |
| | | try { |
| | | node = nodeService.selectById(param.getNodeId()); |
| | | } catch (Exception e) { |
| | | return R.error("货位不存在"); |
| | | } |
| | | } |
| | | if (node == null) { |
| | | return R.error("货位不存在"); |
| | |
| | | Mat mat = matService.selectByMatnr(dto.getMatnr()); |
| | | if (mat == null) { |
| | | throw new CoolException("物料数据错误,请联系管理员"); |
| | | } |
| | | // 保存入库记录 |
| | | Pakin pakin = new Pakin( |
| | | "I" + String.valueOf(snowflakeIdWorker.nextId()), // 任务号[非空] |
| | | null, // 工作状态 |
| | | null, // 托盘号 |
| | | dto.getCount(), // 入库数量 |
| | | node.getId(), // 关联货位[非空] |
| | | node.getUuid(), // 货位[非空] |
| | | mat.getMatnr(), // 商品编码[非空] |
| | | null, // 商品名称 |
| | | null, // 名称 |
| | | null, // 尺码 |
| | | null, // 型号 |
| | | null, // 批号 |
| | | null, // 单位 |
| | | null, // SKC |
| | | null, // 单据类型 |
| | | null, // 单据编号 |
| | | null, // 客户名称 |
| | | null, // 品项数 |
| | | null, // 数量 |
| | | null, // 重量 |
| | | 1, // 状态 |
| | | userId, // 添加人员 |
| | | now, // 添加时间 |
| | | userId, // 修改人员 |
| | | now, // 修改时间 |
| | | null // 备注 |
| | | ); |
| | | VersionUtils.setPakin(pakin, mat); |
| | | if (!pakinService.insert(pakin)) { |
| | | throw new CoolException("保存入库记录失败"); |
| | | } |
| | | LocDetl locDetl = locDetlService.getLocDetl(node.getId(), dto.getMatnr()); |
| | | if (locDetl == null) { |
| | |
| | | billDto.setQty(dto.getCount()); |
| | | dtos.add(billDto); |
| | | } |
| | | if (!erpService.uploadBill(dtos, docId, docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, docId, docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | |
| | | return R.ok("入库成功"); |
| | |
| | | billDto.setQty(comb.getAnfme()); |
| | | dtos.add(billDto); |
| | | } |
| | | if (!erpService.uploadBill(dtos, param.getDocType(), docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, param.getDocType(), docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | for (Pakout pakout : pakouts) { |
| | | total = pakout.getAnfme() + total; |
| | | } |
| | | |
| | | StoPrintVo vo = new StoPrintVo(); |
| | | vo.setDocNum(param.getOrderNo()); |
| | | vo.setList(pakouts); |
| | |
| | | return R.ok("补仓成功,等待立库调拨"); |
| | | } |
| | | |
| | | @Override |
| | | public R asrsStockTransferLocMode(AsrsTransferParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getNode_id(), param.getMatnr(), param.getSafe_qua(), param.getAmount())) { |
| | | return R.error("数量错误"); |
| | | } |
| | | Node node = nodeService.selectById(param.getNode_id()); |
| | | Mat mat = matService.selectByMatnr(param.getMatnr()); |
| | | if (node == null || mat == null) { |
| | | return R.error(); |
| | | } |
| | | double anfme = Arith.subtract(2, param.getSafe_qua(), param.getAmount()); |
| | | List<StockTransferParam> params = new ArrayList<>(); |
| | | StockTransferParam transferParam = new StockTransferParam(); |
| | | transferParam.setMatnr(param.getMatnr()); |
| | | transferParam.setAnfme(anfme); |
| | | transferParam.setAllotNo(param.getNode_id()+ "_" +param.getMatnr()); |
| | | transferParam.setLocNo(param.getLocNo()); |
| | | params.add(transferParam); |
| | | Result1 result = asrsService.stockTransferLocMode(params); |
| | | if (result.getCode() == 500) { |
| | | if (Cools.isEmpty(result.getData())) { |
| | | throw new CoolException(result.getMsg()); |
| | | } else { |
| | | throw new CodeCoolException("20001-" + result.getData()); |
| | | } |
| | | } |
| | | |
| | | return R.ok("补仓成功,等待立库调拨"); |
| | | } |
| | | |
| | | @Override |
| | | public R stockCheck(StoCheckParam param, Long userId) { |
| | |
| | | billDto.setMatnr(check.getMatnr()); |
| | | billDto.setQty(Math.abs(check.getDiffQty())); |
| | | dtos.add(billDto); |
| | | if (!erpService.uploadBill(dtos, docId.intValue(), docNum)) { |
| | | throw new CoolException("无法上报至erp"); |
| | | ErpR erpR = erpService.uploadBill(dtos, docId.intValue(), docNum); |
| | | if (!erpR.getSuccess()) { |
| | | throw new CoolException("无法上报至erp:"+erpR.getMsg()); |
| | | } |
| | | return R.ok(); |
| | | } |