Преглед на файлове

桶装物料入库需求接口

ChenYang преди 1 година
родител
ревизия
1e3a738347

+ 10 - 9
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/InvAsnController.java

@@ -1,8 +1,10 @@
 package com.ruoyi.web.controller.warewms.ams;
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.ruoyi.ams.task.service.IWcsTaskService;
 import com.ruoyi.ams.xuankuang.domain.form.EmptyPalletLocForm;
 import com.ruoyi.ams.xuankuang.service.BucketWcsToWmsApiService;
+import com.ruoyi.ams.xuankuang.service.WcsTaskSubService;
 import com.ruoyi.ams.xuankuang.service.WcsToWmsApiService;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
@@ -11,9 +13,7 @@ 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 org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -39,12 +39,15 @@ public class InvAsnController {
     @Autowired
     private WcsToWmsApiService bucketWcsToWmsApiService;
 
+    @Autowired
+    private IWcsTaskService wcsTaskService;
+
     //TODO 李卫
     @ApiOperation("桶装入库:获取当前场景下的库位")
     @GetMapping(value = "/getBaseLocationInfoList")
     public AjaxResult getBaseLocationInfoList(Long zoneId, String locationSceneCode) {
         List<BaseLocationInfo> baseLocationInfoList = iBaseLocationInfoService.getBaseLocationInfoList(zoneId);
-        List<Long> bucketLocationIdList = wcsToWmsApiService.getBucketLocationIdList(locationSceneCode);
+        List<Long> bucketLocationIdList = wcsTaskService.getBucketLocationIdList(locationSceneCode);
         List<BaseLocationInfo> locationInfoList = baseLocationInfoList.stream()
                 .filter(item -> CollectionUtil.contains(bucketLocationIdList, item.getId())).collect(Collectors.toList());
         //获取库位的配置
@@ -52,12 +55,10 @@ public class InvAsnController {
     }
 
 
-
-
     //TODO 李卫
-    @ApiOperation("桶装入库:空托库")
-    @GetMapping(value = "/emptyPalletLoc")
-    public AjaxResult emptyPalletLoc(EmptyPalletLocForm emptyPalletLocForm) {
+    @ApiOperation("桶装入库:空托仓位入库")
+    @PostMapping(value = "/emptyPalletLoc")
+    public AjaxResult emptyPalletLoc(@RequestBody EmptyPalletLocForm emptyPalletLocForm) {
         return bucketWcsToWmsApiService.emptyPalletLoc(emptyPalletLocForm);
     }
 

+ 17 - 29
ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/PdaAgvCallController.java

@@ -8,11 +8,12 @@ import com.ruoyi.common.utils.StringUtils;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.aspectj.weaver.loadtime.Aj;
 import org.springframework.beans.factory.annotation.Autowired;
-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 javax.validation.Valid;
+import java.math.BigDecimal;
 
 /**
  * @author Jwk
@@ -23,45 +24,32 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 @RestController
 @RequestMapping("/pda/agvCall")
+@Valid
 public class PdaAgvCallController {
 
     @Autowired
     private AgvCallProxyService agvCallProxyService;
-    @Autowired
-    private IInvLotLocIdService invLotLocIdService;
-    /**
-     * 桶装入库
-     *
-     * @param agvCallForm
-     * @return
-     */
+
+
+
     @ApiOperation("桶装入库")
     @PostMapping("/theBucketIsLoadedIntoTheLibrary")
-    public AjaxResult theBucketIsLoadedIntoTheLibrary(@RequestBody AgvCallForm agvCallForm) {
-        if (StringUtils.isEmpty(agvCallForm.getLocationFrom())) {
-            return AjaxResult.error("起始库位为空!");
-        }
-        String locationFrom = agvCallForm.getLocationFrom();
-        String locationTo = agvCallForm.getLocationTo();
-        Double qty = agvCallForm.getAgvCallItemDTOList().get(0).getQty();
-        String palletNo = agvCallForm.getAgvCallItemDTOList().get(0).getLotattDTO().getLotatt07();
-        return agvCallProxyService.theBucketIsLoadedIntoTheLibrary(locationFrom, locationTo, qty,palletNo);
+    public AjaxResult theBucketIsLoadedIntoTheLibrary(String palletNo, @RequestParam String materialType,
+                                                      @RequestParam String sourceLocationId, @RequestParam Double quantity) {
+        agvCallProxyService.theBucketIsLoadedIntoTheLibrary(palletNo, materialType, sourceLocationId, quantity);
+        return AjaxResult.success("桶装入库下发任务成功");
     }
 
     /**
      * 桶装出库
      *
-     * @param agvCallForm
      * @return
      */
     @ApiOperation("桶装出库")
     @PostMapping("/barrelsOutOfStorage")
-    public AjaxResult barrelsOutOfStorage(@RequestBody AgvCallForm agvCallForm) {
-        if (StringUtils.isEmpty(agvCallForm.getLocationTo())) {
-            return AjaxResult.error("目标库位为空!");
-        }
-        String locationFrom = agvCallForm.getLocationFrom();
-        String locationTo = agvCallForm.getLocationTo();
-        return agvCallProxyService.barrelsOutOfStorage(locationFrom, locationTo,"","");
+    public AjaxResult barrelsOutOfStorage(@RequestParam String palletNo, @RequestParam String materialType,
+                                          @RequestParam String targetLocationId, @RequestParam  Double quantity) {
+        //agvCallProxyService.barrelsOutOfStorage(locationFrom, locationTo,"","");
+        return AjaxResult.success("桶装入库下发任务成功");
     }
 }

+ 0 - 3
ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WcsToWmsApiController.java

@@ -122,12 +122,9 @@ public class WcsToWmsApiController {
         return wcsToWmsApiService.outboundRequest(outboundForm);
     }
 
-    //移库 越库 入库出库
-
     /**
      * 当入库时因为物料袋破碎等原因,导致入库袋数减少,更新数据
      *
-     * @param outboundForm
      * @return
      */
     @ApiOperation("入库数量不足更新数据")

+ 0 - 8
ruoyi-admin/src/main/java/com/ruoyi/xuankuang/controller/WmsToWcsApiController.java

@@ -38,14 +38,6 @@ public class WmsToWcsApiController {
     }
 
 
-    //agv入库任务下发
-    @ApiOperation("入库任务下发")
-    @PostMapping(value = "/agvInTask")
-    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卸货完成
     @ApiOperation("回调卸货完成")
     @GetMapping(value = "/wmsAgvCallbackIntask/{taskNo}")

+ 6 - 0
ruoyi-admin/src/test/java/com/ruoyi/admin/test/base/WarehouseTest.java

@@ -31,6 +31,7 @@ import com.ruoyi.ams.order.service.IWmsDocOrderHeaderService;
 import com.ruoyi.ams.order.vo.StockOrderVO;
 import com.ruoyi.ams.task.service.IWcsTaskService;
 import com.ruoyi.ams.xuankuang.service.WcsTaskSubService;
+import com.ruoyi.ams.xuankuang.service.WmsDocAsnSubService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.BaseWarehouse;
@@ -371,9 +372,14 @@ public class WarehouseTest {
         redisTemplate.boundListOps("2").leftPop();
         System.out.println(redisTemplate.boundListOps("2").range(0, 10));
 
+
+
     }
 
 
+    @Autowired
+    private WmsDocAsnSubService wmsDocAsnSubService;
+
 
 
 

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

@@ -5,5 +5,5 @@ public interface SceneConstants {
     /**
      * 桶装物料的业务场景配置
      */
-    String STORAGE_BUCKET_SCENE = "STORAGE_BUCKET_SCENE_CONFIG";
+    String STORAGE_BUCKET_SCENE = "storage.bucket.scene.config";
 }

+ 7 - 0
warewms-ams/src/main/java/com/ruoyi/ams/task/service/IWcsTaskService.java

@@ -194,4 +194,11 @@ public interface IWcsTaskService {
      * @return
      */
     WcsTask selectWcsTask(String asnNo, String palletNo, Constant.TASK_STS taskStatusEnum);
+
+    /**
+     * 从桶装入库的配置信息中获取桶装物料的列表
+     * @param locationSceneCode
+     * @return
+     */
+    List<Long> getBucketLocationIdList(String locationSceneCode);
 }

+ 25 - 1
warewms-ams/src/main/java/com/ruoyi/ams/task/service/impl/WcsTaskServiceImpl.java

@@ -2,8 +2,11 @@ package com.ruoyi.ams.task.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.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.google.common.collect.Lists;
+import com.jhlabs.image.Histogram;
 import com.ruoyi.ams.agv.ndc.domain.AmsTask;
 import com.ruoyi.ams.agv.ndc.service.IAmsTaskService;
 import com.ruoyi.ams.box.service.IWmsBoxInfoService;
@@ -20,12 +23,14 @@ import com.ruoyi.ams.task.service.IWcsTaskService;
 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.common.utils.spring.SpringUtils;
 import com.ruoyi.common.utils.uuid.SnowflakeIdWorker;
 import com.ruoyi.hard.demo.AutoDoorClient;
+import com.ruoyi.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -34,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
 import java.lang.reflect.Method;
 import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * AGV任务Service业务层处理
@@ -67,6 +73,8 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
     private IAmsTaskService iAmsTaskService;
     @Autowired
     private AutoDoorClient autoDoorClient;
+    @Autowired
+    private ISysConfigService sysConfigService;
 
     //任务状态翻译
     private String codeConvert(int code) {
@@ -534,11 +542,27 @@ public class WcsTaskServiceImpl implements IWcsTaskService {
         WcsTask wcsTask = new WcsTask();
         wcsTask.setExt1(asnNo);
         wcsTask.setExt2(palletNo);
-        wcsTask.setState(Long.parseLong(String.valueOf(taskStatusEnum)));
+        wcsTask.setState(Long.parseLong(String.valueOf(taskStatusEnum.getValue())));
         List<WcsTask> wcsTaskList = wcsTaskMapper.selectWcsTaskList(wcsTask);
         return CollectionUtil.isNotEmpty(wcsTaskList) ? wcsTaskList.get(0) : new WcsTask();
     }
 
+    /**
+     * 根据场景code返回库位列表
+     * @param subSceneCode
+     * @return
+     * //TODO 李卫
+     */
+    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());
+    }
 
     /**
      * 查询AGV任务

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

@@ -1,14 +1,30 @@
 package com.ruoyi.ams.xuankuang.service;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.lang.Assert;
+import cn.hutool.core.util.ObjectUtil;
+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;
+import com.ruoyi.ams.asn.service.IWmsDocAsnHeaderService;
 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.inv.service.IInvLotLocIdService;
+import com.ruoyi.ams.task.service.IWcsTaskService;
+import com.ruoyi.ams.xuankuang.domain.form.AgvInTaskForm;
+import com.ruoyi.ams.xuankuang.domain.vo.WcsResponseVo;
 import com.ruoyi.base.constant.Constant;
+import com.ruoyi.base.domain.BaseLocationInfo;
+import com.ruoyi.base.domain.BaseSku;
 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.core.domain.AjaxResult;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.service.ISysConfigService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -29,47 +45,73 @@ public class AgvCallProxyService {
     @Autowired
     private IBusinessService iBusinessService;
     @Autowired
-    private IInvLotLocIdService invLotLocIdService;
-    @Autowired
-    private IBaseLocationInfoService baseLocationInfoService;
-    @Autowired
     BaseLocationInfoSubService baseLocationInfoSubService;
     @Autowired
     WmsDocAsnSubService wmsDocAsnSubService;
+    @Autowired
+    private IBaseSkuService iBaseSkuService;
+    @Autowired
+    private ISysConfigService sysConfigService;
+
+
+    @Autowired
+    private IdSequenceUtils idSequenceUtils;
+    @Autowired
+    private IWmsDocAsnHeaderService iWmsDocAsnHeaderService;
+    @Autowired
+    private IWmsDocAsnDetailsService iWmsDocAsnDetailsService;
+    @Autowired
+    private WcsTaskSubService wcsTaskSubService;
+    @Autowired
+    private WmsToWcsApiService wmsToWcsApiService;
+    @Autowired
+    private IBaseLocationInfoService iBaseLocationInfoService;
+    @Autowired
+    private InvLotLocIdSubService invLotLocIdSubService;
+    @Autowired
+    private IWcsTaskService iWcsTaskService;
+
     /**
      * 桶装入库
-     *
-     * @param locationFrom
-     * @param locationTo
      * @return
      */
-    public AjaxResult theBucketIsLoadedIntoTheLibrary(String locationFrom, String locationTo, Double qty,String palletNo) {
-        // todo 查询是否有可用库位,无可用库位直接结束,pda提示仓库内无可用库位
-        String sku = "C4H9O2PSSNH4";
-        BaseLocationLotattDTO baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(sku);
-        if (baseLocationLotattVO == null){
-            AjaxResult.error("没有可以推荐的目标库位!");
-        }
-        AgvCallDTO agvCallDTO = new AgvCallDTO();
-        agvCallDTO.setLocationFrom(locationFrom);
-        agvCallDTO.setLocationTo(locationTo);
-        List<AgvCallItemDTO> agvCallItemDTOList = new ArrayList<>();
-        AgvCallItemDTO agvCallItemDTO = new AgvCallItemDTO();
-        LotattDTO lotattDTO = new LotattDTO();
-        agvCallItemDTO.setSku("C4H9O2PSSNH4"); // 丁铵黑药
-        agvCallItemDTO.setQty(qty);
-        lotattDTO.setLotatt07(palletNo);
-        agvCallItemDTO.setLotattDTO(lotattDTO);
-        agvCallItemDTOList.add(agvCallItemDTO);
-        agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
-        AjaxResult ajaxResult = iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.TWO.getValue(), agvCallDTO);
-        if (ajaxResult.isSuccess()){
-            //sourceLocationId  起始库位
-            wmsDocAsnSubService.agvInTask(palletNo, "5", 1L, new BigDecimal(qty));
+    public void theBucketIsLoadedIntoTheLibrary(String palletNo, String materialType,
+                                                      String agvSourceLocationId, Double 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());
+        Assert.isTrue(ObjectUtil.isNotNull(quantity) && quantity > 0, "quantity is illegal");
+        BigDecimal quantityDecimal = new BigDecimal(quantity);
+
+        //2. 获取agv的库位,并创建agv的wcs任务
+        String agvTargetLocationId = String.valueOf(getAgvTargetLocationId("bucketLocationIdList"));
+        String agvTaskNo = IdWorker.getIdStr();
+        wcsTaskSubService.addWcsTask(agvTaskNo, agvSourceLocationId, agvTargetLocationId,
+                asnNo, palletNo, Constant.TASK_STS.TASK_CREATE.getLongValue(), "agv入库任务下发");
+
+        //3.入库单创建
+        WmsDocAsnHeader wmsDocAsnHeader =
+                iWmsDocAsnHeaderService.createAsnHeader(asnNo, Constant.ASN_TYP.TZ.getValue(), Constant.ASN_STS.STS00.getValue());
+        WmsDocAsnDetails wmsDocAsnDetail =
+                iWmsDocAsnDetailsService.createAsnDetail(asnNo, baseSku.getSku(), quantityDecimal);
+
+        //4. 根据入库单进行agv的任务下发,通知wcs并生成wcs任务;agv的目标点则是wcs任务的起始点位
+        String taskNo = IdWorker.getIdStr();
+        WcsResponseVo wcsResponseVo = noticeBucketIntoLocTask(taskNo, agvTargetLocationId, asnNo, palletNo, materialType, quantity);
+
+        if (!wcsResponseVo.isSuccess()) {
+            wmsDocAsnHeader.setNotes(wcsResponseVo.getMessage());
+            iWmsDocAsnHeaderService.updateWmsDocAsnHeader(wmsDocAsnHeader);
+            wcsTaskSubService.callBack(taskNo, Constant.TASK_STS.TASK_CANCEL.getValue(), null);
         }
-        return ajaxResult;
+        wmsDocAsnHeader.setAsnStatus(Constant.ASN_STS.STS10.getValue());
+        wmsDocAsnDetail.setLineStatus(Constant.ASN_STS.STS10.getValue());
+        iWmsDocAsnDetailsService.updateWmsDocAsnDetails(wmsDocAsnDetail);
+        iWmsDocAsnHeaderService.updateWmsDocAsnHeader(wmsDocAsnHeader);
     }
 
+
     /**
      * 桶装出库
      *
@@ -92,4 +134,47 @@ public class AgvCallProxyService {
         agvCallDTO.setAgvCallItemDTOList(agvCallItemDTOList);
         return iBusinessService.agvCall(Constant.FLOW_CONFIG_ID.ONE.getValue(), agvCallDTO);
     }
+
+    private WcsResponseVo noticeBucketIntoLocTask(String taskNo, String bucketCacheLocationId, String asnNo, String palletNo, String materialType, Double quantity) {
+
+        BaseSku baseSku = iBaseSkuService.selectBaseSkuByMaterialType(materialType);
+        Assert.isTrue(ObjectUtil.isNotNull(baseSku), "baseSku is null");
+        // 1.推荐目标库位
+        BaseLocationLotattDTO baseLocationLotatt = baseLocationInfoSubService.recommendAReceiptLocation(baseSku.getSku());
+        Assert.isTrue(ObjectUtil.isNotNull(baseLocationLotatt), "baseLocationLotatt is null");
+        // 2.入库缓存位生成库存
+        invLotLocIdSubService.initInv(bucketCacheLocationId, baseSku.getSku(), palletNo, asnNo, taskNo, quantity);
+
+        // 3.生成任务
+        wcsTaskSubService.addWcsTask(taskNo, bucketCacheLocationId
+                , String.valueOf(baseLocationLotatt.getId()), asnNo, palletNo, Constant.TASK_STS.TASK_PUBILSH.getLongValue(), "四向车入库任务");
+        //4.同步当前的wcs任务
+        AgvInTaskForm agvInTaskForm = assemblyAgvInTaskForm(taskNo, asnNo, materialType, quantity, palletNo, baseLocationLotatt);
+        return wmsToWcsApiService.wmsAgvInTask(agvInTaskForm);
+    }
+
+
+    private AgvInTaskForm assemblyAgvInTaskForm(String taskNo, String asnNo, String materialType, Double quantity, String palletNo, BaseLocationLotattDTO baseLocationLotatt) {
+        AgvInTaskForm agvInTaskForm = new AgvInTaskForm();
+        agvInTaskForm.setTaskNo(taskNo);
+        agvInTaskForm.setAgvId("1");
+        agvInTaskForm.setMaterial(Integer.valueOf(materialType));
+        agvInTaskForm.setDocNo(asnNo);
+        agvInTaskForm.setNum(quantity.intValue());
+        agvInTaskForm.setPalletId(palletNo);
+        agvInTaskForm.setRow(Integer.valueOf(baseLocationLotatt.getRowIndex()));
+        agvInTaskForm.setCol(Integer.valueOf(baseLocationLotatt.getRowNo()));
+        agvInTaskForm.setFloor(Integer.valueOf(baseLocationLotatt.getShiftNo()));
+        return agvInTaskForm;
+    }
+
+
+    private Long getAgvTargetLocationId(String subSceneCode) {
+        List<Long> bucketLocationIdList = iWcsTaskService.getBucketLocationIdList(subSceneCode);
+        Assert.isTrue(CollectionUtil.isNotEmpty(bucketLocationIdList), "bucketLocationIdList is empty");
+        BaseLocationInfo agvTargetLocationInfo = iBaseLocationInfoService.selectBaseLocationInfoById(bucketLocationIdList.get(0));
+        return ObjectUtil.isNotNull(agvTargetLocationInfo) ? agvTargetLocationInfo.getId() : Constant.DRUM_CONNECTORS;
+    }
+
+
 }

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

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
+import com.ruoyi.ams.task.service.IWcsTaskService;
 import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.domain.vo.BaseLocationLotattDTO;
@@ -32,10 +33,10 @@ public class BucketWcsToWmsApiService extends WcsToWmsApiService {
     private IBaseLocationInfoService baseLocationInfoService;
 
     @Autowired
-    private WcsToWmsApiService wcsToWmsApiService;
+    private IInvLotLocIdService invLotLocIdService;
 
     @Autowired
-    private IInvLotLocIdService invLotLocIdService;
+    private IWcsTaskService iWcsTaskService;
 
     /**
      * 入库分配库位
@@ -50,7 +51,7 @@ public class BucketWcsToWmsApiService extends WcsToWmsApiService {
                         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<Long> bucketLocationIdList = iWcsTaskService.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());
@@ -72,7 +73,7 @@ public class BucketWcsToWmsApiService extends WcsToWmsApiService {
                         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<Long> bucketLocationIdList = iWcsTaskService.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());

+ 0 - 55
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WcsToWmsApiService.java

@@ -569,61 +569,6 @@ public class WcsToWmsApiService {
         return AjaxResult.success();
     }
 
-    /**
-     * 桶装入库预备创建库存
-     * @param sku
-     * @param sourceLocationId
-     * @param asnNo
-     * @param palletNo
-     * @param quantity
-     * @return
-     */
-    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);
-    }
-
-
-    public LocationCoordDTO getInvInfoByTask(WcsTask wcsTask) {
-        if(ObjectUtil.isNotNull(wcsTask) && StringUtils.isNotBlank(wcsTask.getTaskNo())) return new LocationCoordDTO();
-        return assemblyLocationCoordInfo(wcsTask.getLocationTo(), wcsTask.getTaskNo());
-    }
-
-    /**
-     * 根据场景code返回库位列表
-     * @param subSceneCode
-     * @return
-     * //TODO 李卫
-     */
-    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());
-    }
-
-    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;
-    }
 
     /**
      * 安全交握,Wcs回调通知agv是否可以执行

+ 0 - 81
warewms-ams/src/main/java/com/ruoyi/ams/xuankuang/service/WmsDocAsnSubService.java

@@ -122,67 +122,7 @@ public class WmsDocAsnSubService {
 
     }
 
-    /**
-     * agv入库任务下发
-     * @return
-     */
-    //TODO 李卫 synchronized
-    @Transactional
-    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 = wcsTaskService.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);
-        }
-        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;
-    }
 
     /**
      * agv回调wcs卸货完成
@@ -204,25 +144,4 @@ public class WmsDocAsnSubService {
         return AjaxResult.success();
     }
 
-    /**
-     * 生成入库单方法
-     *
-     * @return
-     */
-    public String generateAnOutboundOrder(String sku, BigDecimal qty) {
-        // 生成单头
-        WmsDocAsnHeader wmsDocAsnHeader = new WmsDocAsnHeader();
-        String asnNo = idSequenceUtils.generateId("ASNNO");
-        wmsDocAsnHeader.setAsnNo(asnNo);
-        wmsDocAsnHeader.setEdiSendFlag("N");
-        wmsDocAsnHeader.setAsnType(Constant.ASN_TYP.TZ.getValue());
-        wmsDocAsnHeader.setCreateTime(new Date());
-        wmsDocAsnHeader.setCreateBy("PDA");
-        wmsDocAsnHeader.setAsnStatus(Constant.ASN_STS.STS00.getValue());
-        wmsDocAsnHeaderMapper.insertWmsDocAsnHeader(wmsDocAsnHeader);
-        //生成明细
-
-        return asnNo;
-    }
-
 }

+ 4 - 6
warewms-base/src/main/java/com/ruoyi/base/constant/Constant.java

@@ -43,12 +43,7 @@ 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;
 
@@ -291,6 +286,9 @@ public class Constant {
          */
         STS00("00"),
 
+        /**
+         * 同步成功
+         */
         STS10("10"),
 
         STS20("20"),

+ 5 - 2
warewms-base/src/main/java/com/ruoyi/base/domain/BaseLocationInfo.java

@@ -1,9 +1,10 @@
 package com.ruoyi.base.domain;
 
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 
 /**
  * 库位信息对象 base_location_info
@@ -31,6 +32,7 @@ public class BaseLocationInfo extends BaseEntity {
      * 区域id
      */
     @Excel(name = "库区名称")
+    @TableField(exist = false)
     private String zoneName;
 
     /**
@@ -152,6 +154,7 @@ public class BaseLocationInfo extends BaseEntity {
     @Excel(name = "绑定物料编号")
     private String userdefine10;
 
+    @TableField(exist = false)
     private String orderByClause;
 
     public void setId(Long id) {