|
@@ -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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|