| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.common.config.CodeCoolException; |
| | | import zy.cloud.wms.common.model.BillDto; |
| | | import zy.cloud.wms.common.model.MatnrDto; |
| | | import zy.cloud.wms.common.model.OrderStoDto; |
| | | 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.ErpService; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.*; |
| | |
| | | private CstmrService cstmrService; |
| | | @Autowired |
| | | private ErpService erpService; |
| | | @Autowired |
| | | private AsrsService asrsService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | List<OrderDetl> orderDetls = orderDetlService.selectByOrderNo(param.getOrderNo()); |
| | | if (Cools.isEmpty(orderDetls)) { |
| | | return R.error("此单据已失效,请联系管理员"); |
| | | } |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | if (Arith.remainder(orderDetl.getAnfme(), 1) > 0) { |
| | | return R.error(orderDetl.getMaktx() + "数量必须为整数"); |
| | | } |
| | | } |
| | | OrderStoDto dto = new OrderStoDto().create(order.getOrderNo(), orderDetls); |
| | | // 开始整理出库数据 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R asrsStockTransfer(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()); |
| | | params.add(transferParam); |
| | | Result1 result = asrsService.stockTransfer(params); |
| | | if (result.getCode() == 500) { |
| | | if (Cools.isEmpty(result.getData())) { |
| | | throw new CoolException(result.getMsg()); |
| | | } else { |
| | | throw new CodeCoolException("20001-" + result.getData()); |
| | | } |
| | | } |
| | | // 直接增加库存 |
| | | LocDetl locDetl = locDetlService.getLocDetl(param.getNode_id(), param.getMatnr()); |
| | | if (locDetl == null) { |
| | | // 更新货位库存明细 |
| | | locDetl = new LocDetl(); |
| | | locDetl.setLocNo(node.getName()); |
| | | locDetl.setNodeId(node.getId()); |
| | | locDetl.setAnfme(anfme); |
| | | VersionUtils.setLocDetl(locDetl, mat); |
| | | locDetl.setStatus(1); |
| | | locDetl.setCreateBy(userId); |
| | | locDetl.setCreateTime(new Date()); |
| | | locDetl.setUpdateBy(userId); |
| | | locDetl.setUpdateTime(new Date()); |
| | | boolean insert = locDetlService.insert(locDetl); |
| | | if (!insert) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } else { |
| | | if (!locDetlService.incrementStock(node.getId(), param.getMatnr(), anfme)) { |
| | | throw new CoolException("新增库存明细档失败"); |
| | | } |
| | | } |
| | | |
| | | return R.ok("补仓成功,等待立库调拨"); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R stockCheck(StoCheckParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getLocNo())) { |
| | | return R.error("请选择货位"); |