zhs před 2 roky
rodič
revize
bc113bfb56

+ 12 - 3
src/main/java/com/tld/controller/DeliveryController.java

@@ -1,11 +1,10 @@
 package com.tld.controller;
 
+import com.tld.model.AskGoods;
 import com.tld.model.Delivery;
 import com.tld.service.DeliveryService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.Map;
 
@@ -49,6 +48,16 @@ public class DeliveryController {
         return deliveryService.getRecommend(delivery);
     }
 
+    /**
+     * 半成品入虚拟表
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @PostMapping("addVitrual")
+    public Map<String, Object> addVitrual(@RequestBody AskGoods askGoods){
+        return deliveryService.addVitrual(askGoods);
+    }
+
     /**
      * 出库
      * @param uniqueCode PDA唯一表示

+ 1 - 1
src/main/java/com/tld/mapper/AskGoodsMapper.java

@@ -51,7 +51,7 @@ public interface AskGoodsMapper {
 
     void addRemoval(AskGoods askGoods);
 
-    String getMaterialId(@Param("wllbCode") String wllbCode, @Param("accountSleeve") String accountSleeve);
+    String getMaterialId(@Param("wllbCode") String wllbCode);
 
     AskGoods getAskDetailed(String askGoodsId, String materialId);
 

+ 5 - 0
src/main/java/com/tld/mapper/DeliveryMapper.java

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 @Mapper
 public interface DeliveryMapper {
@@ -32,4 +33,8 @@ public interface DeliveryMapper {
     int getSumAmount(Inventory inventory);
 
     MaterialClass getMaterialClass(String materialId);
+
+    int getProductNumVitrual(Inventory inventory);
+
+    Map<String, Object> getScanIsNot(AskGoods askGoods);
 }

+ 1 - 1
src/main/java/com/tld/mapper/InviteMapper.java

@@ -54,7 +54,7 @@ public interface InviteMapper {
 
     void updateInventory(Inventory inventory);
 
-    String getMaterialId(@Param("wllbCode") String wllbCode, @Param("accountSleeve") String accountSleeve);
+    String getMaterialId(@Param("wllbCode") String wllbCode);
 
     AskGoods getAskDetailed(String askGoodsId, String materialId);
 

+ 4 - 0
src/main/java/com/tld/model/AskGoods.java

@@ -204,4 +204,8 @@ public class AskGoods implements Serializable {
      * 所属公司
      */
     private String accountSleeve;
+    /**
+     * 库存id
+     */
+    private String inventoryId;
 }

+ 4 - 0
src/main/java/com/tld/model/Delivery.java

@@ -99,6 +99,10 @@ public class Delivery implements Serializable {
      * 结束时间
      */
     private String endTime;
+    /**
+     * pda唯一标识
+     */
+    private String uniqueCode;
     /**
      * 页数
      */

+ 3 - 0
src/main/java/com/tld/service/DeliveryService.java

@@ -1,5 +1,6 @@
 package com.tld.service;
 
+import com.tld.model.AskGoods;
 import com.tld.model.Delivery;
 
 import java.util.Map;
@@ -12,4 +13,6 @@ public interface DeliveryService {
     Map<String, Object> OutOfLibrary(String uniqueCode, String type, String deliveryId);
 
     Map<String, Object> getAttribute(Delivery delivery);
+
+    Map<String, Object> addVitrual(AskGoods askGoods);
 }

+ 4 - 4
src/main/java/com/tld/service/impl/AskGoodsServiceImpl.java

@@ -177,7 +177,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             int alreadyNum =  askGoodsMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
             int inventoryAlready =  askGoodsMapper.getInventoryAlready(askGoods);//库存已扫描数量
             int inventorySurplus = (Integer.parseInt(inventory.getAmount()) - Integer.parseInt(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
-            Double surplusNum = Double.parseDouble(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
+            Double surplusNum = Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
 
             if(surplusNum >= inventorySurplus){
                 askGoods.setNum(String.valueOf(inventorySurplus));
@@ -208,6 +208,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             List<AskGoods> list = askGoodsMapper.getVirtualUniqueCode(uniqueCode, type, askGoodsId);
             for(AskGoods askGoods : list){
                 askGoods.setStorageCode(removalCode);
+                askGoods.setCompanyNumber(askGoods.getAccountSleeve());
                 Inventory inventory = askGoodsMapper.getInventory(askGoods);
                 if(inventory == null){
                     throw new Exception("库存不存在");
@@ -219,7 +220,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     inventory.setAmount(askGoods.getNum());
                     askGoodsMapper.updateInventory(inventory);
                 }
-                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode(), askGoods.getAccountSleeve());//查询物料id
+                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 AskGoods askGoods1 = askGoodsMapper.getAskDetailed(askGoodsId, materialId);//查询要料申请单内容
                 ReturRemoval returRemoval = new ReturRemoval()
                         .setMaterialId(materialId)
@@ -228,8 +229,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                         .setNum(askGoods.getNum())
                         .setEntryNumber(askGoods1.getEntryNumber())
                         .setDocumentPointsId(askGoods1.getId())
-                        .setStorageLocationCode(askGoods.getStorageLocationCode())
-                        .setWbs(askGoods1.getWbs());
+                        .setStorageLocationCode(askGoods.getStorageLocationCode());
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
                 askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
                 askGoodsMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息

+ 57 - 15
src/main/java/com/tld/service/impl/DeliveryServiceImpl.java

@@ -53,33 +53,55 @@ public class DeliveryServiceImpl implements DeliveryService {
                 //查询所有产成品库位
                 String storageLocationCode = deliveryMapper.getStorageLocationCodeList();
                 List<Inventory> list = new LinkedList<>();
-                Map<String, Object> occupyMap = new HashMap<>();
                 for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
                     int occupy = deliveryMapper.getVitrual(inventory);
-                    if(Integer.parseInt(inventory.getAmount()) == occupy){
-                        list.add(inventory);
-                        int num = Integer.parseInt(inventory.getAmount()) - occupy;
-                        occupyMap.put(inventory.getStorageLocationCode(), num);
+                    if(occupy == 0){
+                        if(Integer.parseInt(inventory.getAmount()) == Integer.getInteger(delivery.getOutNum())){
+                            list.add(inventory);
+                            map.put("data", list);
+                            map.put("msg", "200");
+                            return map;
+                        }
                     }
                 }
                 map.put("data", list);
-                map.put("occupyMap", occupyMap);
             } else if(materialClass.getPartType().equals("半成品")){
                 String storageLocationCode = "000000,";
                 List<Inventory> list = new LinkedList<>();
-                Map<String, Object> occupyMap = new HashMap<>();
                 for(Inventory inventory : deliveryMapper.getInventory(storageLocationCode, delivery)){
-                    int occupy = deliveryMapper.getVitrual(inventory);
-                    if(Integer.parseInt(inventory.getAmount()) > occupy){
+                    int productNum = deliveryMapper.getProductNumVitrual(inventory);
+                    if(Integer.parseInt(inventory.getAmount()) < 0){
+                        map.put("msg", "500");
+                        map.put("errMsg", "库存不足");
+                        return map;
+                    } else {
                         list.add(inventory);
-                        int num = Integer.parseInt(inventory.getAmount()) - occupy;
-                        occupyMap.put(inventory.getStorageLocationCode(), num);
+                        map.put("data", list);
+                        map.put("msg", "200");
+                        return map;
                     }
                 }
-                map.put("data", list);
-                map.put("occupyMap", occupyMap);
             } else {
-
+                List<Inventory> list = new LinkedList<>();
+                AskGoods askGoods = new AskGoods()
+                        .setCompanyNumber(delivery.getCompanyNumber())
+                        .setMaterialId(delivery.getMaterialId());
+                for(Inventory inventory : askGoodsMapper.getMaterialCk(askGoods)){
+                    AskGoods askGoods1 = askGoodsMapper.getAsk(inventory);
+                    if(askGoods1 != null){
+                        if(Double.parseDouble(askGoods1.getNum()) != Double.parseDouble(inventory.getAmount())){
+                            list.add(inventory);
+                            map.put("data", list);
+                            map.put("msg", "200");
+                            return map;
+                        }
+                    } else {
+                        list.add(inventory);
+                        map.put("data", list);
+                        map.put("msg", "200");
+                        return map;
+                    }
+                }
             }
             map.put("msg", "200");
         }catch (Exception e){
@@ -107,7 +129,7 @@ public class DeliveryServiceImpl implements DeliveryService {
                     inventory.setAmount(askGoods.getNum());
                     askGoodsMapper.updateInventory(inventory);
                 }
-                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode(), askGoods.getAccountSleeve());//查询物料id
+                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 deliveryMapper.updateDelivery(materialId, askGoods.getNum(), deliveryId); //修改销售单出库数量
                 //查询销售单部分信息
                 Delivery delivery = new Delivery().setDeliveryId(deliveryId).setMaterialId(materialId);
@@ -173,6 +195,26 @@ public class DeliveryServiceImpl implements DeliveryService {
         return map;
     }
 
+    @Override
+    public Map<String, Object> addVitrual(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            Map<String, Object> mapVal = deliveryMapper.getScanIsNot(askGoods);
+            if(Double.parseDouble(mapVal.get("amount").toString()) - Double.parseDouble(mapVal.get("vitrualNum").toString()) == 0){
+                map.put("msg", "500");
+                map.put("errMsg", "已全部出库");
+                return map;
+            }
+            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+            e.printStackTrace();
+        }
+        return map;
+    }
+
     /**
      * 出库单生成
      * @return

+ 17 - 0
src/main/java/com/tld/service/impl/DictionaryServiceImpl.java

@@ -1,12 +1,15 @@
 package com.tld.service.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.tld.mapper.DictionaryMapper;
 import com.tld.model.Access;
 import com.tld.model.Goods;
 import com.tld.service.DictionaryService;
+import com.tld.util.RedisUtil;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -14,15 +17,19 @@ import com.tld.model.Dictionary;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 @Service
 public class DictionaryServiceImpl implements DictionaryService {
 
     @Autowired
     private DictionaryMapper dictionaryMapper;
+    @Autowired
+    private RedisUtil redisUtil;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -65,6 +72,16 @@ public class DictionaryServiceImpl implements DictionaryService {
             String tableName = dictionaryMapper.getTableName(dictionary.getType());
             dictionary.setTableName(tableName);
             List<Dictionary> list = dictionaryMapper.getDictionary(dictionary);
+//            List<Dictionary> list = new ArrayList<>();
+//            if(redisUtil.hasKey(tableName)){
+//                System.out.println("345");
+//                String value = redisUtil.get(tableName);
+//                list = JSONObject.parseArray(value, Dictionary.class);
+//            } else {
+//                System.out.println("123");
+//                list = dictionaryMapper.getDictionary(dictionary);
+//                redisUtil.add(tableName, list, 60, TimeUnit.MINUTES);
+//            }
             map.put("msg", "200");
             map.put("data", list);
         }  catch (Exception e){

+ 4 - 3
src/main/java/com/tld/service/impl/InviteServiceImpl.java

@@ -48,7 +48,7 @@ public class InviteServiceImpl implements InviteService {
             List<String> scanNum = new LinkedList<>();
             for(AskGoods askGoods1 : list){
                 askGoods1.setUniqueCode(askGoods.getUniqueCode());
-                askGoods1.setAskGoodsId(askGoods.getAskGoodsId());
+                askGoods1.setUniqueCode(askGoods.getUniqueCode());
                 scanNum.add(inviteMapper.getScanNum(askGoods1));//扫描总数
             }
             map.put("scanNum", scanNum);
@@ -103,7 +103,7 @@ public class InviteServiceImpl implements InviteService {
             int alreadyNum =  inviteMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
             int inventoryAlready =  inviteMapper.getInventoryAlready(askGoods);//库存已扫描数量
             int inventorySurplus = (Integer.parseInt(inventory.getAmount()) - Integer.parseInt(inventory.getAmountLock())) - inventoryAlready; //库存剩余数量
-            int surplusNum = Integer.parseInt(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
+            Double surplusNum = Double.parseDouble(askGoods1.getNum()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
 
             if(surplusNum >= inventorySurplus){
                 askGoods.setNum(String.valueOf(inventorySurplus));
@@ -133,6 +133,7 @@ public class InviteServiceImpl implements InviteService {
             String removalCode = codeGenerateCk();
             for(AskGoods askGoods : list){
                 askGoods.setStorageCode(removalCode);
+                askGoods.setCompanyNumber(askGoods.getAccountSleeve());
                 Inventory inventory = inviteMapper.getInventory(askGoods);
                 if(inventory == null){
                     throw new Exception("库存不存在");
@@ -144,7 +145,7 @@ public class InviteServiceImpl implements InviteService {
                     inventory.setAmount(askGoods.getNum());
                     inviteMapper.updateInventory(inventory);
                 }
-                String materialId = inviteMapper.getMaterialId(askGoods.getWllbCode(), askGoods.getAccountSleeve());//查询物料id
+                String materialId = inviteMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 AskGoods askGoods1 = inviteMapper.getAskDetailed(askGoodsId, materialId);//查询要料申请单内容
                 ReturRemoval returRemoval = new ReturRemoval()
                         .setMaterialId(materialId)

+ 2 - 2
src/main/java/com/tld/service/impl/WarehouseTransferServiceImpl.java

@@ -98,7 +98,7 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                     inventory.setAmount(askGoods.getNum());
                     askGoodsMapper.updateInventory(inventory);
                 }
-                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode(), askGoods.getAccountSleeve());//查询物料id
+                String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 WarehouseTransfer warehouseTransfer = warehouseTransferMapper.getWarehouseTransferDetailed(askGoodsId, materialId);//查询移库申请内容
 //                //入库流水信息
 //                WarehousingVirtual WarehousingVirtual1 = new WarehousingVirtual()
@@ -159,7 +159,7 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
             //查询入库所需要的信息
             for(WarehousingVirtual warehousingVirtual : warehousingVirtualList) {
                 //查询采购单信息
-                String materialId = askGoodsMapper.getMaterialId(warehousingVirtual.getWllbCode(), warehousingVirtual.getAccountSleeve());//查询物料id
+                String materialId = askGoodsMapper.getMaterialId(warehousingVirtual.getWllbCode());//查询物料id
                 WarehouseTransfer warehouseTransfer = warehouseTransferMapper.getWarehouseTransferDetailed(warehousingVirtual.getWarehouseTransferId(), materialId);//查询移库申请内容
                 if(warehouseTransfer != null) {
                     //WBS

+ 2 - 2
src/main/resources/mapper/AskGoodsMapper.xml

@@ -152,7 +152,7 @@
             a.wbs,
             a.measurement_id,
             a.num,
-            a.out_num
+            ifnull(a.out_num, 0) as out_num
         FROM
             tld_ask_goods a
             join tld_material b on a.material_id = b.tld_id
@@ -206,7 +206,7 @@
     </insert>
     <!-- 查询指定物料类型的id -->
     <select id="getMaterialId" resultType="String">
-        select tld_id from tld_material where code = #{wllbCode} and company_number = #{accountSleeve}
+        select tld_id from tld_material where code = #{wllbCode}
     </select>
     <!-- 查询要料申请单内容 -->
     <select id="getAskDetailed" resultType="com.tld.model.AskGoods">

+ 18 - 3
src/main/resources/mapper/DeliveryMapper.xml

@@ -58,7 +58,7 @@
         FROM tld_inventory a
         LEFT JOIN tld_storage_location b on a.storage_location_code = b.storage_location_code
         WHERE #{storageLocationCode} LIKE CONCAT( '%', CONCAT( a.storage_location_code, ',' ), '%' )
-          AND a.material_id = #{delivery.materialId} AND a.hold = '0'
+          AND a.material_id = #{delivery.materialId} AND a.hold = '0' AND a.wbs = #{delivery.wbs}
         <if test="delivery.attribute != null and delivery.attribute != ''">
             and a.attribute = #{delivery.attribute}
         </if>
@@ -90,10 +90,10 @@
     <!-- 查询指定库存被占用数量 -->
     <select id="getVitrual" resultType="int">
         select
-               ifnull(sum(a.num), 0)
+               count(*)
         from tld_ask_goods_vitrual a
         join tld_material b on a.wllb_code = b.code
-        where a.storage_location_code = #{storageLocationCode} and b.code = #{wllbCode} and a.attribute = #{attribute} and a.produc_date = #{producBatch}
+        where a.storage_location_code = #{storageLocationCode} and b.code = #{wllbCode} and a.attribute = #{attribute} and a.produc_date = #{producBatch} and serial = #{serial}
     </select>
     <!-- 修改销售单出库数量 -->
     <update id="updateDelivery">
@@ -149,4 +149,19 @@
             part_type
         from tld_material where tld_id = #{materialId}
     </select>
+    <!-- 查询虚拟表半成品扫描数量 -->
+    <select id="getProductNumVitrual" resultType="int">
+        select
+            sum(num) as num
+        from tld_ask_goods_vitrual a
+        join tld_material b on a.wllb_code = b.code
+        where a.storage_location_code = #{storageLocationCode} and b.code = #{wllbCode} and a.wbs = #{wbs}
+    </select>
+    <!-- 查询库存数量是否充足 -->
+    <select id="getScanIsNot" resultType="java.util.Map">
+        select
+            (select ifnull(amount,0) from tld_inventory where id = #{id}) as amount,
+            (select ifnull(sum(num),0) from tld_ask_goods_vitrual where wbs = #{wbs} and wllb_code = #{wllbCode} and storage_location_code = #{storageLocationCode} and produc_date = #{producDate}) as vitrualNum
+        from dual
+    </select>
 </mapper>

+ 1 - 1
src/main/resources/mapper/DictionaryMapper.xml

@@ -24,7 +24,7 @@
                 and name like CONCAT(CONCAT('%', #{name}), '%')
             </if>
             <if test="code != null and code != ''">
-                and code = #{code}
+                and code like CONCAT(CONCAT('%', #{code}), '%')
             </if>
             <if test="tldId != null and tldId != ''">
                 and tld_id = #{tldId}

+ 5 - 3
src/main/resources/mapper/InviteMapper.xml

@@ -67,7 +67,9 @@
             e.CODE AS materialCode,
             b.ask_goods_code,
             b.company_number,
-            b.department
+            c.name ,
+            c.code,
+            c.id AS departmentId
         FROM
             tld_invite a
             JOIN tld_invite_f b ON a.ask_goods_id = b.ask_goods_id
@@ -215,7 +217,7 @@
     </insert>
     <!-- 查询指定物料类型的id -->
     <select id="getMaterialId" resultType="String">
-        select tld_id from tld_material where code = #{wllbCode} and company_number = #{accountSleeve}
+        select tld_id from tld_material where code = #{wllbCode}
     </select>
     <!-- 查询要料申请单内容 -->
     <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
@@ -426,6 +428,6 @@
     <!-- 修改出库数量 -->
     <update id="updateOutNum">
         update tld_invite
-        set ifnull(out_num, 0) = out_num + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
+        set out_num = ifnull(out_num,0) + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
     </update>
 </mapper>

+ 2 - 2
src/main/resources/mapper/ReceiveGoodsMapper.xml

@@ -152,7 +152,7 @@
             c.name as supplierName
         from tld_purchase a
         left join tld_material b on a.material_id = b.tld_id
-        left join tld_customer c on a.supplier_id = c.tld_id
+        left join tld_customer c on a.supplier_id = c.code
         <trim prefix="WHERE" prefixOverrides="and |or">
             <if test="orderCode != null and orderCode != ''">
                 and a.order_code = #{orderCode}
@@ -181,7 +181,7 @@
             c.name as supplierName
         from tld_purchase a
         left join tld_material b on a.material_id = b.tld_id
-        left join tld_customer c on a.supplier_id = c.tld_id
+        left join tld_customer c on a.supplier_id = c.code
         where
             a.arrival_time <![CDATA[<]]> CURDATE() and type = '0'
         <if test="orderCode != null and orderCode != ''">

+ 6 - 6
src/main/resources/mapper/WarehousingMapper.xml

@@ -12,7 +12,7 @@
             a.storage_location_code,
             a.wllb_code
         from tld_material_class a
-        join tld_material b on a.wllb_code = b.tld_id
+        join tld_material b on a.wllb_code = b.code
         where b.code = #{wllbCode}
     </select>
     <!-- 根据物料分类查询库位 -->
@@ -22,7 +22,7 @@
             b.storage_location_code
         from tld_material a
         join tld_storage_location b on a.wllb_class = b.storage_location_type
-        where a.wllb_code = #{wllbCode}
+        where a.code = #{wllbCode}
     </select>
     <!-- 新增库位信息虚拟表 -->
     <insert id="addWarehousingVirtual">
@@ -125,7 +125,7 @@
             tld_receive_goods a
             LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
             JOIN tld_material c on a.material_id = c.tld_id
-            LEFT JOIN tld_customer f on a.supplier_id = f.tld_id
+            LEFT JOIN tld_customer f on a.supplier_id = f.code
         WHERE
             a.supplier_id = #{suppId} and IFNULL(a.warehousing_num, 0 ) <![CDATA[<]]> a.qualified_num and c.code = #{wllbCode}
         ORDER BY
@@ -370,16 +370,16 @@
     </insert>
     <!-- 查询库存里是否存在半成品虚拟库位 -->
     <select id="getInventoryNotice" resultType="int">
-        select count(0) from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and account_sleeve = #{companyNumber}
+        select count(0) from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and account_sleeve = #{companyNumber} and wbs = #{wbs}
     </select>
     <!-- 增加半成品/产成品虚拟库位数量 -->
     <update id="updateInventoryNotice">
-        update tld_inventory set amount = amount + #{warehousingNum},totime = now() where storage_location_code = #{storageLocationCode} and material_id = #{materialId};
+        update tld_inventory set amount = amount + #{warehousingNum},totime = now() where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and wbs = #{wbs} and produc_batch = #{producBatch};
         update tld_notice set warehousing_num = #{warehousingNum},type = '1' where notice_id = #{noticeId} and material_id = #{materialId}
     </update>
     <!-- 半成品出库库存查询 -->
     <select id="getHalfInventory" resultType="com.tld.model.Inventory">
-        select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and account_sleeve = #{companyNumber} and wbs = #{wbs}
+        select storage_location_code,wllb_class,material_id,amount from tld_inventory where storage_location_code = #{storageLocationCode} and material_id = #{materialId} and account_sleeve = #{companyNumber} and wbs = #{wbs} order by produc_batch
     </select>
     <!-- 删除库存信息 -->
     <delete id="delInventoryNotice">