Commit 8fb43f641b4b633cb99ef916558c9d87823baa5f

Authored by xqs
2 parents 4503f4f4 0d86cf9f

pull

src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderService.java
... ... @@ -5,6 +5,7 @@ import com.huaheng.pc.shipment.shipmentContainerDetail.domain.ShipmentContainerD
5 5 import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel;
6 6 import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
7 7 import com.baomidou.mybatisplus.extension.service.IService;
  8 +import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
8 9 import org.apache.ibatis.annotations.Param;
9 10  
10 11 import java.util.List;
... ... @@ -28,6 +29,8 @@ public interface ShipmentContainerHeaderService extends IService<ShipmentContain
28 29  
29 30 AjaxResult autoCombination(String shipmentCode);
30 31  
  32 + AjaxResult autoCombination(List<ShipmentDetail> shipmentDetailList);
  33 +
31 34 AjaxResult checkForCancelCombination(List<Integer> shipmentContainerIds);
32 35  
33 36 AjaxResult createTask(List<Integer> idList);
... ...
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... ... @@ -387,16 +387,21 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
387 387 @Override
388 388 @Transactional
389 389 public AjaxResult autoCombination(String shipmentCode) {
390   - int num=0;
391   - AjaxResult ajaxResult=new AjaxResult();
392   -
393   - LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper=Wrappers.lambdaQuery();
394   - lambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode,shipmentCode)
395   - .eq(ShipmentDetail::getWarehouseCode,ShiroUtils.getWarehouseCode());
  390 + LambdaQueryWrapper<ShipmentDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
  391 + lambdaQueryWrapper.eq(ShipmentDetail::getShipmentCode, shipmentCode)
  392 + .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
396 393 List<ShipmentDetail> shipmentDetailList = shipmentDetailService.list(lambdaQueryWrapper);
397   - if(shipmentDetailList.size()<1 || shipmentDetailList==null){
  394 + if (shipmentDetailList.size() < 1 || shipmentDetailList == null) {
398 395 return AjaxResult.error("找不到子单链");
399 396 }
  397 + return this.autoCombination(shipmentDetailList);
  398 + }
  399 +
  400 +
  401 + //出库自动组盘
  402 + public AjaxResult autoCombination(List<ShipmentDetail> shipmentDetailList){
  403 + int num = 0;
  404 + List<Integer> list=new ArrayList<>();
400 405 for (ShipmentDetail item : shipmentDetailList) {
401 406 //获取需要出库数量
402 407 BigDecimal shipmentQty = item.getShipQty().subtract(item.getRequestQty());
... ... @@ -412,6 +417,9 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
412 417 // search.setInventorySts(item.getInventorySts()); //物料状态
413 418  
414 419 List<InventoryDetail> inventoryList = shippingCombinationService.getInventorys(item);
  420 + if(inventoryList.size() < 1 && item.getWaveId() != 0){
  421 + return AjaxResult.error("主单为"+item.getShipmentCode()+"子单id为"+item.getId() + "的单据没有库存,波次失败");
  422 + }
415 423 if (inventoryList.size() < 1) {
416 424 num = num + 1;
417 425 } else {
... ... @@ -426,11 +434,12 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
426 434 shipmentCombination.setInventoryDetailId(inventory.getId());
427 435 shipmentCombination.setShipmentDetailId(item.getId());
428 436 shipmentCombination.setType((short) 300);
429   - List<Integer> list=new ArrayList<>();
  437 +
430 438 //如果库存数 >= 待出库数,组盘数就是待出库数并且结束组盘,否则组盘数就是库存数
431 439 if (inventoryQty.compareTo(shipmentQty) > -1) {
432 440 shipmentCombination.setShipQty(shipmentQty);
433 441 ShipmentContainerHeader shipmentContainerHeader=this.combination(shipmentCombination);
  442 + list.add(shipmentContainerHeader.getId());
434 443 } else {
435 444 shipmentCombination.setShipQty(inventoryQty);
436 445 ShipmentContainerHeader shipmentContainerHeader=this.combination(shipmentCombination);
... ... @@ -443,7 +452,7 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl&lt;ShipmentCont
443 452 if(num==shipmentDetailList.size()){
444 453 throw new ServiceException("单据物料在此库区没有库存,无法出库");
445 454 }
446   - return AjaxResult.success("成功");
  455 + return AjaxResult.success("成功",list);
447 456 }
448 457  
449 458 /**
... ...
src/main/java/com/huaheng/pc/shipment/wave/controller/WaveController.java
... ... @@ -165,9 +165,12 @@ public class WaveController extends BaseController {
165 165 @Log(title = "出库-波次", operating = "开始波次", action = BusinessType.UPDATE)
166 166 @PostMapping("/startWave")
167 167 @ResponseBody
168   - public AjaxResult editSave(Wave wave) {
169   - wave.setLastUpdatedBy(ShiroUtils.getLoginName());
170   - return toAjax(waveService.updateById(wave));
  168 + public AjaxResult starWave(String ids) {
  169 + if (StringUtils.isEmpty(ids)){
  170 + return AjaxResult.error("id不能为空");
  171 + }
  172 + AjaxResult result=waveService.startWave(ids);
  173 + return result;
171 174 }
172 175  
173 176 }
... ...
src/main/java/com/huaheng/pc/shipment/wave/service/WaveService.java
1 1 package com.huaheng.pc.shipment.wave.service;
2 2  
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
3 5 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6 +import com.huaheng.common.support.Convert;
  7 +import com.huaheng.common.utils.security.ShiroUtils;
  8 +import com.huaheng.framework.web.domain.AjaxResult;
  9 +import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
  10 +import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
  11 +import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
4 12 import com.huaheng.pc.shipment.wave.domain.Wave;
5 13 import com.huaheng.pc.shipment.wave.mapper.WaveMapper;
  14 +import org.springframework.beans.factory.annotation.Autowired;
6 15 import org.springframework.stereotype.Service;
  16 +import org.springframework.transaction.annotation.Transactional;
  17 +
  18 +import java.util.ArrayList;
  19 +import java.util.Arrays;
  20 +import java.util.List;
7 21  
8 22 @Service
9 23 public class WaveService extends ServiceImpl<WaveMapper, Wave> {
10 24  
  25 +
  26 + @Autowired
  27 + private ShipmentDetailService shipmentDetailService;
  28 + @Autowired
  29 + private ShipmentContainerHeaderService shipmentContainerHeaderService;
  30 +
  31 + //开始波次,对带有此波次号的单据进行后续的后台操作
  32 +
  33 + @Transactional
  34 + public AjaxResult startWave(String ids) {
  35 + List<ShipmentDetail> list = new ArrayList<>();
  36 + for (Integer id : Convert.toIntArray(ids)) {
  37 + //找到此波次的单据
  38 + LambdaQueryWrapper<ShipmentDetail> lam = Wrappers.lambdaQuery();
  39 + lam.eq(ShipmentDetail::getWaveId,id)
  40 + .eq(ShipmentDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
  41 + List<ShipmentDetail> shipmentDetails=shipmentDetailService.list(lam);
  42 +
  43 + //整合所有加入波次的单据
  44 + if(shipmentDetails != null){
  45 + list.addAll(shipmentDetails);
  46 + }
  47 + }
  48 +
  49 + //自动组盘
  50 + AjaxResult ajaxResult=shipmentContainerHeaderService.autoCombination(list);
  51 + if(ajaxResult.getData() != null){
  52 + //生成任务
  53 + shipmentContainerHeaderService.createTask(Arrays.asList(Convert.toIntArray(ajaxResult.getData().toString())));
  54 + }
  55 + return AjaxResult.success("波次运行成功");
  56 + }
11 57 }
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... ... @@ -502,6 +502,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
502 502 detail.setMaterialCode(DataUtils.getString(map.get("materialCode")));//物料号
503 503 detail.setMaterialName(DataUtils.getString(map.get("materialName")));//物料名称
504 504 detail.setMaterialSpec(DataUtils.getString(map.get("materialSpec")));//物料规格
  505 + detail.setMaterialUnit(DataUtils.getString(map.get("materialUnit")));//物料单位
505 506 detail.setReceiptCode(DataUtils.getString(map.get("receiptCode")));//入库单编码
506 507 detail.setReceiptDetailId(DataUtils.getInteger(map.get("receiptDetailId")));//入库单明细ID
507 508 detail.setBatch(DataUtils.getString(map.get("batch")));//批次
... ... @@ -534,6 +535,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
534 535 inventoryTransaction.setContainerCode(DataUtils.getString(map.get("containerCode")));
535 536 inventoryTransaction.setMaterialCode(DataUtils.getString(map.get("materialCode")));
536 537 inventoryTransaction.setMaterialName(DataUtils.getString(map.get("materialName")));
  538 + inventoryTransaction.setMaterialSpec(DataUtils.getString(map.get("materialSpec")));//物料规格
  539 + inventoryTransaction.setMaterialUnit(DataUtils.getString(map.get("materialUnit")));//物料单位
537 540 inventoryTransaction.setBillCode(DataUtils.getString(map.get("receiptCode")));
538 541 inventoryTransaction.setBillDetailId(DataUtils.getInteger(map.get("receiptDetailId")));
539 542 inventoryTransaction.setBatch(DataUtils.getString(map.get("batch")));
... ... @@ -1293,8 +1296,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1293 1296 shipmentContainerHeaderLambdaUpdateWrapper.eq(ShipmentContainerHeader::getId,task.getAllocationHeadId());
1294 1297 if (! shipmentContainerHeaderService.update(shipmentContainerHeader, shipmentContainerHeaderLambdaUpdateWrapper))
1295 1298 throw new ServiceException("更新组盘头状态失败");
1296   -
1297   -
1298 1299 //修改出库单状态
1299 1300 LambdaQueryWrapper<TaskDetail> taskDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
1300 1301 taskDetailLambdaQueryWrapper.eq(TaskDetail::getTaskId,task.getId());
... ...