zhs %!s(int64=2) %!d(string=hai) anos
pai
achega
6e8ff61dd7

+ 2 - 2
src/main/java/com/tld/controller/WarehousingController.java

@@ -209,7 +209,7 @@ public class WarehousingController {
      * 推荐库位后其他入库
      */
     @GetMapping("otherWarehou")
-    public Map<String, Object> otherWarehou(Inventory inventory){
-        return warehousingService.otherWarehou(inventory);
+    public Map<String, Object> otherWarehou(Inventory inventory, HttpServletRequest request){
+        return warehousingService.otherWarehou(inventory, request);
     }
 }

+ 2 - 0
src/main/java/com/tld/mapper/AskGoodsMapper.java

@@ -115,4 +115,6 @@ public interface AskGoodsMapper {
     AskGoods getWareInfo(AskGoods askGoods);
 
     Inventory getInventoryWarehousing(AskGoods askGoods);
+
+    List<Inventory> getInventoryInfoOther(AskGoods askGoods);
 }

+ 2 - 0
src/main/java/com/tld/mapper/WarehousingMapper.java

@@ -124,4 +124,6 @@ public interface WarehousingMapper {
     void addgeetStorget(Map<String, Object> map);
 
     void updategeetStorget(Map<String, Object> map);
+
+    void addInventoryOther(Inventory inventory);
 }

+ 1 - 1
src/main/java/com/tld/service/WarehousingService.java

@@ -45,7 +45,7 @@ public interface WarehousingService {
 
     Map<String, Object> otherWarehousing(AskGoods askGoods);
 
-    Map<String, Object> otherWarehou(Inventory inventory);
+    Map<String, Object> otherWarehou(Inventory inventory, HttpServletRequest request);
 
     void test();
 }

+ 16 - 34
src/main/java/com/tld/service/impl/WarehousingServiceImpl.java

@@ -803,37 +803,13 @@ public class WarehousingServiceImpl implements WarehousingService {
     public Map<String, Object> otherWarehousing(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
         try {
-            //查询库存
-            List<Inventory> inventory = askGoodsMapper.getInventoryInfo(askGoods);
             //判断物料是否录入
-            MaterialClass materialClass = warehousingMapper.getMateriaIsExist(askGoods.getMaterialCode());
-            if(inventory.size() == 0){
-                map.put("data", materialClass.getPartType());
-                map.put("msg", "500");
-                return map;
-            } else {
-                warehousingMapper.updateInventoryOther(inventory.get(0));
-                List<WarehousingVirtual> list = new LinkedList<>();
-                String storageCode = codeGenerateRk();
-                WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
-                        .setStorageCode(storageCode)
-                        .setWllbCode(materialClass.getWllbCode())
-                        .setSuppId(inventory.get(0).getSupplierId())
-                        .setSerial(inventory.get(0).getSerial())
-                        .setProducDate(inventory.get(0).getProducDate())
-                        .setCapacity(askGoods.getNum())
-                        .setType("其他入库")
-                        .setUserId(askGoods.getUserId())
-                        .setDepartmentId(askGoods.getDepartmentId())
-                        .setStorageLocationCode(inventory.get(0).getStorageLocationCode())
-                        .setWbs(inventory.get(0).getWbs())
-                        .setAccountSleeve(inventory.get(0).getAccountSleeve())
-                        .setMaterialId(materialClass.getTldId());
-                list.add(warehousingVirtual);
-                warehousingMapper.addStorage(list);//入库流水
-                warehousingMapper.addReturnWarehousingOther(warehousingVirtual);//其他入库返回信息
-                map.put("data", storageCode);
-            }
+            MaterialClass materialClass = warehousingMapper.getMateriaIsExist(askGoods.getWllbCode());
+            askGoods.setMaterialId(materialClass.getTldId());
+            //查询库存
+            List<Inventory> inventory = askGoodsMapper.getInventoryInfoOther(askGoods);
+            map.put("list", inventory);
+            map.put("data", materialClass);
             map.put("msg", "200");
         } catch (Exception e) {
             e.printStackTrace();
@@ -844,14 +820,20 @@ public class WarehousingServiceImpl implements WarehousingService {
     }
 
     @Override
-    public Map<String, Object> otherWarehou(Inventory inventory) {
+    public Map<String, Object> otherWarehou(Inventory inventory, HttpServletRequest request) {
         Map<String, Object> map = new HashMap<>();
         try {
             //判断物料是否录入
             MaterialClass materialClass = warehousingMapper.getMateriaIsExist(inventory.getWllbCode());
-            warehousingMapper.updateInventoryOther(inventory);
+            String userId = request.getHeader("userId");
+            inventory.setWllbClass(materialClass.getWllbClass()).setMaterialId(inventory.getMaterialId()).setUserId(userId);
+            if(inventory.getId() != null){
+                warehousingMapper.addInventoryOther(inventory);
+            } else {
+                warehousingMapper.updateInventoryOther(inventory);
+            }
             List<WarehousingVirtual> list = new LinkedList<>();
-            String storageCode = codeGenerateRk();
+            String storageCode = codeGenerateRk();//入库单
             WarehousingVirtual warehousingVirtual = new WarehousingVirtual()
                     .setStorageCode(storageCode)
                     .setWllbCode(materialClass.getWllbCode())
@@ -860,7 +842,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                     .setProducDate(inventory.getProducDate())
                     .setCapacity(inventory.getNum())
                     .setType("其他入库")
-                    .setUserId(inventory.getUserId())
+                    .setUserId(userId)
                     .setDepartmentId(inventory.getDepartmentId())
                     .setStorageLocationCode(inventory.getStorageLocationCode())
                     .setWbs(inventory.getWbs())

+ 45 - 0
src/main/resources/mapper/AskGoodsMapper.xml

@@ -634,6 +634,51 @@
             and supplier_id = #{supplierId}
         </if>
     </select>
+    <!-- 其他入库查询库存是否存在 -->
+    <select id="getInventoryInfoOther" resultType="com.tld.model.Inventory">
+        select
+            id,
+            storage_location_code,
+            wllb_class,
+            library_type,
+            material_id,
+            amount,
+            total,
+            totime,
+            hold,
+            amount_lock,
+            account_sleeve,
+            wbs,
+            supplier_id,
+            serial,
+            wllb_code,
+            produc_date,
+            scrq,
+            produc_batch,
+            attribute
+        from tld_inventory where material_id = #{materialId} and account_sleeve = #{accountSleeve}
+        <if test="wbs != '' and wbs != null">
+            and wbs = #{wbs}
+        </if>
+        <if test="wbs == ''.toString() or wbs == null ">
+            and wbs is null
+        </if>
+        <if test="serial != '' and serial != null">
+            and serial = #{serial}
+        </if>
+        <if test="attribute != '' and attribute != null">
+            and attribute = #{attribute}
+        </if>
+        <if test="producDate != '' and producDate != null">
+            and produc_batch = #{producDate}
+        </if>
+        <if test="supplierId != '' and supplierId != null">
+            and supplier_id = #{supplierId}
+        </if>
+        <if test="storageLocationCode != '' and storageLocationCode != null">
+            and storage_location_code = #{storageLocationCode}
+        </if>
+    </select>
     <!-- 查询仓库 -->
     <select id="getWarehouseWhere" resultType="String">
         SELECT

+ 8 - 2
src/main/resources/mapper/WarehousingMapper.xml

@@ -378,11 +378,11 @@
     </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} and wbs = #{wbs}
+        select count(*) 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} and wbs = #{wbs} and produc_batch = #{producBatch};
+        update tld_inventory set amoun0t = 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>
     <!-- 半成品出库库存查询 -->
@@ -685,6 +685,12 @@
         insert into tld_return_gs_other_warehousing(storage_code,account_sleeve,storage_location_code,wbs,amount,material_id)
         value(#{storageCode},#{accountSleeve},#{storageLocationCode},#{wbs},#{amount},#{materialId})
     </insert>
+    <!-- 其他入库 -->
+    <insert id="addInventoryOther">
+        insert into
+            tld_inventory(storage_location_code,wllb_class,library_type,material_id,amount,totime,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date,scrq,produc_batch,attribute)
+            value(#{storageLocationCode},#{wllbClass},#{libraryType},#{materialId},#{amount},now(),'0',#{accountSleeve},#{wbs},#{supplierId},#{serial},#{wllbCode},#{producDate},now(),#{producDate},#{attribute})
+    </insert>
 
     <select id="gettest" resultType="java.util.Map">
         select * from tld_test