zhs 2 éve
szülő
commit
dd0a2eefcc

+ 32 - 3
src/main/java/com/tld/controller/WarehouseTransferController.java

@@ -2,7 +2,7 @@ package com.tld.controller;
 
 import com.tld.model.WarehouseTransfer;
 import com.tld.service.WarehouseTransferService;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -14,10 +14,11 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("warehouseTransfer")
+@RequiredArgsConstructor
 public class WarehouseTransferController {
 
-    @Autowired
-    private WarehouseTransferService warehouseTransferService;
+//    @Autowired
+    private final WarehouseTransferService warehouseTransferService;
 
     /**
      * 查询移库单
@@ -28,4 +29,32 @@ public class WarehouseTransferController {
     public Map<String, Object> getWarehouseTransfer(WarehouseTransfer warehouseTransfer){
         return warehouseTransferService.getWarehouseTransfer(warehouseTransfer);
     }
+
+    /**
+     * 推荐库位
+     * @param warehouseTransfer 参数
+     * @return 返回结果
+     */
+    @GetMapping("getRecommend")
+    public Map<String, Object> getRecommend(WarehouseTransfer warehouseTransfer){
+        return warehouseTransferService.getRecommend(warehouseTransfer);
+    }
+
+    /**
+     * 出库
+     */
+    @GetMapping("OutOfLibrary")
+    public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId){
+        return warehouseTransferService.OutOfLibrary(uniqueCode, type, askGoodsId);
+    }
+
+    /**
+     * 入库
+     * @param uniqueCode 参数
+     * @return 返回结果
+     */
+    @GetMapping("warehousing")
+    public Map<String, Object> warehousing(String uniqueCode, String type){
+        return warehouseTransferService.warehousing(uniqueCode, type);
+    }
 }

+ 3 - 0
src/main/java/com/tld/mapper/DictionaryMapper.java

@@ -2,6 +2,7 @@ package com.tld.mapper;
 
 import com.tld.model.Delivery;
 import com.tld.model.Dictionary;
+import com.tld.model.WarehouseTransfer;
 import org.apache.ibatis.annotations.Mapper;
 
 import java.util.List;
@@ -22,4 +23,6 @@ public interface DictionaryMapper {
     List<Dictionary> getDictionaryPage(Dictionary dictionary);
 
     String getWarehouse(String storageLocationCode);
+
+    Dictionary getWarehouseInfo(WarehouseTransfer warehouseTransfer);
 }

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

@@ -70,4 +70,6 @@ public interface InviteMapper {
     int getReturnRemovalCount();
 
     String getScanNum(AskGoods askGoods1);
+
+    void updateOutNum(String num, String askGoodsId, String materialId);
 }

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

@@ -1,5 +1,7 @@
 package com.tld.mapper;
 
+import com.tld.model.AskGoods;
+import com.tld.model.Inventory;
 import com.tld.model.WarehouseTransfer;
 import org.apache.ibatis.annotations.Mapper;
 
@@ -8,4 +10,20 @@ import java.util.List;
 @Mapper
 public interface WarehouseTransferMapper {
     List<WarehouseTransfer> getWarehouseTransfer(WarehouseTransfer warehouseTransfer);
+
+    List<Inventory> getMaterialCk(WarehouseTransfer warehouseTransfer);
+
+    AskGoods getAsk(Inventory inventory);
+
+    WarehouseTransfer getWarehouseTransferDetailed(String askGoodsId, String materialId);
+
+    void updateOutNum(String num, String askGoodsId, String materialId);
+
+    int getReturnWarehouseTransferCount();
+
+    void addReturnGsWarehouseTransfer(WarehouseTransfer warehouseTransfer1);
+
+    WarehouseTransfer getWarehouseTransferDetailedF(String askGoodsId);
+
+    void addReturnGsWarehouseTransferF(WarehouseTransfer warehouseTransfer1);
 }

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

@@ -180,4 +180,8 @@ public class AskGoods implements Serializable {
      * 客户名称
      */
     private String customerName;
+    /**
+     * 所属仓库
+     */
+    private String warehouseWhere;
 }

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

@@ -92,4 +92,8 @@ public class Inventory implements Serializable {
      * 属性
      */
     private String attribute;
+    /**
+     * 出货仓库
+     */
+    private String warehouseWhere;
 }

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

@@ -66,6 +66,10 @@ public class WarehouseTransfer {
      * 是否移库
      */
     private String type;
+    /**
+     * 出货仓库
+     */
+    private String warehouseWhere;
     /**
      * 分数
      */
@@ -74,4 +78,5 @@ public class WarehouseTransfer {
      * 条数
      */
     private int limit;
+
 }

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

@@ -136,4 +136,8 @@ public class WarehousingVirtual implements Serializable {
      * 半成品产成品入库通知单
      */
     private String noticeId;
+    /**
+     * 移库通知单id
+     */
+    private String warehouseTransferId;
 }

+ 6 - 0
src/main/java/com/tld/service/WarehouseTransferService.java

@@ -6,4 +6,10 @@ 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);
 }

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

@@ -54,7 +54,7 @@ public class AskGoodsServiceImpl implements AskGoodsService {
                     ag.setSourceType(jsonMap.get("sourceType").toString());
                     ag.setMoveType(jsonMap.get("moveType").toString());
 
-                   //子表
+                    //子表
                     ag.setType("0");
                     ag.setEntryNumber(element.get("entryNumber").toString());
                     ag.setProductionCode(element.get("prodOrderNo").toString());
@@ -198,6 +198,9 @@ public class AskGoodsServiceImpl implements AskGoodsService {
             List<AskGoods> list = askGoodsMapper.getVirtualUniqueCode(uniqueCode, type, askGoodsId);
             for(AskGoods askGoods : list){
                 Inventory inventory = askGoodsMapper.getInventory(askGoods);
+                if(inventory == null){
+                    throw new Exception("库存不存在");
+                }
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
                     askGoodsMapper.deleteInventory(inventory);

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

@@ -130,6 +130,9 @@ public class InviteServiceImpl implements InviteService {
             List<AskGoods> list = inviteMapper.getVirtualUniqueCode(uniqueCode, type, askGoodsId);
             for(AskGoods askGoods : list){
                 Inventory inventory = inviteMapper.getInventory(askGoods);
+                if(inventory == null){
+                    throw new Exception("库存不存在");
+                }
                 //如果出库库存等于虚拟表库存则删除此库存
                 if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
                     inviteMapper.deleteInventory(inventory);
@@ -150,6 +153,7 @@ public class InviteServiceImpl implements InviteService {
                 inviteMapper.addRemoval(askGoods);//插入出库流水
                 inviteMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
                 inviteMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
+                inviteMapper.updateOutNum(askGoods.getNum(), askGoodsId, materialId);//修改出库数量
             }
             //查询要货单父级信息
             AskGoods askGoods3 = inviteMapper.getAskDetailedF(askGoodsId);

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

@@ -1,24 +1,32 @@
 package com.tld.service.impl;
 
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import com.tld.mapper.WarehouseTransferMapper;
-import com.tld.mapper.WarehousingMapper;
-import com.tld.model.Notice;
-import com.tld.model.WarehouseTransfer;
+import com.tld.mapper.*;
+import com.tld.model.*;
+import com.tld.model.Dictionary;
 import com.tld.service.WarehouseTransferService;
+import lombok.RequiredArgsConstructor;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @Service
+@RequiredArgsConstructor
 public class WarehouseTransferServiceImpl implements WarehouseTransferService {
-
-    @Autowired
-    private WarehouseTransferMapper warehouseTransferMapper;
+    //移库
+    private final WarehouseTransferMapper warehouseTransferMapper;
+    //redis锁
+    private final RedissonClient redissonClient;
+    //出库
+    private final AskGoodsMapper askGoodsMapper;
+    //入库
+    private final WarehousingMapper warehousingMapper;
+    //字典
+    private final DictionaryMapper dictionaryMapper;
+    //用户
+    private final UserMapper userMapper;
 
     @Override
     public Map<String, Object> getWarehouseTransfer(WarehouseTransfer warehouseTransfer) {
@@ -34,4 +42,179 @@ 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);
+            if(dictionary.getName().equals("原材料库")){
+                map.put("msg", "500");
+                map.put("errMsg", "请扫描标签");
+                return map;
+            }
+            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<>();
+        //redis并发锁
+        RLock lock = redissonClient.getLock(uniqueCode);
+        lock.lock();
+        try{
+            List<AskGoods> list = askGoodsMapper.getVirtualUniqueCode(uniqueCode, type, askGoodsId);
+            //入库信息
+            List<WarehousingVirtual> warehousing = new LinkedList<>();
+            for(AskGoods askGoods : list){
+                Inventory inventory = askGoodsMapper.getInventory(askGoods);
+                if(inventory == null){
+                    throw new Exception("库存不存在");
+                }
+                //如果出库库存等于虚拟表库存则删除此库存
+                if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
+                    askGoodsMapper.deleteInventory(inventory);
+                } else {
+                    inventory.setAmount(askGoods.getNum());
+                    askGoodsMapper.updateInventory(inventory);
+                }
+                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
+                        .setSerial(askGoods.getSerial())//连翻号
+                        .setProducDate(askGoods.getProducDate())//批次
+                        .setNum(askGoods.getNum())//入库数量
+                        .setSeq("0")
+                        .setType(askGoods.getType())//入库类型
+                        .setUserId(askGoods.getUserId())//用户
+                        .setDepartmentId(askGoods.getDepartmentId())//部门
+                        .setStorageLocationCode(askGoods.getStorageLocationCode());//库位编号
+                warehousing.add(WarehousingVirtual1);
+                askGoodsMapper.addRemoval(askGoods);//插入出库流水
+                askGoodsMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
+                warehouseTransferMapper.updateOutNum(askGoods.getNum(), askGoodsId, materialId);//修改出库数量
+                WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
+                        .setWarehouseTransferId(warehouseTransfer.getWarehouseTransferId()) //移库单id
+                        .setEntryNumber(warehouseTransfer.getEntryNumber())//分录号
+                        .setSupplyWarehouseId(warehouseTransfer.getSupplyWarehouseId())//供货仓库id
+                        .setMaterialId(materialId)//物料id
+                        .setWbs(warehouseTransfer.getWbs())//wbs
+                        .setOutNum(askGoods.getNum()); //出库数量
+                warehouseTransferMapper.addReturnGsWarehouseTransfer(warehouseTransfer1);//新增返回gs数据子表信息
+            }
+            String warehouseTransfer = codeGenerateYK(); //移库单
+            WarehouseTransfer warehouseTransferF = warehouseTransferMapper.getWarehouseTransferDetailedF(askGoodsId);//查询父表移库单申请
+            WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
+                    .setWarehouseTransferId(warehouseTransferF.getWarehouseTransferId()) //移库单id
+                    .setWarehouseTransferCode(warehouseTransfer)//移库单编号
+                    .setAskGoodsWarehouseId(warehouseTransferF.getAskGoodsWarehouseId()) //要货仓库id
+                    .setWarehouseTransferType(warehouseTransferF.getWarehouseTransferType()); //移库类型
+            warehouseTransferMapper.addReturnGsWarehouseTransferF(warehouseTransfer1);//新增返回gs数据子表信息
+            warehousingMapper.addStorage(warehousing);//入库流水
+            map.put("data", warehouseTransfer);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        } finally {
+            //释放锁
+            lock.unlock();
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> warehousing(String uniqueCode, String type) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            //入库信息
+            List<WarehousingVirtual> list = new LinkedList<>();
+            List<WarehousingVirtual> warehousingVirtualList = warehousingMapper.getVirtual(uniqueCode, type);
+            //查询入库所需要的信息
+            for(WarehousingVirtual warehousingVirtual : warehousingVirtualList) {
+                //查询采购单信息
+                String materialId = askGoodsMapper.getMaterialId(warehousingVirtual.getWllbCode());//查询物料id
+                WarehouseTransfer warehouseTransfer = warehouseTransferMapper.getWarehouseTransferDetailed(warehousingVirtual.getWarehouseTransferId(), materialId);//查询移库申请内容
+                if(warehouseTransfer != null) {
+                    //WBS
+                    warehousingVirtual.setWbs(warehouseTransfer.getWbs());
+                }
+                //查询部门编号
+                List<User> listUser = userMapper.getAllUser(new User().setId(Integer.parseInt(warehousingVirtual.getUserId())));
+                warehousingVirtual.setDepartmentId(listUser.get(0).getDepartmentId());
+                //查询物料分类
+                WarehousingVirtual warehousingVirtual1 = warehousingMapper.getWlClass(warehousingVirtual);
+                warehousingVirtual.setWllbClass(warehousingVirtual1.getWllbClass());
+                warehousingVirtual.setMaterialId(warehousingVirtual1.getMaterialId());
+                list.add(warehousingVirtual);
+                warehouseTransferMapper.updateOutNum(warehousingVirtual.getNum(), warehousingVirtual.getWarehouseTransferId(), materialId);//修改出库数量
+                WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
+                        .setWarehouseTransferId(warehouseTransfer.getWarehouseTransferId()) //移库单id
+                        .setEntryNumber(warehouseTransfer.getEntryNumber())//分录号
+                        .setSupplyWarehouseId(warehouseTransfer.getSupplyWarehouseId())//供货仓库id
+                        .setMaterialId(materialId)//物料id
+                        .setWbs(warehouseTransfer.getWbs())//wbs
+                        .setOutNum(warehousingVirtual.getNum()); //出库数量
+                warehouseTransferMapper.addReturnGsWarehouseTransfer(warehouseTransfer1);//新增返回gs数据子表信息
+            }
+            //入库
+            warehousingMapper.addStorage(list);//入库流水
+            warehousingMapper.addInventory(list);//库存
+            warehousingMapper.delVirtual(uniqueCode);//删除临时表数据
+
+            String warehouseTransfer = codeGenerateYK(); //移库单
+            WarehouseTransfer warehouseTransferF = warehouseTransferMapper.getWarehouseTransferDetailedF(warehousingVirtualList.get(0).getWarehouseTransferId());//查询父表移库单申请
+            WarehouseTransfer warehouseTransfer1 = new WarehouseTransfer()
+                    .setWarehouseTransferId(warehouseTransferF.getWarehouseTransferId()) //移库单id
+                    .setWarehouseTransferCode(warehouseTransfer)//移库单编号
+                    .setAskGoodsWarehouseId(warehouseTransferF.getAskGoodsWarehouseId()) //要货仓库id
+                    .setWarehouseTransferType(warehouseTransferF.getWarehouseTransferType()); //移库类型
+            warehouseTransferMapper.addReturnGsWarehouseTransferF(warehouseTransfer1);//新增返回gs数据子表信息
+            map.put("data", warehouseTransfer);
+            map.put("msg", "200");
+        } catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "服务器请求异常,请稍后再试");
+        }
+        return map;
+    }
+
+    /**
+     * 移库单生成
+     * @return
+     */
+    public String codeGenerateYK(){
+        StringBuilder stringBuilder = new StringBuilder("YK");
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        stringBuilder.append(sdf.format(date));
+        int count = warehouseTransferMapper.getReturnWarehouseTransferCount();
+        for(int i = 0; i < 4 - (count + "").length(); i++){
+            stringBuilder.append("0");
+        }
+        return (stringBuilder.append(count + 1)).toString();
+    }
 }

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

@@ -78,8 +78,8 @@
             a.scrq,
             b.storage_location_name as storageLocationName
         from tld_inventory a
-        left join tld_storage_location b on a.storage_location_code = b.storage_location_code
-        where a.material_id = #{materialId} and a.hold = '0' order by a.produc_date
+        join tld_storage_location b on a.storage_location_code = b.storage_location_code
+        where a.material_id = #{materialId} and a.hold = '0' and b.warehouse_where != '5000' order by a.produc_date
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
@@ -207,7 +207,7 @@
     </select>
     <!-- 新增返回gs数据字表信息 -->
     <insert id="addReturnGsRemoval">
-        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,ask_id,storage_location_code)
+        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,document_points_id,storage_location_code)
         values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
     </insert>
     <!-- 查询要货单父级信息 -->
@@ -251,7 +251,7 @@
             entry_number as entryNumber,
             document_id as askGoodsId,
             document_points_id as askId
-        from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
+        from tld_return_gs_removal_z where document_id = #{askGoodsId}
     </select>
     <!-- 查询出库流水 -->
     <select id="getRemoval" resultType="com.tld.model.AskGoods">

+ 4 - 0
src/main/resources/mapper/DictionaryMapper.xml

@@ -58,4 +58,8 @@
     <select id="getWarehouse" resultType="String">
         select warehouse_where from tld_storage_location where storage_location_code = #{storageLocationCode}
     </select>
+    <!-- 查询仓库字典 -->
+    <select id="getWarehouseInfo" resultType="com.tld.model.Dictionary">
+        select code,name,tld_id from tld_warehouse where code = #{askGoodsWarehouseId}
+    </select>
 </mapper>

+ 13 - 7
src/main/resources/mapper/InviteMapper.xml

@@ -89,8 +89,8 @@
             a.scrq,
             b.storage_location_name as storageLocationName
         from tld_inventory a
-        left join tld_storage_location b on a.storage_location_code = b.storage_location_code
-        where a.material_id = #{materialId} order by a.scrq
+        join tld_storage_location b on a.storage_location_code = b.storage_location_code
+        where a.material_id = #{materialId} and a.hold = '0' and b.warehouse_where != '5000' order by a.produc_date
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
@@ -100,6 +100,7 @@
     <!-- 查询指定库存内容 -->
     <select id="getInventory" resultType="com.tld.model.Inventory">
         select
+            id,
             storage_location_code,
             wllb_class,
             library_type,
@@ -194,7 +195,7 @@
     <!-- 插入出库流水 -->
     <insert id="addRemoval">
         insert into tld_removal(wllb_code,supplier_id,serial,num,type,user_id,storage_location_code,scrq,process,ask_goods_id,produc_date,department)
-        values(#{materialCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department})
+        values(#{wllbCode},#{supplierId},#{serial},#{num},#{type},#{userId},#{storageLocationCode},now(),#{process},#{askGoodsId},#{producDate},#{department})
     </insert>
     <!-- 查询指定物料类型的id -->
     <select id="getMaterialId" resultType="String">
@@ -217,8 +218,8 @@
     </select>
     <!-- 新增返回gs数据字表信息 -->
     <insert id="addReturnGsRemoval">
-        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,ask_goods_id,ask_id,storage_location_code)
-        values(#{materialId},#{wbs},#{num},#{entryNumber},#{askGoodsId},#{askId},#{storageLocationCode})
+        insert into tld_return_gs_removal_z(material_id,wbs,num,entry_number,document_id,document_points_id,storage_location_code)
+        values(#{materialId},#{wbs},#{num},#{entryNumber},#{documentId},#{documentPointsId},#{storageLocationCode})
     </insert>
     <!-- 查询要货单父级信息 -->
     <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
@@ -235,8 +236,8 @@
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
-        insert into tld_invite_f(ask_goods_id,removal_code,source_type,move_type,scrq)
-        values(#{askGoodsId},#{removalCode},#{sourceType},#{movetype},now())
+        insert into tld_return_gs_removal(document_id,removal_code,source_type,move_type,scrq,delivery_type)
+        values(#{documentId},#{removalCode},#{sourceType},#{moveType},now(),#{deliveryType})
     </insert>
     <!-- 查询当天出库数量 -->
     <select id="getReturnRemovalCount" resultType="int">
@@ -331,4 +332,9 @@
             </if>
         </trim>
     </select>
+    <!-- 修改出库数量 -->
+    <update id="updateOutNum">
+        update tld_invite
+        set out_num = out_num + #{num} where material_id = #{materialId} and ask_goods_id = #{askGoodsId}
+    </update>
 </mapper>

+ 78 - 0
src/main/resources/mapper/WarehouseTransferMapper.xml

@@ -23,4 +23,82 @@
         join tld_warehouse_transfer_f b on a.warehouse_transfer_id = b.warehouse_transfer_id
         where type = #{type}
     </select>
+    <!-- 物料库位选择 -->
+    <select id="getMaterialCk" 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
+        where a.material_id = #{materialId} and a.hold = '0' and b.warehouse_where = #{warehouseWhere} order by a.produc_date
+    </select>
+    <!-- 查询库存是否充足 -->
+    <select id="getAsk" resultType="com.tld.model.AskGoods">
+        SELECT
+            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}
+    </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}
+    </select>
+    <!-- 修改出库数量 -->
+    <update id="updateOutNum">
+        update tld_warehouse_transfer
+        set out_num = out_num + #{num},type = '1' where material_id = #{materialId} and warehouse_transfer_id = #{askGoodsId}
+    </update>
+    <!-- 查询当天移库单条数 -->
+    <select id="getReturnWarehouseTransferCount" resultType="int">
+        select count(*) from tld_return_warehouse_transfer where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
+    </select>
+    <!-- 新增返回gs移库信息 -->
+    <insert id="addReturnGsWarehouseTransfer">
+        insert into tld_return_warehouse_transfer_z(warehouse_transfer_id,entry_number,supply_warehouse_id,material_id,wbs,out_num)
+        value(#{warehouseTransferId},#{entryNumber},#{supplyWarehouseId},#{materialId},#{wbs},#{outNum})
+    </insert>
+    <!-- 查询父表移库单申请 -->
+    <select id="getWarehouseTransferDetailedF"  resultType="com.tld.model.WarehouseTransfer">
+        select
+               warehouse_transfer_id,
+               warehouse_transfer_code,
+               ask_goods_warehouse_id,
+               warehouse_transfer_type,
+               scrq
+        from tld_warehouse_transfer_f where warehouse_transfer_id = #{askGoodsId}
+    </select>
+    <!--  新增返回gs父表移库信息 -->
+    <insert id="addReturnGsWarehouseTransferF">
+        insert into tld_warehouse_transfer_f(warehouse_transfer_id,warehouse_transfer_code,ask_goods_warehouse_id,warehouse_transfer_type,scrq)
+        value(#{warehouseTransferId},#{warehouseTransferCode},#{askGoodsWarehouseId},#{warehouseTransferType},now())
+    </insert>
 </mapper>

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

@@ -27,8 +27,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)
-        values(#{uniqueCode},#{num},#{storageLocationCode},#{wllbCode},#{suppId},#{serial},#{type},#{producDate},#{capacity},#{seq},#{userId},#{storageLocationName},#{attribute},#{noticeId})
+        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>
     <!-- 查询总数量 -->
     <select id="getScanNum" resultType="java.util.Map">
@@ -55,7 +55,7 @@
         FROM
             tld_storage_location
         WHERE
-            #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%')
+            #{storageLocationCode} like CONCAT('%', CONCAT(storage_location_code, ','), '%') and warehouse_where != '5000'
     </select>
     <!-- 查询是否是混合物料 -->
     <select id="getIsNotSisable" resultType="String">
@@ -492,7 +492,7 @@
                 and tld_id = #{materialId}
             </if>
             <if test="materialCode != null and materialCode != ''">
-                and wllb_code = #{materialCode}
+                and code = #{materialCode}
             </if>
         </trim>
     </select>
@@ -522,7 +522,7 @@
     <!-- 产成品入库 -->
     <insert id="addHalf">
         insert into tld_half(wllb_code,produc_date,produc_batch,capacity,user_id,storage_location_code,scrq,serial,seq,attribute)
-        value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{scrq},#{serial},#{seq},#{attribute})
+        value(#{wllbCode},#{producDate},#{producDate},#{num},#{userId},#{storageLocationCode},now(),#{serial},#{seq},#{attribute})
     </insert>
     <!-- 查询虚拟表数据进行入库 -->
     <select id="getVirtualNotice" resultType="com.tld.model.WarehousingVirtual">