瀏覽代碼

问题修改

zhs 2 年之前
父節點
當前提交
4113f2296b

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

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

+ 16 - 0
src/main/java/com/tld/controller/GsAccessController.java

@@ -1,7 +1,9 @@
 package com.tld.controller;
 
+import com.tld.model.AskGoods;
 import com.tld.model.Dictionary;
 import com.tld.model.ReceiveGoods;
+import com.tld.service.AskGoodsService;
 import com.tld.service.DictionaryService;
 import com.tld.service.ReceiveGoodsSerivce;
 import com.tld.util.PassToken;
@@ -25,6 +27,9 @@ public class GsAccessController {
     //字典
     @Autowired
     private DictionaryService dictionaryService;
+    //申请领料出库
+    @Autowired
+    private AskGoodsService askGoodsService;
 
     /**
      * 字典
@@ -58,4 +63,15 @@ public class GsAccessController {
     public Map<String, Object>addReceiveGoodsConfirm(ReceiveGoods receiveGoods){
         return receiveGoodsSerivce.addReceiveGoodsConfirm(receiveGoods);
     }
+
+    /**
+     * 生产领料出库
+     * @param askGoods 参数
+     * @return 返回结果
+     */
+    @PostMapping("addAskGoods")
+    @PassToken
+    public Map<String, Object>addAskGoods(AskGoods askGoods){
+        return askGoodsService.addAskGoods(askGoods);
+    }
 }

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

@@ -27,8 +27,8 @@ public class WarehousingController {
      * @return 返回结果
      */
     @GetMapping("getRecommend")
-    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String  unique){
-        return warehousingService.getRecommend(wllbCode, suppId, num, unique);
+    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate){
+        return warehousingService.getRecommend(wllbCode, suppId, num, unique, producDate);
     }
 
     /**
@@ -46,7 +46,7 @@ public class WarehousingController {
      * @param uniqueCode 参数
      * @return 返回接结果
      */
-    @PostMapping("getWarehousingVirtual")
+    @GetMapping("getWarehousingVirtual")
     public Map<String, Object> addWarehousingVirtual(String uniqueCode){
         return warehousingService.getWarehousingVirtual(uniqueCode);
     }
@@ -57,9 +57,9 @@ public class WarehousingController {
      * @param serial 连翻号
      * @return 返回结果
      */
-    @DeleteMapping("delWarehousingVirtual")
-    public Map<String, Object> delWarehousingVirtual(String wllbCode, String serial){
-        return warehousingService.delWarehousingVirtual(wllbCode, serial);
+    @PostMapping("delWarehousingVirtual")
+    public Map<String, Object> delWarehousingVirtual(@RequestBody String wllbCode, String serial, String producDate, String suppId){
+        return warehousingService.delWarehousingVirtual(wllbCode, serial, producDate, suppId);
     }
 
     /**

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

@@ -0,0 +1,43 @@
+package com.tld.mapper;
+
+import com.tld.model.AskGoods;
+import com.tld.model.Inventory;
+import com.tld.model.StorageLocation;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+@Mapper
+public interface AskGoodsMapper {
+    int getAskGoods(AskGoods askGoods);
+
+    void updateAskGoodsNum(AskGoods askGoods);
+
+    void addAskGoods(AskGoods askGoods);
+
+    int getAskGoodsf(AskGoods askGoods);
+
+    void addAskGoodsf(AskGoods askGoods);
+
+    List<AskGoods> getAskGoodsfList(AskGoods askGoods);
+
+    List<AskGoods> getAskGoodsMaterial(AskGoods askGoods);
+
+    List<Inventory> getMaterialCk(AskGoods askGoods);
+
+    void addAskGoodsVitrual(AskGoods askGoods);
+
+
+    void addAskGoodsLog(AskGoods askGoods);
+
+    Inventory getInventory(AskGoods askGoods);
+
+    AskGoods getAsk(Inventory inventory);
+
+    Map<String, Object> getScanIsNot(AskGoods askGoods);
+
+    AskGoods getAsknInfo(AskGoods askGoods);
+
+    int getAskInfoNumVitrual(AskGoods askGoods);
+}

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

@@ -23,7 +23,7 @@ public interface WarehousingMapper {
 
     List<StorageLocation> getIsNotSisableLocation(String isNotDisable);
 
-    void delWarehousingVirtual(@Param("wllbCode")String wllbCode, @Param("serial")String serial);
+    void delWarehousingVirtual(@Param("wllbCode")String wllbCode, @Param("serial")String serial, @Param("producDate")String producDate, @Param("suppId")String suppId);
 
     List<WarehousingVirtual> getVirtual(String uniqueCode);
 
@@ -50,4 +50,6 @@ public interface WarehousingMapper {
     List<WarehousingVirtual> getWarehousingVirtual(String uniqueCode);
 
     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);
 }

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

@@ -0,0 +1,119 @@
+package com.tld.model;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+/**
+ * 生产领料
+ */
+@Data
+@Accessors(chain = true)
+public class AskGoods implements Serializable {
+    /**
+     * 主键
+     */
+    private String id;
+    /**
+     * 要货单id
+     */
+    private String askGoodsId;
+    /**
+     * 分录号
+     */
+    private String entryNumber;
+    /**
+     * 生产订单号
+     */
+    private String productionCode;
+    /**
+     * 物料id
+     */
+    private String materialId;
+    /**
+     * wbs
+     */
+    private String wbs;
+    /**
+     * 计量单位
+     */
+    private String measurementId;
+    /**
+     * 数量
+     */
+    private String num;
+    /**
+     * 出库数量
+     */
+    private String outNum;
+    /**
+     * 要货申请单编号
+     */
+    private String askGoodsCode;
+    /**
+     * 公司编号
+     */
+    private String companyNumber;
+    /**
+     * 申请日期
+     */
+    private String sqrq;
+    /**
+     * 申请部门id
+     */
+    private String departmentId;
+    /**
+     * 申请部门
+     */
+    private String departmentName;
+    /**
+     * 来源类型
+     */
+    private String sourceType;
+    /**
+     * 移动类型
+     */
+    private String moveType;
+    /**
+     * 物料名称
+     */
+    private String materialName;
+    /**
+     * 物料编号
+     */
+    private String materialCode;
+    /**
+     * pda唯一标识
+     */
+    private String uniqueCode;
+    /**
+     * 库位编号
+     */
+    private String storageLocationCode;
+    /**
+     * 供应商编号
+     */
+    private String supplierId;
+    /**
+     * 连翻号
+     */
+    private String serial;
+    /**
+     * 出库类型
+     */
+    private String type;
+    /**
+     * 用户编号
+     */
+    private String userId;
+    /**
+     * 生成日期
+     */
+    private String scrq;
+    /**
+     * 生产日期
+     */
+    private String producDate;
+
+}

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

@@ -64,4 +64,20 @@ public class Inventory implements Serializable {
      * 供应商
      */
     private String supplierId;
+    /**
+     * 连翻号
+     */
+    private String serial;
+    /**
+     * 物料编号
+     */
+    private String wllbCode;
+    /**
+     * 生产日期
+     */
+    private String producDate;
+    /**
+     * 物料id
+     */
+    private String materialId;
 }

+ 12 - 0
src/main/java/com/tld/model/ReturnWarehousing.java

@@ -60,4 +60,16 @@ public class ReturnWarehousing implements Serializable {
      * 采购单id
      */
     private String orderNumber;
+    /**
+     * 年
+     */
+    private String year;
+    /**
+     * 月
+     */
+    private String month;
+    /**
+     * 日期
+     */
+    private String time;
 }

+ 8 - 0
src/main/java/com/tld/model/Storage.java

@@ -84,6 +84,14 @@ public class Storage implements Serializable {
      * 库位名称
      */
     private String storageLocationName;
+    /**
+     * 开始时间
+     */
+    private String startTime;
+    /**
+     * 结束时间
+     */
+    private String endTime;
     /**
      * 页数
      */

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

@@ -36,6 +36,10 @@ public class StorageLocation implements Serializable {
      * 物料类型
      */
     private String materialName;
+    /**
+     * 物料id
+     */
+    private String materialId;
     /**
      *库存容量
      */

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

@@ -36,6 +36,10 @@ public class WarehousingVirtual implements Serializable {
      * 物料分类
      */
     private String wllbClass;
+    /**
+     * 物料id
+     */
+    private String materialId;
     /**
      * 物料名称
      */

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

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

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

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

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

@@ -0,0 +1,118 @@
+package com.tld.service.impl;
+
+import com.tld.mapper.AskGoodsMapper;
+import com.tld.model.AskGoods;
+import com.tld.model.Inventory;
+import com.tld.model.StorageLocation;
+import com.tld.service.AskGoodsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+@Service
+public class AskGoodsServiceImpl implements AskGoodsService {
+
+    @Autowired
+    private AskGoodsMapper askGoodsMapper;
+
+    @Override
+    public Map<String, Object> addAskGoods(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            int count = askGoodsMapper.getAskGoods(askGoods);
+            if(count != 0){
+                askGoodsMapper.updateAskGoodsNum(askGoods);
+            } else {
+                if(askGoodsMapper.getAskGoodsf(askGoods) == 0){
+                    askGoodsMapper.addAskGoodsf(askGoods);
+                }
+                askGoodsMapper.addAskGoods(askGoods);
+            }
+            askGoodsMapper.addAskGoodsLog(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+
+    @Override
+    public Map<String, Object> getAskGoodsfList(AskGoods askGoods) {
+        Map<String, Object> map = new HashMap<>();
+        try{
+            List<AskGoods> list = askGoodsMapper.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 = askGoodsMapper.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 : askGoodsMapper.getMaterialCk(askGoods)){
+                AskGoods askGoods1 = askGoodsMapper.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 = askGoodsMapper.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 = askGoodsMapper.getInventory(askGoods); //库存数量
+            AskGoods askGoods1 = askGoodsMapper.getAsknInfo(askGoods); //要货单数量
+            int alreadyNum =  askGoodsMapper.getAskInfoNumVitrual(askGoods);//已扫描总数
+            int surplusNum = Integer.parseInt(askGoods1.getNum()) - alreadyNum; //剩余要扫描数量
+
+
+            askGoodsMapper.addAskGoodsVitrual(askGoods);
+            map.put("msg", "200");
+        }catch (Exception e){
+            e.printStackTrace();
+            map.put("msg", "500");
+            map.put("errMsg", "失败");
+        }
+        return map;
+    }
+}

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

@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletResponse;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -25,9 +26,15 @@ public class WarehousingServiceImpl implements WarehousingService {
     private UserMapper userMapper;
 
     @Override
-    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique) {
+    public Map<String, Object> getRecommend(String wllbCode, String suppId, String num, String unique, String producDate) {
         Map<String, Object> map = new HashMap<>();
         try{
+            Map<String, Object> mapVal = warehousingMapper.getScanIsNot(wllbCode, suppId, unique, producDate);
+            if(Integer.parseInt(mapVal.get("inventoryCount").toString()) != 0 || Integer.parseInt(mapVal.get("virtualCount").toString()) != 0){
+                map.put("msg", "500");
+                map.put("errMsg", "已被扫描");
+                return map;
+            }
             //判断如果是混合则走单独逻辑
             String isNotSisable = warehousingMapper.getIsNotSisable(wllbCode);
             if(isNotSisable.equals("1")){
@@ -75,10 +82,10 @@ public class WarehousingServiceImpl implements WarehousingService {
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public Map<String, Object> delWarehousingVirtual(String wllbCode, String serial) {
+    public Map<String, Object> delWarehousingVirtual(String wllbCode, String serial, String producDate, String suppId) {
         Map<String, Object> map = new HashMap<>();
         try{
-            warehousingMapper.delWarehousingVirtual(wllbCode, serial);
+            warehousingMapper.delWarehousingVirtual(wllbCode, serial, producDate, suppId);
             map.put("msg", "200");
         } catch (Exception e){
             e.printStackTrace();
@@ -98,17 +105,19 @@ public class WarehousingServiceImpl implements WarehousingService {
             for(WarehousingVirtual warehousingVirtual : warehousingMapper.getVirtual(uniqueCode)){
                 //查询采购单信息
                 List<ReceiveGoods> receiveGoods = warehousingMapper.getReceiveGoods(warehousingVirtual);
-                //所属账套
-                warehousingVirtual.setAccountSleeve(receiveGoods.get(0).getCompanyNumber());
-                //WBS
-                warehousingVirtual.setWbs(receiveGoods.get(0).getWbs());
+                if(receiveGoods.size() != 0) {
+                    //所属账套
+                    warehousingVirtual.setAccountSleeve(receiveGoods.get(0).getCompanyNumber());
+                    //WBS
+                    warehousingVirtual.setWbs(receiveGoods.get(0).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.setPart(warehousingVirtual1.getPart());
+                warehousingVirtual.setMaterialId(warehousingVirtual1.getMaterialId());
                 list.add(warehousingVirtual);
             }
             //入库
@@ -117,7 +126,7 @@ public class WarehousingServiceImpl implements WarehousingService {
             //返回采购单id
             StringBuilder stringBuilder = new StringBuilder();
             //入质检入库数量
-            for(WarehousingVirtual warehousingVirtual1 : warehousingMapper.getVirtual(uniqueCode)){
+            for(WarehousingVirtual warehousingVirtual1 : warehousingMapper.getVirtual(uniqueCode)) {
                 //查询采购单信息
                 List<ReceiveGoods> receiveGoods = warehousingMapper.getReceiveGoods(warehousingVirtual1);
                 for(ReceiveGoods receiveGoods1 : receiveGoods) {
@@ -137,7 +146,9 @@ public class WarehousingServiceImpl implements WarehousingService {
                         //存入给gs的返回数据
                         ReturnWarehousing returnWarehousing = new ReturnWarehousing()
                                 .setWarehousingNum(receiveGoods1.getWarehousingNum())
+
                                 .setGsCk(warehousingVirtual1.getGsCk())
+
                                 .setSourceType(receiveGoods1.getSourceType())
                                 .setMoveType(receiveGoods1.getMoveType())
                                 .setEntryNumber(receiveGoods1.getEntryNumber())
@@ -169,12 +180,32 @@ public class WarehousingServiceImpl implements WarehousingService {
     @Override
     public void plugOutWarehousing(String orderNumber) {
         try{
-            List<ReturnWarehousing> list = warehousingMapper.getPlugOutWarehousing(orderNumber);
+            Calendar cal = Calendar.getInstance();
+            int year = cal.get(Calendar.YEAR);
+            int month = cal.get(Calendar.MONTH) + 1;
+            int day = cal.get(Calendar.DATE) ;
+            List<ReturnWarehousing> list = new ArrayList<>();
+            for(ReturnWarehousing returnWarehousing : warehousingMapper.getPlugOutWarehousing(orderNumber)){
+                returnWarehousing.setYear(String.valueOf(year));
+                returnWarehousing.setMonth(String.valueOf(month));
+                returnWarehousing.setTime(year + "-" + month + "-" + day);
+                list.add(returnWarehousing);
+            }
         }catch (Exception e){
             e.printStackTrace();
         }
     }
 
+    public static void main(String[] args) {
+        Calendar cal = Calendar.getInstance();
+        int year = cal.get(Calendar.YEAR);
+        int month = cal.get(Calendar.MONTH) + 1;
+        int day = cal.get(Calendar.DATE) ;
+        System.out.println(year);
+        System.out.println(month);
+        System.out.println(day);
+    }
+
     @Override
     public Map<String, Object> warehousingFlowing(Storage storage) {
         Map<String, Object> map = new HashMap<>();
@@ -246,6 +277,6 @@ public class WarehousingServiceImpl implements WarehousingService {
         for(int i = 0; i < 4 - (count + "").length(); i++){
             stringBuilder.append("0");
         }
-        return (stringBuilder.append(count)).toString();
+        return (stringBuilder.append(count + 1)).toString();
     }
 }

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

@@ -0,0 +1,95 @@
+<?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.AskGoodsMapper">
+    <!-- 查询要货单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(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>
+    <!-- 查询次要货单是否存在 -->
+    <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 from tld_ask_goods_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_ask_goods 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 * from tld_inventory where material_id = #{materialId}
+    </select>
+    <!-- 新增出库虚拟表 -->
+    <insert id="addAskGoodsVitrual">
+        insert into tld_ask_goods_vitrual(unique_code,supplier_id,serial,wllb_code,produc_date,ask_goods_id,type)
+        values(uniqueCode,supplierId,serial,wllbCode,producDate,askGoodsId,#{type})
+    </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>
+    <!-- 查询库存是否充足 -->
+    <select id="getAsk" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.*
+        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 num from tld_ask_goods_vitrual where supplier_id = #{supplierId} and serial = #{uniqueCode} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualNum
+        from dual
+    </select>
+    <!-- 查询指定送货单信息 -->
+    <select id="getAsknInfo" resultType="com.tld.model.AskGoods">
+        SELECT
+            a.*
+        FROM
+            tld_ask_goods 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}
+    </select>
+</mapper>

+ 4 - 1
src/main/resources/mapper/MaterialClassMapper.xml

@@ -11,12 +11,15 @@
             c.name as wllbName,
             a.id
        from tld_material_class a
-       left join tld_storage_location b on a.storage_location_code = b.id
+       left join tld_storage_location b on a.storage_location_code = b.storage_location_code
        left join tld_material c on a.wllb_code = c.tld_id
        <trim prefix="WHERE" prefixOverrides="and |or">
            <if test="storageLocationCode != null and storageLocationCode != ''">
                and a.storage_location_code = #{storageLocationCode}
            </if>
+           <if test="id != null and id != ''">
+               and a.id = #{id}
+           </if>
            <if test="wllbCode != null and wllbCode != ''">
                and a.wllb_code = #{wllbCode}
            </if>

+ 6 - 4
src/main/resources/mapper/ReceiveGoodsMapper.xml

@@ -5,6 +5,7 @@
     <!-- 查询收货单 -->
     <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
         select
+            a.id,
             a.order_code,
             b.name as materialName,
             c.name as supplierName,
@@ -16,7 +17,7 @@
             a.arrival_time
         from tld_receive_goods a
         left join tld_material b on a.material_id = b.tld_id
-        left join tld_customer c on a.supplier_id = c.tld_id
+        left join tld_customer c on a.supplier_id = c.code
         <trim prefix="WHERE" prefixOverrides="and |or">
 <!--            <if test="materialId != null and materialId != ''">-->
 <!--                and a.material_id = #{materialId}-->
@@ -38,6 +39,7 @@
     <!-- 查询超时采购单 -->
     <select id="getPastReceiveGoods" resultType="com.tld.model.ReceiveGoods">
         select
+            a.id,
             a.order_code,
             b.name as materialName,
             c.name as supplierName,
@@ -49,7 +51,7 @@
             a.arrival_time
         from tld_receive_goods a
         left join tld_material b on a.material_id = b.tld_id
-        left join tld_customer c on a.supplier_id = c.tld_id
+        left join tld_customer c on a.supplier_id = c.code
         where a.type = "0" and a.arrival_time <![CDATA[<]]> CURDATE()
         <if test="orderCode != null and orderCode != ''">
             and a.order_code = #{orderCode}
@@ -61,8 +63,8 @@
     </select>
     <!-- 新增采购单信息 -->
     <insert id="addReceiveGoods">
-        insert into tld_receive_goods(order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number)
-        values(#{orderCode},#{materialId},#{purchaseNum},#{arrivalNum},#{type},#{qualifiedNum},#{disqualificationNum},#{wbs},#{arrivalTime},#{measurementId},#{supplierId},#{entryNumber});
+        insert into tld_receive_goods(order_code,material_id,purchase_num,arrival_num,type,qualified_num,disqualification_num,wbs,arrival_time,measurement_id,supplier_id,entry_number,warehousing_num)
+        values(#{orderCode},#{materialId},#{purchaseNum},#{arrivalNum},#{type},#{qualifiedNum},#{disqualificationNum},#{wbs},#{arrivalTime},#{measurementId},#{supplierId},#{entryNumber},'0');
     </insert>
     <!-- 新增采购单信息 -->
     <insert id="addReceiveGoodsf">

+ 28 - 20
src/main/resources/mapper/WarehousingMapper.xml

@@ -27,12 +27,12 @@
     <!-- 查询总数量 -->
     <select id="getScanNum" resultType="java.util.Map">
         SELECT
-            sum(a.num) + ${num} + c.amount as scanNum,
+            (ifnull(sum(a.num), 0) + ${num} + ifnull(c.amount, 0)) as scanNum,
             b.storage_location_capacity as storageLocationCapacity
         FROM
             tld_warehousing_virtual a
             join tld_storage_location b on a.storage_location_code = b.storage_location_code
-            join tld_inventory c on a.storage_location_code = c.storage_location_code
+            left join tld_inventory c on a.storage_location_code = c.storage_location_code
         where a.storage_location_code = #{storageLocationCode}
     </select>
     <!-- 查询 -->
@@ -54,22 +54,23 @@
     </select>
     <!-- 删除虚拟表 -->
     <delete id="delWarehousingVirtual">
-        delete from tld_warehousing_virtual where serial = #{serial} and wllb_code = #{wllbCode}
+        delete from tld_warehousing_virtual where serial = #{serial} and wllb_code = #{wllbCode} and produc_date = #{producDate} and supp_id = #{suppId}
     </delete>
     <!-- 查询虚拟表数据进行入库 -->
     <select id="getVirtual" resultType="com.tld.model.WarehousingVirtual">
         select * from tld_warehousing_virtual where unique_code = #{uniqueCode}
     </select>
     <!-- 查询采购单信息 -->
-    <select id="getReceiveGoods" resultType="com.tld.model.WarehousingVirtual">
+    <select id="getReceiveGoods" resultType="com.tld.model.ReceiveGoods">
         SELECT
-            a.*,b.company_number,b.order_number,b.source_type,b.move_type
+            a.*,b.company_number,b.order_number,b.source_type,b.move_type,f.name as supplierName
         FROM
             tld_receive_goods a
-            JOIN tld_receive_goods_f b on a.order_code = b.order_code
-            JOIN tld_material c on a.material_id = c.tld_id and c.code = #{wllbCode}
+            LEFT JOIN tld_receive_goods_f b on a.order_code = b.order_code
+            LEFT JOIN tld_material c on a.material_id = c.tld_id and c.code = #{wllbCode}
+            LEFT JOIN tld_customer f on a.supplier_id = f.tld_id
         WHERE
-            a.supplier_id = #{suppId} and a.warehousing_num <![CDATA[<]]> a.qualified_num
+            a.supplier_id = #{suppId} and IFNULL(a.warehousing_num, 0 ) <![CDATA[<]]> a.qualified_num
         ORDER BY
             a.arrival_time DESC
     </select>
@@ -77,27 +78,29 @@
     <update id="updateReceiveGood">
         update tld_receive_goods
         set
-            warehousing_num = (select warehousing_num + ${warehousingNum} from tld_receive_goods where id = #{id})
+            warehousing_num = (
+                select a.result from (select (warehousing_num + ${warehousingNum}) as result from tld_receive_goods where id = #{id}) a
+                )
         where id = #{id}
     </update>
     <!-- 查询物料类型 -->
     <select id="getWlClass" resultType="com.tld.model.WarehousingVirtual">
-        select wllb_class,name as part from tld_material where code = #{wllbCode}
+        select wllb_class,tld_id as materialId from tld_material where code = #{wllbCode}
     </select>
     <!-- 插入入库流水 -->
     <insert id="addStorage">
-        insert into tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq,storage_code)
+        insert into tld_storage(wllb_code,supplier_id,serial,produc_date,produc_batch,capacity,seq,type,user_id,department_id,storage_location_code,scrq)
         values
         <foreach collection="list" index="index" item="item" separator=",">
-            (#{wllbCode},#{suppId},#{serial},#{producDate},#{producDate},#{capacity},#{seq},#{type},#{userId},#{departmentId},#{storageLocationCode},now(),#{storageCode})
+            (#{item.wllbCode},#{item.suppId},#{item.serial},#{item.producDate},#{item.producDate},#{item.num},#{item.seq},#{item.type},#{item.userId},#{item.departmentId},#{item.storageLocationCode},now())
         </foreach>
     </insert>
     <!-- 插入库存 -->
     <insert id="addInventory">
-        insert into tld_inventory(storage_location_code,wllb_class,part,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial)
+        insert into tld_inventory(storage_location_code,wllb_class,material_id,amount,totime,hold,amount_lock,account_sleeve,wbs,supplier_id,serial,wllb_code,produc_date)
         values
         <foreach collection="list" index="index" item="item" separator=",">
-            (#{storageLocationCode},#{wllbClass},#{part},#{num},now(),'0','0',#{accountSleeve},#{wbs},#{suppId},#{serial})
+            (#{item.storageLocationCode},#{item.wllbClass},#{item.materialId},#{item.num},now(),'0','0',#{item.accountSleeve},#{item.wbs},#{item.suppId},#{item.serial},#{item.wllbCode},#{item.producDate})
         </foreach>
     </insert>
     <!-- 删除临时表数据 -->
@@ -112,17 +115,15 @@
     <insert id="addReturnWarehousing">
         insert into tld_return_gs_warehousing(storage_code,gs_ck,source_type,move_type,entry_number,wbs,material_id,warehousing_num,receive_goods_id,scrq,order_number)
         values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber});
-
-        insert into tld_receive_good_transmission_log(storage_code,gs_ck,source_type,move_type,entry_number,wbs,material_id,warehousing_num,receive_goods_id,scrq,order_number)
-        values(#{storageCode},#{gsCk},#{sourceType},#{moveType},#{entryNumber},#{wbs},#{materialId},#{warehousingNum},#{receiveGoodsId},now(),#{orderNumber});
     </insert>
     <!-- 入库回传 -->
     <select id="getPlugOutWarehousing" resultType="com.tld.model.ReturnWarehousing">
-        select <include refid="field"/> from tld_receive_good_transmission where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
+        select * from tld_return_gs_warehousing where #{orderNumber} LIKE CONCAT('%', CONCAT(order_number, ','), '%')
     </select>
     <!-- 查询入库流水 -->
     <select id="warehousingFlowing" resultType="com.tld.model.Storage">
         select
+            a.id,
             a.wllb_code,
             h.name as supplierName,
             a.serial,
@@ -140,7 +141,7 @@
         left join tld_user c on a.user_id = c.id
         left join tld_department e on a.department_id = 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.tld_id
+        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}
@@ -177,7 +178,7 @@
         left join tld_user c on a.user_id = c.id
         left join tld_department e on a.department_id = 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.tld_id
+        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}
@@ -190,4 +191,11 @@
             </if>
         </trim>
     </select>
+    <!-- 查询是否扫描 -->
+    <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_warehousing_virtual where supp_id = #{suppId} and serial = #{unique} and wllb_code = #{wllbCode} and produc_date = #{producDate}) as virtualCount
+        from dual
+    </select>
 </mapper>