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 fbe805d..fee6620 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
@@ -151,7 +151,12 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper,
     }
 
 
-    //选中的单据加入波次
+    /**
+     * 选中的单据加入波次
+     * 根据选中的主单ID和波次主表的code,判断主单之和是否符合波次的限制条件,
+     * 看此code的波次是否建成未开始执行,如果是则只需修改波次属性,否则创建新的波次,
+     * 修改加入波次的子单,修改子单和主单的状态,并修改子单的waveId
+     */
     @Override
     @Transactional
     public void saveWave(String ids, String code) {
@@ -228,14 +233,29 @@ public class ShipmentDetailServiceImpl extends ServiceImpl<ShipmentDetailMapper,
             }
         }
 
-        //修改出库子单
+        //修改出库子单,加入波次ID,并修改状态为波次
         for(ShipmentDetail shipmentDetail :shipmentDetailList){
             shipmentDetail.setWaveId(wave.getId());
+            shipmentDetail.setStatus(200);
         }
 
         flag = this.updateBatchById(shipmentDetailList);
         if(flag == false){
             throw new ServiceException("出库子单加入波次失败");
         }
+
+        List<ShipmentHeader> shipmentHeaderList=new ArrayList<>();
+        //修改主单状态
+        for (Integer id : Convert.toIntArray(ids)){
+            ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id);
+            shipmentHeader.setFirstStatus(200);
+            shipmentHeader.setLastStatus(200);
+            shipmentHeaderList.add(shipmentHeader);
+        }
+        flag = shipmentHeaderService.updateBatchById(shipmentHeaderList);
+        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 76a300f..2ee90b1 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
@@ -272,6 +272,7 @@ public class ShipmentHeaderController extends BaseController
 		}
 
 		shipmentDetailService.saveWave(ids,code);
+
 		return AjaxResult.success("加入波次成功");
 	}
 
diff --git a/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java b/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java
index 75aa9fa..22c9dd0 100644
--- a/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java
+++ b/src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java
@@ -173,4 +173,20 @@ public class WaveController extends BaseController {
         return result;
     }
 
+
+    /**
+     * 开始波次
+     */
+    @RequiresPermissions("shipment:wave:freed")
+    @Log(title = "出库-波次", operating = "开始波次", action = BusinessType.UPDATE)
+    @PostMapping("/freed")
+    @ResponseBody
+    public AjaxResult freed(String ids) {
+        if (StringUtils.isEmpty(ids)){
+            return AjaxResult.error("id不能为空");
+        }
+        AjaxResult result=waveService.freed(ids);
+        return result;
+    }
+
 }
diff --git a/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java b/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java
index d0bf227..67d171f 100644
--- a/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java
+++ b/src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java
@@ -3,6 +3,7 @@ package com.huaheng.pc.shipment.wave.service;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huaheng.common.exception.service.ServiceException;
 import com.huaheng.common.support.Convert;
 import com.huaheng.common.utils.security.ShiroUtils;
 import com.huaheng.framework.web.domain.AjaxResult;
@@ -28,12 +29,28 @@ public class WaveService extends ServiceImpl<WaveMapper, Wave> {
     @Autowired
     private ShipmentContainerHeaderService shipmentContainerHeaderService;
 
-    //开始波次,对带有此波次号的单据进行后续的后台操作
+    /**
+     * 开始波次,对带有此波次号的单据进行后续的后台操作
+     * 1、查看波次是否符合开始波次的条件
+     * 2、整合波次的所有子单单据
+     * 3、对每个单据自动组盘,失败则回退
+     * 4、生成任务
+     * 5、修改波次的状态
+     */
 
     @Transactional
     public AjaxResult startWave(String ids) {
+        List<Wave> waves = new ArrayList<>();
         List<ShipmentDetail> list = new ArrayList<>();
         for (Integer id : Convert.toIntArray(ids)) {
+
+            //查看此波次的状态,状态不为o时,无法开始波次
+            Wave wave = this.getById(id);
+            if(wave == null || wave.getStatus() != 0){
+                return AjaxResult.error("id为"+id+"的波次找不到,或者状态不能做开始操作");
+            }
+            waves.add(wave);
+
             //找到此波次的单据
             LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery();
             lam.eq(ShipmentDetail::getWaveId,id)
@@ -52,6 +69,27 @@ public class WaveService extends ServiceImpl<WaveMapper, Wave> {
             //生成任务
             shipmentContainerHeaderService.createTask(Arrays.asList(Convert.toIntArray(ajaxResult.getData().toString())));
         }
+
+        for(Wave wave : waves){
+            wave.setStatus(400);
+            wave.setCurrentWaveStep("生成任务");
+        }
+        Boolean flag = this.updateBatchById(waves);
+        if(flag == false){
+            throw new ServiceException("波次运行失败,修改波次状态时报错");
+        }
         return AjaxResult.success("波次运行成功");
     }
+
+
+    /**
+     * 释放波次,执行任务
+     * @param ids
+     * @return
+     */
+    @Transactional
+    public AjaxResult freed(String ids) {
+
+        return null;
+    }
 }
diff --git a/src/main/resources/templates/shipment/wave/wave.html b/src/main/resources/templates/shipment/wave/wave.html
index 9b41e4b..2b4a993 100644
--- a/src/main/resources/templates/shipment/wave/wave.html
+++ b/src/main/resources/templates/shipment/wave/wave.html
@@ -231,6 +231,23 @@
                 };
                 localSubmit(url, "post", "json", data);
             }
+
+
+            //释放
+            function freed() {
+                var rows = $("#bootstrap-table").bootstrapTable('getSelections');
+                if (rows.length == 0) {
+                    $.modal.alertWarning("请至少选择一条记录");
+                    return;
+                }
+                var url = prefix + "/freed";
+                var data = {
+                    "ids": rows.map(function (v) {
+                        return v.id;
+                    }).join(',')
+                };
+                localSubmit(url, "post", "json", data);
+            }
         </script>
 </body>
 </html>
\ No newline at end of file