xiaochan il y a 3 mois
Parent
commit
71dd8e425e

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>web-server</artifactId>
-    <version>12.6.3</version>
+    <version>12.6.4</version>
     <name>web-server</name>
     <description>server for yibao-web</description>
     <properties>

+ 10 - 0
src/main/java/thyyxxk/webserver/controller/archive/ArchiveController.java

@@ -2,6 +2,7 @@ package thyyxxk.webserver.controller.archive;
 
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import thyyxxk.webserver.config.auth.PassToken;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.archive.PatientArchive;
 import thyyxxk.webserver.service.archive.TaskPatient;
@@ -76,6 +77,15 @@ public class ArchiveController {
         return ResultVoUtil.success(server.uploadFile(file, path));
     }
 
+
+    @PostMapping("/uploadFileByCode")
+    @PassToken
+    public ResultVo<ArchiveServer.UploadResult> uploadFileByCode(@RequestParam("file") MultipartFile file,
+                                                                 @RequestParam("path") String path,
+                                                                 @RequestParam("code") String code) {
+        return ResultVoUtil.success(server.uploadFileByCode(file, path, code));
+    }
+
     @PostMapping("/delUploadById/{id}")
     public ResultVo<String> delUploadById(@PathVariable("id") String id) {
         server.delUploadById(id);

+ 17 - 4
src/main/java/thyyxxk/webserver/service/archive/ArchiveServer.java

@@ -68,8 +68,13 @@ public class ArchiveServer {
     }
 
     public ForestRequest<?> sendApi(String url) {
+        return sendApi(url, null);
+    }
+
+    public ForestRequest<?> sendApi(String url, String code) {
         String now = FastDateFormat.getInstance("yyyy-MM-ddHH:mm").format(new DateTime());
-        String string = TokenUtil.getInstance().getTokenUserId() + "_" + now;
+        String currentCode = code == null ? TokenUtil.getInstance().getTokenUserId() : code;
+        String string = currentCode + "_" + now;
         String authorization = rsa.encryptBase64(string, KeyType.PublicKey);
 
         return Forest.post(archiveData.getArchiveUrl() + url)
@@ -167,10 +172,18 @@ public class ArchiveServer {
      * @return 返回文件的id,文件的地址
      */
     public UploadResult uploadFile(MultipartFile file, String path) {
-        return uploadFile(file, path, !isProd);
+        return uploadFile(file, path, !isProd, null);
+    }
+
+    public UploadResult uploadFileByCode(MultipartFile file, String path, String code) {
+        return uploadFile(file, path, !isProd, code);
     }
 
 
+    public UploadResult uploadFile(MultipartFile file, String path, boolean isTest) {
+        return uploadFile(file, path, isTest, null);
+    }
+
     /**
      * 上传文件到服务器,如果需要删除请调用这个接口 {@link #delUploadById(String) }
      *
@@ -179,10 +192,10 @@ public class ArchiveServer {
      * @param isTest 是否放入测试的文件夹
      * @return 返回文件的id,文件的地址
      */
-    public UploadResult uploadFile(MultipartFile file, String path, boolean isTest) {
+    public UploadResult uploadFile(MultipartFile file, String path, boolean isTest, String code) {
         JSONObject execute;
         try {
-            execute = sendApi("/uploadFile")
+            execute = sendApi("/uploadFile", code)
                     .contentFormUrlEncoded()
                     .addHeader("content-type", "multipart/form-data")
                     .addFile("file", file.getInputStream(), file.getOriginalFilename(), file.getContentType())

+ 1 - 2
src/main/java/thyyxxk/webserver/service/ca/CaServer.java

@@ -682,8 +682,7 @@ public class CaServer implements Assertion {
 
         // 写入CA数据
         FileUtil.writeString(upload.getCaData(), archivePath + caPath, StandardCharsets.UTF_8);
-        // 写入pdf
-        FileUtil.writeBytes(file, archivePath + pdfPath);
+        FileUtil.writeString(new String(file), archivePath + pdfPath, StandardCharsets.UTF_8);
         return "/archive" + pdfPath;
     }
 

+ 1 - 0
src/main/resources/application-prod.yml

@@ -152,6 +152,7 @@ rmHkUserApi: http://172.16.32.167:20923/thyy/api/haikang/door/destructionUser
 thyy:
   archive:
     path: "/mnt/archive"
+    archive-url: http://172.16.32.167:20921/thyy/api/archive
   other:
     mobile-address: "https://emr.hnthyy.cn:8080"
     mobile-agentid: 1000050