| | |
| | | import com.alibaba.fastjson.JSON;
|
| | | 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.*;
|
| | |
| | | @Override
|
| | | public Loc generateEmptyLoc(Long taskType, Integer locTypeHeight) {
|
| | | List<ShelvesRule> shelvesRules = shelvesRuleService.list(new LambdaQueryWrapper<ShelvesRule>().eq(ShelvesRule::getStatus, 1).orderByDesc(ShelvesRule::getCreateTime));
|
| | | if(shelvesRules.isEmpty()) {
|
| | | if (shelvesRules.isEmpty()) {
|
| | | throw new CoolException("未配置上架规则");
|
| | | }
|
| | | ShelvesRule shelvesRule = shelvesRules.get(0);
|
| | |
| | | }
|
| | |
|
| | | List<ShelvesRuleDetl> ruleDetls = shelvesRule.getRuleDetl$();
|
| | | if(ruleDetls.isEmpty()) {
|
| | | if (ruleDetls.isEmpty()) {
|
| | | throw new CoolException("未配置上架规则明细");
|
| | | }
|
| | |
|
| | |
| | | //获取库位
|
| | | if (!suggestLoc.isEmpty()) {
|
| | | defaultLoc = locUtils.filterLoc(taskType, suggestLoc);
|
| | | if(defaultLoc != null) {
|
| | | if (defaultLoc != null) {
|
| | | return defaultLoc;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
|
| | | return locUtils.getGlobalEmptyLocToCtu(locTypeHeight);
|
| | | //从全局库位中获取(完整巷道)
|
| | | List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
|
| | | //获取库位
|
| | | if (!globalLoc.isEmpty()) {
|
| | | defaultLoc = locUtils.filterAllLoc(globalLoc);
|
| | | if(defaultLoc != null) {
|
| | | return defaultLoc;
|
| | | }
|
| | | }
|
| | | // List<Loc> globalLoc = locUtils.getGlobalEmptyLoc(taskType, locTypeHeight, laneRowList, currentLev);
|
| | | // //获取库位
|
| | | // if (!globalLoc.isEmpty()) {
|
| | | // defaultLoc = locUtils.filterAllLoc(globalLoc);
|
| | | // if (defaultLoc != null) {
|
| | | // return defaultLoc;
|
| | | // }
|
| | | // }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | return defaultLoc;
|
| | | }
|
| | | }
|
| | | //fixme 如果没有相邻库位是否考虑推荐库位
|
| | |
|
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.SUGGEST.id)) {
|
| | | //获取推荐库位
|
| | | List<Loc> suggestLoc = locUtils.getSuggestLoc(taskType, mat.getId(), batch, locTypeHeight, laneRowList, currentLev);
|
| | |
| | | }
|
| | |
|
| | | if (ruleDetl.getDetlType().equals(ShelvesRuleDetlType.COMPLETE.id)) {
|
| | | return locUtils.getGlobalEmptyLocToCtu(locTypeHeight);
|
| | | //从全局库位中获取(完整巷道)
|
| | | List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev);
|
| | | //获取库位
|
| | | if (!globalLoc.isEmpty()) {
|
| | | defaultLoc = locUtils.filterAllLoc(globalLoc);
|
| | | if (defaultLoc != null) {
|
| | | return defaultLoc;
|
| | | }
|
| | | }
|
| | | // List<Loc> globalLoc = locUtils.getGlobalLoc(taskType, locTypeHeight, laneRowList, currentLev);
|
| | | // //获取库位
|
| | | // if (!globalLoc.isEmpty()) {
|
| | | // defaultLoc = locUtils.filterAllLoc(globalLoc);
|
| | | // if (defaultLoc != null) {
|
| | | // return defaultLoc;
|
| | | // }
|
| | | // }
|
| | | }
|
| | | }
|
| | | return defaultLoc;
|
| | |
| | |
|
| | | //生成库位
|
| | | Loc loc = this.generateLoc(param.getTaskType(), param.getBarcode(), param.getLocTypeHeight());
|
| | | if(loc == null) {
|
| | | if (loc == null) {
|
| | | throw new CoolException("没有空库位");
|
| | | }
|
| | |
|
| | |
| | | taskDetl.setMatId(waitPakin.getDetl$().getMatId());
|
| | | taskDetl.setMatnr(waitPakin.getDetl$().getMat$().getMatnr());
|
| | | boolean taskDetlSave = taskDetlService.save(taskDetl);
|
| | | if(!taskDetlSave){
|
| | | if (!taskDetlSave) {
|
| | | throw new CoolException("任务明细生成失败");
|
| | | }
|
| | |
|
| | |
| | | taskDetlField.setDetlId(taskDetl.getId());
|
| | | taskDetlField.setValue(orderDetlField.getValue());
|
| | | boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
|
| | | if(!taskDetlFieldSave){
|
| | | if (!taskDetlFieldSave) {
|
| | | throw new CoolException("明细扩展生成失败");
|
| | | }
|
| | | }
|
| | |
| | | waitPakin.setIoStatus(1);
|
| | | waitPakin.setUpdateTime(new Date());
|
| | | boolean waitPakinUpdate = waitPakinService.updateById(waitPakin);
|
| | | if(!waitPakinUpdate){
|
| | | if (!waitPakinUpdate) {
|
| | | throw new CoolException("组托通知档更新失败");
|
| | | }
|
| | |
|
| | | //更新订单明细数据
|
| | | OrderDetl orderDetl = orderDetlService.getById(taskDetl.getDetlId());
|
| | | if(orderDetl == null){
|
| | | if (orderDetl == null) {
|
| | | throw new CoolException("订单明细不存在");
|
| | | }
|
| | |
|
| | | orderDetl.setWorkQty(orderDetl.getWorkQty() + taskDetl.getAnfme());
|
| | | orderDetl.setUpdateTime(new Date());
|
| | | boolean orderDetlUpdate = orderDetlService.updateById(orderDetl);
|
| | | if(!orderDetlUpdate){
|
| | | if (!orderDetlUpdate) {
|
| | | throw new CoolException("订单明细更新失败");
|
| | | }
|
| | |
|
| | | //获取订单
|
| | | Order order = orderService.getById(taskDetl.getOrderId());
|
| | | if(order == null){
|
| | | if (order == null) {
|
| | | throw new CoolException("订单不存在");
|
| | | }
|
| | |
|
| | |
| | | loc.setLocStsId(LocStsType.S.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | boolean locUpdate = locService.updateById(loc);
|
| | | if(!locUpdate){
|
| | | if (!locUpdate) {
|
| | | throw new CoolException("库位状态更新失败");
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //生成库位
|
| | | Loc loc = this.generateEmptyLoc(param.getTaskType(), param.getLocTypeHeight());
|
| | | if(loc == null) {
|
| | | if (loc == null) {
|
| | | throw new CoolException("没有空库位");
|
| | | }
|
| | |
|
| | |
| | | loc.setLocStsId(LocStsType.S.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | boolean locUpdate = locService.updateById(loc);
|
| | | if(!locUpdate){
|
| | | if (!locUpdate) {
|
| | | throw new CoolException("库位状态更新失败");
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | public boolean completeTask(Long taskId) {
|
| | | Task task = taskService.getById(taskId);
|
| | | if(task == null){
|
| | | if (task == null) {
|
| | | throw new CoolException("任务不存在");
|
| | | }
|
| | |
|
| | |
| | | if (task.getTaskType() < 100) {
|
| | | //入库
|
| | | task.setTaskSts(TaskStsType.COMPLETE_IN.id);//99.入库完成
|
| | | }else {
|
| | | } else {
|
| | | //出库
|
| | | TaskDetl taskDetl = taskDetls.get(0); //TODO 出库流程待确认,ESS取货后,输送线流转到扫码处状态
|
| | | if (taskDetl.getWaveId() == null) {
|
| | | task.setTaskSts(TaskStsType.COMPLETE_OUT.id);//199.出库完成
|
| | | }else {
|
| | | } else {
|
| | | task.setTaskSts(TaskStsType.WAVE_SEED.id);//198.播种中
|
| | | }
|
| | | }
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean cancelTask(Long taskId) {
|
| | | Task task = taskService.getById(taskId);
|
| | | if(task == null){
|
| | | if (task == null) {
|
| | | throw new CoolException("任务不存在");
|
| | | }
|
| | |
|
| | |
| | | case 54://并板
|
| | | case 57://盘点
|
| | | loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
|
| | | if(loc == null){
|
| | | if (loc == null) {
|
| | | throw new CoolException("库位不存在");
|
| | | }
|
| | | if(loc.getLocStsId() != LocStsType.S.val()){
|
| | | if (loc.getLocStsId() != LocStsType.S.val()) {
|
| | | throw new CoolException("库位状态不处于S.入库预约");
|
| | | }
|
| | | loc.setLocStsId(LocStsType.O.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | if(!locService.updateById(loc)){
|
| | | if (!locService.updateById(loc)) {
|
| | | throw new CoolException("库位状态变更失败");
|
| | | }
|
| | | break;
|
| | |
| | | case 107://盘点
|
| | | case 110://空板
|
| | | loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
|
| | | if(loc == null){
|
| | | if (loc == null) {
|
| | | throw new CoolException("库位不存在");
|
| | | }
|
| | | if(loc.getLocStsId() != LocStsType.R.val()){
|
| | | if (loc.getLocStsId() != LocStsType.R.val()) {
|
| | | throw new CoolException("库位状态不处于R.出库预约");
|
| | | }
|
| | | loc.setLocStsId(LocStsType.F.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | if(!locService.updateById(loc)){
|
| | | if (!locService.updateById(loc)) {
|
| | | throw new CoolException("库位状态变更失败");
|
| | | }
|
| | |
|
| | |
| | |
|
| | | String matUniqueKey = Utils.getMatUniqueKey(taskDetl.getMatnr(), taskDetl.getBatch(), taskDetl.getUniqueField());
|
| | | WaveDetl waveDetl = waveDetlService.getOne(new LambdaQueryWrapper<WaveDetl>().eq(WaveDetl::getStockIndex, matUniqueKey).eq(WaveDetl::getWaveId, taskDetl.getWaveId()));
|
| | | if(waveDetl == null){
|
| | | if (waveDetl == null) {
|
| | | continue;
|
| | | }
|
| | | waveDetl.setWorkQty(waveDetl.getWorkQty() - taskDetl.getAnfme());
|
| | |
| | | break;
|
| | | case 11://库位移转
|
| | | Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
|
| | | if(originLoc == null){
|
| | | if (originLoc == null) {
|
| | | throw new CoolException("源库位不存在");
|
| | | }
|
| | | if (originLoc.getLocStsId() != LocStsType.R.val()) {
|
| | |
| | | }
|
| | |
|
| | | loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getTargetLoc()));
|
| | | if(loc == null){
|
| | | if (loc == null) {
|
| | | throw new CoolException("目标库位不存在");
|
| | | }
|
| | | if(loc.getLocStsId() != LocStsType.S.val()){
|
| | | if (loc.getLocStsId() != LocStsType.S.val()) {
|
| | | throw new CoolException("目标库位状态不处于S.入库预约");
|
| | | }
|
| | |
|
| | | originLoc.setLocStsId(LocStsType.F.val());
|
| | | originLoc.setUpdateTime(new Date());
|
| | | if(!locService.updateById(originLoc)){
|
| | | if (!locService.updateById(originLoc)) {
|
| | | throw new CoolException("库位状态变更失败");
|
| | | }
|
| | |
|
| | | loc.setLocStsId(LocStsType.O.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | if(!locService.updateById(loc)){
|
| | | if (!locService.updateById(loc)) {
|
| | | throw new CoolException("库位状态变更失败");
|
| | | }
|
| | | break;
|
| | |
| | |
|
| | | //删除任务
|
| | | boolean removeTask = taskService.removeById(taskId);
|
| | | if(!removeTask){
|
| | | if (!removeTask) {
|
| | | throw new CoolException("回滚任务失败");
|
| | | }
|
| | |
|
| | |
| | | //入库回滚组托通知档
|
| | | if (task.getTaskType() == 1) {
|
| | | WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getDetlId, taskDetl.getDetlId()).eq(WaitPakin::getBarcode, task.getBarcode()));
|
| | | if(waitPakin == null){
|
| | | if (waitPakin == null) {
|
| | | throw new CoolException("组托通知档不存在");
|
| | | }
|
| | |
|
| | | waitPakin.setIoStatus(0);
|
| | | waitPakin.setUpdateTime(new Date());
|
| | | boolean updateWaitPakin = waitPakinService.updateById(waitPakin);
|
| | | if(!updateWaitPakin){
|
| | | if (!updateWaitPakin) {
|
| | | throw new CoolException("组托通知档回滚失败");
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | //删除明细
|
| | | boolean removeDetl = taskDetlService.removeById(taskDetl.getId());
|
| | | if(!removeDetl){
|
| | | if (!removeDetl) {
|
| | | throw new CoolException("回滚明细失败");
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //删除明细扩展
|
| | | boolean removeField = taskDetlFieldService.removeById(detlField.getId());
|
| | | if(!removeField){
|
| | | if (!removeField) {
|
| | | throw new CoolException("回滚扩展明细失败");
|
| | | }
|
| | | }
|
| | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean pickTask(Long taskId) {
|
| | | Task task = taskService.getById(taskId);
|
| | | if(task == null){
|
| | | if (task == null) {
|
| | | throw new CoolException("任务不存在");
|
| | | }
|
| | |
|
| | |
| | |
|
| | | //获取源库位
|
| | | Loc originLoc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
|
| | | if(originLoc == null){
|
| | | if (originLoc == null) {
|
| | | throw new CoolException("源库位不存在");
|
| | | }
|
| | |
|
| | | //获取源库位高度
|
| | | LocTypeBind locTypeBind = locTypeBindService.getOne(new LambdaQueryWrapper<LocTypeBind>().eq(LocTypeBind::getLocId, originLoc.getId()).in(LocTypeBind::getTypeId, LocBindType.HEIGHT.list()));
|
| | | if(locTypeBind == null){
|
| | | if (locTypeBind == null) {
|
| | | throw new CoolException("库位类型不存在");
|
| | | }
|
| | | LocType locType = locTypeService.getById(locTypeBind.getTypeId());
|
| | | if(locType == null){
|
| | |
|
| | | if (locType == null) {
|
| | | throw new CoolException("库位类型不存在");
|
| | | }
|
| | | LocTypeHeightType locTypeHeightType = LocTypeHeightType.get(locType.getFlag());
|
| | | if(locTypeHeightType == null){
|
| | |
|
| | | if (locTypeHeightType == null) {
|
| | | throw new CoolException("高低库位类型不存在");
|
| | | }
|
| | |
|
| | |
| | | throw new CoolException("任务明细不存在");
|
| | | }
|
| | | TaskDetl taskDetl = taskDetls.get(0);
|
| | |
|
| | | //生成库位
|
| | | Loc loc = this.generateLoc(taskType, taskDetl.getMatId(), taskDetl.getBatch(), taskDetl.getUniqueField(), locTypeHeightType.id);
|
| | | if(loc == null) {
|
| | | //生成新的库位 !important
|
| | | // Loc loc = this.generateLoc(taskType, taskDetl.getMatId(), taskDetl.getBatch(), taskDetl.getUniqueField(), locTypeHeightType.id);
|
| | | // if(loc == null) {
|
| | | // throw new CoolException("没有空库位");
|
| | | // }
|
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocNo, task.getOriginLoc()));
|
| | | if (loc == null) {
|
| | | throw new CoolException("没有空库位");
|
| | | }
|
| | | //102拣料此处需修改为WCS_CONTAINER_RECEIVE,定时任务查询后,自动下发入库任务至ESS
|
| | | task.setTaskSts(TaskStsType.WCS_CONTAINER_RECEIVE.id);//1.生成入库任务
|
| | | task.setTaskType(taskType);
|
| | | task.setTargetLoc(loc.getLocNo());
|
| | | //原库位变目标库位, 原站点变目标站点
|
| | | //todo 需确认原站点为空,该怎么处理
|
| | | task.setTargetLoc(task.getOriginLoc());
|
| | | task.setUpdateTime(new Date());
|
| | | if (!taskService.updateById(task)) {
|
| | | throw new CoolException("拣料失败");
|
| | | }
|
| | |
|
| | | //库位O => S
|
| | | //库位状态改为预约入库 R => S
|
| | | loc.setLocStsId(LocStsType.S.val());
|
| | | loc.setUpdateTime(new Date());
|
| | | boolean locUpdate = locService.updateById(loc);
|
| | | if(!locUpdate){
|
| | | if (!locUpdate) {
|
| | | throw new CoolException("库位状态更新失败");
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public boolean locAdjust(LocAdjustParam param) {
|
| | | if (param == null) {
|
| | | throw new CoolException("参数不能为空");
|
| | |
| | | throw new CoolException("目标库位不存在");
|
| | | }
|
| | |
|
| | | if(targetLoc.getLocStsId() != LocStsType.O.val()){
|
| | | if (targetLoc.getLocStsId() != LocStsType.O.val()) {
|
| | | throw new CoolException("目标库位非空状态");
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, sourceLoc.getId()));
|
| | | if(locDetls.isEmpty()){
|
| | | if (locDetls.isEmpty()) {
|
| | | throw new CoolException("源库位明细不存在");
|
| | | }
|
| | |
|
| | |
| | | taskDetl.setMatId(locDetl.getMatId());
|
| | | taskDetl.setMatnr(locDetl.getMatnr());
|
| | | boolean taskDetlSave = taskDetlService.save(taskDetl);
|
| | | if(!taskDetlSave){
|
| | | if (!taskDetlSave) {
|
| | | throw new CoolException("任务明细生成失败");
|
| | | }
|
| | |
|
| | |
| | | taskDetlField.setDetlId(taskDetl.getId());
|
| | | taskDetlField.setValue(locDetlField.getValue());
|
| | | boolean taskDetlFieldSave = taskDetlFieldService.save(taskDetlField);
|
| | | if(!taskDetlFieldSave){
|
| | | if (!taskDetlFieldSave) {
|
| | | throw new CoolException("明细扩展生成失败");
|
| | | }
|
| | | }
|
| | |
| | | sourceLoc.setLocStsId(LocStsType.R.val());
|
| | | sourceLoc.setUpdateTime(new Date());
|
| | | boolean sourceLocUpdate = locService.updateById(sourceLoc);
|
| | | if(!sourceLocUpdate){
|
| | | if (!sourceLocUpdate) {
|
| | | throw new CoolException("库位状态更新失败");
|
| | | }
|
| | |
|
| | |
| | | targetLoc.setLocStsId(LocStsType.S.val());
|
| | | targetLoc.setUpdateTime(new Date());
|
| | | boolean targetLocUpdate = locService.updateById(targetLoc);
|
| | | if(!targetLocUpdate){
|
| | | if (!targetLocUpdate) {
|
| | | throw new CoolException("库位状态更新失败");
|
| | | }
|
| | |
|