diff --git a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue index 95b9be3..3593506 100644 --- a/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue +++ b/ant-design-vue-jeecg/src/views/system/task/CircleTaskHeaderList.vue @@ -142,11 +142,11 @@ <span slot="action" slot-scope="text, record"> <a v-if="record.status == 1" v-has="'taskHeader:executeTask'" @click="executeTask(record)">执行<a-divider type="vertical"/></a> - <a v-if="record.isEmptyOut == 1 && record.exceptionState == 1" v-has="'taskHeader:executeTask'" @click="handleEmptyOutTask(record)">修复空出数据 + <a v-if="record.isEmptyOut == 1 && record.exceptionState == 1" v-has="'taskHeader:handleEmptyOutTask'" @click="handleEmptyOutTask(record)">修复空出数据 <a-divider type="vertical"/></a> - <a v-if="record.isPickupError == 1 && record.exceptionState == 1" v-has="'taskHeader:executeTask'" @click="handlePickupErrorTask(record)">修复取货错数据 + <a v-if="record.isPickupError == 1 && record.exceptionState == 1" v-has="'taskHeader:handlePickupErrorTask'" @click="handlePickupErrorTask(record)">修复取货错数据 <a-divider type="vertical"/></a> - <a v-if="record.isDoubleIn == 1 && record.exceptionState == 1" v-has="'taskHeader:executeTask'" @click="handleDoubleInTask(record)">修复重入数据 + <a v-if="record.isDoubleIn == 1 && record.exceptionState == 1" v-has="'taskHeader:handleDoubleInTask'" @click="handleDoubleInTask(record)">修复重入数据 <a-divider type="vertical"/></a> <a v-if="record.status <= 10" v-has="'taskHeader:cancelTask'" @click="cancelTask(record)">取消</a> </span> diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java index 22d4115..bc16604 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import javax.annotation.Resource; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.wms.api.erp.entity.*; import org.jeecg.modules.wms.api.erp.service.IErpService; import org.jeecg.modules.wms.config.address.service.IAddressService; @@ -38,7 +39,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson.JSON; -import org.jeecg.common.exception.JeecgBootException; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -399,6 +399,7 @@ public class ErpServiceImpl implements IErpService { } @Override + @Transactional(rollbackFor = Exception.class) public Result backReceipt(ReceiptHeader receiptHeader) { if (receiptHeader == null) { return Result.error("回传入库单, 入库单为空!!"); @@ -436,6 +437,7 @@ public class ErpServiceImpl implements IErpService { } @Override + @Transactional(rollbackFor = Exception.class) public Result backShipment(ShipmentHeader shipmentHeader) { if (shipmentHeader == null) { return Result.error("回传出库单, 出库单为空!!"); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/IMobileService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/IMobileService.java index 15cb482..6553900 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/IMobileService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/IMobileService.java @@ -8,5 +8,6 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; public interface IMobileService { Result<TaskHeader> callBox(CallBoxBean bean, String warehouseCode); + Result<TaskHeader> quickReceipt(QuickReceiptBean bean, String warehouseCode); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/impl/MobileService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/impl/MobileService.java index bbda1c9..f596674 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/impl/MobileService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/service/impl/MobileService.java @@ -1,16 +1,20 @@ package org.jeecg.modules.wms.api.mobile.service.impl; +import java.util.ArrayList; +import java.util.List; + import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.modules.wms.api.mobile.entity.CallBoxBean; import org.jeecg.modules.wms.api.mobile.entity.QuickReceiptBean; import org.jeecg.modules.wms.api.mobile.service.IMobileService; import org.jeecg.modules.wms.config.container.entity.Container; import org.jeecg.modules.wms.config.container.service.IContainerService; -import org.jeecg.modules.wms.config.location.entity.Location; import org.jeecg.modules.wms.config.location.service.ILocationService; +import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService; import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptDetailService; @@ -24,11 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.jeecg.common.exception.JeecgBootException; - -import java.util.ArrayList; -import java.util.List; - /** */ @Service @@ -51,56 +50,47 @@ public class MobileService implements IMobileService { @Resource private IReceiveService receiveService; + @Resource + private IParameterConfigurationService parameterConfigurationService; @Override @Transactional(rollbackFor = Exception.class) public Result<TaskHeader> callBox(CallBoxBean bean, String warehouseCode) { + String containerCode = bean.getContainerCode(); if (StringUtils.isEmpty(bean.getContainerCode())) { - return Result.error("托盘号containerCode不能为空"); + return Result.error("呼叫料盒,托盘号containerCode不能为空"); } if (StringUtils.isEmpty(bean.getLocationCode())) { - return Result.error("库位locationCode不能为空"); + return Result.error("呼叫料盒, 库位locationCode不能为空"); } if (StringUtils.isEmpty(bean.getCompanyCode())) { - return Result.error("货主companyCode不能为空"); + return Result.error("呼叫料盒, 货主companyCode不能为空"); } - if(StringUtils.isEmpty(bean.getPort())){ - return Result.error("出库口不能为空"); + if (StringUtils.isEmpty(bean.getPort())) { + return Result.error("呼叫料盒, 出库口不能为空"); } - - Container container = containerService.getContainerByCode(bean.getContainerCode(), warehouseCode); + Container container = containerService.getContainerByCode(containerCode, warehouseCode); if (container == null) { - return Result.error(bean.getContainerCode() + " " + warehouseCode + "容器不存在"); + return Result.error("呼叫料盒,容器为空"); } - - if (StringUtils.isEmpty(container.getLocationCode())) { - return Result.error(bean.getContainerCode() + "容器不在库位上"); + String fromLocationCode = container.getLocationCode(); + String toLocationCode = QuantityConstant.EMPTY_STRING; + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_TASK_LOCATION); + int taskLocationRule = Integer.parseInt(value); + if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) { + toLocationCode = fromLocationCode; } - - if (!container.getLocationCode().equals(bean.getLocationCode())) { - return Result.error(bean.getContainerCode() + "容器不在库位[" + bean.getLocationCode() + "]上"); - } - - Location loc = locationService.getLocationByCode(bean.getLocationCode(), warehouseCode); - // 校验目标地址 - if (loc == null) { - return Result.error("目标库位不存在"); - } - if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(loc.getStatus())) { - return Result.error("目标库位非空闲"); - } - // 判断托盘是否已经存在任务 - TaskHeader taskHeader = taskHeaderService.getUnCompleteTaskByContainerCode(bean.getContainerCode(), warehouseCode); - if (taskHeader != null) { - return Result.error("容器已存在任务"); + Result result = taskHeaderService.createTaskLockContainerAndLocation(bean.getType(), containerCode, fromLocationCode, toLocationCode, warehouseCode); + if (!result.isSuccess()) { + throw new JeecgBootException(result.getMessage()); } // 创建主任务 - taskHeader = new TaskHeader(); - taskHeader.setWarehouseCode(loc.getWarehouseCode()); + TaskHeader taskHeader = new TaskHeader(); + taskHeader.setWarehouseCode(warehouseCode); taskHeader.setCompanyCode(bean.getCompanyCode()); taskHeader.setToPortCode(bean.getPort()); if (bean.getType() == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) { @@ -112,14 +102,12 @@ public class MobileService implements IMobileService { taskHeader.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_SHIPMENT); taskHeader.setTaskType(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT); } - taskHeader.setContainerCode(container.getCode()); + taskHeader.setContainerCode(containerCode); taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); - taskHeader.setFromLocationCode(loc.getCode()); - if (taskHeaderService.save(taskHeader)) { - // 锁定库位状态 - locationService.updateStatus(loc.getCode(), QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); - } else { - throw new JeecgBootException("补充入库主表生成失败!"); + taskHeader.setFromLocationCode(fromLocationCode); + taskHeader.setToLocationCode(toLocationCode); + if (!taskHeaderService.save(taskHeader)) { + throw new JeecgBootException("呼叫料盒, 保存任务失败"); } return Result.OK("呼叫料盒成功", taskHeader); @@ -141,7 +129,7 @@ public class MobileService implements IMobileService { return Result.error("收货明细不能为空"); } - //创建入库单 + // 创建入库单 ReceiptHeader receiptHeader = new ReceiptHeader(); receiptHeader.setType(bean.getReceiptType()); receiptHeader.setCompanyCode(bean.getCompanyCode()); @@ -153,32 +141,32 @@ public class MobileService implements IMobileService { } else { throw new JeecgBootException(rs1.getMessage()); } - + List<ReceiptDetail> receiptDetailList = bean.getReceiptDetails(); List<Receive> receiveList = new ArrayList<>(); - for (ReceiptDetail d : bean.getReceiptDetails()) { - d.setReceiptId(receiptHeader.getId()); - Result rs2 = receiptDetailService.saveReceiptDetail(d); - if(!rs2.isSuccess()) { + for (ReceiptDetail receiptDetail : receiptDetailList) { + receiptDetail.setReceiptId(receiptHeader.getId()); + Result rs2 = receiptDetailService.saveReceiptDetail(receiptDetail); + if (!rs2.isSuccess()) { throw new JeecgBootException(rs2.getMessage()); } - Receive v = new Receive(); - v.setId(d.getId()); - v.setQty(d.getQty()); - v.setTaskQty(d.getQty()); - v.setInventoryStatus(d.getInventoryStatus()); - v.setMaterialCode(d.getMaterialCode()); - v.setMaterialName(d.getMaterialName()); - v.setBatch(d.getBatch()); - v.setMaterialSpec(d.getMaterialSpec()); - v.setMaterialUnit(d.getMaterialUnit()); - v.setContainerCode(bean.getContainerCode()); - receiveList.add(v); + Receive receive = new Receive(); + receive.setId(receiptDetail.getId()); + receive.setQty(receiptDetail.getQty()); + receive.setTaskQty(receiptDetail.getQty()); + receive.setInventoryStatus(receiptDetail.getInventoryStatus()); + receive.setMaterialCode(receiptDetail.getMaterialCode()); + receive.setMaterialName(receiptDetail.getMaterialName()); + receive.setBatch(receiptDetail.getBatch()); + receive.setMaterialSpec(receiptDetail.getMaterialSpec()); + receive.setMaterialUnit(receiptDetail.getMaterialUnit()); + receive.setContainerCode(bean.getContainerCode()); + receiveList.add(receive); } Result<TaskHeader> rs3 = receiveService.receivingAndCreateTask(receiveList, warehouseCode); - if(rs3.isSuccess()) { + if (rs3.isSuccess()) { return rs3; - }else{ + } else { throw new JeecgBootException(rs3.getMessage()); } } 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..7d32058 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; @@ -97,7 +96,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService roadWays = locationList.stream().map(Location::getRoadWay).distinct().collect(toList()); } String value = parameterConfigurationService.getValueByCode(QuantityConstant.DOUBLE_FORK_RESERVE_LOCATION); - int reserveNumber = 10; + int reserveNumber = 4; if (StringUtils.isNotEmpty(value)) { reserveNumber = Integer.parseInt(value); } @@ -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/framework/service/IHuahengMultiHandlerService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/IHuahengMultiHandlerService.java index 07fd580..0ff4ef3 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/IHuahengMultiHandlerService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/IHuahengMultiHandlerService.java @@ -1,10 +1,14 @@ package org.jeecg.modules.wms.framework.service; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.wms.api.mobile.entity.CallBoxBean; +import org.jeecg.modules.wms.api.mobile.entity.QuickReceiptBean; import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerHeader; +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.shipment.shipmentCombination.entity.CombinationModel; import org.jeecg.modules.wms.shipment.shipmentContainerHeader.entity.ShipmentContainerHeader; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.CombinationParam; +import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; /** @@ -25,4 +29,12 @@ public interface IHuahengMultiHandlerService { Result autoCombination(String shipmentCode, String warehouseCode); Result createShipmentTask(ShipmentContainerHeader shipmentContainerHeader, String warehouseCode, long shipmentOrder, int sequence, int sequenceNumber); + + Result callBox(CallBoxBean bean, String warehouseCode); + + Result quickReceipt(QuickReceiptBean bean, String warehouseCode); + + Result backReceipt(ReceiptHeader receiptHeader); + + Result backShipment(ShipmentHeader shipmentHeader); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/impl/HuahengMultiHandlerServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/impl/HuahengMultiHandlerServiceImpl.java index 6b751dc..1f54a49 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/impl/HuahengMultiHandlerServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/service/impl/HuahengMultiHandlerServiceImpl.java @@ -5,18 +5,24 @@ import java.math.BigDecimal; import javax.annotation.Resource; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.wms.api.erp.service.IErpService; +import org.jeecg.modules.wms.api.mobile.entity.CallBoxBean; +import org.jeecg.modules.wms.api.mobile.entity.QuickReceiptBean; +import org.jeecg.modules.wms.api.mobile.service.IMobileService; import org.jeecg.modules.wms.framework.controller.HuahengBaseController; import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerHeader; import org.jeecg.modules.wms.receipt.receiptContainerHeader.service.IReceiptContainerHeaderService; +import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.shipment.shipmentCombination.entity.CombinationModel; import org.jeecg.modules.wms.shipment.shipmentCombination.service.IShipmentCombinationService; import org.jeecg.modules.wms.shipment.shipmentContainerHeader.entity.ShipmentContainerHeader; import org.jeecg.modules.wms.shipment.shipmentContainerHeader.service.IShipmentContainerHeaderService; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.CombinationParam; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail; +import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentDetailService; import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; @@ -41,6 +47,10 @@ public class HuahengMultiHandlerServiceImpl extends HuahengBaseController implem private IInventoryDetailService inventoryDetailService; @Resource private IShipmentContainerHeaderService shipmentContainerHeaderService; + @Resource + private IMobileService mobileService; + @Resource + private IErpService erpService; @Override @Transactional(rollbackFor = Exception.class) @@ -119,6 +129,7 @@ public class HuahengMultiHandlerServiceImpl extends HuahengBaseController implem } @Override + @Transactional(rollbackFor = Exception.class) public Result autoCombination(String shipmentCode, String warehouseCode) { Result result = handleMultiProcess("combination", new MultiProcessListener() { @Override @@ -131,6 +142,7 @@ public class HuahengMultiHandlerServiceImpl extends HuahengBaseController implem } @Override + @Transactional(rollbackFor = Exception.class) public Result createShipmentTask(ShipmentContainerHeader shipmentContainerHeader, String warehouseCode, long shipmentOrder, int sequence, int sequenceNumber) { Result result = handleMultiProcess("createShipmentTask", new MultiProcessListener() { @Override @@ -142,4 +154,58 @@ public class HuahengMultiHandlerServiceImpl extends HuahengBaseController implem return result; } + @Override + @Transactional(rollbackFor = Exception.class) + public Result callBox(CallBoxBean bean, String warehouseCode) { + String lockKey = warehouseCode; + Result result = handleMultiProcess("callBox", lockKey, new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = mobileService.callBox(bean, warehouseCode); + return result; + } + }); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result quickReceipt(QuickReceiptBean bean, String warehouseCode) { + String lockKey = warehouseCode; + Result result = handleMultiProcess("quickReceipt", lockKey, new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = mobileService.quickReceipt(bean, warehouseCode); + return result; + } + }); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result backReceipt(ReceiptHeader receiptHeader) { + Result result = handleMultiProcess("backReceipt", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = erpService.backReceipt(receiptHeader); + return result; + } + }); + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result backShipment(ShipmentHeader shipmentHeader) { + Result result = handleMultiProcess("backShipment", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = erpService.backShipment(shipmentHeader); + return result; + } + }); + return result; + } + } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/ErpTask.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/ErpTask.java index 7d2d0be..76c5dd7 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/ErpTask.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/monitor/job/ErpTask.java @@ -1,23 +1,17 @@ package org.jeecg.modules.wms.monitor.job; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.annotation.Resource; -import org.apache.commons.collections.MapUtils; import org.jeecg.modules.wms.api.erp.service.IErpService; +import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptHeaderService; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader; import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentHeaderService; import org.jeecg.utils.constant.QuantityConstant; -import org.quartz.DisallowConcurrentExecution; -import org.quartz.Job; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; -import org.quartz.PersistJobDataAfterExecution; +import org.quartz.*; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -42,6 +36,8 @@ public class ErpTask implements Job { @Resource private IErpService erpService; + @Resource + private IHuahengMultiHandlerService huahengMultiHandlerService; @Override public void execute(JobExecutionContext context) throws JobExecutionException { @@ -51,7 +47,7 @@ public class ErpTask implements Job { List<ReceiptHeader> receiptHeaderList = receiptHeaderService.list(receiptHeaderLambdaQueryWrapper); for (ReceiptHeader receiptHeader : receiptHeaderList) { try { - erpService.backReceipt(receiptHeader); + huahengMultiHandlerService.backReceipt(receiptHeader); } catch (Exception e) { e.printStackTrace(); } @@ -63,7 +59,7 @@ public class ErpTask implements Job { List<ShipmentHeader> shipmentHeaderList = shipmentHeaderService.list(shipmentHeaderLambdaQueryWrapper); for (ShipmentHeader shipmentHeader : shipmentHeaderList) { try { - erpService.backShipment(shipmentHeader); + huahengMultiHandlerService.backShipment(shipmentHeader); } catch (Exception e) { e.printStackTrace(); } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java index a33eaf6..daa262b 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java @@ -137,7 +137,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai // 锁定容器和库位 Result result = taskHeaderService.createTaskLockContainerAndLocation(taskType, containerCode, fromLocationCode, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java index fc1e712..2bea9b2 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptHeader/controller/ReceiptHeaderController.java @@ -24,6 +24,7 @@ import org.jeecg.modules.wms.api.mobile.entity.CallBoxBean; import org.jeecg.modules.wms.api.mobile.entity.QuickReceiptBean; import org.jeecg.modules.wms.api.mobile.service.IMobileService; import org.jeecg.modules.wms.config.material.service.IMaterialService; +import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptDetail; import org.jeecg.modules.wms.receipt.receiptHeader.entity.ReceiptHeader; import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptDetailService; @@ -80,6 +81,8 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec private IMaterialService materialService; @Resource private IErpService erpService; + @Resource + private IHuahengMultiHandlerService huahengMultiHandlerService; /*---------------------------------主表处理-begin-------------------------------------*/ @@ -357,7 +360,7 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec @RequiresPermissions("receiptHeader:back") @RequestMapping(value = "/backErpReceipt", method = {RequestMethod.PUT, RequestMethod.POST}) public Result<?> backErpReceipt(@RequestBody ReceiptHeader receiptHeader) { - return erpService.backReceipt(receiptHeader); + return huahengMultiHandlerService.backReceipt(receiptHeader); } @AutoLog(value = "PDA入库-快速入库") @@ -368,9 +371,8 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec public Result<?> quickReceipt(@RequestBody QuickReceiptBean bean, HttpServletRequest req) { String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); bean.setWarehouseCode(warehouseCode); - - return mobileService.quickReceipt(bean, warehouseCode); - + Result result = huahengMultiHandlerService.quickReceipt(bean, warehouseCode); + return result; } @AutoLog(value = "PDA入库-呼叫料盒") @@ -382,6 +384,7 @@ public class ReceiptHeaderController extends JeecgController<ReceiptHeader, IRec String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); // 补充入库类型 bean.setType(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT); - return mobileService.callBox(bean, warehouseCode); + Result result = huahengMultiHandlerService.callBox(bean, warehouseCode); + return result; } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java index 72df89c..5c58ef0 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java @@ -512,7 +512,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi // 锁定容器、库位 Result result = taskHeaderService.createTaskLockContainerAndLocation(taskType, containerCode, fromLocationCode, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java index 22ac8b3..80c2a94 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentHeader/controller/ShipmentHeaderController.java @@ -24,6 +24,7 @@ import org.jeecg.common.util.oConvertUtils; import org.jeecg.modules.wms.api.erp.service.IErpService; import org.jeecg.modules.wms.api.mobile.entity.CallBoxBean; import org.jeecg.modules.wms.api.mobile.service.IMobileService; +import org.jeecg.modules.wms.framework.service.IHuahengMultiHandlerService; import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail; @@ -40,16 +41,7 @@ import org.jeecgframework.poi.excel.entity.ExportParams; import org.jeecgframework.poi.excel.entity.ImportParams; import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; @@ -89,6 +81,8 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS private IErpService erpService; @Resource private IInventoryDetailService inventoryDetailService; + @Resource + private IHuahengMultiHandlerService huahengMultiHandlerService; /*---------------------------------主表处理-begin-------------------------------------*/ @@ -378,7 +372,7 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS @RequiresPermissions("shipmentHeader:back") @RequestMapping(value = "/backErpShipment", method = {RequestMethod.PUT, RequestMethod.POST}) public Result<?> backErpShipment(@RequestBody ShipmentHeader shipmentHeader) { - return erpService.backShipment(shipmentHeader); + return huahengMultiHandlerService.backShipment(shipmentHeader); } @AutoLog(value = "PDA出库-呼叫料盒") @@ -390,6 +384,7 @@ public class ShipmentHeaderController extends JeecgController<ShipmentHeader, IS String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); // 补充入库类型 bean.setType(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT); - return mobileService.callBox(bean, warehouseCode); + Result result = huahengMultiHandlerService.callBox(bean, warehouseCode); + return result; } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java index 58db1cb..7f2045f 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java @@ -227,7 +227,7 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_CYCLECOUNT, containerCode, fromLocationCode, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); 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/controller/TaskHeaderController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java index 6d2a2ad..56bb2ba 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/controller/TaskHeaderController.java @@ -598,7 +598,7 @@ public class TaskHeaderController extends HuahengBaseController { } String fromLocationCode = container.getLocationCode(); if (StringUtils.isEmpty(fromLocationCode)) { - return Result.error("选择整出口, 起始库位号为空"); + return Result.error("选择分拣口, 起始库位号为空"); } Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); if (fromLocation == null) { @@ -656,7 +656,13 @@ public class TaskHeaderController extends HuahengBaseController { @ResponseBody @ApiLogger(apiName = "修复空出的数据", from = "WMS") public Result handleEmptyOut(@RequestParam(name = "id", required = true) String id) { - Result result = taskHeaderService.handleEmptyOut(id); + Result result = handleMultiProcess("handleEmptyOut", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = taskHeaderService.handleEmptyOut(id); + return result; + } + }); return result; } @@ -670,7 +676,13 @@ public class TaskHeaderController extends HuahengBaseController { @ResponseBody @ApiLogger(apiName = "修复重入的数据", from = "WMS") public Result handleDoubleIn(@RequestParam(name = "id", required = true) String id) { - Result result = taskHeaderService.handleDoubleIn(id); + Result result = handleMultiProcess("handleDoubleIn", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = taskHeaderService.handleDoubleIn(id); + return result; + } + }); return result; } @@ -684,7 +696,13 @@ public class TaskHeaderController extends HuahengBaseController { @ResponseBody @ApiLogger(apiName = "修复取货错的数据", from = "WMS") public Result handlePickupError(@RequestParam(name = "id", required = true) String id) { - Result result = taskHeaderService.handlePickupError(id); + Result result = handleMultiProcess("handlePickupError", new MultiProcessListener() { + @Override + public Result<?> doProcess() { + Result result = taskHeaderService.handlePickupError(id); + return result; + } + }); return result; } 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..e9efdb0 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 @@ -257,7 +257,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_TRANSFER, containerCode, fromLocationCode, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); @@ -308,7 +308,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_CHECK_OUT, containerCode, fromLocationCode, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); @@ -380,7 +380,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_OVER_STATION, containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskHeader taskHeader = new TaskHeader(); taskHeader.setWarehouseCode(warehouseCode); @@ -476,7 +476,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT, containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); @@ -512,7 +512,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT, containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); @@ -912,7 +912,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_EMPTYRECEIPT, containerCode, QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskHeader taskHeader = new TaskHeader(); taskHeader.setWarehouseCode(warehouseCode); @@ -954,7 +954,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_EMPTYSHIPMENT, containerCode, QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode); if (!result.isSuccess()) { - return result; + throw new JeecgBootException(result.getMessage()); } TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); String zoneCode = taskLockEntity.getZoneCode(); @@ -1011,7 +1011,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea return Result.ok("入库任务(" + taskHeader.getId() + ")已经是完成的!"); } if (taskDetailList.isEmpty()) { - throw new JeecgBootException("入库任务明细为空"); + throw new JeecgBootException("完成入库任务时, 入库任务明细为空"); } Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); if (toLocation == null) { @@ -1442,6 +1442,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea case QuantityConstant.TASK_TYPE_OVER_STATION: result = taskHeaderService.createOverStationTaskLockContainer(containerCode, warehouseCode); break; + default: + throw new JeecgBootException("创建任务时,没有匹配到这种任务类型" + taskType); } return result; } @@ -1767,6 +1769,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea * 盘点完成,传入任务主单,查出任务明细,通过任务明细查找盘点的明细单, * 完成任务同时,修改盘点细单和主单的状态,完成后库存锁复位 */ + log.info("开始完成盘点任务"); String warehouseCode = taskHeader.getWarehouseCode(); String containerCode = taskHeader.getContainerCode(); String fromLocationCode = taskHeader.getFromLocationCode(); @@ -1778,44 +1781,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 +1843,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 +1859,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 +1889,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 +1910,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 +1932,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 +1962,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 +1982,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 +2072,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("完成空托盘出库成功"); }