| | |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.Shelves; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | */ |
| | | public StartupDto getLocNo(Integer whsType, Integer staDescId, Integer sourceStaNo, List<String> matNos, LocTypeDto locTypeDto, LocTypeDto oldLocType, int times) { |
| | | StartupDto startupDto = new StartupDto(); |
| | | int start = 2; |
| | | int end = 30; |
| | | switch (sourceStaNo) { |
| | | case 103: |
| | | whsType = 1; |
| | | break; |
| | | case 111: |
| | | case 211: |
| | | case 107: |
| | | whsType = 2; |
| | | end = 17; |
| | | break; |
| | | case 208: |
| | | case 118: |
| | | whsType = 3; |
| | | start = 18; |
| | | break; |
| | | default: |
| | | throw new CoolException("检索库位失败,请联系管理员"); |
| | | whsType = 1; |
| | | break; |
| | | } |
| | | // 生成工作号 |
| | | int workNo = getWorkNo(0); |
| | |
| | | LocMast locMast = null; |
| | | |
| | | // 靠近摆放规则 --- 同天同规格物料 |
| | | if (!Cools.isEmpty(matNos)) { |
| | | List<String> locNos = locDetlService.getSameDetl(matNos.get(0), sRow, eRow); |
| | | if (!Cools.isEmpty(matNos) && matNos.size() == 1) { |
| | | List<String> locNos = locDetlService.getSameDetl(matNos.get(0), start, end); |
| | | for (String locNo : locNos) { |
| | | List<String> groupLoc = Utils.getGroupLoc(locNo); |
| | | locMast = locMastService.findOutMost(groupLoc); |
| | | if (null != locMast) { |
| | | LocMast locMast0 = locMastService.findOutMost(groupLoc); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast, locTypeDto)) { |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | // 浅库位对应堆垛机必须可用且无异常 |
| | | if (basCrnpService.checkSiteError(locMast.getCrnNo(), true)) { |
| | | crnNo = locMast.getCrnNo(); |
| | | if (basCrnpService.checkSiteError(locMast0.getCrnNo(), true)) { |
| | | crnNo = locMast0.getCrnNo(); |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | | } |
| | |
| | | |
| | | // 靠近摆放规则 --- 空托 |
| | | if (staDescId == 10) { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow)); |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "D").ge("row1", start).le("row1", end)); |
| | | if (locMasts.size() > 0) { |
| | | for (LocMast loc : locMasts) { |
| | | List<String> groupLoc = Utils.getGroupLoc(loc.getLocNo()); |
| | | locMast = locMastService.findOutMost(groupLoc); |
| | | if (null != locMast) { |
| | | LocMast locMast0 = locMastService.findOutMost(groupLoc); |
| | | if (null != locMast0) { |
| | | // 浅库位符合尺寸检测 |
| | | if (VersionUtils.locMoveCheckLocType(locMast, locTypeDto)) { |
| | | if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) { |
| | | // 浅库位对应堆垛机必须可用且无异常 |
| | | if (basCrnpService.checkSiteError(locMast.getCrnNo(), true)) { |
| | | crnNo = locMast.getCrnNo(); |
| | | if (basCrnpService.checkSiteError(locMast0.getCrnNo(), true)) { |
| | | crnNo = locMast0.getCrnNo(); |
| | | locMast = locMast0; |
| | | break; |
| | | } |
| | | } |
| | |
| | | |
| | | // 如果没有相近物料,则按规则轮询货架 |
| | | if (null == locMast) { |
| | | switch (whsType) { |
| | | case 1: |
| | | if (curRow == 1) { |
| | | curRow = 7; |
| | | } else if (curRow == 7) { |
| | | curRow = 1; |
| | | } |
| | | crnNo = 1; |
| | | break; |
| | | case 2: |
| | | if (curRow == 8) { |
| | | curRow = 14; |
| | | } else if (curRow == 14) { |
| | | curRow = 8; |
| | | } |
| | | crnNo = 2; |
| | | break; |
| | | case 3: |
| | | if (curRow == 15) { |
| | | curRow = 21; |
| | | } else if (curRow == 21) { |
| | | curRow = 15; |
| | | } |
| | | crnNo = 3; |
| | | break; |
| | | default: |
| | | Shelves shelves = new Shelves(rowCount, crn_qty); |
| | | for (int i = 0; i < shelves.group; i ++) { |
| | | curRow = shelves.start(curRow); |
| | | if (curRow < 0) { |
| | | throw new CoolException("检索库位失败,请联系管理员"); |
| | | } |
| | | Integer crnNo1 = shelves.get(curRow) + 1; |
| | | if (whsType != 1) { |
| | | crnNo1 = whsType; |
| | | } |
| | | if (basCrnpService.checkSiteError(crnNo1, true)) { |
| | | crnNo = crnNo1; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!basCrnpService.checkSiteError(crnNo, true)) { |
| | | throw new CoolException("没有可用的堆垛机"); |
| | | } |
| | | if (crnNo == 0) { |
| | | throw new CoolException("没有可用的堆垛机"); |
| | | } |
| | |
| | | if (locMast == null) { |
| | | List<Integer> rows = Utils.getGroupLoc(curRow); |
| | | |
| | | locMast = locMastService.queryFreeLocMast(null, rows, locTypeDto.getLocType1()); |
| | | // 因库位移转、需预留空库位 |
| | | List<LocMast> locMasts = locMastService.queryFreeLocMast(rows, rows.size(), locTypeDto.getLocType1()); |
| | | if (!Cools.isEmpty(locMasts)) { |
| | | Integer innermostRow = Utils.getOutLayerRow(locMasts.get(0).getLocNo(), false); |
| | | for (LocMast one : locMasts) { |
| | | if (one.getRow1().equals(innermostRow)) { |
| | | locMast = one; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // 因库位移转、需预留空库位 todo:luxiaotao |
| | | // if (!locMastService.checkEmptyCount(locMast)) { |
| | | // locMast = null; |
| | | // } |