From 08cd807032b661ec5061ab822ccbf53b41d7d438 Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期二, 03 十二月 2024 14:12:53 +0800 Subject: [PATCH] #库位移转 --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java | 141 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 141 insertions(+), 0 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java index 97ceb6c..cdbe93b 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/service/impl/WorkServiceImpl.java @@ -1,11 +1,14 @@ package com.zy.asrs.wms.asrs.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.zy.asrs.framework.common.Cools; +import com.zy.asrs.framework.common.R; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wms.asrs.entity.*; import com.zy.asrs.wms.asrs.entity.enums.*; import com.zy.asrs.wms.asrs.entity.param.FieldParam; import com.zy.asrs.wms.asrs.entity.param.GeneratePakInParam; +import com.zy.asrs.wms.asrs.entity.param.LocTransferParam; import com.zy.asrs.wms.asrs.service.*; import com.zy.asrs.wms.utils.LocUtils; import com.zy.asrs.wms.utils.OrderUtils; @@ -37,6 +40,10 @@ private OrderDetlService orderDetlService; @Autowired private LocService locService; + @Autowired + private LocDetlService locDetlService; + @Autowired + private LocDetlFieldService locDetlFieldService; @Autowired private LocStsService locStsService; @Autowired @@ -499,8 +506,35 @@ throw new CoolException("娉㈡鏄庣粏鏇存柊澶辫触"); } } + break; + case 11://搴撲綅绉昏浆 + Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc())); + if(originLoc == null){ + throw new CoolException("婧愬簱浣嶄笉瀛樺湪"); + } + if (originLoc.getLocStsId() != LocStsType.R.val()) { + throw new CoolException("婧愬簱浣嶇姸鎬佷笉澶勪簬R.鍑哄簱棰勭害"); + } + loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc())); + if(loc == null){ + throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�"); + } + if(loc.getLocStsId() != LocStsType.S.val()){ + throw new CoolException("鐩爣搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害"); + } + originLoc.setLocStsId(LocStsType.F.val()); + originLoc.setUpdateTime(new Date()); + if(!locService.updateById(originLoc)){ + throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�"); + } + + loc.setLocStsId(LocStsType.O.val()); + loc.setUpdateTime(new Date()); + if(!locService.updateById(loc)){ + throw new CoolException("搴撲綅鐘舵�佸彉鏇村け璐�"); + } break; } @@ -650,4 +684,111 @@ return true; } + + @Override + public boolean locTransfer(LocTransferParam param) { + if (param == null) { + throw new CoolException("鍙傛暟涓嶈兘涓虹┖"); + } + + if (Cools.isEmpty(param.getSourceLocNo())) { + throw new CoolException("婧愬簱浣嶄笉鑳戒负绌�"); + } + + if (Cools.isEmpty(param.getTargetLocNo())) { + throw new CoolException("鐩爣搴撲綅涓嶈兘涓虹┖"); + } + + Loc sourceLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getSourceLocNo())); + if (sourceLoc == null) { + throw new CoolException("婧愬簱浣嶄笉瀛樺湪"); + } + + if (sourceLoc.getLocStsId() != LocStsType.F.val()) { + throw new CoolException("婧愬簱浣嶉潪鍦ㄥ簱鐘舵��"); + } + + Loc targetLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, param.getTargetLocNo())); + if (targetLoc == null) { + throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦�"); + } + + if(targetLoc.getLocStsId() != LocStsType.O.val()){ + throw new CoolException("鐩爣搴撲綅闈炵┖鐘舵��"); + } + + TaskType taskType = taskTypeService.getById(11); + if (taskType == null) { + throw new CoolException("浠诲姟绫诲瀷涓嶅瓨鍦�"); + } + + Task task = new Task(); + task.setTaskNo(this.generateTaskNo(taskType.getId()));//浠诲姟鍙� + task.setTaskSts(TaskStsType.GENERATE_IN.id);//1.鐢熸垚鍏ュ簱浠诲姟 + task.setTaskType(taskType.getId());//浠诲姟绫诲瀷 + task.setIoPri(this.generateIoPri(taskType.getId()));//浼樺厛绾� + task.setOriginLoc(param.getSourceLocNo()); + task.setTargetLoc(param.getTargetLocNo()); + task.setOriginSite(null); + task.setTargetSite(null); + task.setBarcode(sourceLoc.getBarcode());//鎵樼洏鐮� + boolean taskSave = taskService.save(task); + if (!taskSave) { + throw new CoolException("浠诲姟鐢熸垚澶辫触"); + } + + List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, sourceLoc.getId())); + if(locDetls.isEmpty()){ + throw new CoolException("婧愬簱浣嶆槑缁嗕笉瀛樺湪"); + } + + //鐢熸垚浠诲姟鏄庣粏 + for (LocDetl locDetl : locDetls) { + TaskDetl taskDetl = new TaskDetl(); + taskDetl.setTaskId(task.getId()); + taskDetl.setTaskNo(task.getTaskNo()); + taskDetl.setAnfme(locDetl.getAnfme());//鏁伴噺 + taskDetl.setStock(0D);//搴撳瓨 + taskDetl.setBatch(locDetl.getBatch());//鎵瑰彿 + taskDetl.setBarcode(sourceLoc.getBarcode()); + taskDetl.setMatId(locDetl.getMatId()); + taskDetl.setMatnr(locDetl.getMatnr()); + boolean taskDetlSave = taskDetlService.save(taskDetl); + if(!taskDetlSave){ + throw new CoolException("浠诲姟鏄庣粏鐢熸垚澶辫触"); + } + + //鐢熸垚鏄庣粏鎵╁睍 + List<LocDetlField> locDetlFieldList = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId())); + for (LocDetlField locDetlField : locDetlFieldList) { + TaskDetlField taskDetlField = new TaskDetlField(); + taskDetlField.setName(locDetlField.getName()); + taskDetlField.setFieldId(locDetlField.getFieldId()); + taskDetlField.setDetlId(taskDetl.getId()); + taskDetlField.setValue(locDetlField.getValue()); + boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField); + if(!taskDetlFieldSave){ + throw new CoolException("鏄庣粏鎵╁睍鐢熸垚澶辫触"); + } + } + } + + //搴撲綅F => R + sourceLoc.setLocStsId(LocStsType.R.val()); + sourceLoc.setUpdateTime(new Date()); + boolean sourceLocUpdate = locService.updateById(sourceLoc); + if(!sourceLocUpdate){ + throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�"); + } + + //搴撲綅O => S + targetLoc.setLocStsId(LocStsType.S.val()); + targetLoc.setUpdateTime(new Date()); + boolean targetLocUpdate = locService.updateById(targetLoc); + if(!targetLocUpdate){ + throw new CoolException("搴撲綅鐘舵�佹洿鏂板け璐�"); + } + + return true; + } } -- Gitblit v1.9.1