zhs hace 2 años
padre
commit
7367b66e5e

+ 9 - 0
src/main/java/com/tld/controller/AskGoodsController.java

@@ -60,6 +60,15 @@ public class AskGoodsController {
         return askGoodsService.addAskGoodsVitrual(askGoods);
     }
 
+    /**
+     * 移库入虚拟库
+     * @param askGoods 參數
+     * @return 返回結果
+     */
+    @PostMapping("addWarehouseTransferVitrual")
+    public Map<String, Object> addWarehouseTransferVitrual(@RequestBody AskGoods askGoods){
+        return askGoodsService.addWarehouseTransferVitrual(askGoods);
+    }
     /**
      * 出库
      */

+ 12 - 11
src/main/java/com/tld/controller/WarehouseTransferController.java

@@ -2,6 +2,7 @@ package com.tld.controller;
 
 import com.tld.model.AskGoods;
 import com.tld.model.WarehouseTransfer;
+import com.tld.model.WarehousingVirtual;
 import com.tld.service.WarehouseTransferService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -31,17 +32,7 @@ public class WarehouseTransferController {
     }
 
     /**
-     * 推荐库位
-     * @param warehouseTransfer 参数
-     * @return 返回结果
-     */
-    @GetMapping("getRecommend")
-    public Map<String, Object> getRecommend(WarehouseTransfer warehouseTransfer){
-        return warehouseTransferService.getRecommend(warehouseTransfer);
-    }
-
-    /**
-     * 插入出库虚拟表
+     * 半成品出库入虚拟表
      * @param askGoods 参数
      * @return 返回结果
      */
@@ -77,4 +68,14 @@ public class WarehouseTransferController {
     public Map<String, Object> delWarehouseTransfer(String id , HttpServletRequest request){
         return warehouseTransferService.delWarehouseTransfer(id,request);
     }
+
+    /**
+     * 物料库位选择
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getMaterialCk")
+    public Map<String, Object> getMaterialCk(AskGoods askGoods){
+        return warehouseTransferService.getMaterialCk(askGoods);
+    }
 }

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

@@ -28,8 +28,8 @@ public class WarehousingController {
      * @return 返回结果
      */
     @GetMapping("getRecommend")
-    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate){
-        return warehousingService.getRecommend(wllbCode, suppId, num, unique, producDate);
+    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere){
+        return warehousingService.getRecommend(wllbCode, suppId, num, unique, producDate, warehouseWhere);
     }
 
     /**

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

@@ -112,4 +112,5 @@ public interface AskGoodsMapper {
 
     List<Map<String, Object>> getGsRemoval(@Param("removalCode") String removalCode);
 
+    AskGoods getWareInfo(AskGoods askGoods);
 }

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

@@ -38,4 +38,6 @@ public interface WarehouseTransferMapper {
     Integer getScanNumWare(WarehouseTransfer warehouseTransfer1);
 
     WarehouseTransfer getAsknInfo(AskGoods askGoods);
+
+    List<Inventory> getMaterialWarehouseTransfer(AskGoods askGoods);
 }

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

@@ -51,7 +51,7 @@ public interface WarehousingMapper {
 
     List<Map<String, Object>> export(Storage storage);
 
-    Map<String, Object> getScanIsNot(@Param("wllbCode")String wllbCode, @Param("suppId")String suppId, @Param("unique")String unique, @Param("producDate")String producDate);
+    Map<String, Object> getScanIsNot(@Param("wllbCode")String wllbCode, @Param("suppId")String suppId, @Param("unique")String unique, @Param("producDate")String producDate, @Param("warehouseWhere")String warehouseWhere);
 
     MaterialClass getMateriaIsExist(String wllbCode);
 

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

@@ -208,4 +208,8 @@ public class AskGoods implements Serializable {
      * 库存id
      */
     private String inventoryId;
+    /**
+     * 移库入库库位
+     */
+    private String storageLocationCodeRk;
 }

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

@@ -118,4 +118,8 @@ public class WarehouseTransfer {
      * 要货仓库状态
      */
     private String askType;
+    /**
+     * 供货仓库状态
+     */
+    private String suppType;
 }

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

@@ -140,5 +140,9 @@ public class WarehousingVirtual implements Serializable {
      * 移库通知单id
      */
     private String warehouseTransferId;
+    /**
+     * 移库出库库位
+     */
+    private String storageLocationCodeCk;
 
 }

+ 2 - 0
src/main/java/com/tld/service/AskGoodsService.java

@@ -45,4 +45,6 @@ public interface AskGoodsService {
     Map<String, Object> delAskGoods(String id, HttpServletRequest request);
 
     void CreateBOLOutStock(String removalCode);
+
+    Map<String, Object> addWarehouseTransferVitrual(AskGoods askGoods);
 }

+ 3 - 2
src/main/java/com/tld/service/WarehouseTransferService.java

@@ -2,6 +2,7 @@ package com.tld.service;
 
 import com.tld.model.AskGoods;
 import com.tld.model.WarehouseTransfer;
+import com.tld.model.WarehousingVirtual;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Map;
@@ -9,8 +10,6 @@ import java.util.Map;
 public interface WarehouseTransferService {
     Map<String, Object> getWarehouseTransfer(WarehouseTransfer warehouseTransfer);
 
-    Map<String, Object> getRecommend(WarehouseTransfer warehouseTransfer);
-
     Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId);
 
     Map<String, Object> warehousing(String uniqueCode, String type);
@@ -18,4 +17,6 @@ public interface WarehouseTransferService {
     Map<String, Object> delWarehouseTransfer(String id, HttpServletRequest request);
 
     Map<String, Object> addAskGoodsVitrual(AskGoods askGoods);
+
+    Map<String, Object> getMaterialCk(AskGoods askGoods);
 }

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

@@ -7,7 +7,7 @@ import javax.servlet.http.HttpServletResponse;
 import java.util.Map;
 
 public interface WarehousingService {
-    Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate);
+    Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere);
 
     Map<String, Object> addWarehousingVirtual(WarehousingVirtual warehousingVirtual);
 

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

@@ -735,6 +735,39 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         }
     }
 
+    @Override
+    public Map<String, Object> addWarehouseTransferVitrual(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            Map<String, Object> mapVal = askGoodsMapper.getScanIsNot(askGoods);
+            if((Double.parseDouble(mapVal.get("inventoryNum").toString()) - Double.parseDouble(mapVal.get("virtualNum").toString())) == 0){
+                map.put("msg", "500");
+                map.put("errMsg", "已全部出库");
+                return map;
+            }
+            Inventory inventory = askGoodsMapper.getInventory(askGoods); //库存数量
+            AskGoods askGoods1 = askGoodsMapper.getWareInfo(askGoods); //要货单数量
+            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()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
+
+            if(surplusNum >= inventorySurplus){
+                askGoods.setNum(String.valueOf(inventorySurplus));
+            } else {
+                askGoods.setNum(String.valueOf(surplusNum));
+            }
+            askGoods.setStorageLocationCode(inventory.getStorageLocationCode());//库存编号
+            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
     /**
      * 出库单生成
      * @return

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

@@ -66,32 +66,6 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
         return map;
     }
 
-    @Override
-    public Map<String, Object> getRecommend(WarehouseTransfer warehouseTransfer) {
-        Map<String, Object> map = new HashMap<>();
-        try{
-            Dictionary dictionary = dictionaryMapper.getWarehouseInfo(warehouseTransfer);
-            List<Inventory> list = new LinkedList<>();
-            for(Inventory inventory : warehouseTransferMapper.getMaterialCk(warehouseTransfer)){
-                AskGoods askGoods1 = warehouseTransferMapper.getAsk(inventory);
-                if(askGoods1 != null){
-                    if(Double.parseDouble(askGoods1.getNum()) != Double.parseDouble(inventory.getAmount())){
-                        list.add(inventory);
-                    }
-                } else {
-                    list.add(inventory);
-                }
-            }
-            map.put("data", list);
-            map.put("msg", "200");
-        }catch (Exception e){
-            e.printStackTrace();
-            map.put("msg", "500");
-            map.put("errMsg", "失败");
-        }
-        return map;
-    }
-
     @Override
     public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId) {
         Map<String, Object> map = new HashMap<>();
@@ -108,6 +82,7 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 //查询物料信息
                 MaterialClass material = warehousingMapper.getMaterial(new Notice().setMaterialCode(askGoods.getWllbCode()));
                 Inventory inventory = new Inventory();
+                askGoods.setCompanyNumber(askGoods.getAccountSleeve());
                 if(material.getPartType().equals("原材料")){
                     inventory = askGoodsMapper.getInventory(askGoods);
                 } else if(material.getPartType().equals("产成品")){
@@ -116,7 +91,9 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                     inventory = askGoodsMapper.getInventoryInfo(askGoods).get(0);
                 }
                 if(inventory == null){
-                    throw new Exception("库存不存在");
+                    map.put("msg", "500");
+                    map.put("errMsg", "库存不存在");
+                    return map;
                 }
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
@@ -127,7 +104,7 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 }
                 String materialId = askGoodsMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
                 WarehouseTransfer warehouseTransfer = warehouseTransferMapper.getWarehouseTransferDetailed(askGoodsId, materialId);//查询移库申请内容
-//                //入库流水信息
+                //入库流水信息
                 WarehousingVirtual WarehousingVirtual1 = new WarehousingVirtual()
                         .setWllbCode(askGoods.getWllbCode()) //物料code
                         .setSuppId(askGoods.getSupplierId())//供应商id
@@ -137,11 +114,15 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                         .setSeq("0")
                         .setType(askGoods.getType())//入库类型
                         .setUserId(askGoods.getUserId())//用户
-                        .setDepartmentId(askGoods.getDepartmentId())//部门
-                        .setStorageLocationCode(askGoods.getStorageLocationCode())//库位编号
+                        .setDepartmentId(askGoods.getDepartment())//部门
+                        .setStorageLocationCode(askGoods.getStorageLocationCodeRk())//库位编号
                         .setStorageCode(warehouseTransferCode)//移库单号
-                        .setWbs(warehouseTransfer.getWbs());//wbs
+                        .setWbs(warehouseTransfer.getWbs())//wbs
+                        .setMaterialId(materialId)//物料id
+                        .setAccountSleeve(warehouseTransfer.getAccountSleeve())//公司
+                        .setWllbClass(material.getWllbClass());
                 warehousing.add(WarehousingVirtual1);
+                askGoods.setStorageLocationCode(askGoods.getStorageLocationCode());
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
                 askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
                 warehouseTransferMapper.updateOutNum(askGoods.getNum(), askGoodsId, materialId);//修改出库数量
@@ -162,6 +143,7 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                     .setWarehouseTransferType(warehouseTransferF.getWarehouseTransferType()); //移库类型
             warehouseTransferMapper.addReturnGsWarehouseTransferF(warehouseTransfer1);//新增返回gs数据父表信息
             warehousingMapper.addStorage(warehousing);//入库流水
+            warehousingMapper.addInventory(warehousing);//库存
             map.put("data", warehouseTransferCode);
             map.put("msg", "200");
         }catch (Exception e){
@@ -194,7 +176,8 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 if(warehouseTransfer != null) {
                     //WBS
                     warehousingVirtual.setWbs(warehouseTransfer.getWbs());
-                    warehousingVirtual.setWbs(warehouseTransfer.getWbs());
+                    //账套
+                    warehousingVirtual.setAccountSleeve(warehouseTransfer.getAccountSleeve());
                 }
                 //查询部门编号
                 List<User> listUser = userMapper.getAllUser(new User().setId(Integer.parseInt(warehousingVirtual.getUserId())));
@@ -207,8 +190,35 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
                 list.add(warehousingVirtual);
                 warehouseTransferMapper.updateOutNum(warehousingVirtual.getNum(), warehousingVirtual.getWarehouseTransferId(), materialId);//修改出库数量
 
-
-                AskGoods askGoods = new AskGoods();
+                AskGoods askGoods = new AskGoods()
+                        .setStorageLocationCode(warehousingVirtual.getStorageLocationCodeCk())
+                        .setSupplierId(warehousingVirtual.getSuppId())
+                        .setSerial(warehousingVirtual.getSerial())
+                        .setNum(warehousingVirtual.getNum())
+                        .setType(warehousingVirtual.getType())
+                        .setUserId(warehousingVirtual.getUserId())
+                        .setWllbCode(warehousingVirtual.getWllbCode())
+                        .setStorageCode(warehouseTransferCode)
+                        .setWbs(warehousingVirtual.getWbs())
+                        .setProducDate(warehousingVirtual.getProducDate())
+                        .setDepartment(listUser.get(0).getDepartmentId())
+                        .setAskGoodsId(warehousingVirtual.getWarehouseTransferId())
+                        .setCompanyNumber(warehouseTransfer.getAccountSleeve());
+                Inventory inventory = new Inventory();
+                if(material.getPartType().equals("原材料")){
+                    inventory = askGoodsMapper.getInventory(askGoods);
+                } else if(material.getPartType().equals("产成品")){
+                    inventory = deliveryMapper.getInventoryHalf(askGoods);
+                } else if(material.getPartType().equals("半成品")){
+                    inventory = askGoodsMapper.getInventoryInfo(askGoods).get(0);
+                }
+                //如果出库库存等于虚拟表库存则删除此库存
+                if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
+                    askGoodsMapper.deleteInventory(inventory);
+                } else {
+                    inventory.setAmount(askGoods.getNum());
+                    askGoodsMapper.updateInventory(inventory);
+                }
                 askGoodsMapper.addRemoval(askGoods);//插入出库流水
 
 
@@ -275,30 +285,35 @@ public class WarehouseTransferServiceImpl implements WarehouseTransferService {
     }
 
     @Override
-    @Transactional(rollbackFor = Exception.class)
     public Map<String, Object> addAskGoodsVitrual(AskGoods askGoods) {
         Map<String, Object> map = new HashMap<>();
         try{
-            Map<String, Object> mapVal = askGoodsMapper.getScanIsNot(askGoods);
-            if((Double.parseDouble(mapVal.get("inventoryNum").toString()) - Double.parseDouble(mapVal.get("virtualNum").toString())) == 0){
-                map.put("msg", "500");
-                map.put("errMsg", "已全部出库");
-                return map;
-            }
-            Inventory inventory = askGoodsMapper.getInventory(askGoods); //库存数量
-            WarehouseTransfer askGoods1 = warehouseTransferMapper.getAsknInfo(askGoods); //移库数量
-            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()) - Double.parseDouble(askGoods1.getOutNum()) - alreadyNum; //剩余要扫描数量
+            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
 
-            if(surplusNum >= inventorySurplus){
-                askGoods.setNum(String.valueOf(inventorySurplus));
-            } else {
-                askGoods.setNum(String.valueOf(surplusNum));
+    @Override
+    public Map<String, Object> getMaterialCk(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<Inventory> list = new LinkedList<>();
+            for(Inventory inventory : warehouseTransferMapper.getMaterialWarehouseTransfer(askGoods)){
+                AskGoods askGoods1 = warehouseTransferMapper.getAsk(inventory);
+                if(askGoods1 != null){
+                    if(Double.parseDouble(askGoods1.getNum()) != Double.parseDouble(inventory.getAmount())){
+                        list.add(inventory);
+                    }
+                } else {
+                    list.add(inventory);
+                }
             }
-            askGoods.setStorageLocationCode(inventory.getStorageLocationCode());//库存编号
-            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("data", list);
             map.put("msg", "200");
         }catch (Exception e){
             e.printStackTrace();

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

@@ -51,7 +51,7 @@ public class WarehousingServiceImpl implements WarehousingService {
     private DictionaryMapper dictionaryMapper;
 
     @Override
-    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate) {
+    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate, String warehouseWhere) {
         Map<String, Object> map = new HashMap<>();
         try{
             //判断物料是否录入
@@ -66,7 +66,7 @@ public class WarehousingServiceImpl implements WarehousingService {
                 map.put("errMsg", "此物料是" + materialClass.getPartType());
                 return map;
             }
-            Map<String, Object> mapVal = warehousingMapper.getScanIsNot(wllbCode, suppId, unique, producDate);
+            Map<String, Object> mapVal = warehousingMapper.getScanIsNot(wllbCode, suppId, unique, producDate, warehouseWhere);
             if(Integer.parseInt(mapVal.get("inventoryCount").toString()) != 0 || Integer.parseInt(mapVal.get("virtualCount").toString()) != 0){
                 map.put("msg", "500");
                 map.put("errMsg", "已被扫描");

+ 9 - 0
src/main/resources/application.yml

@@ -12,11 +12,20 @@ spring:
       primary: master
       strict: true
       datasource:
+        # 主库数据源
         master:
           username: root
           password: "#09SilverB"
           url: jdbc:mysql://8.142.144.205:3306/tld?useUnicode=true&characterEncoding=utf-8&useSSL=true&rewriteBatchedStatements=true&allowMultiQueries=true
           driver-class-name: com.mysql.cj.jdbc.Driver
+        # 从数据源
+#        slave:
+#          # 从数据源开关/默认关闭
+#          enabled: true
+#          url: jdbc:mysql://10.2.111.92:3306/okr?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&allowMultiQueries=true
+#          username: root
+#          password: "#09SilverB"
+        # sqlserver
 #        ds2:
 #          username: sa
 #          password: "#09SilverB"

+ 26 - 6
src/main/resources/mapper/AskGoodsMapper.xml

@@ -96,12 +96,14 @@
             b.storage_location_name as storageLocationName
         from tld_inventory a
         join tld_storage_location b on a.storage_location_code = b.storage_location_code
-        where a.material_id = #{materialId} and a.account_sleeve = #{companyNumber} and a.hold = '0' and b.warehouse_where != '5000' order by a.produc_date
+        join tld_warehouse c on b.warehouse_where = c.tld_id
+        where a.material_id = #{materialId} and a.account_sleeve = #{companyNumber} and a.hold = '0' and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
+        order by a.produc_date
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
-        insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department,attribute,account_sleeve)
-        values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department},#{attribute},#{companyNumber})
+        insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type,storage_location_code,num,user_id,department,attribute,account_sleeve,storage_location_code_rk,wbs)
+        values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department},#{attribute},#{companyNumber},#{storageLocationCodeRk},#{wbs})
     </insert>
     <!-- 查询指定库存内容 -->
     <select id="getInventory" resultType="com.tld.model.Inventory">
@@ -123,7 +125,7 @@
            wllb_code,
            produc_date,
            scrq
-        from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber}
+        from tld_inventory where supplier_id = #{supplierId} and serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and account_sleeve = #{companyNumber} and wbs = #{wbs}
     </select>
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
@@ -132,7 +134,7 @@
         FROM
             tld_ask_goods_vitrual a
             join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
-        where a.storage_location_code = #{storageLocationCode}
+        where a.storage_location_code = #{storageLocationCode} and a.serial = #{serial}
     </select>
     <!-- 查询是否扫描 -->
     <select id="getScanIsNot" resultType="java.util.Map">
@@ -158,6 +160,22 @@
             join tld_material b on a.material_id = b.tld_id
         where a.ask_goods_id = #{askGoodsId} and b.code = #{wllbCode}
     </select>
+    <!-- 查询指定移庫單 -->
+    <select id="getWareInfo" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.warehouse_transfer_id as askGoodsId,
+            a.entry_number,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            ifnull(a.out_num, 0) as out_num
+        FROM
+            tld_warehouse_transfer a
+            join tld_material b on a.material_id = b.tld_id
+        where a.warehouse_transfer_id = #{askGoodsId} and b.code = #{wllbCode}
+    </select>
     <!-- 查询已扫描总数 -->
     <select id="getAskInfoNumVitrual" resultType="int">
         select ifnull(sum(num), 0) from tld_ask_goods_vitrual where wllb_code = #{wllbCode} and ask_goods_id = #{askGoodsId} and type = #{type}
@@ -181,7 +199,9 @@
             num,
             user_id,
             department,
-            account_sleeve
+            account_sleeve,
+            wbs,
+            storage_location_code_rk
         from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
     </select>
     <!-- 删除库存 -->

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

@@ -85,7 +85,7 @@
             b.storage_location_name as storageLocationName
         FROM tld_inventory a
         JOIN tld_material b on a.material_id = b.tld_id
-        WHERE a.attribute = #{attribute} and a.produc_batch = #{producDate} and a.serial = #{serial} and b.code = #{wllbCode} and a.account_sleeve = #{companyNumber}
+        WHERE a.attribute = #{attribute} and a.produc_batch = #{producDate} and a.serial = #{serial} and b.code = #{wllbCode} and a.account_sleeve = #{companyNumber} and wbs = #{wbs}
     </select>
     <!-- 查询指定库存被占用数量 -->
     <select id="getVitrual" resultType="int">

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

@@ -81,7 +81,7 @@
     </select>
     <!-- 查询指定pda 指定物料扫描总数 -->
     <select id="getScanNum" resultType="String">
-        select if(sum(num) is null, 0, num)
+        select if(sum(num) is null, 0, sum(num))
         from tld_ask_goods_vitrual
         where unique_code = #{uniqueCode} and ask_goods_id = #{askGoodsId}
     </select>

+ 53 - 19
src/main/resources/mapper/WarehouseTransferMapper.xml

@@ -24,7 +24,8 @@
             c.part_type as partType,
             f.name as askGoodsWarehouseaName,
             e.name as supplyWarehouseName,
-            ifnull(f.warehouse_type, 10) as askType
+            ifnull(f.warehouse_type, 10) as askType,
+            ifnull(e.warehouse_type, 10) as suppType
         from tld_warehouse_transfer a
         join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
         join tld_material c on a.material_id = c.tld_id
@@ -46,6 +47,7 @@
             <if test="endTime != null and endTime != ''">
                 and a.document_time <![CDATA[<=]]> #{endTime}
             </if>
+            and (a.num + 0) <![CDATA[>]]> (a.out_num + 0)
         </trim>
     </select>
     <!-- 物料库位选择 -->
@@ -79,28 +81,31 @@
             ifnull(sum(a.num),0) as num
         FROM tld_ask_goods_vitrual a
         join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
-        where a.storage_location_code = #{storageLocationCode}
+        where a.storage_location_code = #{storageLocationCode} and a.serial = #{serial}
     </select>
     <!-- 查询移库单内容 -->
     <select id="getWarehouseTransferDetailed" resultType="com.tld.model.WarehouseTransfer">
         select
-            id,
-            warehouse_transfer_id,
-            entry_number,
-            supply_warehouse_id
-            material_id,
-            wbs,
-            measurement_id,
-            num,
-            out_num,
-            type
-        from tld_warehouse_transfer
-        where warehouse_transfer_id = #{askGoodsId} and material_id = #{materialId}
+            a.id,
+            a.warehouse_transfer_id,
+            a.entry_number,
+            a.supply_warehouse_id,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.out_num,
+            a.type,
+            a.account_sleeve,
+            b.ask_goods_warehouse_id
+        from tld_warehouse_transfer a
+        join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
+        where a.warehouse_transfer_id = #{askGoodsId} and a.material_id = #{materialId}
     </select>
     <!-- 修改出库数量 -->
     <update id="updateOutNum">
         update tld_warehouse_transfer
-        set out_num = ifnull(out_num, 0) + #{num},type = '1' where material_id = #{materialId} and warehouse_transfer_id = #{askGoodsId}
+        set out_num = ifnull(out_num, 0) + #{num} where material_id = #{materialId} and warehouse_transfer_id = #{askGoodsId}
     </update>
     <!-- 查询当天移库单条数 -->
     <select id="getReturnWarehouseTransferCount" resultType="int">
@@ -118,7 +123,7 @@
                warehouse_transfer_code,
                ask_goods_warehouse_id,
                warehouse_transfer_type,
-               scrq
+               document_time
         from tld_warehouse_transfer_f where warehouse_transfer_id = #{askGoodsId}
     </select>
     <!--  查询移库单原始数据 -->
@@ -131,18 +136,18 @@
     </delete>
     <!--  新增返回gs父表移库信息 -->
     <insert id="addReturnGsWarehouseTransferF">
-        insert into tld_warehouse_transfer_f(warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq)
+        insert into tld_return_warehouse_transfer(warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq)
         value(#{warehouseTransferId},#{warehouseTransferCode},#{askGoodsWarehouseId},#{warehouseTransferType},now())
     </insert>
     <!-- 查询指定pda 指定物料扫描总数 -->
     <select id="getScanNum" resultType="integer">
-        select if(sum(num) is null, 0, num)
+        select if(sum(num) is null, 0, sum(num))
         from tld_warehousing_virtual
         where unique_code = #{uniqueCode} and warehouse_transfer_id = #{warehouseTransferId} and wllb_code = #{materialCode}
     </select>
     <!-- 查询指定pda 指定物料扫描总数 -->
     <select id="getScanNumWare" resultType="integer">
-        select if(sum(num) is null, 0, num)
+        select if(sum(num) is null, 0, sum(num))
         from tld_ask_goods_vitrual
         where unique_code = #{uniqueCode} and ask_goods_id = #{warehouseTransferId} and wllb_code = #{materialCode}
     </select>
@@ -162,4 +167,33 @@
             join tld_material b on a.material_id = b.tld_id
         where a.warehouse_transfer_id = #{askGoodsId} and b.code = #{wllbCode}
     </select>
+    <!-- 物料库位选择 -->
+    <select id="getMaterialWarehouseTransfer" resultType="com.tld.model.Inventory">
+        select
+            a.storage_location_code,
+            a.wllb_class,
+            a.library_type,
+            a.material_id,
+            (a.amount - ifnull(a.amount_lock, 0)) as amount,
+            a.total,
+            a.totime,
+            a.hold,
+            a.amount_lock,
+            a.account_sleeve,
+            a.wbs,
+            a.supplier_id,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.scrq,
+            b.storage_location_name as storageLocationName
+        from tld_inventory a
+        join tld_storage_location b on a.storage_location_code = b.storage_location_code
+        join tld_warehouse c on b.warehouse_where = c.tld_id
+        where a.material_id = #{materialId} and a.account_sleeve = #{companyNumber} and a.hold = '0' and (c.warehouse_type = '0' or c.warehouse_type = '1' or c.warehouse_type = '2')
+        <if test="warehouseWhere != null and warehouseWhere != ''">
+            and c.tld_id = #{warehouseWhere}
+        </if>
+        order by a.produc_date
+    </select>
 </mapper>

+ 11 - 3
src/main/resources/mapper/WarehousingMapper.xml

@@ -26,8 +26,8 @@
     </select>
     <!-- 新增库位信息虚拟表 -->
     <insert id="addWarehousingVirtual">
-        insert into tld_warehousing_virtual(unique_code,num,storage_location_code,wllb_code,supp_id,serial,type,produc_date,capacity,seq,user_id,storage_location_name,attribute,notice_id,warehouse_transfer_id)
-        values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId},#{warehouseTransferId})
+        insert into tld_warehousing_virtual(unique_code,num,storage_location_code,wllb_code,supp_id,serial,type,produc_date,capacity,seq,user_id,storage_location_name,attribute,notice_id,warehouse_transfer_id,storage_location_code_ck)
+        values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId},#{warehouseTransferId},#{storageLocationCodeCk})
     </insert>
     <!-- 查询总数量 -->
     <select id="getScanNum" resultType="java.util.Map">
@@ -93,6 +93,8 @@
             a.seq,
             a.user_id,
             a.attribute,
+            a.warehouse_transfer_id,
+            a.storage_location_code_ck,
             a.storage_location_name,
             b.user_name
         from tld_warehousing_virtual a
@@ -270,7 +272,13 @@
     <!-- 查询是否扫描 -->
     <select id="getScanIsNot" resultType="java.util.Map">
         select
-               (select count(*) from tld_inventory where supplier_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryCount,
+               (select count(*)
+               from tld_inventory a
+               join tld_storage_location b on a.storage_location_code = b.storage_location_code
+               where a.supplier_id = #{suppId} and a.serial = #{unique} and a.wllb_code = #{wllbCode} and a.produc_date = #{producDate}
+                <if test="warehouseWhere != null and warehouseWhere != ''">
+                    and b.warehouse_where = #{warehouseWhere}
+                </if>) as inventoryCount,
                (select count(*) from tld_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualCount
         from dual
     </select>