瀏覽代碼

组盘解绑bug修复

zhangxin 1 年之前
父節點
當前提交
9cff3129d7

+ 22 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java

@@ -4,7 +4,11 @@ import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
-import com.ruoyi.ams.asn.form.*;
+import com.ruoyi.ams.asn.dto.UnbindWmsBoxDTO;
+import com.ruoyi.ams.asn.form.PaForm;
+import com.ruoyi.ams.asn.form.StockForm;
+import com.ruoyi.ams.asn.form.StockingListForm;
+import com.ruoyi.ams.asn.form.UnlockForm;
 import com.ruoyi.ams.asn.service.IWmsDocAsnDetailsService;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 import com.ruoyi.ams.asn.vo.SearchStockVO;
@@ -15,18 +19,13 @@ import com.ruoyi.ams.box.service.IWmsBoxInfoService;
 import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.common.vo.DictVO;
 import com.ruoyi.ams.config.domain.FlowConfigHeader;
-import com.ruoyi.ams.config.domain.dto.AgvCallDTO;
-import com.ruoyi.ams.config.domain.dto.AgvCallItemDTO;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.config.domain.vo.FlowConfigHeaderVO;
 import com.ruoyi.ams.config.domain.vo.LotattConfigVO;
 import com.ruoyi.ams.config.service.IFlowConfigHeaderService;
 import com.ruoyi.ams.config.service.ILotattConfigService;
-import com.ruoyi.ams.inv.domain.form.InvLocIdSearchFrom;
-import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.form.InvTransferPickForm;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
-import com.ruoyi.ams.lineCall.domain.form.LineCallDetailsForm;
 import com.ruoyi.ams.lineCall.domain.form.LineCallForm;
 import com.ruoyi.ams.lineCall.domain.form.LineCallListFrom;
 import com.ruoyi.ams.lineCall.domain.vo.LineCallVO;
@@ -45,8 +44,8 @@ import com.ruoyi.base.domain.form.BasLocationForm;
 import com.ruoyi.base.domain.vo.CodeSkuRelationshipSoVO;
 import com.ruoyi.base.domain.vo.CodeSkuRelationshipVO;
 import com.ruoyi.base.form.SnCheckForm;
-import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.form.SnCheckSoForm;
+import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -63,7 +62,9 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 /**
  * Created by IntelliJ IDEA.
@@ -555,6 +556,19 @@ public class PdaController {
         return wmsDocOrderHeaderService.syncPdaGroupDiskBH(pdaGroupDiskDTO);
     }
 
+
+    /**
+     * PDA解绑物料并发控制
+     * @param unbindWmsBoxDTO
+     * @return
+     */
+    @PostMapping("/docOrder/unbindWmsBox")
+    public AjaxResult unbindWmsBox(@RequestBody UnbindWmsBoxDTO unbindWmsBoxDTO) {
+        return wmsDocOrderHeaderService.syncUnbindWmsBox(unbindWmsBoxDTO);
+    }
+
+
+
     /**
      * 分拣出库
      *

+ 27 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/dto/UnbindWmsBoxDTO.java

@@ -0,0 +1,27 @@
+package com.ruoyi.ams.asn.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class UnbindWmsBoxDTO implements Serializable {
+
+    @ApiModelProperty(value = "起始托盘")
+    private String palletFrom;
+
+    @ApiModelProperty(value = "目标托盘")
+    private String palletTo;
+
+    @ApiModelProperty(value = "批次属性主键")
+    private String lotnum;
+
+    @ApiModelProperty(value = "托盘绑定物料")
+    private String sku;
+
+    @ApiModelProperty(value = "出库单号 不传为分拣组盘")
+    private String erpNo;
+
+
+}

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/box/service/impl/WmsBoxInfoServiceImpl.java

@@ -247,6 +247,7 @@ public class WmsBoxInfoServiceImpl implements IWmsBoxInfoService {
     public Boolean updateWmsBoxLocationIdByBoxNo(String boxNo, Long locationId){
         return wmsBoxInfoMapper.update(new WmsBoxInfo(), Wrappers.<WmsBoxInfo>lambdaUpdate()
                 .eq(WmsBoxInfo::getBoxNo, boxNo)
+                .set(WmsBoxInfo::getUpdateTime, DateUtils.getNowDate())
                 .set(WmsBoxInfo::getLocationId, locationId)) > 0;
     }
 }

+ 9 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java

@@ -439,6 +439,15 @@ public interface IInvLotLocIdService {
      */
     Boolean updateInvLotLocId(String lotNum, String lotNumTo, BigDecimal qty, String sku, String locationId);
 
+    /**
+     * 修改库位库存主键以及库位id
+     * @param lotNum
+     * @param lotNumTo
+     * @param locationId
+     * @return
+     */
+    Boolean updateInvLotLocIdLotNum(String lotNum, String lotNumTo, String locationId);
+
     /**
      * 修改库位库存信息
      * @param lotNum

+ 16 - 1
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -30,7 +30,6 @@ import com.ruoyi.base.domain.BaseLocationZone;
 import com.ruoyi.base.domain.form.BasLocationForm;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.utils.IdSequenceUtils;
-import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
@@ -1165,6 +1164,22 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         return updateInvLotLocId(lotNum, lotNumTo, qty, null, sku, locationId);
     }
 
+    /**
+     * 修改库位库存主键以及库位id
+     * @param lotNum
+     * @param lotNumTo
+     * @param locationId
+     * @return
+     */
+    @Override
+    public Boolean updateInvLotLocIdLotNum(String lotNum, String lotNumTo, String locationId) {
+        return invLotLocIdMapper.update(new InvLotLocId(), Wrappers.<InvLotLocId>lambdaUpdate()
+                .eq(InvLotLocId::getLotnum, lotNum)
+                .set(StringUtils.isNotBlank(lotNumTo), InvLotLocId::getLotnum, lotNumTo)
+                .set(StringUtils.isNotBlank(locationId), InvLotLocId::getLocationId, locationId)
+        ) > 0;
+    }
+
     /**
      *  修改库位库存信息
      * @param lotNum

+ 13 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/service/IWmsDocOrderHeaderService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.ams.order.service;
 
+import com.ruoyi.ams.asn.dto.UnbindWmsBoxDTO;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.order.domain.PalletMatchLog;
@@ -251,6 +252,18 @@ public interface IWmsDocOrderHeaderService {
      */
     AjaxResult groupDiskBHCheck(GroupDiskFrom groupDiskFrom);
 
+    /**
+     * PDA解绑物料并发控制
+     * @param unbindWmsBoxDTO
+     * @return
+     */
+    AjaxResult syncUnbindWmsBox(UnbindWmsBoxDTO unbindWmsBoxDTO);
+
+    /**
+     * PDA理货备货并发控制
+     * @param pdaGroupDiskDTO
+     * @return
+     */
     AjaxResult syncPdaGroupDiskBH(PdaGroupDiskDTO pdaGroupDiskDTO);
 
     /**

+ 2 - 1
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderDetailsServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.common.exception.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -148,7 +149,7 @@ public class WmsDocOrderDetailsServiceImpl implements IWmsDocOrderDetailsService
      */
     @Override
     public List<WmsDocOrderDetails> queryWmsDocOrderDetailsByOrderNo(List<String> orderNoList){
-        return wmsDocOrderDetailsMapper.selectList(Wrappers.<WmsDocOrderDetails>lambdaQuery().in(WmsDocOrderDetails::getOrderNo, orderNoList));
+        return wmsDocOrderDetailsMapper.selectList(Wrappers.<WmsDocOrderDetails>lambdaQuery().in(WmsDocOrderDetails::getOrderNo, orderNoList).orderByAsc(WmsDocOrderDetails::getOrderLineNo));
     }
 
 }

+ 74 - 5
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -1,11 +1,14 @@
 package com.ruoyi.ams.order.service.impl;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.comparator.CompareUtil;
+import cn.hutool.core.util.NumberUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 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.box.domain.WmsBoxInfo;
 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.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.math.BigDecimal;
 import java.util.*;
@@ -1066,7 +1068,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
     @Transactional
     @Override
-    public synchronized AjaxResult groupDisk(GroupDiskFrom groupDiskFrom) {
+    public AjaxResult groupDisk(GroupDiskFrom groupDiskFrom) {
         String palletNoFrom = groupDiskFrom.getPalletNoFrom(); // 起始托盘
         String palletNoTo = groupDiskFrom.getPalletNoTo(); // 目标托盘
         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
      * @return
      */
@@ -2866,8 +2935,8 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         invLotAtt.setSku(sku);
         invLotAtt.setLotatt02(sn);
         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());
         return invLotAtt;
     }