|
@@ -1339,7 +1339,9 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
List<InvLotLocIdLotattVO> invLotLocIdLotattList = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom);
|
|
|
// 组盘是把出库的库存重新组到一个新的托盘上,所以起始托盘和条码理应可以查询到系统里有对应的库存。
|
|
|
if (invLotLocIdLotattList.size() == 0) {
|
|
|
- return AjaxResult.error(String.format("不存在对应库存!起始托盘:%s,条码:%s", palletNoFrom, sn));
|
|
|
+ // 备货(不是当前出库单分配的)
|
|
|
+ return groupDiskUnAllocationBH(groupDiskFrom);
|
|
|
+// return AjaxResult.error(String.format("不存在对应库存!起始托盘:%s,条码:%s", palletNoFrom, sn));
|
|
|
}
|
|
|
// 产品的话基本只能查出有一条库存 但是物料可能会多条 但是我们只处理一条库存
|
|
|
List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = new ArrayList<>();
|
|
@@ -1444,7 +1446,131 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
boxInfoUpdate.setId(wmsBoxInfo.getId());
|
|
|
boxInfoUpdate.setLocationId(currentVirtualZone);
|
|
|
wmsBoxInfoService.updateWmsBoxInfo(boxInfoUpdate);
|
|
|
- return AjaxResult.success("组盘成功!");
|
|
|
+ return AjaxResult.success("备货成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 备货(不是当前出库单分配的)
|
|
|
+ *
|
|
|
+ * @param groupDiskFrom
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult groupDiskUnAllocationBH(GroupDiskFrom groupDiskFrom) {
|
|
|
+ String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
|
|
|
+ String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
|
|
|
+ String sn = groupDiskFrom.getSn(); // 条码号
|
|
|
+ String orderNo = ""; // 出库单号
|
|
|
+ String sku = ""; // 物料编码
|
|
|
+ Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
|
|
|
+ boolean isAllUpdate = false; // 库存转移类型,是全部修改,还是拆分
|
|
|
+ boolean isStockPalletNoTo = groupDiskFrom.isStockPalletNoTo(); // 目标托盘是否是备货托盘,为了方便,目标托盘默认是备货托盘
|
|
|
+ final Double toQty;
|
|
|
+ Long currentVirtualZone; // 当前所在的虚拟区
|
|
|
+ if (StringUtils.isNotEmpty(groupDiskFrom.getOrderNo())) {
|
|
|
+ orderNo = groupDiskFrom.getOrderNo();
|
|
|
+ }
|
|
|
+ // 根据条码获取物料号
|
|
|
+ CodeSkuRelationshipVO codeSkuRelationshipVO = codeSkuRelationshipService.checkIsProduct(sn);
|
|
|
+ sku = codeSkuRelationshipVO.getSku();
|
|
|
+ if (codeSkuRelationshipVO.isProduct()) {
|
|
|
+ qty = 1.0; //产品默认为1
|
|
|
+ }
|
|
|
+ toQty = qty;
|
|
|
+ // 根据起始托盘,物料号查出库存
|
|
|
+ InvLocIdSearchFrom locIdSearchFrom = new InvLocIdSearchFrom();
|
|
|
+ locIdSearchFrom.setSku(sku);
|
|
|
+ LotattDTO lotattDTO = new LotattDTO();
|
|
|
+ lotattDTO.setLotatt07(palletNoFrom);
|
|
|
+ lotattDTO.setLotatt02(sn);
|
|
|
+// lotattDTO.setLotatt15(orderNo);
|
|
|
+ locIdSearchFrom.setLotattDTO(lotattDTO);
|
|
|
+ List<InvLotLocIdLotattVO> invLotLocIdLotattList = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom);
|
|
|
+ /// 筛选出未备货的库存
|
|
|
+// invLotLocIdLotattList = invLotLocIdLotattList.stream().filter(v -> StringUtils.isEmpty(v.getLotatt14())).collect(Collectors.toList());
|
|
|
+// if (invLotLocIdLotattList.size() == 0) {
|
|
|
+// return AjaxResult.error(String.format("不存在对应库存!起始托盘:%s,条码:%s", palletNoFrom, sn));
|
|
|
+// }
|
|
|
+ // 产品的话基本只能查出有一条库存 我们只处理一条库存
|
|
|
+ List<InvLotLocIdLotattVO> invLotLocIdLotattVOList = new ArrayList<>();
|
|
|
+ InvLotLocIdLotattVO endLotattVO = null;
|
|
|
+ List<InvLotLocIdLotattVO> equalInv = invLotLocIdLotattList.stream().filter(v -> v.getQty().compareTo(toQty) == 0).collect(Collectors.toList());
|
|
|
+ if (equalInv.size() > 0) {
|
|
|
+ endLotattVO = equalInv.get(0);
|
|
|
+ isAllUpdate = true;
|
|
|
+ } else {
|
|
|
+ List<InvLotLocIdLotattVO> greaterInv = invLotLocIdLotattList.stream().filter(v -> v.getQty().compareTo(toQty) == 1).collect(Collectors.toList());
|
|
|
+ if (greaterInv.size() > 0) {
|
|
|
+ endLotattVO = greaterInv.get(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (endLotattVO == null) {
|
|
|
+ return AjaxResult.error("组盘数量大于单条库存数量!");
|
|
|
+ }
|
|
|
+ currentVirtualZone = endLotattVO.getLocationId();
|
|
|
+ invLotLocIdLotattVOList.add(endLotattVO);
|
|
|
+ // 验证备货库存是否已经备货
|
|
|
+ if (StringUtils.isNotEmpty(endLotattVO.getLotatt14())) {
|
|
|
+ return AjaxResult.error("扫描条码已经备货,对应出库单:" + endLotattVO.getLotatt14());
|
|
|
+ }
|
|
|
+ //验证目标托盘库存,一个托盘只能备货一个出库单
|
|
|
+ AjaxResult ajaxResultC = invLotLocIdService.checkPalletIsOnlyOrderNo(groupDiskFrom.getPalletNoTo()
|
|
|
+ , orderNo);
|
|
|
+ if (!ajaxResultC.isSuccess()) {
|
|
|
+ return ajaxResultC;
|
|
|
+ }
|
|
|
+ // 创建Lotnum和库存对应关系
|
|
|
+ Map<String, List<InvLotLocIdLotattVO>> lotnumAndInvLocIdMap = new HashMap<>();
|
|
|
+ invLotLocIdLotattVOList.stream().forEach(v -> {
|
|
|
+ if (lotnumAndInvLocIdMap.get(v) == null) {
|
|
|
+ lotnumAndInvLocIdMap.put(v.getLotnum(), Arrays.asList(v));
|
|
|
+ } else {
|
|
|
+ List<InvLotLocIdLotattVO> locIdLotattVOList = lotnumAndInvLocIdMap.get(v.getLotnum());
|
|
|
+ locIdLotattVOList.add(v);
|
|
|
+ lotnumAndInvLocIdMap.put(v.getLotnum(), locIdLotattVOList);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 根据老Lotnum创建新的Lotnum
|
|
|
+ for (Map.Entry<String, List<InvLotLocIdLotattVO>> lotnumToInvLocId : lotnumAndInvLocIdMap.entrySet()) {
|
|
|
+ String lotnum = lotnumToInvLocId.getKey();
|
|
|
+ List<InvLotLocIdLotattVO> invLocIdList = lotnumToInvLocId.getValue();
|
|
|
+ InvLotAtt invLotAtt = invLotAttMapper.selectInvLotAttByLotnum(lotnum);
|
|
|
+ String newLotnum = idSequenceUtils.generateId("LOTNUMBER");
|
|
|
+ invLotAtt.setLotnum(newLotnum);
|
|
|
+ invLotAtt.setLotatt07(palletNoTo);
|
|
|
+ invLotAtt.setLotatt14(orderNo); // 备货对应的出库单号
|
|
|
+ InvLotLocIdLotattVO invLotLocIdLotattVO = invLocIdList.get(0);
|
|
|
+ if (StringUtils.isEmpty(invLotLocIdLotattVO.getLotatt15())) {
|
|
|
+ invLotAtt.setLotatt15(orderNo);
|
|
|
+ } else {
|
|
|
+ invLotAtt.setLotatt15(invLotLocIdLotattVO.getLotatt15());
|
|
|
+ }
|
|
|
+ invLotAtt.setCreateTime(DateUtils.getNowDate());
|
|
|
+ if (invLotAttMapper.insertInvLotAtt(invLotAtt) > 0) {
|
|
|
+ for (InvLotLocIdLotattVO v : invLocIdList) {
|
|
|
+ if (isAllUpdate) {
|
|
|
+ InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
|
|
|
+ invLotLocIdUpdate.setLotnum(lotnum);
|
|
|
+ invLotLocIdUpdate.setLocationId(v.getLocationId().toString());
|
|
|
+ invLotLocIdUpdate.setCustomerId(v.getCustomerId());
|
|
|
+ invLotLocIdUpdate.setSku(v.getSku());
|
|
|
+ invLotLocIdUpdate.setQtyallocated(invLotLocIdUpdate.getQty());
|
|
|
+ invLotLocIdUpdate.setLotnumTo(newLotnum);
|
|
|
+ invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
|
|
|
+ }
|
|
|
+ // 更新出库单备货数量
|
|
|
+ wmsDocOrderHeaderService.modifystockCompletionStatus(orderNo, sku, new BigDecimal(toQty));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 更新托盘
|
|
|
+ WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(palletNoTo);
|
|
|
+ WmsBoxInfo boxInfoUpdate = new WmsBoxInfo();
|
|
|
+ boxInfoUpdate.setId(wmsBoxInfo.getId());
|
|
|
+ boxInfoUpdate.setLocationId(currentVirtualZone);
|
|
|
+ wmsBoxInfoService.updateWmsBoxInfo(boxInfoUpdate);
|
|
|
+ return AjaxResult.success("备货成功!(未分配条码)");
|
|
|
}
|
|
|
|
|
|
@Transactional
|