Przeglądaj źródła

库位库存占用(PDA,PC)

k 2 lat temu
rodzic
commit
c125ccf374

+ 26 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/ams/InvLotLocIdController.java

@@ -81,6 +81,32 @@ public class InvLotLocIdController extends BaseController {
         return invLotLocIdService.clear(locationId, Constant.WAREHOUSE_ID, getUsername());
     }
 
+    /**
+     * 库位任务状态调整
+     *
+     * @param locationId
+     * @return
+     */
+    @Log(title = "PDA库位状态调整", businessType = BusinessType.UPDATE)
+    @PostMapping("/setStockStatus")
+    public AjaxResult adjLocationStockStatus(String locationId) {
+
+        return invLotLocIdService.adjLocationStockStatus(locationId, Constant.WAREHOUSE_ID, getUsername());
+    }
+
+    /**
+     * 库存是否有货状态调整
+     *
+     * @param locationId
+     * @return
+     */
+    @Log(title = "PDA库存状态调整", businessType = BusinessType.UPDATE)
+    @PostMapping("/setIsEmpty")
+    public AjaxResult adjLocationIsEmpty(String locationId) {
+
+        return invLotLocIdService.adjLocationIsEmpty(locationId, Constant.WAREHOUSE_ID, getUsername());
+    }
+
     /**
      * 导出库位库存信息列表
      */

+ 8 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warewms/pda/PdaInvLotLocIdController.java

@@ -64,30 +64,30 @@ public class PdaInvLotLocIdController {
     }
 
     /**
-     * 库位状态调整
+     * 库位任务状态调整
      *
      * @param locationId
      * @param updateBy
      * @return
      */
     @Log(title = "PDA库位状态调整", businessType = BusinessType.UPDATE)
-    @PostMapping("/setStatusLoc")
-    public AjaxResult lockOrUnlockLocStatus(String locationId, String updateBy) {
+    @PostMapping("/setStockStatus")
+    public AjaxResult adjLocationStockStatus(String locationId, String updateBy) {
 
-        return AjaxResult.success("");
+        return invLotLocIdService.adjLocationStockStatus(locationId, Constant.WAREHOUSE_ID, updateBy);
     }
 
     /**
-     * 库存状态调整
+     * 库存是否有货状态调整
      *
      * @param locationId
      * @param updateBy
      * @return
      */
     @Log(title = "PDA库存状态调整", businessType = BusinessType.UPDATE)
-    @PostMapping("/setStatusInv")
-    public AjaxResult lockOrUnlockInvStatus(String locationId, String updateBy) {
+    @PostMapping("/setIsEmpty")
+    public AjaxResult adjLocationIsEmpty(String locationId, String updateBy) {
 
-        return AjaxResult.success("");
+        return invLotLocIdService.adjLocationIsEmpty(locationId, Constant.WAREHOUSE_ID, updateBy);
     }
 }

+ 14 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/IInvLotLocIdService.java

@@ -83,6 +83,20 @@ public interface IInvLotLocIdService {
      */
     AjaxResult clear(String locationId, Long warehouseId, String updateBy);
 
+    /**
+     * 库位任务状态调整
+     *
+     * @return
+     */
+    AjaxResult adjLocationStockStatus(String locationId, Long warehouseId, String updateBy);
+
+    /**
+     * 库存是否有货状态调整
+     *
+     * @return
+     */
+    AjaxResult adjLocationIsEmpty(String locationId, Long warehouseId, String updateBy);
+
     /**
      * 新增库位库存信息
      *

+ 47 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/service/impl/InvLotLocIdServiceImpl.java

@@ -10,11 +10,13 @@ import com.ruoyi.ams.inv.domain.vo.InvLotLocIdLotattVO;
 import com.ruoyi.ams.inv.mapper.InvLotAttMapper;
 import com.ruoyi.ams.inv.mapper.InvLotLocIdMapper;
 import com.ruoyi.ams.inv.service.IInvLotLocIdService;
+import com.ruoyi.base.constant.Constant;
 import com.ruoyi.base.domain.BaseLocationInfo;
 import com.ruoyi.base.service.IBaseLocationInfoService;
 import com.ruoyi.base.service.SysIdsequenceService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -30,6 +32,7 @@ import java.util.List;
  * @author andy
  * @date 2022-03-03
  */
+@Slf4j
 @Service
 public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
 
@@ -219,6 +222,50 @@ public class InvLotLocIdServiceImpl implements IInvLotLocIdService {
         return AjaxResult.success("操作成功!");
     }
 
+    @Override
+    public AjaxResult adjLocationStockStatus(String locationId, Long warehouseId, String updateBy) {
+        Long id; // 库位ID
+        BaseLocationInfo baseLocationInfo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationId, warehouseId);
+        if (baseLocationInfo == null) {
+            return AjaxResult.error("不存在对应库位:" + locationId);
+        }
+        id = baseLocationInfo.getId();
+        // 动态修改任务状态 空闲|占用
+        Boolean isIdle = baseLocationInfoService.verifyLocationIsIdle(locationId, warehouseId); // isIdle 是否空闲
+        Boolean result = isIdle ? baseLocationInfoService.lockLocationStockStatus(id, warehouseId, updateBy)
+                : baseLocationInfoService.unLockLocationStockStatus(id, warehouseId, updateBy);
+        if (!result) {
+            return AjaxResult.success("修改库位任务状态失败!");
+        }
+
+        log.error("【修改库位任务占用状态】:" + baseLocationInfo.getLocationNo() + ","
+                + (isIdle ? Constant.STOCK_STATUS.STOCK10.getValue() : Constant.STOCK_STATUS.STOCK00.getValue()));
+
+        return AjaxResult.success("操作成功!");
+    }
+
+    @Override
+    public AjaxResult adjLocationIsEmpty(String locationId, Long warehouseId, String updateBy) {
+        Long id; // 库位ID
+        BaseLocationInfo baseLocationInfo = baseLocationInfoService.selectBaseLocationInfoByIdOrNo(locationId, warehouseId);
+        if (baseLocationInfo == null) {
+            return AjaxResult.error("不存在对应库位:" + locationId);
+        }
+        id = baseLocationInfo.getId();
+        // 动态修改库存占用状态 有货|无货
+        Boolean isInStock = baseLocationInfoService.verifyLocationIsInStock(locationId, warehouseId); // isInStock 是否有货
+        Boolean result = isInStock ? baseLocationInfoService.unOccupyLocationIsEmpty(id, warehouseId, updateBy)
+                : baseLocationInfoService.occupyLocationIsEmpty(id, warehouseId, updateBy);
+        if (!result) {
+            return AjaxResult.success("修改库位库存占用状态失败!");
+        }
+
+        log.error("【修改库位库存占用状态】:" + baseLocationInfo.getLocationNo() + ","
+                + (isInStock ? Constant.IS_YES.N.getValue() : Constant.IS_YES.Y.getValue()));
+
+        return AjaxResult.success("操作成功!");
+    }
+
     /**
      * 新增库位库存信息
      *

+ 23 - 16
warewms-base/src/main/java/com/ruoyi/base/service/IBaseLocationInfoService.java

@@ -9,6 +9,7 @@ import com.ruoyi.base.domain.vo.BasLocationTreeSelectVO;
 import com.ruoyi.base.domain.vo.BaseLocationLotattListVO;
 import com.ruoyi.base.domain.vo.TreeSelectVO;
 import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
 
 /**
  * 库位信息Service接口
@@ -147,10 +148,10 @@ public interface IBaseLocationInfoService {
     Boolean verifyLocationIsIdle(String locationId, Long warehouseId);
 
     /**
-     * 验证库位是否有库存
+     * 验证库位库存是否为占用
      *
      * @param locationId
-     * @return true 有货
+     * @return true 占用
      */
     Boolean verifyLocationIsInStock(String locationId, Long warehouseId);
 
@@ -165,25 +166,25 @@ public interface IBaseLocationInfoService {
     boolean lockLocationStockStatus(Long id, Long warehouseId, String updateBy);
 
     /**
-     * 锁库位(起始和目标)
+     * 锁库位
      *
-     * @param locationFromId
-     * @param locationToId
+     * @param id
      * @param warehouseId
      * @param updateBy
      * @return
      */
-    boolean lockLocationStockStatus(Long locationFromId, Long locationToId, Long warehouseId, String updateBy);
+    boolean unLockLocationStockStatus(Long id, Long warehouseId, String updateBy);
 
     /**
-     * 锁库位
+     * 锁库位(起始和目标)
      *
-     * @param id
+     * @param locationFromId
+     * @param locationToId
      * @param warehouseId
      * @param updateBy
      * @return
      */
-    boolean unLockLocationStockStatus(Long id, Long warehouseId, String updateBy);
+    boolean lockLocationStockStatus(Long locationFromId, Long locationToId, Long warehouseId, String updateBy);
 
     /**
      * 解锁库位(起始和目标)
@@ -197,27 +198,33 @@ public interface IBaseLocationInfoService {
     boolean unLockLocationStockStatus(Long locationFromId, Long locationToId, Long warehouseId, String updateBy);
 
     /**
-     * 修改库位状态为空闲无货
+     * 占领库位状态(是否有货状态)
      *
      * @param id
      * @param warehouseId
      * @param updateBy
      * @return
      */
-    boolean updateLocationIdleAndEmpty(Long id, Long warehouseId, String updateBy);
+    boolean occupyLocationIsEmpty(Long id, Long warehouseId, String updateBy);
 
     /**
-     * 修改库位任务占用状态和库位是否有货状态
+     * 放开占领库位状态(是否有货状态)
      *
      * @param id
      * @param warehouseId
      * @param updateBy
-     * @param stockStatus
-     * @param isYes
      * @return
      */
-    boolean updateLocationStockStatusAndIsEmpty(Long id, Long warehouseId, String updateBy
-            , Constant.STOCK_STATUS stockStatus, Constant.IS_YES isYes);
+    boolean unOccupyLocationIsEmpty(Long id, Long warehouseId, String updateBy);
 
+    /**
+     * 修改库位状态为空闲无货
+     *
+     * @param id
+     * @param warehouseId
+     * @param updateBy
+     * @return
+     */
+    boolean updateLocationIdleAndEmpty(Long id, Long warehouseId, String updateBy);
 
 }

+ 25 - 29
warewms-base/src/main/java/com/ruoyi/base/service/impl/BaseLocationInfoServiceImpl.java

@@ -255,7 +255,14 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
 
     @Override
     public boolean lockLocationStockStatus(Long id, Long warehouseId, String updateBy) {
-        return updateLocationStockStatus(id, warehouseId, updateBy, Constant.STOCK_STATUS.STOCK10);
+        return updateLocationStockStatusAndIsEmpty(id, warehouseId, updateBy
+                , Constant.STOCK_STATUS.STOCK10, null);
+    }
+
+    @Override
+    public boolean unLockLocationStockStatus(Long id, Long warehouseId, String updateBy) {
+        return updateLocationStockStatusAndIsEmpty(id, warehouseId, updateBy
+                , Constant.STOCK_STATUS.STOCK00, null);
     }
 
     @Override
@@ -266,11 +273,6 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
         return lockLocationStockStatus(locationToId, warehouseId, updateBy);
     }
 
-    @Override
-    public boolean unLockLocationStockStatus(Long id, Long warehouseId, String updateBy) {
-        return updateLocationStockStatus(id, warehouseId, updateBy, Constant.STOCK_STATUS.STOCK00);
-    }
-
     @Override
     public boolean unLockLocationStockStatus(Long locationFromId, Long locationToId, Long warehouseId, String updateBy) {
         if (!unLockLocationStockStatus(locationFromId, warehouseId, updateBy)) {
@@ -279,25 +281,16 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
         return unLockLocationStockStatus(locationToId, warehouseId, updateBy);
     }
 
-    /**
-     * 修改库位锁定状态
-     *
-     * @param id
-     * @param warehouseId
-     * @param updateBy
-     * @return
-     */
-    private boolean updateLocationStockStatus(Long id, Long warehouseId, String updateBy, Constant.STOCK_STATUS stockStatus) {
-        BaseLocationInfo locationInfo = selectBaseLocationInfoById(id);
-        if (locationInfo == null) {
-            return false;
-        }
-        BaseLocationInfo locationInfoFromUpdate = new BaseLocationInfo();
-        locationInfoFromUpdate.setId(locationInfo.getId());
-        locationInfoFromUpdate.setStockStatus(stockStatus.getValue());
-        locationInfoFromUpdate.setUpdateBy(updateBy);
-        locationInfoFromUpdate.setWarehouseId(warehouseId);
-        return this.updateBaseLocationInfo(locationInfoFromUpdate) > 0;
+    @Override
+    public boolean occupyLocationIsEmpty(Long id, Long warehouseId, String updateBy) {
+        return updateLocationStockStatusAndIsEmpty(id, warehouseId, updateBy
+                , null, Constant.IS_YES.Y);
+    }
+
+    @Override
+    public boolean unOccupyLocationIsEmpty(Long id, Long warehouseId, String updateBy) {
+        return updateLocationStockStatusAndIsEmpty(id, warehouseId, updateBy
+                , null, Constant.IS_YES.N);
     }
 
     @Override
@@ -306,8 +299,7 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
                 , Constant.STOCK_STATUS.STOCK00, Constant.IS_YES.N);
     }
 
-    @Override
-    public boolean updateLocationStockStatusAndIsEmpty(Long id, Long warehouseId, String updateBy
+    private boolean updateLocationStockStatusAndIsEmpty(Long id, Long warehouseId, String updateBy
             , Constant.STOCK_STATUS stockStatus, Constant.IS_YES isYes) {
         BaseLocationInfo locationInfo = selectBaseLocationInfoById(id);
         if (locationInfo == null) {
@@ -315,8 +307,12 @@ public class BaseLocationInfoServiceImpl implements IBaseLocationInfoService {
         }
         BaseLocationInfo locationInfoFromUpdate = new BaseLocationInfo();
         locationInfoFromUpdate.setId(locationInfo.getId());
-        locationInfoFromUpdate.setStockStatus(stockStatus.getValue());
-        locationInfoFromUpdate.setIsEmpty(isYes.getValue());
+        if (stockStatus != null) {
+            locationInfoFromUpdate.setStockStatus(stockStatus.getValue());
+        }
+        if (isYes != null) {
+            locationInfoFromUpdate.setIsEmpty(isYes.getValue());
+        }
         locationInfoFromUpdate.setUpdateBy(updateBy);
         locationInfoFromUpdate.setWarehouseId(warehouseId);
         return this.updateBaseLocationInfo(locationInfoFromUpdate) > 0;