| | |
| | | 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.OrderStoDto; |
| | | import zy.cloud.wms.common.service.asrs.AsrsService; |
| | | import zy.cloud.wms.common.service.asrs.entity.Result; |
| | | import zy.cloud.wms.common.utils.VersionUtils; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.entity.param.StockTransferParam; |
| | | import zy.cloud.wms.manager.service.CustOrderService; |
| | | import zy.cloud.wms.manager.service.LocDetlService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | import zy.cloud.wms.manager.service.PakoutService; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Optional; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/3/1 |
| | |
| | | private CustOrderService custOrderService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private AsrsService asrsService; |
| | | |
| | | @Transactional |
| | | public List<StoPreTab> stockOutPreview(OrderStoDto dto) { |
| | | if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getCustOrders())) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | List<StoPreTab> res = new ArrayList<>(); |
| | | // 检查库存是否足够 |
| | | locDetlService.checkLocDetlCount(dto.getNumber()); |
| | | List<StoPreTab> result = new ArrayList<>(); |
| | | List<StockTransferParam> transferParams = locDetlService.checkLocDetlCountOfRes(dto.getNumber()); |
| | | if (!Cools.isEmpty(transferParams)) { |
| | | // 查看立库库存 |
| | | Result result = asrsService.stockTransferPrew(transferParams); |
| | | if (result.getCode() == 500) { |
| | | throw new CodeCoolException("20001-" + String.valueOf(result.getData())); |
| | | } |
| | | if (result.getCode() == 200) { |
| | | res = (List<StoPreTab>) result.getData(); |
| | | } |
| | | } |
| | | |
| | | for (CustOrder custOrder : dto.getCustOrders()) { |
| | | // 判断物料是否存在 |
| | | Mat mat = matService.selectByMatnr(custOrder.getUserCode()); |
| | |
| | | tab.setRemQty(tab.getTotal() - tab.getReduce()); |
| | | tab.setPrior(locDetlService.isPrior(locDetl.getNodeId(), mat.getMatnr())); |
| | | tab.setPrior$(tab.getPrior()?"✔":"×"); |
| | | result.add(tab); |
| | | tab.setType(1); |
| | | res.add(tab); |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return result; |
| | | res.sort(new Comparator<StoPreTab>() { |
| | | @Override |
| | | public int compare(StoPreTab o1, StoPreTab o2) { |
| | | // return o1.getMatnr().length() - o2.getMatnr().length(); |
| | | return (int) (o1.getAnfme() - o2.getAnfme()); |
| | | } |
| | | }); |
| | | return res; |
| | | } |
| | | |
| | | @Transactional |