diff --git a/src/main/java/com/huaheng/pc/config/FilterConfigDetail/domain/FilterConfigDetail.java b/src/main/java/com/huaheng/pc/config/FilterConfigDetail/domain/FilterConfigDetail.java
index 4831b61..a37b6fa 100644
--- a/src/main/java/com/huaheng/pc/config/FilterConfigDetail/domain/FilterConfigDetail.java
+++ b/src/main/java/com/huaheng/pc/config/FilterConfigDetail/domain/FilterConfigDetail.java
@@ -78,6 +78,10 @@ public class FilterConfigDetail implements Serializable {
     @ApiModelProperty(value="全SQL")
     private String statement;
 
+    @TableField(value = "sqll")
+    @ApiModelProperty(value="后续分组排序")
+    private String sqll;
+
     /**
      * 是否系统创建
      */
diff --git a/src/main/java/com/huaheng/pc/config/waveMaster/domain/WaveMaster.java b/src/main/java/com/huaheng/pc/config/waveMaster/domain/WaveMaster.java
index e77de7f..83ff3b0 100644
--- a/src/main/java/com/huaheng/pc/config/waveMaster/domain/WaveMaster.java
+++ b/src/main/java/com/huaheng/pc/config/waveMaster/domain/WaveMaster.java
@@ -23,13 +23,20 @@ public class WaveMaster implements Serializable {
     private Integer id;
 
     /**
-     * 主表名称
+     * 主表编码
      */
     @TableField(value = "code")
-    @ApiModelProperty(value="主表名称")
+    @ApiModelProperty(value="主表编码")
     private String code;
 
     /**
+     * 主表名称
+     */
+    @TableField(value = "name")
+    @ApiModelProperty(value="主表名称")
+    private String name;
+
+    /**
      * 仓库编码
      */
     @TableField(value = "warehouseCode")
diff --git a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
index 6368a48..a8c9a78 100644
--- a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
+++ b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailService.java
@@ -14,7 +14,7 @@ public interface InventoryDetailService extends IService<InventoryDetail> {
 
     void detailcreateCheckOutTask (Integer id);
 
-    List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail);
+    List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail,String sqll);
 
 
     AjaxResult detailCheckTask (Integer[] ids) throws InvocationTargetException, IllegalAccessException;
diff --git a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
index 33e4755..65504f1 100644
--- a/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/inventory/inventoryDetail/service/InventoryDetailServiceImpl.java
@@ -128,11 +128,18 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe
     }
 
     @Override
-    public List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail) {
-        sql=sql+" \n" +"and warehouseCode='" + shipmentDetail.getWarehouseCode()+"' \n" +
-                "and companyCode='" + shipmentDetail.getCompanyCode()+"' \n" +
-                "and materialCode='" + shipmentDetail.getMaterialCode() +"' \n" +
-                "and inventorySts='" + shipmentDetail.getInventorySts() + "'";
+    public List<InventoryDetail> selectBysql(String sql, ShipmentDetail shipmentDetail,String sqll) {
+        if(StringUtils.isEmpty(sqll)) {
+            sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
+                    "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
+                    "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
+                    "and inventorySts='" + shipmentDetail.getInventorySts() + "'";
+        }else {
+            sql = sql + " \n" + "and warehouseCode='" + shipmentDetail.getWarehouseCode() + "' \n" +
+                    "and companyCode='" + shipmentDetail.getCompanyCode() + "' \n" +
+                    "and materialCode='" + shipmentDetail.getMaterialCode() + "' \n" +
+                    "and inventorySts='" + shipmentDetail.getInventorySts() + "'"+ " \n" +sqll;
+        }
         return inventoryDetailMapper.selectBysql(sql);
     }
 
diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailService.java b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailService.java
index 96d8afd..1f4896f 100644
--- a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailService.java
+++ b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailService.java
@@ -17,5 +17,8 @@ public interface ShipmentDetailService extends IService<ShipmentDetail>{
 
     Integer countUnCompleted(Integer shipmentId);
 
+    //选中的单据加入波次
+    void saveWave(String ids,String code);
+
 
 }
diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
index 06e3515..93f44a0 100644
--- a/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
@@ -2,17 +2,25 @@ package com.huaheng.pc.shipment.shipmentDetail.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.huaheng.common.exception.service.ServiceException;
+import com.huaheng.common.support.Convert;
 import com.huaheng.common.utils.DataUtils;
 import com.huaheng.common.utils.StringUtils;
 import com.huaheng.common.utils.security.ShiroUtils;
 import com.huaheng.framework.web.domain.AjaxResult;
 import com.huaheng.pc.config.material.domain.Material;
 import com.huaheng.pc.config.material.service.MaterialService;
+import com.huaheng.pc.config.waveMaster.domain.WaveMaster;
+import com.huaheng.pc.config.waveMaster.service.WaveMasterService;
 import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
 import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
+import com.huaheng.pc.shipment.wave.domain.Wave;
+import com.huaheng.pc.shipment.wave.service.WaveService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -31,6 +39,10 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper,
     private MaterialService materialService;
     @Resource
     private ShipmentDetailMapper shipmentDetailMapper;
+    @Autowired
+    private WaveMasterService waveMasterService;
+    @Autowired
+    private WaveService waveService;
 
     /**
      * 新增出库明细
@@ -137,4 +149,76 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper,
     public Integer countUnCompleted(Integer shipmentId) {
         return shipmentDetailMapper.countUnCompleted(shipmentId);
     }
+
+
+    //选中的单据加入波次
+    @Override
+    @Transactional
+    public void saveWave(String ids, String code) {
+        //找到波次主表,看系统是否有此波次
+        LambdaQueryWrapper<WaveMaster> lam=Wrappers.lambdaQuery();
+        lam.eq(WaveMaster::getCode,code)
+                .eq(WaveMaster::getWarehouseCode,ShiroUtils.getWarehouseCode());
+        WaveMaster waveMaster=waveMasterService.getOne(lam);
+        if(waveMaster == null){
+            throw new ServiceException("系统没有此波次");
+        }
+
+        if(ids.length()>waveMaster.getMaxShipments()){
+            throw new ServiceException("加入波次的单据数量超过波次的单据限制");
+        }
+
+        List<ShipmentDetail> shipmentDetailList=new ArrayList<>();
+        BigDecimal qty=null;
+        //检查出库子表是否有处于波次的
+        for (Integer id : Convert.toIntArray(ids))
+        {
+            LambdaQueryWrapper<ShipmentDetail> lamDetail=Wrappers.lambdaQuery();
+            lamDetail.eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode())
+                    .eq(ShipmentDetail::getShipmentId,id);
+            List<ShipmentDetail> shipmentDetails=this.list(lamDetail);
+            if(shipmentDetails == null || shipmentDetails.size() == 0){
+                throw new ServiceException("系统没有主单id为"+id+"的子单");
+            }
+
+            //查看是否有单据处于波次中
+            for(ShipmentDetail shipmentDetail : shipmentDetails) {
+                if (shipmentDetail.getWaveId() != 0) {
+                    throw new ServiceException("主单id为" + id + "子单id为" + shipmentDetail.getId() + "的子单已加入波次,不可再加入波次");
+                }
+                shipmentDetailList.add(shipmentDetail);
+                qty=qty.add(shipmentDetail.getShipQty());
+            }
+        }
+
+        if(shipmentDetailList.size()>waveMaster.getMaxLines()){
+            throw new ServiceException("加入波次的总行数超过波次的行数限制");
+        }
+
+        //创建波次
+        Wave wave=new Wave();
+        wave.setWarehouseCode(ShiroUtils.getWarehouseCode());
+        wave.setMasterCode(code);
+        wave.setWaveName(waveMaster.getName());
+        wave.setStatus(0);
+        wave.setCurrentWaveStep("0");
+        wave.setTotalShipments(ids.length());
+        wave.setTotalLines(shipmentDetailList.size());
+        wave.setTotalQty(qty);
+        wave.setCreatedBy(ShiroUtils.getLoginName());
+        Boolean flag=waveService.save(wave);
+        if(flag == false){
+            throw new ServiceException("波次建立失败");
+        }
+
+        //修改出库子单
+        for(ShipmentDetail shipmentDetail :shipmentDetailList){
+            shipmentDetail.setWaveId(wave.getId());
+        }
+
+        flag = this.updateBatchById(shipmentDetailList);
+        if(flag == false){
+            throw new ServiceException("出库子单加入波次失败");
+        }
+    }
 }
diff --git a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
index d460e40..66698dd 100644
--- a/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
+++ b/src/main/java/com/huaheng/pc/shipment/shipmentHeader/controller/ShipmentHeaderController.java
@@ -15,6 +15,8 @@ import com.huaheng.framework.web.domain.AjaxResult;
 import com.huaheng.framework.web.page.PageDomain;
 import com.huaheng.framework.web.page.TableDataInfo;
 import com.huaheng.framework.web.page.TableSupport;
+import com.huaheng.pc.config.waveMaster.domain.WaveMaster;
+import com.huaheng.pc.config.waveMaster.service.WaveMasterService;
 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
 import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
 import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
@@ -46,6 +48,9 @@ public class ShipmentHeaderController extends BaseController
 	private ShipmentHeaderService shipmentHeaderService;
 	@Autowired
 	private ShipmentDetailService shipmentDetailService;
+	@Autowired
+	private WaveMasterService waveMasterService;
+
 	
 	@RequiresPermissions("shipment:bill:view")
 	@GetMapping()
@@ -225,4 +230,48 @@ public class ShipmentHeaderController extends BaseController
 //
 //	}
 
+	/**
+	 * 加入波次
+	 */
+	@GetMapping("/wave")
+	public String addZoneCode()
+	{
+		return prefix + "/addWave";
+	}
+
+	/**
+	 * 查询波次列表
+	 */
+	@RequiresPermissions("shipment:bill:list")
+	@Log(title = "出库-出库单", operating = "查询库区列表", action = BusinessType.GRANT)
+	@PostMapping("/waveList")
+	@ResponseBody
+	public TableDataInfo waveList()
+	{
+		LambdaQueryWrapper<WaveMaster> lam = Wrappers.lambdaQuery();
+		lam.eq(WaveMaster::getWarehouseCode,ShiroUtils.getWarehouseCode());
+		List<WaveMaster> waveMasters = waveMasterService.list(lam);
+		return getDataTable(waveMasters);
+	}
+
+
+
+	/**
+	 * 波次
+	 */
+	@RequiresPermissions("shipment:bill:wave")
+	@Log(title = "出库-出库单", operating="波次", action = BusinessType.OTHER)
+	@PostMapping( "/addWave")
+	@ResponseBody
+	@Transactional
+	public void analysis(String ids,String code){
+		if (StringUtils.isEmpty(ids))
+			throw new ServiceException("id不能为空");
+		if(StringUtils.isEmpty(code)){
+			throw new ServiceException("波次不能为空");
+		}
+
+		shipmentDetailService.saveWave(ids,code);
+	}
+
 }
diff --git a/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java b/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
index 9c38262..a603558 100644
--- a/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
+++ b/src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
@@ -61,7 +61,7 @@ public class ShippingCombinationService {
 
             //根据sql查库存
             try {
-                list = inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail);
+                list = inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
             }catch (Exception e){
                 throw new ServiceException("sql错误");
             }
@@ -81,7 +81,7 @@ public class ShippingCombinationService {
             }
 
             //根据sql查库存
-            list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail);
+            list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
             return list;
         }
 
@@ -110,7 +110,7 @@ public class ShippingCombinationService {
         }
 
         //根据sql查库存
-        list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail);
+        list=inventoryDetailService.selectBysql(filterConfigDetail.getStatement(),shipmentDetail,filterConfigDetail.getSqll());
         return list;
     }
 
diff --git a/src/main/java/com/huaheng/pc/shipment/wave/domain/Wave.java b/src/main/java/com/huaheng/pc/shipment/wave/domain/Wave.java
index 9fbebd0..a91ca74 100644
--- a/src/main/java/com/huaheng/pc/shipment/wave/domain/Wave.java
+++ b/src/main/java/com/huaheng/pc/shipment/wave/domain/Wave.java
@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 import java.util.Date;
 
 @ApiModel(value="com.huaheng.pc.shipment.wave.domain.Wave")
@@ -83,7 +84,7 @@ public class Wave implements Serializable {
      */
     @TableField(value = "totalQty")
     @ApiModelProperty(value="总数量")
-    private Integer totalQty;
+    private BigDecimal totalQty;
 
     /**
      * 波次开始时间
diff --git a/src/main/resources/templates/config/configValue/add.html b/src/main/resources/templates/config/configValue/add.html
index 365a59f..6b612f5 100644
--- a/src/main/resources/templates/config/configValue/add.html
+++ b/src/main/resources/templates/config/configValue/add.html
@@ -64,7 +64,7 @@
 </div>
 <div th:include="include::footer"></div>
 <script type="text/javascript">
-    var prefix = ctx + "config/company"
+    var prefix = ctx + "config/configValue"
     $("#form-configValue-add").validate({
         rules:{
             moduleType:{
diff --git a/src/main/resources/templates/shipment/shipmentHeader/addWave.html b/src/main/resources/templates/shipment/shipmentHeader/addWave.html
new file mode 100644
index 0000000..fd1e891
--- /dev/null
+++ b/src/main/resources/templates/shipment/shipmentHeader/addWave.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML>
+<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
+<meta charset="utf-8">
+<head th:include="include :: header"></head>
+<body>
+<div class="wrapper wrapper-content animated fadeInRight ibox-content">
+    <form class="form-horizontal m">
+        <div class="form-group">
+            <label class="col-sm-3 control-label">请选择:</label>
+            <div class="col-sm-8">
+                <select id="code" class="form-control"></select>
+            </div>
+        </div>
+        <div class="form-group">
+            <div class="form-control-static col-sm-offset-9">
+                <input type="button"  onclick="reSubmit()" class="btn btn-primary" value="提交">
+                <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
+            </div>
+        </div>
+    </form>
+</div>
+
+<div th:include="include :: footer"></div>
+</body>
+<script type="text/javascript">
+    let prefix = ctx + "shipment/shipmentHeader";
+    let url = location.search;
+    if (url.indexOf("?") !== -1){
+        var ids=url.substr(url.indexOf("?")+5);
+    }
+    $(function () {
+        $.ajax({
+            url:prefix+'/waveList',
+            type:'post',
+            success:function (res) {
+                if (res.code === 200) {
+                    $("#code").children().remove();
+                    for (let i = 0; i < res.data.length; i++) {
+                        $("#code").append("<option value='"+res.data[i].code+"'>"+res.data[i].name+"</option>")
+                    }
+                }
+                else {
+                    $.modal.msgError(res.msg);
+                }
+            }
+        })
+    });
+    function reSubmit() {
+        let code=$("#code option:selected").val();
+        $.ajax({
+            url:prefix+'/addWave',
+            type:'post',
+            data:{
+                ids:ids,
+                code:code
+            },
+            success:function (res) {
+                if (res.code === 200) {
+                    $.modal.msgSuccess("成功!");
+                    $.modal.close();
+                    window.parent.loadDetail();
+                }
+                else {
+                    $.modal.msgError(res.msg);
+                }
+            }
+        })
+    }
+</script>
+</html>
\ No newline at end of file
diff --git a/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html b/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
index 76a0701..ecc1659 100644
--- a/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
+++ b/src/main/resources/templates/shipment/shipmentHeader/shipmentHeader.html
@@ -91,10 +91,10 @@
                            <!--shiro:hasPermission="shipment:bill:analysis">-->
                             <!--<i class="fa fa-plus"></i> 订单分析-->
                         <!--</a>-->
-                        <!--<a class="btn btn-outline btn-success btn-rounded" onclick="wave()"-->
-                           <!--shiro:hasPermission="shipment:bill:analysis">-->
-                            <!--<i class="fa fa-plus"></i> 加入波次-->
-                        <!--</a>-->
+                        <a class="btn btn-outline btn-success btn-rounded" onclick="wave()"
+                           shiro:hasPermission="shipment:bill:wave">
+                            <i class="fa fa-plus"></i> 加入波次
+                        </a>
                     </div>
                     <table id="bootstrap-table" data-mobile-responsive="true" class="table table-bordered table-hover"></table>
                 </div>
@@ -705,23 +705,23 @@
         })
     });
 
-    // function addzone() {
-    //     let url=prefix_detail+'/addZoneCode?ids=';
-    //     let rows=$("#bootstrap-table-detail").bootstrapTable('getSelections');
-    //     if (rows.length === 0) {
-    //         $.modal.msgWarning("请至少选择一条记录");
-    //     }
-    //     else {
-    //         let ids = "";
-    //         for(let i=0; i<rows.length; i++) {
-    //             ids = ids + rows[i].id + ","
-    //         }
-    //         ids = ids.substring(0, ids.length-1);
-    //         url=url+ids;
-    //         $.modal.open("分配库区",url,800,250)
-    //     }
-    // }
-    //
+    function wave() {
+        let url=prefix+'/wave?ids=';
+        let rows=$("#bootstrap-table").bootstrapTable('getSelections');
+        if (rows.length === 0) {
+            $.modal.msgWarning("请至少选择一条记录");
+        }
+        else {
+            let ids = "";
+            for(let i=0; i<rows.length; i++) {
+                ids = ids + rows[i].id + ","
+            }
+            ids = ids.substring(0, ids.length-1);
+            url=url+ids;
+            $.modal.open("加入波次",url,800,250)
+        }
+    }
+
     // //自动分配库区
     // function autoZone() {
     //     let code=$("#shipmentCode").val();