src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/model/Shelves.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/common/service/DoubleDeepService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java
@@ -44,7 +44,7 @@ } } // 库位检索 String locNo = doubleDeepService.getLocNo(); String locNo = doubleDeepService.getLocNo(1); // if (staNo == null || staNo.get) src/main/java/com/zy/common/model/Shelves.java
New file @@ -0,0 +1,98 @@ package com.zy.common.model; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Created by vincent on 2020/6/11 */ public class Shelves { // 货架排数量 private final int size; // 货架组数量 private final int group; // 偏移量[default:0] private int offset = 0; // 货架实例节点 private List<List<Integer>> nodes; public Shelves(int size, int group) { this(size, group, 0); } public Shelves(int size, int group, int offset) { this.size = size; this.group = group; this.offset = offset; init(); } /** * 初始化 */ private void init(){ if (group == 0 || size%group != 0) { throw new RuntimeException("shelves init fail!"); } nodes = new ArrayList<>(); for (int g = 1; g <= this.group; g++){ // 1 2 int unit = size/group; // 4 List<Integer> node = new ArrayList<>(); for (int i = (g-1)*unit+1+offset ; i <= g*unit+offset; i++){ node.add(i); } nodes.add(node); } } /** * * @param curSeq 当前货架号 * @return 规则命中货架号 */ public int start(int curSeq){ Iterator<List<Integer>> iterator = nodes.iterator(); while (iterator.hasNext()){ List<Integer> node = iterator.next(); if (node.contains(curSeq)) { int idx = node.indexOf(curSeq); // 是否为末尾货架 if (iterator.hasNext()) { return iterator.next().get(idx); } else { List<Integer> first = nodes.get(0); Integer val = first.get(idx); int res = size /group + 1 + offset - val; // 反向命中货架时不再是对立下标(相对于巷道) if (res < val) { // 轮询所有货架后重新开始定位 if (val - res - offset == 1) { return first.get(0); } res = res + 1; } return res + offset; } } } return 0; } public static void main(String[] args) throws InterruptedException { Shelves shelves = new Shelves(4,2); System.out.println(shelves.nodes.toString()); int start = 1; while (true) { System.out.println(start); start = shelves.start(start); Thread.sleep(500L); } } } src/main/java/com/zy/common/service/DoubleDeepService.java
@@ -1,10 +1,14 @@ package com.zy.common.service; import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.entity.RowLastno; import com.zy.asrs.entity.WrkLastno; import com.zy.asrs.entity.WrkMast; import com.zy.asrs.service.RowLastnoService; import com.zy.asrs.service.WrkLastnoService; import com.zy.asrs.service.WrkMastService; import com.zy.common.model.Shelves; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,6 +23,8 @@ private WrkMastService wrkMastService; @Autowired private WrkLastnoService wrkLastnoService; @Autowired private RowLastnoService rowLastnoService; /** * 生成工作号 @@ -27,43 +33,66 @@ */ public int getWorkNo(Integer wrkMk) { WrkLastno wrkLastno = wrkLastnoService.selectById(wrkMk); if (Cools.isEmpty(wrkLastno)) { throw new CoolException("数据异常,请联系管理员"); } int workNo = 0; // 入出库类型 if (wrkLastno.getWrkMk() == 0) { if (!Cools.isEmpty(wrkLastno)){ workNo = wrkLastno.getWrkNo(); int sNo = wrkLastno.getSNo(); int eNo = wrkLastno.getENo(); workNo = wrkLastno.getWrkNo(); int sNo = wrkLastno.getSNo(); int eNo = wrkLastno.getENo(); workNo = workNo>=eNo ? sNo : workNo+1; workNo = workNo>=eNo ? sNo : workNo+1; while (true) { WrkMast wrkMast = wrkMastService.selectById(workNo); if (null != wrkMast) { workNo = workNo>=eNo ? sNo : workNo+1; } else { break; } } if (workNo > 0){ // todo wrkLastno.setWrkNo(workNo); wrkLastnoService.updateById(wrkLastno); while (true) { WrkMast wrkMast = wrkMastService.selectById(workNo); if (null != wrkMast) { workNo = workNo>=eNo ? sNo : workNo+1; } else { break; } } if (workNo > 0){ // todo wrkLastno.setWrkNo(workNo); wrkLastnoService.updateById(wrkLastno); } } return workNo; } /** * 检索库位号 * @param * @return * @param whsType 类型 1:双深式货架 * @return locNo 检索到的库位号 */ public String getLocNo() { return null; public String getLocNo(Integer whsType) { RowLastno rowLastno = rowLastnoService.selectById(whsType); if (Cools.isEmpty(rowLastno)) { throw new CoolException("数据异常,请联系管理员"); } String locNo = null; if (rowLastno.getWhsType() == 1){ int curRow = rowLastno.getCurrentRow(); int sRow = rowLastno.getsRow(); int eRow = rowLastno.geteRow(); int crn_qty = rowLastno.getCrnQty(); Shelves shelves = new Shelves(8, crn_qty); curRow = shelves.start(curRow); if (curRow != 0) { rowLastno.setCurrentRow(curRow); rowLastnoService.updateById(rowLastno); } } return locNo; } } }