Browse Source

永湖需求变更

zhangxin 1 năm trước cách đây
mục cha
commit
cf7947dec7

+ 12 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaController.java

@@ -751,7 +751,7 @@ public class PdaController {
      * 1.删除备货库存
      * 2.修改出库单状态
      */
-    @PostMapping("/base/locationReleaseLine")
+    @PostMapping("/base/oldLocationReleaseLine")
     public AjaxResult locationReleaseLine(@RequestBody LineReleaseFrom lineReleaseFrom) {
         String orderNo = wmsDocOrderHeaderService.changeErpNoToOrderNo(lineReleaseFrom.getOrderNo());
         if (StringUtils.isEmpty(orderNo)) {
@@ -760,6 +760,17 @@ public class PdaController {
         lineReleaseFrom.setOrderNo(orderNo);
         return invLotLocIdService.locationReleaseLine(lineReleaseFrom);
     }
+
+    /**
+     * PDA备货出库释放
+     * 1.删除备货库存
+     * 2.修改出库单状态
+     */
+    @PostMapping("/base/locationReleaseLine")
+    public AjaxResult releaseWarehouse(@RequestBody LineReleaseFrom lineReleaseFrom) {
+        wmsDocOrderHeaderService.releaseWarehouse(lineReleaseFrom);
+        return AjaxResult.success("托盘出库成功!");
+    }
     //endregion
 
 

+ 28 - 30
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/wcs/WcsController.java

@@ -1,14 +1,11 @@
 package com.ruoyi.web.controller.warewms.wcs;
 
 import com.alibaba.fastjson.JSON;
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
 import com.ruoyi.ams.agv.ndc.common.CRC16Util;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
-import com.ruoyi.ams.business.BusinessServiceImpl;
 import com.ruoyi.ams.business.IBusinessService;
-import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.redis.RedisCache;
@@ -20,7 +17,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @RestController
@@ -37,22 +34,23 @@ public class WcsController {
     @PostMapping("/btnOp")
     public AjaxResult add(@RequestBody BtnOpForm btnOpForm) {
         log.info("按钮盒请求------------------------》" + JSON.toJSONString(btnOpForm));
-        if (redisCache.tryLock(btnOpForm.getIp() + btnOpForm.getOpType(), 15)) {
-            log.info("交管操作执行");
-            //1: 192.168.77.105
-            //2: 192.168.77.104
-            String op = "";
-            String businessType = "";
-            if (btnOpForm.getOpType().equals("CLOSE")) {
-                businessType = "74";
-            } else if (btnOpForm.getOpType().equals("OPEN")) {
-                businessType = "75";
-            }
-            if (btnOpForm.getIp().equals("192.168.77.105")) {
-                op = "1";
-            } else if (btnOpForm.getIp().equals("192.168.77.104")) {
-                op = "2";
-            }
+        redisCache.setCacheObject(btnOpForm.getIp() + btnOpForm.getOpType(), btnOpForm.getOpType(), 15, TimeUnit.SECONDS);
+
+        log.info("交管操作执行");
+        //1: 192.168.77.105
+        //2: 192.168.77.104
+        String op = "";
+        String businessType = "";
+        if (btnOpForm.getOpType().equals("CLOSE")) {
+            businessType = "74";
+        } else if (btnOpForm.getOpType().equals("OPEN")) {
+            businessType = "75";
+        }
+        if (btnOpForm.getIp().equals("192.168.77.105")) {
+            op = "1";
+        } else if (btnOpForm.getIp().equals("192.168.77.104")) {
+            op = "2";
+        }
 //            WcsTask wcsTask = new WcsTask();
 //            wcsTask.setLocationFrom(Constant.LOC_MIDDLE_CACHE.toString());
 //            wcsTask.setLocationTo(Constant.LOC_SORTATION_CACHE.toString());
@@ -62,17 +60,17 @@ public class WcsController {
 //            wcsTask.setTaskNo(System.currentTimeMillis() + "");
 //            businessService.sendTask(wcsTask);
 
-            AmsTask addTaskForm = new AmsTask();
-            addTaskForm.setTaskNo(String.valueOf(System.currentTimeMillis()));
-            addTaskForm.setIkey(Long.parseLong(String.valueOf(CRC16Util.calcCrc16(ByteUtil.string2byteArray(addTaskForm.getTaskNo())))));
-            addTaskForm.setStFrom(Integer.valueOf(Constant.LOC_MIDDLE_CACHE.toString()));
-            addTaskForm.setStTo(Integer.valueOf(Constant.LOC_SORTATION_CACHE.toString()));
-            addTaskForm.setPriority(1);
-            addTaskForm.setBusinessType(businessType);
-            addTaskForm.setExt1(op);
+        AmsTask addTaskForm = new AmsTask();
+        addTaskForm.setTaskNo(String.valueOf(System.currentTimeMillis()));
+        addTaskForm.setIkey(Long.parseLong(String.valueOf(CRC16Util.calcCrc16(ByteUtil.string2byteArray(addTaskForm.getTaskNo())))));
+        addTaskForm.setStFrom(Integer.valueOf(Constant.LOC_MIDDLE_CACHE.toString()));
+        addTaskForm.setStTo(Integer.valueOf(Constant.LOC_SORTATION_CACHE.toString()));
+        addTaskForm.setPriority(1);
+        addTaskForm.setBusinessType(businessType);
+        addTaskForm.setExt1(op);
+
+        amsTaskService.insertAmsTask(addTaskForm);
 
-            amsTaskService.insertAmsTask(addTaskForm);
-        }
         return AjaxResult.success("");
     }
 }

+ 5 - 3
ruoyi-admin/src/main/resources/application-dev.yml

@@ -6,7 +6,7 @@ spring:
         druid:
             # 主库数据源
             master:
-                url: jdbc:mysql://localhost:3306/warewms_yonghu_zx?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
+                url: jdbc:mysql://localhost:3306/yonghu?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8
                 username: root
                 password: root
                 driverClassName: com.mysql.cj.jdbc.Driver
@@ -58,13 +58,15 @@ spring:
                         multi-statement-allow: true
     redis:
         # 地址
-        host: 154.12.16.4
+        host: localhost
+#        host: 154.12.16.4
         # 端口,默认为6379
         port: 6379
         # 数据库索引
         database: 0
         # 密码
-        password: 123499
+        password: 123456
+#        password: 123499
         # 连接超时时间
         timeout: 10s
         lettuce:

+ 60 - 8
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -1,5 +1,6 @@
-package com.ruoyi.admin.test.base;
+package com.ruoyi.admin.test.base.impl;
 
+import cn.hutool.core.comparator.CompareUtil;
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.RuoYiApplication;
 import com.ruoyi.ams.agv.ndc.domain.AmsHexdefineDetail;
@@ -10,32 +11,33 @@ import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.form.StockForm;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
+import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.business.domain.FilterLockInvLocationDTO;
 import com.ruoyi.ams.config.domain.AsnSoStrategy;
 import com.ruoyi.ams.config.domain.FlowConfigHeader;
 import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
-import com.ruoyi.ams.business.IBusinessService;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.config.domain.dto.OutWarehouseDTO;
 import com.ruoyi.ams.config.mapper.AsnSoStrategyMapper;
 import com.ruoyi.ams.config.service.IFlowConfigHeaderService;
 import com.ruoyi.ams.config.service.LocationAllocationStrategy;
 import com.ruoyi.ams.erp.domain.ErpBarCodeList;
-import com.ruoyi.ams.erp.domain.ErpBarcodes;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
 import com.ruoyi.ams.erp.mapper.ErpBarcodesMapper;
+import com.ruoyi.ams.erp.service.IErpBarcodesService;
 import com.ruoyi.ams.erp.service.ISyncService;
-import com.ruoyi.ams.erp.service.impl.SyncServiceImpl;
+import com.ruoyi.ams.inv.domain.InvLotAtt;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
+import com.ruoyi.ams.inv.service.IInvLotAttService;
 import com.ruoyi.ams.locationView.domain.form.LocationViewForm;
 import com.ruoyi.ams.locationView.domain.vo.LocationViewVO;
 import com.ruoyi.ams.locationView.service.LocationViewService;
 import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
 import com.ruoyi.ams.order.mapper.WmsDocOrderDetailsMapper;
+import com.ruoyi.ams.order.service.IWmsDocOrderDetailsService;
 import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
-import com.ruoyi.ams.order.vo.StockOrderVO;
 import com.ruoyi.ams.task.service.IWcsTaskService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
@@ -46,7 +48,8 @@ import com.ruoyi.base.mapper.BaseSkuMapper;
 import com.ruoyi.base.service.IBaseIdsequenceService;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseWarehouseService;
-import com.ruoyi.base.utils.IdSequenceUtils;;
+import com.ruoyi.base.utils.IdSequenceUtils;
+import com.ruoyi.common.exception.base.BaseException;
 import org.assertj.core.util.Lists;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -60,6 +63,8 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+;
+
 /**
  * Created by IntelliJ IDEA.
  * User: andy.qu
@@ -99,6 +104,9 @@ public class WarehouseTest {
     private IWmsDocAsnHeaderService wmsDocAsnHeaderService;
     @Autowired
     private IWmsDocOrderHeaderService wmsDocOrderHeaderService;
+
+    @Autowired
+    private IWmsDocOrderDetailsService wmsDocOrderDetailsService;
     @Autowired
     private IWcsTaskService wcsTaskService;
     @Autowired
@@ -215,10 +223,20 @@ public class WarehouseTest {
         System.out.println(JSON.toJSONString(locationInfoList));
     }
 
+    @Autowired
+    private IErpBarcodesService erpBarcodesService;
+
     @Test
     public void test7() {
-        List<StockOrderVO> orderVOList = wmsDocOrderDetailsMapper.selectStockOrder("123");
-        System.out.println(orderVOList);
+
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails("SO202308300006");
+        for (WmsDocOrderDetails wmsDocOrderDetails : wmsDocOrderDetailsList) {
+            if (CompareUtil.compare(wmsDocOrderDetails.getOrderLineNo(), new BigDecimal("48")) == 0)
+            erpBarcodesService.recordErpBarcodeListSo(wmsDocOrderDetails, "R12101H23H0205"
+                    , "SORTATION01", "YZB0133", BigDecimal.ONE, "59");
+
+        }
+
     }
 
     @Test
@@ -406,8 +424,42 @@ public class WarehouseTest {
         redisTemplate.opsForValue().set("erpOrderList", JSON.toJSONString(erpOrderListList));
     }
 
+    @Autowired
+    private IInvLotAttService invLotAttService;
+
+    @Test
+    public void erpCode() {
+        erpBarcodesService.untieRecordErpBarcodeListAsnSo("Y1471-23060011", null, "M11501H23F0104");
+    }
 
+    @Test
+    public synchronized void a() {
+       d();
+    }
 
+    @Test
+    public void d(){
+        wmsDocOrderHeaderService.reversePickInventoryMatch("[\"T2502-23101001\"]");
+        System.out.println(JSON.toJSONString(wmsDocOrderHeaderService.queryPalletMatchInfoList("[\"T2502-23101001\"]")));
+//        c();
+//        b();
+    }
+
+    private void c(){
+        InvLotAtt invLotAtt = new InvLotAtt();
+        invLotAtt.setLotnum("1");
+        invLotAtt.setSku("1");
+        invLotAttService.insertInvLotAtt(invLotAtt);
+    }
+    private void b() {
+        InvLotLocId invLotLocId = new InvLotLocId();
+        invLotLocId.setLotnum("1");
+        invLotLocId.setLocationId("1");
+        invLotLocId.setCustomerId("1");
+        invLotLocId.setSku("1");
+        invLotLocIdMapper.insertInvLotLocId(invLotLocId);
+        if(1==1) throw new BaseException("test");
+    }
 
     @Test
     public void doStockTest() {

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/GroupDiskConvertDTO.java

@@ -8,6 +8,8 @@ import java.math.BigDecimal;
 @Data
 public class GroupDiskConvertDTO extends PdaGroupDiskDTO{
 
+    private static final long serialVersionUID = -4176978857003577412L;
+
     @ApiModelProperty("产品/物料")
     private String sku;
 

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/PalletMatchLogDTO.java

@@ -11,6 +11,7 @@ import java.util.Date;
 
 @Data
 public class PalletMatchLogDTO implements Serializable {
+
     private static final long serialVersionUID = -3052302494611264008L;
 
     @TableId(type = IdType.ASSIGN_UUID)

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/PdaGroupDiskDTO.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 
 @Data
 public class PdaGroupDiskDTO implements Serializable {
+
     private static final long serialVersionUID = -6537424798126213032L;
 
     /**

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/ReversePickConvertDTO.java

@@ -5,6 +5,8 @@ import lombok.Data;
 @Data
 public class ReversePickConvertDTO extends ReversePickGroupDiskDTO{
 
+    private static final long serialVersionUID = 873413393162302280L;
+
     private String sku;
 
     private String palletFrom;

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/ReversePickGroupDiskDTO.java

@@ -8,7 +8,9 @@ import java.math.BigDecimal;
 
 @Data
 public class ReversePickGroupDiskDTO implements Serializable {
+
     private static final long serialVersionUID = -5918088014815517706L;
+
     /**
      * 起始托盘
      */

+ 1 - 0
warewms-ams/src/main/java/com/ruoyi/ams/order/dto/ReversePickInventoryMatchDTO.java

@@ -8,6 +8,7 @@ import java.math.BigDecimal;
 @Data
 public class ReversePickInventoryMatchDTO implements Serializable {
 
+    private static final long serialVersionUID = -8872518833999701581L;
     private String sku;
 
     private String orderNo;

+ 4 - 4
warewms-ams/src/main/java/com/ruoyi/ams/order/mapper/WmsDocOrderHeaderMapper.java

@@ -1,12 +1,11 @@
 package com.ruoyi.ams.order.mapper;
 
-import java.util.List;
-
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
 import com.ruoyi.ams.order.domain.WmsDocOrderHeader;
 import com.ruoyi.ams.order.vo.CheckOutVO;
-import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
 
 /**
  * 出库单头Mapper接口
@@ -14,6 +13,7 @@ import org.apache.ibatis.annotations.Param;
  * @author ruoyi
  * @date 2022-10-18
  */
+@Mapper
 public interface WmsDocOrderHeaderMapper extends BaseMapper<WmsDocOrderHeader> {
     /**
      * 查询出库单头

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

@@ -458,6 +458,13 @@ public interface IWmsDocOrderHeaderService {
      */
     AjaxResult pdaReversePickGroupDisk(ReversePickGroupDiskDTO reversePickGroupDiskDTO);
 
+    /**
+     * 出库释放
+     * @param lineReleaseFrom
+     * @return
+     */
+    Boolean releaseWarehouse(LineReleaseFrom lineReleaseFrom);
+
     /**
      * 库存分配
      * @param orderNos

+ 10 - 2
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/UpdateOrderStockingProcessImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.ams.order.service.impl;
 
+import cn.hutool.core.util.NumberUtil;
 import com.alibaba.fastjson.JSON;
 import com.ruoyi.ams.erp.domain.ErpOrderList;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
@@ -139,7 +140,7 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         // 变更出库明细和单头
         updateQuantityAndStatusOfDocuments(markerListMap);
         // 更新库存
-        updateInventory(markerListMap);
+//        updateInventory(markerListMap);
         // 更新备货之后,检查哪些托盘上有非备货的库存,并且更新到备货单备注中
         Set<String> palletsEndNotInStocks = checkThePalletIsNotInStock(orderNo);
         StringBuilder builder = new StringBuilder();
@@ -302,7 +303,14 @@ public class UpdateOrderStockingProcessImpl implements UpdateOrderStockingProces
         WmsDocOrderHeader wmsDocOrderHeader = wmsDocOrderHeaderService.selectDocOrderHeaderByOrderNo(orderNo);
         for (WmsDocOrderDetails details : value) {
             BigDecimal qtySoft = details.getQtySoftAllocated();
-            iWmsDocOrderDetailsService.deleteWmsDocOrderDetailsByOrderNo(details.getOrderNo(), details.getOrderLineNo().longValue());
+//            iWmsDocOrderDetailsService.deleteWmsDocOrderDetailsByOrderNo(details.getOrderNo(), details.getOrderLineNo().longValue());
+            //删除的明细保留 状态更改为完成 数量改为零 已备货明细通过反拣取出库存
+            details.setLineStatus(orderStatus);
+            details.setQtyOrdered(BigDecimal.ZERO);
+            details.setQtyOrderedEach(BigDecimal.ZERO);
+            details.setQtySoftAllocated(NumberUtil.add(qtySoft, NumberUtil.sub(BigDecimal.ZERO, details.getQtyAllocated())));
+            details.setQtySoftallocatedEach(details.getQtySoftAllocated());
+            iWmsDocOrderDetailsService.updateWmsDocOrderDetails(details);
             // 更新需要减去的备货库存
             details.setQtyOrdered(qtySoft);
         }

+ 60 - 25
warewms-ams/src/main/java/com/ruoyi/ams/order/service/impl/WmsDocOrderHeaderServiceImpl.java

@@ -63,7 +63,9 @@ import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
+import io.jsonwebtoken.lang.Assert;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -2774,6 +2776,37 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return wmsDocOrderHeaderService.reversePickInventoryMatch(orderNos);
     }
 
+    /**
+     * 出库释放
+     * @param lineReleaseFrom
+     * @return
+     */
+    @Override
+    public Boolean releaseWarehouse(LineReleaseFrom lineReleaseFrom) {
+        String palletNo = lineReleaseFrom.getPalletNo();
+        WmsDocOrderHeader wmsDocOrderHeader = selectWmsDocOrderHeaderByErpNo(lineReleaseFrom.getOrderNo());
+        Assert.isTrue(ObjectUtil.isNotNull(wmsDocOrderHeader), "出库单不存在!");
+        Assert.isTrue(Constant.ORDER_TYP.BH.getValue().equals(wmsDocOrderHeader.getOrderType()), "单据类型为备货单才可出库!");
+        String orderNo = wmsDocOrderHeader.getOrderNo();
+        List<InvLotAtt> invLotAttList = invLotAttService.queryInvLotAtt(lineReleaseFrom.getPalletNo());
+        List<InvLotAtt> invLotAttFilterList = invLotAttList.stream().filter(item ->
+                CompareUtil.compare(item.getLotatt14(), lineReleaseFrom.getOrderNo()) == 0).collect(Collectors.toList());
+        Assert.isTrue(CollectionUtil.isNotEmpty(invLotAttFilterList), "托盘无出库单备货库存!");
+        List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttFilterList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
+        Assert.isTrue(CollectionUtil.isNotEmpty(invLotLocIdList), "该托盘出库单备货库存已全部出库!");
+        Long locationId = Long.parseLong(invLotLocIdList.stream().map(InvLotLocId::getLocationId).findFirst().orElseThrow(() -> new BaseException("库存库位信息丢失!")));
+        // 清除库存
+        invLotLocIdService.clear(locationId, palletNo, Constant.WAREHOUSE_ID, "PDA");
+        // 修改出库单状态
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.selectWmsDocOrderDetailsByOrderNo(orderNo);
+        List<WmsDocOrderDetails> wmsDocOrderDetailsFilterList = wmsDocOrderDetailsList.stream().filter(item ->
+                CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS23.getValue()) != 0).collect(Collectors.toList());
+        return wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
+                .set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(wmsDocOrderDetailsFilterList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS99.getValue())
+                .set(WmsDocOrderHeader::getUpdateTime, DateUtils.getNowDate())
+                .eq(WmsDocOrderHeader::getOrderNo, orderNo)) > 0;
+    }
+
     /**
      * 库存匹配
      */
@@ -2782,7 +2815,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     public Boolean inventoryMatch(String orderNos) {
         List<String> orderList = JSONArray.parseArray(orderNos, String.class);
         List<PalletMatchLog> palletMatchLogList = palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
-        List<InvLotAttPalletTotalDTO> result = buildInventoryMatchList(orderList, palletMatchLogList);
+        List<InvLotAttPalletTotalDTO> result = buildInventoryMatchList(orderList, Constant.ORDER_TYP.BH.getValue(), palletMatchLogList);
         return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
     }
 
@@ -2793,11 +2826,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
     @Transactional(propagation = Propagation.REQUIRES_NEW)
     public Boolean reversePickInventoryMatch(String orderNos) {
         List<String> orderList = JSONArray.parseArray(orderNos, String.class);
-        List<PalletMatchLog> palletMatchLogList = palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
-        LinkedList<Object> reversePickInventoryMatchList = buildReversePickInventoryMatchList(orderList, palletMatchLogList);
+        palletMatchLogService.checkOrderNoAndGetPalletMatchLogList(orderList);
+        //反拣暂时不考虑呼出托盘重复问题 传入空list
+        LinkedList<Object> reversePickInventoryMatchList = buildReversePickInventoryMatchList(orderList, Lists.newArrayList());
         Boolean flag = (Boolean) reversePickInventoryMatchList.pop();
         List<InvLotAttPalletTotalDTO> result = (List<InvLotAttPalletTotalDTO>) reversePickInventoryMatchList.pop();
-        if (flag) result.addAll(buildInventoryMatchList(orderList, palletMatchLogList));
+        if (flag) result.addAll(buildInventoryMatchList(orderList, Constant.ORDER_TYP.FJ.getValue(), Lists.newArrayList()));
         return palletMatchLogService.insertBatch(buildPalletMatchLogList(result, orderList));
     }
 
@@ -2879,10 +2913,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         return AjaxResult.success("托盘:" + unbindDTO.getPalletTo() + "解绑成功!托盘数量: " + invLotAttService.queryPalletTotal(unbindDTO.getPalletTo()));
     }
 
-    /**
-     * PDA托盘出库:构建匹配列表
-     */
-    private List<InvLotAttPalletTotalDTO> buildInventoryMatchList(List<String> orderList, List<PalletMatchLog> palletMatchLogList){
+    private List<WmsDocOrderDetails> getWmsDocOrderDetailsList(List<String> orderList, String orderType){
         //根据erp单号获取出库单头列表
         List<WmsDocOrderHeader> wmsDocOrderHeaderList = wmsDocOrderHeaderMapper.selectList(Wrappers.<WmsDocOrderHeader>lambdaQuery().in(WmsDocOrderHeader::getSoReference1, orderList).orderByDesc(WmsDocOrderHeader::getCreateTime));
         if (CollectionUtil.isEmpty(wmsDocOrderHeaderList)) {
@@ -2899,7 +2930,18 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
             throw new BaseException("出库单明细为空!");
         }
-        Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupBySkuMap = wmsDocOrderDetailsList.stream().filter(item -> StringUtils.isNotBlank(item.getSku())).collect(Collectors.groupingBy(WmsDocOrderDetails::getSku));
+        return wmsDocOrderDetailsList.stream().filter(item -> StringUtils.isNotBlank(item.getSku())
+                && orderType.equals(Constant.ORDER_TYP.FJ.getValue()) ?
+                NumberUtil.isGreater(item.getQtyAllocated(), BigDecimal.ZERO) : Boolean.TRUE).collect(Collectors.toList());
+    }
+
+    /**
+     * PDA托盘出库:构建匹配列表
+     */
+    private List<InvLotAttPalletTotalDTO> buildInventoryMatchList(List<String> orderList, String orderType, List<PalletMatchLog> palletMatchLogList){
+        //出库类型多可通过map维护
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = getWmsDocOrderDetailsList(orderList, orderType);
+        Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupBySkuMap = wmsDocOrderDetailsList.stream().collect(Collectors.groupingBy(WmsDocOrderDetails::getSku));
         if (CollectionUtil.isEmpty(wmsDocOrderDetailsGroupBySkuMap)) {
             throw new BaseException("出库单明细绑定sku为空!");
         }
@@ -2927,21 +2969,12 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      * PDA反拣出库:构建匹配列表
      */
     private LinkedList<Object> buildReversePickInventoryMatchList(List<String> orderList, List<PalletMatchLog> palletMatchLogList){
-        //根据erp单号获取出库单头列表
-        List<WmsDocOrderHeader> wmsDocOrderHeaderList = wmsDocOrderHeaderMapper.selectList(Wrappers.<WmsDocOrderHeader>lambdaQuery().in(WmsDocOrderHeader::getSoReference1, orderList).orderByDesc(WmsDocOrderHeader::getCreateTime));
-        if (CollectionUtil.isEmpty(wmsDocOrderHeaderList)) {
-            throw new BaseException("请扫描正确的出库单号");
-        }
-        List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(
-                wmsDocOrderHeaderList.stream().filter(item -> StringUtils.isNotBlank(item.getOrderNo()))
-                        .map(WmsDocOrderHeader::getOrderNo).collect(Collectors.toList()));
-        if (CollectionUtil.isEmpty(wmsDocOrderDetailsList)) {
-            throw new BaseException("出库单明细为空!");
-        }
+        List<WmsDocOrderDetails> wmsDocOrderDetailsList = getWmsDocOrderDetailsList(orderList, Constant.ORDER_TYP.FJ.getValue());
         //所需出库托盘
         List<InvLotAttPalletTotalDTO> invLotAttPalletTotalDTOList = new ArrayList<>();
-        Boolean flag = Boolean.FALSE;
+        boolean flag = Boolean.FALSE;
         Map<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupByOrderNoMap = wmsDocOrderDetailsList.stream().collect(Collectors.groupingBy(WmsDocOrderDetails::getOrderNo));
+        if (CollectionUtil.isEmpty(wmsDocOrderDetailsGroupByOrderNoMap)) throw new BaseException("该出库单未进行理货备货!");
         List<ReversePickInventoryMatchDTO> reversePickInventoryMatchDTOList = new ArrayList<>();
         for (Map.Entry<String, List<WmsDocOrderDetails>> wmsDocOrderDetailsGroupByOrderNoEntry : wmsDocOrderDetailsGroupByOrderNoMap.entrySet()) {
             List<String> skuList = wmsDocOrderDetailsGroupByOrderNoEntry.getValue().stream().map(WmsDocOrderDetails::getSku).distinct().collect(Collectors.toList());
@@ -2969,8 +3002,10 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
         for (ReversePickInventoryMatchDTO reversePickInventoryMatchDTO : reversePickInventoryMatchDTOList) {
             List<InvLotAttPalletTotalDTO> skuPalletTotalList = invLotAttPalletTotalMap.get(reversePickInventoryMatchDTO.getSku());
             if (CollectionUtil.isEmpty(skuPalletTotalList)) continue;
-            List<InvLotAttPalletTotalDTO> palletTotalFilterByOrderNoList = skuPalletTotalList.stream().filter(item -> reversePickInventoryMatchDTO.getOrderNo().equals(item.getOrderNo())).collect(Collectors.toList());
-            List<InvLotAttPalletTotalDTO> invLotAttPalletTotalList = buildInvLotAttPalletTotalList(palletTotalFilterByOrderNoList, reversePickInventoryMatchDTO.getQty(), palletMatchLogList);
+            List<InvLotAttPalletTotalDTO> palletTotalFilterByOrderNoList = skuPalletTotalList.stream().filter(item ->
+                    reversePickInventoryMatchDTO.getOrderNo().equals(item.getOrderNo())).collect(Collectors.toList());
+            List<InvLotAttPalletTotalDTO> invLotAttPalletTotalList = buildInvLotAttPalletTotalList(palletTotalFilterByOrderNoList,
+                    reversePickInventoryMatchDTO.getQty(), palletMatchLogList);
             invLotAttPalletTotalDTOList.addAll(invLotAttPalletTotalList);
         }
         LinkedList<Object> result = ListUtil.toLinkedList(flag, invLotAttPalletTotalDTOList);
@@ -3099,7 +3134,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
      */
     private BigDecimal judgeReversePickType(String sku, String orderNo){
         List<WmsDocOrderDetails> wmsDocOrderDetailsList = wmsDocOrderDetailsService.queryWmsDocOrderDetails(orderNo, sku);
-        BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal orderRequireQty = wmsDocOrderDetailsList.stream().filter(item -> !NumberUtil.equals(BigDecimal.ZERO, item.getQtyAllocated())).map(WmsDocOrderDetails::getQtyOrdered).reduce(BigDecimal.ZERO, BigDecimal::add);
         List<InvLotAtt> invLotAttList = invLotAttService.queryOrderSameSkuInvLotAttList(sku, orderNo);
         if (CollectionUtil.isEmpty(invLotAttList)) return NumberUtil.sub(BigDecimal.ZERO, orderRequireQty);
         List<InvLotLocId> invLotLocIdList = invLotLocIdService.queryInvLotLocIdByLotnum(invLotAttList.stream().map(InvLotAtt::getLotnum).collect(Collectors.toList()));
@@ -3180,7 +3215,7 @@ public class WmsDocOrderHeaderServiceImpl implements IWmsDocOrderHeaderService {
 
         List<WmsDocOrderDetails> wmsDocOrderDetailsByOrderNo = wmsDocOrderDetailsService.queryWmsDocOrderDetails(groupDiskConvertDTO.getWmsOrderNo());
         List<WmsDocOrderDetails> docOrderDetailsList = wmsDocOrderDetailsByOrderNo.stream()
-                .filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS20.getValue()) != 0).collect(Collectors.toList());
+                .filter(item -> CompareUtil.compare(item.getLineStatus(), Constant.ORDER_STS.STS23.getValue()) != 0).collect(Collectors.toList());
         wmsDocOrderHeaderMapper.update(new WmsDocOrderHeader(), Wrappers.<WmsDocOrderHeader>lambdaUpdate()
                 .set(WmsDocOrderHeader::getOrderStatus, CollectionUtil.isNotEmpty(docOrderDetailsList) ? Constant.ORDER_STS.STS22.getValue() : Constant.ORDER_STS.STS23.getValue()).eq(WmsDocOrderHeader::getOrderNo, groupDiskConvertDTO.getWmsOrderNo()));
     }

+ 1 - 3
warewms-ams/src/main/resources/mapper/docOrder/WmsDocOrderDetailsMapper.xml

@@ -387,9 +387,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="updateOrderDetailsSubStockQtyAndSts">
         update wms_doc_order_details
         set
-           qty_allocated = qty_allocated - #{qtyAll}
-          ,qty_allocated_each = qty_allocated_each - #{qtyAll}
-          ,qty_soft_allocated = qty_soft_allocated - #{qtySoft}
+           qty_soft_allocated = qty_soft_allocated - #{qtySoft}
           ,qty_softallocated_each = qty_softallocated_each - #{qtySoft}
           ,line_status = #{status}
         where order_no = #{orderNo} and order_line_no = #{orderLoneNo}