| | |
| | | <template> |
| | | <div> |
| | | <el-button id="button" type="primary" @click="printReports" style="background: #409eff; position: fixed; top: 90px; right: 100px; padding: 20px; color: white; border: none; cursor: pointer; margin-right: 10px;"> |
| | | <el-button id="button" type="primary" @click="printReports" style="background: #409eff; position: fixed; top: 90px; right: 90px; padding: 20px; color: white; border: none; cursor: pointer; margin-right: 10px;"> |
| | | 预览 |
| | | </el-button> |
| | | <el-button id="button" type="primary" @click="handlePrint" style="position: fixed; top: 90px; right: 20px; padding: 20px; background: #409eff; color: white; border: none; border-radius: 5px; cursor: pointer;"> |
| | |
| | | .then((res) => { |
| | | if (res.code == 200) { |
| | | try { |
| | | materialList.value = res.data.materialList[0]; |
| | | console.log('reportData:', materialList.value); |
| | | materialList.value = res.data.materialList; |
| | | console.log('materialList:', materialList.value); |
| | | } catch (error) { |
| | | console.error("解析布局数据失败:", error); |
| | | } |
| | |
| | | printLayouts : config.printLayouts ? '1' : '0', |
| | | printReport : config.printReport ? '1' : '0', |
| | | layouts : layoutData.value, |
| | | reportData: reportData.value, |
| | | materialList: materialList.value, |
| | | productList: productList.value, |
| | | reportData:{ |
| | | rectangleQuantity: reportData.value.rectangleQuantity, |
| | | otherShapeQuantity: reportData.value.otherShapeQuantity, |
| | | rectangleArea: reportData.value.rectangleArea, |
| | | otherShapeArea: reportData.value.otherShapeArea, |
| | | rectanglePerimeter: reportData.value.rectanglePerimeter, |
| | | otherShapePerimeter: reportData.value.otherShapePerimeter, |
| | | materialList: materialList.value, |
| | | productList: productList.value, |
| | | }, |
| | | layoutSet: { |
| | | layoutRows: layoutRowsMap[config.rowTypes] || 1, |
| | | layoutColumns: layoutColumnsMap[config.columnTypes] || 1, |
| | |
| | | List<Map<String, Object>> selectProjectList(String processId); |
| | | |
| | | List<Map<String, Object>> materialOptimizeUse(String processId); |
| | | |
| | | List<Map<String, Object>> getLayoutSetSv(String processId); |
| | | } |
| | |
| | | |
| | | public Map<String, Object> getMaterialInfoSv(String processId) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("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<>(); |
| | | |
| | | // 遍历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); |
| | | return map; |
| | | } |
| | | |
| | | |
| | | public Map<String, Object> getProductListSv(String processId) { |
| | | Map<String, Object> productMap = new HashMap<>(); |
| | | List<Map<String, Object>> productInfo = glassOptimizeMapper.selectProjectList(processId); |
| | |
| | | #{projectId}, |
| | | #{glass.stockCode}, |
| | | 1, |
| | | #{glass.width}, |
| | | #{glass.height}, |
| | | #{glass.width}+#{glass.leftTrim}+#{glass.rightTrim}, |
| | | #{glass.height}+#{glass.downTrim}+#{glass.upTrim}, |
| | | #{glass.count}, |
| | | #{glass.count}, |
| | | 1, |
| | |
| | | ou.use_count AS quantity, |
| | | ou.width, |
| | | ou.height, |
| | | ou.width*ou.height*ou.use_count/1000000.0 as useArea, |
| | | op.glass_total_area as totalArea |
| | | ou.width*ou.height*ou.use_count/1000000.0 as useArea |
| | | FROM |
| | | pp.optimize_use ou |
| | | INNER JOIN pp.optimize_project op on ou.project_no = op.project_no |
| | | WHERE |
| | | ou.project_no = #{processId} and ou.state=1 |
| | | </select> |
| | |
| | | from pp.optimize_use ou |
| | | left join mm.material_store ms on ou.raw_stock_code=ms.id where project_no=#{projectNumber} and state=1 |
| | | </select> |
| | | <select id="getLayoutSetSv" resultType="java.util.Map"> |
| | | SELECT |
| | | project_no, |
| | | width,height, |
| | | usage_rate, |
| | | stock_code |
| | | FROM |
| | | pp.optimize_layout |
| | | WHERE |
| | | project_no = #{processId} |
| | | </select> |
| | | |
| | | |
| | | </mapper> |