Commit 8518315ce28337e481d0f73b5a0892010f5309a8

Authored by xqs
2 parents 416f31fc 55672fe5

Merge branch 'develop' of http://172.16.29.40:8010/wms/wms2 into develop

src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
@@ -21,6 +21,8 @@ import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader; @@ -21,6 +21,8 @@ import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
21 import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService; 21 import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
22 import com.huaheng.pc.shipment.shippingCombination.domain.ShippingSearch; 22 import com.huaheng.pc.shipment.shippingCombination.domain.ShippingSearch;
23 import com.huaheng.pc.shipment.shippingCombination.service.ShippingCombinationService; 23 import com.huaheng.pc.shipment.shippingCombination.service.ShippingCombinationService;
  24 +import com.huaheng.pc.shipment.wave.domain.Wave;
  25 +import com.huaheng.pc.shipment.wave.service.WaveService;
24 import com.huaheng.pc.task.taskDetail.domain.TaskDetail; 26 import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
25 import com.huaheng.pc.task.taskDetail.service.TaskDetailService; 27 import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
26 import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel; 28 import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel;
@@ -63,6 +65,8 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont @@ -63,6 +65,8 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont
63 private TaskHeaderService taskHeaderService; 65 private TaskHeaderService taskHeaderService;
64 @Autowired 66 @Autowired
65 private TaskDetailService taskDetailService; 67 private TaskDetailService taskDetailService;
  68 + @Autowired
  69 + private WaveService waveService;
66 70
67 71
68 @Override 72 @Override
@@ -249,6 +253,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont @@ -249,6 +253,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont
249 shipmentContainerDetail.setMaterialSpec(material.getSpec()); 253 shipmentContainerDetail.setMaterialSpec(material.getSpec());
250 shipmentContainerDetail.setQty(shipmentCombinationModel.getShipQty()); 254 shipmentContainerDetail.setQty(shipmentCombinationModel.getShipQty());
251 shipmentContainerDetail.setCreated(null); 255 shipmentContainerDetail.setCreated(null);
  256 + shipmentContainerDetail.setWaveId(shipmentDetail.getWaveId());
252 shipmentContainerDetail.setCreatedBy(ShiroUtils.getLoginName()); 257 shipmentContainerDetail.setCreatedBy(ShiroUtils.getLoginName());
253 shipmentContainerDetailService.save(shipmentContainerDetail); 258 shipmentContainerDetailService.save(shipmentContainerDetail);
254 } 259 }
@@ -418,6 +423,9 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont @@ -418,6 +423,9 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont
418 423
419 List<InventoryDetail> inventoryList = shippingCombinationService.getInventorys(item); 424 List<InventoryDetail> inventoryList = shippingCombinationService.getInventorys(item);
420 if(inventoryList.size() < 1 && item.getWaveId() != 0){ 425 if(inventoryList.size() < 1 && item.getWaveId() != 0){
  426 + Wave wave = waveService.getById(item.getWaveId());
  427 + wave.setStatus(999);
  428 + waveService.updateById(wave);
421 return AjaxResult.error("主单为"+item.getShipmentCode()+"子单id为"+item.getId() + "的单据没有库存,波次失败"); 429 return AjaxResult.error("主单为"+item.getShipmentCode()+"子单id为"+item.getId() + "的单据没有库存,波次失败");
422 } 430 }
423 if (inventoryList.size() < 1) { 431 if (inventoryList.size() < 1) {
src/main/java/com/huaheng/pc/shipment/shipmentDetail/service/ShipmentDetailServiceImpl.java
@@ -191,8 +191,10 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper, @@ -191,8 +191,10 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper,
191 if (shipmentDetail.getWaveId() != 0) { 191 if (shipmentDetail.getWaveId() != 0) {
192 throw new ServiceException("主单id为" + id + "子单id为" + shipmentDetail.getId() + "的子单已加入波次,不可再加入波次"); 192 throw new ServiceException("主单id为" + id + "子单id为" + shipmentDetail.getId() + "的子单已加入波次,不可再加入波次");
193 } 193 }
194 - shipmentDetailList.add(shipmentDetail);  
195 - qty=qty.add(shipmentDetail.getShipQty()); 194 + if(shipmentDetail.getShipQty().compareTo(shipmentDetail.getRequestQty())!=0) {
  195 + shipmentDetailList.add(shipmentDetail);
  196 + qty = qty.add(shipmentDetail.getShipQty().subtract(shipmentDetail.getRequestQty()));
  197 + }
196 } 198 }
197 } 199 }
198 200
@@ -236,7 +238,9 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper, @@ -236,7 +238,9 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper,
236 //修改出库子单,加入波次ID,并修改状态为波次 238 //修改出库子单,加入波次ID,并修改状态为波次
237 for(ShipmentDetail shipmentDetail :shipmentDetailList){ 239 for(ShipmentDetail shipmentDetail :shipmentDetailList){
238 shipmentDetail.setWaveId(wave.getId()); 240 shipmentDetail.setWaveId(wave.getId());
239 - shipmentDetail.setStatus(200); 241 + if(shipmentDetail.getStatus()<200) {
  242 + shipmentDetail.setStatus(200);
  243 + }
240 } 244 }
241 245
242 flag = this.updateBatchById(shipmentDetailList); 246 flag = this.updateBatchById(shipmentDetailList);
@@ -248,7 +252,6 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper, @@ -248,7 +252,6 @@ public class ShipmentDetailServiceImpl extends ServiceImpl&lt;ShipmentDetailMapper,
248 //修改主单状态 252 //修改主单状态
249 for (Integer id : Convert.toIntArray(ids)){ 253 for (Integer id : Convert.toIntArray(ids)){
250 ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id); 254 ShipmentHeader shipmentHeader = shipmentHeaderService.getById(id);
251 - shipmentHeader.setFirstStatus(200);  
252 shipmentHeader.setLastStatus(200); 255 shipmentHeader.setLastStatus(200);
253 shipmentHeaderList.add(shipmentHeader); 256 shipmentHeaderList.add(shipmentHeader);
254 } 257 }
src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java
@@ -175,10 +175,10 @@ public class WaveController extends BaseController { @@ -175,10 +175,10 @@ public class WaveController extends BaseController {
175 175
176 176
177 /** 177 /**
178 - * 开始波次 178 + * 释放
179 */ 179 */
180 @RequiresPermissions("shipment:wave:freed") 180 @RequiresPermissions("shipment:wave:freed")
181 - @Log(title = "出库-波次", operating = "开始波次", action = BusinessType.UPDATE) 181 + @Log(title = "出库-波次", operating = "波次释放", action = BusinessType.UPDATE)
182 @PostMapping("/freed") 182 @PostMapping("/freed")
183 @ResponseBody 183 @ResponseBody
184 public AjaxResult freed(String ids) { 184 public AjaxResult freed(String ids) {
src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java
@@ -10,14 +10,20 @@ import com.huaheng.framework.web.domain.AjaxResult; @@ -10,14 +10,20 @@ import com.huaheng.framework.web.domain.AjaxResult;
10 import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService; 10 import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
11 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail; 11 import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
12 import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService; 12 import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
  13 +import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
  14 +import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
13 import com.huaheng.pc.shipment.wave.domain.Wave; 15 import com.huaheng.pc.shipment.wave.domain.Wave;
14 import com.huaheng.pc.shipment.wave.mapper.WaveMapper; 16 import com.huaheng.pc.shipment.wave.mapper.WaveMapper;
  17 +import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
  18 +import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
  19 +import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
15 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service; 21 import org.springframework.stereotype.Service;
17 import org.springframework.transaction.annotation.Transactional; 22 import org.springframework.transaction.annotation.Transactional;
18 23
19 import java.util.ArrayList; 24 import java.util.ArrayList;
20 import java.util.Arrays; 25 import java.util.Arrays;
  26 +import java.util.HashSet;
21 import java.util.List; 27 import java.util.List;
22 28
23 @Service 29 @Service
@@ -28,6 +34,12 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; { @@ -28,6 +34,12 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; {
28 private ShipmentDetailService shipmentDetailService; 34 private ShipmentDetailService shipmentDetailService;
29 @Autowired 35 @Autowired
30 private ShipmentContainerHeaderService shipmentContainerHeaderService; 36 private ShipmentContainerHeaderService shipmentContainerHeaderService;
  37 + @Autowired
  38 + private TaskDetailService taskDetailService;
  39 + @Autowired
  40 + private TaskHeaderService taskHeaderService;
  41 + @Autowired
  42 + private ShipmentHeaderService shipmentHeaderService;
31 43
32 /** 44 /**
33 * 开始波次,对带有此波次号的单据进行后续的后台操作 45 * 开始波次,对带有此波次号的单据进行后续的后台操作
@@ -44,14 +56,14 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; { @@ -44,14 +56,14 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; {
44 List<ShipmentDetail> list = new ArrayList<>(); 56 List<ShipmentDetail> list = new ArrayList<>();
45 for (Integer id : Convert.toIntArray(ids)) { 57 for (Integer id : Convert.toIntArray(ids)) {
46 58
47 - //查看此波次的状态,状态不为o时,无法开始波次 59 + //1、查看此波次的状态,状态不为o时,无法开始波次
48 Wave wave = this.getById(id); 60 Wave wave = this.getById(id);
49 if(wave == null || wave.getStatus() != 0){ 61 if(wave == null || wave.getStatus() != 0){
50 return AjaxResult.error("id为"+id+"的波次找不到,或者状态不能做开始操作"); 62 return AjaxResult.error("id为"+id+"的波次找不到,或者状态不能做开始操作");
51 } 63 }
52 waves.add(wave); 64 waves.add(wave);
53 65
54 - //找到此波次的单据 66 + //2、找到此波次的单据
55 LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery(); 67 LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery();
56 lam.eq(ShipmentDetail::getWaveId,id) 68 lam.eq(ShipmentDetail::getWaveId,id)
57 .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()); 69 .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
@@ -63,15 +75,16 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; { @@ -63,15 +75,16 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; {
63 } 75 }
64 } 76 }
65 77
66 - //自动组盘 78 + //3、自动组盘
67 AjaxResult ajaxResult=shipmentContainerHeaderService.autoCombination(list); 79 AjaxResult ajaxResult=shipmentContainerHeaderService.autoCombination(list);
68 if(ajaxResult.getData() != null){ 80 if(ajaxResult.getData() != null){
69 - //生成任务 81 + //4、生成任务
70 shipmentContainerHeaderService.createTask(Arrays.asList(Convert.toIntArray(ajaxResult.getData().toString()))); 82 shipmentContainerHeaderService.createTask(Arrays.asList(Convert.toIntArray(ajaxResult.getData().toString())));
71 } 83 }
72 84
  85 + //5、修改波次的状态
73 for(Wave wave : waves){ 86 for(Wave wave : waves){
74 - wave.setStatus(400); 87 + wave.setStatus(300);
75 wave.setCurrentWaveStep("生成任务"); 88 wave.setCurrentWaveStep("生成任务");
76 } 89 }
77 Boolean flag = this.updateBatchById(waves); 90 Boolean flag = this.updateBatchById(waves);
@@ -84,12 +97,85 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; { @@ -84,12 +97,85 @@ public class WaveService extends ServiceImpl&lt;WaveMapper, Wave&gt; {
84 97
85 /** 98 /**
86 * 释放波次,执行任务 99 * 释放波次,执行任务
  100 + * 1、查看此波次的状态,是否可以释放波次
  101 + * 2、查看波次的状态,是成功释放还是失败释放
  102 + * 成功释放:1、找到此波次的所有子任务
  103 + * 2、根据子任务选出主任务
  104 + * 3、将这些主任务执行
  105 + * 失败释放:1.找到次波次的所有子单据
  106 + * 2.修改子单据的波次为0
  107 + * 3.修改主子单的状态
87 * @param ids 108 * @param ids
88 * @return 109 * @return
89 */ 110 */
90 @Transactional 111 @Transactional
91 public AjaxResult freed(String ids) { 112 public AjaxResult freed(String ids) {
  113 + Boolean flag = false;
  114 + List<TaskDetail> taskDetailList = new ArrayList<>();
  115 + for (Integer id : Convert.toIntArray(ids)) {
  116 +
  117 + //1、查看此波次是否可以释放
  118 + Wave wave = this.getById(id);
  119 + if(wave == null || (wave.getStatus()!=300 && wave.getStatus()!=999)){
  120 + return AjaxResult.error(id+"波次不可释放");
  121 + }
  122 +
  123 + //2、查看此波次的状态,看是成功释放还是失败释放
  124 + if(wave.getStatus() == 300) {
  125 + //成功释放——找到此波次的未执行的子任务列表
  126 + LambdaQueryWrapper<TaskDetail> lam = Wrappers.lambdaQuery();
  127 + lam.eq(TaskDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
  128 + .eq(TaskDetail::getStatus, 0)
  129 + .eq(TaskDetail::getWaveId, id);
  130 + List<TaskDetail> taskDetails = taskDetailService.list(lam);
  131 + if (taskDetails != null) {
  132 + taskDetailList.addAll(taskDetails);
  133 + }
  134 + }else {
  135 + //失败释放——找到次波次的所有子单据
  136 + LambdaQueryWrapper<ShipmentDetail> detailLam = Wrappers.lambdaQuery();
  137 + detailLam.eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode())
  138 + .eq(ShipmentDetail::getWaveId,wave.getId());
  139 + List<ShipmentDetail> shipmentDetails =shipmentDetailService.list(detailLam);
  140 +
  141 + //2.修改子单据的波次为0
  142 + //3.修改主子单的状态
  143 + HashSet<Integer> set = new HashSet<>();
  144 + for(ShipmentDetail item : shipmentDetails){
  145 + if(item.getShipQty().compareTo(item.getRequestQty())!=0) {
  146 + item.setStatus(0);
  147 + }
  148 + item.setWaveId(0);
  149 + set.add(item.getShipmentId());
  150 + }
  151 + flag = shipmentDetailService.updateBatchById(shipmentDetails);
  152 + if(flag == false){
  153 + throw new ServiceException("修改出库子单状态失败");
  154 + }
  155 + for(Integer shipmentId :set){
  156 + ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentId);
  157 + if(shipmentHeader == null){
  158 + throw new ServiceException("没有对应的出库主单");
  159 + }
  160 + if(shipmentHeader.getFirstStatus()<= 200) {
  161 + shipmentHeader.setFirstStatus(0);
  162 + flag = shipmentHeaderService.updateById(shipmentHeader);
  163 + if (flag == false) {
  164 + throw new ServiceException("修改出库主单失败");
  165 + }
  166 + }
  167 + }
  168 + }
  169 + }
  170 +
  171 + HashSet<Integer> idSet = new HashSet();
  172 + //成功释放——遍历子任务列表,找出主单(distinct)id
  173 + for(TaskDetail item : taskDetailList){
  174 + idSet.add(item.getTaskId());
  175 + }
  176 + //成功释放——将这些主任务执行
  177 + taskHeaderService.sendTaskToWcs(idSet.toArray(new Integer[idSet.size()]));
92 178
93 - return null; 179 + return AjaxResult.success("波次释放成功");
94 } 180 }
95 } 181 }
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
@@ -296,6 +296,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea @@ -296,6 +296,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
296 taskDetail.setFromLocation(task.getFromLocation()); 296 taskDetail.setFromLocation(task.getFromLocation());
297 taskDetail.setToLocation(task.getToLocation()); 297 taskDetail.setToLocation(task.getToLocation());
298 taskDetail.setStatus(0); 298 taskDetail.setStatus(0);
  299 + taskDetail.setWaveId(shipmentContainerDetail.getWaveId());
299 taskDetail.setInventorySts(shipmentContainerDetail.getInventorySts()); 300 taskDetail.setInventorySts(shipmentContainerDetail.getInventorySts());
300 taskDetail.setTaskType(task.getTaskType()); 301 taskDetail.setTaskType(task.getTaskType());
301 taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); 302 taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());