|  |  |  | 
|---|
|  |  |  | public String getMapData(@PathVariable("lev") Integer lev) { | 
|---|
|  |  |  | BasMap basMap = basMapService.getOne(new LambdaQueryWrapper<BasMap>().eq(BasMap::getLev, lev).eq(BasMap::getHostId, getHostId())); | 
|---|
|  |  |  | //解析json地图数据 | 
|---|
|  |  |  | List<ArrayList> arrayLists = JSON.parseArray(basMap.getData(), ArrayList.class); | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | List<ArrayList> arrayLists = new ArrayList<>(); | 
|---|
|  |  |  | try{ | 
|---|
|  |  |  | arrayLists = JSON.parseArray(basMap.getData(), ArrayList.class); | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.list(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLev1, lev).eq(LocMast::getHostId, getHostId())); | 
|---|
|  |  |  | for (LocMast locMast : locMasts) { | 
|---|
|  |  |  | Integer row = locMast.getRow1(); | 
|---|
|  |  |  | Integer bay = locMast.getBay1(); | 
|---|
|  |  |  | for (HashMap<String, Integer> lineRow : lineRows) { | 
|---|
|  |  |  | if (row > lineRow.get("start") && row <= lineRow.get("end")) { | 
|---|
|  |  |  | row += lineRow.get("count"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ArrayList rowData = arrayLists.get(row); | 
|---|
|  |  |  | Object o = rowData.get(bay); | 
|---|
|  |  |  | JSONObject jsonObject = JSON.parseObject(o.toString()); | 
|---|
|  |  |  | int value = Integer.parseInt(jsonObject.get("value").toString()); | 
|---|
|  |  |  | if (value >= 0 && value != 3) { | 
|---|
|  |  |  | //只有该行中的任一一列有数据,则不需要创建空白行 | 
|---|
|  |  |  | flag = false; | 
|---|
|  |  |  | if (DISABLE_LOC_NO.contains(locMast.getLocNo())) { | 
|---|
|  |  |  | //禁止库位 | 
|---|
|  |  |  | jsonObject.put("value", 10);//将禁用库位进行设置 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | jsonObject.put("locNo", locMast.getLocNo());//设置库位号 | 
|---|
|  |  |  | jsonObject.put("locSts", locMast.getLocSts());//库位状态 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.list(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLev1, lev).eq(LocMast::getHostId, getHostId())); | 
|---|
|  |  |  | for (LocMast locMast : locMasts) { | 
|---|
|  |  |  | Integer row = locMast.getRow1(); | 
|---|
|  |  |  | Integer bay = locMast.getBay1(); | 
|---|
|  |  |  | for (HashMap<String, Integer> lineRow : lineRows) { | 
|---|
|  |  |  | if (row > lineRow.get("start") && row <= lineRow.get("end")) { | 
|---|
|  |  |  | row += lineRow.get("count"); | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | jsonObject.put("lockLocMast", locMast.getLocType3$()); | 
|---|
|  |  |  | jsonObject.put("batch", "");//批号 | 
|---|
|  |  |  | jsonObject.put("barcode", "");//条码号 | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("R")) { | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locMast.getLocNo()).eq(LocDetl::getHostId, getHostId())); | 
|---|
|  |  |  | if (!locDetls.isEmpty()) { | 
|---|
|  |  |  | LocDetl locDetl = locDetls.get(0); | 
|---|
|  |  |  | jsonObject.put("batch", locDetl.getBatch());//批号 | 
|---|
|  |  |  | jsonObject.put("barcode", locDetl.getBarcode());//条码号 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 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$()); | 
|---|
|  |  |  | jsonObject.put("batch", "");//批号 | 
|---|
|  |  |  | jsonObject.put("barcode", "");//条码号 | 
|---|
|  |  |  | if (locMast.getLocSts().equals("F") || locMast.getLocSts().equals("R")) { | 
|---|
|  |  |  | List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocNo, locMast.getLocNo()).eq(LocDetl::getHostId, getHostId())); | 
|---|
|  |  |  | if (!locDetls.isEmpty()) { | 
|---|
|  |  |  | LocDetl locDetl = locDetls.get(0); | 
|---|
|  |  |  | jsonObject.put("batch", locDetl.getBatch());//批号 | 
|---|
|  |  |  | jsonObject.put("barcode", locDetl.getBarcode());//条码号 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //更新list | 
|---|
|  |  |  | rowData.set(bay, jsonObject); | 
|---|
|  |  |  | arrayLists.set(row, rowData); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新list | 
|---|
|  |  |  | rowData.set(bay, jsonObject); | 
|---|
|  |  |  | arrayLists.set(row, rowData); | 
|---|
|  |  |  | } catch (Exception e){ | 
|---|
|  |  |  | System.out.println("異常:異常原因:"+e.getMessage()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return JSONObject.toJSONString(arrayLists); | 
|---|