|
@@ -1,7 +1,9 @@
|
|
|
package com.ruoyi.ams.xuankuang.service;
|
|
|
|
|
|
import com.ruoyi.ams.config.domain.dto.AgvCallDTO;
|
|
|
+import com.ruoyi.ams.config.domain.dto.LotattDTO;
|
|
|
import com.ruoyi.ams.inv.service.IInvLotLocIdService;
|
|
|
+import com.ruoyi.ams.order.domain.WmsDocOrderDetails;
|
|
|
import com.ruoyi.ams.task.domain.WcsTask;
|
|
|
import com.ruoyi.ams.task.service.IWcsTaskService;
|
|
|
import com.ruoyi.ams.xuankuang.domain.form.EmptyPalletLocForm;
|
|
@@ -10,6 +12,7 @@ import com.ruoyi.ams.xuankuang.domain.form.TaskStatusForm;
|
|
|
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.BaseSku;
|
|
|
import com.ruoyi.base.domain.vo.BaseLocationLotattVO;
|
|
|
import com.ruoyi.base.service.IBaseLocationInfoService;
|
|
|
import com.ruoyi.base.service.IBaseSkuService;
|
|
@@ -19,6 +22,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static com.ruoyi.ams.xuankuang.service.BaseLocationInfoSubService.OUT_ZONES;
|
|
|
+
|
|
|
/**
|
|
|
* @author HuKang
|
|
|
* @version 1.0
|
|
@@ -64,7 +73,7 @@ public class WcsToWmsApiService {
|
|
|
// 任务号
|
|
|
String wcsNo = stackingCompletion.getWcsNo();
|
|
|
|
|
|
- log.info(String.valueOf(reportType),palletNo,materialType,sku,qty,asnNo,wcsNo);
|
|
|
+ log.info(String.valueOf(reportType), palletNo, materialType, sku, qty, asnNo, wcsNo);
|
|
|
|
|
|
// 判重
|
|
|
WcsTask wcsTaskQuery = new WcsTask();
|
|
@@ -126,67 +135,86 @@ public class WcsToWmsApiService {
|
|
|
// 任务号
|
|
|
String wcsNo = emptyPalletLocForm.getWcsNo();
|
|
|
|
|
|
- if (taskType == 0){
|
|
|
+ if (taskType == 0) {
|
|
|
return AjaxResult.error("未传入空托仓位请求类型");
|
|
|
}
|
|
|
|
|
|
- // 判重
|
|
|
- WcsTask wcsTaskQuery = new WcsTask();
|
|
|
- wcsTaskQuery.setExt1("");
|
|
|
- wcsTaskQuery.setExt2("");
|
|
|
- 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);
|
|
|
- }
|
|
|
- BaseLocationLotattVO baseLocationLotattVO = new BaseLocationLotattVO();
|
|
|
if (taskType == 1) {
|
|
|
- // 推荐目标库位
|
|
|
- baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(Constant.PALLET_TYPE);
|
|
|
- if (baseLocationLotattVO == null) {
|
|
|
- AjaxResult.error("没有可以推荐的目标库位!");
|
|
|
+ // 判重
|
|
|
+ WcsTask wcsTaskQuery = new WcsTask();
|
|
|
+ wcsTaskQuery.setExt1("");
|
|
|
+ wcsTaskQuery.setExt2("");
|
|
|
+ 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);
|
|
|
}
|
|
|
- } else {
|
|
|
- baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(Constant.PALLET_TYPE1);
|
|
|
+ BaseLocationLotattVO baseLocationLotattVO = new BaseLocationLotattVO();
|
|
|
+
|
|
|
+ // 推荐目标库位
|
|
|
+ baseLocationLotattVO = baseLocationInfoSubService.recommendAReceiptLocation(Constant.PALLET_TYPE);
|
|
|
if (baseLocationLotattVO == null) {
|
|
|
AjaxResult.error("没有可以推荐的目标库位!");
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- // 生成任务
|
|
|
- String taskNo = "";
|
|
|
- AjaxResult ajaxResult = wcsTaskSubService.addWcsTask(Constant.LOC_STAGE_CACHE.toString()
|
|
|
- , baseLocationLotattVO.getId().toString()
|
|
|
- , ""
|
|
|
- , ""
|
|
|
- , wcsNo);
|
|
|
- if (!ajaxResult.isSuccess()) {
|
|
|
- return ajaxResult;
|
|
|
- }
|
|
|
- taskNo = ajaxResult.get("data").toString();
|
|
|
- if (taskType ==1){
|
|
|
+
|
|
|
+ // 生成任务
|
|
|
+ String taskNo = "";
|
|
|
+ AjaxResult ajaxResult = wcsTaskSubService.addWcsTask(Constant.LOC_STAGE_CACHE.toString()
|
|
|
+ , baseLocationLotattVO.getId().toString()
|
|
|
+ , ""
|
|
|
+ , ""
|
|
|
+ , wcsNo);
|
|
|
+ if (!ajaxResult.isSuccess()) {
|
|
|
+ return ajaxResult;
|
|
|
+ }
|
|
|
+ taskNo = ajaxResult.get("data").toString();
|
|
|
// 入库缓存位生成库存
|
|
|
InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), Constant.PALLET_TYPE, "", "", taskNo, 1.0);
|
|
|
- }else {
|
|
|
- // 入库缓存位生成库存
|
|
|
- InvLotLocIdSubService.initInv(Constant.LOC_STAGE_CACHE.toString(), Constant.PALLET_TYPE1, "", "", taskNo, 1.0);
|
|
|
+ // 反馈
|
|
|
+ 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);
|
|
|
}
|
|
|
- // 反馈
|
|
|
- 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);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ BaseSku baseSku = iBaseSkuService.selectBaseSkuByCustomerId(Constant.CUSTOMER_ID, Constant.PALLET_TYPE);
|
|
|
+
|
|
|
+ String pallentNo = baseLocationLotattVO.getLotattVO().getLotatt07();
|
|
|
+ String locationFrom = baseLocationLotattVO.getLocationNo();
|
|
|
+
|
|
|
+ // 生成四向车出库任务
|
|
|
+ AjaxResult ajaxResult = wcsTaskSubService.addWcsOutTask(locationFrom, Constant.LOC_SORTATION_CACHE.toString(), "", pallentNo, wcsNo);
|
|
|
+ LocationCoordinateVo locationCoordinateVo1 = new LocationCoordinateVo();
|
|
|
+ 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()));
|
|
|
+ return AjaxResult.success("仓位获取成功", locationCoordinateVo1);
|
|
|
+ }
|
|
|
+ return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -203,5 +231,30 @@ public class WcsToWmsApiService {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 匹配库存
|
|
|
+ *
|
|
|
+ * @param baseLocationLotattVOS
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public synchronized BaseLocationLotattVO filterInv1(List<BaseLocationLotattVO> baseLocationLotattVOS) {
|
|
|
|
|
|
+ for (BaseLocationLotattVO baseLocationLotattVO : baseLocationLotattVOS) {
|
|
|
+ //库存数量
|
|
|
+ BigDecimal qty = new BigDecimal(1);
|
|
|
+ String sku = Constant.PALLET_TYPE;
|
|
|
+ if (!sku.equals(Constant.PALLET_TYPE)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int i = qty.compareTo(BigDecimal.ONE);
|
|
|
+ if (i == 0) {
|
|
|
+ return baseLocationLotattVO;
|
|
|
+ } else if (i > 0) {
|
|
|
+ return baseLocationLotattVO;
|
|
|
+ } else if (i < 0) {
|
|
|
+ return baseLocationLotattVO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return baseLocationLotattVOS.get(0);
|
|
|
+ }
|
|
|
}
|