From 8ed5da34c12b456a04f08e870dab4f299163ae51 Mon Sep 17 00:00:00 2001 From: zhanglb Date: Fri, 25 Aug 2023 11:06:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../segmentation/ocrbasic/AddOcrBasicDTO.java | 2 +- .../ocrbasic/EditOcrBasicDTO.java | 2 +- .../ocrconfig/AddOcrConfigDTO.java | 2 +- .../ocrconfig/EditOcrConfigDTO.java | 2 +- .../ocrfileinfo/AddOcrFileInfoDTO.java | 2 +- .../ocrfileinfo/EditOcrFileInfoDTO.java | 2 +- .../segmentation/ocrrule/AddOcrRuleDTO.java | 2 +- .../segmentation/ocrrule/EditOcrRuleDTO.java | 2 +- .../AddOcrSpecialDetailDTO.java | 2 +- .../EditOcrSpecialDetailDTO.java | 2 +- .../ocrspecialrule/AddOcrSpecialRuleDTO.java | 2 +- .../ocrspecialrule/EditOcrSpecialRuleDTO.java | 2 +- .../ocrsprule/AddOcrSpRuleDTO.java | 2 +- .../ocrsprule/EditOcrSpRuleDTO.java | 2 +- .../ocrversion/AddOcrVersionDTO.java | 2 +- .../ocrversion/EditOcrVersionDTO.java | 2 +- .../vo/segmentation/ocrbasic/OcrBasicVO.java | 2 +- .../segmentation/ocrconfig/OcrConfigVO.java | 2 +- .../ocrfileinfo/OcrFileInfoVO.java | 2 +- .../vo/segmentation/ocrrule/OcrRuleVO.java | 2 +- .../ocrspecialdetail/OcrSpecialDetailVO.java | 2 +- .../ocrspecialrule/OcrSpecialRuleVO.java | 2 +- .../segmentation/ocrsprule/OcrSpRuleVO.java | 2 +- .../segmentation/ocrversion/OcrVersionVO.java | 2 +- .../server/common/download/Base64Utils.java | 154 ----- .../server/common/download/CallBackPara.java | 50 -- .../common/download/DownloadManager.java | 67 --- .../common/download/FileCheckPoints.java | 40 -- .../docus/server/common/download/FtpInfo.java | 11 - .../common/download/GeneralDownloadInfo.java | 200 ------- .../server/common/download/GlobalData.java | 143 ----- .../server/common/download/IDownCallBack.java | 7 - .../server/common/download/IDownloadInfo.java | 60 -- .../server/common/download/MultiDownFile.java | 38 -- .../common/download/NoCheckPointInfo.java | 73 --- .../common/download/RemoteLocalPair.java | 72 --- .../server/common/download/SaveFileItem.java | 73 --- .../docus/server/common/download/Tools.java | 30 - .../download/downLoader/HttpDownloader.java | 559 ------------------ .../src/main/resources/bootstrap.yml | 2 +- .../java/com/docus/server/FileController.java | 24 +- pom.xml | 6 +- 42 files changed, 29 insertions(+), 1628 deletions(-) delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/Base64Utils.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/CallBackPara.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/DownloadManager.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/FileCheckPoints.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/FtpInfo.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/GeneralDownloadInfo.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/GlobalData.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/IDownCallBack.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/IDownloadInfo.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/MultiDownFile.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/NoCheckPointInfo.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/RemoteLocalPair.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/SaveFileItem.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/Tools.java delete mode 100644 docus-segmentation/src/main/java/com/docus/server/common/download/downLoader/HttpDownloader.java diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/AddOcrBasicDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/AddOcrBasicDTO.java index c2572ff..1672433 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/AddOcrBasicDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/AddOcrBasicDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrBasicDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案主键") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/EditOcrBasicDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/EditOcrBasicDTO.java index 01c9166..43cbe9e 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/EditOcrBasicDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrbasic/EditOcrBasicDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrBasicDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案主键") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/AddOcrConfigDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/AddOcrConfigDTO.java index c8f8e9b..cbdbd08 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/AddOcrConfigDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/AddOcrConfigDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrConfigDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String configKey; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/EditOcrConfigDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/EditOcrConfigDTO.java index d429615..db6322c 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/EditOcrConfigDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrconfig/EditOcrConfigDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrConfigDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String configKey; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/AddOcrFileInfoDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/AddOcrFileInfoDTO.java index 184c593..a2a1e83 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/AddOcrFileInfoDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/AddOcrFileInfoDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrFileInfoDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案id") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/EditOcrFileInfoDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/EditOcrFileInfoDTO.java index 1520402..d3a5ab6 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/EditOcrFileInfoDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrfileinfo/EditOcrFileInfoDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrFileInfoDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案id") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/AddOcrRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/AddOcrRuleDTO.java index 77857cc..62c936f 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/AddOcrRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/AddOcrRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/EditOcrRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/EditOcrRuleDTO.java index 203f964..5bbc21b 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/EditOcrRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrrule/EditOcrRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/AddOcrSpecialDetailDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/AddOcrSpecialDetailDTO.java index d990d13..afb9247 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/AddOcrSpecialDetailDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/AddOcrSpecialDetailDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrSpecialDetailDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "特殊规则id") private Integer specialId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/EditOcrSpecialDetailDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/EditOcrSpecialDetailDTO.java index f4056cb..4823fb8 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/EditOcrSpecialDetailDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialdetail/EditOcrSpecialDetailDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrSpecialDetailDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "特殊规则id") private Integer specialId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/AddOcrSpecialRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/AddOcrSpecialRuleDTO.java index 244b311..1e6e07d 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/AddOcrSpecialRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/AddOcrSpecialRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrSpecialRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/EditOcrSpecialRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/EditOcrSpecialRuleDTO.java index cdc0944..8bf1dd7 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/EditOcrSpecialRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrspecialrule/EditOcrSpecialRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrSpecialRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/AddOcrSpRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/AddOcrSpRuleDTO.java index c100e68..dfbe1e0 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/AddOcrSpRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/AddOcrSpRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrSpRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/EditOcrSpRuleDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/EditOcrSpRuleDTO.java index b1e192f..864ec85 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/EditOcrSpRuleDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrsprule/EditOcrSpRuleDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrSpRuleDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/AddOcrVersionDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/AddOcrVersionDTO.java index 2c76ba0..c4f0f24 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/AddOcrVersionDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/AddOcrVersionDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class AddOcrVersionDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "版本号") private Integer version; diff --git a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/EditOcrVersionDTO.java b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/EditOcrVersionDTO.java index f2bcefa..cb04134 100644 --- a/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/EditOcrVersionDTO.java +++ b/docus-client-interface/src/main/java/com/docus/server/dto/segmentation/ocrversion/EditOcrVersionDTO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class EditOcrVersionDTO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "版本号") private Integer version; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrbasic/OcrBasicVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrbasic/OcrBasicVO.java index 6642dc1..05fb400 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrbasic/OcrBasicVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrbasic/OcrBasicVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrBasicVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案主键") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrconfig/OcrConfigVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrconfig/OcrConfigVO.java index e9ef7f5..9c78210 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrconfig/OcrConfigVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrconfig/OcrConfigVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrConfigVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String configKey; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrfileinfo/OcrFileInfoVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrfileinfo/OcrFileInfoVO.java index 146a5b0..ee03d38 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrfileinfo/OcrFileInfoVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrfileinfo/OcrFileInfoVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrFileInfoVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "病案id") private String patientId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrrule/OcrRuleVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrrule/OcrRuleVO.java index d344b96..8fd5720 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrrule/OcrRuleVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrrule/OcrRuleVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrRuleVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialdetail/OcrSpecialDetailVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialdetail/OcrSpecialDetailVO.java index a01e216..49a0c90 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialdetail/OcrSpecialDetailVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialdetail/OcrSpecialDetailVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrSpecialDetailVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "特殊规则id") private Integer specialId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialrule/OcrSpecialRuleVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialrule/OcrSpecialRuleVO.java index 96f78c1..dfd85e0 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialrule/OcrSpecialRuleVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrspecialrule/OcrSpecialRuleVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrSpecialRuleVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "分段id") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrsprule/OcrSpRuleVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrsprule/OcrSpRuleVO.java index 1f86fc4..bfe623d 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrsprule/OcrSpRuleVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrsprule/OcrSpRuleVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrSpRuleVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "") private String assortId; diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrversion/OcrVersionVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrversion/OcrVersionVO.java index 6dab0fc..637ed52 100644 --- a/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrversion/OcrVersionVO.java +++ b/docus-client-interface/src/main/java/com/docus/server/vo/segmentation/ocrversion/OcrVersionVO.java @@ -29,7 +29,7 @@ import java.time.LocalDateTime; public class OcrVersionVO implements Serializable { @ApiModelProperty(value = "id") - private Integer id; + private Long id; @ApiModelProperty(value = "版本号") private Integer version; diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/Base64Utils.java b/docus-segmentation/src/main/java/com/docus/server/common/download/Base64Utils.java deleted file mode 100644 index 3159ce3..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/Base64Utils.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.docus.server.common.download; - -import lombok.extern.slf4j.Slf4j; -import sun.misc.BASE64Decoder; -import sun.misc.BASE64Encoder; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -@Slf4j -public class Base64Utils { - private static Base64Utils utils =null; - private Base64Utils(){ - - } - public static Base64Utils getInstance(){ - if(utils==null){ - synchronized (Base64Utils.class){ - if(utils == null){ - utils = new Base64Utils(); - } - } - } - return utils; - } - - public String imageToBase64Str(String imgFile) { - InputStream inputStream = null; - byte[] data = null; - try { - inputStream = new FileInputStream(imgFile); - data = new byte[inputStream.available()]; - inputStream.read(data); - inputStream.close(); - } catch (IOException e) { - e.printStackTrace(); - } - // 加密 - BASE64Encoder encoder = new BASE64Encoder(); - return encoder.encode(data); - } - - - public byte[] base64StrToBytes(String imgStr) { - if (imgStr == null) { - return null; - } - String[] s = imgStr.split(","); - if(s.length>0){ - imgStr=s[1]; - } - BASE64Decoder decoder = new BASE64Decoder(); - try { - // 解密 - byte[] b = decoder.decodeBuffer(imgStr); - // 处理数据 - for (int i = 0; i < b.length; ++i) { - if (b[i] < 0) { - b[i] += 256; - } - } - return b; - } catch (Exception e) { - log.error("Base64 转 byte[] 出错啦!",e); - return null; - } - } - - - public boolean base64StrToImage(byte[] bytes, String path) { - if (bytes == null) { - return false; - } - try { - //文件夹不存在则自动创建 - File tempFile = new File(path); - if (!tempFile.getParentFile().exists()) { - tempFile.getParentFile().mkdirs(); - } - OutputStream out = new FileOutputStream(tempFile); - out.write(bytes); - out.flush(); - out.close(); - return true; - } catch (Exception e) { - log.error("图片文件下载失败:"+e.getMessage()); - return false; - } - } - - public boolean base64StrToImage(String imgStr, String path) { - if (imgStr == null) { - return false; - } - String[] s = imgStr.split(","); - if(s.length>0){ - imgStr=s[1]; - } - BASE64Decoder decoder = new BASE64Decoder(); - try { - // 解密 - byte[] b = decoder.decodeBuffer(imgStr); - // 处理数据 - for (int i = 0; i < b.length; ++i) { - if (b[i] < 0) { - b[i] += 256; - } - } - //文件夹不存在则自动创建 - File tempFile = new File(path); - if (!tempFile.getParentFile().exists()) { - tempFile.getParentFile().mkdirs(); - } - OutputStream out = new FileOutputStream(tempFile); - out.write(b); - out.flush(); - out.close(); - return true; - } catch (Exception e) { - log.error("图片文件下载失败:"+e.getMessage()); - return false; - } - } - - public int getFileSize(File inFile){ - InputStream in =null; - try{ - in= new FileInputStream(inFile); - int len =in.available(); - return len; - } - catch (Exception e){ - - } - finally { - try{ - in.close(); - } - catch (IOException e){ - e.printStackTrace(); - } - } - return -1; - } - - - public static void main(String[] args) { - System.out.println(Base64Utils.getInstance().imageToBase64Str("e:\\1.jpg")); - } -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/CallBackPara.java b/docus-segmentation/src/main/java/com/docus/server/common/download/CallBackPara.java deleted file mode 100644 index cd87c6e..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/CallBackPara.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.docus.server.common.download; - -import lombok.Data; - -import java.sql.Timestamp; -import java.util.List; - -@Data -public class CallBackPara { - /** - * 主键 - */ - private String id; - /** - * 其他信息 - */ - private String mess; - - /** - * 本地存放路径 - */ - private String localpath; - - /** - * 文件名 - */ - private String filename; - - /** - * 下载开始时间 - */ - private Timestamp starttime; - - /** - * 下载完成时间 - */ - private Timestamp endtime; - - private List files; - - /** - * 下载存储文件的方式 0 传过来的格式,1转为 pdf 默认 ,2 转为图片jpg存储 - */ - private int fileStorageFormat=1; - - /** - * 0:病案,1:门急诊 2:省中医封存 - */ - private int datatype=0; -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/DownloadManager.java b/docus-segmentation/src/main/java/com/docus/server/common/download/DownloadManager.java deleted file mode 100644 index 1788611..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/DownloadManager.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.docus.server.common.download; - -import com.docus.core.util.SpringUtils; -import com.docus.server.common.download.downLoader.HttpDownloader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collection; - - -public class DownloadManager { - - private static Logger logger = LoggerFactory.getLogger(DownloadManager.class); - - enum ProtocolType {HTTP, HTTPS, FTP, BASE64, SMB, OTHER} - - ; - - public static void feedLinks(Collection list, int maxHttpRetry) { - for (RemoteLocalPair pair : list) { - ProtocolType deal = getLinkProtocol(pair.remoteUrl); - if (deal == ProtocolType.HTTP || deal == ProtocolType.HTTPS) { - HttpDownload(pair, maxHttpRetry); - } else if (deal == ProtocolType.FTP) { - } else if (deal == ProtocolType.BASE64) { - } else if (deal == ProtocolType.SMB) { - } else { - logger.error(pair.remoteUrl + " Url is not http or ftp!"); - } - } - } - - - public static void HttpDownload(RemoteLocalPair pair, int maxHttpRetry) { - //GeneralDownloadInfo info = new GeneralDownloadInfo(pair); - NoCheckPointInfo info = new NoCheckPointInfo(pair); - HttpDownloader downloader = new HttpDownloader(info, maxHttpRetry); - downloader.intiCallBack(SpringUtils.getBean(IDownCallBack.class)); - //可以用thread.start()不过不建议 - downloader.run(); - } - - - protected static ProtocolType getLinkProtocol(String link) { - int idx = link.indexOf("://"); - if (idx == -1) { - if (link.contains("base64")) { - return ProtocolType.BASE64; - } - return ProtocolType.OTHER; - } - String name = link.substring(0, idx); - if (name.equals("http")) { - return ProtocolType.HTTP; - } - if (name.equals("https")) { - return ProtocolType.HTTPS; - } - if (name.equals("ftp")) { - return ProtocolType.FTP; - } - if (name.equals("smb")) { - return ProtocolType.SMB; - } - return ProtocolType.OTHER; - } -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/FileCheckPoints.java b/docus-segmentation/src/main/java/com/docus/server/common/download/FileCheckPoints.java deleted file mode 100644 index 59ba410..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/FileCheckPoints.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.docus.server.common.download; - -public class FileCheckPoints { - public int statecode; - public long timestamp = -99; - public long totalSize = -99; - private int split = -1; - private long[] startPos; - private long[] endPos; - - public long[] getStartPos() { - return startPos; - } - - public void setStartPos(long[] startPos) { - split = startPos.length; - this.startPos = startPos; - } - - public long[] getEndPos() { - return endPos; - } - - public void setEndPos(long[] endPos) { - split = endPos.length; - this.endPos = endPos; - } - - public int getSplit() { - return split; - } - - public void copy(FileCheckPoints _chp) { - this.setEndPos(_chp.endPos); - this.setStartPos(_chp.startPos); - this.totalSize = _chp.totalSize; - this.timestamp = _chp.timestamp; - } - -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/FtpInfo.java b/docus-segmentation/src/main/java/com/docus/server/common/download/FtpInfo.java deleted file mode 100644 index 0101ee1..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/FtpInfo.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.docus.server.common.download; - -import lombok.Data; - -@Data -public class FtpInfo { - private String ip; - private Integer port; - private String user; - private String pwd; -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/GeneralDownloadInfo.java b/docus-segmentation/src/main/java/com/docus/server/common/download/GeneralDownloadInfo.java deleted file mode 100644 index 32b0d8f..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/GeneralDownloadInfo.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.docus.server.common.download; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.StringUtils; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -public class GeneralDownloadInfo implements IDownloadInfo { - - /** - * 0:ftp地址,1:文件,2:用户名:3:密码,4:端口 - * @param fullUrl - * @return - */ - public static String[] getHostNameAndFilePath(String fullUrl) { - fullUrl = fullUrl.trim(); - String[] res = new String[5]; - int beginIndex = "ftp://".length(); - int endIndex = fullUrl.indexOf('/', beginIndex); - if (endIndex != -1) { - res[0] = fullUrl.substring(beginIndex, endIndex); - res[1] = fullUrl.substring(endIndex + 1); - } else { - res[0] = fullUrl.substring(beginIndex); - res[1] = Tools.getRandomUUID().toString() + ".none"; - } - String[] temp = res[0].split("@"); - if(temp.length>1){ - res[0] = temp[1]; - res[2] =temp[0]; - } - else - { - res[2]=""; - res[3]=""; - } - temp = res[0].split(":"); - if(temp.length>1){ - res[0] = temp[0]; - res[4] =temp[1]; - } - else - { - res[4]=""; - } - if(!StringUtils.isEmpty(res[2])){ - temp = res[2].split(":"); - if(temp.length>1){ - res[2] = temp[0]; - res[3] =temp[1]; - } - } - - return res; - } - - public GeneralDownloadInfo(RemoteLocalPair pair) { - this.pair = pair; - curName = pair.localName; - curFlagFile = new File(pair.getLocalFullPath()+".flags"); - if (!curFlagFile.getParentFile().exists()) { - curFlagFile.getParentFile().mkdirs(); - } - } - - @Override - public FileCheckPoints getCurCheckPoints() { - return chp; - } - - @Override - public RemoteLocalPair getPair() { - return this.pair; - } - - @Override - public void initDownload() { - - } - - - - @Override - public int getSplitNum(){ - return this.pair.splitNum; - } - @Override - public boolean isNeedDownload(FileCheckPoints serverInitChp) { - chp = readInfo(); - if (chp.timestamp == serverInitChp.timestamp && chp.totalSize == serverInitChp.totalSize && chp.getSplit() == serverInitChp.getSplit()) { - // 不需要下载 - boolean isneed = false; - for (int i = 0; i < chp.getStartPos().length; i++) { - if (chp.getStartPos()[i] < chp.getEndPos()[i]) { - isneed = true; - logger.info("restore from checkpoint"); - break; - } - } - return isneed; - } else { - chp.copy(serverInitChp); - return true; - } - } - - @Override - public synchronized boolean writeInfo(FileCheckPoints chkp) { - DataOutputStream dos = null; - try { - dos = new DataOutputStream(new FileOutputStream(curFlagFile)); - dos.writeLong(chkp.timestamp); - dos.writeLong(chkp.totalSize); - int split = chp.getSplit(); - dos.writeInt(split); - for(int i=0; i < chp.getSplit(); i++){ - dos.writeLong(chp.getStartPos()[i]); - dos.writeLong(chp.getEndPos()[i]); - } - } catch (FileNotFoundException e) { - logger.debug(curName, e); - } catch (IOException e) { - logger.debug(curName, e); - } finally { - if (dos != null) { - try { - dos.close(); - } catch (IOException e) { - logger.debug(curName, e); - } - } - } - return true; - } - - /** - * function:读取写入点的位置信息 如果不存在,那么 - */ - @Override - public FileCheckPoints readInfo() { - if (curFlagFile.exists()) { - DataInputStream dis = null; - try { - dis = new DataInputStream(new FileInputStream(curFlagFile)); - long curTimeStamp = dis.readLong(); - long curTotalSize = dis.readLong(); - int curSplit = dis.readInt(); - FileCheckPoints chkP = new FileCheckPoints(); - chkP.timestamp = curTimeStamp; - chkP.totalSize = curTotalSize; - long[] sp = new long[curSplit]; - long[] ep = new long[curSplit]; - for (int i=0; i< curSplit; i++){ - sp[i] = dis.readLong(); - ep[i] = dis.readLong(); - } - chkP.setStartPos(sp); - chkP.setEndPos(ep); - return chkP; - } catch (FileNotFoundException e) { - logger.debug(curName, e); - } catch (IOException e) { - logger.debug(curName, e); - } finally { - if (dis != null) { - try { - dis.close(); - } catch (IOException e) { - logger.debug(curName, e); - } - } - } - } else { - return new FileCheckPoints(); - } - return new FileCheckPoints(); - } - - @Override - public void downloadDone(FileCheckPoints chkp) { - writeInfo(chkp); - } - - - private Logger logger = LoggerFactory.getLogger(GeneralDownloadInfo.class); - - - private RemoteLocalPair pair; - private String curName; - private File curFlagFile; - private FileCheckPoints chp = null; - -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/GlobalData.java b/docus-segmentation/src/main/java/com/docus/server/common/download/GlobalData.java deleted file mode 100644 index fbfe4e6..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/GlobalData.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.docus.server.common.download; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -public class GlobalData { - - /** - * @param args - */ - public static void main(String[] args) { - - } - - private Properties properties; - private String filePath; - - private GlobalData(String filePath) { - this.filePath = filePath; - properties = loadProperties(filePath); - } - - //=================================== - private Properties loadProperties(String filePath) { - InputStream is; - try { - is = new BufferedInputStream(new FileInputStream(new File(filePath))); - Properties properties = new Properties(); - properties.load(is); - return properties; - } catch (FileNotFoundException e) { -// e.printStackTrace(); - } catch (IOException e) { -// e.printStackTrace(); - } - return null; - } - - public Properties getProperties() { - return properties; - } - - public void setPropertity(String key, String value) { - FileOutputStream oFile; - try { - properties.setProperty(key, value); - oFile = new FileOutputStream(filePath); - properties.store(oFile, "add counter!"); - oFile.close(); - } catch (IOException e) { -// e.printStackTrace(); - } - } - - public String getTempDir() { - String path = properties.getProperty("TEMP_PATH"); - File dir = new File(path); - if (!dir.exists()) { - try { - dir.mkdir(); - } catch (SecurityException e) { -// e.printStackTrace(); - } - } - return path; - } - - public String getParserDir() { - String path = properties.getProperty("PARSER_DIR"); - File dir = new File(path); - if (!dir.exists()) { - try { - dir.mkdir(); - } catch (SecurityException e) { -// e.printStackTrace(); - } - } - return path; - } - - public String getHomoGoaUrl() { - return properties.getProperty("GO_HOMO_GOA_GZ_LINK"); - } - - public String getGoBasicOboUrl() { - return properties.getProperty("GO_OBO_BASIC_LINK"); - } - - public String getGoOboUrl() { - return properties.getProperty("GO_OBO_LINK"); - } - - public String getGoOwlUrl() { - return properties.getProperty("GO_OWL_LINK"); - } - - public String getGoOwlPlusUrl() { - return properties.getProperty("GO_OWL_PLUS_LINK"); - } - - public String getDoOboUrl() { - return properties.getProperty("DO_OBO_LINK"); - } - - public String getProOboUrl() { - return properties.getProperty("PRO_OBO_LINK"); - } - - public String getChebiOboUrl() { - return properties.getProperty("CHEBI_OBO_LINK"); - } - - public String getLocalGoBasicPath() { - String goUrl = getGoBasicOboUrl(); - return getTempDir() + File.separator + GlobalData.getFileName(goUrl); - } - - //==================================== - private static GlobalData single; - private static Object lock = new Object(); - - //==================================== - public static String getFileName(String url) { - return url.substring(url.lastIndexOf("/") + 1, url.length()); - } - - public static GlobalData getInstance() { - synchronized (lock) { - if (single == null) { - single = new GlobalData("configure/settings.properties"); - } - return single; - } - } - - -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/IDownCallBack.java b/docus-segmentation/src/main/java/com/docus/server/common/download/IDownCallBack.java deleted file mode 100644 index 7a96913..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/IDownCallBack.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.docus.server.common.download; - -public interface IDownCallBack { - void success(CallBackPara para); - - void fail(CallBackPara para); -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/IDownloadInfo.java b/docus-segmentation/src/main/java/com/docus/server/common/download/IDownloadInfo.java deleted file mode 100644 index 7b8f03c..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/IDownloadInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.docus.server.common.download; - - -public interface IDownloadInfo { - /** - * 初始化download这个阶段可以做连接数据库的操作 - */ - void initDownload(); - - /** - * 判断是否需要下载,从数据库获取断点数据 - * - * @param serverInitChp checkpoint - * @return - */ - boolean isNeedDownload(FileCheckPoints serverInitChp); - - /** - * 写入断点,可以进行数据库写入操作 - * - * @param chkp checkpoint - * @return - */ - boolean writeInfo(FileCheckPoints chkp); - - /** - * 获取当前的checkPoint - * - * @return - */ - FileCheckPoints getCurCheckPoints(); - - /** - * 读取断点信息,可以进行数据库操作 - * - * @return - */ - FileCheckPoints readInfo(); - - /** - * 最后下载完成之后的操作 - * - * @param chkp - */ - void downloadDone(FileCheckPoints chkp); - - /** - * 获取当前链接和本地保存的路径信息 - * - * @return - */ - RemoteLocalPair getPair(); - - /** - * 文件分块,默认为1 - * - * @return - */ - int getSplitNum(); -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/MultiDownFile.java b/docus-segmentation/src/main/java/com/docus/server/common/download/MultiDownFile.java deleted file mode 100644 index e4a4e6d..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/MultiDownFile.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.docus.server.common.download; - -public class MultiDownFile { - public MultiDownFile(String remoteUrl, String localPath, String localName) { - this.remoteUrl = remoteUrl; - this.localPath = localPath; - this.localName = localName; - } - - private String remoteUrl; - private String localPath; - private String localName; - - public String getRemoteUrl() { - return remoteUrl; - } - - public void setRemoteUrl(String remoteUrl) { - this.remoteUrl = remoteUrl; - } - - public String getLocalPath() { - return localPath; - } - - public void setLocalPath(String localPath) { - this.localPath = localPath; - } - - public String getLocalName() { - return localName; - } - - public void setLocalName(String localName) { - this.localName = localName; - } - -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/NoCheckPointInfo.java b/docus-segmentation/src/main/java/com/docus/server/common/download/NoCheckPointInfo.java deleted file mode 100644 index 05f77c7..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/NoCheckPointInfo.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.docus.server.common.download; - - -import java.io.File; - -/** - * 使用这个info可以实现无断线续传功能的下载 - * - * @author burkun - */ -public class NoCheckPointInfo implements IDownloadInfo { - - - private boolean isDownloding; - - public NoCheckPointInfo(RemoteLocalPair pair) { - this.pair = pair; - File file = new File(pair.localPath); - if (!file.exists()) { - file.mkdirs(); - } - } - - @Override - public void initDownload() { - isDownloding = true; - } - - @Override - public boolean isNeedDownload(FileCheckPoints serverInitChp) { - chp = serverInitChp; - return true; - } - - @Override - public boolean writeInfo(FileCheckPoints chkp) { - chp = chkp; - return true; - } - - @Override - public FileCheckPoints getCurCheckPoints() { - return chp; - } - - @Override - public FileCheckPoints readInfo() { - return null; - } - - @Override - public void downloadDone(FileCheckPoints chkp) { - isDownloding = false; - } - - @Override - public RemoteLocalPair getPair() { - return pair; - } - - @Override - public int getSplitNum() { - return 1; - } - - public boolean IsDownloading() { - return isDownloding; - } - - private RemoteLocalPair pair; - private FileCheckPoints chp = null; - -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/RemoteLocalPair.java b/docus-segmentation/src/main/java/com/docus/server/common/download/RemoteLocalPair.java deleted file mode 100644 index bf687c1..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/RemoteLocalPair.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.docus.server.common.download; - -import java.io.File; -import java.util.List; - - -/** - * 需要的下载和保存的文件对 - * - * @author burkun - */ -public class RemoteLocalPair { - public String id; - public int splitNum = 1; - public String remoteUrl; - public String localPath; - public String localName; - - public String getLocalFullPath() { - return localPath + File.separator + localName; - } - - public String user; - public String pwd; - public Integer port; - public List separators; - public String failurl; - public List proxyurls; - public List smbips; - /** - * 下载存储文件的方式 0 传过来的格式,1转为 pdf 默认 ,2 转为图片jpg存储 - */ - public int fileStorageFormat = 1; - /** - * 0:病案,1:门急诊 2:省中医封存 - */ - public int datatype = 0; - - /** - * @param remoteUrl 远程url - * @param localPath 本地路径 - * @param localName 本地文件名 - */ - public RemoteLocalPair(String remoteUrl, String localPath, String localName) { - this.remoteUrl = remoteUrl; - if (localName.length() == 0) { - this.localName = getFileName(remoteUrl); - ; - } else { - this.localName = localName; - } - if (localPath.length() == 0) { - this.localPath = GlobalData.getInstance().getTempDir(); - } else { - this.localPath = localPath; - } - } - - /** - * @param remoteUrl 远程url - * @param localPath 本地路径 默认文件名从url中提取 - */ - public RemoteLocalPair(String remoteUrl, String localPath) { - this.remoteUrl = remoteUrl; - this.localName = getFileName(remoteUrl); - this.localPath = localPath; - } - - private String getFileName(String url) { - return url.substring(url.lastIndexOf("/") + 1, url.length()); - } -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/SaveFileItem.java b/docus-segmentation/src/main/java/com/docus/server/common/download/SaveFileItem.java deleted file mode 100644 index 485eee5..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/SaveFileItem.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.docus.server.common.download; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.RandomAccessFile; - - -/** - * function: 写入文件、保存文件 - */ -public class SaveFileItem { - //存储文件 - private RandomAccessFile itemFile; - private String name; - private Logger logger = LoggerFactory.getLogger(SaveFileItem.class); - - /** - * @param name 文件路径、名称 - * @param pos 写入点位置position - * @throws IOException - */ - public SaveFileItem(String name, long pos) throws IOException { - this.name = name; - itemFile = new RandomAccessFile(name, "rwd"); - //在指定的pos位置写入数据 - itemFile.seek(pos); - } - - /** - * function: 同步方法写入文件 - * @author hoojo - * @createDate 2011-9-26 下午12:21:22 - * @param buff 缓冲数组 - * @param start 起始位置 - * @param length 长度 - * @return - */ - public synchronized int write(byte[] buff, int start, int length) { - int i = -1; - try { - itemFile.write(buff, start, length); - i = length; - } catch (IOException e) { - logger.debug(name, e); - } - return i; - } - - public void close() throws IOException { - if (itemFile != null) { - itemFile.close(); - } - } - - public String getFileName(){ - return this.name; - } - /** - * 设置文件大小,在old 文件大于新文件时特别有用 - * @param newLength 新的文件长度 - */ - public void setLength(long newLength){ - try { - if(newLength != itemFile.length()){ - itemFile.setLength(newLength); - } - } catch (IOException e) { - logger.debug(name, e); - } - } -} \ No newline at end of file diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/Tools.java b/docus-segmentation/src/main/java/com/docus/server/common/download/Tools.java deleted file mode 100644 index a50caaf..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/Tools.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.docus.server.common.download; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; -import java.util.UUID; - -public class Tools { - public static UUID getRandomUUID() { - return UUID.randomUUID(); - } - - /** - * @param filename propertiy file path - * @return - * @author burkun - */ - public static Properties readPropertiesFile(String filename) { - Properties properties = new Properties(); - try { - InputStream inputs = new FileInputStream(filename); - properties.load(inputs); - inputs.close(); - } catch (IOException e) { -// e.printStackTrace(); - } - return properties; - } -} diff --git a/docus-segmentation/src/main/java/com/docus/server/common/download/downLoader/HttpDownloader.java b/docus-segmentation/src/main/java/com/docus/server/common/download/downLoader/HttpDownloader.java deleted file mode 100644 index 506b459..0000000 --- a/docus-segmentation/src/main/java/com/docus/server/common/download/downLoader/HttpDownloader.java +++ /dev/null @@ -1,559 +0,0 @@ -package com.docus.server.common.download.downLoader; - -import com.alibaba.fastjson.JSON; -import com.docus.server.common.download.CallBackPara; -import com.docus.server.common.download.FileCheckPoints; -import com.docus.server.common.download.IDownCallBack; -import com.docus.server.common.download.IDownloadInfo; -import com.docus.server.common.download.MultiDownFile; -import com.docus.server.common.download.SaveFileItem; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.httpclient.util.URIUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLEncoder; -import java.security.cert.CertificateException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * - */ -@Slf4j -public class HttpDownloader extends Thread { - - private Logger logger = LoggerFactory.getLogger(HttpDownloader.class); - private IDownloadInfo info; - private int maxRetry = 5; - private IDownCallBack downCallBack; - private String userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"; - - public HttpDownloader(IDownloadInfo info, int maxRetry) { - this.info = info; - this.maxRetry = maxRetry; - } - - /** - * 初始化回调方法 - * - * @param downCallBack - */ - public void intiCallBack(IDownCallBack downCallBack) { - this.downCallBack = downCallBack; - } - - - public HttpDownloader(IDownloadInfo info) { - this.info = info; - } - - public String[] removeArraysEmpty(String[] arr) { - return Arrays.stream(arr).filter(s -> !"".equals(s)).toArray(String[]::new); - } - - @Override - public void run() { - CallBackPara para = new CallBackPara(); - para.setId(info.getPair().id); - para.setFilename(info.getPair().localName); - para.setLocalpath(info.getPair().localPath); - para.setStarttime(getNewtime()); - para.setFileStorageFormat(info.getPair().fileStorageFormat); - para.setDatatype(info.getPair().datatype); - String url = info.getPair().remoteUrl; - List files = new ArrayList<>(); - - String[] urls = removeArraysEmpty(url.split("http://|https://")); - if (urls.length > 1) { - for (int i = 0; i < urls.length; i++) { - String urltemp = ""; - if (url.indexOf("http://" + urls[i]) >= 0) { - urltemp = "http://" + urls[i]; - } - if (url.indexOf("https://" + urls[i]) >= 0) { - urltemp = "https://" + urls[i]; - } - for (String o : this.info.getPair().separators) { - urltemp = urltemp.replaceAll(o + "$", ""); - } - files.add(new MultiDownFile(urltemp, info.getPair().localPath, "docustemp_" + i + "_" + info.getPair().localName)); - } - } else { - files.add(new MultiDownFile(url, info.getPair().localPath, info.getPair().localName)); - } - para.setFiles(files); - if (info.getPair().proxyurls != null) { - Pattern p = Pattern.compile(String.join("|", info.getPair().proxyurls)); - for (MultiDownFile o : files) { - Matcher matcher = p.matcher(o.getRemoteUrl()); - if (matcher.find()) { - o.setRemoteUrl(String.format(info.getPair().failurl, o.getRemoteUrl())); - } - } - } -// URLHttpDownBootstrapBuilder builder=null; -// HttpDownBootstrap bootstrap; - try { - for (MultiDownFile file : files) { -// try { -// url = EncoderUrl(file.getRemoteUrl()); -// } catch (Exception e) { -// -// } - downLoadFromUrl(url, file.getLocalName(), file.getLocalPath()); - if (downCallBack != null) { - downCallBack.success(para); - } - //防止过快,第三链接无法支持 - try { - Thread.sleep(100); - } catch (Exception e) { - - } -// builder = HttpDownBootstrap.builder(url); -// builder.downConfig(new HttpDownConfigInfo() -// .setFilePath(file.getLocalPath()) -// ).callBackPara(para); -// builder.response(new HttpResponseInfo(file.getLocalName())); -// bootstrap = builder.callback(new ConsoleHttpDownCallback()).build(); -// bootstrap.start(); -// bootstrap = null; -// builder = null; - } - } catch (Exception e) { -// e.printStackTrace(); - log.error("nio下载失败," + JSON.toJSONString(para) + ";失败信息:" + e.getMessage()); - if (downCallBack != null) { - downCallBack.fail(para); - } - } -// finally { -// bootstrap = null; -// builder = null; -// } - } - - public String EncoderUrl(String url) throws UnsupportedEncodingException { - String resultURL = ""; - for (int i = 0; i < url.length(); i++) { - char charAt = url.charAt(i); - //只对汉字处理 - if (isChineseChar(charAt)) { - String encode = URLEncoder.encode(charAt + "", "UTF-8"); - resultURL += encode; - } else { - resultURL += charAt; - } - } - return resultURL; - } - - public boolean isChineseChar(char c) { - return String.valueOf(c).matches("[\u4e00-\u9fa5]"); - } - - /** - * 处理多级302等跳转 - * - * @param uc - * @return - * @throws Exception - */ - private HttpURLConnection reload(HttpURLConnection uc) throws Exception { - - HttpURLConnection huc = uc; - - if (huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_TEMP - || huc.getResponseCode() == HttpURLConnection.HTTP_MOVED_PERM) {// 302, 301 - String url = huc.getHeaderField("Location"); - url = url.replace("\\", "/"); - return reload((HttpURLConnection) new URL(url).openConnection()); - } - return uc; - } - - - public void downLoadFromUrl(String urlStr, String fileName, String savePath) throws Exception { - long start = System.currentTimeMillis(); - urlStr = urlStr.replace("\\", "/"); - urlStr = URIUtil.encodePathQuery(urlStr); - URL url = new URL(urlStr); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - try { - boolean useHttps = urlStr.toLowerCase().startsWith("https"); - if (useHttps) { - HttpsURLConnection https = (HttpsURLConnection) conn; - trustAllHosts(https); - https.setHostnameVerifier(DO_NOT_VERIFY); - } - //设置超时间为3秒 - //防止屏蔽程序抓取而返回403错误 - conn.setRequestProperty("User-Agent", userAgent); - conn.setRequestProperty("Accept-Encoding", "identity"); - conn.setConnectTimeout(8 * 1000); - conn.setReadTimeout(8 * 1000); - conn = reload(conn); - long length = conn.getContentLength(); - if (length < 0) { - String values = conn.getHeaderField("Content-Length"); - if (values != null && !values.isEmpty()) { - length = Long.parseLong(values); - } - } -// log.info(urlStr+" 文件大小:"+length); - InputStream inputStream = null; - if (conn.getResponseCode() >= 400) { - throw new Exception("文件不存在"); -// inputStream = conn.getErrorStream(); - } else { - inputStream = conn.getInputStream(); - } - //得到输入流 - //InputStream inputStream = conn.getInputStream(); - //获取自己数组 - byte[] getData = readInputStream(inputStream); - - //文件保存位置 - File saveDir = new File(savePath); - if (!saveDir.exists()) { - saveDir.mkdirs(); - } - File file = new File(saveDir + File.separator + fileName); - - FileOutputStream fos = new FileOutputStream(file); - fos.write(getData); - if (fos != null) { - fos.close(); - } - if (inputStream != null) { - inputStream.close(); - } - long end = System.currentTimeMillis(); - logger.info("info:" + url + " download success;用时:" + (end - start) + "ms"); - } catch (Exception ex) { - throw ex; - } finally { - // 断开连接,释放资源 - conn.disconnect(); - } - } - - - /** - * 从输入流中获取字节数组 - * - * @param inputStream - * @return - * @throws IOException - */ - public byte[] readInputStream(InputStream inputStream) throws IOException { - byte[] buffer = new byte[1024]; - int len = 0; - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - while ((len = inputStream.read(buffer)) != -1) { - bos.write(buffer, 0, len); - } - bos.close(); - return bos.toByteArray(); - } - - - public static FileCheckPoints initCheckPoint(int splitNum, long totalSize, long timeStamp) { - long[] startPos = new long[splitNum]; - long[] endPos = new long[splitNum]; - for (int i = 0, len = startPos.length; i < len; i++) { - long size = i * (totalSize / len); - startPos[i] = size; - // 设置最后一个结束点的位置 - if (i == len - 1) { - endPos[i] = totalSize; - } else { - size = (i + 1) * (totalSize / len); - endPos[i] = size; - } - } - FileCheckPoints chp = new FileCheckPoints(); - chp.setEndPos(endPos); - chp.setStartPos(startPos); - chp.totalSize = totalSize; - chp.timestamp = timeStamp; - return chp; - } - - private FileCheckPoints getInitedCheckPoint() { - long fileLength = -1; - long timeStamp = -1; - HttpURLConnection conn = null; - int stateCode = 0; - try { - URL url = new URL(this.info.getPair().remoteUrl); - conn = (HttpURLConnection) url.openConnection(); - conn.setRequestProperty("Accept-Encoding", "identity"); - HttpDownloader.RetriveSingleStream.setHeader(conn); - stateCode = conn.getResponseCode(); - // 判断http status是否为HTTP/1.1 206 Partial Content或者200 OK - if (stateCode != HttpURLConnection.HTTP_OK - && stateCode != HttpURLConnection.HTTP_PARTIAL) { - logger.warn(info.getPair().remoteUrl + " #Error Code:# " - + stateCode); - fileLength = -2; - } else if (stateCode >= 400) { - logger.warn(info.getPair().remoteUrl + " #Error Code:# " - + stateCode); - fileLength = -2; - } else { - // 获取长度 - fileLength = conn.getContentLengthLong(); - timeStamp = conn.getLastModified(); - logger.info(info.getPair().remoteUrl + " #FileLength:# " - + fileLength); - } - } catch (MalformedURLException e) { -// e.printStackTrace(); - } catch (IOException e) { -// e.printStackTrace(); - } finally { - if (conn != null) { - conn.disconnect(); - } - } - FileCheckPoints chp; - if (fileLength > 0) { - chp = initCheckPoint(info.getSplitNum(), fileLength, timeStamp); - chp.timestamp = timeStamp; - } else { - chp = new FileCheckPoints(); - chp.statecode = stateCode; - } - return chp; - } - - /** - * bug fixed change the RandomAccessFile size - * - * @author burkun - */ - - - protected static class RetriveSingleStream implements Runnable { - private boolean isDone = false; - private FileCheckPoints chp; - private int curIndex; - private SaveFileItem file; - private long startPos; - private long endPos; - byte[] buffer = new byte[1024 * 12]; - private IDownloadInfo __info; - private int maxRetry; - private Logger logger = LoggerFactory.getLogger(RetriveSingleStream.class); - - public boolean isDone() { - return isDone; - } - - public RetriveSingleStream(IDownloadInfo info, FileCheckPoints chp, - int curIndex, int maxRetry) { - this.__info = info; - this.chp = chp; - this.curIndex = curIndex; - this.startPos = chp.getStartPos()[curIndex]; - this.endPos = chp.getEndPos()[curIndex]; - this.maxRetry = maxRetry; - } - - @Override - public void run() { - InputStream in = null; - HttpURLConnection conn = null; - int curRetry = 0; - - while (curRetry < maxRetry && !isDone) { - try { - URL url = new URL(__info.getPair().remoteUrl); - conn = (HttpURLConnection) url.openConnection(); - conn.setConnectTimeout(10000); - conn.setReadTimeout(30000); - setHeader(conn); - String property = "bytes=" + startPos + "-"; - conn.setRequestProperty("RANGE", property); - logger.info(__info.getPair().localName + " #Block" - + (curIndex + 1) + "# begin downloading..."); - int length; - long counter = 0; - InputStream is = conn.getInputStream(); - file = new SaveFileItem(__info.getPair().getLocalFullPath(), startPos); - //--bug fixed - file.setLength(__info.getCurCheckPoints().totalSize); - //--bug fixed - while (!isDone && startPos < endPos && (length = is.read(buffer)) > 0) { - startPos += file.write(buffer, 0, length); - counter += 1; - chp.getStartPos()[curIndex] = Math.min(startPos, endPos); - if (counter % 20 == 0) { - __info.writeInfo(chp); - logger.info(__info.getPair().remoteUrl + " #Block" - + (curIndex + 1) + "# download " - + getPercentage() + "%..."); - Thread.yield(); - } - } - __info.writeInfo(chp); - isDone = true; - } catch (IOException e) { - isDone = false; - logger.debug(__info.getPair().remoteUrl, e); - } finally { - if (!isDone) { - curRetry++; - logger.debug(__info.getPair().remoteUrl + " download failed, retry again!"); - if (curRetry >= maxRetry) { - //保证循环跳出 - isDone = true; - } - } else { - curRetry = maxRetry; - } - try { - if (in != null) { - in.close(); - } - if (file != null) { - file.close(); - } - if (conn != null) { - conn.disconnect(); - } - } catch (IOException e) { - logger.debug(__info.getPair().remoteUrl, e); - } - } - } - } - - - public static void setHeader(URLConnection conn) { - conn.setRequestProperty( - "User-Agent", - "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 BIDUBrowser/7.0 Safari/537.36"); - conn.setRequestProperty("Accept-Language", - "en-us,en;q=0.7,zh-cn;q=0.3"); - conn.setRequestProperty("Accept-Encoding", "utf-8"); - conn.setRequestProperty("Accept-Charset", - "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); - conn.setRequestProperty("Keep-Alive", "300"); - conn.setRequestProperty("connnection", "keep-alive"); - // conn.setRequestProperty("If-Modified-Since", - // "Fri, 02 Jan 2009 17:00:05 GMT"); - // conn.setRequestProperty("If-None-Match", - // "\"1261d8-4290-df64d224\""); - conn.setRequestProperty("Cache-conntrol", "max-age=0"); - conn.setRequestProperty("Referer", "http://www.baidu.com"); - } - - private int getPercentage() { - long total = 0; - for (int i = 0; i < chp.getSplit(); i++) { - total += chp.getEndPos()[i] - chp.getStartPos()[i]; - } - return (int) ((chp.totalSize - total) * 100 / chp.totalSize); - } - - } - - private Timestamp getNewtime() { - Date now = new Date(); - Timestamp timestamp = new Timestamp(now.getTime()); - return timestamp; - } - -// public static void main(String[] args) { -// String url="http://ss,ss,https://bbbbb;http://ccc"; -// List separators = new ArrayList<>(); -// separators.add(","); -// separators.add(";"); -// String[] urls = url.split("http://|https://"); -// for (int i = 0; i < urls.length; i++) { -// String urltemp = ""; -// if (url.indexOf("http://" + urls[i]) >= 0) { -// urltemp="http://" + urls[i]; -// } -// if (url.indexOf("https://" + urls[i]) >= 0) { -// urltemp="https://" + urls[i]; -// } -// for(String o:separators){ -// urltemp=urltemp.replaceAll(o+"$", ""); -// } -// System.out.println(urltemp); -// } -// } - /** - * 覆盖java默认的证书验证 - */ - private final TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException { - - } - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] x509Certificates, String s) throws CertificateException { - - } - - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } - }}; - - /** - * 设置不验证主机 - */ - private final HostnameVerifier DO_NOT_VERIFY = new HostnameVerifier() { - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - - /** - * 信任所有 - * - * @param connection - * @return - */ - private SSLSocketFactory trustAllHosts(HttpsURLConnection connection) { - SSLSocketFactory oldFactory = connection.getSSLSocketFactory(); - try { - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, trustAllCerts, new java.security.SecureRandom()); - SSLSocketFactory newFactory = sc.getSocketFactory(); - connection.setSSLSocketFactory(newFactory); - } catch (Exception e) { - e.printStackTrace(); - } - return oldFactory; - } - -} diff --git a/docus-segmentation/src/main/resources/bootstrap.yml b/docus-segmentation/src/main/resources/bootstrap.yml index 06d4ad8..5cb1129 100644 --- a/docus-segmentation/src/main/resources/bootstrap.yml +++ b/docus-segmentation/src/main/resources/bootstrap.yml @@ -12,7 +12,7 @@ spring: datasource: #公司病案的文件服务数据库 master: - url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus-ocr?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai + url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus_ocr?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai username: docus password: docus702 driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy diff --git a/docus-segmentation/src/test/java/com/docus/server/FileController.java b/docus-segmentation/src/test/java/com/docus/server/FileController.java index 66b6a58..fdb8f49 100644 --- a/docus-segmentation/src/test/java/com/docus/server/FileController.java +++ b/docus-segmentation/src/test/java/com/docus/server/FileController.java @@ -2,8 +2,7 @@ package com.docus.server; import cn.hutool.core.util.ZipUtil; import cn.hutool.http.HttpRequest; -import com.docus.server.common.download.downLoader.HttpDownloader; -import com.docus.server.common.utils.StartUpExeUtils; + import com.google.common.collect.Lists; import io.swagger.annotations.ApiOperation; import org.springframework.boot.test.context.SpringBootTest; @@ -23,29 +22,8 @@ import java.util.Map; @SpringBootTest public class FileController { - public static void test() throws Exception { - /** - * 1、接收调度器下载采集器包命令 - * 2、下载保存到指定部署路径 - * 3、启动采集器 - */ - - HttpDownloader httpDownloader = new HttpDownloader(null); - String url = "http://192.168.16.110:9113/sch/file/download?filePath=collector_packages/20230718/91d930e6-0490-44e5-9756-caee3251d645/navicat.zip"; - String fileName = "collector.zip"; - String savePath = "H:\\docus\\1"; //部署路径 - String procName = "navicat.exe"; //进程名称 - - httpDownloader.downLoadFromUrl(url, fileName, savePath); - ZipUtil.unzip(savePath + "\\" + fileName, savePath + "\\collector"); - StartUpExeUtils.startUpExe(savePath + "\\collector\\" + procName, procName); - } - - public static void main(String[] args) throws Exception { - test(); - } public static void test1() throws Exception { ZipUtil.unzip("/Users/linruifeng/Desktop/collector_packages/collector.zip", "/Users/linruifeng/Desktop/collector_packages"); diff --git a/pom.xml b/pom.xml index b7a4580..c26ae6c 100644 --- a/pom.xml +++ b/pom.xml @@ -221,17 +221,17 @@ org.mapstruct mapstruct - ${org.mapstruct.version} + 1.4.1.Final org.mapstruct mapstruct-jdk8 - ${org.mapstruct.version} + 1.4.1.Final org.mapstruct mapstruct-processor - ${org.mapstruct.version} + 1.4.1.Final