From bbd1a0f5608cd95998b25dc33f8a6f0418ca81d4 Mon Sep 17 00:00:00 2001 From: judy <278197488@qq.com> Date: Thu, 18 Jul 2024 15:32:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8=E8=B4=A7?= =?UTF-8?q?=E4=BD=8D=E5=8F=8A=E8=B4=A7=E4=BD=8D=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseLocationController.java | 2 +- .../impl/BusinDataTaskServiceImpl.java | 270 ++++++++++-------- .../mapper/wms/BaseLocationMapper.xml | 1 + 3 files changed, 146 insertions(+), 127 deletions(-) diff --git a/shkj-wms/src/main/java/com/shkj/wms/controller/base/BaseLocationController.java b/shkj-wms/src/main/java/com/shkj/wms/controller/base/BaseLocationController.java index 10f1ec8..6c9c5b7 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/controller/base/BaseLocationController.java +++ b/shkj-wms/src/main/java/com/shkj/wms/controller/base/BaseLocationController.java @@ -89,7 +89,7 @@ public class BaseLocationController extends BaseController { * 禁用启用货位 */ @PostMapping("/enableDisableLocation") - public Result enableDisableLocation(@Valid @RequestBody BaseLocationRemoveBo bo) { + public Result enableDisableLocation(@RequestBody BaseLocationRemoveBo bo) { return iBaseLocationService.deleteWithValidById(bo.getIds(), bo.getStatus()); } diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java index 9d75ecf..d565745 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java @@ -30,13 +30,16 @@ import com.shkj.wms.third.rcs.enums.RCSTaskTypeEnum; import com.shkj.wms.utils.JsonUtil; import com.shkj.wms.utils.TunnelTaskUtil; import com.shkj.wms.vo.*; +import io.lettuce.core.api.async.RedisTransactionalAsyncCommands; import lombok.extern.slf4j.Slf4j; +import net.bytebuddy.asm.Advice; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.math3.linear.ConjugateGradient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; import javax.validation.Valid; @@ -1919,150 +1922,165 @@ public class BusinDataTaskServiceImpl extends ServiceImpl sysStockDetailVos = iSysStockDetailService.queryList(stockDetailQueryBo); - if (sysStockDetailVos == null && sysStockDetailVos.size() == 0) { - return Result.err().msg("移出货位无保险杠库存"); - } + try { + // 查询移出货位是否有库存 + Long outLocationId = bo.getOutLocationId(); + SysStockDetailQueryBo stockDetailQueryBo = new SysStockDetailQueryBo(); + stockDetailQueryBo.setLocationId(outLocationId); + List sysStockDetailVos = iSysStockDetailService.queryList(stockDetailQueryBo); + if (sysStockDetailVos == null && sysStockDetailVos.size() == 0) { + return Result.err().msg("移出货位无保险杠库存"); + } - BaseLocation outBaseLocation = iBaseLocationService.getById(outLocationId); - //查看是否时双深位,如果是则判断单深位是否有库存 - Result booleanResult = checkIsSleep(outBaseLocation); - if (!Result.isOk(booleanResult)) { - return booleanResult; - } - // 查询移出货位是否有未完成的任务 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper() - .notIn(BusinDataTask::getTaskStatus, Arrays.asList("2", "3")) - .in(BusinDataTask::getTaskType, Arrays.asList("9", "16")) - .eq(BusinDataTask::getFromLayer, outBaseLocation.getLayer()) - .eq(BusinDataTask::getFromColumn, outBaseLocation.getLocationColumn()) - .eq(BusinDataTask::getFromRow, outBaseLocation.getLocationRow()).last("limit 1"); - BusinDataTask businDataTask = getOne(wrapper); - if (businDataTask != null) { - return Result.err().msg("移出货位有未完成的货位移动任务,不可重复移动"); - } + BaseLocation outBaseLocation = iBaseLocationService.getById(outLocationId); + //查看是否时双深位,如果是则判断单深位是否有库存 + Result booleanResult = checkIsSleep(outBaseLocation); + if (!Result.isOk(booleanResult)) { + return booleanResult; + } + // 查询移出货位是否有未完成的任务 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper() + .notIn(BusinDataTask::getTaskStatus, Arrays.asList("2", "3")) + .in(BusinDataTask::getTaskType, Arrays.asList("9", "16")) + .eq(BusinDataTask::getFromLayer, outBaseLocation.getLayer()) + .eq(BusinDataTask::getFromColumn, outBaseLocation.getLocationColumn()) + .eq(BusinDataTask::getFromRow, outBaseLocation.getLocationRow()).last("limit 1"); + BusinDataTask businDataTask = getOne(wrapper); + if (businDataTask != null) { + return Result.err().msg("移出货位有未完成的货位移动任务,不可重复移动"); + } - //查询目标货位,并预占 - Long inLocationId = bo.getInLocationId(); - BaseLocation inBaseLocation = iBaseLocationService.getById(inLocationId); - if (inBaseLocation == null) { - return Result.err().msg("未获取到移入货位信息"); - } + //查询目标货位,并预占 + Long inLocationId = bo.getInLocationId(); + BaseLocation inBaseLocation = iBaseLocationService.getById(inLocationId); + if (inBaseLocation == null) { + return Result.err().msg("未获取到移入货位信息"); + } - if (!inBaseLocation.getLocationStatus().equals("0")) { - return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode()); - } + if (!inBaseLocation.getLocationStatus().equals("0")) { + return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode()); + } - inBaseLocation.setLocationStatus("4"); - iBaseLocationService.updateById(inBaseLocation); - //更改货位状态未移库中,此货位不可在出库 - outBaseLocation.setLocationStatus("5"); - iBaseLocationService.updateById(outBaseLocation); + inBaseLocation.setLocationStatus("4"); + iBaseLocationService.updateById(inBaseLocation); + //更改货位状态未移库中,此货位不可在出库 + outBaseLocation.setLocationStatus("5"); + iBaseLocationService.updateById(outBaseLocation); - //生成移库出库任务 - int index = 0; - List taskGoodsList = new ArrayList<>(); - List sysStockDetails = new ArrayList<>(); - - - String inTunnel = inBaseLocation.getTunnel(); - String outTunnel = outBaseLocation.getTunnel(); - BusinDataTask dataTaskAdd = new BusinDataTask(); - BusinDataTask dataTaskOut = new BusinDataTask(); - BusinDataTask dataTaskIn = new BusinDataTask(); - - if (!inTunnel.equals(outTunnel)) { - dataTaskOut.setTaskStatus("0"); - dataTaskOut.setBatch(DateUtils.getDate()); - dataTaskOut.setIsUrgent("0");//非紧急任务 - dataTaskOut.setIsTop("0"); - dataTaskOut.setPriority("0"); - dataTaskOut.setFromColumn(outBaseLocation.getLocationColumn()); - dataTaskOut.setFromLayer(outBaseLocation.getLayer()); - dataTaskOut.setFromRow(outBaseLocation.getLocationRow()); - dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue()); - - dataTaskIn.setTaskStatus("0"); - dataTaskIn.setBatch(DateUtils.getDate()); - dataTaskIn.setIsUrgent("0");//非紧急任务 - dataTaskIn.setIsTop("0"); - dataTaskIn.setPriority("0"); - dataTaskIn.setToLayer(inBaseLocation.getLayer()); - dataTaskIn.setToRow(inBaseLocation.getLocationRow()); - dataTaskIn.setToColumn(inBaseLocation.getLocationColumn()); - dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue()); + //生成移库出库任务 + int index = 0; + List taskGoodsList = new ArrayList<>(); + List sysStockDetails = new ArrayList<>(); - } else { - dataTaskAdd.setTaskStatus("0"); - dataTaskAdd.setBatch(DateUtils.getDate()); - dataTaskAdd.setIsUrgent("0");//非紧急任务 - dataTaskAdd.setIsTop("0"); - dataTaskAdd.setPriority("0"); - dataTaskAdd.setToLayer(inBaseLocation.getLayer()); - dataTaskAdd.setToRow(inBaseLocation.getLocationRow()); - dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn()); - dataTaskAdd.setTaskType(TaskTypeEnum.seat_adjustment.getValue()); - } - for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) { - Long taskInId = 0L; - Long taskOutId = 0L; - if (index == 0) { - if (!inTunnel.equals(outTunnel)) { - //根据巷道获取目标货位的输送线的agv接驳点 - BasePointQueryBo pointQueryBo = new BasePointQueryBo(); - pointQueryBo.setTunnel(inTunnel); - pointQueryBo.setGroupNo("4"); - BasePointVo basePointVo = iBasePointService.selectBasePointByQuery(pointQueryBo); - String pointNo = basePointVo.getPointNo(); - Long plcId = basePointVo.getPlcId(); - String devCode = basePointVo.getDevCode(); - dataTaskOut.setIsDown(basePointVo.getIsDown()); - dataTaskOut.setTaskPath(pointNo); - dataTaskOut.setPlcId(plcId); - dataTaskOut.setDpsNoOne(Long.valueOf(devCode)); - dataTaskOut.setLocationId(inLocationId); - this.save(dataTaskIn); - taskInId = dataTaskIn.getId(); - dataTaskOut.setAssociatedTasksId(dataTaskIn.getId().toString()); - this.save(dataTaskOut); - taskOutId = dataTaskOut.getId(); - } else { - this.save(dataTaskAdd); - } - index++; - } + String inTunnel = inBaseLocation.getTunnel(); + String outTunnel = outBaseLocation.getTunnel(); + BusinDataTask dataTaskAdd = new BusinDataTask(); + BusinDataTask dataTaskOut = new BusinDataTask(); + BusinDataTask dataTaskIn = new BusinDataTask(); - //保险杠信息 if (!inTunnel.equals(outTunnel)) { - BusinDataTaskGoods taskGoodsIn = new BusinDataTaskGoods(); - taskGoodsIn.setGoodsNo(sysStockDetailVo.getGoodsNo()); - taskGoodsIn.setIsPunching(sysStockDetailVo.getIsPuch()); - taskGoodsIn.setBranchId(SecurityUtils.getCurrentBranchId()); - taskGoodsIn.setTaskCode(taskInId); - taskGoodsList.add(taskGoodsIn); - BusinDataTaskGoods taskGoodsOut = new BusinDataTaskGoods(); - taskGoodsOut.setGoodsNo(sysStockDetailVo.getGoodsNo()); - taskGoodsOut.setIsPunching(sysStockDetailVo.getIsPuch()); - taskGoodsOut.setBranchId(SecurityUtils.getCurrentBranchId()); - taskGoodsOut.setTaskCode(taskOutId); - taskGoodsList.add(taskGoodsOut); + dataTaskOut.setTaskStatus("0"); + dataTaskOut.setBatch(DateUtils.getDate()); + dataTaskOut.setIsUrgent("0");//非紧急任务 + dataTaskOut.setIsTop("0"); + dataTaskOut.setPriority("0"); + dataTaskOut.setFromColumn(outBaseLocation.getLocationColumn()); + dataTaskOut.setFromLayer(outBaseLocation.getLayer()); + dataTaskOut.setFromRow(outBaseLocation.getLocationRow()); + dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue()); + + dataTaskIn.setTaskStatus("0"); + dataTaskIn.setBatch(DateUtils.getDate()); + dataTaskIn.setIsUrgent("0");//非紧急任务 + dataTaskIn.setIsTop("0"); + dataTaskIn.setPriority("0"); + dataTaskIn.setToLayer(inBaseLocation.getLayer()); + dataTaskIn.setToRow(inBaseLocation.getLocationRow()); + dataTaskIn.setToColumn(inBaseLocation.getLocationColumn()); + dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue()); + + } else { + dataTaskAdd.setTaskStatus("0"); + dataTaskAdd.setBatch(DateUtils.getDate()); + dataTaskAdd.setIsUrgent("0");//非紧急任务 + dataTaskAdd.setIsTop("0"); + dataTaskAdd.setPriority("0"); + dataTaskAdd.setToLayer(inBaseLocation.getLayer()); + dataTaskAdd.setToRow(inBaseLocation.getLocationRow()); + dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn()); + dataTaskAdd.setTaskType(TaskTypeEnum.seat_adjustment.getValue()); } + for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) { + Long taskInId = 0L; + Long taskOutId = 0L; + if (index == 0) { + if (!inTunnel.equals(outTunnel)) { + //根据巷道获取目标货位的输送线的agv接驳点 + BasePointQueryBo pointQueryBo = new BasePointQueryBo(); + pointQueryBo.setTunnel(inTunnel); + pointQueryBo.setGroupNo("4"); + BasePointVo basePointVo = iBasePointService.selectBasePointByQuery(pointQueryBo); + String pointNo = basePointVo.getPointNo(); + Long plcId = basePointVo.getPlcId(); + String devCode = basePointVo.getDevCode(); + dataTaskOut.setIsDown(basePointVo.getIsDown()); + dataTaskOut.setTaskPath(pointNo); + dataTaskOut.setPlcId(plcId); + dataTaskOut.setDpsNoOne(Long.valueOf(devCode)); + dataTaskOut.setLocationId(inLocationId); + this.save(dataTaskIn); + taskInId = dataTaskIn.getId(); + dataTaskOut.setAssociatedTasksId(dataTaskIn.getId().toString()); + this.save(dataTaskOut); + taskOutId = dataTaskOut.getId(); + } else { + this.save(dataTaskAdd); + } + index++; + } + + //保险杠信息 + if (!inTunnel.equals(outTunnel)) { + BusinDataTaskGoods taskGoodsIn = new BusinDataTaskGoods(); + taskGoodsIn.setGoodsNo(sysStockDetailVo.getGoodsNo()); + taskGoodsIn.setIsPunching(sysStockDetailVo.getIsPuch()); + taskGoodsIn.setBranchId(SecurityUtils.getCurrentBranchId()); + taskGoodsIn.setTaskCode(taskInId); + taskGoodsList.add(taskGoodsIn); + BusinDataTaskGoods taskGoodsOut = new BusinDataTaskGoods(); + taskGoodsOut.setGoodsNo(sysStockDetailVo.getGoodsNo()); + taskGoodsOut.setIsPunching(sysStockDetailVo.getIsPuch()); + taskGoodsOut.setBranchId(SecurityUtils.getCurrentBranchId()); + taskGoodsOut.setTaskCode(taskOutId); + taskGoodsList.add(taskGoodsOut); + }else{ + BusinDataTaskGoods taskGoodsAdd = new BusinDataTaskGoods(); + taskGoodsAdd.setGoodsNo(sysStockDetailVo.getGoodsNo()); + taskGoodsAdd.setIsPunching(sysStockDetailVo.getIsPuch()); + taskGoodsAdd.setBranchId(SecurityUtils.getCurrentBranchId()); + taskGoodsAdd.setTaskCode(taskOutId); + taskGoodsList.add(taskGoodsAdd); + taskGoodsList.add(taskGoodsAdd); + } + // //出库预占 // sysStockDetailVo.setOutQty(sysStockDetailVo.getQty().intValue()); // SysStockDetail sysStockDetail = BeanUtil.toBean(sysStockDetailVo, SysStockDetail.class); // sysStockDetail.setOutTime(DateUtils.getNowDate()); // sysStockDetails.add(sysStockDetail); - } + } - // iSysStockDetailService.updateBatchById(sysStockDetails); - return iBusinDataTaskGoodsService.saveBatch(taskGoodsList) ? Result.ok() : Result.err().msg("移库任务失败"); + // iSysStockDetailService.updateBatchById(sysStockDetails); + iBusinDataTaskGoodsService.saveBatch(taskGoodsList); + return Result.ok().msg("移库任务成功"); + }catch (Exception e){ + log.info("移库任务失败:"+e.getMessage()); + TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); + return Result.err().msg("移库任务失败"); + } } diff --git a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml index 06146b2..8afb8d4 100644 --- a/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml +++ b/shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml @@ -555,6 +555,7 @@ JOIN base_storage s ON a.storage_id = s.id WHERE l.is_del = '0' AND a.is_del = '0' + and l.location_status='0' and l.id not in (select distinct location_id from sys_stock_detail) and l.location_name like concat('%', #{locationName},'%')