| | |
| | | package zy.cloud.wms.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.*; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | 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 SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private AsrsService asrsService; |
| | | @Autowired |
| | | private ErpService erpService; |
| | | @Autowired |
| | |
| | | } |
| | | } |
| | | return R.ok("生成销售订单" + param.getNumber() + "成功"); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public R stockTransfer(String number, Long userId) { |
| | | List<CustOrder> custOrders = custOrderService.selectList(new EntityWrapper<CustOrder>().eq("number", number).eq("status", 1)); |
| | | boolean asrs = false; |
| | | List<StockTransferParam> params = new ArrayList<>(); |
| | | for (CustOrder custOrder : custOrders) { |
| | | Double count = locDetlService.selectCountByMatnr(custOrder.getUserCode()); |
| | | if (count == null) { |
| | | count = 0.0D; |
| | | } |
| | | if (count < custOrder.getQty()) { |
| | | if (!asrs) { asrs = true; } |
| | | StockTransferParam param = new StockTransferParam(); |
| | | param.setMatnr(custOrder.getUserCode()); |
| | | param.setAnfme(custOrder.getQty() - count); |
| | | params.add(param); |
| | | } |
| | | } |
| | | if (asrs) { |
| | | // if (asrsService.stockTransfer(params)) { |
| | | // for (StockTransferParam param : params) { |
| | | // // 修改销售订单待出数量 |
| | | // if (!custOrderService.updateQty(number, param.getMatnr(), param.getAnfme())) { |
| | | // throw new CoolException("修改销售订单待出数量失败"); |
| | | // } |
| | | // } |
| | | // return R.ok("库存调拨成功"); |
| | | // } else { |
| | | // return R.error("立库调拨失败,请联系管理员"); |
| | | // } |
| | | } |
| | | return R.error("暂不缺货,不需要立库调拨"); |
| | | } |
| | | |
| | | @Override |
| | | public R asrsStockTransfer(AsrsTransferParam param, Long userId) { |
| | | if (Cools.isEmpty(param.getNode_id(), param.getMatnr(), param.getSafe_qua(), param.getAmount())) { |
| | | return R.error("数量错误"); |
| | | } |
| | | List<StockTransferParam> params = new ArrayList<>(); |
| | | StockTransferParam transferParam = new StockTransferParam(); |
| | | transferParam.setMatnr(param.getMatnr()); |
| | | transferParam.setAnfme(Arith.subtract(2, param.getSafe_qua(), param.getAmount())); |
| | | 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()); |
| | | } |
| | | } |
| | | return R.ok("补仓成功,等待立库调拨"); |
| | | } |
| | | |
| | | @Override |