|
@@ -54,6 +54,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 出库单头Service业务层处理
|
|
@@ -303,7 +304,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
}
|
|
|
for (InvLotLocId inv : invList) {
|
|
|
if (orderQty.doubleValue() == 0) {
|
|
|
- return AjaxResult.success("分配完成",originalOrderQty);
|
|
|
+ return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
}
|
|
|
//可以叫料且合格的库存
|
|
|
InvLotAtt lotAtt = invLotAttMapper.selectInvLotAttByLotnum(inv.getLotnum());
|
|
@@ -352,7 +353,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
// wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
|
|
|
//生成分配明细
|
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), allocatedQty, details, "20");
|
|
|
- return AjaxResult.success("分配完成",originalOrderQty);
|
|
|
+ return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
} else {
|
|
|
throw new ServiceException("占用库存分配数失败");
|
|
|
}
|
|
@@ -370,7 +371,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
// wmsDocOrderHeaderService.updateWmsDocOrderHeader(header);
|
|
|
//生成分配明细
|
|
|
actAllocationDetailsService.addActAllocationDetails(inv.getLotnum(), inv.getLocationId(), currentQty, details, "10");
|
|
|
- return AjaxResult.success("分配完成",originalOrderQty);
|
|
|
+ return AjaxResult.success("分配完成", originalOrderQty);
|
|
|
|
|
|
} else {
|
|
|
throw new ServiceException("占用库存分配数失败");
|
|
@@ -379,7 +380,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return AjaxResult.success("库存数不足,部分分配",originalOrderQty.subtract(orderQty));
|
|
|
+ return AjaxResult.success("库存数不足,部分分配", originalOrderQty.subtract(orderQty));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -400,37 +401,77 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public AjaxResult toPick(PickForm pickForm) {
|
|
|
- List<PickInfoForm> pickInfoFormList = null;
|
|
|
- Map<String, String> exitsMap = new HashMap<>();
|
|
|
- for (PickInfoForm p : pickInfoFormList) {
|
|
|
- String locationTo = p.getLocationTo();
|
|
|
- //TODO 任务完成后更新 查询对应的分配明细表
|
|
|
- //TODO 改成按托盘号进行呼叫
|
|
|
- ActAllocationDetails actAllocationDetails = actAllocationDetailsService.selectActAllocationDetailsByAllocationId(p.getAllocationId());
|
|
|
- String location = actAllocationDetails.getLocationId().toString();
|
|
|
- //qty = actAllocationDetails.getPickQty();
|
|
|
- //actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(p.getQty())));
|
|
|
- //actAllocationDetails.setPickToLocation(locationTo);
|
|
|
- actAllocationDetails.setLocationId(Long.parseLong(locationTo));
|
|
|
- actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
|
|
|
-
|
|
|
- //更新出库单拣货数量
|
|
|
- WmsDocOrderDetails wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByNoLineNo(actAllocationDetails.getOrderNo(), actAllocationDetails.getLineNo());
|
|
|
- wmsDocOrderDetails.setQtyPicked(wmsDocOrderDetails.getQtyPicked().add(actAllocationDetails.getPickQty()));
|
|
|
- wmsDocOrderDetails.setQtyPickedEach(wmsDocOrderDetails.getQtyPicked());
|
|
|
- if (actAllocationDetails.getQty().compareTo(actAllocationDetails.getPickQty()) == 1) {
|
|
|
- wmsDocOrderDetails.setLineStatus("30");
|
|
|
- } else {
|
|
|
- wmsDocOrderDetails.setLineStatus("40");
|
|
|
+ String orderNo = pickForm.getOrderNo();
|
|
|
+ String sn = pickForm.getSn();
|
|
|
+ BigDecimal qty = new BigDecimal(pickForm.getQty()); // 拣货数量
|
|
|
+ // 验证sn
|
|
|
+ CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.snCheck(sn);
|
|
|
+ WmsDocOrderHeader docOrderHeader = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
|
|
|
+ // 查询出分配明细
|
|
|
+ ActAllocationDetailsFrom actAllocationQuery = new ActAllocationDetailsFrom();
|
|
|
+ actAllocationQuery.setOrderNo(orderNo);
|
|
|
+ actAllocationQuery.setLotatt02(sn);
|
|
|
+ actAllocationQuery.setStatus(Constant.ORDER_STS.STS20.getValue());
|
|
|
+ List<ActAllocationDetailsFrom> actAllocationDetailsFromList = actAllocationDetailsService.selectActAllocationDetailsInvLotAttList(actAllocationQuery);
|
|
|
+ // 最终确定要拣货的明细
|
|
|
+ ActAllocationDetailsFrom endActAllocation = null;
|
|
|
+ // 相等拣货数量的明细
|
|
|
+ List<ActAllocationDetailsFrom> EqualAllocationList = actAllocationDetailsFromList
|
|
|
+ .stream()
|
|
|
+ .filter(v -> {
|
|
|
+ BigDecimal canPickNum = v.getQty().subtract(v.getPickQty());
|
|
|
+ return canPickNum.compareTo(qty) == 1;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ // 大于拣货数量的明细
|
|
|
+ List<ActAllocationDetailsFrom> greaterAllocationList = new ArrayList<>();
|
|
|
+ if (EqualAllocationList.size() == 0) {
|
|
|
+ greaterAllocationList = actAllocationDetailsFromList
|
|
|
+ .stream()
|
|
|
+ .filter(v -> {
|
|
|
+ BigDecimal canPickNum = v.getQty().subtract(v.getPickQty());
|
|
|
+ return canPickNum.compareTo(qty) == 0;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if (greaterAllocationList.size() > 0) {
|
|
|
+ endActAllocation = greaterAllocationList.get(0);
|
|
|
}
|
|
|
- wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
|
|
|
-
|
|
|
- //库存进行移动
|
|
|
- invLotLocIdService.stockTransfer(actAllocationDetails.getLocationId(), "", Long.parseLong(locationTo));
|
|
|
- //托盘进行绑定修改
|
|
|
- wmsBoxInfoMapper.updateLocationBind(Long.parseLong(location), Long.parseLong(locationTo), null);
|
|
|
- }
|
|
|
- return AjaxResult.success("操作成功");
|
|
|
+ } else {
|
|
|
+ endActAllocation = EqualAllocationList.get(0);
|
|
|
+ }
|
|
|
+ if (endActAllocation == null) {
|
|
|
+ return AjaxResult.error("没有可以拣货的分配明细!");
|
|
|
+ }
|
|
|
+ // 更新分配明细
|
|
|
+ ActAllocationDetails allocationUpdate = new ActAllocationDetails();
|
|
|
+ allocationUpdate.setAllocationId(endActAllocation.getAllocationId());
|
|
|
+ allocationUpdate.setPickQty(endActAllocation.getPickQty().add(qty));
|
|
|
+ allocationUpdate.setStatus(Constant.ORDER_STS.STS30.getValue());
|
|
|
+ if (endActAllocation.getQty().compareTo(allocationUpdate.getPickQty()) == 0) {
|
|
|
+ allocationUpdate.setStatus(Constant.ORDER_STS.STS40.getValue());
|
|
|
+ }
|
|
|
+ actAllocationDetailsService.updateActAllocationDetails(allocationUpdate);
|
|
|
+ // 更新库存数量
|
|
|
+ String lotnum = endActAllocation.getLotnum();
|
|
|
+ Long locationId = endActAllocation.getLocationId();
|
|
|
+ String sku = endActAllocation.getMaterial();
|
|
|
+ String customerId = Constant.CUSTOMER_ID;
|
|
|
+ InvLotLocId invLotLocId = invLotLocIdService.selectInvLotLocIdById(locationId.toString(), customerId, sku, lotnum);
|
|
|
+ invLotLocId.setQty(invLotLocId.getQty().subtract(qty));
|
|
|
+ invLotLocId.setQtyEach(invLotLocId.getQty());
|
|
|
+ invLotLocId.setQtyallocated(invLotLocId.getQtyallocated().subtract(qty));
|
|
|
+ invLotLocId.setQtyallocatedEach(invLotLocId.getQtyallocated());
|
|
|
+ invLotLocIdService.updateInvLotLocId(invLotLocId);
|
|
|
+ // 删除0库存
|
|
|
+ invLotLocIdService.clearZeroInventory(locationId.toString(),customerId,sku,lotnum);
|
|
|
+ // 更新出库单拣货数量
|
|
|
+ WmsDocOrderDetails wmsDocOrderDetails = wmsDocOrderDetailsMapper.selectWmsDocOrderDetailsByNoLineNo(endActAllocation.getOrderNo(), endActAllocation.getLineNo());
|
|
|
+ wmsDocOrderDetails.setQtyPicked(wmsDocOrderDetails.getQtyPicked().add(qty));
|
|
|
+ wmsDocOrderDetails.setQtyPickedEach(wmsDocOrderDetails.getQtyPicked());
|
|
|
+ wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS30.getValue());
|
|
|
+ if (wmsDocOrderDetails.getQtyOrdered().compareTo(wmsDocOrderDetails.getQtyPicked()) == 0) {
|
|
|
+ wmsDocOrderDetails.setLineStatus(Constant.ORDER_STS.STS40.getValue());
|
|
|
+ }
|
|
|
+ wmsDocOrderDetailsMapper.updateWmsDocOrderDetails(wmsDocOrderDetails);
|
|
|
+ return AjaxResult.success("拣货成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -572,7 +613,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
} else {
|
|
|
List<InvLotLocIdLotattVO> locIdLotattVOList = lotnumAndInvLocIdMap.get(v.getLotnum());
|
|
|
locIdLotattVOList.add(v);
|
|
|
- lotnumAndInvLocIdMap.put(v.getLotnum(),locIdLotattVOList);
|
|
|
+ lotnumAndInvLocIdMap.put(v.getLotnum(), locIdLotattVOList);
|
|
|
}
|
|
|
});
|
|
|
if (palletNoFrom.equals(palletNoTo) && orderNo.equals("")) {
|
|
@@ -581,7 +622,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
|
|
|
} else {
|
|
|
// 根据老Lotnum创建新的Lotnum
|
|
|
- for (Map.Entry<String, List<InvLotLocIdLotattVO>> lotnumToInvLocId: lotnumAndInvLocIdMap.entrySet()) {
|
|
|
+ for (Map.Entry<String, List<InvLotLocIdLotattVO>> lotnumToInvLocId : lotnumAndInvLocIdMap.entrySet()) {
|
|
|
String lotnum = lotnumToInvLocId.getKey();
|
|
|
List<InvLotLocIdLotattVO> invLocIdList = lotnumToInvLocId.getValue();
|
|
|
InvLotAtt invLotAtt = invLotAttMapper.selectInvLotAttByLotnum(lotnum);
|
|
@@ -640,7 +681,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
actAllocationDetails.setPickQty(actAllocationDetails.getPickQty().add(new BigDecimal(arrangeStockForm.getQty())));
|
|
|
if (actAllocationDetails.getQty().compareTo(actAllocationDetails.getPickQty()) == 1) {
|
|
|
actAllocationDetails.setStatus("30");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
actAllocationDetails.setStatus("40");
|
|
|
}
|
|
|
actAllocationDetailsService.updateActAllocationDetails(actAllocationDetails);
|
|
@@ -885,7 +926,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
details.setdEdi04(erpOrder.getVaild()); //单据状态
|
|
|
details.setdEdi05(erpOrder.getStockId()); //仓库编号
|
|
|
details.setdEdi06(erpOrder.getOrderState()); //是否扫描完成
|
|
|
- details.setdEdi07(erpOrder.getOrderNo()+""); //项次
|
|
|
+ details.setdEdi07(erpOrder.getOrderNo() + ""); //项次
|
|
|
details.setdEdi08(erpOrder.getOrderType()); //erp单据类型
|
|
|
details.setdEdi09(erpOrder.getInout()); //erp出入库类型
|
|
|
details.setLineStatus("00");
|