diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseKnifeMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseKnifeMapper.java index 3eba3c4..9c17bf1 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseKnifeMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseKnifeMapper.java @@ -121,4 +121,6 @@ public interface BaseKnifeMapper { public Boolean isDuplicateRfid(String rfid); List selectBaseKnifeNotValidList(BaseKnife baseKnifeWrapper); + + List selectNotEmptyAreaCodeList(); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java index af5a02d..d2b2ef2 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmStorageLocationService.java @@ -1,6 +1,8 @@ package com.ktg.mes.wm.service; import java.util.List; + +import com.ktg.mes.wm.domain.WmStorageArea; import com.ktg.mes.wm.domain.WmStorageLocation; import com.ktg.mes.wm.domain.vo.WmStorageLocationVo; @@ -105,4 +107,13 @@ public interface IWmStorageLocationService * @return */ public int deleteByWarehouseId(Long warehouseId); + + /** + * 查询一个库位 + * + * @param code 库区编码 + * @param isBig 是否大件 + * @return 库位 + */ + WmStorageArea queryOneAreaByLocationCode(String code, Boolean isBig); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java index 9a25b15..55a50da 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmStorageLocationServiceImpl.java @@ -1,11 +1,15 @@ package com.ktg.mes.wm.service.impl; import java.util.List; +import java.util.stream.Collectors; import com.ktg.common.constant.UserConstants; import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.StringUtils; +import com.ktg.mes.md.mapper.BaseKnifeMapper; +import com.ktg.mes.wm.domain.WmStorageArea; import com.ktg.mes.wm.domain.vo.WmStorageLocationVo; +import com.ktg.mes.wm.mapper.WmStorageAreaMapper; import org.apache.catalina.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,6 +29,12 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService @Autowired private WmStorageLocationMapper wmStorageLocationMapper; + @Autowired + private BaseKnifeMapper baseKnifeMapper; + + @Autowired + private WmStorageAreaMapper wmStorageAreaMapper; + /** * 查询库区设置 * @@ -151,4 +161,27 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService public int deleteByWarehouseId(Long warehouseId) { return wmStorageLocationMapper.deleteByWarehouseId(warehouseId); } + + @Override + public WmStorageArea queryOneAreaByLocationCode(String code, Boolean isBig) { + // 获取库区 + WmStorageLocation wmStorageLocationByCode = this.wmStorageLocationMapper.selectWmStorageLocationByLocationCode(code); + if (wmStorageLocationByCode == null) throw new RuntimeException("自动获取库位失败,该库区不存在"); + + // 获取台账中已经使用的库位编码 + List selectNotEmptyAreaCodeList = this.baseKnifeMapper.selectNotEmptyAreaCodeList(); + + // 获取库位列表 + WmStorageArea wmStorageAreaQuery = new WmStorageArea(); + wmStorageAreaQuery.setLocationId(wmStorageLocationByCode.getLocationId()); + if (isBig) wmStorageAreaQuery.setAttr3(1L); + List wmStorageAreaList = this.wmStorageAreaMapper.selectWmStorageAreaList(wmStorageAreaQuery).stream() + // 过滤掉全部存在物品的库位 + .filter(it -> !selectNotEmptyAreaCodeList.contains(it.getAreaCode())) + .collect(Collectors.toList()); + if (wmStorageAreaList.isEmpty()) throw new RuntimeException("自动获取库位失败,无可用库位"); + + // 返回第一个可用的库位 + return wmStorageAreaList.get(0); + } } diff --git a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml index 0f2ad03..e7a50d9 100644 --- a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml @@ -612,4 +612,11 @@ FROM BASE_KNIFE WHERE RFID = #{value} - \ No newline at end of file + + + diff --git a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml index 90b2a73..85d08b6 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmStorageAreaMapper.xml @@ -1,189 +1,370 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - select area_id, area_code, area_name, location_id, area, max_loa, position_x, position_y, position_z, enable_flag, frozen_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_storage_area + select area_id, + area_code, + area_name, + location_id, + area, + max_loa, + position_x, + position_y, + position_z, + enable_flag, + frozen_flag, + remark, + attr1, + attr2, + attr3, + attr4, + create_by, + create_time, + update_by, + update_time + from wm_storage_area - + - + insert into wm_storage_area - area_code, - area_name, - location_id, - area, - max_loa, - position_x, - position_y, - position_z, - enable_flag, - frozen_flag, - remark, - attr1, - attr2, - attr3, - attr4, - create_by, - create_time, - update_by, - update_time, - + + area_code, + + + area_name, + + + location_id, + + + area, + + + max_loa, + + + position_x, + + + position_y, + + + position_z, + + + enable_flag, + + + frozen_flag, + + + remark, + + + attr1, + + + attr2, + + + attr3, + + + attr4, + + + create_by, + + + create_time, + + + update_by, + + + update_time, + + - #{areaCode}, - #{areaName}, - #{locationId}, - #{area}, - #{maxLoa}, - #{positionX}, - #{positionY}, - #{positionZ}, - #{enableFlag}, - #{frozenFlag}, - #{remark}, - #{attr1}, - #{attr2}, - #{attr3}, - #{attr4}, - #{createBy}, - #{createTime}, - #{updateBy}, - #{updateTime}, - + + #{areaCode}, + + + #{areaName}, + + + #{locationId}, + + + #{area}, + + + #{maxLoa}, + + + #{positionX}, + + + #{positionY}, + + + #{positionZ}, + + + #{enableFlag}, + + + #{frozenFlag}, + + + #{remark}, + + + #{attr1}, + + + #{attr2}, + + + #{attr3}, + + + #{attr4}, + + + #{createBy}, + + + #{createTime}, + + + #{updateBy}, + + + #{updateTime}, + + update wm_storage_area - area_code = #{areaCode}, - area_name = #{areaName}, - location_id = #{locationId}, - area = #{area}, - max_loa = #{maxLoa}, - position_x = #{positionX}, - position_y = #{positionY}, - position_z = #{positionZ}, - enable_flag = #{enableFlag}, - frozen_flag = #{frozenFlag}, - remark = #{remark}, - attr1 = #{attr1}, - attr2 = #{attr2}, - attr3 = #{attr3}, - attr4 = #{attr4}, - create_by = #{createBy}, - create_time = #{createTime}, - update_by = #{updateBy}, - update_time = #{updateTime}, + + area_code = #{areaCode}, + + + area_name = #{areaName}, + + + location_id = #{locationId}, + + + area = #{area}, + + + max_loa = #{maxLoa}, + + + position_x = #{positionX}, + + + position_y = #{positionY}, + + + position_z = #{positionZ}, + + + enable_flag = #{enableFlag}, + + + frozen_flag = #{frozenFlag}, + + + remark = #{remark}, + + + attr1 = #{attr1}, + + + attr2 = #{attr2}, + + + attr3 = #{attr3}, + + + attr4 = #{attr4}, + + + create_by = #{createBy}, + + + create_time = #{createTime}, + + + update_by = #{updateBy}, + + + update_time = #{updateTime}, + where area_id = #{areaId} - update wm_storage_area set IS_DELETE =1 + update wm_storage_area + set IS_DELETE =1 where area_id = #{areaId} - update wm_storage_area set IS_DELETE = 1 + update wm_storage_area + set IS_DELETE = 1 where area_id in #{areaId} @@ -191,13 +372,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - update wm_storage_area set IS_DELETE =1 - where location_id in ( select location_id from wm_storage_location where warehouse_id = #{warehouseId}) + update wm_storage_area + set IS_DELETE =1 + where location_id in (select location_id from wm_storage_location where warehouse_id = #{warehouseId}) - update wm_storage_area set IS_DELETE = 1 + update wm_storage_area + set IS_DELETE = 1 where location_id = #{locationId} - \ No newline at end of file