| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.serializer.SerializerFeature; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.enums.MapExcelNodeType; |
| | | import com.zy.common.model.MapNode; |
| | | import com.zy.core.enums.MapNodeType; |
| | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @Component |
| | | public class MapExcelUtils { |
| | |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | MapNode node = new MapNode(); |
| | | node.setId(row + "-" + bay); |
| | | node.setRow(row); |
| | | node.setBay(bay); |
| | | |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | String nodeType = nodeData.get("bgColor").toString(); |
| | |
| | | mapList.add(rows); |
| | | } |
| | | |
| | | MapNode baseMapNode = null; |
| | | //生成小车地图坐标间距数据 |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | |
| | | Integer left = bayData.getInteger("left"); |
| | | Integer right = bayData.getInteger("right"); |
| | | |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("top")) { |
| | | top = jsonData.getInteger("top"); |
| | | } |
| | | if (jsonData.containsKey("bottom")) { |
| | | bottom = jsonData.getInteger("bottom"); |
| | | } |
| | | if (jsonData.containsKey("left")) { |
| | | left = jsonData.getInteger("left"); |
| | | } |
| | | if (jsonData.containsKey("right")) { |
| | | right = jsonData.getInteger("right"); |
| | | } |
| | | |
| | | if (jsonData.containsKey("xBase")) { |
| | | //基点 |
| | | baseMapNode = mapNode; |
| | | } |
| | | } |
| | | |
| | | mapNode.setTop(top); |
| | | mapNode.setBottom(bottom); |
| | | mapNode.setLeft(left); |
| | |
| | | } |
| | | } |
| | | |
| | | //生成牛眼Y坐标基准数据 |
| | | if (baseMapNode == null) { |
| | | throw new CoolException("未设置基准点"); |
| | | } |
| | | |
| | | List<Integer> rowList = new ArrayList<>(); |
| | | List<Integer> bayList = new ArrayList<>(); |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | rowList.add(row); |
| | | } |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | bayList.add(bay); |
| | | } |
| | | |
| | | if (baseMapNode.getRow() != 1) { |
| | | Collections.reverse(rowList); |
| | | } |
| | | |
| | | if (baseMapNode.getBay() != 1) { |
| | | Collections.reverse(bayList); |
| | | } |
| | | |
| | | //生成牛眼Y坐标基准数据 |
| | | for (int i = 0; i < bayList.size(); i++) { |
| | | Integer bay = bayList.get(i); |
| | | int yBase = 10000; |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | for (int j = 0; j < rowList.size(); j++) { |
| | | Integer row = rowList.get(j); |
| | | MapNode mapNode = mapList.get(row - 1).get(bay - 1); |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | |
| | | JSONObject rowData = rowMap.get(row); |
| | | Integer bottom = rowData.getInteger("bottom"); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("bottom")) { |
| | | bottom = jsonData.getInteger("bottom"); |
| | | } |
| | | } |
| | | |
| | | if (row != 1) { |
| | | yBase += bottom; |
| | | } |
| | | mapNode.setYBase(yBase); |
| | | |
| | | if (baseMapNode.getRow() == 1) { |
| | | yBase += mapNode.getBottom(); |
| | | }else { |
| | | yBase += mapNode.getTop(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //生成牛眼X坐标基准数据 |
| | | for (int row = 1; row <= finalRow; row++) { |
| | | for (int i = 0; i < rowList.size(); i++) { |
| | | Integer row = rowList.get(i); |
| | | int xBase = 10000; |
| | | for (int bay = 1; bay <= finalBay; bay++) { |
| | | for (int j = 0; j < bayList.size(); j++) { |
| | | Integer bay = bayList.get(j); |
| | | MapNode mapNode = mapList.get(row - 1).get(bay - 1); |
| | | HashMap<String, Object> nodeData = excelData.get(row + 1).get(bay + 1); |
| | | |
| | | JSONObject bayData = bayMap.get(bay); |
| | | Integer right = bayData.getInteger("right"); |
| | | String nodeValue = nodeData.get("value").toString(); |
| | | if (Utils.isJSON(nodeValue)) { |
| | | JSONObject jsonData = JSON.parseObject(nodeValue); |
| | | if (jsonData.containsKey("right")) { |
| | | right = jsonData.getInteger("right"); |
| | | } |
| | | } |
| | | |
| | | if (bay != 1) { |
| | | xBase += right; |
| | | } |
| | | mapNode.setXBase(xBase); |
| | | |
| | | if (baseMapNode.getBay() == 1) { |
| | | xBase += mapNode.getRight(); |
| | | }else { |
| | | xBase += mapNode.getLeft(); |
| | | } |
| | | } |
| | | } |
| | | |