|
@@ -1,11 +1,14 @@
|
|
package com.ruoyi.ams.order.service.impl;
|
|
package com.ruoyi.ams.order.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
import cn.hutool.core.comparator.CompareUtil;
|
|
import cn.hutool.core.comparator.CompareUtil;
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
+import com.ruoyi.ams.asn.dto.UnbindWmsBoxDTO;
|
|
import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
|
|
import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
|
|
import com.ruoyi.ams.box.domain.WmsBoxInfo;
|
|
import com.ruoyi.ams.box.domain.WmsBoxInfo;
|
|
import com.ruoyi.ams.box.mapper.WmsBoxInfoMapper;
|
|
import com.ruoyi.ams.box.mapper.WmsBoxInfoMapper;
|
|
@@ -66,7 +69,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@@ -1066,7 +1068,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
- public synchronized AjaxResult groupDisk(GroupDiskFrom groupDiskFrom) {
|
|
|
|
|
|
+ public AjaxResult groupDisk(GroupDiskFrom groupDiskFrom) {
|
|
String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
|
|
String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
|
|
String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
|
|
String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
|
|
String sn = groupDiskFrom.getSn(); // 条码号
|
|
String sn = groupDiskFrom.getSn(); // 条码号
|
|
@@ -2732,7 +2734,74 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 并发控制
|
|
|
|
|
|
+ * PDA解绑物料并发控制
|
|
|
|
+ * @param unbindWmsBoxDTO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public synchronized AjaxResult syncUnbindWmsBox(UnbindWmsBoxDTO unbindWmsBoxDTO){
|
|
|
|
+ return unbindWmsBox(unbindWmsBoxDTO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRES_NEW)
|
|
|
|
+ public AjaxResult unbindWmsBox(UnbindWmsBoxDTO unbindWmsBoxDTO) {
|
|
|
|
+ WmsBoxInfo wmsBoxToInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(unbindWmsBoxDTO.getPalletTo());
|
|
|
|
+ if (ObjectUtil.isNull(wmsBoxToInfo)) {
|
|
|
|
+ throw new BaseException("查询不到目标托盘:" + unbindWmsBoxDTO.getPalletTo());
|
|
|
|
+ }
|
|
|
|
+ WmsBoxInfo wmsBoxFromInfo = wmsBoxInfoService.selectWmsBoxInfoByBoxNo(unbindWmsBoxDTO.getPalletFrom());
|
|
|
|
+ if (ObjectUtil.isNull(wmsBoxFromInfo)){
|
|
|
|
+ throw new BaseException("查询不到起始托盘:" + unbindWmsBoxDTO.getPalletFrom());
|
|
|
|
+ }
|
|
|
|
+ Long locationId = Optional.ofNullable(wmsBoxFromInfo.getLocationId()).orElseThrow(() -> new BaseException("起始托盘库位信息被清空:" + unbindWmsBoxDTO.getPalletFrom()));
|
|
|
|
+ //把目标托盘设置成非满拖
|
|
|
|
+ wmsBoxToInfo.setIsFull("N");
|
|
|
|
+ wmsBoxInfoService.updateWmsBoxInfo(wmsBoxToInfo);
|
|
|
|
+
|
|
|
|
+ List<InvLotLocId> invLotLocIdList = invLotLocIdService.selectInvLotLocIdByLotnum(unbindWmsBoxDTO.getLotnum());
|
|
|
|
+ if (CollectionUtil.isEmpty(invLotLocIdList)) {
|
|
|
|
+ throw new BaseException("该托盘不存在库存:" + unbindWmsBoxDTO.getPalletTo());
|
|
|
|
+ }
|
|
|
|
+ InvLotLocId invLotLocId = invLotLocIdList.stream().findFirst().get();
|
|
|
|
+ InvLotAtt invLotAtt = invLotAttService.selectInvLotAttByLotnum(invLotLocId.getLotnum());
|
|
|
|
+ //创建新批次
|
|
|
|
+ String lotNum = IdWorker.getIdStr();
|
|
|
|
+ invLotAttService.insertInvLotAtt(buildInvLotAtt(lotNum, unbindWmsBoxDTO.getPalletFrom(), null, invLotAtt.getLotatt02()
|
|
|
|
+ , unbindWmsBoxDTO.getSku(), StringUtils.isNotBlank(invLotAtt.getLotatt08()) ? invLotAtt.getLotatt08() : null));
|
|
|
|
+ //修改库存
|
|
|
|
+ invLotLocIdService.updateInvLotLocIdLotNum(invLotLocId.getLotnum(), lotNum, String.valueOf(locationId));
|
|
|
|
+ if (StringUtils.isBlank(unbindWmsBoxDTO.getErpNo())) return AjaxResult.success("托盘:" + unbindWmsBoxDTO.getPalletTo() + "解绑成功!");
|
|
|
|
+
|
|
|
|
+ WmsDocOrderHeader wmsDocOrderHeader = selectWmsDocOrderHeaderByErpNo(unbindWmsBoxDTO.getErpNo());
|
|
|
|
+ if (ObjectUtil.isNull(wmsDocOrderHeader)) throw new BaseException("出库单号错误!");
|
|
|
|
+ String orderNo = wmsDocOrderHeader.getOrderNo();
|
|
|
|
+ List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetailsByOrderNo(orderNo);
|
|
|
|
+ if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) throw new BaseException("出库单明细为空!");
|
|
|
|
+ wmsDocOrderDetailsList = ListUtil.reverse(wmsDocOrderDetailsList.stream().filter(item -> ObjectUtil.isNotNull(item.getQtyAllocated())
|
|
|
|
+ || !NumberUtil.equals(item.getQtyAllocated(), BigDecimal.ZERO)).collect(Collectors.toList()));
|
|
|
|
+ BigDecimal qtyAllocated = ObjectUtil.isNotNull(invLotLocId.getQtyallocated()) ? invLotLocId.getQtyallocated() : BigDecimal.ZERO;
|
|
|
|
+ BigDecimal qty = invLotLocId.getQty().subtract(qtyAllocated);
|
|
|
|
+
|
|
|
|
+ for (WmsDocOrderDetails wmsDocOrderDetails : wmsDocOrderDetailsList) {
|
|
|
|
+ Boolean flag = CompareUtil.compare(qty, wmsDocOrderDetails.getQtyAllocated()) >= 0;
|
|
|
|
+ wmsDocOrderDetails.setQtyAllocated(flag ? BigDecimal.ZERO : wmsDocOrderDetails.getQtyAllocated().subtract(qty));
|
|
|
|
+ wmsDocOrderDetails.setQtyAllocatedEach(wmsDocOrderDetails.getQtyAllocated());
|
|
|
|
+ wmsDocOrderDetails.setLineStatus(flag ? Constant.ORDER_STS.STS00.getValue() : Constant.ORDER_STS.STS10.getValue());
|
|
|
|
+ wmsDocOrderDetailsService.updateWmsDocOrderDetails(wmsDocOrderDetails);
|
|
|
|
+ qty = qty.subtract(wmsDocOrderDetails.getQtyAllocated());
|
|
|
|
+ if (!flag || NumberUtil.equals(qty, BigDecimal.ZERO)) break;
|
|
|
|
+ }
|
|
|
|
+ //修改出库单单据状态
|
|
|
|
+ wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
|
|
|
|
+ .set(WmsDocOrderHeader::getOrderStatus, Constant.ORDER_STS.STS22.getValue()).eq(WmsDocOrderHeader::getOrderNo, orderNo));
|
|
|
|
+
|
|
|
|
+ // 删除条码扫描记录
|
|
|
|
+ erpBarcodesService.untieRecordErpBarcodeListAsnSo(unbindWmsBoxDTO.getErpNo(), null, invLotAtt.getLotatt02());
|
|
|
|
+ return AjaxResult.success("托盘:" + unbindWmsBoxDTO.getPalletTo() + "解绑成功!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * PDA理货备货并发控制
|
|
* @param pdaGroupDiskDTO
|
|
* @param pdaGroupDiskDTO
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@@ -2866,8 +2935,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
|
|
invLotAtt.setSku(sku);
|
|
invLotAtt.setSku(sku);
|
|
invLotAtt.setLotatt02(sn);
|
|
invLotAtt.setLotatt02(sn);
|
|
invLotAtt.setLotatt07(palletNoTo);
|
|
invLotAtt.setLotatt07(palletNoTo);
|
|
- invLotAtt.setLotatt08(asnNo);
|
|
|
|
- invLotAtt.setLotatt14(orderNo); // 备货对应的出库单号
|
|
|
|
|
|
+ invLotAtt.setLotatt08(StringUtils.isNotBlank(asnNo) ? asnNo : null);
|
|
|
|
+ invLotAtt.setLotatt14(StringUtils.isNotBlank(orderNo) ? orderNo : null); // 备货对应的出库单号
|
|
invLotAtt.setCreateTime(DateUtils.getNowDate());
|
|
invLotAtt.setCreateTime(DateUtils.getNowDate());
|
|
return invLotAtt;
|
|
return invLotAtt;
|
|
}
|
|
}
|