From d7963a84282c548fee3595b3343e6ae6ca49bb29 Mon Sep 17 00:00:00 2001 From: yn147 <2270338776@qq.com> Date: 星期五, 24 十一月 2023 14:12:01 +0800 Subject: [PATCH] 学籍,考勤 --- src/main/java/com/qxueyou/scc/exercise/service/impl/ExercisePyService.java | 56 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/exercise/service/impl/ExercisePyService.java b/src/main/java/com/qxueyou/scc/exercise/service/impl/ExercisePyService.java index c3db240..88f426d 100644 --- a/src/main/java/com/qxueyou/scc/exercise/service/impl/ExercisePyService.java +++ b/src/main/java/com/qxueyou/scc/exercise/service/impl/ExercisePyService.java @@ -58,7 +58,7 @@ private static Logger log = LogManager.getLogger("ExercisePyService"); /** - * 上传解析 + * 涓婁紶瑙f瀽 */ public Map<String, Object> parserPyExercise(String groupId, String fullPath, String module) { @@ -67,7 +67,7 @@ List<String> lst = generateLstFromFile(file, fullPath); if (null == lst || lst.isEmpty()) { - return CollectionUtils.newObjectMap("resultCode",0,"msg","文档解析内容为空"); + return CollectionUtils.newObjectMap("resultCode",0,"msg","鏂囨。瑙f瀽鍐呭涓虹┖"); } return exerciseParsePy(lst, fullPath); @@ -75,10 +75,10 @@ } /** - * 校验 + * 鏍¢獙 * * @param content - * 习题文本内容 + * 涔犻鏂囨湰鍐呭 * @return */ public Map<String, Object> validatePyExercise(String content) { @@ -93,9 +93,9 @@ lst.add(arrLine[i]); } - // 判断:是否为空 + // 鍒ゆ柇锛氭槸鍚︿负绌� if (null == lst || lst.isEmpty()) { - return CollectionUtils.newObjectMap("resultCode",0,"msg","文档解析内容为空"); + return CollectionUtils.newObjectMap("resultCode",0,"msg","鏂囨。瑙f瀽鍐呭涓虹┖"); } return exerciseParsePy(lst, "" ); @@ -105,7 +105,7 @@ public Result doImportPyExercise(List<ExerciseItemData> lstItems,String groupId) { if(null == lstItems || lstItems.isEmpty()){ - return new Result(false, "没有记录"); + return new Result(false, "娌℃湁璁板綍"); } ExerciseGroupItemRe re ; @@ -175,11 +175,11 @@ new Object[]{ iCount,ClientUtils.getUserId(), ClientUtils.getUserName(), groupId } ); } catch (Exception e) { - log.error("解析习题copyProperties 失败:" ,e ); - return new Result(false , "服务器内部转换错误"); + log.error("瑙f瀽涔犻copyProperties 澶辫触锛�" ,e ); + return new Result(false , "鏈嶅姟鍣ㄥ唴閮ㄨ浆鎹㈤敊璇�"); } - return new Result(true , "成功导入" + iCount + "道习题"); + return new Result(true , "鎴愬姛瀵煎叆" + iCount + "閬撲範棰�"); } @@ -192,7 +192,7 @@ } /** - * post传参 + * post浼犲弬 * @param key * @param size * @return @@ -207,7 +207,7 @@ /** - * 缓存版本 + * 缂撳瓨鐗堟湰 * @param key * @param size * @return @@ -255,7 +255,7 @@ } } } catch (Exception e) { - log.error("解析练习txt文档失败:" + fullPath, e); + log.error("瑙f瀽缁冧範txt鏂囨。澶辫触锛�" + fullPath, e); } finally { IOUtils.closeQuietly(br); IOUtils.closeQuietly(reader); @@ -269,7 +269,7 @@ } /** - * 从office转换到txt:2007转换:自带序号格式会丢失;2003会解析出来 + * 浠巓ffice杞崲鍒皌xt锛�2007杞崲锛氳嚜甯﹀簭鍙锋牸寮忎細涓㈠け锛�2003浼氳В鏋愬嚭鏉� * * @param file * @return @@ -285,7 +285,7 @@ if ("doc".equals(fileExtention)) { WordExtractor extractor = new WordExtractor(is); - // 获取Word文件中的文本+自带序号 + // 鑾峰彇Word鏂囦欢涓殑鏂囨湰+鑷甫搴忓彿 strText = extractor.getText(); extractor.close(); } else if ("docx".equals(fileExtention)) { @@ -293,18 +293,18 @@ .getAbsolutePath()); POIXMLTextExtractor extractor = new XWPFWordExtractor( opcPackage); - // 只能获取Word文件中的文本,不能取到office序号 + // 鍙兘鑾峰彇Word鏂囦欢涓殑鏂囨湰锛屼笉鑳藉彇鍒皁ffice搴忓彿 strText = extractor.getText(); extractor.close(); } else { - throw new RuntimeException("文件格式错误, 请上传word文档(.doc及.docx)格式", + throw new RuntimeException("鏂囦欢鏍煎紡閿欒, 璇蜂笂浼爓ord鏂囨。锛�.doc鍙�.docx锛夋牸寮�", null); } - // 将得到的文本全角转半角 + // 灏嗗緱鍒扮殑鏂囨湰鍏ㄨ杞崐瑙� strText = formatFullToHalf(strText); - // 解决空格保存为txt的时候,乱码为? + // 瑙e喅绌烘牸淇濆瓨涓簍xt鐨勬椂鍊欙紝涔辩爜涓猴紵 byte bytes[] = { (byte) 0xC2, (byte) 0xA0 }; String UTFSpace = new String(bytes, "UTF-8"); strText = strText.replaceAll(UTFSpace, " "); @@ -319,9 +319,9 @@ return txtFile.getAbsolutePath(); } catch (FileNotFoundException e) { - throw new RuntimeException("office文档未找到", e); + throw new RuntimeException("office鏂囨。鏈壘鍒�", e); } catch (IOException e) { - throw new RuntimeException("office文档读取失败", e); + throw new RuntimeException("office鏂囨。璇诲彇澶辫触", e); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } finally { @@ -331,7 +331,7 @@ } /** - * 全角转半角 + * 鍏ㄨ杞崐瑙� * * @param oriText * @return @@ -342,23 +342,23 @@ } char[] charArray = oriText.toCharArray(); - // 对全角字符转换的char数组遍历 + // 瀵瑰叏瑙掑瓧绗﹁浆鎹㈢殑char鏁扮粍閬嶅巻 for (int i = 0; i < charArray.length; ++i) { int charIntValue = (int) charArray[i]; - // 如果符合转换关系,将对应下标之间减掉偏移量65248;如果是空格的话,直接做转换 + // 濡傛灉绗﹀悎杞崲鍏崇郴,灏嗗搴斾笅鏍囦箣闂村噺鎺夊亸绉婚噺65248;濡傛灉鏄┖鏍肩殑璇�,鐩存帴鍋氳浆鎹� if (charIntValue >= 65281 && charIntValue <= 65374) { charArray[i] = (char) (charIntValue - 65248); } else if (charIntValue == 12288) { charArray[i] = (char) 32; } else if (charIntValue == 58033) { - // 空格 + // 绌烘牸 charArray[i] = (char) 32; } else if (charIntValue == 65380) { - // 顿号 + // 椤垮彿 charArray[i] = (char) 12289; } else if (charIntValue == 65377) { - // 句号 + // 鍙ュ彿 charArray[i] = (char) 12290; } } @@ -367,7 +367,7 @@ } /** - * 解析文件后缀 + * 瑙f瀽鏂囦欢鍚庣紑 * * @param filename * @return -- Gitblit v1.8.0