| | |
| | | |
| | | public Map<String, Object> getMaterialInfoSv(String processId) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Map<String, Object>> materialList = glassOptimizeMapper.getMaterialInfoSv(processId); |
| | | // List<Map<String, Object>> materialList = glassOptimizeMapper.getMaterialInfoSv(processId); |
| | | List<Map<String, Object>> layoutSet = glassOptimizeMapper.getLayoutSetSv(processId); |
| | | |
| | | // 创建一个Map来存储每个stock_code的总面积 |
| | | Map<String, Double> stockCodeAreaMap = new HashMap<>(); |
| | | // // 创建一个Map来存储每个stock_code的总面积 |
| | | // Map<String, Double> stockCodeAreaMap = new HashMap<>(); |
| | | // |
| | | // // 遍历layoutSet计算每个stock_code的总面积(面积*使用率) |
| | | // for (Map<String, Object> layout : layoutSet) { |
| | | // Object stockCodeObj = layout.get("stock_code"); |
| | | // Object widthObj = layout.get("width"); |
| | | // Object heightObj = layout.get("height"); |
| | | // Object usageRateObj = layout.get("usage_rate"); |
| | | // |
| | | // if (stockCodeObj != null && widthObj != null && heightObj != null && usageRateObj != null) { |
| | | // try { |
| | | // String stockCode = stockCodeObj.toString(); |
| | | // double width = Double.parseDouble(widthObj.toString()); |
| | | // double height = Double.parseDouble(heightObj.toString()); |
| | | // double usageRate = Double.parseDouble(usageRateObj.toString()); |
| | | // |
| | | // // 计算单条数据的面积(平方米) |
| | | // double area = (width * height * usageRate) / 1000000.0; |
| | | // |
| | | // // 累加到对应stock_code的总面积 |
| | | // stockCodeAreaMap.put(stockCode, stockCodeAreaMap.getOrDefault(stockCode, 0.0) + area); |
| | | // } catch (NumberFormatException e) { |
| | | // System.err.println("数据转换错误: " + e.getMessage()); |
| | | // } |
| | | // } |
| | | // } |
| | | // |
| | | // // 将计算出的总面积添加到materialList中对应的物料数据 |
| | | // for (Map<String, Object> material : materialList) { |
| | | // Object stockCodeObj = material.get("code"); |
| | | // if (stockCodeObj != null) { |
| | | // String stockCode = stockCodeObj.toString(); |
| | | // if (stockCodeAreaMap.containsKey(stockCode)) { |
| | | // material.put("totalArea", stockCodeAreaMap.get(stockCode)); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // 遍历layoutSet计算每个stock_code的总面积(面积*使用率) |
| | | for (Map<String, Object> layout : layoutSet) { |
| | | Object stockCodeObj = layout.get("stock_code"); |
| | | Object widthObj = layout.get("width"); |
| | | Object heightObj = layout.get("height"); |
| | | Object usageRateObj = layout.get("usage_rate"); |
| | | |
| | | if (stockCodeObj != null && widthObj != null && heightObj != null && usageRateObj != null) { |
| | | try { |
| | | String stockCode = stockCodeObj.toString(); |
| | | double width = Double.parseDouble(widthObj.toString()); |
| | | double height = Double.parseDouble(heightObj.toString()); |
| | | double usageRate = Double.parseDouble(usageRateObj.toString()); |
| | | |
| | | // 计算单条数据的面积(平方米) |
| | | double area = (width * height * usageRate) / 1000000.0; |
| | | |
| | | // 累加到对应stock_code的总面积 |
| | | stockCodeAreaMap.put(stockCode, stockCodeAreaMap.getOrDefault(stockCode, 0.0) + area); |
| | | } catch (NumberFormatException e) { |
| | | System.err.println("数据转换错误: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 将计算出的总面积添加到materialList中对应的物料数据 |
| | | for (Map<String, Object> material : materialList) { |
| | | Object stockCodeObj = material.get("code"); |
| | | if (stockCodeObj != null) { |
| | | String stockCode = stockCodeObj.toString(); |
| | | if (stockCodeAreaMap.containsKey(stockCode)) { |
| | | material.put("totalArea", stockCodeAreaMap.get(stockCode)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | map.put("materialList", materialList); |
| | | map.put("materialList", layoutSet); |
| | | return map; |
| | | } |
| | | |