Browse Source

选矿AGV需求后端代码

ChenYang 1 year ago
parent
commit
73a202e930
47 changed files with 1181 additions and 533 deletions
  1. BIN
      doc/~$环境使用手册.docx
  2. 13 0
      ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java
  3. 61 0
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/InvAsnController.java
  4. 1 1
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java
  5. 15 105
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaDocAsnController.java
  6. 7 4
      ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WcsToWmsApiController.java
  7. 10 2
      ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WmsToWcsApiController.java
  8. 1 1
      ruoyi-admin/src/main/resources/application.yml
  9. 49 1
      ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/ProcessLocationTest.java
  10. 53 2
      ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java
  11. 10 0
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
  12. 9 0
      ruoyi-common/src/main/java/com/ruoyi/common/constant/SceneConstants.java
  13. 1 0
      ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
  14. 2 0
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
  15. 34 0
      warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/StatusUpdateService.java
  16. 28 25
      warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/SocketBufferServiceImpl.java
  17. 93 38
      warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/StatusUpdateServiceImpl.java
  18. 2 0
      warewms-ams/src/main/java/com/ruoyi/ams/asn/domain/WmsDocAsnHeader.java
  19. 21 3
      warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnDetailsService.java
  20. 21 0
      warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnHeaderService.java
  21. 27 2
      warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnDetailsServiceImpl.java
  22. 25 0
      warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java
  23. 5 4
      warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java
  24. 13 16
      warewms-ams/src/main/java/com/ruoyi/ams/config/service/LocationAllocationStrategy.java
  25. 3 4
      warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java
  26. 3 1
      warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java
  27. 20 1
      warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java
  28. 46 20
      warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java
  29. 7 3
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/domain/vo/LocationCoordinateVo.java
  30. 4 10
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/domain/form/CallbackTaskFrom.java
  31. 5 5
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/AgvCallProxyService.java
  32. 27 20
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BaseLocationInfoSubService.java
  33. 8 13
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BeltLineClientService.java
  34. 91 0
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BucketWcsToWmsApiService.java
  35. 44 11
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WcsTaskSubService.java
  36. 113 108
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WcsToWmsApiService.java
  37. 66 76
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsDocAsnSubService.java
  38. 12 12
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsDocOrderSubService.java
  39. 2 0
      warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsToWcsApiService.java
  40. 1 1
      warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml
  41. 104 5
      warewms-base/src/main/java/com/ruoyi/base/constant/Constant.java
  42. 1 1
      warewms-base/src/main/java/com/ruoyi/base/domain/vo/BaseLocationLotattVO.java
  43. 9 9
      warewms-base/src/main/java/com/ruoyi/base/mapper/BaseLocationInfoMapper.java
  44. 30 7
      warewms-base/src/main/java/com/ruoyi/base/service/IBaseLocationInfoService.java
  45. 48 12
      warewms-base/src/main/java/com/ruoyi/base/service/impl/BaseLocationInfoServiceImpl.java
  46. 1 1
      warewms-base/src/main/resources/mapper/base/BaseLocationInfoMapper.xml
  47. 35 9
      warewms-hard/src/main/java/com/ruoyi/hard/xuankang/BeltLineClient.java

BIN
doc/~$环境使用手册.docx


+ 13 - 0
ruoyi-admin/src/main/java/com/ruoyi/init/StartService.java

@@ -11,14 +11,19 @@ import com.ruoyi.ams.xuankuang.service.StirringTankClientService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.framework.config.ThreadPoolConfig;
 import com.ruoyi.hard.xuankang.StirringTankClient;
 import lombok.extern.slf4j.Slf4j;
+import org.quartz.spi.ThreadPool;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 @Slf4j
 @Component
@@ -41,6 +46,10 @@ public class StartService implements CommandLineRunner {
     @Autowired
     private StirringTankClientService stirringTankClientService;
 
+    @Autowired
+    @Qualifier("scheduledExecutorService")
+    private ScheduledExecutorService scheduledExecutorService;
+
     @Override
     public void run(String... args) throws Exception {
         //自动下发任务
@@ -48,6 +57,10 @@ public class StartService implements CommandLineRunner {
             Thread thread = new Thread(new AutoTaskThread(businessService));
             thread.start();
         }
+        //↑↑↑↑↑↑↑↑↑shit mountain,bad smell!  ↓↓↓↓↓↓↓↓↓shit hill,not good smell!
+        /*scheduledExecutorService.scheduleAtFixedRate(
+                ()-> businessService.autoSend(), 1, 1, TimeUnit.SECONDS
+        );*/
 
         //ndc下发
         if (initTaskConfig.getAciService()) {

+ 61 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/InvAsnController.java

@@ -0,0 +1,61 @@
+package com.ruoyi.web.controller.warewms.ams;
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.ruoyi.ams.xuankuang.domain.form.EmptyPalletLocForm;
+import com.ruoyi.ams.xuankuang.service.BucketWcsToWmsApiService;
+import com.ruoyi.ams.xuankuang.service.WcsToWmsApiService;
+import com.ruoyi.base.domain.BaseLocationInfo;
+import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.common.core.domain.AjaxResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author JWK
+ * @version 1.0
+ * @date 2022/11/14 14:52
+ */
+@Api("入库场景下的其他逻辑")
+@RestController
+@RequestMapping("/inv/asn")
+public class InvAsnController {
+
+
+    @Autowired
+    private IBaseLocationInfoService iBaseLocationInfoService;
+
+    @Autowired
+    private WcsToWmsApiService wcsToWmsApiService;
+
+    @Qualifier("bucketWcsToWmsApiService")
+    @Autowired
+    private BucketWcsToWmsApiService bucketWcsToWmsApiService;
+
+    @ApiOperation("桶装入库:获取当前场景下的库位")
+    @GetMapping(value = "/getBaseLocationInfoList")
+    public AjaxResult getBaseLocationInfoList(Long zoneId, String locationSceneCode) {
+        List<BaseLocationInfo> baseLocationInfoList = iBaseLocationInfoService.getBaseLocationInfoList(zoneId);
+        List<Long> bucketLocationIdList = wcsToWmsApiService.getBucketLocationIdList(locationSceneCode);
+        List<BaseLocationInfo> locationInfoList = baseLocationInfoList.stream()
+                .filter(item -> CollectionUtil.contains(bucketLocationIdList, item.getId())).collect(Collectors.toList());
+        //获取库位的配置
+        return AjaxResult.success(locationInfoList);
+    }
+
+
+
+    @ApiOperation("桶装入库:空托出库")
+    @GetMapping(value = "/emptyPalletLoc")
+    public AjaxResult emptyPalletLoc(EmptyPalletLocForm emptyPalletLocForm) {
+        return bucketWcsToWmsApiService.emptyPalletLoc(emptyPalletLocForm);
+    }
+
+}

+ 1 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/WcsTaskController.java

@@ -175,7 +175,7 @@ public class WcsTaskController extends BaseController {
         wcsTask.setLocationFrom("998");
         wcsTask.setLocationTo("997");
         wcsTask.setDeviceName(toChargeForm.getAgvNo().toString());
-        wcsTask.setState(Constant.TASK_STS.TASK9.getValue().longValue());
+        wcsTask.setState(Constant.TASK_STS.TASK_WAIT.getValue().longValue());
         wcsTask.setPriority(1l);
         wcsTask.setTaskType(Constant.TASK_BUSINESS_TYPE.TASK_POWER.getValue());
         wcsTask.setAgvNo(toChargeForm.getAgvNo().toString());//车号

+ 15 - 105
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaDocAsnController.java

@@ -1,5 +1,8 @@
 package com.ruoyi.web.controller.warewms.pda;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
@@ -7,132 +10,39 @@ import com.ruoyi.ams.business.IBusinessService;
 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.xuankuang.service.WcsToWmsApiService;
 import com.ruoyi.base.constant.Constant;
+import com.ruoyi.base.domain.BaseLocationInfo;
+import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.common.constant.SceneConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.Data;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.ListOperations;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author JWK
  * @version 1.0
  * @date 2022/11/14 14:52
  */
-@Api("入库")
+@Api("PDA入库接口-弃用")
 @RestController
 @RequestMapping("/pda/asn")
 public class PdaDocAsnController {
 
 
-    @Autowired
-    private IBusinessService businessService;
-    @Autowired
-    private IWmsDocAsnHeaderService wmsDocAsnHeaderService;
-
-//    @Transactional
-//    @ApiOperation("入库位->接驳位任务下发")
-//    @PostMapping("inToTran")
-//    public AjaxResult inToTran(@RequestBody DocAsnHeader docAsnHeader) {
-//        if (StringUtils.isEmpty(docAsnHeader.getLocationFrom())) {
-//            return AjaxResult.error("请选择起始点位!");
-//        }
-//        // 创建入库单
-//        WmsDocAsnHeader header = new WmsDocAsnHeader();
-//        header.setAsnStatus("99");
-//        header.setAsnType("PR");
-//        header.setCreateTime(new Date());
-//        header.setCreateBy("pda");
-//        header.setCustomerId(Constant.CUSTOMER_ID);
-//        AjaxResult ajaxResult = wmsDocAsnHeaderService.insertWmsDocAsnHeader(header);
-//        String asnno = (String) ajaxResult.getData();
-//        List<DocAsnDetails> docAsnDetails = docAsnHeader.getDocAsnDetails();
-//        for (DocAsnDetails docAsnDetail : docAsnDetails) {
-//            WmsDocAsnDetails details = new WmsDocAsnDetails();
-//            details.setAsnNo(header.getAsnNo());
-//            details.setSku(docAsnDetail.getSku());
-//            details.setExpectedQty(new BigDecimal(docAsnDetail.getQty()));
-//            details.setExpectedQtyEach(new BigDecimal(docAsnDetail.getQty()));
-//            details.setReceivedQty(BigDecimal.ZERO);
-//            details.setReceivedQtyEach(BigDecimal.ZERO);
-//            details.setLineStatus("99");
-//            details.setCreateBy("pda");
-//            details.setCreateTime(new Date());
-//            details.setLotatt01(docAsnDetail.getBatchNo());
-//            details.setLotatt02(docAsnDetail.getWeight());
-//            details.setLotatt05("DJ");
-//            details.setLotatt07(docAsnDetail.getBoxNo() != null ? docAsnDetail.getBoxNo() : "");
-//            wmsDocAsnHeaderService.insertWmsDocAsnDetails(details);
-//        }
-//        // 下发任务
-//        AgvCallDTO agvCallDTO = new AgvCallDTO();
-//        agvCallDTO.setWarehouseId(Constant.WAREHOUSE_ID);
-//        agvCallDTO.setLocationFrom(docAsnHeader.getLocationFrom());
-//        agvCallDTO.setLocationTo(docAsnHeader.getLocationTo());
-//        List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
-//        docAsnDetails.stream().forEach(v -> {
-//            AgvCallItemDTO agvCallItemDTO = new AgvCallItemDTO();
-//            agvCallItemDTO.setSku(v.getSku());
-//            agvCallItemDTO.setQty(Double.valueOf(v.getQty()));
-//            agvCallItemDTO.setWeight(Double.valueOf(v.getWeight()));
-//            LotattDTO lotattDTO = new LotattDTO();
-//            lotattDTO.setLotatt01(v.getBatchNo());
-//            lotattDTO.setLotatt02(v.getWeight());
-//            lotattDTO.setLotatt05("DJ");
-//            lotattDTO.setLotatt07(v.getBoxNo() != null ? v.getBoxNo() : "");
-//            lotattDTO.setLotatt08(asnno);
-//            agvCallItemDTO.setLotattDTO(lotattDTO);
-//            agvCallItemDTOList.add(agvCallItemDTO);
-//        });
-//        agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
-//        return businessService.agvCall(Constant.IN_TRAN_FLOW_ID, agvCallDTO);
-//    }
-
-    @Data
-    public static class DocAsnHeader {
-        private String locationFrom;
-        private String locationTo;
-        private List<DocAsnDetails> docAsnDetails;
-    }
-
-    @Data
-    public static class DocAsnDetails {
-        /**
-         * 批号
-         */
-        private String batchNo;
-        /**
-         * 产品代码
-         */
-        private String sku;
-        /**
-         * 如果下料时,二维码中有的话,就是每一周转箱塞子的数量
-         */
-        private String qty;
-
-        /**
-         * 单个周转箱的重量
-         */
-        private String weight;
-
-        /**
-         * 周转箱号
-         */
-        private String boxNo;
-
-
-    }
-
-
 }

+ 7 - 4
ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WcsToWmsApiController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.spring.web.json.Json;
 
 import java.util.Locale;
+import java.util.Stack;
 
 /**
  * WCS调WMS接口
@@ -77,7 +78,7 @@ public class WcsToWmsApiController {
     @ApiOperation("空托仓位请求")
     @PostMapping("/emptyPalletLocRequest")
     public AjaxResult emptyPalletLocRequest(@RequestBody EmptyPalletLocForm emptyPalletLocForm) {
-        return wcsToWmsApiService.EmptyPalletLoc(emptyPalletLocForm);
+        return wcsToWmsApiService.emptyPalletLoc(emptyPalletLocForm);
     }
 
     /**
@@ -95,13 +96,13 @@ public class WcsToWmsApiController {
     /**
      * WCS回调AGV安全交握申请结果
      *
-     * @param callbackTaskFrom
+     * @param callbackForm
      * @return
      */
     @ApiOperation("WCS安全交握AGV")
     @PostMapping("/callback/task")
-    public AjaxResult callbackTask(@RequestBody CallbackTaskFrom callbackTaskFrom) {
-        return wcsToWmsApiService.secureHandover(callbackTaskFrom);
+    public AjaxResult callbackTask(@RequestBody CallbackTaskForm callbackForm) {
+        return AjaxResult.success(wcsToWmsApiService.callbackNotice(callbackForm));
     }
 
     /**
@@ -116,6 +117,8 @@ public class WcsToWmsApiController {
         return wcsToWmsApiService.outboundRequest(outboundForm);
     }
 
+    //移库 越库 入库出库
+
     /**
      * 当入库时因为物料袋破碎等原因,导致入库袋数减少,更新数据
      *

+ 10 - 2
ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WmsToWcsApiController.java

@@ -3,12 +3,18 @@ package com.ruoyi.xuankuang.controller;
 
 import com.ruoyi.ams.xuankuang.service.WmsDocAsnSubService;
 import com.ruoyi.ams.xuankuang.service.WmsDocOrderSubService;
+import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.core.domain.AjaxResult;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import java.math.BigDecimal;
+import java.util.LinkedList;
+import java.util.Stack;
+
 @RestController
 @RequestMapping("/Wms/Wcs")
 public class WmsToWcsApiController {
@@ -31,11 +37,13 @@ public class WmsToWcsApiController {
         return wmsDocOrderSubService.initOrderDetails(orderNo);
     }
 
+
     //agv入库任务下发
     @ApiOperation("入库任务下发")
     @PostMapping(value = "/agvInTask")
-    public AjaxResult agvInTask(String palletNo, Double qty) {
-        return wmsDocAsnSubService.agvInTask(palletNo, qty);
+    public AjaxResult agvInTask(String palletNo, String materialType, Long sourceLocationId, Double qty) {
+        //qty我也不知道这个屌毛为嘛一会用double一会用BigDecimal
+        return AjaxResult.success(wmsDocAsnSubService.agvInTask(palletNo, materialType, sourceLocationId , new BigDecimal(qty)));
     }
 
     //agv回调wcs卸货完成

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -81,7 +81,7 @@ mybatis-plus:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
   configuration-properties:
     prefix:
-    blobType: BLOB
+    blobType: blob
     boolValue: TRUE
 
 

+ 49 - 1
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/ProcessLocationTest.java

@@ -5,6 +5,7 @@ import cn.hutool.core.comparator.CompareUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
 import com.ruoyi.RuoYiApplication;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.service.IInvLotAttService;
@@ -16,9 +17,9 @@ import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.poi.ExcelUtil;
+import io.netty.util.internal.SocketUtils;
 import io.netty.util.internal.StringUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.compress.utils.Lists;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,8 @@ import org.springframework.util.Assert;
 
 import java.io.File;
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -176,6 +179,51 @@ public class ProcessLocationTest {
 //        System.out.println(handleLocationNo("  -02-08"));
 //        System.out.println(handleLocationNo("Out-02-cache"));
 //        System.out.println(handleLocationNo("STAGE01"));
+
+
+
+        LinkedList<String> linkedList = Lists.newLinkedList();
+        ArrayList<String> arrayList = Lists.newArrayList();
+        linkedList.add("10");
+        linkedList.add("20");
+        linkedList.add("30");
+        linkedList.add("40");
+        linkedList.add("50");
+        linkedList.add("60");
+        linkedList.add("70");
+        linkedList.add("80");
+        System.out.println("queue.element():"+linkedList.element()); //读取第一个
+        System.out.println("queue.remove():"+linkedList.remove()); //删掉第一个
+
+        System.out.println("queue:"+linkedList);
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue.poll():" + linkedList.poll()); //读取且拿取==出队列
+        System.out.println("queue:"+linkedList);
+
+        linkedList.clear();
+
+        linkedList.push("10");
+        linkedList.push("20");
+        linkedList.push("30");
+        linkedList.push("40");
+        linkedList.push("50");
+        linkedList.push("60");
+        linkedList.push("70");
+        linkedList.push("80");
+
+        System.out.println("stack.element():"+linkedList.element()); //读取第一个
+        System.out.println("stack.remove():"+linkedList.remove()); //删掉第一个
+
+        System.out.println("stack:"+linkedList);
+        System.out.println("stack.peek():"+linkedList.peek()); //拿取栈顶==出栈
+        System.out.println("stack:"+linkedList);
     }
 
 

+ 53 - 2
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -34,7 +34,7 @@ import com.ruoyi.ams.xuankuang.service.WcsTaskSubService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.BaseWarehouse;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.mapper.BaseSkuMapper;
 import com.ruoyi.base.service.IBaseIdsequenceService;
@@ -43,8 +43,10 @@ import com.ruoyi.base.service.IBaseWarehouseService;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.omg.CORBA.PRIVATE_MEMBER;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.math.BigDecimal;
@@ -150,7 +152,7 @@ public class WarehouseTest {
         LotattDTO lotattDTO = new LotattDTO();
         List<Long> zoneList = new ArrayList<>();
         zoneList.add(2L);
-        List<BaseLocationLotattVO> baseLocationLotattVOS = baseLocationInfoMapper.selectSortedLocationLotattListByZoneIdList(zoneList, 1L, lotattDTO.getAttr());
+        List<BaseLocationLotattDTO> baseLocationLotattVOS = baseLocationInfoMapper.selectSortedLocationLotattListByZoneIdList(zoneList, 1L, lotattDTO.getAttr());
         System.out.println(JSON.toJSONString(baseLocationLotattVOS));
     }
 
@@ -327,4 +329,53 @@ public class WarehouseTest {
         wcsTaskSubService.callBack("1690210547924", 2, null);
     }
 
+
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+
+    @Test
+    public void stackTest(){
+        /*redisTemplate.opsForList().leftPush("1", "Pallet01");
+        redisTemplate.opsForList().leftPush("1", "Pallet02");
+        redisTemplate.opsForList().leftPush("1", "Pallet03");
+        redisTemplate.opsForList().leftPush("1", "Pallet04");
+        redisTemplate.opsForList().leftPush("1", "Pallet05");
+        *//*redisTemplate.opsForList().leftPop("1");
+        redisTemplate.opsForList().leftPop("1");
+        redisTemplate.opsForList().leftPop("1");
+        redisTemplate.opsForList().leftPop("1");*//*
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        System.out.println(redisTemplate.opsForList().leftPop("1"));
+        */
+
+        redisTemplate.boundListOps("2").leftPush("Pallet01");
+        redisTemplate.boundListOps("2").leftPush("Pallet02");
+        redisTemplate.boundListOps("2").leftPush("Pallet03");
+        redisTemplate.boundListOps("2").leftPush("Pallet04");
+        redisTemplate.boundListOps("2").leftPush("Pallet05");
+        redisTemplate.boundListOps("2").leftPop();
+        redisTemplate.boundListOps("2").leftPop();
+        redisTemplate.boundListOps("2").leftPop();
+        redisTemplate.boundListOps("2").leftPop();
+        redisTemplate.boundListOps("2").leftPop();
+        System.out.println(redisTemplate.boundListOps("2").range(0, 10));
+
+    }
+
+
+
+
+
 }

+ 10 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -219,4 +219,14 @@ public class Constants
      * 默认的货主代码
      */
     public static final String DEFAULT_CUSTOMER_ID = "default";
+
+    /**
+     * 下料缓存区
+     */
+    public static final Long EMPTY_PALLET_INV = 4L;
+
+    /**
+     * 空托盘库位排序的子场景
+     */
+    public static final String EMPTY_PALLET_INV_SORT = "emptyPalletInvSort";
 }

+ 9 - 0
ruoyi-common/src/main/java/com/ruoyi/common/constant/SceneConstants.java

@@ -0,0 +1,9 @@
+package com.ruoyi.common.constant;
+
+public interface SceneConstants {
+
+    /**
+     * 桶装物料的业务场景配置
+     */
+    String STORAGE_BUCKET_SCENE = "STORAGE_BUCKET_SCENE_CONFIG";
+}

+ 1 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java

@@ -271,4 +271,5 @@ public class RedisCache {
     public Collection<String> keys(final String pattern) {
         return redisTemplate.keys(pattern);
     }
+
 }

+ 2 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java

@@ -34,6 +34,8 @@ public class ResourcesConfig implements WebMvcConfigurer
         /** swagger配置 */
         registry.addResourceHandler("/swagger-ui/**")
                 .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
+        registry.addResourceHandler("/webjars/**")
+                .addResourceLocations("classpath:/META-INF/resources/webjars/");
     }
 
     /**

+ 34 - 0
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/StatusUpdateService.java

@@ -1,5 +1,7 @@
 package com.ruoyi.ams.agv.ndc.service;
 
+import com.ruoyi.ams.agv.ndc.domain.AmsNdcEvent;
+
 /**
  * Created by IntelliJ IDEA.
  * User: andy.qu
@@ -33,6 +35,8 @@ public interface StatusUpdateService {
      */
     void feedbackTS(Integer doorNo);
 
+
+
     /**
      * 开门
      *
@@ -40,10 +44,40 @@ public interface StatusUpdateService {
      */
     void openDoor(Integer doorNo);
 
+
+
+
     /**
      * 关门
      */
     void closeDoor(Integer doorNo);
 
 
+    /**
+     * @Description 开门
+     * @Author chenyang
+     */
+    void openBeltGate(AmsNdcEvent event);
+
+
+    /**
+     * @Description 关门
+     * @Author chenyang
+     */
+    void closeBeltGate(AmsNdcEvent event);
+
+
+    /**
+     * ts回调门已打开
+     * @param event
+     */
+    public void feedbackTS(AmsNdcEvent event);
+
+
+    /**
+     * wcs通知
+     * @param taskNo
+     * @param eventId
+     */
+    void wcsTaskNotice(String taskNo, Integer eventId);
 }

+ 28 - 25
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/SocketBufferServiceImpl.java

@@ -1,12 +1,15 @@
 package com.ruoyi.ams.agv.ndc.service.impl;
 
+import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.google.common.collect.Lists;
 import com.ruoyi.ams.agv.ndc.common.Aci;
 import com.ruoyi.ams.agv.ndc.common.ByteUtil;
 import com.ruoyi.ams.agv.ndc.domain.AmsNdcEvent;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.entity.Order;
 import com.ruoyi.ams.agv.ndc.service.*;
+import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.core.redis.RedisCache;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -22,9 +25,10 @@ import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import static com.ruoyi.ams.agv.ndc.service.ChargerButtService.*;
-import static com.ruoyi.ams.agv.ndc.service.impl.StatusUpdateServiceImpl.AGV_ACTION.*;
 import static com.ruoyi.ams.agv.ndc.service.ChargerButtProxy.CHARGER_BUTT_REQUEST.*;
+import static com.ruoyi.ams.agv.ndc.service.ChargerButtService.*;
+import static com.ruoyi.ams.agv.ndc.service.impl.StatusUpdateServiceImpl.AGV_ACTION.PICKUP;
+import static com.ruoyi.ams.agv.ndc.service.impl.StatusUpdateServiceImpl.AGV_ACTION.UNLOAD;
 
 
 /**
@@ -62,7 +66,7 @@ public class SocketBufferServiceImpl implements SocketBufferService {
     public List<Order> bufferSeparator(byte[] buffer) {
         List<Order> orderList = new ArrayList<>();
         String bufferStr = ByteUtil.byteArray2HexString(buffer);
-        //通过固定的头部 87CD0008 将多条消息拆分开
+        // 87CD0008000187CD00080001 -> ["","0001","0002"]
         String[] signalList = bufferStr.split("87CD0008");
         for (String signalStr : signalList) {
 
@@ -127,31 +131,31 @@ public class SocketBufferServiceImpl implements SocketBufferService {
     @Override
     public void handleMsgEvent(byte[] parameters) {
         int icarNo = ByteUtil.getShort(parameters, 40);
-        AmsNdcEvent event = new AmsNdcEvent();
-        event.setType(parameters[13] & 0xff);
-        event.setEcode((int) ByteUtil.getShort(parameters, 16));
-        AmsNdcEvent eventBean = amsNdcEventService.selectAmsNdcEventByModel(event);
+        AmsNdcEvent amsNdcEvent = new AmsNdcEvent();
+        amsNdcEvent.setType(parameters[13] & 0xff);
+        amsNdcEvent.setEcode((int) ByteUtil.getShort(parameters, 16));
+        AmsNdcEvent eventBean = amsNdcEventService.selectAmsNdcEventByModel(amsNdcEvent);
         if (eventBean != null) {
 
-            event = eventBean;
+            final AmsNdcEvent event = eventBean;
             event.setLocationindex(ByteUtil.getInt(parameters, 26));
             event.setLp1("" + ByteUtil.getInt(parameters, 34));
             event.setLp2("" + ByteUtil.getInt(parameters, 38));
             event.setLp3("" + ByteUtil.getInt(parameters, 42));
             event.setLp4("" + ByteUtil.getInt(parameters, 46));
             int eventId = event.getId();
-            AmsTask taskBean = new AmsTask();
+            AmsTask amsTask = new AmsTask();
 
 //            log.info("----event:" + eventId);
             switch (eventId) {
                 case 85://user event ts cancel                  任务取消
 
                     log.info("任务回调执行取消:" + JSON.toJSONString(event));
-                    taskBean.setAciIndex(Integer.parseInt(event.getLp1()));
-                    taskBean = amsTaskService.selectAmsTaskByModel(taskBean);
+                    amsTask.setAciIndex(Integer.parseInt(event.getLp1()));
+                    amsTask = amsTaskService.selectAmsTaskByModel(amsTask);
 
                     AmsTask taskBeanUpdate = new AmsTask();
-                    taskBeanUpdate.setId(taskBean.getId());
+                    taskBeanUpdate.setId(amsTask.getId());
                     taskBeanUpdate.setEvent(eventId);
                     taskBeanUpdate.setServerAck(0);
                     taskBeanUpdate.setAciAccept(1);
@@ -160,7 +164,7 @@ public class SocketBufferServiceImpl implements SocketBufferService {
                     taskBeanUpdate.setIsDelete(null);
                     amsTaskService.updateAmsTask(taskBeanUpdate);
                     //任务状态回调
-                    long taskId_85 = taskBean.getId().longValue();
+                    long taskId_85 = amsTask.getId().longValue();
                     executorService.execute(() -> {
                         statusUpdateService.updateStatus(taskId_85, icarNo);
                     });
@@ -177,20 +181,22 @@ public class SocketBufferServiceImpl implements SocketBufferService {
                 case 113://user event Fetch Empty
                     log.info("----event:" + eventId + ":" + JSON.toJSONString(event));
 
-                    taskBean.setAciIndex(Integer.parseInt(event.getLp1()));
-                    taskBean = amsTaskService.selectAmsTaskByModel(taskBean);
-                    if (taskBean != null) {
+                    amsTask.setAciIndex(Integer.parseInt(event.getLp1()));
+                    amsTask = amsTaskService.selectAmsTaskByModel(amsTask);
+                    if (amsTask != null) {
                         AmsTask taskBeanUpdate01 = new AmsTask();
-                        taskBeanUpdate01.setId(taskBean.getId());
+                        taskBeanUpdate01.setId(amsTask.getId());
                         taskBeanUpdate01.setEvent(eventId);
                         taskBeanUpdate01.setServerAck(0);
                         taskBeanUpdate01.setSystemStatus(null);
                         taskBeanUpdate01.setIsDelete(null);
                         amsTaskService.updateAmsTask(taskBeanUpdate01);
 
-                        long taskId = taskBean.getId().longValue();
+                        long taskId = amsTask.getId();
                         executorService.execute(() -> {
                             statusUpdateService.updateStatus(taskId, icarNo);
+                            //statusUpdateService.wcsTaskNotice(taskNo, eventId);
+
                         });
                     }
                     break;
@@ -263,17 +269,14 @@ public class SocketBufferServiceImpl implements SocketBufferService {
                     }
                     break;
                 case 126: //600 中间卷帘门请求开启 定时请求
-                    log.info("快速门-请求开启!" + "-" + JSON.toJSONString(event));
-                    String lp3_126 = event.getLp3();
+                    log.info("the open request of belt gate is begining, the event info is: {}", JSONUtil.toJsonStr(event));
                     executorService.execute(() -> {
-                        statusUpdateService.openDoor(Integer.valueOf(lp3_126));
+                        statusUpdateService.openBeltGate(event);
                     });
-                    break;
                 case 127: //601 中间卷帘门请求关闭 只请求一次
-                    log.info("快速门-请求关闭!" + "-" + JSON.toJSONString(event));
-                    String lp3_127 = event.getLp3();
+                    log.info("the close request of belt gate is begining, the event info is: {}", JSONUtil.toJsonStr(event));
                     executorService.execute(() -> {
-                        statusUpdateService.closeDoor(Integer.valueOf(lp3_127));
+                        statusUpdateService.closeBeltGate(event);
                     });
                     break;
                 case 134:

+ 93 - 38
warewms-ams/src/main/java/com/ruoyi/ams/agv/ndc/service/impl/StatusUpdateServiceImpl.java

@@ -1,21 +1,27 @@
 package com.ruoyi.ams.agv.ndc.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.ruoyi.ams.agv.ndc.domain.AmsNdcEvent;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.entity.CallbackResult;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.agv.ndc.service.StatusUpdateService;
 import com.ruoyi.ams.business.BusinessServiceImpl;
-import com.ruoyi.ams.business.IBusinessService;
-import com.ruoyi.ams.task.form.AddTaskForm;
+import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.xuankuang.service.BeltLineClientService;
+import com.ruoyi.ams.xuankuang.service.WmsDocAsnSubService;
 import com.ruoyi.base.constant.Constant;
+import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
 import com.ruoyi.hard.demo.AutoDoorClient;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Slf4j
 @Component
@@ -26,10 +32,27 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
     @Autowired
     private IWcsTaskService wcsTaskService;
     @Autowired
-    private IBusinessService businessService;
-    @Autowired
     private AutoDoorClient autoDoorClient;
 
+    @Autowired
+    private BeltLineClientService beltLineClientService;
+
+    @Autowired
+    private WmsDocAsnSubService wmsDocAsnSubService;
+
+
+    private final static Map<Integer, Integer> eventIdToStatus =  new HashMap<Integer, Integer>(){
+        {
+            put(86, 1);
+            put(90, 2);
+            put(91, 4);
+            put(92, 6);
+            put(85, 7);
+            put(113, 8);
+            put(114, 2);
+        }
+    };
+
     public enum AGV_ACTION {
         /***
          * 取货
@@ -51,9 +74,26 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
     }
 
 
+
+    @Override
+    public void wcsTaskNotice(String taskNo, Integer eventId) {
+        if(ObjectUtil.equals(eventId, 92)){
+            wmsDocAsnSubService.wmsAgvCallbackIntask(taskNo);
+            return;
+        }
+        if(ObjectUtil.equals(eventId, 91)) {
+            WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
+            if(ObjectUtil.isNull(wcsTask) || StringUtils.isBlank(wcsTask.getExt3())){
+                log.info("task is not found, taskNo is {}, caused by : {}");
+                return;
+            }
+            wmsDocAsnSubService.wmsAgvCallbackOuttask(wcsTask.getExt3());
+        }
+    }
+
     @Override
-    public void updateStatus(Long id, Integer carNo) {
-        AmsTask amsTask = amsTaskService.selectAmsTaskById(id);
+    public void updateStatus(Long taskId, Integer carNo) {
+        AmsTask amsTask = amsTaskService.selectAmsTaskById(taskId);
         if (amsTask != null) {
             log.info("任务回调-------------------------》" + amsTask.getTaskNo());
             if (amsTask.getAciIndex() == null) {
@@ -63,37 +103,7 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
             result.setCarNo(carNo);
             result.setTaskNo(amsTask.getTaskNo());
             //判断状态
-            if (false) {
-//            if (null != amsTask.getSystemStatus() && amsTask.getSystemStatus() == 3) {
-//                result.setState(2);
-//            } else if (null != amsTask.getSystemStatus() && amsTask.getSystemStatus() == 4) {
-//                result.setState(7);
-            } else {
-                switch (amsTask.getEvent().intValue()) {
-                    case 86:
-                        result.setState(1);
-                        break;
-                    case 90:
-                        result.setState(2);
-                        break;
-                    case 91:
-                        result.setState(4);
-                        break;
-                    case 92:
-                        result.setState(6);
-                        break;
-                    case 85:
-                        result.setState(7);
-                        break;
-                    case 113:
-                        result.setState(8);
-                        break;
-                    case 114:
-                        result.setState(2);
-                        break;
-                }
-            }
-
+            result.setState(eventIdToStatus.get(amsTask.getEvent()));;
             wcsTaskService.callBack(result.getTaskNo(), result.getState(), result.getCarNo());
 
             amsTask.setSystemStatus(result.getState());
@@ -165,6 +175,7 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
         amsTaskService.insertAmsTask(addTaskForm);
     }
 
+
     @Override
     public void openDoor(Integer doorNo) {
         AutoDoorClient.AUTO_DOOR_NO doorNum = null;
@@ -192,7 +203,51 @@ public class StatusUpdateServiceImpl implements StatusUpdateService {
         if (isClose) {
             log.info("关门信号发送成功!门号:" + doorNo);
             // 不需要反馈
-//            feedbackTS(doorNo);
+            feedbackTS(doorNo);
         }
     }
+
+    @Override
+    public void openBeltGate(AmsNdcEvent event) {
+        if(beltLineClientService.openTheConveyorLine()) feedbackTS(event);
+    }
+
+    @Override
+    public void closeBeltGate(AmsNdcEvent event) {
+        beltLineClientService.closeTheConveyorLine();
+    }
+
+
+
+
+
+    @Override
+    public void feedbackTS(AmsNdcEvent event) {
+        AmsTask addTaskForm = new AmsTask();
+        addTaskForm.setTaskNo(SnowflakeIdWorker.generateId().toString());
+        //吴老板说这个方法有bug
+        addTaskForm.setIkey((long) BusinessServiceImpl.geniKey(addTaskForm.getTaskNo()));
+        addTaskForm.setBusinessType(Constant.TASK_BUSINESS_TYPE.TASK_164.getValue());
+        addTaskForm.setStFrom(998);
+        addTaskForm.setStTo(999);
+        addTaskForm.setPriority(1);
+        // 固定写法
+        //TODO 这里传什么是个问题
+        addTaskForm.setExt2(event.getLp1());
+        addTaskForm.setExt3("0000");
+
+        // 如果ams_task已经有此任务的待接收消息,则不生成新的消息
+        AmsTask amsTaskQuery = new AmsTask();
+        amsTaskQuery.setAciAccept(0);
+        amsTaskQuery.setIsDelete(0);
+        amsTaskQuery.setBusinessType(Constant.TASK_BUSINESS_TYPE.TASK_164.getValue());
+        amsTaskQuery.setExt2(addTaskForm.getExt2());
+        List<AmsTask> undoneList = amsTaskService.selectAmsTaskList(amsTaskQuery);
+        if (undoneList.size() > 0) {
+            return;
+        }
+        amsTaskService.insertAmsTask(addTaskForm);
+    }
+
+
 }

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/domain/WmsDocAsnHeader.java

@@ -98,6 +98,8 @@ public class WmsDocAsnHeader extends BaseEntity
     /** 是否有效(N删除Y有效) */
     private String activeFlag;
 
+
+
     private String ediSendFlag;
 
     /** $column.columnComment */

+ 21 - 3
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnDetailsService.java

@@ -1,11 +1,10 @@
 package com.ruoyi.ams.asn.service;
 
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
-import com.ruoyi.ams.asn.form.DelDocAsnDetailsForm;
-import com.ruoyi.ams.asn.form.StockForm;
 
 /**
  * 入库单明细Service接口
@@ -81,8 +80,27 @@ public interface IWmsDocAsnDetailsService {
 
     /**
      * 批量删除
-     * @param arr
      * @return
      */
     int deleteWmsDocAsnDetailsByAsnNoLineNos(List<HashMap<String,Object>> list);
+
+
+    /**
+     * 创建入库单
+     * @param asnNo 入库单号
+     * @param asnLineNo 当前行号
+     * @param sku 入库物料号
+     * @param quantity 入库物料号对应的数量
+     * @return
+     */
+    WmsDocAsnDetails createAsnDetail(String asnNo, Long asnLineNo, String sku, BigDecimal quantity);
+
+    /**
+     * 创建入库单
+     * @param asnNo 入库单号
+     * @param sku 入库物料号
+     * @param quantity 入库物料号对应的数量
+     * @return
+     */
+    WmsDocAsnDetails createAsnDetail(String asnNo, String sku, BigDecimal quantity);
 }

+ 21 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/IWmsDocAsnHeaderService.java

@@ -154,4 +154,25 @@ public interface IWmsDocAsnHeaderService {
      * @return
      */
     CodeSkuRelationshipVO searchSn(SnCheckForm snCheckForm);
+
+    /**
+     * 创建入库单头
+     * @param asnNo 入库单号
+     * @param asnType 入库类型
+     * @param asnStatus 入库状态
+     * @param goalLineNo 目标产线号
+     * @return
+     */
+    WmsDocAsnHeader createAsnHeader(String asnNo, String asnType, String asnStatus, String goalLineNo) ;
+
+
+
+    /**
+     * 创建入库单头
+     * @param asnType 入库类型
+     * @param asnStatus 入库状态
+     * @param goalLineNo 目标产线号
+     * @return
+     */
+    WmsDocAsnHeader createAsnHeader(String asnType, String asnStatus, String goalLineNo);
 }

+ 27 - 2
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnDetailsServiceImpl.java

@@ -1,10 +1,12 @@
 package com.ruoyi.ams.asn.service.impl;
 
+import java.math.BigDecimal;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
-import com.ruoyi.ams.asn.form.DelDocAsnDetailsForm;
-import com.ruoyi.ams.asn.form.StockForm;
+import cn.hutool.core.date.DateUtil;
+import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.exception.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -134,4 +136,27 @@ public class WmsDocAsnDetailsServiceImpl implements IWmsDocAsnDetailsService {
         }
         return 1;
     }
+
+    @Override
+    public WmsDocAsnDetails createAsnDetail(String asnNo, Long asnLineNo, String sku, BigDecimal quantity) {
+        WmsDocAsnDetails wmsDocAsnDetails = new WmsDocAsnDetails();
+        wmsDocAsnDetails.setAsnNo(asnNo);
+        wmsDocAsnDetails.setAsnLineNo(asnLineNo); //行号
+        wmsDocAsnDetails.setLineStatus(Constant.ASN_STS.STS00.getValue());
+        wmsDocAsnDetails.setSku(sku);
+        wmsDocAsnDetails.setExpectedQty(quantity);
+        wmsDocAsnDetails.setExpectedQtyEach(quantity);
+        wmsDocAsnDetails.setReceivedQty(BigDecimal.ZERO);
+        wmsDocAsnDetails.setReceivedQtyEach(BigDecimal.ZERO);
+        wmsDocAsnDetails.setCreateTime(DateUtil.date());
+        wmsDocAsnDetails.setCreateBy(Constant.TERMINAL_CREATOR.PDA.getDesc());
+        wmsDocAsnDetailsMapper.insertWmsDocAsnDetails(wmsDocAsnDetails);
+        return wmsDocAsnDetails;
+    }
+
+
+    @Override
+    public WmsDocAsnDetails createAsnDetail(String asnNo, String sku, BigDecimal quantity){
+        return createAsnDetail(asnNo, 1L, sku, quantity);
+    }
 }

+ 25 - 0
warewms-ams/src/main/java/com/ruoyi/ams/asn/service/impl/WmsDocAsnHeaderServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.ams.asn.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.form.PaForm;
@@ -37,6 +38,7 @@ import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.service.ICodeSkuRelationshipService;
 import com.ruoyi.base.utils.IdSequenceUtils;
+import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.ServiceException;
@@ -600,4 +602,27 @@ public class WmsDocAsnHeaderServiceImpl implements IWmsDocAsnHeaderService {
         }
         return codeSkuRelationshipVO;
     }
+
+    @Override
+    public WmsDocAsnHeader createAsnHeader(String asnNo, String asnType, String asnStatus, String goalLineNo) {
+        WmsDocAsnHeader wmsDocAsnHeader = new WmsDocAsnHeader();
+        String finalAsnNo = StringUtils.isNotBlank(asnNo)
+                ? asnNo : idSequenceUtils.generateId(Constant.ID_TYPE.ASNNO.getDesc());
+        wmsDocAsnHeader.setAsnNo(finalAsnNo);
+        wmsDocAsnHeader.setEdiSendFlag(Constants.YES);
+        wmsDocAsnHeader.setAsnType(asnType);
+        wmsDocAsnHeader.setCreateTime(DateUtil.date());
+        wmsDocAsnHeader.setCreateBy(Constant.TERMINAL_CREATOR.PDA.getDesc());
+        wmsDocAsnHeader.setAsnStatus(asnStatus);
+        wmsDocAsnHeader.setAsnReference2(goalLineNo);
+        wmsDocAsnHeaderMapper.insertWmsDocAsnHeader(wmsDocAsnHeader);
+        return wmsDocAsnHeader;
+    }
+
+    @Override
+    public WmsDocAsnHeader createAsnHeader(String asnNo, String asnType, String asnStatus) {
+        return createAsnHeader(asnNo, asnType, asnStatus, null);
+    }
+
+
 }

+ 5 - 4
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -24,7 +24,7 @@ import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.BaseLocationZone;
 import com.ruoyi.base.domain.BaseSku;
 import com.ruoyi.base.domain.dto.BaseLocationInfoSameColDTO;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseSkuService;
@@ -36,6 +36,7 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -266,13 +267,13 @@ public class BusinessServiceImpl implements IBusinessService {
             if (!StringUtils.isEmpty(outWarehouseDTO.getLocationZoneFrom())) {
                 zoneIdList.add(Long.parseLong(outWarehouseDTO.getLocationZoneFrom()));
             } else {
-                List<BaseLocationLotattVO> zoneList = invLotLocIdMapper.selectInvZoneBySkuLotatt(outWarehouseDTO.getSku(), outWarehouseDTO.getSkuType(), outWarehouseDTO.getLotattDTO());
-                for (BaseLocationLotattVO vo : zoneList) {
+                List<BaseLocationLotattDTO> zoneList = invLotLocIdMapper.selectInvZoneBySkuLotatt(outWarehouseDTO.getSku(), outWarehouseDTO.getSkuType(), outWarehouseDTO.getLotattDTO());
+                for (BaseLocationLotattDTO vo : zoneList) {
                     zoneIdList.add(vo.getZoneId());
                 }
             }
             LotattDTO lotattDTO = outWarehouseDTO.getLotattDTO();
-            List<BaseLocationLotattVO> locationInfoList = baseLocationInfoMapper.selectSortedLocationLotattListByZoneIdList(zoneIdList, outWarehouseDTO.getWarehouseId(), lotattDTO.getAttr());
+            List<BaseLocationLotattDTO> locationInfoList = baseLocationInfoMapper.selectSortedLocationLotattListByZoneIdList(zoneIdList, outWarehouseDTO.getWarehouseId(), lotattDTO.getAttr());
             AsnSoStrategy asnSoStrategy = asnSoStrategyMapper.selectAsnSoStrategy();
             return locationAllocationStrategy.filterLockInv(locationInfoList, outWarehouseDTO, asnSoStrategy, token);
         }

+ 13 - 16
warewms-ams/src/main/java/com/ruoyi/ams/config/service/LocationAllocationStrategy.java

@@ -9,20 +9,17 @@ import com.ruoyi.ams.config.domain.dto.InWarehouseDTO;
 import com.ruoyi.ams.config.domain.dto.OutWarehouseDTO;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.vo.BaseLocationLotattListVO;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.domain.vo.LotattInfo;
 import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.core.redis.RedisKey;
-import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.*;
 
@@ -173,15 +170,15 @@ public class LocationAllocationStrategy {
      * @param asnSoStrategy   出入库策略
      * @return
      */
-    public BaseLocationInfo filterLockInv(List<BaseLocationLotattVO> locationLotattVOList, OutWarehouseDTO outWarehouseDTO, AsnSoStrategy asnSoStrategy, Long token) {
+    public BaseLocationInfo filterLockInv(List<BaseLocationLotattDTO> locationLotattVOList, OutWarehouseDTO outWarehouseDTO, AsnSoStrategy asnSoStrategy, Long token) {
 
         //将同一列的库位排序好
         LinkedHashMap<String, Boolean> taskingFlag = new LinkedHashMap<>();
-        LinkedHashMap<String, List<BaseLocationLotattVO>> map = new LinkedHashMap<>();
+        LinkedHashMap<String, List<BaseLocationLotattDTO>> map = new LinkedHashMap<>();
         List<LocationSortDTO> list = new ArrayList<>();
         List<LocationSortDTO> sameLotattList = new ArrayList<>();
-        for (BaseLocationLotattVO info : locationLotattVOList) {
-            List<BaseLocationLotattVO> infoList;
+        for (BaseLocationLotattDTO info : locationLotattVOList) {
+            List<BaseLocationLotattDTO> infoList;
             if (map.containsKey(info.getColNo())) {
                 infoList = map.get(info.getColNo());
             } else {
@@ -217,7 +214,7 @@ public class LocationAllocationStrategy {
 
         //过滤出每列可以用的库位并进行分配
         BaseLocationInfo currentLocation = null;
-        BaseLocationLotattVO currentLocationLotatt = null;
+        BaseLocationLotattDTO currentLocationLotatt = null;
 
         //同批次属性优先出库,进行效期排序
         if (asnSoStrategy.getSoSameLotatt1Flag().equals("optimization")) {
@@ -225,8 +222,8 @@ public class LocationAllocationStrategy {
                 sameLotattList.sort(new LocationSortComparator());
             }
             for (LocationSortDTO locationSortDTO : list) {
-                List<BaseLocationLotattVO> locationInfoList = map.get(locationSortDTO.getColNo());
-                for (BaseLocationLotattVO b : locationInfoList) {
+                List<BaseLocationLotattDTO> locationInfoList = map.get(locationSortDTO.getColNo());
+                for (BaseLocationLotattDTO b : locationInfoList) {
                     //如果不是强制效期优先的进行多列同时出库跳过已经在出库的列
                     if (!asnSoStrategy.getSoPeriodFlag().equals("force")) {
                         if (taskingFlag.get(b.getColNo())) {
@@ -264,8 +261,8 @@ public class LocationAllocationStrategy {
         if (asnSoStrategy.getSoPeriodFlag().equals("optimization") || asnSoStrategy.getSoPeriodFlag().equals("force")) {
             list.sort(new LocationSortComparator());
             for (LocationSortDTO locationSortDTO : list) {
-                List<BaseLocationLotattVO> locationInfoList = map.get(locationSortDTO.getColNo());
-                for (BaseLocationLotattVO b : locationInfoList) {
+                List<BaseLocationLotattDTO> locationInfoList = map.get(locationSortDTO.getColNo());
+                for (BaseLocationLotattDTO b : locationInfoList) {
                     if (!asnSoStrategy.getSoPeriodFlag().equals("force")) {
                         if (taskingFlag.get(b.getColNo())) {
                             continue;
@@ -304,9 +301,9 @@ public class LocationAllocationStrategy {
             }
         } else {
             //不进行效期排序
-            for (Map.Entry<String, List<BaseLocationLotattVO>> entry : map.entrySet()) {
-                List<BaseLocationLotattVO> locationInfoList = entry.getValue();
-                for (BaseLocationLotattVO b : locationInfoList) {
+            for (Map.Entry<String, List<BaseLocationLotattDTO>> entry : map.entrySet()) {
+                List<BaseLocationLotattDTO> locationInfoList = entry.getValue();
+                for (BaseLocationLotattDTO b : locationInfoList) {
                     if (!asnSoStrategy.getSoPeriodFlag().equals("force")) {
                         if (taskingFlag.get(b.getColNo())) {
                             continue;

+ 3 - 4
warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java

@@ -5,13 +5,12 @@ import java.util.List;
 import java.util.Map;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ruoyi.ams.asn.vo.StockingListVO;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.inv.domain.InvLotAtt;
 import com.ruoyi.ams.inv.domain.InvLotLocId;
 import com.ruoyi.ams.inv.domain.form.InvLocIdSearchFrom;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.common.core.domain.AjaxResult;
 import org.apache.ibatis.annotations.Param;
 
@@ -110,7 +109,7 @@ public interface InvLotLocIdMapper extends BaseMapper<InvLotLocId> {
      * @param lotattDTO
      * @return
      */
-    List<BaseLocationLotattVO> selectInvLocationList(@Param("zoneId") Long zoneId, @Param("sku") String sku, @Param("skuType") String skuType, @Param("weight") Double weight, @Param("supplier") String supplier, @Param("lotattDTO") LotattDTO lotattDTO);
+    List<BaseLocationLotattDTO> selectInvLocationList(@Param("zoneId") Long zoneId, @Param("sku") String sku, @Param("skuType") String skuType, @Param("weight") Double weight, @Param("supplier") String supplier, @Param("lotattDTO") LotattDTO lotattDTO);
 
     /**
      * 根据sku和批次属性获取
@@ -119,7 +118,7 @@ public interface InvLotLocIdMapper extends BaseMapper<InvLotLocId> {
      * @param skuType
      * @return
      */
-    List<BaseLocationLotattVO> selectInvZoneBySkuLotatt(@Param("sku") String sku, @Param("skuType") String skuType, @Param("lotattDTO") LotattDTO lotattDTO);
+    List<BaseLocationLotattDTO> selectInvZoneBySkuLotatt(@Param("sku") String sku, @Param("skuType") String skuType, @Param("lotattDTO") LotattDTO lotattDTO);
 
     /**
      * 获取sku列表

+ 3 - 1
warewms-ams/src/main/java/com/ruoyi/ams/task/mapper/WcsTaskMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.ams.task.mapper;
 
 import java.util.List;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.dto.WcsTaskLocationDTO;
 import org.apache.ibatis.annotations.Param;
@@ -11,7 +13,7 @@ import org.apache.ibatis.annotations.Param;
  * @author andy
  * @date 2022-03-10
  */
-public interface WcsTaskMapper 
+public interface WcsTaskMapper extends BaseMapper<WcsTask>
 {
     /**
      * 查询AGV任务

+ 20 - 1
warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java

@@ -2,9 +2,9 @@ package com.ruoyi.ams.task.service;
 
 import java.util.List;
 
-import com.ruoyi.ams.agv.ndc.entity.CallbackResult;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.dto.WcsTaskLocationDTO;
+import com.ruoyi.base.constant.Constant;
 import com.ruoyi.common.core.domain.AjaxResult;
 
 /**
@@ -183,4 +183,23 @@ public interface IWcsTaskService {
      * @return
      */
     AjaxResult moveStartingPointToDestinationout(WcsTask wcsTask);
+
+    /**
+     * 翻转任务状态
+     * @author chenyang
+     * @param taskNo 任务号
+     * @param sourceStatus 源状态
+     * @param targetStatus 目标状态
+     * @return
+     */
+    Boolean updateTaskStatus(String taskNo, Integer sourceStatus, Integer targetStatus);
+
+    /**
+     * 根据入库单号查询多个
+     * @param asnNo 入库单号
+     * @param palletNo  托盘编号
+     * @param taskStatusEnum  任务状态枚举
+     * @return
+     */
+    WcsTask selectWcsTask(String asnNo, String palletNo, Constant.TASK_STS taskStatusEnum);
 }

+ 46 - 20
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -1,9 +1,15 @@
 package com.ruoyi.ams.task.service.impl;
 
 import java.lang.reflect.Method;
+import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.box.service.IWmsBoxInfoService;
@@ -114,21 +120,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         return wcsTaskMapper.selectWcsUnallocated(warehouseId);
     }
 
-    /**
-     * 查询AGV任务
-     *
-     * @param wcsTask AGV任务
-     * @return AGV任务
-     */
-    @Override
-    public WcsTask selectWcsTaskByModel(WcsTask wcsTask) {
-        List<WcsTask> list = wcsTaskMapper.selectWcsTaskList(wcsTask);
-        if (list != null && list.size() > 0) {
-            return list.get(0);
-        } else {
-            return null;
-        }
-    }
+
 
     /**
      * 新增AGV任务
@@ -264,8 +256,8 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
 
         String taskNo = wcsTask.getTaskNo();
         // 任务状态: 队列等待 直接删除即可 其他状态 需要请求AMS删除
-        if (wcsTask.getState() == Constant.TASK_STS.TASK9.getValue().longValue()
-                || wcsTask.getState() == Constant.TASK_STS.TASK10.getValue().longValue()) {
+        if (wcsTask.getState() == Constant.TASK_STS.TASK_WAIT.getValue().longValue()
+                || wcsTask.getState() == Constant.TASK_STS.TASK_PUBILSH.getValue().longValue()) {
             callBack(wcsTask.getTaskNo(), 7, null);
         } else {
             //请求ams 取消任务
@@ -354,7 +346,7 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         }
 
         if (state > 1 && state != 7) {
-            wcsTask.setAgvNo(carNo + "");
+            wcsTask.setAgvNo(ObjectUtil.isNotNull(carNo)? String.valueOf(carNo) : null);
         }
 
         if (wcsTask.getState() == 2 || wcsTask.getState() == 7) {
@@ -462,8 +454,6 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
                 }
                 throw new RuntimeException();
             }
-        } else {
-
         }
         wcsTask.setState(state.longValue());
         wcsTask.setUpdateDate(new Date());
@@ -589,6 +579,42 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         return AjaxResult.success();
     }
 
+    @Override
+    public Boolean updateTaskStatus(String taskNo, Integer sourceStatus, Integer targetStatus) {
+        LambdaUpdateWrapper<WcsTask> updateWrapper = Wrappers.<WcsTask>lambdaUpdate().set(WcsTask::getState, targetStatus)
+                .eq(WcsTask::getTaskNo, taskNo).eq(WcsTask::getState, sourceStatus);
+        return wcsTaskMapper.update(null, updateWrapper) == 1;
+    }
+
+
+
+    @Override
+    public WcsTask selectWcsTask(String asnNo, String palletNo, Constant.TASK_STS taskStatusEnum) {
+        WcsTask wcsTask = new WcsTask();
+        wcsTask.setExt1(asnNo);
+        wcsTask.setExt2(palletNo);
+        wcsTask.setState(Long.parseLong(String.valueOf(taskStatusEnum)));
+        List<WcsTask> wcsTaskList = wcsTaskMapper.selectWcsTaskList(wcsTask);
+        return CollectionUtil.isNotEmpty(wcsTaskList) ? wcsTaskList.get(0) : new WcsTask();
+    }
+
+
+    /**
+     * 查询AGV任务
+     *
+     * @param wcsTask AGV任务
+     * @return AGV任务
+     */
+    @Override
+    public WcsTask selectWcsTaskByModel(WcsTask wcsTask) {
+        List<WcsTask> list = wcsTaskMapper.selectWcsTaskList(wcsTask);
+        if (list != null && list.size() > 0) {
+            return list.get(0);
+        } else {
+            return null;
+        }
+    }
+
     /**
      * 修改库存出入库标记
      *

+ 7 - 3
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/domain/vo/LocationCoordinateVo.java

@@ -1,19 +1,23 @@
-package com.ruoyi.ams.xuankuang.domain.vo;
+package com.ruoyi.ams.xuankuang.domain.dto;
 
 import lombok.Data;
 
 /**
- * @author JWK
+ * @author chenyang
  * @version 1.0
  * @date 2023/4/3 18:29
  */
 @Data
-public class LocationCoordinateVo {
+public class LocationCoordDTO{
 
 
     private String taskNo;
+
     private String locationId;
+
     private Integer row;
+
     private Integer col;
+
     private Integer floor;
 }

+ 4 - 10
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/domain/form/CallbackTaskFrom.java

@@ -1,9 +1,12 @@
 package com.ruoyi.ams.xuankuang.domain.form;
 
+import java.io.Serializable;
+
 /**
  * WCS安全交握AGV
  */
-public class CallbackTaskFrom {
+public class CallbackTaskForm implements Serializable {
+    private static final long serialVersionUID = -5943679557042890375L;
     /**
      * 任务号
      */
@@ -25,15 +28,6 @@ public class CallbackTaskFrom {
      */
     private String message;
 
-    public CallbackTaskFrom() {
-    }
-
-    public CallbackTaskFrom(String taskNo, String safeCode, int handshakeType, String message) {
-        this.taskNo = taskNo;
-        this.safeCode = safeCode;
-        this.handshakeType = handshakeType;
-        this.message = message;
-    }
 
     public String getTaskNo() {
         return taskNo;

+ 5 - 5
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/AgvCallProxyService.java

@@ -6,13 +6,14 @@ import com.ruoyi.ams.config.domain.dto.AgvCallItemDTO;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
 import com.ruoyi.base.constant.Constant;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -40,13 +41,12 @@ public class AgvCallProxyService {
      *
      * @param locationFrom
      * @param locationTo
-     * @param createUser
      * @return
      */
     public AjaxResult theBucketIsLoadedIntoTheLibrary(String locationFrom, String locationTo, Double qty,String palletNo) {
         // todo 查询是否有可用库位,无可用库位直接结束,pda提示仓库内无可用库位
         String sku = "C4H9O2PSSNH4";
-        BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
+        BaseLocationLotattDTO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
         if (baseLocationLotattVO == null){
             AjaxResult.error("没有可以推荐的目标库位!");
         }
@@ -64,7 +64,8 @@ public class AgvCallProxyService {
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
         AjaxResult ajaxResult = iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TWO.getValue(), agvCallDTO);
         if (ajaxResult.isSuccess()){
-            wmsDocAsnSubService.agvInTask(palletNo,qty);
+            //sourceLocationId  起始库位
+            wmsDocAsnSubService.agvInTask(palletNo, "5", 1L, new BigDecimal(qty));
         }
         return ajaxResult;
     }
@@ -74,7 +75,6 @@ public class AgvCallProxyService {
      *
      * @param locationFrom
      * @param locationTo
-     * @param createUser
      * @return
      */
     public AjaxResult barrelsOutOfStorage(String locationFrom, String locationTo,String palletNo,String wcsId) {

+ 27 - 20
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BaseLocationInfoSubService.java

@@ -1,15 +1,16 @@
 package com.ruoyi.ams.xuankuang.service;
 
 import com.alibaba.fastjson.JSON;
+import com.google.common.collect.Lists;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
 import com.ruoyi.base.constant.Constant;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.crypto.interfaces.PBEKey;
 import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -54,19 +55,27 @@ public class BaseLocationInfoSubService {
      * @param bindSku
      * @return
      */
-    public BaseLocationLotattVO recommendAReceiptLocation(String bindSku) {
-        List<BaseLocationLotattVO> baseLocationLotattVOS = this.selectAllocatingInventoryAccordingConditionsOrderBy(
-                Arrays.asList(IN_ZONES)
-                , bindSku
-                , null);
-        BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoService.checkTheSameColumnLocation(baseLocationLotattVOS);
-        if (baseLocationLotattVO != null) {
-            return baseLocationLotattVO;
-        }
-        return null;
+    public BaseLocationLotattDTO recommendAReceiptLocation(String bindSku) {
+        List<BaseLocationLotattDTO> baseLocationLotattVOS = selectAllocatingInventoryAccordingConditionsOrderBy(
+                Arrays.asList(IN_ZONES), bindSku);
+        return baseLocationInfoService.checkTheSameColumnLocation(baseLocationLotattVOS);
+
     }
 
 
+    /**
+     * 根据条件查询可分配库位
+     *
+     * @param zoneIdList
+     * @param bindSku
+     * @return
+     */
+    public List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneIdList
+            , String bindSku) {
+        return selectAllocatingInventoryAccordingConditionsOrderBy(
+                Lists.newArrayList(zoneIdList), new LotattDTO(), bindSku, StringUtils.EMPTY);
+    }
+
 
 
     /**
@@ -74,15 +83,12 @@ public class BaseLocationInfoSubService {
      *
      * @param zoneId
      * @param bindSku
-     * @param orderBy
      * @return
      */
-    public List<BaseLocationLotattVO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId
-            , String bindSku
-            , String orderBy) {
-        return baseLocationInfoService.selectAllocatingLocationAccordingConditionsOrderBy(zoneId
-                , bindSku
-                , orderBy);
+    public List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(String zoneId
+            , String bindSku) {
+        return selectAllocatingInventoryAccordingConditionsOrderBy(
+                Lists.newArrayList(zoneId), new LotattDTO(), bindSku, StringUtils.EMPTY);
     }
 
     /**
@@ -94,7 +100,8 @@ public class BaseLocationInfoSubService {
      * @param orderBy
      * @return
      */
-    public List<BaseLocationLotattVO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId
+    public List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(
+            List<String> zoneId
             , LotattDTO lotattDTO
             , String sku
             , String orderBy) {

+ 8 - 13
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BeltLineClientService.java

@@ -3,23 +3,24 @@ package com.ruoyi.ams.xuankuang.service;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.hard.xuankang.BeltLineClient;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 
 /**
  * @author Jwk
  * @version 1.0
  * @date 2023/6/26 14:44
  */
-
+@Service
 public class BeltLineClientService {
     @Autowired
     private BeltLineClient beltLineClient;
 
     //进入时抬升输送线
-    public AjaxResult openTheConveyorLine() {
+    public boolean openTheConveyorLine() {
         //读输送线机械状态
         Number station = beltLineClient.readMechanicalState();
         if (station.intValue() == 1) {
-            return AjaxResult.success();
+            return Boolean.TRUE;
         }
         //读模式
         Number number = beltLineClient.readMode();
@@ -31,22 +32,16 @@ public class BeltLineClientService {
             beltLineClient.writeDirection(1);
             //读状态
             Number number1 = beltLineClient.readState();
-            if (number1.intValue() == 3){
-                return AjaxResult.success();
-            }
+            return number1.intValue() == 3;
         }
-        return AjaxResult.error();
+        return Boolean.FALSE;
     }
 
     //退出时关闭输送线
-    public AjaxResult closeTheConveyorLine() {
+    public Boolean closeTheConveyorLine() {
         //写通过完成
         beltLineClient.writeState(4);
         //写通过方向
-        Boolean aBoolean = beltLineClient.writeDirection(2);
-        if (aBoolean) {
-            return AjaxResult.success();
-        }
-        return AjaxResult.error();
+        return beltLineClient.writeDirection(2);
     }
 }

+ 91 - 0
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/BucketWcsToWmsApiService.java

@@ -0,0 +1,91 @@
+package com.ruoyi.ams.xuankuang.service;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.ruoyi.ams.inv.domain.InvLotLocId;
+import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
+import com.ruoyi.ams.inv.service.IInvLotLocIdService;
+import com.ruoyi.base.constant.Constant;
+import com.ruoyi.base.domain.BaseLocationInfo;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
+import com.ruoyi.base.domain.vo.LotattVO;
+import com.ruoyi.base.service.IBaseLocationInfoService;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.ConvertUtils;
+import com.ruoyi.hard.xuankang.ConvertUtil;
+import com.ruoyi.system.domain.SysConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author HuKang
+ * @version 1.0
+ * @date 2023/3/30 15:42
+ */
+@Slf4j
+@Service("bucketWcsToWmsApiService")
+public class BucketWcsToWmsApiService extends WcsToWmsApiService {
+
+
+    @Autowired
+    private IBaseLocationInfoService baseLocationInfoService;
+
+    @Autowired
+    private WcsToWmsApiService wcsToWmsApiService;
+
+    @Autowired
+    private IInvLotLocIdService invLotLocIdService;
+
+    /**
+     * 入库分配库位
+     * @return
+     */
+    @Override
+    protected BaseLocationInfo selectLocationInfo(){
+        //4,5,6
+        List<BaseLocationInfo> locationInfoList =
+                baseLocationInfoService.selectLocationInfoList(Constants.EMPTY_PALLET_INV, Constant.PALLET_TYPE,
+                        Boolean.TRUE, Constant.STOCK_STATUS.STOCK00.getValue());
+        //获得库存表的排序 orderby
+        //1,2,3,4,5,6
+        List<Long> bucketLocationIdList = wcsToWmsApiService.getBucketLocationIdList(Constants.EMPTY_PALLET_INV_SORT);
+        List<BaseLocationInfo> finalLocationInfoList = bucketLocationIdList.stream().map(id ->
+                locationInfoList.stream().filter(info -> id.equals(info.getId())).findFirst().orElseGet(() -> null)
+        ).filter(ObjectUtil::isNotNull).collect(Collectors.toList());
+        //4
+        return CollectionUtil.getFirst(finalLocationInfoList);
+
+    }
+
+    /**
+     * 出库分配库存
+     * @return
+     */
+    protected BaseLocationLotattDTO allocateLocationInfo(){
+        //1,2,3
+        List<BaseLocationInfo> locationInfoList =
+                baseLocationInfoService.selectLocationInfoList(Constants.EMPTY_PALLET_INV, Constant.PALLET_TYPE,
+                        Boolean.FALSE, Constant.STOCK_STATUS.STOCK00.getValue());
+        //获得库存表的排序 orderby
+        //1,2,3,4,5,6
+        List<Long> bucketLocationIdList = wcsToWmsApiService.getBucketLocationIdList(Constants.EMPTY_PALLET_INV_SORT);
+        List<BaseLocationInfo> finalLocationInfoList = bucketLocationIdList.stream().map(id ->
+                locationInfoList.stream().filter(info -> id.equals(info.getId())).findFirst().orElseGet(() -> null)
+        ).filter(ObjectUtil::isNotNull).collect(Collectors.toList());
+        //3
+        BaseLocationInfo baseLocationInfo = CollectionUtil.getLast(finalLocationInfoList);
+        List<InvLotLocIdLotattVO> invLotLocIdLotattVOS = invLotLocIdService.selectInvLocIdLotattByLocationId(baseLocationInfo.getId());
+
+        BaseLocationLotattDTO baseLocationLotatt = ConvertUtils.sourceToTarget(baseLocationInfo, BaseLocationLotattDTO.class);
+        LotattVO lotattVO = new LotattVO();
+        lotattVO.setLotatt07(invLotLocIdLotattVOS.get(0).getLotatt07());
+        baseLocationLotatt.setLotattVO(lotattVO);
+        return baseLocationLotatt;
+    }
+
+}

+ 44 - 11
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WcsTaskSubService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.ams.xuankuang.service;
 
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.service.IWmsDocAsnDetailsService;
@@ -18,6 +19,7 @@ import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -57,24 +59,54 @@ public class WcsTaskSubService {
     @Autowired
     WmsDocAsnSubService wmsDocAsnSubService;
 
+
+
     /**
-     * 增加四向车任务
-     *
+     * 新增wcsTask,兼容老的四向车立体库任务
+     * @param locationFrom
+     * @param locationTo
+     * @param asnNo
+     * @param palletNo
      * @return
      */
     public AjaxResult addWcsTask(String locationFrom, String locationTo
-            , String asnNo
-            , String palletNo
-            , String wcsNo) {
+            , String asnNo, String palletNo, String wcsNo) {
+        return addWcsTask(IdWorker.getIdStr(), locationFrom, locationTo, asnNo, palletNo, wcsNo, 10L, "立体库任务");
+    }
+
+
+    /**
+     * 增加wcsTask,桶装入库的时候封装用
+     * @param taskNo
+     * @param locationFrom
+     * @param locationTo
+     * @param asnNo
+     * @param palletNo
+     * @param state
+     * @param remake
+     * @return
+     */
+    public AjaxResult addWcsTask(String taskNo, String locationFrom, String locationTo
+            , String asnNo, String palletNo, Long state, String remake) {
+        return addWcsTask(taskNo, locationFrom, locationTo, asnNo, palletNo, StringUtils.EMPTY, state, remake);
+    }
+
+
+
+    /**
+     * 增加一个wcs任务
+     *
+     * @return
+     */
+    public AjaxResult addWcsTask(String taskNo, String locationFrom, String locationTo
+            , String asnNo, String palletNo, String wcsNo, Long state, String remake) {
 
         BaseLocationInfo baseLocationInfoFrom = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationFrom, 1l);
         BaseLocationInfo baseLocationInfoTo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationTo, 1l);
 
-        String taskNo = generateTaskNo();
-        ;
         WcsTask wcsTask = new WcsTask();
         wcsTask.setTaskNo(taskNo);
-        wcsTask.setState(10L);
+        wcsTask.setState(state);
         wcsTask.setTaskType(Constant.TASK_TYPE.FORWARD.getValue());
         wcsTask.setBusinessType("01");
         wcsTask.setAreaFrom(baseLocationInfoFrom.getZoneId().toString());
@@ -88,9 +120,8 @@ public class WcsTaskSubService {
         wcsTask.setExt1(asnNo);
         wcsTask.setExt2(palletNo);
         wcsTask.setExt3(wcsNo);
-        wcsTask.setRemark("立体库任务");
-        int i = iWcsTaskService.insertWcsTask(wcsTask);
-        if (i > 0) {
+        wcsTask.setRemark(remake);
+        if (iWcsTaskService.insertWcsTask(wcsTask) > 0) {
             iBaseLocationInfoService.lockLocationStockStatus(Long.valueOf(wcsTask.getLocationFrom())
                     , Long.valueOf(wcsTask.getLocationTo())
                     , Constant.WAREHOUSE_ID, "Wcs");
@@ -502,4 +533,6 @@ public class WcsTaskSubService {
         }
         return System.currentTimeMillis() + "";
     }
+
+
 }

+ 113 - 108
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WcsToWmsApiService.java

@@ -1,27 +1,34 @@
 package com.ruoyi.ams.xuankuang.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.comparator.CompareUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Lists;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.mapper.WmsDocAsnDetailsMapper;
 import com.ruoyi.ams.asn.mapper.WmsDocAsnHeaderMapper;
 import com.ruoyi.ams.asn.service.IWmsDocAsnDetailsService;
 import com.ruoyi.ams.config.domain.dto.LotattDTO;
+import com.ruoyi.ams.inv.domain.InvLotAtt;
+import com.ruoyi.ams.inv.service.IInvLotAttService;
 import com.ruoyi.ams.task.domain.WcsTask;
 import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.xuankuang.domain.dto.LocationCoordDTO;
 import com.ruoyi.ams.xuankuang.domain.form.*;
-import com.ruoyi.ams.xuankuang.domain.vo.LocationCoordinateVo;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.utils.IdSequenceUtils;
+import com.ruoyi.common.constant.SceneConstants;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.hard.xuankang.StirringTankClient;
 import com.ruoyi.hard.xuankang.UnpackingMachineSubClient;
+import com.ruoyi.system.service.ISysConfigService;
 import io.jsonwebtoken.lang.Assert;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import static com.ruoyi.ams.xuankuang.service.BaseLocationInfoSubService.OUT_ZONES;
 
@@ -75,6 +83,10 @@ public class WcsToWmsApiService {
     private WmsDocAsnSubService wmsDocAsnSubService;
     @Autowired
     private AgvCallProxyService agvCallProxyService;
+    @Autowired
+    private ISysConfigService sysConfigService;
+    @Autowired
+    private IInvLotAttService invLotAttService;
 
     /**
      * 组盘上报
@@ -112,7 +124,7 @@ public class WcsToWmsApiService {
             if (wcsTask != null) {
                 String locationTo = wcsTask.getLocationTo();
                 BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationTo, Constant.WAREHOUSE_ID);
-                LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+                LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
                 locationCoordinateVo.setTaskNo(wcsTask.getTaskNo());
                 locationCoordinateVo.setLocationId(baseLocationInfo.getLocationNo());
                 locationCoordinateVo.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
@@ -122,7 +134,7 @@ public class WcsToWmsApiService {
             }
 
             // 推荐目标库位
-            BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
+            BaseLocationLotattDTO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
             if (baseLocationLotattVO == null) {
                 AjaxResult.error("没有可以推荐的目标库位!");
             }
@@ -143,7 +155,7 @@ public class WcsToWmsApiService {
             // 入库缓存位生成库存
             InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), sku, palletNo, ajaxResult1.getData().toString(), taskNo, qty);
             // 反馈
-            LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+            LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
             locationCoordinateVo.setTaskNo(taskNo);
             locationCoordinateVo.setLocationId(baseLocationLotattVO.getLocationNo());
             locationCoordinateVo.setFloor(Integer.valueOf(baseLocationLotattVO.getShiftNo()));
@@ -161,7 +173,7 @@ public class WcsToWmsApiService {
         if (wcsTask != null) {
             String locationTo = wcsTask.getLocationTo();
             BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationTo, Constant.WAREHOUSE_ID);
-            LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+            LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
             locationCoordinateVo.setTaskNo(wcsTask.getTaskNo());
             locationCoordinateVo.setLocationId(baseLocationInfo.getLocationNo());
             locationCoordinateVo.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
@@ -171,7 +183,7 @@ public class WcsToWmsApiService {
         }
 
         // 推荐目标库位
-        BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
+        BaseLocationLotattDTO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
         if (baseLocationLotattVO == null) {
             AjaxResult.error("没有可以推荐的目标库位!");
         }
@@ -190,7 +202,7 @@ public class WcsToWmsApiService {
         // 入库缓存位生成库存
         InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), sku, palletNo, asnNo, taskNo, qty);
         // 反馈
-        LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+        LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
         locationCoordinateVo.setTaskNo(taskNo);
         locationCoordinateVo.setLocationId(baseLocationLotattVO.getLocationNo());
         locationCoordinateVo.setFloor(Integer.valueOf(baseLocationLotattVO.getShiftNo()));
@@ -206,7 +218,7 @@ public class WcsToWmsApiService {
      * @return
      */
     @Transactional
-    public synchronized AjaxResult EmptyPalletLoc(EmptyPalletLocForm emptyPalletLocForm) {
+    public synchronized AjaxResult emptyPalletLoc(EmptyPalletLocForm emptyPalletLocForm) {
         // 空托仓位请求类型
         int taskType = emptyPalletLocForm.getTaskType();
         // 任务号
@@ -226,7 +238,7 @@ public class WcsToWmsApiService {
             if (wcsTask != null) {
                 String locationTo = wcsTask.getLocationTo();
                 BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationTo, Constant.WAREHOUSE_ID);
-                LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+                LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
                 locationCoordinateVo.setTaskNo(wcsTask.getTaskNo());
                 locationCoordinateVo.setLocationId(baseLocationInfo.getLocationNo());
                 locationCoordinateVo.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
@@ -234,16 +246,16 @@ public class WcsToWmsApiService {
                 locationCoordinateVo.setRow(Integer.valueOf(baseLocationInfo.getRowIndex()));
                 return AjaxResult.success("仓位获取成功!", locationCoordinateVo);
             }
-            BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(Constant.PALLET_TYPE);
-            if (baseLocationLotattVO == null) {
+
+            BaseLocationInfo baseLocationInfo = selectLocationInfo();
+            if (baseLocationInfo == null) {
                 AjaxResult.error("没有可以推荐的目标库位!");
             }
 
-
             // 生成任务
             String taskNo = "";
             AjaxResult ajaxResult = wcsTaskSubService.addWcsTask(Constant.LOC_STAGE_CACHE.toString()
-                    , baseLocationLotattVO.getId().toString()
+                    , baseLocationInfo.getId().toString()
                     , ""
                     , ""
                     , wcsNo);
@@ -254,44 +266,50 @@ public class WcsToWmsApiService {
             // 入库缓存位生成库存
             InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), Constant.PALLET_TYPE, "", "", taskNo, 1.0);
             // 反馈
-            LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
+            LocationCoordDTO locationCoordinateVo = new LocationCoordDTO();
             locationCoordinateVo.setTaskNo(taskNo);
-            locationCoordinateVo.setLocationId(baseLocationLotattVO.getLocationNo());
-            locationCoordinateVo.setFloor(Integer.valueOf(baseLocationLotattVO.getShiftNo()));
-            locationCoordinateVo.setCol(Integer.valueOf(baseLocationLotattVO.getRowNo()));
-            locationCoordinateVo.setRow(Integer.valueOf(baseLocationLotattVO.getRowIndex()));
+            locationCoordinateVo.setLocationId(baseLocationInfo.getLocationNo());
+            locationCoordinateVo.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
+            locationCoordinateVo.setCol(Integer.valueOf(baseLocationInfo.getRowNo()));
+            locationCoordinateVo.setRow(Integer.valueOf(baseLocationInfo.getRowIndex()));
             return AjaxResult.success("仓位获取成功!", locationCoordinateVo);
         }
 
         if (taskType == 2) {
-            String sku = Constant.PALLET_TYPE;
-            LotattDTO lotattDTO = new LotattDTO();
-            String orderBy = "";
-            List<String> outZones = OUT_ZONES;
-            List<BaseLocationLotattVO> baseLocationLotattVOS = baseLocationInfoSubService.selectAllocatingInventoryAccordingConditionsOrderBy(outZones, lotattDTO, sku, orderBy);
-            if (baseLocationLotattVOS.size() == 0) {
-                return AjaxResult.error("仓库中无库存");
-            }
-            BaseLocationLotattVO baseLocationLotattVO = filterInv1(baseLocationLotattVOS);
-            Assert.isTrue(ObjectUtil.isNotNull(baseLocationLotattVO), "仓库中无库存");
 
-            String pallentNo = ObjectUtil.isNotNull(baseLocationLotattVO.getLotattVO())
-                    ? baseLocationLotattVO.getLotattVO().getLotatt07() : StringUtils.EMPTY;
-            String locationFrom = baseLocationLotattVO.getLocationNo();
+            BaseLocationLotattDTO baseLocationLotatt = allocateLocationInfo();
+
+            Assert.isTrue(ObjectUtil.isNotNull(baseLocationLotatt), "仓库中无库存");
+
+            //TODO 这一块有可疑的地方 baseLocationLotatt
+            String pallentNo = ObjectUtil.isNotNull(baseLocationLotatt.getLotattVO())
+                    ? baseLocationLotatt.getLotattVO().getLotatt07() : StringUtils.EMPTY;
+            String locationFrom = baseLocationLotatt.getLocationNo();
+
 
             // 生成四向车出库任务
-            AjaxResult ajaxResult = wcsTaskSubService.addWcsOutTask(locationFrom, Constant.LOC_SORTATION_CACHE.toString(), "", pallentNo, wcsNo);
-            LocationCoordinateVo locationCoordinateVo1 = new LocationCoordinateVo();
+            AjaxResult ajaxResult = wcsTaskSubService.addWcsOutTask(baseLocationLotatt.getLocationNo(), Constant.LOC_SORTATION_CACHE.toString(), "", pallentNo, wcsNo);
+            LocationCoordDTO locationCoordinateVo1 = new LocationCoordDTO();
             locationCoordinateVo1.setTaskNo(ajaxResult.get("data").toString());
-            locationCoordinateVo1.setLocationId(baseLocationLotattVO.getLocationNo());
-            locationCoordinateVo1.setFloor(Integer.valueOf(baseLocationLotattVO.getShiftNo()));
-            locationCoordinateVo1.setCol(Integer.valueOf(baseLocationLotattVO.getRowNo()));
-            locationCoordinateVo1.setRow(Integer.valueOf(baseLocationLotattVO.getRowIndex()));
+            locationCoordinateVo1.setLocationId(baseLocationLotatt.getLocationNo());
+            locationCoordinateVo1.setFloor(Integer.valueOf(baseLocationLotatt.getShiftNo()));
+            locationCoordinateVo1.setCol(Integer.valueOf(baseLocationLotatt.getRowNo()));
+            locationCoordinateVo1.setRow(Integer.valueOf(baseLocationLotatt.getRowIndex()));
             return AjaxResult.success("仓位获取成功", locationCoordinateVo1);
         }
         return AjaxResult.success();
     }
 
+    protected BaseLocationLotattDTO allocateLocationInfo() {
+        List<BaseLocationLotattDTO> baseLocationLotattList = baseLocationInfoSubService.selectAllocatingInventoryAccordingConditionsOrderBy(OUT_ZONES, Constant.PALLET_TYPE);
+        Assert.isTrue(CollectionUtil.isNotEmpty(baseLocationLotattList),  "there is no stock in the warehouse");
+        return filterInv1(baseLocationLotattList);
+    }
+
+    protected BaseLocationInfo selectLocationInfo() {
+        return baseLocationInfoSubService.recommendAReceiptLocation(Constant.PALLET_TYPE);
+    }
+
 
     /**
      * 任务状态反馈
@@ -312,7 +330,7 @@ public class WcsToWmsApiService {
      * @param locationLotattList
      * @return
      */
-    public synchronized BaseLocationLotattVO filterInv1(List<BaseLocationLotattVO> locationLotattList) {
+    public synchronized BaseLocationLotattDTO filterInv1(List<BaseLocationLotattDTO> locationLotattList) {
         return locationLotattList.parallelStream()
                 .filter(item -> ObjectUtil.isNotNull(item)
                         && StringUtils.equals(Constant.PALLET_TYPE, item.getSku())
@@ -611,86 +629,70 @@ public class WcsToWmsApiService {
     }
 
     /**
-     * 桶装入库
+     * 桶装入库预备创建库存
+     * @param sku
+     * @param sourceLocationId
+     * @param asnNo
+     * @param palletNo
+     * @param quantity
      * @return
      */
-    @Transactional
-    public synchronized AjaxResult theBucketIsLoadedIntoTheLibrary(String sku, String asnNo, String palletNo, BigDecimal num) {
-
-
-        // 数量
-        Double qty = num.doubleValue();
+    public LocationCoordDTO createInvPrepare(String taskNo, String sku, Long sourceLocationId, String asnNo, String palletNo, BigDecimal quantity) {
+        //获取桶装物料在真实库位中存放的位置
+        List<Long> realBucketLocationIdList = getBucketLocationIdList("realBucketLocationIdList");
+        //TODO 目前只有一个真实库位用于存放桶装料,多个就要选取库位了
+        Long targetLocationId = realBucketLocationIdList.get(0);
+        BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoById(targetLocationId);
+        Assert.isTrue(ObjectUtil.isNotNull(baseLocationInfo), "没有可以推荐的目标库位!");
+
+        //预备创建库存
+        InvLotLocIdSubService.initInv(String.valueOf(sourceLocationId), sku, palletNo, asnNo, taskNo, quantity.doubleValue());
+        return assemblyLocationCoordInfo(baseLocationInfo.getLocationNo(), taskNo);
+    }
 
-        // 任务号
-        String wcsNo = "";
 
-        // 判重
-        WcsTask wcsTaskQuery = new WcsTask();
-        wcsTaskQuery.setExt1(asnNo);
-        wcsTaskQuery.setExt2(palletNo);
-        wcsTaskQuery.setExt3(wcsNo);
-        WcsTask wcsTask = iWcsTaskService.selectWcsTaskByModel(wcsTaskQuery);
-        if (wcsTask != null) {
-            String locationTo = wcsTask.getLocationTo();
-            BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationTo, Constant.WAREHOUSE_ID);
-            LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
-            locationCoordinateVo.setTaskNo(wcsTask.getTaskNo());
-            locationCoordinateVo.setLocationId(baseLocationInfo.getLocationNo());
-            locationCoordinateVo.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
-            locationCoordinateVo.setCol(Integer.valueOf(baseLocationInfo.getRowNo()));
-            locationCoordinateVo.setRow(Integer.valueOf(baseLocationInfo.getRowIndex()));
-            return AjaxResult.success("仓位获取成功!", locationCoordinateVo);
-        }
+    public LocationCoordDTO getInvInfoByTask(WcsTask wcsTask) {
+        if(ObjectUtil.isNotNull(wcsTask) && StringUtils.isNotBlank(wcsTask.getTaskNo())) return new LocationCoordDTO();
+        return assemblyLocationCoordInfo(wcsTask.getLocationTo(), wcsTask.getTaskNo());
+    }
 
-        // 推荐目标库位
-        BaseLocationLotattVO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
-        if (baseLocationLotattVO == null) {
-            AjaxResult.error("没有可以推荐的目标库位!");
-        }
+    /**
+     * 根据场景code返回库位列表
+     * @param subSceneCode
+     * @return
+     */
+    public List<Long> getBucketLocationIdList(String subSceneCode) {
+        String bucketConfig = sysConfigService.selectConfigByKey(SceneConstants.STORAGE_BUCKET_SCENE);
+        if(StringUtils.isBlank(bucketConfig)) return Lists.newArrayList();
+
+        JSONObject bucketSceneConfig = JSONObject.parseObject(bucketConfig);
+        List<Integer> bucketLocationIdList = ObjectUtil.isNotNull(bucketSceneConfig) && ObjectUtil.isNotNull(bucketSceneConfig.get(subSceneCode))
+                ? (List<Integer>) bucketSceneConfig.get(subSceneCode) : Lists.newArrayList();
+        return bucketLocationIdList.stream().filter(item -> ObjectUtil.isNotNull(item))
+                .map(item -> item.longValue()).collect(Collectors.toList());
+    }
 
-        // 生成任务
-        String taskNo = "";
-        AjaxResult ajaxResult = wcsTaskSubService.addWcsTask(Constant.LOC_STAGE_CACHE.toString()
-                , baseLocationLotattVO.getId().toString()
-                , asnNo
-                , palletNo
-                , wcsNo);
-        if (!ajaxResult.isSuccess()) {
-            return ajaxResult;
-        }
-        taskNo = ajaxResult.get("data").toString();
-        // 入库缓存位生成库存
-        InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), sku, palletNo, asnNo, taskNo, qty);
-        // 反馈
-        LocationCoordinateVo locationCoordinateVo = new LocationCoordinateVo();
-        locationCoordinateVo.setTaskNo(taskNo);
-        locationCoordinateVo.setLocationId(baseLocationLotattVO.getLocationNo());
-        locationCoordinateVo.setFloor(Integer.valueOf(baseLocationLotattVO.getShiftNo()));
-        locationCoordinateVo.setCol(Integer.valueOf(baseLocationLotattVO.getRowNo()));
-        locationCoordinateVo.setRow(Integer.valueOf(baseLocationLotattVO.getRowIndex()));
-        return AjaxResult.success("仓位获取成功!", locationCoordinateVo);
+    private LocationCoordDTO assemblyLocationCoordInfo(String locationNo, String taskNo) {
+        BaseLocationInfo baseLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationNo, Constant.WAREHOUSE_ID);
+        LocationCoordDTO locationCoordDTO = new LocationCoordDTO();
+        locationCoordDTO.setTaskNo(taskNo);
+        locationCoordDTO.setLocationId(baseLocationInfo.getLocationNo());
+        locationCoordDTO.setFloor(Integer.valueOf(baseLocationInfo.getShiftNo()));
+        locationCoordDTO.setCol(Integer.valueOf(baseLocationInfo.getRowNo()));
+        locationCoordDTO.setRow(Integer.valueOf(baseLocationInfo.getRowIndex()));
+        return locationCoordDTO;
     }
 
     /**
-     * 安全交握
-     * @param callbackTaskFrom
+     * 安全交握,Wcs回调通知agv是否可以执行
+     * @param callbackForm
      * @return
      */
-    public AjaxResult secureHandover(CallbackTaskFrom callbackTaskFrom) {
-        if (callbackTaskFrom.getSafeCode().equals("1")){
-            WcsTask wcsTask = new WcsTask();
-            wcsTask.setState(new Long(13));
-            WcsTask wcsTask1 = wcsTaskService.selectWcsTaskByModel(wcsTask);
-            wcsTask1.setState(new Long(9));
-            int i = wcsTaskService.updateWcsTask(wcsTask1);
-            if (i>0){
-                return AjaxResult.success();
-            }
-        }else if (callbackTaskFrom.getSafeCode().equals("0")){
-            log.error(callbackTaskFrom.getMessage());
-            return AjaxResult.success("未执行");
-        }
-        return AjaxResult.success();
+    public Boolean callbackNotice(CallbackTaskForm callbackForm) {
+        Assert.isTrue(StringUtils.equals(Constant.SAFE_CODE.PASS.getCode(), callbackForm.getSafeCode()),
+                "当前任务未执行");
+        return wcsTaskService.updateTaskStatus(callbackForm.getTaskNo(),
+                Constant.TASK_STS.TASK_CREATE.getValue(),  Constant.TASK_STS.TASK_WAIT.getValue());
     }
 
     /**
@@ -729,4 +731,7 @@ public class WcsToWmsApiService {
         wmsDocAsnSubService.wmsAgvCallbackIntask(taskNo);
         return AjaxResult.success();
     }
+
+
+
 }

+ 66 - 76
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsDocAsnSubService.java

@@ -1,39 +1,38 @@
 package com.ruoyi.ams.xuankuang.service;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.google.common.collect.Lists;
 import com.ruoyi.ams.asn.domain.WmsDocAsnDetails;
 import com.ruoyi.ams.asn.domain.WmsDocAsnHeader;
 import com.ruoyi.ams.asn.mapper.WmsDocAsnDetailsMapper;
 import com.ruoyi.ams.asn.mapper.WmsDocAsnHeaderMapper;
 import com.ruoyi.ams.asn.service.IWmsDocAsnDetailsService;
 import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
-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.task.domain.WcsTask;
+import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.xuankuang.domain.dto.LocationCoordDTO;
 import com.ruoyi.ams.xuankuang.domain.form.AgvInTaskForm;
 import com.ruoyi.ams.xuankuang.domain.form.BillTaskForm;
-import com.ruoyi.ams.xuankuang.domain.vo.LocationCoordinateVo;
 import com.ruoyi.ams.xuankuang.domain.vo.WcsResponseVo;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseSku;
 import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.utils.IdSequenceUtils;
 import com.ruoyi.common.core.domain.AjaxResult;
+import javafx.concurrent.Task;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.util.Assert;
 import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
 
-import java.io.Console;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 入库业务
@@ -65,7 +64,8 @@ public class WmsDocAsnSubService {
     @Autowired
     private WmsDocAsnHeaderMapper wmsDocAsnHeaderMapper;
     @Autowired
-    private WmsDocAsnDetailsMapper wmsDocAsnDetailsMapper;
+    private IWcsTaskService iWcsTaskService;
+
 
 
     /**
@@ -126,64 +126,65 @@ public class WmsDocAsnSubService {
 
     /**
      * agv入库任务下发
-     * @param asnNo
+     * @param palletNo 托盘号
+     * @param quantity 数量
      * @return
      */
     @Transactional
-    public AjaxResult agvInTask(String palletNo,Double qty) {
-        // wms物料编码
-        String sku = iBaseSkuService.selectBaseSkuByMaterialType("5").getSku();
-        String asnNo = generateAnOutboundOrder(sku, new BigDecimal(qty));
-        //  根据单号,和创建状态为00
-        WmsDocAsnDetails wmsDocAsnDetails = new WmsDocAsnDetails();
-        wmsDocAsnDetails.setAsnNo(asnNo);
-        wmsDocAsnDetails.setLineStatus(Constant.ASN_STS.STS00.getValue());
-        List<WmsDocAsnDetails> list = iWmsDocAsnDetailsService.selectWmsDocAsnDetailsList(wmsDocAsnDetails);
-        WmsDocAsnHeader wmsDocAsnHeader = iWmsDocAsnHeaderService.selectWmsDocAsnHeaderByAsnNo(asnNo);
-
-        boolean con = true;
-        for (WmsDocAsnDetails details:list) {
-            BaseSku baseSku = iBaseSkuService.selectBaseSkuByCustomerId(Constant.CUSTOMER_ID, details.getSku());
-            AgvInTaskForm agvInTaskForm = new AgvInTaskForm();
-            agvInTaskForm.setAgvId("1");
-            agvInTaskForm.setMaterial(Integer.valueOf(baseSku.getDesc2()));
-            agvInTaskForm.setDocNo(asnNo);
-            agvInTaskForm.setNum(details.getExpectedQty().intValue());
-            //托盘码
-            String pallentNo = palletNo;
-            AjaxResult ajaxResult = wcsToWmsApiService.theBucketIsLoadedIntoTheLibrary(sku, asnNo, pallentNo, details.getExpectedQty());
-            LocationCoordinateVo locationCoordinateVo =  ajaxResult.getDataParseObject(LocationCoordinateVo.class);
-            String taskNo = locationCoordinateVo.getTaskNo();
-            String row = locationCoordinateVo.getRow().toString();
-            String col = locationCoordinateVo.getCol().toString();
-            String floor = locationCoordinateVo.getFloor().toString();
-            agvInTaskForm.setTaskNo(taskNo);
-            agvInTaskForm.setPalletId(pallentNo);
-            agvInTaskForm.setRow(Integer.parseInt(row));
-            agvInTaskForm.setCol(Integer.parseInt(col));
-            agvInTaskForm.setFloor(Integer.parseInt(floor));
-            //调用agv入库任务下发
-            WmsToWcsApiService wmsToWcsApiService = new WmsToWcsApiService();
-            WcsResponseVo wcsResponseVo = wmsToWcsApiService.wmsAgvInTask(agvInTaskForm);
-            if (!wcsResponseVo.isSuccess()) {
-                con = false;
-                wmsDocAsnHeader.setNotes(wcsResponseVo.getMessage());
-                iWmsDocAsnHeaderService.updateWmsDocAsnHeader(wmsDocAsnHeader);
-                wcsTaskSubService.callBack(taskNo,7,null);
-                continue;
-            }
-            // 修改 明细行状态为10
-            details.setLineStatus(Constant.ASN_STS.STS10.getValue());
-            iWmsDocAsnDetailsService.updateWmsDocAsnDetails(details);
-        }
-        if (con == true) {
-            wmsDocAsnHeader.setNotes("");
-            // 修改 单头10
-            wmsDocAsnHeader.setAsnStatus(Constant.ASN_STS.STS10.getValue());
+    public List<WmsDocAsnDetails> agvInTask(String palletNo, String materialType, Long sourceLocationId, BigDecimal quantity) {
+        //1.预备参数设置
+        BaseSku baseSku  = iBaseSkuService.selectBaseSkuByMaterialType(materialType);
+        Assert.isTrue(ObjectUtil.isNotNull(baseSku) && StringUtils.isNotBlank(baseSku.getSku()), "the materialType is illegal");
+        String asnNo = idSequenceUtils.generateId(Constant.ID_TYPE.ASNNO.getDesc());
+        //2.入库单创建
+        WmsDocAsnHeader wmsDocAsnHeader =
+                iWmsDocAsnHeaderService.createAsnHeader(asnNo, Constant.ASN_TYP.TZ.getValue(), Constant.ASN_STS.STS00.getValue());
+        WmsDocAsnDetails wmsDocAsnDetail =
+                iWmsDocAsnDetailsService.createAsnDetail(asnNo, baseSku.getSku(), quantity);
+        //3. 如果任务已经存在,则从任务中获取库存信息,否则就预建立入库库存
+        WcsTask wcsTask = iWcsTaskService.selectWcsTask(asnNo, palletNo, Constant.TASK_STS.TASK_PUBILSH);
+        Boolean isNotEmpty = ObjectUtils.isNotNull(wcsTask) && StringUtils.isNotBlank(wcsTask.getTaskNo());
+        String taskNo = IdWorker.getIdStr();
+        LocationCoordDTO locationCoordDTO = isNotEmpty ? wcsToWmsApiService.getInvInfoByTask(wcsTask)
+                : wcsToWmsApiService.createInvPrepare(taskNo, baseSku.getSku(), sourceLocationId, asnNo, palletNo, quantity);
+        //4. 新增一个wcs任务
+        wcsTaskSubService.addWcsTask(taskNo, String.valueOf(sourceLocationId), String.valueOf(locationCoordDTO.getLocationId()),
+                asnNo, palletNo, Constant.TASK_STS.TASK_CREATE.getLongValue(), "下发AGV桶装入库");
+        Assert.isTrue(StringUtils.isNotBlank(taskNo), "生成任务失败");
+        //5.通知wcs当前任务完成
+        AgvInTaskForm agvInTaskForm = assemblyAgvInTaskForm(asnNo, materialType, quantity, palletNo, locationCoordDTO);
+        WcsResponseVo wcsResponseVo = wmsToWcsApiService.wmsAgvInTask(agvInTaskForm);
+        if (!wcsResponseVo.isSuccess()) {
+            wmsDocAsnHeader.setNotes(wcsResponseVo.getMessage());
             iWmsDocAsnHeaderService.updateWmsDocAsnHeader(wmsDocAsnHeader);
+            wcsTaskSubService.callBack(locationCoordDTO.getTaskNo(), Constant.TASK_STS.TASK_CANCEL.getValue(), null);
+            return Lists.newArrayList(wmsDocAsnDetail);
         }
-        return AjaxResult.success("",list);
+        wmsDocAsnHeader.setAsnStatus(Constant.ASN_STS.STS10.getValue());
+        wmsDocAsnDetail.setLineStatus(Constant.ASN_STS.STS10.getValue());
+        iWmsDocAsnDetailsService.updateWmsDocAsnDetails(wmsDocAsnDetail);
+        iWmsDocAsnHeaderService.updateWmsDocAsnHeader(wmsDocAsnHeader);
+        return Lists.newArrayList(wmsDocAsnDetail);
+    }
+
+    private AgvInTaskForm assemblyAgvInTaskForm(String asnNo, String materialType, BigDecimal quantity, String palletNo, LocationCoordDTO locationCoordDTO) {
 
+        AgvInTaskForm agvInTaskForm = new AgvInTaskForm();
+        agvInTaskForm.setAgvId("1");
+        agvInTaskForm.setMaterial(Integer.valueOf(materialType));
+        agvInTaskForm.setDocNo(asnNo);
+        agvInTaskForm.setNum(quantity.intValue());
+        //托盘码
+        String taskNo = locationCoordDTO.getTaskNo();
+        String row = locationCoordDTO.getRow().toString();
+        String col = locationCoordDTO.getCol().toString();
+        String floor = locationCoordDTO.getFloor().toString();
+        agvInTaskForm.setTaskNo(taskNo);
+        agvInTaskForm.setPalletId(palletNo);
+        agvInTaskForm.setRow(Integer.parseInt(row));
+        agvInTaskForm.setCol(Integer.parseInt(col));
+        agvInTaskForm.setFloor(Integer.parseInt(floor));
+        return agvInTaskForm;
     }
 
     /**
@@ -223,18 +224,7 @@ public class WmsDocAsnSubService {
         wmsDocAsnHeader.setAsnStatus(Constant.ASN_STS.STS00.getValue());
         wmsDocAsnHeaderMapper.insertWmsDocAsnHeader(wmsDocAsnHeader);
         //生成明细
-        WmsDocAsnDetails wmsDocAsnDetails = new WmsDocAsnDetails();
-        wmsDocAsnDetails.setAsnNo(asnNo);
-        wmsDocAsnDetails.setAsnLineNo(new Long(1));
-        wmsDocAsnDetails.setLineStatus(Constant.ASN_STS.STS00.getValue());
-        wmsDocAsnDetails.setSku(sku);
-        wmsDocAsnDetails.setExpectedQty(qty);
-        wmsDocAsnDetails.setExpectedQtyEach(qty);
-        wmsDocAsnDetails.setReceivedQty(new BigDecimal(0));
-        wmsDocAsnDetails.setReceivedQtyEach(new BigDecimal(0));
-        wmsDocAsnDetails.setCreateTime(new Date());
-        wmsDocAsnDetails.setCreateBy("PDA");
-        wmsDocAsnDetailsMapper.insertWmsDocAsnDetails(wmsDocAsnDetails);
+
         return asnNo;
     }
 

+ 12 - 12
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsDocOrderSubService.java

@@ -16,7 +16,7 @@ import com.ruoyi.ams.xuankuang.domain.form.OutTaskForm;
 import com.ruoyi.ams.xuankuang.domain.vo.WcsResponseVo;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseSku;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.IBaseSkuService;
 import com.ruoyi.base.utils.IdSequenceUtils;
@@ -86,10 +86,10 @@ public class WmsDocOrderSubService {
         WmsDocOrderHeader wmsDocOrderHeader = iWmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
 
         // 匹配库存(先进先出)
-        List<BaseLocationLotattVO> baseLocationLotattVOS = addConfirmAllocationAuto(orderNo);
+        List<BaseLocationLotattDTO> baseLocationLotattVOS = addConfirmAllocationAuto(orderNo);
 
         //筛选库存
-        List<BaseLocationLotattVO> baseLocationLotattVOS1 = filterInv(baseLocationLotattVOS, orderNo);
+        List<BaseLocationLotattDTO> baseLocationLotattVOS1 = filterInv(baseLocationLotattVOS, orderNo);
 
         // 匹配库存(撇开先进先出)
 //        baseLocationLotattVOS = addConfirmAllocationAuto(orderNo);
@@ -103,7 +103,7 @@ public class WmsDocOrderSubService {
         int allocateQuantities = 0;
         //出库单对应袋数
         int orderNum = list.get(0).getQtyOrderedEach().intValue();
-        for (BaseLocationLotattVO baseLocationLotattVO1 : baseLocationLotattVOS1) {
+        for (BaseLocationLotattDTO baseLocationLotattVO1 : baseLocationLotattVOS1) {
 
 
             BaseSku baseSku = iBaseSkuService.selectBaseSkuByCustomerId(Constant.CUSTOMER_ID, list.get(0).getSku());
@@ -180,7 +180,7 @@ public class WmsDocOrderSubService {
      * @param orderNo
      * @return
      */
-    public List<BaseLocationLotattVO> addConfirmAllocationAuto(String orderNo) {
+    public List<BaseLocationLotattDTO> addConfirmAllocationAuto(String orderNo) {
 
         // 查询出库单头
         WmsDocOrderHeader wmsDocOrderHeader = iWmsDocOrderHeaderService.selectWmsDocOrderHeaderByOrderNo(orderNo);
@@ -193,7 +193,7 @@ public class WmsDocOrderSubService {
         //List<String> skuList = detailslist.stream().map(item -> item.getSku()).collect(Collectors.toList());
         String sku = detailslist.get(0).getSku();
         Assert.isTrue(StringUtils.isNotNull(sku),"存在无物料号的出库单");
-        List<BaseLocationLotattVO> baseLocationLotattVOS
+        List<BaseLocationLotattDTO> baseLocationLotattVOS
                 = baseLocationInfoSubService.selectAllocatingInventoryAccordingConditionsOrderBy(OUT_ZONES,  new LotattDTO(), sku, null);
         Assert.isTrue(CollectionUtil.isNotEmpty(baseLocationLotattVOS),"仓库中无库存");
 
@@ -206,7 +206,7 @@ public class WmsDocOrderSubService {
      * @param orderNo
      * @return
      */
-    public synchronized List<BaseLocationLotattVO> filterInv(List<BaseLocationLotattVO> baseLocationLotattVOS, String orderNo) {
+    public synchronized List<BaseLocationLotattDTO> filterInv(List<BaseLocationLotattDTO> baseLocationLotattVOS, String orderNo) {
         //  根据单号,和创建状态为00
         WmsDocOrderDetails wmsDocOrderDetails = new WmsDocOrderDetails();
         wmsDocOrderDetails.setOrderNo(orderNo);
@@ -214,23 +214,23 @@ public class WmsDocOrderSubService {
         List<WmsDocOrderDetails> list = iWmsDocOrderDetailsService.selectWmsDocOrderDetailsList(wmsDocOrderDetails);
 
         //出库同列阻挡和任务阻挡
-        List<BaseLocationLotattVO> baseLocationLotattVOS2 = new ArrayList<>();
+        List<BaseLocationLotattDTO> baseLocationLotattVOS2 = new ArrayList<>();
         for (int i = 0; i < baseLocationLotattVOS.size(); i++) {
-            BaseLocationLotattVO baseLocationLotattVO = baseLocationLotattVOS.get(i);
-            BaseLocationLotattVO baseLocationLotattVO1 = baseLocationInfoService.checkTheSameColumnLocation1(baseLocationLotattVO, baseLocationLotattVOS2);
+            BaseLocationLotattDTO baseLocationLotattVO = baseLocationLotattVOS.get(i);
+            BaseLocationLotattDTO baseLocationLotattVO1 = baseLocationInfoService.checkTheSameColumnLocation1(baseLocationLotattVO, baseLocationLotattVOS2);
             if (baseLocationLotattVO1 != null) {
                 baseLocationLotattVOS2.add(baseLocationLotattVO1);
             }
         }
 
-        List<BaseLocationLotattVO> baseLocationLotattVOS1 = new ArrayList<>();
+        List<BaseLocationLotattDTO> baseLocationLotattVOS1 = new ArrayList<>();
 
         for (WmsDocOrderDetails wmsDocOrderDetails1 : list) {
             String sku1 = wmsDocOrderDetails1.getSku();
             //出库数量
             BigDecimal qtyAllocatedEach = wmsDocOrderDetails1.getQtyOrderedEach();
 
-            for (BaseLocationLotattVO baseLocationLotattVO1 : baseLocationLotattVOS2) {
+            for (BaseLocationLotattDTO baseLocationLotattVO1 : baseLocationLotattVOS2) {
                 if (qtyAllocatedEach.compareTo(BigDecimal.ZERO) <= 0) {
                     return baseLocationLotattVOS1;
                 }

+ 2 - 0
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsToWcsApiService.java

@@ -89,7 +89,9 @@ public class WmsToWcsApiService {
         String r = "";
         WcsResponseVo wcsResponseVo = new WcsResponseVo();
         try {
+            log.info("WmsToWcsApiService-wmsAgvInTask-input:{}, timestamp:{}", json, System.currentTimeMillis());
             r = HttpRequest.postData(Constant.WCS_TASK_URL4, json);
+            log.info("WmsToWcsApiService-wmsAgvInTask-output:{}, timestamp:{}", r, System.currentTimeMillis());
             wcsResponseVo = JSON.parseObject(r, WcsResponseVo.class);
         } catch (Exception e) {
             log.error("agv入库任务下发接口失败: ", e);

+ 1 - 1
warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml

@@ -63,7 +63,7 @@
         <result property="lotatt18" column="lotatt18"/>
     </resultMap>
 
-    <resultMap type="BaseLocationLotattVO" id="BaseLocationInfoLotattResult">
+    <resultMap type="BaseLocationLotattDTO" id="BaseLocationInfoLotattResult">
         <result property="id" column="id"/>
         <result property="warehouseId" column="warehouse_id"/>
         <result property="zoneId" column="zone_id"/>

+ 104 - 5
warewms-base/src/main/java/com/ruoyi/base/constant/Constant.java

@@ -1,5 +1,9 @@
 package com.ruoyi.base.constant;
 
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.ruoyi.common.utils.StringUtils;
+import io.netty.util.internal.ObjectUtil;
+
 /**
  * Created by IntelliJ IDEA.
  * User: andy.qu
@@ -39,6 +43,16 @@ public class Constant {
      */
     public static final Long LOC_MIDDLE_CACHE = 99999l;
 
+    /**
+     * 默认的桶装物料的库位
+     * TODO 这个是啥要和玥明确认
+     * @author chenyang
+     */
+    public static final Long DEFAULT_BUCKET_LOCATION_ID = 1L;
+
+    public static final Long DEFAULT_WAREHOUSE_ID = 1L;
+
+
 
     //region WCS智库 工单下发
     public static final String WCS_TASK_URL = "http://localhost:8082/adaptor/wms/bill";
@@ -58,6 +72,7 @@ public class Constant {
     // WCS智库 agv回调wcs取货完成
     public static final String WCS_TASK_URL6 = "http://localhost:8082/adaptor/agv/callback/outtask?wcsId=";
 
+
     /**
      * 产线编号
      */
@@ -277,6 +292,7 @@ public class Constant {
         STS00("00"),
 
         STS10("10"),
+
         STS20("20"),
         /**
          * 部分收货
@@ -570,7 +586,7 @@ public class Constant {
         /**
          * 取消
          */
-        TASK7(7),
+        TASK_CANCEL(7),
         /**
          * 空叉取消
          */
@@ -578,15 +594,15 @@ public class Constant {
         /**
          * 队列等待
          */
-        TASK9(9),
+        TASK_WAIT(9),
         /**
          * 已下发
          */
-        TASK10(10),
+        TASK_PUBILSH(10),
         /**
-         * 生成
+         * 任务创建
          */
-        TASK13(13);
+        TASK_CREATE(13);
 
 
         private Integer value;
@@ -595,6 +611,10 @@ public class Constant {
             return value;
         }
 
+        public Long getLongValue(){
+            return ObjectUtils.isNotNull(value) ? value.longValue() : null;
+        }
+
         TASK_STS(Integer value) {
             this.value = value;
         }
@@ -701,4 +721,83 @@ public class Constant {
         }
     }
 
+    public enum SAFE_CODE {
+        /***
+         * 0:异常不可执行
+         */
+        REFUSE("0"),
+        /***
+         * 1:安全可执行
+         */
+        PASS("1");
+
+        private String code;
+
+        SAFE_CODE(String code) {
+            this.code = code;
+        }
+
+        public String getCode() {
+            return code;
+        }
+    }
+
+    public enum ID_TYPE {
+        ASNNO("ASNNO");
+
+        private String desc;
+
+        ID_TYPE(String desc) {
+            this.desc = desc;
+        }
+
+        public String getDesc() {
+            return desc;
+        }
+    }
+
+    public enum TERMINAL_CREATOR {
+
+        PDA("PDA"),
+
+        WEB("WEB");
+
+        private String desc;
+
+        TERMINAL_CREATOR(String desc) {
+            this.desc = desc;
+        }
+
+        public String getDesc() {
+            return desc;
+        }
+    }
+
+    public enum MATERIAL_TYPE {
+
+        Na2CO3("1","碳酸钠"),
+        NH42SO4("2", "硫酸铵"),
+        NaPO36("3", "六偏磷酸钠"),
+        CH3CH2OCS2Na("4", "乙黄药"),
+        C4H9O2PSSNH4("5", "丁铵黑药"),
+        C5H10OS2("6", "丁黄药");
+
+        public String getCode() {
+            return code;
+        }
+
+        public String getDesc() {
+            return desc;
+        }
+
+        private String code;
+
+        private String desc;
+
+        MATERIAL_TYPE(String code, String desc){
+            this.code = code;
+            this.desc = desc;
+        }
+
+    }
 }

+ 1 - 1
warewms-base/src/main/java/com/ruoyi/base/domain/vo/BaseLocationLotattVO.java

@@ -10,7 +10,7 @@ import java.util.Map;
  * User: andy.qu
  * Date: 2022/3/1
  */
-public class BaseLocationLotattVO extends BaseLocationInfo {
+public class BaseLocationLotattDTO extends BaseLocationInfo {
     private String sku;
     private Float qty;
     private LotattVO lotattVO;

+ 9 - 9
warewms-base/src/main/java/com/ruoyi/base/mapper/BaseLocationInfoMapper.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.dto.BaseLocationGuiDTO;
 import com.ruoyi.base.domain.dto.BaseLocationInfoSameColDTO;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.domain.vo.LotattVO;
 import org.apache.ibatis.annotations.Param;
 
@@ -91,7 +91,7 @@ public interface BaseLocationInfoMapper extends BaseMapper<BaseLocationInfo> {
      * @param baseLocationInfo
      * @return
      */
-    List<BaseLocationLotattVO> selectSortedLocationLotattListByZoneId(BaseLocationInfo baseLocationInfo);
+    List<BaseLocationLotattDTO> selectSortedLocationLotattListByZoneId(BaseLocationInfo baseLocationInfo);
 
     /**
      * 根据zoneId和批次属性查询库位信息带批次属性
@@ -100,7 +100,7 @@ public interface BaseLocationInfoMapper extends BaseMapper<BaseLocationInfo> {
      * @param lotatt
      * @return
      */
-    List<BaseLocationLotattVO> selectSortedLocationLotattListByZoneIdList(@Param("zoneId") List<Long> zoneId, @Param("warehouseId") Long warehouseId, @Param("lotatt") Map<String, String> lotatt);
+    List<BaseLocationLotattDTO> selectSortedLocationLotattListByZoneIdList(@Param("zoneId") List<Long> zoneId, @Param("warehouseId") Long warehouseId, @Param("lotatt") Map<String, String> lotatt);
 
     List<BaseLocationInfo> selectSortedLocationLotattListByZoneIdListOrderBy(@Param("zoneId") List<String> zoneId, @Param("warehouseId") Long warehouseId
             , @Param("lotatt") Map<String, String> lotatt,@Param("sku") String sku,@Param("orderByClause") String orderBy);
@@ -115,8 +115,8 @@ public interface BaseLocationInfoMapper extends BaseMapper<BaseLocationInfo> {
      * @param orderBy
      * @return
      */
-    List<BaseLocationLotattVO> selectAllocatingLocationAccordingConditionsOrderBy(@Param("zoneId") List<String> zoneId, @Param("warehouseId") Long warehouseId
-            ,@Param("bindSku") String bindSku,@Param("orderByClause") String orderBy);
+    List<BaseLocationLotattDTO> selectAllocatingLocationAccordingConditionsOrderBy(@Param("zoneId") List<String> zoneId, @Param("warehouseId") Long warehouseId
+            , @Param("bindSku") String bindSku, @Param("orderByClause") String orderBy);
 
     /**
      * 根据条件分配库存
@@ -128,8 +128,8 @@ public interface BaseLocationInfoMapper extends BaseMapper<BaseLocationInfo> {
      * @param orderBy
      * @return
      */
-    List<BaseLocationLotattVO> selectAllocatingInventoryAccordingConditionsOrderBy(@Param("zoneId") List<String> zoneId, @Param("warehouseId") Long warehouseId
-            , @Param("lotatt") Map<String, String> lotatt,@Param("sku") String sku,@Param("orderByClause") String orderBy);
+    List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(@Param("zoneId") List<String> zoneId, @Param("warehouseId") Long warehouseId
+            , @Param("lotatt") Map<String, String> lotatt, @Param("sku") String sku, @Param("orderByClause") String orderBy);
 
 
     /**
@@ -157,9 +157,9 @@ public interface BaseLocationInfoMapper extends BaseMapper<BaseLocationInfo> {
      * @param baseLocationInfo
      * @return
      */
-    List<BaseLocationLotattVO> queryByListInUserdeFine1(BaseLocationInfo baseLocationInfo);
+    List<BaseLocationLotattDTO> queryByListInUserdeFine1(BaseLocationInfo baseLocationInfo);
 
-    List<BaseLocationLotattVO> selectSortedLocationLotattListByLocationIdList(@Param("locationId") List<Long> locationId, @Param("warehouseId") Long warehouseId, @Param("lotatt") Map<String, String> lotatt, @Param("sku") String sku);
+    List<BaseLocationLotattDTO> selectSortedLocationLotattListByLocationIdList(@Param("locationId") List<Long> locationId, @Param("warehouseId") Long warehouseId, @Param("lotatt") Map<String, String> lotatt, @Param("sku") String sku);
 
     /**
      * 根据id查询库位库存信息

+ 30 - 7
warewms-base/src/main/java/com/ruoyi/base/service/IBaseLocationInfoService.java

@@ -1,14 +1,12 @@
 package com.ruoyi.base.service;
 
-import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.dto.BaseLocationInfoSameColDTO;
 import com.ruoyi.base.domain.vo.BasLocationTreeSelectVO;
 import com.ruoyi.base.domain.vo.BaseLocationLotattListVO;
-import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
+import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
 import com.ruoyi.base.domain.vo.TreeSelectVO;
 import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.redis.RedisKey;
 
 import java.util.List;
 import java.util.Map;
@@ -29,7 +27,7 @@ public interface IBaseLocationInfoService {
      * @param basLocationList
      * @return
      */
-    BaseLocationLotattVO checkTheSameColumnLocation(List<BaseLocationLotattVO> basLocationList);
+    BaseLocationLotattDTO checkTheSameColumnLocation(List<BaseLocationLotattDTO> basLocationList);
 
     /**
      * 出库校验同列任务任务状态和阻挡
@@ -37,7 +35,7 @@ public interface IBaseLocationInfoService {
      * @param basLocationList
      * @return
      */
-    BaseLocationLotattVO checkTheSameColumnLocation1(BaseLocationLotattVO baseLocationLotattVO,List<BaseLocationLotattVO> basLocationList);
+    BaseLocationLotattDTO checkTheSameColumnLocation1(BaseLocationLotattDTO baseLocationLotattVO, List<BaseLocationLotattDTO> basLocationList);
 
     /**
      * 查询库位信息
@@ -65,7 +63,7 @@ public interface IBaseLocationInfoService {
      * @param orderBy
      * @return
      */
-    List<BaseLocationLotattVO> selectAllocatingLocationAccordingConditionsOrderBy(List<String> zoneId
+    List<BaseLocationLotattDTO> selectAllocatingLocationAccordingConditionsOrderBy(List<String> zoneId
             , String bindSku
             , String orderBy);
 
@@ -78,7 +76,7 @@ public interface IBaseLocationInfoService {
      * @param orderBy
      * @return
      */
-    List<BaseLocationLotattVO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId
+    List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId
             , Map<String, String> lotatt
             , String sku
             , String orderBy);
@@ -327,4 +325,29 @@ public interface IBaseLocationInfoService {
      * @return
      */
     Boolean reSetLocationInfo(BaseLocationInfo baseLocationInfo);
+
+
+    /**
+     * 根据库位Id获取当前库位信息List
+     * @param zoneId
+     * @author chenyang
+     */
+    List<BaseLocationInfo> getBaseLocationInfoList(Long zoneId, List<Long> configLocationIdList);
+
+    /**
+     * 根据库位Id获取当前库位信息List
+     * @param zoneId
+     * @author chenyang
+     */
+    List<BaseLocationInfo> getBaseLocationInfoList(Long zoneId);
+
+    /**
+     *
+     * @param zoneId
+     * @param bindSku
+     * @param isEmpty
+     * @
+     * @return
+     */
+    List<BaseLocationInfo> selectLocationInfoList(Long zoneId, String bindSku, Boolean isEmpty, String stockStatus);
 }

+ 48 - 12
warewms-base/src/main/java/com/ruoyi/base/service/impl/BaseLocationInfoServiceImpl.java

@@ -1,5 +1,9 @@
 package com.ruoyi.base.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.ruoyi.base.constant.Constant;
@@ -11,22 +15,24 @@ import com.ruoyi.base.mapper.BaseLocationInfoMapper;
 import com.ruoyi.base.mapper.BaseLocationZoneMapper;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.utils.CommonUtils;
+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;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.security.web.PortResolverImpl;
 import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.function.LongFunction;
 import java.util.stream.Collectors;
 
 /**
@@ -45,6 +51,8 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
     private BaseLocationZoneMapper baseLocationZoneMapper;
     @Autowired
     private RedisCache redisCache;
+    @Autowired
+    private ISysConfigService sysConfigService;
 
     /**
      * 入库校验同列任务任务状态和阻挡
@@ -52,12 +60,12 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
      * @param basLocationList
      * @return
      */
-    public BaseLocationLotattVO checkTheSameColumnLocation(List<BaseLocationLotattVO> basLocationList) {
+    public BaseLocationLotattDTO checkTheSameColumnLocation(List<BaseLocationLotattDTO> basLocationList) {
         boolean isBlock = false; // 是否阻挡
-        BaseLocationLotattVO basLocation = null;
+        BaseLocationLotattDTO basLocation = null;
         //筛选2次 第2次去除同列占用和阻挡条件 todo 先筛选一次吧
         for (int i = 0; i < 1 && basLocation == null; i++) {
-            for (BaseLocationLotattVO location : basLocationList) {
+            for (BaseLocationLotattDTO location : basLocationList) {
                 //如果库位类型不为地堆则不用判断同列占用和阻挡
                 if (location.getLocationType().equals("1")) {
                     isBlock = true;
@@ -88,10 +96,10 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
      * @param basLocationList      满足要求的库位列表
      * @return
      */
-    public BaseLocationLotattVO checkTheSameColumnLocation1(BaseLocationLotattVO baseLocationLotattVO, List<BaseLocationLotattVO> basLocationList) {
+    public BaseLocationLotattDTO checkTheSameColumnLocation1(BaseLocationLotattDTO baseLocationLotattVO, List<BaseLocationLotattDTO> basLocationList) {
 
         //查同列所有库位
-        List<BaseLocationLotattVO> baseLocationInfos = baseLocationInfoMapper.queryByListInUserdeFine1(baseLocationLotattVO);
+        List<BaseLocationLotattDTO> baseLocationInfos = baseLocationInfoMapper.queryByListInUserdeFine1(baseLocationLotattVO);
 
         if (baseLocationInfos.size() == 1) {
             return baseLocationLotattVO;
@@ -114,7 +122,7 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
                 }
 
                 boolean isSuit = false;
-                for (BaseLocationLotattVO vo : basLocationList) {
+                for (BaseLocationLotattDTO vo : basLocationList) {
 
                     if (inStockByLocs.get(i).getId().equals(vo.getId())) {
 
@@ -156,13 +164,13 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
     }
 
     @Override
-    public List<BaseLocationLotattVO> selectAllocatingLocationAccordingConditionsOrderBy(List<String> zoneId, String bindSku, String orderBy) {
+    public List<BaseLocationLotattDTO> selectAllocatingLocationAccordingConditionsOrderBy(List<String> zoneId, String bindSku, String orderBy) {
         return baseLocationInfoMapper.selectAllocatingLocationAccordingConditionsOrderBy(zoneId, Constant.WAREHOUSE_ID, bindSku
                 , orderBy);
     }
 
     @Override
-    public List<BaseLocationLotattVO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId, Map<String, String> lotatt, String sku
+    public List<BaseLocationLotattDTO> selectAllocatingInventoryAccordingConditionsOrderBy(List<String> zoneId, Map<String, String> lotatt, String sku
             , String orderBy) {
         return baseLocationInfoMapper.selectAllocatingInventoryAccordingConditionsOrderBy(zoneId, Constant.WAREHOUSE_ID, lotatt, sku
                 , orderBy);
@@ -285,12 +293,17 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
         return baseLocationInfoMapper.selectSortedLocationListByZoneId(query);
     }
 
+
+
+
+
+
     @Override
     public List<BaseLocationLotattListVO> selectSortedLocatinListByZoneId(List<Long> locationId, Long warehouseId, Map<String, String> lotatt, String sku) {
         List<BaseLocationLotattListVO> result = new ArrayList<>();
-        List<BaseLocationLotattVO> locationLotattVOList = baseLocationInfoMapper.selectSortedLocationLotattListByLocationIdList(locationId, warehouseId, lotatt, sku);
+        List<BaseLocationLotattDTO> locationLotattVOList = baseLocationInfoMapper.selectSortedLocationLotattListByLocationIdList(locationId, warehouseId, lotatt, sku);
         BaseLocationLotattListVO current = null;
-        for (BaseLocationLotattVO vo : locationLotattVOList) {
+        for (BaseLocationLotattDTO vo : locationLotattVOList) {
             if (current == null || current.getId().longValue() != vo.getId().longValue()) {
                 current = new BaseLocationLotattListVO();
                 BeanUtils.copyProperties(vo, current);
@@ -516,4 +529,27 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
                 .eq(BaseLocationInfo::getId, baseLocationInfo.getId());
         return baseLocationInfoMapper.update(null, updateWrapper) == 1;
     }
+
+
+    @Override
+    public List<BaseLocationInfo> getBaseLocationInfoList(Long zoneId, List<Long> configLocationIdList) {
+        List<BaseLocationInfo> baseLocationInfoList = getBaseLocationInfoList(zoneId);
+        return baseLocationInfoList.stream().filter(item -> CollectionUtil.contains(configLocationIdList, item.getId())).collect(Collectors.toList());
+    }
+
+    @Override
+    public List<BaseLocationInfo> getBaseLocationInfoList(Long zoneId) {
+        return baseLocationInfoMapper.selectList(Wrappers.<BaseLocationInfo>lambdaQuery().eq(BaseLocationInfo::getZoneId, zoneId)
+                .eq(BaseLocationInfo::getWarehouseId, Constant.DEFAULT_WAREHOUSE_ID));
+    }
+
+
+    @Override
+    public List<BaseLocationInfo> selectLocationInfoList(Long zoneId, String bindSku, Boolean isEmpty, String stockStatus) {
+        return baseLocationInfoMapper.selectList(Wrappers.<BaseLocationInfo>lambdaQuery()
+                .eq(BaseLocationInfo::getZoneId, zoneId)
+                .eq(BaseLocationInfo::getBindSku, bindSku)
+                .eq(BaseLocationInfo::getIsEmpty, isEmpty? Constants.YES : Constants.NO)
+                .eq(BaseLocationInfo::getStockStatus, stockStatus));
+    }
 }

+ 1 - 1
warewms-base/src/main/resources/mapper/base/BaseLocationInfoMapper.xml

@@ -43,7 +43,7 @@
         <result property="zoneName" column="zone_name"/>
     </resultMap>
 
-    <resultMap type="BaseLocationLotattVO" id="BaseLocationInfoLotattResult">
+    <resultMap type="BaseLocationLotattDTO" id="BaseLocationInfoLotattResult">
         <result property="id" column="id"/>
         <result property="warehouseId" column="warehouse_id"/>
         <result property="zoneId" column="zone_id"/>

+ 35 - 9
warewms-hard/src/main/java/com/ruoyi/hard/xuankang/BeltLineClient.java

@@ -30,7 +30,7 @@ public class BeltLineClient {
      * 输送线命令
      */
     public enum CONVEYOR_LINE_COMMAND {
-        //读心跳
+        /*//读心跳
         READ_THE_HEART(1, 0, 1, 0),
         //读模式
         READ_THE_MODE(1, 1, 1, 0),
@@ -45,9 +45,27 @@ public class BeltLineClient {
         //写状态
         WRITE_THE_STATE(1, 11, 1, 0),
         //写通过方向
-        WRITE_THE_DIRECTION(1, 12, 1, 0);
+        WRITE_THE_DIRECTION(1, 12, 1, 0);*/
+
 
 
+        //读心跳
+        READ_THE_HEART(1, 0),
+        //读模式
+        READ_THE_MODE(1, 1),
+        //读状态
+        READ_THE_STATE(1, 2),
+        //读机械状态
+        READ_THE_MECHANICAL_STATUS(1, 3),
+        //写心跳
+        WRITE_THE_HEART(1, 9),
+        //写模式
+        WRITE_THE_MODE(1, 10),
+        //写状态
+        WRITE_THE_STATE(1, 11),
+        //写通过方向
+        WRITE_THE_DIRECTION(1, 12);
+
         /**
          * 从节点id
          */
@@ -59,17 +77,23 @@ public class BeltLineClient {
         /**
          * 读的长度
          */
-        private int value;
-        /**
+        /*private int value;
+        *//**
          * 写的值
-         */
-        private int value1;
+         *//*
+        private int value1;*/
 
-        CONVEYOR_LINE_COMMAND(int slaveId, int offset, int value, int value1) {
+        /*CONVEYOR_LINE_COMMAND(int slaveId, int offset, int value, int value1) {
             this.slaveId = slaveId;
             this.offset = offset;
             this.value = value;
             this.value1 = value1;
+        }*/
+
+
+        CONVEYOR_LINE_COMMAND(int slaveId, int offset) {
+            this.slaveId = slaveId;
+            this.offset = offset;
         }
 
         public int getSlaveId() {
@@ -80,13 +104,13 @@ public class BeltLineClient {
             return offset;
         }
 
-        public int getValue() {
+        /*public int getValue() {
             return value;
         }
 
         public int getValue1() {
             return value1;
-        }
+        }*/
 
     }
 
@@ -166,6 +190,8 @@ public class BeltLineClient {
         return write(WRITE_THE_DIRECTION.getSlaveId(), WRITE_THE_DIRECTION.getOffset(), i);
     }
 
+
+    /*****************************************************************/
     /**
      * 读的方法
      *