andy 3 yıl önce
ebeveyn
işleme
9ae096dce8

+ 5 - 0
ruoyi-ui/src/views/ams/flowConfig/index.vue

@@ -400,6 +400,11 @@
               </el-select>
             </template>
           </el-table-column>
+          <el-table-column label="默认值">
+            <template slot-scope="scope">
+              <el-input type="text" v-model="scope.row.defaultValue" class="cell-input"/>
+            </template>
+          </el-table-column>
           <el-table-column label="备注" prop="remark"></el-table-column>
         </el-table>
       </el-form>

+ 7 - 1
ruoyi-ui/src/views/ams/lineCall/index.vue

@@ -606,7 +606,13 @@
             }
             let obj = JSON.parse(JSON.stringify(this.form))
             this.subData.push(obj)
-            // this.reset();
+            //清空数据
+            // this.form.sku = undefined
+            this.form.qty = undefined
+            this.form.weight = undefined
+            this.form.supplier = undefined
+            this.form.locationFrom = undefined
+            this.form.locationTo = undefined
           }
         });
       },

+ 75 - 40
warewms-ams/src/main/java/com/ruoyi/ams/business/BusinessServiceImpl.java

@@ -95,28 +95,66 @@ public class BusinessServiceImpl implements IBusinessService {
             } else if (flowConfigHeaderVO.getFlowType().equals("SO")) {
                 for (AgvCallItemDTO agvCall : agvCallDTO.getAgvCallItemDTOList()) {
                     //判断总库存是否足够
-                    //TODO 循环判断取出的数据是否够,不够继续取
+                    Double totalQty = agvCall.getQty();
+                    int trySize = 100;
                     Double qty = invLotLocIdService.queryInvBySku(agvCall.getSku(), agvCall.getLotattDTO(), zoneIdList);
-                    if (qty < agvCall.getQty()) {
+                    if (qty == null || qty < agvCall.getQty()) {
                         throw new ServiceException("所需库存不够");
                     }
                     // locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "SO", asnSoStrategy, agvCall, token);
-                    BaseLocationInfo soLocationFrom;
-                    if (locationFromList != null && locationFromList.size() > 0) {
-                        List<Long> locationList = new ArrayList<>();
-                        for (BaseLocationInfo b : locationFromList) {
-                            locationList.add(b.getId());
+                    while (trySize > 0) {
+                        BaseLocationInfo soLocationFrom;
+                        if (locationFromList != null && locationFromList.size() > 0) {
+                            List<Long> locationList = new ArrayList<>();
+                            for (BaseLocationInfo b : locationFromList) {
+                                locationList.add(b.getId());
+                            }
+                            List<BaseLocationLotattVO> locationLotattVOList = baseLocationInfoMapper.selectSortedLocationLotattListByLocationIdList(locationList, 1L, agvCall.getLotattDTO().getAttr(), agvCall.getSku());
+                            OutWarehouseDTO outWarehouseDTO = new OutWarehouseDTO();
+                            outWarehouseDTO.setSku(agvCall.getSku());
+                            outWarehouseDTO.setQty(agvCall.getQty());
+                            outWarehouseDTO.setWeight(agvCall.getWeight());
+                            outWarehouseDTO.setSupplier(agvCall.getSupplier());
+                            outWarehouseDTO.setLotattDTO(agvCall.getLotattDTO());
+                            outWarehouseDTO.setWarehouseId(agvCallDTO.getWarehouseId());
+                            soLocationFrom = locationAllocationStrategy.filterLockInv(locationLotattVOList, outWarehouseDTO, asnSoStrategy, token);
+                        } else {
+                            OutWarehouseDTO outWarehouseDTO = new OutWarehouseDTO();
+                            outWarehouseDTO.setSku(agvCall.getSku());
+                            outWarehouseDTO.setQty(agvCall.getQty());
+                            outWarehouseDTO.setWeight(agvCall.getWeight());
+                            outWarehouseDTO.setSupplier(agvCall.getSupplier());
+                            outWarehouseDTO.setLotattDTO(agvCall.getLotattDTO());
+                            outWarehouseDTO.setWarehouseId(agvCall.getWarehouseId());
+                            soLocationFrom = outInvAllocation(outWarehouseDTO, token);
                         }
-                        List<BaseLocationLotattVO> locationLotattVOList = baseLocationInfoMapper.selectSortedLocationLotattListByLocationIdList(locationList, 1L, agvCall.getLotattDTO().getAttr(), agvCall.getSku());
-                        OutWarehouseDTO outWarehouseDTO = new OutWarehouseDTO();
-                        outWarehouseDTO.setSku(agvCall.getSku());
-                        outWarehouseDTO.setQty(agvCall.getQty());
-                        outWarehouseDTO.setWeight(agvCall.getWeight());
-                        outWarehouseDTO.setSupplier(agvCall.getSupplier());
-                        outWarehouseDTO.setLotattDTO(agvCall.getLotattDTO());
-                        outWarehouseDTO.setWarehouseId(agvCallDTO.getWarehouseId());
-                        soLocationFrom = locationAllocationStrategy.filterLockInv(locationLotattVOList, outWarehouseDTO, asnSoStrategy, token);
-                    } else {
+                        if (soLocationFrom == null) {
+                            throw new ServiceException("没有可分配的库存", token);
+                        }
+                        locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "SO", asnSoStrategy, agvCall, token);
+                        wcsTaskList.addAll(this.genTask(soLocationFrom, locationTo, flowConfigHeaderVO, token));
+                        Double current = invLotLocIdMapper.queryInvBySkuLocationId(agvCall.getSku(), soLocationFrom.getId(), agvCall.getLotattDTO());
+                        if (current != null) {
+                            totalQty -= current;
+                            if (totalQty <= 0) {
+                                break;
+                            }
+                        }
+                        trySize--;
+                    }
+                }
+            } else if (flowConfigHeaderVO.getFlowType().equals("MV")) {
+                for (AgvCallItemDTO agvCall : agvCallDTO.getAgvCallItemDTOList()) {
+                    Double totalQty = agvCall.getQty();
+                    int trySize = 100;
+                    if (agvCall.getQty() != null) {
+                        Double qty = invLotLocIdService.queryInvBySku(agvCall.getSku(), agvCall.getLotattDTO(), zoneIdList);
+                        if (qty == null || qty < agvCall.getQty()) {
+                            throw new ServiceException("所需库存不够");
+                        }
+                    }
+
+                    while (trySize > 0) {
                         OutWarehouseDTO outWarehouseDTO = new OutWarehouseDTO();
                         outWarehouseDTO.setSku(agvCall.getSku());
                         outWarehouseDTO.setQty(agvCall.getQty());
@@ -124,30 +162,27 @@ public class BusinessServiceImpl implements IBusinessService {
                         outWarehouseDTO.setSupplier(agvCall.getSupplier());
                         outWarehouseDTO.setLotattDTO(agvCall.getLotattDTO());
                         outWarehouseDTO.setWarehouseId(agvCall.getWarehouseId());
-                        soLocationFrom = outInvAllocation(outWarehouseDTO, token);
-                    }
-                    if (soLocationFrom == null) {
-                        throw new ServiceException("没有可分配的库存", token);
-                    }
-                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "SO", asnSoStrategy, agvCall, token);
-                    wcsTaskList.addAll(this.genTask(soLocationFrom, locationTo, flowConfigHeaderVO, token));
-                }
-            } else if (flowConfigHeaderVO.getFlowType().equals("MV")) {
-                for (AgvCallItemDTO agvCall : agvCallDTO.getAgvCallItemDTOList()) {
-                    OutWarehouseDTO outWarehouseDTO = new OutWarehouseDTO();
-                    outWarehouseDTO.setSku(agvCall.getSku());
-                    outWarehouseDTO.setQty(agvCall.getQty());
-                    outWarehouseDTO.setWeight(agvCall.getWeight());
-                    outWarehouseDTO.setSupplier(agvCall.getSupplier());
-                    outWarehouseDTO.setLotattDTO(agvCall.getLotattDTO());
-                    outWarehouseDTO.setWarehouseId(agvCall.getWarehouseId());
-                    BaseLocationInfo mvLocationFrom = outInvAllocation(outWarehouseDTO, token);
-                    //locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "MV", asnSoStrategy, agvCall, token);
-                    locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "MV", asnSoStrategy, agvCall, token);
-                    if (mvLocationFrom == null) {
-                        throw new ServiceException("没有可以分配的库存", token);
+                        BaseLocationInfo mvLocationFrom = outInvAllocation(outWarehouseDTO, token);
+                        //locationFrom = this.zoneLocationAllocation(locationFromList, "locationFrom", "MV", asnSoStrategy, agvCall, token);
+                        locationTo = this.zoneLocationAllocation(locationToList, "locationTo", "MV", asnSoStrategy, agvCall, token);
+                        if (mvLocationFrom == null) {
+                            break;
+                        }
+                        if (locationTo == null) {
+                            break;
+                        }
+                        wcsTaskList.addAll(this.genTask(mvLocationFrom, locationTo, flowConfigHeaderVO, token));
+                        if (agvCall.getQty() != null) {
+                            Double current = invLotLocIdMapper.queryInvBySkuLocationId(agvCall.getSku(), mvLocationFrom.getId(), agvCall.getLotattDTO());
+                            if (current != null) {
+                                totalQty -= current;
+                                if (totalQty <= 0) {
+                                    break;
+                                }
+                            }
+                        }
+                        trySize--;
                     }
-                    wcsTaskList.addAll(this.genTask(mvLocationFrom, locationTo, flowConfigHeaderVO, token));
                 }
             }
 

+ 10 - 0
warewms-ams/src/main/java/com/ruoyi/ams/config/domain/FlowConfigDetails.java

@@ -30,6 +30,8 @@ public class FlowConfigDetails extends BaseEntity
     @Excel(name = "是否显示")
     private String lotattFlag;
 
+    private String defaultValue;
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -67,6 +69,14 @@ public class FlowConfigDetails extends BaseEntity
         return lotattFlag;
     }
 
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 5 - 5
warewms-ams/src/main/java/com/ruoyi/ams/config/domain/vo/FlowConfigLotattVO.java

@@ -11,7 +11,7 @@ public class FlowConfigLotattVO {
     private String lotattName;
     private String inputType;
     private String inputScope;
-    private String lotattValue;
+    private String defaultValue;
 
     public String getLotattId() {
         return lotattId;
@@ -53,11 +53,11 @@ public class FlowConfigLotattVO {
         this.inputScope = inputScope;
     }
 
-    public String getLotattValue() {
-        return lotattValue;
+    public String getDefaultValue() {
+        return defaultValue;
     }
 
-    public void setLotattValue(String lotattValue) {
-        this.lotattValue = lotattValue;
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
     }
 }

+ 13 - 7
warewms-ams/src/main/java/com/ruoyi/ams/config/service/LocationAllocationStrategy.java

@@ -178,6 +178,7 @@ public class LocationAllocationStrategy {
             }
             if (info.getStockStatus().equals("10") || redisCache.checkIsLock(RedisKey.LOCK_LOCATION + info.getId())) {
                 taskingFlag.put(info.getColNo(), true);
+                //如果在任务中跳过该库存
             } else {
                 if (taskingFlag.get(info.getColNo()) == null || taskingFlag.get(info.getColNo()).booleanValue() == false) {
                     taskingFlag.put(info.getColNo(), false);
@@ -232,10 +233,11 @@ public class LocationAllocationStrategy {
                         }
                     } else {
                         //如果前面的库位已阻挡则之前的库位不可用
-                        //TODO 任务中的库位可以继续使用
-                        if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
+                        if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
                             if (!redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                                currentLocation = null;
+                                redisCache.deleteObject(RedisKey.LOCK_LOCATION + currentLocation.getId());
+                                currentLocation = b;
+                                currentLocationLotatt = b;
                             }
                         } else {
                             continue;
@@ -270,9 +272,11 @@ public class LocationAllocationStrategy {
                     } else {
                         //如果前面的库位已阻挡则之前的库位不可用
                         //TODO 任务中的库位可以继续使用
-                        if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
+                        if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
                             if (!redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                                currentLocation = null;
+                                redisCache.deleteObject(RedisKey.LOCK_LOCATION + currentLocation.getId());
+                                currentLocation = b;
+                                currentLocationLotatt = b;
                             }
                         } else {
                             continue;
@@ -310,9 +314,11 @@ public class LocationAllocationStrategy {
                     } else {
                         //如果前面的库位已阻挡则之前的库位不可用
                         //TODO 任务中的库位可以继续使用
-                        if (!b.getIsEmpty().equals("Y") || !b.getStockStatus().equals("00")) {
+                        if (b.getIsEmpty().equals("N") && b.getStockStatus().equals("00")) {
                             if (!redisCache.checkIsLock(RedisKey.LOCK_LOCATION + b.getId())) {
-                                currentLocation = null;
+                                redisCache.deleteObject(RedisKey.LOCK_LOCATION + currentLocation.getId());
+                                currentLocation = b;
+                                currentLocationLotatt = b;
                             }
                         } else {
                             continue;

+ 2 - 2
warewms-ams/src/main/java/com/ruoyi/ams/config/service/impl/FlowConfigHeaderServiceImpl.java

@@ -307,8 +307,8 @@ public class FlowConfigHeaderServiceImpl implements IFlowConfigHeaderService {
         List<FlowConfigLotattVO> flowConfigLotattVOList = flowConfigHeaderMapper.selectLotattDetails(id);
         if (flowConfigLotattVOList != null && flowConfigLotattVOList.size() > 0) {
             for (FlowConfigLotattVO v : flowConfigLotattVOList) {
-                if (v.getInputType().equals("DateBox") && !StringUtils.isEmpty(v.getLotattValue()) && v.getLotattValue().equals("now")) {
-                    v.setLotattValue(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date()));
+                if (v.getInputType().equals("DateBox") && !StringUtils.isEmpty(v.getDefaultValue()) && v.getDefaultValue().equals("now")) {
+                    v.setDefaultValue(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date()));
                 }
             }
         }

+ 2 - 1
warewms-ams/src/main/java/com/ruoyi/ams/config/service/impl/LotattConfigServiceImpl.java

@@ -103,7 +103,8 @@ public class LotattConfigServiceImpl implements ILotattConfigService
 
     @Override
     public List<LotattConfigVO> queryLotattConfigListActive() {
-        return lotattConfigMapper.queryLotattConfigListActive();
+        List<LotattConfigVO> list = lotattConfigMapper.queryLotattConfigListActive();
+        return list;
     }
 
     @Override

+ 9 - 0
warewms-ams/src/main/java/com/ruoyi/ams/inv/mapper/InvLotLocIdMapper.java

@@ -129,4 +129,13 @@ public interface InvLotLocIdMapper
      * @return
      */
     Double queryInvBySku(@Param("sku") String sku, @Param("lotattDTO") LotattDTO lotattDTO, @Param("zoneIdList") List<String> zoneIdList);
+
+    /**
+     * 根据物料库位查询库存
+     * @param sku
+     * @param locationId
+     * @param lotattDTO
+     * @return
+     */
+    Double queryInvBySkuLocationId(@Param("sku") String sku, @Param("locationId") Long locationId, @Param("lotattDTO") LotattDTO lotattDTO);
 }

+ 5 - 5
warewms-ams/src/main/resources/mapper/ams/FlowConfigHeaderMapper.xml

@@ -83,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="sub_update_by"    />
         <result property="updateTime"    column="sub_update_time"    />
         <result property="remark"    column="sub_remark"    />
+        <result property="defaultValue"    column="sub_default_value"    />
     </resultMap>
 
     <resultMap type="flowConfigLotattVO" id="FlowConfigLotattVOResult">
@@ -91,8 +92,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="lotattName"    column="lotatt_name"    />
         <result property="inputType"    column="input_type"    />
         <result property="inputScope"    column="input_scope"    />
-        <result property="lotattValue"    column="lotatt_value"    />
-
+        <result property="defaultValue"    column="lotatt_value"    />
     </resultMap>
 
     <sql id="selectFlowConfigHeaderVo">
@@ -121,7 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <select id="selectFlowConfigHeaderById" parameterType="Long" resultMap="FlowConfigHeaderFlowConfigDetailsResult">
         select a.id, a.flow_name,a.flow_type, a.sku_type, a.sku_type_flag, a.qty, a.qty_flag, a.weight, a.weight_flag, a.supplier, a.supplier_flag, a.location_from,a.location_from_flag, a.location_from_device, a.location_to,a.location_to_flag, a.location_to_device, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
-        a.qty_range,a.weight_range,a.supplier_range,b.id as sub_id, b.header_id as sub_header_id, b.lotatt_id as sub_lotatt_id,cf.lotatt_name as sub_lotatt_name, b.lotatt_flag as sub_lotatt_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark,
+        a.qty_range,a.weight_range,a.supplier_range,b.id as sub_id, b.header_id as sub_header_id, b.lotatt_id as sub_lotatt_id,cf.lotatt_name as sub_lotatt_name, b.lotatt_flag as sub_lotatt_flag, b.create_by as sub_create_by, b.create_time as sub_create_time, b.update_by as sub_update_by, b.update_time as sub_update_time, b.remark as sub_remark,b.default_value as sub_default_value,
         a.location_from_strategy_flag,a.location_to_strategy_flag,a.rel_flow,a.root_flow
         from flow_config_header a
         left join flow_config_details b on b.header_id = a.id
@@ -248,9 +248,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </delete>
 
     <insert id="batchFlowConfigDetails">
-        insert into flow_config_details( id, header_id, lotatt_id, lotatt_flag, create_by, create_time, update_by, update_time, remark) values
+        insert into flow_config_details( id, header_id, lotatt_id, lotatt_flag, create_by, create_time, update_by, update_time, remark, default_value) values
 		<foreach item="item" index="index" collection="list" separator=",">
-            ( #{item.id}, #{item.headerId}, #{item.lotattId}, #{item.lotattFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
+            ( #{item.id}, #{item.headerId}, #{item.lotattId}, #{item.lotattFlag}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark}, #{item.defaultValue})
         </foreach>
     </insert>
 

+ 34 - 0
warewms-ams/src/main/resources/mapper/ams/InvLotLocIdMapper.xml

@@ -346,4 +346,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             group by sk.sku
         </where>
     </select>
+
+    <select id="queryInvBySkuLocationId" resultType="double">
+        select
+        sum(inv.qty) qty
+        from inv_lot_loc_id inv
+        left join inv_lot_att att on inv.lotnum = att.lotnum
+        left join base_location_info b on inv.location_id = b.id
+        left join base_sku sk on inv.sku = sk.sku
+        left join base_sku_type skt on sk.sku_type = skt.item_code
+        left join base_location_zone bz on b.zone_id = bz.zone_id
+        <where>
+            <if test="sku != null  and sku != ''"> and sk.sku = #{sku}</if>
+            <if test="lotattDTO.lotatt01 != null  and lotattDTO.lotatt01 != ''"> and att.lotatt01 = #{lotattDTO.lotatt01}</if>
+            <if test="lotattDTO.lotatt02 != null  and lotattDTO.lotatt02 != ''"> and att.lotatt02 = #{lotattDTO.lotatt02}</if>
+            <if test="lotattDTO.lotatt03 != null  and lotattDTO.lotatt03 != ''"> and att.lotatt03 = #{lotattDTO.lotatt03}</if>
+            <if test="lotattDTO.lotatt04 != null  and lotattDTO.lotatt04 != ''"> and att.lotatt04 = #{lotattDTO.lotatt04}</if>
+            <if test="lotattDTO.lotatt05 != null  and lotattDTO.lotatt05 != ''"> and att.lotatt05 = #{lotattDTO.lotatt05}</if>
+            <if test="lotattDTO.lotatt06 != null  and lotattDTO.lotatt06 != ''"> and att.lotatt06 = #{lotattDTO.lotatt06}</if>
+            <if test="lotattDTO.lotatt07 != null  and lotattDTO.lotatt07 != ''"> and att.lotatt07 = #{lotattDTO.lotatt07}</if>
+            <if test="lotattDTO.lotatt08 != null  and lotattDTO.lotatt08 != ''"> and att.lotatt08 = #{lotattDTO.lotatt08}</if>
+            <if test="lotattDTO.lotatt09 != null  and lotattDTO.lotatt09 != ''"> and att.lotatt09 = #{lotattDTO.lotatt09}</if>
+            <if test="lotattDTO.lotatt10 != null  and lotattDTO.lotatt10 != ''"> and att.lotatt10 = #{lotattDTO.lotatt10}</if>
+            <if test="lotattDTO.lotatt11 != null  and lotattDTO.lotatt11 != ''"> and att.lotatt11 = #{lotattDTO.lotatt11}</if>
+            <if test="lotattDTO.lotatt12 != null  and lotattDTO.lotatt12 != ''"> and att.lotatt12 = #{lotattDTO.lotatt12}</if>
+            <if test="lotattDTO.lotatt13 != null  and lotattDTO.lotatt13 != ''"> and att.lotatt13 = #{lotattDTO.lotatt13}</if>
+            <if test="lotattDTO.lotatt14 != null  and lotattDTO.lotatt14 != ''"> and att.lotatt14 = #{lotattDTO.lotatt14}</if>
+            <if test="lotattDTO.lotatt15 != null  and lotattDTO.lotatt15 != ''"> and att.lotatt15 = #{lotattDTO.lotatt15}</if>
+            <if test="lotattDTO.lotatt16 != null  and lotattDTO.lotatt16 != ''"> and att.lotatt16 = #{lotattDTO.lotatt16}</if>
+            <if test="lotattDTO.lotatt17 != null  and lotattDTO.lotatt17 != ''"> and att.lotatt17 = #{lotattDTO.lotatt17}</if>
+            <if test="lotattDTO.lotatt18 != null  and lotattDTO.lotatt18 != ''"> and att.lotatt18 = #{lotattDTO.lotatt18}</if>
+            and b.id = #{locationId}
+            group by sk.sku
+        </where>
+    </select>
 </mapper>

+ 2 - 2
warewms-base/src/main/resources/mapper/base/BaseLocationInfoMapper.xml

@@ -420,11 +420,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         b.userdefine9, b.userdefine10, b.create_by, b.create_time,  b.update_by,  b.update_time,  b.remark, inv.sku, inv.qty, height_limit, weight_limit, att.*
         from base_location_info b left join inv_lot_loc_id inv on b.id = inv.location_id
         left join inv_lot_att att on inv.lotnum = att.lotnum
-        where warehouse_id = #{warehouseId} and inv.sku is not null and id in
+        where warehouse_id = #{warehouseId} and id in
         <foreach item="item" collection="locationId" open="(" separator="," close=")">
             #{item}
         </foreach>
-        <if test="sku != null and sku != ''"> and inv.sku = #{sku}</if>
+        <if test="sku != null and sku != ''"> and (inv.sku = #{sku} or inv.sku is null)</if>
         <if test="lotatt.lotatt01 != null and lotatt.lotatt01 != ''"> and att.lotatt01 = #{lotatt.lotatt01}</if>
         <if test="lotatt.lotatt02 != null and lotatt.lotatt02 != ''"> and att.lotatt02 = #{lotatt.lotatt02}</if>
         <if test="lotatt.lotatt03 != null and lotatt.lotatt03 != ''"> and att.lotatt03 = #{lotatt.lotatt03}</if>