From 28ded8102d83cf74bc232d1cdfc89b7f22c41952 Mon Sep 17 00:00:00 2001 From: wu <731351411@qq.com> Date: 星期二, 03 十二月 2024 09:09:31 +0800 Subject: [PATCH] 增加点击防抖事件 增加笼子使用详情的计算优化。 增加数据推送时的报错处理 测量台交互逻辑增加 参数界面增加翻转加减速度 --- springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java | 126 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 123 insertions(+), 3 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java b/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java index 452b8eb..dc2982d 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java +++ b/springboot-vue3/src/main/java/com/example/springboot/service/HomeService.java @@ -1,13 +1,27 @@ 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; import com.example.springboot.entity.GlassInfo; import com.example.springboot.entity.MeasureSetting; +import com.example.springboot.entity.Queue; import com.example.springboot.mapper.GlassInfoMapper; import com.example.springboot.mapper.MeasureSettingMapper; import com.example.springboot.mapper.QueueMapper; @@ -25,17 +39,26 @@ // 鍖归厤鐜荤拑 瀹斤紝楂橈紝绾胯矾 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); + System.out.println("鑾峰彇鍖归厤璁剧疆:"+MeasureSetting); if (height > 0 && width > 0 && MeasureSetting != null) { // 鏈夋晥鍙傛暟 璇锋眰=1 闀�/瀹�>0 double maxheight = height + MeasureSetting.getErrorHeight(); double minheight = height - MeasureSetting.getErrorHeight(); double maxwidth = width + MeasureSetting.getErrorWidth(); double minwidth = width - MeasureSetting.getErrorWidth(); - // 鏌ヨ褰撳墠娴嬮噺鏁版嵁 - List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight); + Integer Thickness = MeasureSetting.getThickness(); + String Films = MeasureSetting.getFilms(); + // 鏌ヨ褰撳墠娴嬮噺鏁版嵁 + List<GlassInfo> GlassInfos = GlassInfoMapper.selectGlassInfos(maxwidth, minwidth, maxheight, minheight,Thickness,Films); + System.out.println("鍘氬害"+Thickness+"鑶�"+Films); + System.out.println("GlassInfos鏁伴噺:"+GlassInfos.size()); + if(Thickness==0||Films==""){ + System.out.println("鍘氬害"+Thickness+"鑶�"+Films); + return null; + } List types = new ArrayList<>(); for (int i = 0; i < GlassInfos.size(); i++) { Integer glasstype = GlassInfos.get(i).getGlasstype(); @@ -47,4 +70,101 @@ } return Results; } + + // 鍖归厤閫昏緫 + public boolean Normal(double width, double height, String line) { + List<Queue> ErrowQueues= QueueMapper.selectErrorQueues(); + if (ErrowQueues.size()>0) { + System.out.println("鏈夊尮閰嶅け璐ユ暟鎹湭鍘婚櫎"); + return false; + } + //鏌ヨ褰撳墠棰嗗彇鐨勪换鍔� + List<GlassInfo> Result = NormalGlassInfo(width, height, "1"); + System.out.println("Result:"+Result); + if (Result.size() == 1) { + // 鍖归厤鎴愬姛 灏变竴绉嶇被鍨� 娣诲姞鏁版嵁 + GlassInfo GlassInfo = Result.get(0); + int insertCount=QueueMapper.insert(GlassInfo.getId(), width, height, 1); + GlassInfoMapper.updatemeasurenumber(GlassInfo.getId()); + + System.out.println("娣诲姞鏉℃暟锛�"+insertCount); + System.out.println("鍖归厤鎴愬姛娴嬮噺瀹介珮:"+width+" "+height); + System.out.println(GlassInfo.getGlassid()); + return true; + } else if (Result.size() > 1) { + // 鍖归厤澶辫触 鍖归厤鍒板鏉$鍚堢殑鏁版嵁 娣诲姞鏁版嵁 + QueueMapper.insertMatchFailure(width, height, 0); + System.out.println("鍖归厤澶辫触"); + + } else { + // 鍖归厤澶辫触 鏈壘鍒扮鍚堢殑鏁版嵁 娣诲姞鏁版嵁 + QueueMapper.insertMatchFailure(width, height, -1); + System.out.println("鏈壘鍒扮鍚堢殑鏁版嵁"); + } + return false; + } + + // Execl琛ㄦ牸 浼犲叆鏂囦欢璺緞 + public List ReadExecl(String filename) { + try { + // 鍒涘缓鏂囦欢瀵硅薄 + File file = new File(filename); + if (!file.exists()) { + System.out.println("鏂囦欢涓嶅瓨鍦紒 "+filename); + return new ArrayList<>(); + } + // 鍒涘缓鏂囦欢杈撳叆娴佸璞� + FileInputStream inputStream = new FileInputStream(file); + // 鍒涘缓宸ヤ綔绨垮璞� + Workbook workbook = WorkbookFactory.create(inputStream); + // 鑾峰彇绗竴涓伐浣滆〃瀵硅薄 + Sheet sheet = workbook.getSheetAt(0); + // 鍒涘缓涓�涓疄浣撶被闆嗗悎锛岀敤浜庡瓨鍌‥xcel鏁版嵁 + + 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(); + } + + } + } -- Gitblit v1.8.0