|
@@ -1669,6 +1669,180 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
return AjaxResult.success("当前托盘备货成功!(未分配条码),还剩余未备数:" + residual);
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public synchronized AjaxResult groupDiskFJ(GroupDiskFrom groupDiskFrom) {
|
|
|
+ String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
|
|
|
+ String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
|
|
|
+ String sn = groupDiskFrom.getSn(); // 条码号
|
|
|
+ String sku = ""; // 物料编码
|
|
|
+ String orderNo = groupDiskFrom.getOrderNo();
|
|
|
+ Double qty = Double.valueOf(groupDiskFrom.getQty()); // 数量
|
|
|
+ final Double toQty;
|
|
|
+ Long currentVirtualZone; // 当前所在的虚拟区
|
|
|
+ boolean isAllocation = false; // 是否是分配好的库存
|
|
|
+ // 验证出库单
|
|
|
+ if (StringUtils.isNotEmpty(orderNo)) {
|
|
|
+ WmsDocOrderHeader header = wmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
|
|
|
+ if (!header.getOrderType().equals(Constant.ORDER_TYP.BH.getValue())) {
|
|
|
+ return AjaxResult.error("出库单类型不可反拣组盘!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 根据条码获取物料号
|
|
|
+ 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);
|
|
|
+ locIdSearchFrom.setLotattDTO(lotattDTO);
|
|
|
+ List<InvLotLocIdLotattVO> invLotLocIdLotattList = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom);
|
|
|
+ // 组盘是把出库的库存重新组到一个新的托盘上,所以起始托盘和条码理应可以查询到系统里有对应的库存。
|
|
|
+ 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);
|
|
|
+ } 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("不存在匹配库存!");
|
|
|
+ }
|
|
|
+ // 验证库存
|
|
|
+ if (StringUtils.isEmpty(endLotattVO.getLotatt15())) {
|
|
|
+ return AjaxResult.success("扫描的条码不可反拣组盘!");
|
|
|
+ }
|
|
|
+ WmsDocOrderHeader header = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(endLotattVO.getLotatt15());
|
|
|
+ if (header == null || !header.getOrderType().equals(Constant.ORDER_TYP.LH.getValue())) {
|
|
|
+ return AjaxResult.success("扫描的条码不可反拣组盘!不存在对应的出库理货单!");
|
|
|
+ }
|
|
|
+ if (!orderNo.equals(header.getSoReference1())) {
|
|
|
+ return AjaxResult.success("扫描的出库单和托盘库存不匹配!");
|
|
|
+ }
|
|
|
+
|
|
|
+ currentVirtualZone = endLotattVO.getLocationId();
|
|
|
+ invLotLocIdLotattVOList.add(endLotattVO);
|
|
|
+ // 不同的产品类型不允许放一个托盘上
|
|
|
+ boolean isSameType = iWmsDocAsnHeaderService.checkSameTypeByPalletNo(palletNoTo, sku);
|
|
|
+ if (!isSameType) {
|
|
|
+ throw new ServiceException("不同的产品类型不允许放一个托盘上");
|
|
|
+ }
|
|
|
+ //验证目标托盘库存,一个托盘只能备货一个出库单
|
|
|
+ AjaxResult ajaxResultC = invLotLocIdService.checkPalletIsOnlyOrderNo(groupDiskFrom.getPalletNoTo()
|
|
|
+ , "");
|
|
|
+ if (!ajaxResultC.isSuccess()) {
|
|
|
+ return ajaxResultC;
|
|
|
+ }
|
|
|
+ // 起始托盘和目标托盘一样,不做操作
|
|
|
+ if (palletNoFrom.equals(palletNoTo)) {
|
|
|
+ return AjaxResult.success("起始和目标托盘一致,不用组盘!");
|
|
|
+ }
|
|
|
+ // 判断扫描条码的库存是否被分配
|
|
|
+ if (endLotattVO.getQtyallocated().compareTo(BigDecimal.ONE.doubleValue()) == 0) {
|
|
|
+ isAllocation = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建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);
|
|
|
+ if (isAllocation) {
|
|
|
+ invLotAtt.setLotatt14("");
|
|
|
+ }
|
|
|
+ invLotAtt.setCreateTime(DateUtils.getNowDate());
|
|
|
+ if (invLotAttMapper.insertInvLotAtt(invLotAtt) > 0) {
|
|
|
+ for (InvLotLocIdLotattVO v : invLocIdList) {
|
|
|
+ // 已经分配的条码
|
|
|
+ if (isAllocation) {
|
|
|
+ boolean con = false;
|
|
|
+ // 修改原本出库单对应的任意一个条码数据
|
|
|
+ InvLocIdSearchFrom locIdSearchFrom01 = new InvLocIdSearchFrom();
|
|
|
+ locIdSearchFrom01.setSku(sku);
|
|
|
+ LotattDTO lotattDTO01 = new LotattDTO();
|
|
|
+ lotattDTO01.setLotatt07(palletNoFrom);
|
|
|
+ locIdSearchFrom01.setLotattDTO(lotattDTO01);
|
|
|
+ List<InvLotLocIdLotattVO> invLotLocIdLotattList01 = invLotLocIdService.selectInvLocIdLotattList(locIdSearchFrom01);
|
|
|
+ for (InvLotLocIdLotattVO locIdLotattVO : invLotLocIdLotattList01) {
|
|
|
+ // 没有备货并且分配数为1
|
|
|
+ if (StringUtils.isEmpty(locIdLotattVO.getLotatt14())
|
|
|
+ && locIdLotattVO.getQtyallocated().compareTo(BigDecimal.ZERO.doubleValue()) == 0) {
|
|
|
+ // 创建新批次
|
|
|
+ InvLotAtt invLotAttNew = invLotAttMapper.selectInvLotAttByLotnum(locIdLotattVO.getLotnum());
|
|
|
+ String newLotnum01 = idSequenceUtils.generateId("LOTNUMBER");
|
|
|
+ invLotAttNew.setLotnum(newLotnum01);
|
|
|
+ invLotAttNew.setLotatt14(orderNo);
|
|
|
+ invLotAttNew.setCreateTime(DateUtils.getNowDate());
|
|
|
+ invLotAttMapper.insertInvLotAtt(invLotAttNew);
|
|
|
+ // 更新库存
|
|
|
+ InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
|
|
|
+ invLotLocIdUpdate.setLotnum(locIdLotattVO.getLotnum());
|
|
|
+ invLotLocIdUpdate.setLotnumTo(newLotnum01);
|
|
|
+ invLotLocIdUpdate.setLocationId(locIdLotattVO.getLocationId().toString());
|
|
|
+ invLotLocIdUpdate.setCustomerId(locIdLotattVO.getCustomerId());
|
|
|
+ invLotLocIdUpdate.setSku(locIdLotattVO.getSku());
|
|
|
+ invLotLocIdUpdate.setQtyallocated(BigDecimal.ONE);
|
|
|
+ invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
|
|
|
+ con = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!con) {
|
|
|
+ return AjaxResult.error("托盘没有可以反拣组盘的物料!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 修改扫描条码
|
|
|
+ InvLotLocIdForm invLotLocIdUpdate = new InvLotLocIdForm();
|
|
|
+ invLotLocIdUpdate.setLotnum(lotnum);
|
|
|
+ invLotLocIdUpdate.setLocationId(v.getLocationId().toString());
|
|
|
+ invLotLocIdUpdate.setCustomerId(v.getCustomerId());
|
|
|
+ invLotLocIdUpdate.setSku(v.getSku());
|
|
|
+ invLotLocIdUpdate.setQtyallocated(BigDecimal.ZERO);
|
|
|
+ invLotLocIdUpdate.setLotnumTo(newLotnum);
|
|
|
+ invLotLocIdService.updateInvLotLocId(invLotLocIdUpdate);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 更新托盘
|
|
|
+ WmsBoxInfo wmsBoxInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(palletNoTo);
|
|
|
+ WmsBoxInfo boxInfoUpdate = new WmsBoxInfo();
|
|
|
+ boxInfoUpdate.setId(wmsBoxInfo.getId());
|
|
|
+ boxInfoUpdate.setLocationId(currentVirtualZone);
|
|
|
+ wmsBoxInfoService.updateWmsBoxInfo(boxInfoUpdate);
|
|
|
+ return AjaxResult.success("组盘成功!");
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public AjaxResult arrangeStock(ArrangeStockForm arrangeStockForm) {
|