| | |
| | | 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 |
| | |
| | | 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: |
| | | mapFilename = "DTBnode.json"; |
| | | locMasts = locMastService.selectNodeBLocByLev(lev); |
| | | break; |
| | | case 4: |
| | | mapFilename = "DTCnode.json"; |
| | | locMasts = locMastService.selectNodeCLocByLev(lev); |
| | | break; |
| | | case 5: |
| | | mapFilename = "DTDnode.json"; |
| | | locMasts = locMastService.selectNodeDLocByLev(lev); |
| | | break; |
| | | case 32: |
| | | mapFilename = "DTBnode.json"; |
| | | locMasts = locMastService.selectNodeB2LocByLev(lev); |
| | | break; |
| | | case 42: |
| | | mapFilename = "DTCnode.json"; |
| | | locMasts = locMastService.selectNodeC2LocByLev(lev); |
| | | break; |
| | | case 52: |
| | | mapFilename = "DTDnode.json"; |
| | | locMasts = locMastService.selectNodeD2LocByLev(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()) { |
| | |
| | | |
| | | //解析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 32: |
| | | if (row<=3 || row>=5){ |
| | | if (row%1==0){ |
| | | row=row+(row/1)-1; |
| | | }else { |
| | | row=row+((row+1)/1)-1; |
| | | } |
| | | }else { |
| | | if (row%2==0){ |
| | | row=row+(row/2); |
| | | }else { |
| | | row=row+((row-1)/2); |
| | | } |
| | | } |
| | | |
| | | if (bay % 6 == 0) { |
| | | bay=bay+1; |
| | | }else{ |
| | | if (bay>6){ |
| | | bay=bay+locMast.getCrnNo(); |
| | | }else { |
| | | bay=bay+locMast.getCrnNo()-1; |
| | | } |
| | | } |
| | | break; |
| | | case 4: |
| | | case 5: |
| | | case 42: |
| | | case 52: |
| | | if (row<=11){ |
| | | if (row%2==0){ |
| | | row=row+(row/2)-1; |
| | | }else { |
| | | row=row+((row+1)/2)-1; |
| | | } |
| | | }else { |
| | | if (row%2==0){ |
| | | row=row+(row/2); |
| | | }else { |
| | | row=row+((row-1)/2); |
| | | } |
| | | } |
| | | |
| | | if (bay % 7 == 0) { |
| | | bay=bay+1; |
| | | }else{ |
| | | if (bay>7){ |
| | | bay=bay+locMast.getCrnNo(); |
| | | }else { |
| | | bay=bay+locMast.getCrnNo()-1; |
| | | } |
| | | } |
| | | break; |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | 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); |
| | |
| | | @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()); |