zhs 2 роки тому
батько
коміт
f95aa60d78

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

@@ -85,4 +85,24 @@ public class AskGoodsController {
     public void userExport(AskGoods askGoods, HttpServletResponse response){
         askGoodsService.export(askGoods, response);
     }
+
+    /**
+     * 查询出库虚拟表数据
+     * @param uniqueCode pda唯一标识
+     * @return 返回结果
+     */
+    @GetMapping("getAskGoodsVitrual")
+    public Map<String, Object> getAskGoodsVitrual(String uniqueCode, String type){
+        return askGoodsService.getAskGoodsVitrual(uniqueCode, type);
+    }
+
+    /**
+     * 删除出库虚拟表指定数据
+     * @param id 指定id
+     * @return 返回结果
+     */
+    @DeleteMapping("delAskGoodsVitrual")
+    public Map<String, Object> delAskGoodsVitrual(String id){
+        return askGoodsService.delAskGoodsVitrual(id);
+    }
 }

+ 1 - 2
src/main/java/com/tld/controller/GsAccessController.java

@@ -24,7 +24,6 @@ public class GsAccessController {
     //收入货
     @Autowired
     private ReceiveGoodsSerivce receiveGoodsSerivce;
-
     //字典
     @Autowired
     private DictionaryService dictionaryService;
@@ -72,7 +71,7 @@ public class GsAccessController {
      */
     @PostMapping("addAskGoods")
     @PassToken
-    public Map<String, Object>  addAskGoods(AskGoods askGoods){
+    public Map<String, Object> addAskGoods(AskGoods askGoods){
         return askGoodsService.addAskGoods(askGoods);
     }
 

+ 68 - 0
src/main/java/com/tld/controller/InviteController.java

@@ -0,0 +1,68 @@
+package com.tld.controller;
+
+import com.tld.model.AskGoods;
+import com.tld.service.InviteService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+/**
+ * 领用出库
+ */
+@RestController
+@RequestMapping("invite")
+public class InviteController {
+
+    @Autowired
+    private InviteService inviteService;
+
+    /**
+     * 查询领用出库数据
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getAskGoods")
+    public Map<String, Object> getAskGoodsList(AskGoods askGoods){
+        return inviteService.getAskGoodsfList(askGoods);
+    }
+
+    /**
+     * 查询指定领用出库的物料
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getAskGoodsMaterial")
+    public Map<String, Object> getAskGoodsMaterial(AskGoods askGoods){
+        return inviteService.getAskGoodsMaterial(askGoods);
+    }
+
+
+    /**
+     * 物料库位选择
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @GetMapping("getMaterialCk")
+    public Map<String, Object> getMaterialCk(AskGoods askGoods){
+        return inviteService.getMaterialCk(askGoods);
+    }
+
+    /**
+     * 插入出库虚拟表
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @PostMapping("addAskGoodsVitrual")
+    public Map<String, Object> addAskGoodsVitrual(@RequestBody AskGoods askGoods){
+        return inviteService.addAskGoodsVitrual(askGoods);
+    }
+
+    /**
+     * 出库
+     */
+    @GetMapping("OutOfLibrary")
+    public Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId){
+        return inviteService.OutOfLibrary(uniqueCode, type, askGoodsId);
+    }
+}

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

@@ -74,4 +74,8 @@ public interface AskGoodsMapper {
     List<AskGoods> getRemoval(AskGoods askGoods);
 
     List<Map<String, Object>> export(AskGoods askGoods);
+
+    List<AskGoods> getAskGoodsVitrual(@Param("uniqueCode")String uniqueCode, @Param("type")String type);
+
+    void delAskGoodsVitrual(String id);
 }

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

@@ -0,0 +1,54 @@
+package com.tld.mapper;
+
+import com.tld.model.AskGoods;
+import com.tld.model.Inventory;
+import com.tld.model.ReturRemoval;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface InviteMapper {
+    List<AskGoods> getAskGoodsfList(AskGoods askGoods);
+
+    List<AskGoods> getAskGoodsMaterial(AskGoods askGoods);
+
+    List<Inventory> getMaterialCk(AskGoods askGoods);
+
+    AskGoods getAsk(Inventory inventory);
+
+    int getInventoryAlready(AskGoods askGoods);
+
+    int getAskInfoNumVitrual(AskGoods askGoods);
+
+    AskGoods getAsknInfo(AskGoods askGoods);
+
+    Inventory getInventory(AskGoods askGoods);
+
+    Map<String, Object> getScanIsNot(AskGoods askGoods);
+
+    void addAskGoodsVitrual(AskGoods askGoods);
+
+    List<AskGoods> getVirtualUniqueCode(String uniqueCode, String type, String askGoodsId);
+
+    void deleteInventory(Inventory inventory);
+
+    void updateInventory(Inventory inventory);
+
+    String getMaterialId(String wllbCode);
+
+    AskGoods getAskDetailed(String askGoodsId, String materialId);
+
+    void addReturnGsRemoval(ReturRemoval returRemoval);
+
+    void deleteVirtual(String id);
+
+    void addRemoval(AskGoods askGoods);
+
+    void addReturnGsRemovalF(ReturRemoval returRemoval1);
+
+    AskGoods getAskDetailedF(String askGoodsId);
+
+    int getReturnRemovalCount();
+}

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

@@ -132,4 +132,8 @@ public class AskGoods implements Serializable {
      */
     private int limit;
 
+    /**
+     * 要货申请类型
+     */
+    private String askGoodsType;
 }

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

@@ -23,4 +23,8 @@ public interface AskGoodsService {
     Map<String, Object> getRemoval(AskGoods askGoods);
 
     void export(AskGoods askGoods, HttpServletResponse response);
+
+    Map<String, Object> getAskGoodsVitrual(String uniqueCode, String type);
+
+    Map<String, Object> delAskGoodsVitrual(String id);
 }

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

@@ -0,0 +1,17 @@
+package com.tld.service;
+
+import com.tld.model.AskGoods;
+
+import java.util.Map;
+
+public interface InviteService {
+    Map<String, Object> getAskGoodsfList(AskGoods askGoods);
+
+    Map<String, Object> getAskGoodsMaterial(AskGoods askGoods);
+
+    Map<String, Object> getMaterialCk(AskGoods askGoods);
+
+    Map<String, Object> addAskGoodsVitrual(AskGoods askGoods);
+
+    Map<String, Object> OutOfLibrary(String uniqueCode, String type, String askGoodsId);
+}

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

@@ -248,6 +248,35 @@ public class AskGoodsServiceImpl implements AskGoodsService {
         }
     }
 
+    @Override
+    public Map<String, Object> getAskGoodsVitrual(String uniqueCode, String type) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<AskGoods> list = askGoodsMapper.getAskGoodsVitrual(uniqueCode, type);
+            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> delAskGoodsVitrual(String id) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            askGoodsMapper.delAskGoodsVitrual(id);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
     /**
      * 出库单生成
      * @return

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

@@ -0,0 +1,176 @@
+package com.tld.service.impl;
+
+import com.tld.mapper.InviteMapper;
+import com.tld.model.AskGoods;
+import com.tld.model.Inventory;
+import com.tld.model.ReturRemoval;
+import com.tld.service.InviteService;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Service
+public class InviteServiceImpl implements InviteService {
+
+    @Autowired
+    private InviteMapper inviteMapper;
+    //redis锁
+    @Autowired
+    private RedissonClient redissonClient;
+
+    @Override
+    public Map<String, Object> getAskGoodsfList(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<AskGoods> list = inviteMapper.getAskGoodsfList(askGoods);
+            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> getAskGoodsMaterial(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<AskGoods> list = inviteMapper.getAskGoodsMaterial(askGoods);
+            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> getMaterialCk(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<Inventory> list = new LinkedList<>();
+            for(Inventory inventory : inviteMapper.getMaterialCk(askGoods)){
+                AskGoods askGoods1 = inviteMapper.getAsk(inventory);
+                if(Integer.parseInt(askGoods1.getNum()) != Integer.parseInt(inventory.getAmount())){
+                    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> addAskGoodsVitrual(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            Map<String, Object> mapVal = inviteMapper.getScanIsNot(askGoods);
+            if((Integer.parseInt(mapVal.get("inventoryNum").toString()) - Integer.parseInt(mapVal.get("virtualNum").toString())) == 0){
+                map.put("msg", "500");
+                map.put("errMsg", "已全部出库");
+                return map;
+            }
+            Inventory inventory = inviteMapper.getInventory(askGoods); //库存数量
+            AskGoods askGoods1 = inviteMapper.getAsknInfo(askGoods); //要货单数量
+            int alreadyNum =  inviteMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
+            int inventoryAlready =  inviteMapper.getInventoryAlready(askGoods);//库存已扫描数量
+            int inventorySurplus = Integer.parseInt(inventory.getAmount()) - inventoryAlready; //库存剩余数量
+            int surplusNum = Integer.parseInt(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
+
+            if(surplusNum >= inventorySurplus){
+                askGoods.setNum(String.valueOf(inventorySurplus));
+            } else {
+                askGoods.setNum(String.valueOf(surplusNum));
+            }
+            askGoods.setStorageLocationCode(inventory.getStorageLocationCode());//库存编号
+            inviteMapper.addAskGoodsVitrual(askGoods);
+            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 = inviteMapper.getVirtualUniqueCode(uniqueCode, type, askGoodsId);
+            for(AskGoods askGoods : list){
+                Inventory inventory = inviteMapper.getInventory(askGoods);
+                //如果出库库存等于虚拟表库存则删除此库存
+                if(Integer.parseInt(askGoods.getNum()) == Integer.parseInt(inventory.getAmount())){
+                    inviteMapper.deleteInventory(inventory);
+                } else {
+                    inventory.setAmount(askGoods.getNum());
+                    inviteMapper.updateInventory(inventory);
+                }
+                String materialId = inviteMapper.getMaterialId(askGoods.getWllbCode());//查询物料id
+                AskGoods askGoods1 = inviteMapper.getAskDetailed(askGoodsId, materialId);//查询要料申请单内容
+                ReturRemoval returRemoval = new ReturRemoval()
+                        .setMaterialId(materialId)
+                        .setAskGoodsId(askGoodsId)
+                        .setWbs(askGoods1.getWbs())
+                        .setNum(askGoods.getNum())
+                        .setEntryNumber(askGoods1.getEntryNumber())
+                        .setAskId(askGoods1.getId())
+                        .setStorageLocationCode(askGoods.getStorageLocationCode());
+                inviteMapper.addRemoval(askGoods);//插入出库流水
+                inviteMapper.deleteVirtual(askGoods.getId());//删除已出虚拟表库存
+                inviteMapper.addReturnGsRemoval(returRemoval);//新增返回gs数据子表信息
+            }
+            //查询要货单父级信息
+            AskGoods askGoods3 = inviteMapper.getAskDetailedF(askGoodsId);
+            String removalCode = codeGenerateCk();
+            ReturRemoval returRemoval1 = new ReturRemoval()
+                    .setAskGoodsId(askGoods3.getAskGoodsId())
+                    .setRemovalCode(removalCode)
+                    .setSourceType(askGoods3.getSourceType())
+                    .setMoveType(askGoods3.getMoveType());
+            inviteMapper.addReturnGsRemovalF(returRemoval1);//新增返回gs数据父表信息
+            map.put("data", removalCode);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        } finally {
+            //释放锁
+            lock.unlock();
+        }
+        return map;
+    }
+    /**
+     * 出库单生成
+     * @return
+     */
+    public String codeGenerateCk(){
+        StringBuilder stringBuilder = new StringBuilder("CK");
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        stringBuilder.append(sdf.format(date));
+        int count = inviteMapper.getReturnRemovalCount();
+        for(int i = 0; i < 4 - (count + "").length(); i++){
+            stringBuilder.append("0");
+        }
+        return (stringBuilder.append(count + 1)).toString();
+    }
+}

+ 1 - 3
src/main/java/com/tld/service/impl/ReceiveGoodsSerivceImpl.java

@@ -9,9 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class ReceiveGoodsSerivceImpl implements ReceiveGoodsSerivce {

+ 7 - 1
src/main/java/com/tld/service/impl/UserServiceImpl.java

@@ -75,7 +75,12 @@ public class UserServiceImpl implements UserService {
         Map<String, Object> map = new HashMap<>();
         try{
             PageHelper.startPage(user.getPage(), user.getLimit());
-            PageInfo<User> pageInfo = new PageInfo<>(userMapper.getAllUser(user));
+            List<User> list = new ArrayList<>();
+            for(User user1 : userMapper.getAllUser(user)) {
+                user1.setPassword(DesDecry.decrypt(user1.getPassword()));
+                list.add(user1);
+            }
+            PageInfo<User> pageInfo = new PageInfo<>(list);
             map.put("data", pageInfo);
             map.put("msg", "200");
         } catch (Exception e){
@@ -138,6 +143,7 @@ public class UserServiceImpl implements UserService {
                 map.put("errMsg", "用户名已存在");
                 return map;
             }
+            user.setPassword(DesEncry.encrypt(user.getPassword()));
             userMapper.updateUser(user);
             map.put("msg", "200");
         } catch (Exception e){

+ 123 - 11
src/main/resources/mapper/AskGoodsMapper.xml

@@ -20,8 +20,8 @@
     </insert>
     <!-- 新增要料日志 -->
     <insert id="addAskGoodsLog">
-        insert into tld_ask_goods(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_code,company_number,sqrq,department_id,source_type,move_type)
-        values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType})
+        insert into tld_ask_goods_log(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_code,company_number,sqrq,department_id,source_type,move_type,ask_goods_type)
+        values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType})
     </insert>
     <!-- 查询次要货单是否存在 -->
     <select id="getAskGoodsf" resultType="int">
@@ -34,7 +34,13 @@
     </insert>
     <!-- 查询生产领料单 -->
     <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
-        select ask_goods_id,ask_goods_code,department from tld_ask_goods_f order by sqrq desc
+        select
+               a.ask_goods_id,
+               a.ask_goods_code,
+               b.name as departmentName
+        from tld_ask_goods_f a
+        left join tld_department b on a.department = b.tld_id
+        order by sqrq desc
     </select>
     <!-- 查询指定生产单的物料 -->
     <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
@@ -52,7 +58,24 @@
     </select>
     <!-- 物料库位选择 -->
     <select id="getMaterialCk" resultType="com.tld.model.Inventory">
-        select * from tld_inventory where material_id = #{materialId} order by scrq
+        select
+            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
+        from tld_inventory where material_id = #{materialId} order by scrq
     </select>
     <!-- 新增出库虚拟表 -->
     <insert id="addAskGoodsVitrual">
@@ -61,12 +84,40 @@
     </insert>
     <!-- 查询指定库存内容 -->
     <select id="getInventory" resultType="com.tld.model.Inventory">
-        select * from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
+        select
+           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
+        from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
     </select>
     <!-- 查询库存是否充足 -->
     <select id="getAsk" resultType="com.tld.model.AskGoods">
         SELECT
-            a.*
+            a.id,
+            a.unique_code,
+            a.supplier_id,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.ask_goods_id,
+            a.type,
+            a.storage_location_code,
+            a.num,
+            a.user_id,
+            a.department
         FROM
             tld_ask_goods_vitrual a
             join tld_material b on a.wllb_code = b.code and b.tld_id = #{materialId}
@@ -82,7 +133,15 @@
     <!-- 查询指定送货单信息 -->
     <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
         SELECT
-            a.*
+            a.id,
+            a.ask_goods_id,
+            a.entry_number,
+            a.production_code,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.out_num
         FROM
             tld_ask_goods a
             join tld_material b on a.material_id = b.tld_id
@@ -98,7 +157,20 @@
     </select>
     <!-- 查询虚拟表指定pda跟状态的的数据 -->
     <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
-        select * from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
+        select
+            id,
+            unique_code,
+            supplier_id,
+            serial,
+            wllb_code,
+            produc_date,
+            ask_goods_id,
+            type,
+            storage_location_code,
+            num,
+            user_id,
+            department
+        from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
     </select>
     <!-- 删除库存 -->
     <delete id="deleteInventory">
@@ -107,7 +179,7 @@
     <!-- 修改库存数量 -->
     <update id="updateInventory">
         UPDATE tld_inventory
-        SET amount = ( SELECT a.amount FROM (select (amount - ${amount}) as amount from tld_inventory WHERE id = #{id}) as a )
+        SET amount = amount - ${amount}
         WHERE
             id = #{id}
     </update>
@@ -126,7 +198,16 @@
     </select>
     <!-- 查询要料申请单内容 -->
     <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
-        select *
+        select
+            id,
+            ask_goods_id,
+            entry_number,
+            production_code,
+            material_id,
+            wbs,
+            measurement_id,
+            num,
+            out_num
         from tld_ask_goods
         where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
     </select>
@@ -137,7 +218,16 @@
     </insert>
     <!-- 查询要货单父级信息 -->
     <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
-        select * from tld_ask_goods_f where ask_goods_id = #{askGoodsId}
+        select
+            id,
+            ask_goods_id,
+            ask_goods_code,
+            company_number,
+            sqrq,
+            department,
+            source_type,
+            move_type
+        from tld_ask_goods_f where ask_goods_id = #{askGoodsId}
     </select>
     <!-- 新增返回gs数据父表信息 -->
     <insert id="addReturnGsRemovalF">
@@ -237,4 +327,26 @@
             </if>
         </trim>
     </select>
+    <!-- 查询指定pda出库虚拟表 -->
+    <select id="getAskGoodsVitrual" resultType="com.tld.model.AskGoods">
+        select
+            id,
+            unique_code,
+            supplier_id,
+            serial,
+            wllb_code,
+            produc_date,
+            ask_goods_id,
+            type,
+            storage_location_code,
+            num,
+            user_id,
+            department
+        from tld_ask_goods_vitrual
+        where unique_code = #{uniqueCode} and type = #{type}
+    </select>
+    <!-- 删除指定虚拟表数据 -->
+    <delete id="delAskGoodsVitrual">
+        delete from tld_ask_goods_vitrual where id = #{id}
+    </delete>
 </mapper>

+ 324 - 0
src/main/resources/mapper/InviteMapper.xml

@@ -0,0 +1,324 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tld.mapper.InviteMapper">
+    <!-- 查询要货单id+物料id是否存在 -->
+    <select id="getAskGoods" resultType="int">
+        select count(*) from tld_ask_goods where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
+    </select>
+    <!-- 修改要料申请单数量 -->
+    <update id="updateAskGoodsNum">
+        update tld_ask_goods
+        set
+        num = (select num from tld_ask_goods where ask_goods_id = #{askGoodsId} and material_id = #{materialId})
+        where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
+    </update>
+    <!-- 新增要料申请单 -->
+    <insert id="addAskGoods">
+        insert into tld_ask_goods(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num)
+        values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum})
+    </insert>
+    <!-- 新增要料日志 -->
+    <insert id="addAskGoodsLog">
+        insert into tld_ask_goods_log(ask_goods_id,entry_number,production_code,material_id,wbs,measurement_id,num,out_num,ask_goods_code,company_number,sqrq,department_id,source_type,move_type,ask_goods_type)
+        values(#{askGoodsId},#{entryNumber},#{productionCode},#{materialId},#{wbs},#{measurementId},#{outNum},#{askGoodsCode},#{companyNumber},#{sqrq},#{departmentId},#{sourceType},#{moveType},#{askGoodsType})
+    </insert>
+    <!-- 查询次要货单是否存在 -->
+    <select id="getAskGoodsf" resultType="int">
+        select count(*) from tld_ask_goods_f where ask_goods_id = #{askGoodsId} and ask_goods_code = #{askGoodsCode}
+    </select>
+    <!-- 新增要料申请单父级 -->
+    <insert id="addAskGoodsNumf">
+        insert into tld_ask_goods_f(ask_goods_id,ask_goods_code,company_number,sqrq,department,source_type,move_type)
+        values(#{askGoodsId},#{askGoodsCode},#{companyNumber},#{sqrq},#{department},#{sourceType},#{moveType})
+    </insert>
+    <!-- 查询生产领料单 -->
+    <select id="getAskGoodsfList" resultType="com.tld.model.AskGoods">
+        select ask_goods_id,ask_goods_code,department from tld_invite_f order by sqrq desc
+    </select>
+    <!-- 查询指定生产单的物料 -->
+    <select id="getAskGoodsMaterial" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.material_id,
+            a.num,
+            b.name as materialName,
+            b.code as materialCode
+        FROM
+            tld_invite a
+            left join tld_material b on a.material_id = b.tld_id
+        WHERE
+            a.ask_goods_id = #{askGoodsId} and a.num <![CDATA[>]]> a.out_num
+    </select>
+    <!-- 物料库位选择 -->
+    <select id="getMaterialCk" resultType="com.tld.model.Inventory">
+        select
+            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
+        from tld_inventory where material_id = #{materialId} order by scrq
+    </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)
+        values(#{uniqueCode},#{supplierId},#{serial},#{wllbCode},#{producDate},#{askGoodsId},#{type},#{storageLocationCode},#{num},#{userId},#{department})
+    </insert>
+    <!-- 查询指定库存内容 -->
+    <select id="getInventory" resultType="com.tld.model.Inventory">
+        select
+            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
+        from tld_inventory where supplier_id = #{supplierId} getScanIsNot serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}
+    </select>
+    <!-- 查询库存是否充足 -->
+    <select id="getAsk" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.unique_code,
+            a.supplier_id,
+            a.serial,
+            a.wllb_code,
+            a.produc_date,
+            a.ask_goods_id,
+            a.type,
+            a.storage_location_code,
+            a.num,
+            a.user_id,
+            a.department
+        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="getScanIsNot" resultType="java.util.Map">
+        select
+            (select amount from tld_inventory where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as inventoryNum,
+            (select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}) as virtualNum
+        from dual
+    </select>
+    <!-- 查询指定送货单信息 -->
+    <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.id,
+            a.ask_goods_id,
+            a.entry_number,
+            a.production_code,
+            a.material_id,
+            a.wbs,
+            a.measurement_id,
+            a.num,
+            a.out_num
+        FROM
+            tld_invite a
+            join tld_material b on a.material_id = b.tld_id
+        where a.ask_goods_id = #{askGoodsId} and b.code = #{materialCode}
+    </select>
+    <!-- 查询已扫描总数 -->
+    <select id="getAskInfoNumVitrual" resultType="int">
+        select sum(num) from tld_ask_goods_vitrual where wllb_code = #{materialCode} and ask_goods_id = #{askGoodsId} and type = #{type}
+    </select>
+    <!-- 查询此库存在虚拟表里占用的数量 -->
+    <select id="getInventoryAlready" resultType="int">
+        select sum(num) from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate} and type = #{type}
+    </select>
+    <!-- 查询虚拟表指定pda跟状态的的数据 -->
+    <select id="getVirtualUniqueCode" resultType="com.tld.model.AskGoods">
+        select
+            id,
+            unique_code,
+            supplier_id,
+            serial,
+            wllb_code,
+            produc_date,
+            ask_goods_id,
+            type,
+            storage_location_code,
+            num,
+            user_id,
+            department
+        from tld_ask_goods_vitrual where unique_code = #{uniqueCode} and type = #{type} and ask_goods_id = #{askGoodsId}
+    </select>
+    <!-- 删除库存 -->
+    <delete id="deleteInventory">
+        delete from tld_inventory where id = #{id}
+    </delete>
+    <!-- 修改库存数量 -->
+    <update id="updateInventory">
+        UPDATE tld_inventory
+        SET amount = amount - ${amount}
+        WHERE
+            id = #{id}
+    </update>
+    <!-- 删除虚拟表出库记录 -->
+    <delete id="deleteVirtual">
+        delete from tld_ask_goods_vitrual where id = #{id}
+    </delete>
+    <!-- 插入出库流水 -->
+    <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})
+    </insert>
+    <!-- 查询指定物料类型的id -->
+    <select id="getMaterialId" resultType="String">
+        select tld_id from tld_material where code = #{wllbCode}
+    </select>
+    <!-- 查询要料申请单内容 -->
+    <select id="getAskDetailed" resultType="com.tld.model.AskGoods">
+        select
+            id,
+            ask_goods_id,
+            entry_number,
+            production_code,
+            material_id,
+            wbs,
+            measurement_id,
+            num,
+            out_num
+        from tld_invite
+        where ask_goods_id = #{askGoodsId} and material_id = #{materialId}
+    </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>
+    <!-- 查询要货单父级信息 -->
+    <select id="getAskDetailedF" resultType="com.tld.model.AskGoods">
+        select
+            id,
+            ask_goods_id,
+            ask_goods_code,
+            company_number,
+            sqrq,
+            department,
+            source_type,
+            move_type
+        from tld_invite_f where ask_goods_id = #{askGoodsId}
+    </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>
+    <!-- 查询当天出库数量 -->
+    <select id="getReturnRemovalCount" resultType="int">
+        select count(*) from tld_return_gs_removal where scrq BETWEEN CONCAT(CURDATE(),' 00:00:00') AND CONCAT(CURDATE(),' 23:59:59');
+    </select>
+    <!-- 查询回传数据 -->
+    <select id="plugOutRemoval" resultType="java.util.Map">
+        select
+            id,
+            ask_goods_id as askGoodsId,
+            removal_code as removalCode,
+            source_type as sourceType,
+            move_type as moveType
+        from tld_return_gs_removal where removal_code = #{removalCode}
+    </select>
+    <!-- 查询字表回传数据 -->
+    <select id="getRemovalz" resultType="java.util.Map">
+        select
+            material_id as materialId,
+            wbs,
+            num,
+            entry_number as entryNumber,
+            ask_goods_id as askGoodsId,
+            ask_id as askId
+        from tld_return_gs_removal_z where ask_goods_id = #{askGoodsId}
+    </select>
+    <!-- 查询出库流水 -->
+    <select id="getRemoval" resultType="com.tld.model.AskGoods">
+        select
+            a.id,
+            b.name as materialName,
+            a.wllb_code,
+            h.name as supplierName,
+            a.serial,
+            a.type,
+            c.user_name as userName,
+            e.name as departmentName,
+            g.storage_location_name as storageLocationName,
+            a.scrq,
+            a.num
+        from tld_removal a
+        left join tld_material b on a.wllb_code = b.code
+        left join tld_user c on a.user_id = c.id
+        left join tld_department e on a.department = e.tld_id
+        left join tld_storage_location g on a.storage_location_code = g.storage_location_code
+        left join tld_customer h on a.supplier_id = h.code
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="wllbCode != null and wllbCode != ''">
+                and a.wllb_code = #{wllbCode}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and a.scrq <![CDATA[>=]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and a.scrq <![CDATA[<=]]> #{endTime}
+            </if>
+            <if test="type != null and type != ''">
+                and a.type like CONCAT(CONCAT('%', #{type}), '%')
+            </if>
+        </trim>
+    </select>
+    <!-- 导出 -->
+    <select id="export" resultType="java.util.LinkedHashMap">
+        select
+            b.name as materialName,
+            h.name as supplierName,
+            a.serial,
+            a.type,
+            c.user_name as userName,
+            e.name as departmentName,
+            g.storage_location_name as storageLocationName,
+            a.scrq,
+            a.num
+        from tld_removal a
+        left join tld_material b on a.wllb_code = b.code
+        left join tld_user c on a.user_id = c.id
+        left join tld_department e on a.department = e.tld_id
+        left join tld_storage_location g on a.storage_location_code = g.storage_location_code
+        left join tld_customer h on a.supplier_id = h.code
+        <trim prefix="WHERE" prefixOverrides="and |or">
+            <if test="wllbCode != null and wllbCode != ''">
+                and a.wllb_code = #{wllbCode}
+            </if>
+            <if test="startTime != null and startTime != ''">
+                and a.scrq <![CDATA[>=]]> #{startTime}
+            </if>
+            <if test="endTime != null and endTime != ''">
+                and a.scrq <![CDATA[<=]]> #{endTime}
+            </if>
+            <if test="type != null and type != ''">
+                and a.type like CONCAT(CONCAT('%', #{type}), '%')
+            </if>
+        </trim>
+    </select>
+</mapper>

+ 73 - 9
src/main/resources/mapper/WarehousingMapper.xml

@@ -7,7 +7,11 @@
     </sql>
     <!-- 查询物料库位 -->
     <select id="getMaterialClass" resultType="com.tld.model.MaterialClass">
-        select * from tld_material_class where wllb_code = #{wllbCode}
+        select
+            id,
+            storage_location_code,
+            wllb_code
+        from tld_material_class where wllb_code = #{wllbCode}
     </select>
     <!-- 根据物料分类查询库位 -->
     <select id="getMaterialClassType" resultType="com.tld.model.MaterialClass">
@@ -38,7 +42,14 @@
     <!-- 查询 -->
     <select id="recommend" resultType="com.tld.model.StorageLocation">
         SELECT
-            *
+            id,
+            storage_location_code,
+            storage_location_name,
+            warehouse_where,
+            storage_location_type,
+            storage_location_capacity,
+            is_not_disable,
+            create_time
         FROM
             tld_storage_location
         WHERE
@@ -50,7 +61,16 @@
     </select>
     <!-- 查询混合库位 -->
     <select id="getIsNotSisableLocation" resultType="com.tld.model.StorageLocation">
-        select * from tld_storage_location where is_not_disable = #{isNotDisable}
+        select
+            id,
+            storage_location_code,
+            storage_location_name,
+            warehouse_where,
+            storage_location_type,
+            storage_location_capacity,
+            is_not_disable,
+            create_time
+        from tld_storage_location where is_not_disable = #{isNotDisable}
     </select>
     <!-- 删除虚拟表 -->
     <delete id="delWarehousingVirtual">
@@ -58,12 +78,44 @@
     </delete>
     <!-- 查询虚拟表数据进行入库 -->
     <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
-        select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
+        select
+            id,
+            unique_code,
+            num,
+            storage_location_code,
+            wllb_code,
+            supp_id,
+            serial,
+            type,
+            produc_date,
+            capacity,
+            seq,
+            user_id,
+            storage_location_name
+        from tld_warehousing_virtual where unique_code = #{uniqueCode}
     </select>
     <!-- 查询采购单信息 -->
     <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
         SELECT
-            a.*,b.company_number,b.order_number,b.source_type,b.move_type,f.name as supplierName
+            a.id,
+            a.order_code,
+            a.material_id,
+            a.purchase_num,
+            a.arrival_num,
+            a.type,
+            a.qualified_num
+            a.disqualification_num,
+            a.wbs,
+            a.arrival_time,
+            a.measurement_id,
+            a.supplier_id,
+            a.entry_number,
+            a.warehousing_num,
+            b.company_number,
+            b.order_number,
+            b.source_type,
+            b.move_type,
+            f.name as supplierName
         FROM
             tld_receive_goods a
             LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
@@ -78,9 +130,7 @@
     <update id="updateReceiveGood">
         update tld_receive_goods
         set
-            warehousing_num = (
-                select a.result from (select (warehousing_num + ${warehousingNum}) as result from tld_receive_goods where id = #{id}) a
-                )
+            warehousing_num = warehousing_num + ${warehousingNum}
         where id = #{id}
     </update>
     <!-- 查询物料类型 -->
@@ -157,7 +207,21 @@
     </select>
     <!-- 查询虚拟入库 -->
     <select id="getWarehousingVirtual" resultType="com.tld.model.WarehousingVirtual">
-        select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
+        select
+            id,
+            unique_code,
+            num,
+            storage_location_code,
+            wllb_code,
+            supp_id,
+            serial,
+            type,
+            produc_date,
+            capacity,
+            seq,
+            user_id,
+            storage_location_name
+        from tld_warehousing_virtual where unique_code = #{uniqueCode}
     </select>
     <!-- 查询导出内容 -->
     <select id="export" resultType="java.util.LinkedHashMap">