| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | |
| | | // 类型 |
| | | switch (wrkMk) { |
| | | case 0: // 入库 1 - 3000 |
| | | break; |
| | | case 1: // 拣料/并板/盘点 3001 - 6000 |
| | | break; |
| | | case 2: // 出库 6001 -9000 |
| | | break; |
| | | case 3: // 其他 9001 -9999 |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | int workNo = wrkLastno.getWrkNo(); |
| | | int sNo = wrkLastno.getSNo(); |
| | | int eNo = wrkLastno.getENo(); |
| | |
| | | // 生成工作号 |
| | | int workNo = getWorkNo(WorkNoType.getWorkNoType(staDescId)); |
| | | startupDto.setWorkNo(workNo); |
| | | if (sourceStaNo < 100) { |
| | | whsType = 1; |
| | | } else { |
| | | whsType = 2; |
| | | } |
| | | RowLastno rowLastno = rowLastnoService.selectById(whsType); |
| | | if (Cools.isEmpty(rowLastno)) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | |
| | | int curRow = rowLastno.getCurrentRow(); |
| | | int sRow = rowLastno.getsRow(); |
| | | int eRow = rowLastno.geteRow(); |
| | | int crn_qty = rowLastno.getCrnQty(); |
| | | int rowCount = eRow - sRow + 1; |
| | | // 目标堆垛机号 |
| | | int crnNo = 0; |
| | | // 目标库位 |
| | | LocMast locMast = null; |
| | | |
| | | // 如果没有相近物料,则按规则轮询货架 |
| | | if (null == locMast) { |
| | | // 获取目标站所在货架排号 todo:luxiaotao |
| | | if (curRow == sRow) { |
| | | curRow = eRow; |
| | | } else { |
| | | curRow = sRow; |
| | | } |
| | | crnNo = whsType; |
| | | // Shelves shelves = new Shelves(rowCount, crn_qty); |
| | | // curRow = shelves.start(curRow); |
| | | // if (curRow < 0) { |
| | | // throw new CoolException("检索库位失败,请联系管理员"); |
| | | // } |
| | | // for (List<Integer> node : shelves.nodes){ |
| | | // if (node.contains(curRow)) { |
| | | // crnNo = shelves.nodes.indexOf(node) + 1; |
| | | // break; |
| | | // } |
| | | // } |
| | | // 获取目标站所在货架排号 |
| | | curRow = curRow == sRow ? eRow : sRow; |
| | | // 目标堆垛机号 |
| | | int crnNo; |
| | | switch (whsType) { |
| | | case 1: |
| | | crnNo = 1; |
| | | break; |
| | | case 2: |
| | | crnNo = 2; |
| | | break; |
| | | default: |
| | | throw new CoolException("检索库位 -- 检索堆垛机号失败"); |
| | | } |
| | | |
| | | basCrnpService.checkSiteStatus(crnNo); |
| | |
| | | int inQty = staNo.getInQty()==null?0:staNo.getInQty(); |
| | | if (staNo.getAutoing().equals("Y") && inQty<2) { |
| | | // 查找库位 |
| | | if (locMast == null) { |
| | | locMast = locMastService.queryFreeLocMast(curRow); |
| | | } |
| | | LocMast locMast = locMastService.queryFreeLocMast(curRow); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("没有空库位"); |
| | | } |
| | |
| | | throw new CoolException(rowLastno.getWhsType()+"号库位排号分配规则不可用"); |
| | | } |
| | | return startupDto; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(Arith.remainder(1, 4)); |
| | | System.out.println("0200201".substring(0, 2)); |
| | | String locNo = "0800201"; |
| | | int row = Integer.parseInt(locNo.substring(0, 2)); |
| | | double remainder = Arith.remainder(row, 4); |
| | | int targetRow; |
| | | if (remainder == 1) { |
| | | // 得到当前库位的外围库位 |
| | | targetRow = row + 1; |
| | | } else if (remainder == 0) { |
| | | // 得到当前库位的内围库位 |
| | | targetRow = row - 1; |
| | | } else { |
| | | return; |
| | | } |
| | | String zerofill = zerofill(String.valueOf(targetRow), 2)+locNo.substring(2); |
| | | System.out.println(zerofill); |
| | | } |
| | | |
| | | public static String zerofill(String msg, Integer count) { |