From 1dac1ea1fa04f562a75292070a828ba1a44d143f Mon Sep 17 00:00:00 2001 From: LSH Date: 星期四, 28 十二月 2023 16:39:12 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/MapController.java | 165 ++++++++++++++++--------------------------------------- 1 files changed, 48 insertions(+), 117 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/MapController.java b/src/main/java/com/zy/asrs/controller/MapController.java index 5bcad57..487c9d1 100644 --- a/src/main/java/com/zy/asrs/controller/MapController.java +++ b/src/main/java/com/zy/asrs/controller/MapController.java @@ -11,11 +11,11 @@ import com.zy.asrs.utils.Utils; import com.zy.common.web.BaseController; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; import org.springframework.web.bind.annotation.*; import java.io.*; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; @RestController @@ -28,30 +28,14 @@ private LocDetlService locDetlService; private static final List<String> DISABLE_LOC_NO = new ArrayList<String>() {{ - }}; - @GetMapping("/map/getData/auth") + @GetMapping("/map/getData/{lev}/auth") @ManagerAuth - public String getMapData(@RequestParam Integer lev,@RequestParam Integer area) { + public String getMapData(@PathVariable("lev") Integer lev) { try { String mapFilename = "map.json"; -// String fileName ="file:" + new ClassPathResource(mapFilename).getPath(); - //鑾峰彇褰撳墠妤煎眰搴撲綅鏁版嵁 - List<LocMast> locMasts = locMastService.selectLocByLev(lev); - switch (area){ - case 1: - break; - case 2: - case 3: - case 4: - case 5: - mapFilename = "DTDnode.json"; - locMasts = locMastService.selectNodeLocByLev(lev); - break; - } String fileName = this.getClass().getClassLoader().getResource(mapFilename).getPath();//鑾峰彇鏂囦欢璺緞 -// File file = new File("D:\\workspace\\zy-asrs\\src\\main\\resources\\map.json"); File file = new File(fileName); StringBuffer stringBuffer = new StringBuffer(); if (file.isFile() && file.exists()) { @@ -65,114 +49,61 @@ //瑙f瀽json鍦板浘鏁版嵁 List<ArrayList> arrayLists = JSON.parseArray(stringBuffer.toString(), ArrayList.class); - for (String locNo : DISABLE_LOC_NO) {//绂佺敤璁剧疆搴撲綅 - int row = Utils.getRow(locNo); - int bay = Utils.getBay(locNo); - if (row >= 2 && row <= 12) { - row++; - }else if (row == 13) { - row += 2; + ArrayList<HashMap<String, Integer>> lineRows = new ArrayList<>(); + int dataRow = 0; + int dataRowCount = 0; + for (int i = 1; i < arrayLists.size(); i++) { + boolean flag = true; + ArrayList rows = arrayLists.get(i); + for (int j = 1; j < rows.size() - 1; j++) { + Object o = rows.get(j); + JSONObject jsonObject = JSON.parseObject(o.toString()); + int value = Integer.parseInt(jsonObject.get("value").toString()); + if (value >= 0 && value != 3) { + //鍙湁璇ヨ涓殑浠讳竴涓�鍒楁湁鏁版嵁锛屽垯涓嶉渶瑕佸垱寤虹┖鐧借 + flag = false; + } } - ArrayList rowData = arrayLists.get(row); - Object o = rowData.get(bay); - JSONObject jsonObject = JSON.parseObject(o.toString()); - jsonObject.put("value", 10);//灏嗙鐢ㄥ簱浣嶈繘琛岃缃� - //鏇存柊list - rowData.set(bay, jsonObject); - arrayLists.set(row, rowData); + + if (flag) { + //绌虹櫧琛岄渶瑕佽烦杩� + HashMap<String, Integer> map = new HashMap<>(); + map.put("start", dataRow); + int end = i - 1 - dataRowCount; + map.put("end", end); + map.put("count", dataRowCount); + dataRow = end; + dataRowCount++; + lineRows.add(map); + } } - + //鑾峰彇褰撳墠妤煎眰搴撲綅鏁版嵁 + List<LocMast> locMasts = locMastService.selectLocByLev(lev); for (LocMast locMast : locMasts) { Integer row = locMast.getRow1(); Integer bay = locMast.getBay1(); - - switch (area){ - case 1: - if (row % 4 == 0 || (row+1) % 4 == 0) { - row=row+locMast.getCrnNo(); - }else{ - row=row+locMast.getCrnNo()-1; - } - bay=32-bay; + for (HashMap<String, Integer> lineRow : lineRows) { + if (row > lineRow.get("start") && row <= lineRow.get("end")) { + row += lineRow.get("count"); break; - case 2: - case 3: - case 4: - case 5: - if (bay % 7 == 0) { - bay=bay+1; - }else{ - if (bay>7){ - bay=bay+locMast.getCrnNo(); - }else { - bay=bay+locMast.getCrnNo()-1; - } - } - if (row == 3){ - row = row +1; - } else if (row == 5) { - row = row+2; - } else if (row ==8) { - row = row+3; - } - else if (row ==10) { - row = row+4; - } - else if (row ==13) { - row = row+5; - }else if (row ==14) { - row = row+6; - }else { - if (row >3){ - row = row +1; - } - if (row > 5){ - row = row +1; - } - if (row > 8){ - row = row +1; - } - if (row > 10){ - row = row +1; - } - if (row > 13){ - row = row +1; - } - if (row > 14){ - row = row +1; - } - } - - - + } } - - if (area == 1){ - ArrayList rowData = arrayLists.get(row); - Object o = rowData.get(bay); - JSONObject jsonObject = JSON.parseObject(o.toString()); - jsonObject.put("locNo", locMast.getLocNo());//璁剧疆搴撲綅鍙� - jsonObject.put("locSts", locMast.getLocSts());//搴撲綅鐘舵�� - //jsonObject.put("locSts$", locMast.getLocSts$());//搴撲綅鐘舵�� - //鏇存柊list - rowData.set(bay, jsonObject); - arrayLists.set(row, rowData); - }else { - ArrayList rowData = arrayLists.get(bay); - Object o = rowData.get(row); - JSONObject jsonObject = JSON.parseObject(o.toString()); - jsonObject.put("locNo", locMast.getLocNo());//璁剧疆搴撲綅鍙� - jsonObject.put("locSts", locMast.getLocSts());//搴撲綅鐘舵�� - //jsonObject.put("locSts$", locMast.getLocSts$());//搴撲綅鐘舵�� - //鏇存柊list - rowData.set(row, jsonObject); - arrayLists.set(bay, rowData); + ArrayList rowData = arrayLists.get(row); + Object o = rowData.get(bay); + JSONObject jsonObject = JSON.parseObject(o.toString()); + if (DISABLE_LOC_NO.contains(locMast.getLocNo())) { + //绂佹搴撲綅 + jsonObject.put("value", 10);//灏嗙鐢ㄥ簱浣嶈繘琛岃缃� } + jsonObject.put("locNo", locMast.getLocNo());//璁剧疆搴撲綅鍙� + jsonObject.put("locSts", locMast.getLocSts());//搴撲綅鐘舵�� + jsonObject.put("lockLocMast", locMast.getLocType3$()); - - + //鏇存柊list + rowData.set(bay, jsonObject); + arrayLists.set(row, rowData); } return JSONObject.toJSONString(arrayLists); @@ -194,7 +125,7 @@ @RequestParam("matnr") String matnr, @RequestParam("maktx") String maktx ) { - List<LocDetl> locDetls = locDetlService.searchByLike(orderNo, matnr, maktx, specs, ""); + List<LocDetl> locDetls = locDetlService.searchByLike(orderNo, matnr, maktx, specs, locNo); ArrayList<LocDetl> lists = new ArrayList<>(); for (LocDetl locDetl : locDetls) {//杩囨护鎺変笉鏄綋鍓嶆ゼ灞傜殑鏁版嵁 int lev1 = Utils.getLev(locDetl.getLocNo()); -- Gitblit v1.9.1