xiaofei 2 ani în urmă
părinte
comite
fa171ae198

+ 2 - 2
paper-library-business/pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.business</groupId>
     <artifactId>paper-library-business</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.2</version>
     <build>
         <plugins>
             <plugin>
@@ -22,7 +22,7 @@
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.0</version>
+        <version>1.0.2</version>
     </parent>
 
     <dependencies>

+ 14 - 0
paper-library-business/src/main/java/com/qmth/paper/library/business/entity/PaperLibrary.java

@@ -64,6 +64,12 @@ public class PaperLibrary extends BaseEntity implements Serializable {
     @TableField("words_result")
     private String wordsResult;
 
+    /**
+     * OCR识别结果
+     */
+    @TableField("ocr_result")
+    private String ocrResult;
+
 
     public Long getSchoolId() {
         return schoolId;
@@ -128,4 +134,12 @@ public class PaperLibrary extends BaseEntity implements Serializable {
     public void setWordsResult(String wordsResult) {
         this.wordsResult = wordsResult;
     }
+
+    public String getOcrResult() {
+        return ocrResult;
+    }
+
+    public void setOcrResult(String ocrResult) {
+        this.ocrResult = ocrResult;
+    }
 }

+ 0 - 1
paper-library-business/src/main/java/com/qmth/paper/library/business/entity/PaperScanTask.java

@@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.paper.library.common.base.BaseEntity;
-import com.sun.org.apache.xpath.internal.operations.Bool;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;

+ 15 - 9
paper-library-business/src/main/java/com/qmth/paper/library/business/service/impl/PaperLibraryServiceImpl.java

@@ -299,6 +299,7 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
         JSONObject jsonObject = objectList.get(index);
 
         String rootPath = fileStoreUtil.buildPath(UploadFileEnum.DOWNLOAD, true);
+        String cutRootPath = fileStoreUtil.buildPath(UploadFileEnum.CUT, true);
         File file;
         try {
             file = paperLibraryCommonService.downloadFile(rootPath, jsonObject.getString(SystemConstant.PATH), jsonObject.getString(SystemConstant.UPLOAD_TYPE), jsonObject.getString(SystemConstant.TYPE));
@@ -306,14 +307,17 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
             throw ExceptionResultEnum.ERROR.exception("下载图片失败:" + e.getMessage());
         }
         // 裁剪
-        File outFile = new File(rootPath, "sub" + file.getName());
+        File outFile = new File(cutRootPath, "sub" + file.getName());
+        if(!outFile.exists()){
+            outFile.getParentFile().mkdirs();
+        }
         File subFile = ImageUtil.subImg(file, x, y, width, height, outFile);
         if (subFile == null) {
             throw ExceptionResultEnum.ERROR.exception("识别区域图片生成失败");
         }
 
         // 旋转
-        File rotateOutFile = new File(rootPath, "rotate" + file.getName());
+        File rotateOutFile = new File(cutRootPath, "rotate" + file.getName());
         File rotateFile = ImageUtil.rotate(subFile, rotate, rotateOutFile);
 
         List<String> stringList = new ArrayList<>();
@@ -339,25 +343,27 @@ public class PaperLibraryServiceImpl extends ServiceImpl<PaperLibraryMapper, Pap
             if (jsonArray.length() == 0) {
                 throw ExceptionResultEnum.ERROR.exception("未正确识别出内容");
             } else {
-                // 保存识别数据
-                UpdateWrapper<PaperLibrary> updateWrapper = new UpdateWrapper<>();
-                updateWrapper.lambda().set(PaperLibrary::getWordsResult, jsonArray.toString()).eq(PaperLibrary::getId, paperLibraryId);
-                this.updateById(paperLibrary);
-
                 jsonArray.forEach(m -> {
                     org.json.JSONObject object = (org.json.JSONObject) m;
                     if (object.has(SystemConstant.OCR_WORDS)) {
                         stringList.add(object.getString(SystemConstant.OCR_WORDS));
                     }
                 });
+
+                // 保存识别数据
+                UpdateWrapper<PaperLibrary> updateWrapper = new UpdateWrapper<>();
+                updateWrapper.lambda().set(PaperLibrary::getWordsResult, jsonArray.toString())
+                        .set(PaperLibrary::getOcrResult, String.join(",", stringList))
+                        .eq(PaperLibrary::getId, paperLibraryId);
+                this.update(updateWrapper);
             }
         } catch (JSONException e) {
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         } finally {
             try {
                 FileUtils.forceDelete(file);
-                FileUtils.forceDelete(subFile);
-                FileUtils.forceDelete(rotateFile);
+//                FileUtils.forceDelete(subFile);
+//                FileUtils.forceDelete(rotateFile);
             } catch (IOException e) {
                 e.printStackTrace();
             }

+ 2 - 2
paper-library-common/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.common</groupId>
     <artifactId>paper-library-common</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.2</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.0</version>
+        <version>1.0.2</version>
     </parent>
 
     <dependencies>

+ 1 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/enums/UploadFileEnum.java

@@ -13,6 +13,7 @@ public enum UploadFileEnum {
     FILE("file", "local"),
 
     DOWNLOAD("download", "local"),
+    CUT("cut", "local"),
 
     IMAGE("image", "local");
 

+ 14 - 14
paper-library-common/src/main/java/com/qmth/paper/library/common/service/impl/AuthInfoServiceImpl.java

@@ -194,21 +194,21 @@ public class AuthInfoServiceImpl implements AuthInfoService {
             if (Objects.isNull(basicSchool)) {
                 //不存在则创建学校
                 basicSchool = new BasicSchool(o.getId(), o.getCode(), o.getName(), o.getAccessKey(), o.getAccessSecret());
-                if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
-                    String filePath = dictionaryConfig.fssDomain().getConfig() + File.separator + SystemConstant.getUuid() + ".jpg";
-                    File logoFile = new File(filePath);
-                    if (!logoFile.getParentFile().exists()) {
-                        // 不存在则创建父目录及子文件
-                        logoFile.getParentFile().mkdirs();
-                    }
-                    SystemConstant.base64ToImage(o.getLogo(), filePath);
-                    if (logoFile.exists()) {
-                        basicSchool.setLogo(Base64Util.imageToBase64(logoFile));
-                        logoFile.delete();
-                    }
-                } else {
+//                if (Objects.nonNull(o.getLogo()) && (!o.getLogo().startsWith("https:") || !o.getLogo().startsWith("http"))) {
+//                    String filePath = dictionaryConfig.fssDomain().getConfig() + File.separator + SystemConstant.getUuid() + ".jpg";
+//                    File logoFile = new File(filePath);
+//                    if (!logoFile.getParentFile().exists()) {
+//                        // 不存在则创建父目录及子文件
+//                        logoFile.getParentFile().mkdirs();
+//                    }
+//                    SystemConstant.base64ToImage(o.getLogo(), filePath);
+//                    if (logoFile.exists()) {
+//                        basicSchool.setLogo(Base64Util.imageToBase64(logoFile));
+//                        logoFile.delete();
+//                    }
+//                } else {
                     basicSchool.setLogo(o.getLogo());
-                }
+//                }
                 basicSchoolSet.add(basicSchool);
             }
             QueryWrapper<SysOrg> sysOrgQueryWrapper = new QueryWrapper<>();

+ 4 - 0
paper-library-common/src/main/java/com/qmth/paper/library/common/util/Base64Util.java

@@ -31,6 +31,10 @@ public class Base64Util {
         return "data:image/png;base64," + encode(fileToByte(file));
     }
 
+    public static String stringToBase64(String base64String) {
+        return "data:image/png;base64," + base64String;
+    }
+
     /**
      * 文件File类型转byte[]
      *

+ 3 - 2
paper-library/pom.xml

@@ -4,13 +4,13 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library</groupId>
     <artifactId>paper-library</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.2</version>
     <packaging>jar</packaging>
 
     <parent>
         <groupId>com.qmth.paper.library.service</groupId>
         <artifactId>paper-library-service</artifactId>
-        <version>1.0.0</version>
+        <version>1.0.2</version>
     </parent>
 
     <dependencies>
@@ -36,6 +36,7 @@
             <plugin>
                 <groupId>org.springframework.boot</groupId>
                 <artifactId>spring-boot-maven-plugin</artifactId>
+                <version>2.6.2</version>
                 <configuration>
                     <includeSystemScope>true</includeSystemScope>
                 </configuration>

+ 13 - 13
paper-library/src/main/java/com/qmth/paper/library/api/SysController.java

@@ -335,15 +335,15 @@ public class SysController {
             authInfoService.appHasExpired(code);
             Map<String, String> map = new HashMap<>();
             if (Objects.nonNull(basicSchool.getLogo()) && (!basicSchool.getLogo().startsWith("http") || !basicSchool.getLogo().startsWith("https"))) {
-                String hostUrl = SystemConstant.getLocalFileHost(dictionaryConfig.fssDomain().getServer());
-                String filePath = SystemConstant.getLocalFilePath(hostUrl, basicSchool.getLogo());
-                String url = null;
-                if (filePath.startsWith("/")) {
-                    url = hostUrl + filePath;
-                } else {
-                    url = hostUrl + File.separator + filePath;
-                }
-                map.put(SystemConstant.LOGO, url);
+//                String hostUrl = SystemConstant.getLocalFileHost(dictionaryConfig.fssDomain().getServer());
+//                String filePath = SystemConstant.getLocalFilePath(hostUrl, basicSchool.getLogo());
+//                String url = null;
+//                if (filePath.startsWith("/")) {
+//                    url = hostUrl + filePath;
+//                } else {
+//                    url = hostUrl + File.separator + filePath;
+//                }
+                map.put(SystemConstant.LOGO, Base64Util.stringToBase64(basicSchool.getLogo()));
             } else {
                 map.put(SystemConstant.LOGO, basicSchool.getLogo());
             }
@@ -351,10 +351,10 @@ public class SysController {
             return ResultUtil.ok(map);
         } else {
             Map<String, String> map = new HashMap<>();
-            String path = this.getClass().getClassLoader().getResource("static/wx_logo.png").getPath();
-            if (StringUtils.isNotBlank(path)) {
-                map.put(SystemConstant.LOGO, Base64Util.imageToBase64(path));
-            }
+//            String path = this.getClass().getClassLoader().getResource("static/wx_logo.png").getPath();
+//            if (StringUtils.isBlank(path)) {
+//                map.put(SystemConstant.LOGO, Base64Util.imageToBase64(path));
+//            }
             map.put("name", null);
             return ResultUtil.ok(map);
         }

+ 1 - 1
paper-library/src/main/resources/application.properties

@@ -10,7 +10,7 @@ db.host=localhost
 db.port=3306
 db.name=paper-library-v1.0.2
 db.username=root
-db.password=root
+db.password=12345678
 
 com.qmth.datasource.url=jdbc:mysql://${db.host}:${db.port}/${db.name}?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&nullCatalogMeansCurrent=true
 com.qmth.datasource.username=${db.username}

+ 1 - 1
pom.xml

@@ -4,7 +4,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.qmth.paper.library.service</groupId>
     <artifactId>paper-library-service</artifactId>
-    <version>1.0.0</version>
+    <version>1.0.2</version>
     <packaging>pom</packaging>
 
     <modules>

+ 2 - 1
sql/paper-library-v1.0.2.sql

@@ -223,7 +223,8 @@ CREATE TABLE `paper_library`  (
   `user_id` bigint(20) DEFAULT NULL COMMENT '数据检验员id',
   `sequence` int(11) DEFAULT NULL COMMENT '图片序号',
   `abnormal` tinyint(1) DEFAULT '0' COMMENT '异常,默认否(0)',
-  `words_result` mediumtext COMMENT 'OCR识别结果',
+  `words_result` mediumtext COMMENT 'OCR识别结果(原始值)',
+  `ocr_result` mediumtext COMMENT 'OCR识别结果',
   `create_id` bigint(20) DEFAULT NULL COMMENT '创建人',
   `create_time` bigint(20) DEFAULT NULL COMMENT '创建时间',
   `update_id` bigint(20) DEFAULT NULL COMMENT '更新人',

+ 2 - 1
sql/paper_library_1.0.2-罗总优化后.sql

@@ -204,7 +204,8 @@ CREATE TABLE `paper_library`  (
   `user_id` bigint(20) DEFAULT NULL COMMENT '数据检验员id',
   `sequence` int(11) DEFAULT NULL COMMENT '图片序号',
   `abnormal` tinyint(1) DEFAULT '0' COMMENT '异常,默认否(0)',
-  `words_result` mediumtext COMMENT 'OCR识别结果',
+  `words_result` mediumtext COMMENT 'OCR识别结果(原始值)',
+  `ocr_result` mediumtext COMMENT 'OCR识别结果',
   `create_id` bigint(20) DEFAULT NULL COMMENT '创建人',
   `create_time` bigint(20) DEFAULT NULL COMMENT '创建时间',
   `update_id` bigint(20) DEFAULT NULL COMMENT '更新人',