From 322f42a9e9cb263eb4c26acaf49bc3ccdb9eb2f2 Mon Sep 17 00:00:00 2001 From: youjie <272855983@qq.com> Date: Mon, 26 Jun 2023 11:11:08 +0800 Subject: [PATCH] 1. 完善盘点代码 2. 分配库位 优先低库位 然后高库位, 优先低层 然后高层 --- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java | 10 ++++------ huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java | 6 +++--- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java | 77 ++++++++++++++++++++++++++++++++++++----------------------------------------- huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------- 4 files changed, 126 insertions(+), 108 deletions(-) diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java index c13f8d9..d8e886e 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java @@ -1,7 +1,5 @@ package org.jeecg.modules.wms.api.wcs.controller; -import java.net.SocketException; - import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -40,7 +38,7 @@ public class WcsController extends HuahengBaseController { @ResponseBody @ApiOperation("仓位分配") @ApiLogger(apiName = "仓位分配", from = "WCS") - @AccessLimit(seconds = 5, maxCount = 5) + @AccessLimit(seconds = 5, maxCount = 10) public Result warecellAllocation(@RequestBody WarecellDomain warecellDomain, HttpServletRequest req) { String warehouseCode = warecellDomain.getWarehouseCode(); String taskNo = warecellDomain.getTaskNo(); @@ -51,7 +49,7 @@ public class WcsController extends HuahengBaseController { if (StringUtils.isEmpty(taskNo)) { return Result.error("仓位分配, 任务号为空"); } - if (StringUtils.isEmpty(warecellDomain.getZoneCode())) { + if (StringUtils.isEmpty(zoneCode)) { return Result.error("仓位分配, 目的区域为空"); } if (StringUtils.isEmpty(warecellDomain.getHeight())) { @@ -146,7 +144,7 @@ public class WcsController extends HuahengBaseController { @ResponseBody @ApiOperation("WCS任务完成") @ApiLogger(apiName = "WCS任务完成", from = "WCS") - @AccessLimit(seconds = 5, maxCount = 5) + @AccessLimit(seconds = 5, maxCount = 10) public Result completeTaskByWMS(@RequestBody TaskEntity taskEntity) { String taskNo = taskEntity.getTaskNo(); String lockKey = taskNo; @@ -182,7 +180,7 @@ public class WcsController extends HuahengBaseController { @ResponseBody @ApiOperation("到达拣选台") @ApiLogger(apiName = "到达拣选台", from = "WCS") - @AccessLimit(seconds = 5, maxCount = 5) + @AccessLimit(seconds = 5, maxCount = 10) public Result arrivedNotice(@RequestBody ArriveEntity arriveEntity) { String taskNo = arriveEntity.getTaskNo(); String port = arriveEntity.getPort(); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java index 2338143..6c5f2de 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java @@ -25,7 +25,6 @@ import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StopWatch; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -106,7 +105,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService if (StringUtils.isNotEmpty(value)) { searchNumber = Integer.parseInt(value); } - String lastString = "ORDER BY layer asc, id asc limit " + searchNumber; + String lastString = "ORDER BY high asc, layer asc, id asc limit " + searchNumber; List<Integer> removeRoadWays = new ArrayList<>(); // 寻找可用巷道,空闲的空库位低于设定值,那么这个巷道就不能用来分配库位 for (Integer roadWay : roadWays) { @@ -176,12 +175,13 @@ public class LocationAllocationServiceImpl implements LocationAllocationService List<Location> locationList = locationService.getLocationListByZoneCode(zoneCode, warehouseCode); roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); } + String lastString = "ORDER BY high asc, layer asc, id asc limit 1"; Integer roadWay = locationAllocationService.getRoadWay(roadWays, warehouseCode); LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay) .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).ge(Location::getHigh, high) .eq(StringUtils.isNotEmpty(materialAreaCode), Location::getMaterialAreaCode, materialAreaCode).in(Location::getLocationTypeCode, locationTypeCodeList) - .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).last("ORDER BY layer asc, id asc limit 1"); + .eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING).last(lastString); // 单伸位逻辑简单,只需要找到一个空闲库位 Location location = locationService.getOne(locationLambdaQueryWrapper); if (location == null) { diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java index 24c8328..74e0697 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountHeader/service/impl/CycleCountHeaderServiceImpl.java @@ -1,11 +1,15 @@ package org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl; -import org.jeecg.common.exception.JeecgBootException; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import java.text.SimpleDateFormat; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import javax.annotation.Resource; + import org.jeecg.common.api.vo.Result; -import org.jeecg.modules.wms.config.receiptType.entity.ReceiptType; -import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.entity.CycleCountDetail; import org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl.CycleCountDetailServiceImpl; import org.jeecg.modules.wms.stocktaking.cycleCountHeader.entity.CycleCountHeader; @@ -14,29 +18,21 @@ import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.ICycleCountHea import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.stereotype.Service; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.transaction.annotation.Transactional; -import javax.annotation.Resource; -import java.text.SimpleDateFormat; -import java.util.Comparator; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; /** * @Description: 盘点主表 - * @Author: jeecg-boot - * @Date: 2023-01-30 - * @Version: V1.0 + * @Author: jeecg-boot + * @Date: 2023-01-30 + * @Version: V1.0 */ @Service public class CycleCountHeaderServiceImpl extends ServiceImpl<CycleCountHeaderMapper, CycleCountHeader> implements ICycleCountHeaderService { - - - @Resource private CycleCountDetailServiceImpl cycleCountDetailService; @@ -56,55 +52,54 @@ public class CycleCountHeaderServiceImpl extends ServiceImpl<CycleCountHeaderMap } @Override + @Transactional public void updataHeaderStatus(String cycleCountHeaderCode) { - //查询明细单状态,然后更新主单状态 - //执行中时,对比主单状态,比主单数值小的不改变主单,明细单大于主单状态时改变主单状态到和明细单相同 - //完成时在全部单据都完成后才能修改主单状态为完成 - //当其中一条明细有差异时,主单为有差异状态 + // 查询明细单状态,然后更新主单状态 + // 执行中时,对比主单状态,比主单数值小的不改变主单,明细单大于主单状态时改变主单状态到和明细单相同 + // 完成时在全部单据都完成后才能修改主单状态为完成 + // 当其中一条明细有差异时,主单为有差异状态 CycleCountHeader cyclecountHeader = new CycleCountHeader(); cyclecountHeader.setCode(cycleCountHeaderCode); // cyclecountHeader.setWarehouseCode(ShiroUtils.getWarehouseCode()); LambdaQueryWrapper<CycleCountHeader> lamb = Wrappers.lambdaQuery(cyclecountHeader); cyclecountHeader = this.getOne(lamb); - if(StringUtils.isNull(cyclecountHeader)){ + if (StringUtils.isNull(cyclecountHeader)) { throw new JeecgBootException("没有找到盘点主单!"); } CycleCountDetail temp = new CycleCountDetail(); temp.setCycleCountHeadCode(cyclecountHeader.getCode()); temp.setWarehouseCode(cyclecountHeader.getWarehouseCode()); - //temp.setCompanyCode(cyclecountHeader.getCompanyCode()); + // temp.setCompanyCode(cyclecountHeader.getCompanyCode()); LambdaQueryWrapper<CycleCountDetail> lam = Wrappers.lambdaQuery(temp); List<CycleCountDetail> list = cycleCountDetailService.list(lam); - if(list.size() < 1){ + if (list.size() < 1) { throw new JeecgBootException("明细为空!"); } - //当有子单的状态为100时触发主单的完成状态 - //100状态只有全部完成才写入主单 - long count100 = list.stream().filter(t-> t.getEnableStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED)).count(); //明细已完成的条数 - if(count100 == list.size() ){ + // 当有子单的状态为100时触发主单的完成状态 + // 100状态只有全部完成才写入主单 + long count100 = list.stream().filter(t -> t.getEnableStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED)).count(); // 明细已完成的条数 + if (count100 == list.size()) { cyclecountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED); this.updateById(cyclecountHeader); } - //有任何子单没有完成则主单不修改为100 - //有到100的子单时,主单的状态一定是100的前一个状态,所以状态不变 - if(count100 == 0){ - //所有子单状态比较主单状态,只有在明细单大于主单状态时才更改主单状态 + // 有任何子单没有完成则主单不修改为100 + // 有到100的子单时,主单的状态一定是100的前一个状态,所以状态不变 + if (count100 == 0) { + // 所有子单状态比较主单状态,只有在明细单大于主单状态时才更改主单状态 int headerStatus = cyclecountHeader.getStatusCyc(); - long count = list.stream().filter(t->t.getEnableStatus() > headerStatus).count(); - if(count > 0 ){ - //stream流取出明细状态中最大的值,赋给主单状态 - List<CycleCountDetail> cycleCountDetailList = list.stream().sorted( - Comparator.comparing(CycleCountDetail::getEnableStatus).reversed()).collect(Collectors.toList()); + long count = list.stream().filter(t -> t.getEnableStatus() > headerStatus).count(); + if (count > 0) { + // stream流取出明细状态中最大的值,赋给主单状态 + List<CycleCountDetail> cycleCountDetailList = + list.stream().sorted(Comparator.comparing(CycleCountDetail::getEnableStatus).reversed()).collect(Collectors.toList()); cyclecountHeader.setStatusCyc(cycleCountDetailList.get(0).getEnableStatus()); this.updateById(cyclecountHeader); } } - } - @Transactional public String createCode(String receiptType) { String code = null; diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java index 4104ea2..877e257 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java @@ -1767,6 +1767,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea * 盘点完成,传入任务主单,查出任务明细,通过任务明细查找盘点的明细单, * 完成任务同时,修改盘点细单和主单的状态,完成后库存锁复位 */ + log.info("开始完成盘点任务"); String warehouseCode = taskHeader.getWarehouseCode(); String containerCode = taskHeader.getContainerCode(); String fromLocationCode = taskHeader.getFromLocationCode(); @@ -1778,44 +1779,52 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea if (StringUtils.isEmpty(toLocationCode)) { return Result.error("完成盘点任务时,目标库位号为空"); } -// LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal(); + if (StringUtils.isEmpty(containerCode)) { + return Result.error("完成盘点任务时,托盘号为空"); + } + if (StringUtils.isEmpty(warehouseCode)) { + return Result.error("完成盘点任务时,仓库编码为空"); + } taskHeader.setStatus(QuantityConstant.TASK_STATUS_COMPLETED); // 1.先拿到盘点单主单据 CycleCountDetail cycleCountDetail = cycleCountDetailService.getById(taskHeader.getShipmentContainerHeaderId()); - - if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) { - return Result.error("盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); + if (cycleCountDetail == null) { + return Result.error("完成盘点任务时,盘点单详情为空" + taskHeader.getShipmentContainerHeaderId()); } +// if (cycleCountDetail.getGapQty().compareTo(BigDecimal.ZERO) == 0) { +// return Result.error("完成盘点任务时,盘点单据系统实盘数量跟差异数量0,不能完成 单据号" + cycleCountDetail.getCycleCountHeadCode()); +// } // 2.盘点单主单据查明细单据list LambdaQueryWrapper<CycleCountDetailChild> childLambdaQueryWrapper = new LambdaQueryWrapper<CycleCountDetailChild>(); childLambdaQueryWrapper.eq(CycleCountDetailChild::getCycleCountDetailid, cycleCountDetail.getId()); List<CycleCountDetailChild> children = cycleCountDetailChildService.list(childLambdaQueryWrapper); - + if (children.size() == 0) { + return Result.error("完成盘点任务时,盘点单详情明细为空" + cycleCountDetail.getId()); + } // 3.单据list如果差异数量+生成入库单,差异数-生成出库单进行回传类型其他出库单 - InventoryHeader inventoryHeader = inventoryHeaderService.getById(cycleCountDetail.getInventoryHeaderId()); - + if (inventoryHeader == null) { + return Result.error("完成盘点任务时,没有找到库存头" + cycleCountDetail.getInventoryHeaderId()); + } int outboundOrderId = 0; String outboundOrderCode = null; int warehousingOrderId = 0; String warehousingOrderCode = null; - for (CycleCountDetailChild child : children) { if (!child.getChildStatus().equals(QuantityConstant.CYCLECOUNT_STATUS_REGISTERED)) { throw new JeecgBootException("当前任务里面还有没有进行登记的数据,不能完成任务"); } - if (child.getInventoryDetaiId() != null) { InventoryDetail inventoryDetail = inventoryDetailService.getById(child.getInventoryDetaiId()); if (inventoryDetail == null) { throw new JeecgBootException("盘点还没完成 库存明细单据就不存在了 可能出现了问题或者所容器没成功"); } - inventoryHeader.setLocationCode(toLocationCode); - inventoryHeader.setTotalQty(inventoryHeader.getTotalQty().add(child.getGapQty())); - inventoryDetail.setQty(child.getCountedQty()); - inventoryDetailService.updateById(inventoryDetail); + success = inventoryDetailService.updateQtyAndTaskQtyAndLocationCode(child.getCountedQty(), BigDecimal.ZERO, toLocationCode, inventoryDetail.getId()); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新库存详情失败"); + } } else { InventoryDetail inventoryDetail = new InventoryDetail(); inventoryDetail.setInventoryHeaderId(inventoryHeader.getId()); @@ -1832,7 +1841,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea inventoryDetail.setTaskQty(BigDecimal.ZERO); inventoryDetail.setInventoryStatus(child.getInventoryStatus()); inventoryDetail.setBatch(child.getBatch()); - inventoryDetailService.save(inventoryDetail); + success = inventoryDetailService.save(inventoryDetail); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 保存库存详情失败"); + } child.setInventoryDetaiId(inventoryDetail.getId()); } @@ -1845,12 +1857,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptHeader.setType(QuantityConstant.RECEIPT_BILL_TYPE_QTR); receiptHeader.setRemark("盘盈 单号" + cycleCountDetail.getCycleCountHeadCode()); Result result = receiptHeaderService.saveReceiptHeader(receiptHeader); - if (result.getCode() != 200) { + if (!result.isSuccess()) { return result; } receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); receiptHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); - receiptHeaderService.updateById(receiptHeader); + success = receiptHeaderService.updateById(receiptHeader); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新入库表单头失败"); + } // 生成入库单并且赋值给warehousingOrderId warehousingOrderId = receiptHeader.getId(); warehousingOrderCode = receiptHeader.getCode(); @@ -1872,8 +1887,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea receiptDetail.setBatch(child.getBatch()); receiptDetail.setLot(child.getLot()); receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); - receiptDetailService.save(receiptDetail); - + success = receiptDetailService.save(receiptDetail); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 新增入库表单详情失败"); + } // 增加库存交易记录 InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); @@ -1891,14 +1908,19 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea inventoryTransaction.setQty(child.getCountedQty()); inventoryTransaction.setBatch(child.getBatch()); inventoryTransaction.setLot(child.getLot()); - inventoryTransactionService.save(inventoryTransaction); - + success = inventoryTransactionService.save(inventoryTransaction); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 新增库存交易详情失败"); + } } if (child.getGapQty().compareTo(BigDecimal.ZERO) == -1) { if (child.getGapQty().abs().compareTo(child.getSystemQty()) > -1) { - inventoryDetailService.removeById(child.getInventoryDetaiId()); + success = inventoryDetailService.removeById(child.getInventoryDetaiId()); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 删除库存详情失败"); + } } if (outboundOrderId == 0) { @@ -1908,12 +1930,15 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea shipmentHeader.setType(QuantityConstant.SHIPMENT_BILL_TYPE_QTC); shipmentHeader.setRemark("盘亏 单号" + cycleCountDetail.getCycleCountHeadCode()); Result result = shipmentHeaderService.saveShipmentHeader(shipmentHeader); - if (result.getCode() != 200) { + if (!result.isSuccess()) { return result; } shipmentHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); shipmentHeader.setLastStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); - shipmentHeaderService.updateById(shipmentHeader); + success = shipmentHeaderService.updateById(shipmentHeader); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新出库单详情失败"); + } // 生成出库单并且赋值给outboundOrderId outboundOrderId = shipmentHeader.getId(); outboundOrderCode = shipmentHeader.getCode(); @@ -1935,8 +1960,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea shipmentDetail.setBatch(child.getBatch()); shipmentDetail.setLot(child.getLot()); shipmentDetail.setStatus(QuantityConstant.RECEIPT_HEADER_COMPLETED); - shipmentDetailService.save(shipmentDetail); - + success = shipmentDetailService.save(shipmentDetail); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 保存出库单详情失败"); + } InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.setWarehouseCode(taskHeader.getWarehouseCode()); inventoryTransaction.setCompanyCode(taskHeader.getCompanyCode()); @@ -1953,51 +1980,49 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea inventoryTransaction.setQty(child.getCountedQty()); inventoryTransaction.setBatch(child.getBatch()); inventoryTransaction.setLot(child.getLot()); - inventoryTransactionService.save(inventoryTransaction); + success = inventoryTransactionService.save(inventoryTransaction); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 保存出库单详情失败"); + } + } + success = cycleCountDetailChildService.updateById(child); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新盘点详情失败"); } - cycleCountDetailChildService.updateById(child); } if (inventoryHeader.getTotalQty().compareTo(BigDecimal.ZERO) < 1) { - inventoryHeaderService.removeById(inventoryHeader); + success = inventoryHeaderService.removeById(inventoryHeader); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 删除库存头失败"); + } + } else { + success = inventoryHeaderService.updateLocationCodeById(toLocationCode, cycleCountDetail.getInventoryHeaderId()); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新库存头失败"); + } } - inventoryHeaderService.updateById(inventoryHeader); - - // 4.完成当前任务 - if (!taskHeaderService.saveOrUpdate(taskHeader)) { - throw new JeecgBootException("盘点任务单据状态更新失败!"); - } // 盘点明细状态 cycleCountDetail.setEnableStatus(QuantityConstant.CYCLECOUNT_STATUS_COMPLETED); cycleCountDetail.setCompletedAt(new Date()); - cycleCountDetailService.updateById(cycleCountDetail); + success = cycleCountDetailService.updateById(cycleCountDetail); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新盘点单详情失败"); + } // 更新主单状态 cycleCountHeaderService.updataHeaderStatus(cycleCountDetail.getCycleCountHeadCode()); - // 释放库位 - locationService.updateContainerCodeAndStatus(fromLocationCode, QuantityConstant.EMPTY_STRING, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - - locationService.updateContainerCodeAndStatus(toLocationCode, containerCode, QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); - -// // 还原容器状态 -// containerService.restoreContainer(cycleCountDetail.getContainerCode(), taskHeader.getWarehouseCode()); - List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode); - if (inventoryDetailList.size() != 0) { - if (fromLocationCode.equals(toLocationCode)) { - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } else { - success = containerService.updateLocationCodeAndStatus(containerCode, toLocationCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - } - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); - } - } else { - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode); - if (!success) { - throw new JeecgBootException("完成出库查看任务时,更新容器状态失败"); - } + Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), QuantityConstant.TASK_TYPE_CHECK_OUT, + containerCode, fromLocationCode, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); + } + success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); + if (!success) { + throw new JeecgBootException("完成盘点任务时, 更新任务失败"); } + log.info("完成盘点任务"); return Result.OK("完成盘点任务成功"); } @@ -2045,10 +2070,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea throw new JeecgBootException(result.getMessage()); } boolean success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); - log.info("完成空托盘出库任务" + taskHeader.getId()); if (!success) { throw new JeecgBootException("完成空托盘出库任务时, 更新任务失败"); } + log.info("完成空托盘出库任务" + taskHeader.getId()); return Result.OK("完成空托盘出库成功"); } -- libgit2 0.22.2