Albania_Mes-ui/src/views/home/index.vue | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
springboot-vue3/pom.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Albania_Mes-ui/src/views/home/index.vue
@@ -324,7 +324,7 @@ </el-dialog> <el-dialog :visible.sync="Measure" :title="$t('Measure')" top="5vh"> top="5vh"><!--测量页面--> </el-dialog> <el-dialog :visible.sync="StorageCage" :title="$t('StorageCage')" springboot-vue3/pom.xml
@@ -151,6 +151,29 @@ <version>5.13.1</version> </dependency> <!-- <dependency> <groupId>net.sourceforge.jexcelapi</groupId> <artifactId>jxl</artifactId> <version>2.6.12</version> </dependency> --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml-schemas</artifactId> <version>4.1.2</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> @@ -176,6 +199,9 @@ <artifactId>jackson-annotations</artifactId> <version>2.13.0</version> </dependency> </dependencies> <build> springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.List; import com.example.springboot.service.*; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import com.example.springboot.entity.GlassInfo; @@ -129,9 +131,30 @@ //double width=plcmes.getPlcParameter("Height").getValue();//宽 //double height=plcmes.getPlcParameter("width").getValue();//高 //获取测量的长,宽 String url="C:\\Users\\SNG-ZDH-012\\Desktop\\阿尔巴尼亚数据要求.xlsx"; //List typecount= HomeService.ReadExecl2(s); // List xiaopian=HomeService.ReadExecl2(s); // //xiaopian NG1{A:10,B20} NG2{A:5,B5} // for(Object C:xiaopian){ // //看层数 // } // for(int i=0;i<result.size();i++){ // System.out.println(result.get(i)); // } List result= HomeService.ReadExecl(url); for(int i=0;i<result.size();i++){ System.out.println(result.get(i)); } String PlcRequest = "1"; double width = 402; double height = 402; //获取匹配设置 if ("1".equals(PlcRequest)) { List<GlassInfo> Result=HomeService.NormalGlassInfo(width, height, "1"); springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -18,10 +18,10 @@ System.out.println("启动完成"); // new PlcHold().start(); new PlcHoldNew().start(); //new PlcHoldNew().start(); // new PLCAutoMes().start(); //new Plchome().start(); new Plchome().start(); // new PlcLayout().start(); // new Plcalarm().start(); springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java
@@ -1,8 +1,21 @@ package com.example.springboot.service; import java.io.File; import java.io.FileInputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,7 +38,7 @@ // 匹配玻璃 宽,高,线路 public List<GlassInfo> NormalGlassInfo(double width, double height, String line) { // List<GlassInfo> Results=new ArrayList<GlassInfo>(); List<GlassInfo> Results = new ArrayList<GlassInfo>(); // 获取匹配设置 MeasureSetting MeasureSetting = MeasureSettingMapper.SelectMeasureSetting(line); if (height > 0 && width > 0 && MeasureSetting != null) { @@ -47,4 +60,65 @@ } return Results; } //Execl表格 传入文件路径 public List ReadExecl(String filename) { try { // 创建文件对象 File file = new File(filename); // 创建文件输入流对象 FileInputStream inputStream = new FileInputStream(file); // 创建工作簿对象 Workbook workbook = WorkbookFactory.create(inputStream); // 获取第一个工作表对象 Sheet sheet = workbook.getSheetAt(0); // 创建一个实体类集合,用于存储Excel数据 List Results=new ArrayList(); int i=0; // 遍历行 for (Row row : sheet) { // 遍历单元格 List ResultRow=new ArrayList(); //System.out.println(); for (Cell cell : row) { String LastCellvalue=""; // 判断单元格类型是否为公式类型 if (cell.getCellType() == CellType.FORMULA) { // 使用公式计算器计算单元格的值 FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); CellValue cellValue = evaluator.evaluate(cell); // 计算后的单元格值 LastCellvalue=cellValue.getNumberValue()+""; }else if(cell.getCellType() == CellType.NUMERIC){ double value = cell.getNumericCellValue(); if (value%1==0) { LastCellvalue=Math.round(value)+""; }else{ LastCellvalue=value+""; } } else { // 单元格值 LastCellvalue=cell.toString(); } ResultRow.add(LastCellvalue); //System.out.print(LastCellvalue+" "); } Results.add(ResultRow); i++; } System.out.println(i); // 关闭工作簿和输入流对象 workbook.close(); inputStream.close(); return Results; } catch (Exception e) { // TODO: handle exception System.out.println("异常"); return new ArrayList(); } } }