diff --git a/docus-api-common/src/main/java/com/docus/server/common/util/YmlUtil.java b/docus-api-common/src/main/java/com/docus/server/common/util/YmlUtil.java
new file mode 100644
index 0000000..a5fd667
--- /dev/null
+++ b/docus-api-common/src/main/java/com/docus/server/common/util/YmlUtil.java
@@ -0,0 +1,52 @@
+package com.docus.server.common.util;
+
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * @version 1.0
+ * @Description 动态操作yml配置文件工具类
+ * 【需要将config配置文件夹和项目jar包放在同级别目录下,这样修改config下的配置文件后,jvm才能及时得获取新的配置】
+ * @date Mar 24, 2022
+ */
+public class YmlUtil {
+
+ public static LinkedHashMap loadYaml(String fileName) throws Exception {
+ String path = System.getProperty("user.dir");
+
+ File file = new File(path + "/config/" + fileName);
+ InputStream in;
+ if (file.exists()) {
+ in = new FileInputStream(path + "/config/" + fileName);
+ } else {
+ // TODO 如果没有config文件夹,则从项目的resources目录下找
+ in = YmlUtil.class.getClassLoader().getResourceAsStream(fileName);
+ }
+
+ LinkedHashMap lhm = new Yaml().loadAs(in, LinkedHashMap.class);
+ return lhm;
+ }
+
+ public static Object getValByKey(Map lhm, String key) throws Exception {
+ String[] keys = key.split("[.]");
+ Map ymlInfo = lhm;
+ for (int i = 0; i < keys.length; i++) {
+ Object value = ymlInfo.get(keys[i]);
+ if (i < keys.length - 1) {
+ ymlInfo = (Map) value;
+ } else if (value == null) {
+ throw new Exception("key不存在");
+ } else {
+ return value;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/docus-client-interface/src/main/java/com/docus/server/api/collector/update/CollectorUpdateApi.java b/docus-client-interface/src/main/java/com/docus/server/api/collector/update/CollectorUpdateApi.java
new file mode 100644
index 0000000..1e41dc2
--- /dev/null
+++ b/docus-client-interface/src/main/java/com/docus/server/api/collector/update/CollectorUpdateApi.java
@@ -0,0 +1,33 @@
+package com.docus.server.api.collector.update;
+
+import com.docus.server.vo.collector.update.CollectorUpdateVersionVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * 采集器更新 API
+ *
+ * @author AutoGenerator
+ * @since 2023-08-29
+ */
+@FeignClient(value = "docus-collector-update", contextId = "docus-collector-update.CollectorUpdateApi")
+@RequestMapping("/collector/update")
+public interface CollectorUpdateApi {
+
+ /**
+ * 采集器版本号
+ */
+ @GetMapping("/find")
+ CollectorUpdateVersionVO find() throws Exception;
+
+ /**
+ * 采集器部署包下载
+ */
+ @GetMapping("/download")
+ void downloadFile(HttpServletResponse response) throws Exception;
+
+}
diff --git a/docus-client-interface/src/main/java/com/docus/server/vo/collector/update/CollectorUpdateVersionVO.java b/docus-client-interface/src/main/java/com/docus/server/vo/collector/update/CollectorUpdateVersionVO.java
new file mode 100644
index 0000000..3549ab1
--- /dev/null
+++ b/docus-client-interface/src/main/java/com/docus/server/vo/collector/update/CollectorUpdateVersionVO.java
@@ -0,0 +1,30 @@
+package com.docus.server.vo.collector.update;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+
+/**
+ * 采集器更新配置 VO
+ *
+ * @author AutoGenerator
+ * @since 2023-08-29
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel(value = "CollectorUpdateVersionVO", description = "采集器更新配置")
+public class CollectorUpdateVersionVO implements Serializable {
+
+ @ApiModelProperty(value = "采集器版本号")
+ @JsonProperty(value = "UpdateNumber")
+ private String updateNumber;
+
+}
diff --git a/docus-collector-update/WinSW.exe b/docus-collector-update/WinSW.exe
new file mode 100644
index 0000000..6806bb4
Binary files /dev/null and b/docus-collector-update/WinSW.exe differ
diff --git a/docus-collector-update/assembly.xml b/docus-collector-update/assembly.xml
new file mode 100644
index 0000000..cbd39ff
--- /dev/null
+++ b/docus-collector-update/assembly.xml
@@ -0,0 +1,73 @@
+
+
+ exe
+
+ dir
+
+ false
+
+
+
+
+ /lib
+ ${basedir}/target/lib
+
+
+
+ /config
+ ${basedir}/target/resources
+ 0755
+
+ *.xml
+ *.yml
+ *.properties
+
+
+
+
+ /dataConfig
+ ${basedir}/target/dataConfig
+ 0755
+
+ *.json
+
+
+
+
+ /
+ ${basedir}/target/resources/bin
+ 0755
+
+ *.bat
+
+
+
+
+ /
+ ${basedir}/target/resources/bin
+ 0755
+
+ *.xml
+
+
+
+
+ /
+ ${basedir}
+ 0755
+
+ *.exe
+
+
+
+
+ ${basedir}/target
+ /
+ 0755
+
+ ${project.build.finalName}.jar
+
+
+
+
\ No newline at end of file
diff --git a/docus-collector-update/pom.xml b/docus-collector-update/pom.xml
new file mode 100644
index 0000000..cd62973
--- /dev/null
+++ b/docus-collector-update/pom.xml
@@ -0,0 +1,185 @@
+
+
+ docus-collector-server
+ com.docus
+ 1.0-SNAPSHOT
+
+ 4.0.0
+ docus-collector-update
+ Archetype - docus-collector-update
+ http://maven.apache.org
+
+
+
+ com.docus
+ docus-api-common
+ 1.0-SNAPSHOT
+ compile
+
+
+
+ org.freemarker
+ freemarker
+ 2.3.30
+
+
+
+ cn.smallbun.screw
+ screw-core
+ 1.0.3
+
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.4.4
+
+ ZIP
+
+
+ non-exists
+ non-exists
+
+
+
+
+
+
+ repackage
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+
+ target/lib
+ false
+ false
+ runtime
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.2.0
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+
+
+ src/main/resources
+
+ **/*.*
+
+
+
+ ${project.build.directory}/resources
+
+
+
+ copy-bin
+ package
+
+ copy-resources
+
+
+
+
+ src/main/resources
+ true
+
+ bin/*.xml
+ bin/*.bat
+ *.yml
+ *.ftl
+
+
+
+ ${project.build.directory}/resources
+
+
+
+ copy-data-config
+ package
+
+ copy-resources
+
+
+
+
+ ../../dataConfig
+ true
+
+
+ ${project.build.directory}/dataConfig
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+
+ **/*.yml
+
+
+
+
+
+ maven-assembly-plugin
+
+
+
+ ${project.artifactId}
+ false
+
+ assembly.xml
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
+
+
+
diff --git a/docus-collector-update/src/main/java/com/docus/server/AppBootstrap.java b/docus-collector-update/src/main/java/com/docus/server/AppBootstrap.java
new file mode 100644
index 0000000..f3f9731
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/AppBootstrap.java
@@ -0,0 +1,18 @@
+package com.docus.server;
+
+import com.docus.log.EnableTrackGroup;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@EnableTrackGroup
+@EnableAsync
+@EnableFeignClients(basePackages = {"com.docus.core.excel.feign", "com.docus.server.api.collector.update"})
+@SpringBootApplication(scanBasePackages = {"com.docus"})
+public class AppBootstrap {
+ public static void main(String[] args) {
+ System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
+ SpringApplication.run(AppBootstrap.class, args);
+ }
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/CodeGenerator.java b/docus-collector-update/src/main/java/com/docus/server/CodeGenerator.java
new file mode 100644
index 0000000..741f973
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/CodeGenerator.java
@@ -0,0 +1,35 @@
+package com.docus.server;
+
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.rules.DateType;
+import com.docus.infrastructure.generator.BaseCodeGenerator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class CodeGenerator {
+ public static void main(String[] args) {
+ //字段名和枚举名的映射,不区分表名
+ Map enumColumnMap = new HashMap<>();
+ enumColumnMap.put("PROFILE_ITЕM", "AdminProfileItemEnum");
+
+ enumColumnMap.put("ORGANIZATION_TYPE", "OrganizationTypeEnum ");
+ enumColumnMap.put("OPERATE_STATUS", "OperateStatusEnum");
+ enumColumnMap.put("STATE", "StateEnum");
+ enumColumnMap.put("PRIVILEGE_LEVEL", "PrivilegeLevelEnum");
+ enumColumnMap.put("FLAG", "FlagEnum");
+ enumColumnMap.put("collect_type", "CollectTypeEnum");
+ BaseCodeGenerator.setEnumColumnMap(enumColumnMap);
+ BaseCodeGenerator.setModuleName("docus-segmentation");//多个module,需要指定modulename
+ //指定entity生成到独立module里,并生成 api interface
+ BaseCodeGenerator.setClientInterfaceModuleName("docus-client-interface");
+ BaseCodeGenerator.setClientInterfaceSubFolder("segmentation");//文件夹
+ BaseCodeGenerator.setClientInterfaceBasePackage("com.docus.server");
+ AutoGenerator defaultConfig = BaseCodeGenerator.getDefaultConfig();
+ defaultConfig.getGlobalConfig().setSwagger2(true);
+ defaultConfig.getGlobalConfig().setDateType(DateType.ONLY_DATE);
+ defaultConfig.getStrategy().setEntityLombokModel(true);
+ defaultConfig.getStrategy().setInclude("");//需要生成的表,可指定多个,留空为全部生成
+ BaseCodeGenerator.generate(defaultConfig);
+ }
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEvent.java b/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEvent.java
new file mode 100644
index 0000000..6ce2a70
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEvent.java
@@ -0,0 +1,58 @@
+package com.docus.server.common.event;
+
+import com.docus.infrastructure.core.db.enums.IIntegerEnum;
+import lombok.Getter;
+import org.springframework.context.ApplicationEvent;
+
+/**
+ * 流程事件
+ */
+@Getter
+public class FlowEvent extends ApplicationEvent {
+ /**
+ * 业务系统病案主键
+ */
+ private final String patientId;
+ /**
+ * 自动分段流程类型
+ */
+ private final FlowTypeEnum flowTypeEnum;
+
+ public FlowEvent(Object source, String patientId, FlowTypeEnum flowTypeEnum) {
+ super(source);
+ this.patientId = patientId;
+ this.flowTypeEnum = flowTypeEnum;
+ }
+
+
+ public enum FlowTypeEnum implements IIntegerEnum {
+ //正式
+ START_SEGMENT(1, "开始分段事件"),
+ START_OCR(2, "开始OCR事件"),
+ START_UPLOAD(3, "开始上传归档系统事件"),
+
+ //调试
+ START_SEGMENT_TEST(4, "开始分段测试事件"),
+ START_OCR_TEST(5, "开始OCR测试事件"),
+ START_UPLOAD_TEST(6, "开始上传归档系统测试事件");
+
+ private Integer value;
+ private String display;
+
+ FlowTypeEnum(Integer value, String display) {
+ this.value = value;
+ this.display = display;
+ }
+
+ @Override
+ public Integer getValue() {
+ return this.value;
+ }
+
+ @Override
+ public String getDisplay() {
+ return this.display;
+ }
+ }
+
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEventListener.java b/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEventListener.java
new file mode 100644
index 0000000..38bb060
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/common/event/FlowEventListener.java
@@ -0,0 +1,26 @@
+package com.docus.server.common.event;
+
+import com.docus.log.executor.TrackRetrySpringExecutor;
+import com.docus.log.handler.IJobHandler;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.event.EventListener;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class FlowEventListener {
+
+ @EventListener
+ @Async("threadPoolExecutor")
+ public void flowListen(FlowEvent fileEvent) throws Exception {
+
+ FlowEvent.FlowTypeEnum flowTypeEnum = fileEvent.getFlowTypeEnum();
+
+ IJobHandler jobHandler = TrackRetrySpringExecutor.loadJobHandler(flowTypeEnum.name());
+
+ jobHandler.execute(fileEvent.getPatientId());
+
+ }
+
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/common/utils/StartUpExeUtils.java b/docus-collector-update/src/main/java/com/docus/server/common/utils/StartUpExeUtils.java
new file mode 100644
index 0000000..cdb387e
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/common/utils/StartUpExeUtils.java
@@ -0,0 +1,198 @@
+package com.docus.server.common.utils;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+public class StartUpExeUtils {
+
+ public static void main(String[] args) throws Exception {
+// startUpExeOnly("H:\\tools\\Navicat Premium 12免安装\\Navicat Premium 12\\navicat.exe");
+// killExeOnly("navicat.exe");
+
+// startUpExe("H:\\tools\\Navicat Premium 12免安装\\Navicat Premium 12\\navicat.exe", "navicat.exe");
+ restartTerminal("");
+ }
+
+ private static boolean startExeStatus = true;//exe启动状态
+
+ //重启终端
+ public static String restartTerminal(String bat) throws IOException, InterruptedException {
+ Process process = Runtime.getRuntime().exec(bat);
+
+ int exitCode = process.waitFor();
+
+ if (exitCode == 0) {
+ System.out.println("Command executed successfully.");
+ return "Command executed successfully.";
+ } else {
+ System.out.println("Command execution failed.");
+ return "Command executed failed.";
+ }
+ }
+
+ //重启虚拟机
+ public static String restartComputer() throws IOException, InterruptedException {
+ Process process = Runtime.getRuntime().exec("shutdown /r /t 0");
+
+ int exitCode = process.waitFor();
+
+ if (exitCode == 0) {
+ System.out.println("Command executed successfully.");
+ return "Command executed successfully.";
+ } else {
+ System.out.println("Command execution failed.");
+ return "Command executed failed.";
+ }
+ }
+
+ //仅启动exe客户端,不检查进程
+ public static void startUpExeOnly(String exePath) throws IOException {
+ if (exePath != "") {
+ Runtime.getRuntime().exec(exePath);
+ }
+ }
+
+ /**
+ * 仅kill指定进程
+ *
+ * @param procName
+ * @throws IOException
+ */
+ public static void killExeOnly(String procName) throws IOException {
+ if (procName != "") {
+ String command = "taskkill /F /IM " + procName;
+ Runtime.getRuntime().exec("cmd /c " + command);
+ }
+ }
+
+ //启动exe客户端
+ public static boolean startUpExe(String exePath, String procName) {
+ if (exePath != "" && procName != "") {
+ String result = checkProcess(procName);//检查exe进程
+ if (result.isEmpty()) {
+ try {
+ Runtime.getRuntime().exec(exePath);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("程序:" + exePath + "不存在!");
+ }
+ }
+ }
+ return startExeStatus;
+ }
+
+ //启动exe客户端,并传参
+ public static boolean startUpExe(String exePath, String procName, int subId, String curModeId, String riskSet1, String riskSet2, String riskSet3) {
+ if (exePath != "" && procName != "") {
+ String result = checkProcess(procName);//检查exe进程
+ if (result.isEmpty()) {
+ try {
+ //启动exe执行程序
+ String[] cmd = {exePath, subId + "", curModeId, riskSet1, riskSet2, riskSet3};
+ Runtime.getRuntime().exec(cmd);
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.out.println("程序:" + exePath + "不存在!");
+ }
+ }
+ }
+ return startExeStatus;
+ }
+
+ /**
+ * 检查进程是否存在,存在则杀死进程
+ *
+ * @param procName
+ */
+ public static String checkProcess(String procName) {
+ String result = "";
+ //判断是否存在进程
+ Boolean existProc = false;
+ BufferedReader bufferedReader = null;
+ try {
+ Process proc = Runtime.getRuntime().exec("tasklist -fi " + '"' + "imagename eq " + procName + '"');
+ bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (line.contains(procName)) {
+ existProc = true;//存在
+ }
+ }
+ } catch (Exception ex) {
+ result = "查询程序进程异常:" + ex.getMessage();
+ System.out.println("查询程序进程异常:" + ex.getMessage());
+ return result;
+ } finally {
+ if (bufferedReader != null) {
+ try {
+ bufferedReader.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+
+ // 存在,则先杀死该进程
+ if (existProc) {
+ BufferedReader br = null;
+ try {
+ if (procName != "") {
+ //执行cmd命令
+ String command = "taskkill /F /IM " + procName;
+ Runtime runtime = Runtime.getRuntime();
+ Process process = runtime.exec("cmd /c " + command);
+ br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
+ String line = null;
+ StringBuilder build = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ build.append(line);
+ }
+ }
+ } catch (Exception e) {
+ result = "关闭程序进程异常:" + e.getMessage();
+ System.out.println("关闭程序进程异常:" + e.getMessage());
+ return result;
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * 仅检查进程是否存在
+ *
+ * @param procName
+ */
+ public static boolean checkProcessOnly(String procName) {
+ //判断是否存在进程
+ Boolean existProc = false;
+ BufferedReader bufferedReader = null;
+ try {
+ Process proc = Runtime.getRuntime().exec("tasklist -fi " + '"' + "imagename eq " + procName + '"');
+ bufferedReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
+ String line = null;
+ while ((line = bufferedReader.readLine()) != null) {
+ if (line.contains(procName)) {
+ existProc = true;//存在
+ }
+ }
+ } catch (Exception ex) {
+ System.out.println("查询程序进程异常:" + ex.getMessage());
+ return existProc;
+ } finally {
+ if (bufferedReader != null) {
+ try {
+ bufferedReader.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+ return existProc;
+ }
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/common/utils/SystemInfoUtils.java b/docus-collector-update/src/main/java/com/docus/server/common/utils/SystemInfoUtils.java
new file mode 100644
index 0000000..9219cc6
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/common/utils/SystemInfoUtils.java
@@ -0,0 +1,313 @@
+package com.docus.server.common.utils;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import oshi.SystemInfo;
+import oshi.hardware.CentralProcessor;
+import oshi.hardware.GlobalMemory;
+import oshi.hardware.HardwareAbstractionLayer;
+import oshi.hardware.NetworkIF;
+import oshi.software.os.FileSystem;
+import oshi.software.os.OSFileStore;
+import oshi.software.os.OperatingSystem;
+import oshi.util.Util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.DecimalFormat;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * 系统消息工具类
+ **/
+public class SystemInfoUtils {
+
+ private static final int OSHI_WAIT_SECOND = 1000;
+ private static final int SLEEP_TIME = 2 * 1000;
+ private static SystemInfo systemInfo = new SystemInfo();
+ private static HardwareAbstractionLayer hardware = systemInfo.getHardware();
+ private static OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
+
+ public static void main(String[] args) throws Exception {
+ JSONObject info = getInfo();
+ System.out.println(info);
+ }
+
+ public static JSONObject getCpuInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ CentralProcessor processor = hardware.getProcessor();
+ // CPU信息
+ long[] prevTicks = processor.getSystemCpuLoadTicks();
+ Util.sleep(OSHI_WAIT_SECOND);
+ long[] ticks = processor.getSystemCpuLoadTicks();
+ long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
+ long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
+ long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
+ long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
+ long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
+ long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
+ long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
+ long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
+ long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
+ //cpu核数
+ cpuInfo.put("cpuNum", processor.getLogicalProcessorCount());
+ //cpu系统使用率
+ cpuInfo.put("cSys", new DecimalFormat("#.##%").format(cSys * 1.0 / totalCpu));
+ //cpu用户使用率
+ cpuInfo.put("user", new DecimalFormat("#.##%").format(user * 1.0 / totalCpu));
+ //cpu当前等待率
+ cpuInfo.put("iowait", new DecimalFormat("#.##%").format(iowait * 1.0 / totalCpu));
+ //cpu当前使用率
+ cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu)));
+ return cpuInfo;
+ }
+
+ /**
+ * 系统jvm信息
+ */
+ public static JSONObject getJvmInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ Properties props = System.getProperties();
+ Runtime runtime = Runtime.getRuntime();
+ long jvmTotalMemoryByte = runtime.totalMemory();
+ long freeMemoryByte = runtime.freeMemory();
+ //jvm总内存
+ cpuInfo.put("total", formatByte(runtime.totalMemory()));
+ //空闲空间
+ cpuInfo.put("free", formatByte(runtime.freeMemory()));
+ //jvm最大可申请
+ cpuInfo.put("max", formatByte(runtime.maxMemory()));
+ //vm已使用内存
+ cpuInfo.put("user", formatByte(jvmTotalMemoryByte - freeMemoryByte));
+ //jvm内存使用率
+ cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((jvmTotalMemoryByte - freeMemoryByte) * 1.0 / jvmTotalMemoryByte));
+ //jdk版本
+ cpuInfo.put("jdkVersion", props.getProperty("java.version"));
+ //jdk路径
+ cpuInfo.put("jdkHome", props.getProperty("java.home"));
+ return cpuInfo;
+ }
+
+ /**
+ * 系统内存信息
+ */
+ public static JSONObject getMemInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ GlobalMemory memory = systemInfo.getHardware().getMemory();
+ //总内存
+ long totalByte = memory.getTotal();
+ //剩余
+ long acaliableByte = memory.getAvailable();
+ //总内存
+ cpuInfo.put("total", formatByte(totalByte));
+ //使用
+ cpuInfo.put("used", formatByte(totalByte - acaliableByte));
+ //剩余内存
+ cpuInfo.put("free", formatByte(acaliableByte));
+ //使用率
+ cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte));
+ return cpuInfo;
+ }
+
+ /**
+ * 带宽
+ */
+ public static JSONArray networkIFs() throws Exception {
+ JSONObject cpuInfo;
+ JSONArray sysFiles = new JSONArray();
+
+ List networkIFs = systemInfo.getHardware().getNetworkIFs();
+ for (NetworkIF networkIF : networkIFs) {
+ String name = networkIF.getName();
+ long receiveBytes = networkIF.getBytesRecv();
+ long transmitBytes = networkIF.getBytesSent();
+
+ cpuInfo = new JSONObject();
+ //名称
+ cpuInfo.put("name", name);
+ //网络接收
+ cpuInfo.put("receiveBytes", formatNumber(receiveBytes / (1024.0 * (2 * 1000 / 1000))));
+ //网络发送
+ cpuInfo.put("transmitBytes", formatNumber(transmitBytes / (1024.0 * (2 * 1000 / 1000))));
+
+ sysFiles.add(cpuInfo);
+ }
+ return sysFiles;
+ }
+
+ public static JSONObject getNetWork() {
+ JSONObject networkInfo = new JSONObject();
+ Properties props = System.getProperties();
+ String os = props.getProperty("os.name").toLowerCase();
+ os = os.startsWith("win") ? "windows" : "linux";
+ Map result = new HashMap<>();
+ Process pro = null;
+ Runtime r = Runtime.getRuntime();
+ BufferedReader input = null;
+ try {
+ String command = "windows".equals(os) ? "netstat -e" : "ifconfig";
+ pro = r.exec(command);
+ input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
+ long result1[] = readInLine(input, os);
+ Thread.sleep(SLEEP_TIME);
+ pro.destroy();
+ input.close();
+ pro = r.exec(command);
+ input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
+ long result2[] = readInLine(input, os);
+ String rxPercent = formatNumber((result2[0] - result1[0]) / (1024.0 * (SLEEP_TIME / 1000)));// 下行速率(kB/s)
+ String txPercent = formatNumber((result2[1] - result1[1]) / (1024.0 * (SLEEP_TIME / 1000)));// 上行速率(kB/s)
+ networkInfo.put("rxPercent", rxPercent);
+ networkInfo.put("txPercent", txPercent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ Optional.ofNullable(pro).ifPresent(p -> p.destroy());
+ }
+ return networkInfo;
+ }
+
+ private static long[] readInLine(BufferedReader input, String osType) {
+ long arr[] = new long[2];
+ StringTokenizer tokenStat = null;
+ try {
+ if (osType.equals("linux")) { // 获取linux环境下的网口上下行速率
+ long rx = 0, tx = 0;
+ String line = null;
+ //RX packets:4171603 errors:0 dropped:0 overruns:0 frame:0
+ //TX packets:4171603 errors:0 dropped:0 overruns:0 carrier:0
+ while ((line = input.readLine()) != null) {
+ if (line.indexOf("RX packets") >= 0) {
+ rx += Long.parseLong(line.substring(line.indexOf("RX packets") + 11, line.indexOf(" ", line.indexOf("RX packets") + 11)));
+ } else if (line.indexOf("TX packets") >= 0) {
+ tx += Long.parseLong(line.substring(line.indexOf("TX packets") + 11, line.indexOf(" ", line.indexOf("TX packets") + 11)));
+ }
+ }
+ arr[0] = rx;
+ arr[1] = tx;
+ } else { // 获取windows环境下的网口上下行速率
+ input.readLine();
+ input.readLine();
+ input.readLine();
+ input.readLine();
+ tokenStat = new StringTokenizer(input.readLine());
+ tokenStat.nextToken();
+ arr[0] = Long.parseLong(tokenStat.nextToken());
+ arr[1] = Long.parseLong(tokenStat.nextToken());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+
+ private static String formatNumber(double f) {
+ return new Formatter().format("%.2f", f).toString();
+ }
+
+ /**
+ * 系统盘符信息
+ */
+ public static JSONArray getSysFileInfo() {
+ JSONObject cpuInfo;
+ JSONArray sysFiles = new JSONArray();
+ FileSystem fileSystem = operatingSystem.getFileSystem();
+ List fsArray = fileSystem.getFileStores();
+ for (OSFileStore fs : fsArray) {
+ cpuInfo = new JSONObject();
+ //盘符路径
+ cpuInfo.put("dirName", fs.getMount());
+ //盘符类型
+ cpuInfo.put("sysTypeName", fs.getType());
+ //文件类型
+ cpuInfo.put("typeName", fs.getName());
+ //总大小
+ cpuInfo.put("total", formatByte(fs.getTotalSpace()));
+ //剩余大小
+ cpuInfo.put("free", formatByte(fs.getUsableSpace()));
+ //已经使用量
+ cpuInfo.put("used", formatByte(fs.getTotalSpace() - fs.getUsableSpace()));
+ if (fs.getTotalSpace() == 0) {
+ //资源的使用率
+ cpuInfo.put("usage", 0);
+ } else {
+ cpuInfo.put("usage", new DecimalFormat("#.##%").format((fs.getTotalSpace() - fs.getUsableSpace()) * 1.0 / fs.getTotalSpace()));
+ }
+ sysFiles.add(cpuInfo);
+ }
+ return sysFiles;
+ }
+
+ /**
+ * 系统信息
+ */
+ public static JSONObject getSysInfo() throws UnknownHostException {
+ JSONObject cpuInfo = new JSONObject();
+ Properties props = System.getProperties();
+ //操作系统名
+ cpuInfo.put("osName", props.getProperty("os.name"));
+ //系统架构
+ cpuInfo.put("osArch", props.getProperty("os.arch"));
+ //服务器名称
+ cpuInfo.put("computerName", InetAddress.getLocalHost().getHostName());
+ //服务器Ip
+ cpuInfo.put("computerIp", InetAddress.getLocalHost().getHostAddress());
+ //项目路径
+ cpuInfo.put("userDir", props.getProperty("user.dir"));
+ return cpuInfo;
+ }
+
+
+ /**
+ * 所有系统信息
+ */
+ public static JSONObject getInfo() throws Exception {
+ JSONObject info = new JSONObject();
+ info.put("cpuInfo", getCpuInfo());
+ info.put("jvmInfo", getJvmInfo());
+ info.put("memInfo", getMemInfo());
+ info.put("sysInfo", getSysInfo());
+ info.put("sysFileInfo", getSysFileInfo());
+ info.put("networkInfo", getNetWork());
+ return info;
+ }
+
+ /**
+ * 单位转换
+ */
+ private static String formatByte(long byteNumber) {
+ //换算单位
+ double FORMAT = 1024.0;
+ double kbNumber = byteNumber / FORMAT;
+ if (kbNumber < FORMAT) {
+ return new DecimalFormat("#.##KB").format(kbNumber);
+ }
+ double mbNumber = kbNumber / FORMAT;
+ if (mbNumber < FORMAT) {
+ return new DecimalFormat("#.##MB").format(mbNumber);
+ }
+ double gbNumber = mbNumber / FORMAT;
+ if (gbNumber < FORMAT) {
+ return new DecimalFormat("#.##GB").format(gbNumber);
+ }
+ double tbNumber = gbNumber / FORMAT;
+ return new DecimalFormat("#.##TB").format(tbNumber);
+ }
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/controller/CollectorUpdateController.java b/docus-collector-update/src/main/java/com/docus/server/controller/CollectorUpdateController.java
new file mode 100644
index 0000000..511f9c1
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/controller/CollectorUpdateController.java
@@ -0,0 +1,48 @@
+package com.docus.server.controller;
+
+import com.docus.server.api.collector.update.CollectorUpdateApi;
+import com.docus.server.common.service.IFileUploadService;
+import com.docus.server.service.ICollectorUpdateService;
+import com.docus.server.vo.collector.update.CollectorUpdateVersionVO;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 患者信息表 控制器类
+ *
+ * @author AutoGenerator
+ * @since 2023-08-29
+ */
+@Api(value = "采集器更新配置", tags = "采集器更新配置")
+@RestController
+public class CollectorUpdateController implements CollectorUpdateApi {
+ @Resource
+ private ICollectorUpdateService iCollectorUpdateService;
+ @Resource
+ private IFileUploadService iFileUploadService;
+
+ /**
+ * 获取采集器版本号
+ */
+ @ApiOperation("获取采集器版本号")
+ @Override
+ public CollectorUpdateVersionVO find() throws Exception {
+ return iCollectorUpdateService.find();
+ }
+
+ /**
+ * 采集器部署包下载
+ */
+ @ApiOperation("采集器部署包下载")
+ @Override
+ public void downloadFile(HttpServletResponse response) throws Exception {
+
+ String filePath = iCollectorUpdateService.getFilePath();
+
+ iFileUploadService.downloadFile(filePath, response);
+ }
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/infrastructure/cache/TaskCacheLayer.java b/docus-collector-update/src/main/java/com/docus/server/infrastructure/cache/TaskCacheLayer.java
new file mode 100644
index 0000000..6fea6c6
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/infrastructure/cache/TaskCacheLayer.java
@@ -0,0 +1,7 @@
+package com.docus.server.infrastructure.cache;
+
+import com.docus.server.annotation.CacheLayer;
+
+@CacheLayer("schetaskCacheLayer")
+public class TaskCacheLayer {
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/infrastructure/client/DownLoadAPI.java b/docus-collector-update/src/main/java/com/docus/server/infrastructure/client/DownLoadAPI.java
new file mode 100644
index 0000000..56f84f1
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/infrastructure/client/DownLoadAPI.java
@@ -0,0 +1,4 @@
+package com.docus.server.infrastructure.client;
+
+public class DownLoadAPI {
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/service/ICollectorUpdateService.java b/docus-collector-update/src/main/java/com/docus/server/service/ICollectorUpdateService.java
new file mode 100644
index 0000000..faebae1
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/service/ICollectorUpdateService.java
@@ -0,0 +1,17 @@
+package com.docus.server.service;
+
+import com.docus.server.vo.collector.update.CollectorUpdateVersionVO;
+
+/**
+ * 患者信息表 服务接口
+ *
+ * @author AutoGenerator
+ * @since 2023-08-29
+ */
+public interface ICollectorUpdateService {
+
+ CollectorUpdateVersionVO find() throws Exception;
+
+ String getFilePath() throws Exception;
+
+}
diff --git a/docus-collector-update/src/main/java/com/docus/server/service/impl/CollectorUpdateServiceImpl.java b/docus-collector-update/src/main/java/com/docus/server/service/impl/CollectorUpdateServiceImpl.java
new file mode 100644
index 0000000..22b2ee8
--- /dev/null
+++ b/docus-collector-update/src/main/java/com/docus/server/service/impl/CollectorUpdateServiceImpl.java
@@ -0,0 +1,43 @@
+package com.docus.server.service.impl;
+
+import com.docus.server.common.util.YmlUtil;
+import com.docus.server.service.ICollectorUpdateService;
+import com.docus.server.vo.collector.update.CollectorUpdateVersionVO;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.LinkedHashMap;
+
+/**
+ * 患者信息表 服务实现类
+ *
+ * @author AutoGenerator
+ * @since 2023-08-29
+ */
+@Service
+@Slf4j
+public class CollectorUpdateServiceImpl implements ICollectorUpdateService {
+
+ @Override
+ public CollectorUpdateVersionVO find() throws Exception {
+
+ String version = loadYaml("docus.collector.version");
+
+ return CollectorUpdateVersionVO.builder().updateNumber(version).build();
+ }
+
+ @Override
+ public String getFilePath() throws Exception {
+
+ return loadYaml("docus.collector.download-folder");
+ }
+
+ public String loadYaml(String key) throws Exception {
+ LinkedHashMap params = YmlUtil.loadYaml("bootstrap.yml");
+
+ return (String) YmlUtil.getValByKey(params, key);
+
+ }
+
+}
+
diff --git a/docus-collector-update/src/main/resources/application.properties b/docus-collector-update/src/main/resources/application.properties
new file mode 100644
index 0000000..b940360
--- /dev/null
+++ b/docus-collector-update/src/main/resources/application.properties
@@ -0,0 +1,9 @@
+#当前项目的根package
+api.base-package=com.docus.server
+
+spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+spring.datasource.url=jdbc:mysql://db.docus.cn:3306/docus_ocr?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
+spring.datasource.username=docus
+spring.datasource.password=docus702
+
+mybatis-plus.type-enums-package=com.docus.server.enums
diff --git a/docus-collector-update/src/main/resources/bin/auto.bat b/docus-collector-update/src/main/resources/bin/auto.bat
new file mode 100644
index 0000000..b07af42
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/auto.bat
@@ -0,0 +1,6 @@
+@echo off
+
+
+WinSW.exe status|findstr NonExistent && winsw install
+
+WinSW.exe status|findstr stopped && winsw start
diff --git a/docus-collector-update/src/main/resources/bin/jenkins-update.bat b/docus-collector-update/src/main/resources/bin/jenkins-update.bat
new file mode 100644
index 0000000..19d3f53
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/jenkins-update.bat
@@ -0,0 +1,21 @@
+@echo off
+
+set deployDir=%1\@project.artifactId@
+if %deployDir%=="" set deployDir=d:\webroot\@project.artifactId@
+
+set curr_file=%cd%
+cd /d %deployDir%
+call stop.bat
+sc query @project.artifactId@ |Find "RUNNING" && ping 127.0.0.1 -n 10 >nul
+cd %curr_file%
+rd/s/q %deployDir%\lib
+rd/s/q %deployDir%\dataConfig
+rd/s/q %deployDir%\config
+rd/s/q %deployDir%\mybatis.mapper
+del /s/q %deployDir%\*.jar
+xcopy /Y/E/I * %deployDir%
+
+cd /d %deployDir%
+call auto.bat
+cd %curr_file%
+
diff --git a/docus-collector-update/src/main/resources/bin/start.bat b/docus-collector-update/src/main/resources/bin/start.bat
new file mode 100644
index 0000000..58c25cb
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/start.bat
@@ -0,0 +1,21 @@
+set java_opts=-Xms512m -Xmx512m
+set key="java_opts"
+
+
+rem 文件不存在,就跳过
+if not exist java-ops.ini goto end
+
+for /f "tokens=1,2 delims==" %%i in (java-ops.ini) do (
+ if "%%i"==%key% set java_opts=%%j)
+echo java_opts is : %java_opts%
+
+:end
+
+rem 启动java
+
+java %java_opts% -Dfile.encoding=utf-8 -jar -Dspring.profiles.active=@profile.name@ -Dloader.path=config,lib @project.build.finalName@.jar
+
+
+
+
+
diff --git a/docus-collector-update/src/main/resources/bin/stop.bat b/docus-collector-update/src/main/resources/bin/stop.bat
new file mode 100644
index 0000000..1e224c0
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/stop.bat
@@ -0,0 +1,3 @@
+@echo off
+
+winsw stop
diff --git a/docus-collector-update/src/main/resources/bin/update.bat b/docus-collector-update/src/main/resources/bin/update.bat
new file mode 100644
index 0000000..67730ec
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/update.bat
@@ -0,0 +1,47 @@
+@echo off
+
+set curr_file=%cd%
+
+set parentDir=%1
+if %parentDir%=="" set deployDir=d:\webroot
+
+
+set deployDir=%parentDir%\@project.artifactId@
+
+set backupDir=%parentDir%\backup
+
+set dateStr=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
+
+
+cd /d %deployDir%
+
+call stop.bat
+sc query @project.artifactId@ |Find "RUNNING" && ping 127.0.0.1 -n 10 >nul
+
+cd /d %parentDir%
+
+xcopy /Y/E/I project.artifactId@\lib %backupDir%\%dateStr%\@project.artifactId@lib
+xcopy /Y/E/I project.artifactId@\config %backupDir%\%dateStr%\@project.artifactId@config
+xcopy /Y/E/I project.artifactId@\*.jar %backupDir%\%dateStr%\@project.artifactId@
+xcopy /Y/E/I project.artifactId@\*.bat %backupDir%\%dateStr%\@project.artifactId@
+xcopy /Y/E/I project.artifactId@\*.exe %backupDir%\%dateStr%\@project.artifactId@
+xcopy /Y/E/I project.artifactId@\*.xml %backupDir%\%dateStr%\@project.artifactId@
+
+
+cd %curr_file%
+
+rd/s/q %deployDir%\lib
+rd/s/q %deployDir%\config
+del /s/q %deployDir%\*.jar
+
+
+xcopy /Y/E/I lib %deployDir%\lib
+xcopy /Y/E/I config %deployDir%\config
+xcopy /Y/E/I *.jar %deployDir%
+xcopy /Y/E/I *.bat %deployDir%
+xcopy /Y/E/I *.exe %deployDir%
+xcopy /Y/E/I *.xml %deployDir%
+
+cd /d %deployDir%
+call auto.bat
+cd %curr_file%
\ No newline at end of file
diff --git a/docus-collector-update/src/main/resources/bin/winsw.xml b/docus-collector-update/src/main/resources/bin/winsw.xml
new file mode 100644
index 0000000..9d5cf45
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bin/winsw.xml
@@ -0,0 +1,8 @@
+
+ docus-collector-update
+ 生产-采集器更新(docus-collector-update)-服务
+ 生产-采集器更新(docus-collector-update)-服务
+ Automatic
+ %BASE%\start.bat
+
+
\ No newline at end of file
diff --git a/docus-collector-update/src/main/resources/bootstrap.yml b/docus-collector-update/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..c33f306
--- /dev/null
+++ b/docus-collector-update/src/main/resources/bootstrap.yml
@@ -0,0 +1,45 @@
+server:
+ port: 9116
+spring:
+ profiles:
+ active: dev
+ application:
+ name: @artifactId@
+ servlet:
+ multipart:
+ max-file-size: 100MB
+ max-request-size: 200MB
+ redis:
+ host: redis.docus.cn
+ password: JSdocus@702
+ cloud:
+ nacos:
+ discovery:
+ server-addr: nacos.docus.cn
+ namespace: 34acdf7a-9fc6-4bbd-8aea-9a47c8007ad5
+ config:
+ server-addr: ${spring.cloud.nacos.discovery.server-addr}
+ namespace: 34acdf7a-9fc6-4bbd-8aea-9a47c8007ad5
+ file-extension: yml
+ shared-configs:
+ - comm.${spring.cloud.nacos.config.file-extension}
+
+mybatis-plus:
+ configuration:
+ map-underscore-to-camel-case: true
+ call-setters-on-nulls: true
+ jdbc-type-for-null: null
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+ global-config:
+ db-config:
+ update-strategy: ignored
+ field-strategy: NOT_EMPTY
+ db-type: MYSQL
+ mapper-locations: classpath*:/mapper/*Mapper.xml
+ type-enums-package: com.docus.server.enums
+
+
+docus:
+ collector:
+ version: 1.0.0.1
+ download-folder: D:\\JS\\UpateGD\\collector.zip
\ No newline at end of file
diff --git a/docus-collector-update/src/main/resources/log4jdbc.log4j2.properties b/docus-collector-update/src/main/resources/log4jdbc.log4j2.properties
new file mode 100644
index 0000000..5cb6f99
--- /dev/null
+++ b/docus-collector-update/src/main/resources/log4jdbc.log4j2.properties
@@ -0,0 +1,2 @@
+# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger
+log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
\ No newline at end of file
diff --git a/docus-collector-update/src/main/resources/logback.xml b/docus-collector-update/src/main/resources/logback.xml
new file mode 100644
index 0000000..71e872e
--- /dev/null
+++ b/docus-collector-update/src/main/resources/logback.xml
@@ -0,0 +1,104 @@
+
+
+ docus-collector-update
+
+
+
+
+ [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%contextName] [%thread] [%X{traceId}] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
+ [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n
+ utf-8
+
+
+
+
+ ${log.path}%d.%i.log
+
+ 500MB
+
+ 30
+
+
+
+
+
+ [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%X{traceId}] [%L] [%-5p] %m%n
+ utf-8
+
+
+
+
+ ${log.path}external%d.%i.log
+
+ 500MB
+
+ 30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docus-collector-update/src/test/java/com/docus/server/Example.java b/docus-collector-update/src/test/java/com/docus/server/Example.java
new file mode 100644
index 0000000..5a836ed
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/Example.java
@@ -0,0 +1,56 @@
+package com.docus.server;
+
+import oshi.SystemInfo;
+import oshi.hardware.CentralProcessor;
+import oshi.hardware.GlobalMemory;
+import oshi.hardware.HardwareAbstractionLayer;
+import oshi.hardware.NetworkIF;
+import oshi.software.os.FileSystem;
+import oshi.software.os.OSFileStore;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class Example {
+ public static void main(String[] args) {
+ SystemInfo systemInfo = new SystemInfo();
+ CentralProcessor processor = systemInfo.getHardware().getProcessor();
+ int logicalProcessorCount = processor.getLogicalProcessorCount();
+ String cpuModel = processor.getProcessorIdentifier().getName();
+ long[] systemCpuLoadTicks = processor.getSystemCpuLoadTicks();
+
+ System.out.println(logicalProcessorCount);
+ System.out.println(cpuModel);
+ System.out.println(Arrays.asList(systemCpuLoadTicks));
+
+ GlobalMemory memory = systemInfo.getHardware().getMemory();
+ long totalMemorySize = memory.getTotal();
+ long availableMemorySize = memory.getAvailable();
+ double memoryUsage = (totalMemorySize - availableMemorySize) * 100.0 / totalMemorySize;
+ System.out.println(totalMemorySize);
+ System.out.println(availableMemorySize);
+ System.out.println(memoryUsage);
+
+ HardwareAbstractionLayer hal = systemInfo.getHardware();
+ FileSystem fileSystem = systemInfo.getOperatingSystem().getFileSystem();
+ List fileStores = fileSystem.getFileStores();
+ for (OSFileStore store : fileStores) {
+ long totalSpace = store.getTotalSpace();
+ long usableSpace = store.getUsableSpace();
+ double usage = (totalSpace - usableSpace) * 100.0 / totalSpace;
+ System.out.println(totalSpace);
+ System.out.println(usableSpace);
+ System.out.println(usage);
+ }
+
+ List networkIFs = systemInfo.getHardware().getNetworkIFs();
+ for (NetworkIF networkIF : networkIFs) {
+ String name = networkIF.getName();
+ long receiveBytes = networkIF.getBytesRecv();
+ long transmitBytes = networkIF.getBytesSent();
+ System.out.println(name);
+ System.out.println(receiveBytes);
+ System.out.println(transmitBytes);
+ }
+ }
+}
diff --git a/docus-collector-update/src/test/java/com/docus/server/FileController.java b/docus-collector-update/src/test/java/com/docus/server/FileController.java
new file mode 100644
index 0000000..fdb8f49
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/FileController.java
@@ -0,0 +1,83 @@
+package com.docus.server;
+
+import cn.hutool.core.util.ZipUtil;
+import cn.hutool.http.HttpRequest;
+
+import com.google.common.collect.Lists;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 文件上传下载 API
+ *
+ * @author AutoGenerator
+ * @since 2023-07-15
+ */
+@SpringBootTest
+public class FileController {
+
+
+
+
+ public static void test1() throws Exception {
+ ZipUtil.unzip("/Users/linruifeng/Desktop/collector_packages/collector.zip", "/Users/linruifeng/Desktop/collector_packages");
+// ZipUtil.unGzip(new GZIPInputStream(new FileInputStream(new File("/Users/linruifeng/Desktop/collector_packages/index.tar.gz"))));
+// FileUtils.unTarGz("/Users/linruifeng/Desktop/collector_packages/", "/Users/linruifeng/Desktop/collector_packages/test");
+ }
+
+ @ApiOperation("test")
+ @PostMapping("/test")
+ public void test2() throws Exception {
+ File file = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
+ File file1 = new File("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174052\\麻醉.jpg");
+
+ Map data = new HashMap<>();
+ data.put("files", file);
+ data.put("filetype", "jpg");
+
+ ArrayList files = Lists.newArrayList(file, file1);
+
+ String body = HttpRequest.post("http://localhost:9115/file/upload")
+ .form("files", files.toArray(new File[files.size()]))
+ .form("pathKey", "{\n" +
+ " \"success\": true,\n" +
+ " \"datas\": [\n" +
+ " {\n" +
+ " \"index\": 0,\n" +
+ " \"file_type\": \"string\",\n" +
+ " \"angle\": \"string\",\n" +
+ " \"decline\": true,\n" +
+ " \"hand_shadow\": true,\n" +
+ " \"sort\": [\n" +
+ " \"string\"\n" +
+ " ],\n" +
+ " \"data\": [\n" +
+ " {\n" +
+ " \"boxes\": {\n" +
+ " \"left\": 0,\n" +
+ " \"right\": 0,\n" +
+ " \"top\": 0,\n" +
+ " \"bottom\": 0\n" +
+ " },\n" +
+ " \"text\": \"string\"\n" +
+ " }\n" +
+ " ]\n" +
+ " }\n" +
+ " ],\n" +
+ " \"time\": 0,\n" +
+ " \"message\": \"string\"\n" +
+ "}")
+ .contentType("multipart/form-data")
+ .execute()
+ .body();
+
+ System.out.println(body);
+
+ }
+}
diff --git a/docus-collector-update/src/test/java/com/docus/server/FileUtils.java b/docus-collector-update/src/test/java/com/docus/server/FileUtils.java
new file mode 100644
index 0000000..2010beb
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/FileUtils.java
@@ -0,0 +1,162 @@
+package com.docus.server;
+
+import org.apache.tools.tar.TarInputStream;
+
+import java.io.*;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * @program: JavaCode
+ * @ClassName FileUtils
+ * @description:
+ * @author: ltcz99
+ * @create: 2023-04-16
+ * @Version 1.0
+ **/
+public class FileUtils {
+
+
+ /**
+ * 解压tar.gz文件到指定目录
+ *
+ * @param sourceDir 源文件夹
+ * @param destDir 解压后的目标文件夹
+ */
+ public static void unTarGz(String sourceDir, String destDir) throws Exception {
+ File outFile = new File(sourceDir);
+ File[] files = outFile.listFiles();
+ try {
+ //创建输出目录
+ createDirectory(destDir, null);
+ TarInputStream tarIn;
+ int index = 1;
+ for (File file : files) {
+ if (file.getName().contains("tar.gz")) {
+ tarIn = new TarInputStream(new GZIPInputStream(
+ new BufferedInputStream(new FileInputStream(file))),
+ 1024 * 2);
+
+ String outFileName = destDir + "/" + file.getName();
+ OutputStream out = new FileOutputStream(new File(outFileName));
+ int length = 0;
+ byte[] b = new byte[2048];
+ while ((length = tarIn.read(b)) != -1) {
+ out.write(b, 0, length);
+ }
+ out.close();
+ tarIn.close();
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * 解压gz到指定的文件夹下面
+ *
+ * @param sourceDir
+ * @param destDir
+ */
+ public static void unGzipFile(String sourceDir, String destDir) {
+ //创建输出目录
+ createDirectory(destDir, null);
+ File sourceFile = new File(sourceDir);
+ File[] files = sourceFile.listFiles();
+ try {
+ int index = 1;
+ for (File file : files) {
+ if (file.getName().contains("gz")) {
+ FileInputStream fin = new FileInputStream(file);
+ //建立gzip解压工作流
+ GZIPInputStream gzin = new GZIPInputStream(fin);
+ //建立解压文件输出流
+ File tmpFile = new File(destDir + "/" + index++ + ".log");
+ FileOutputStream fout = new FileOutputStream(tmpFile);
+ int length;
+ byte[] buf = new byte[2048];
+ while ((length = gzin.read(buf, 0, buf.length)) != -1) {
+ fout.write(buf, 0, length);
+ }
+ gzin.close();
+ fout.close();
+ fin.close();
+ }
+ }
+ } catch (Exception ex) {
+ System.err.println(ex);
+ }
+ }
+
+ /**
+ * 读取文件到指定的文件夹下面
+ *
+ * @param sourceLogPath
+ * @param destLogPath
+ */
+ public static void readFileToDestLogPath(String sourceLogPath, String destLogPath) {
+ File sourceFile = new File(sourceLogPath);
+ File[] files = sourceFile.listFiles();
+ for (File file : files) {
+ String fileName = destLogPath + "/" + file.getName();
+ File destFile = new File(fileName);
+ if (file.getName().contains("log") && !fileName.contains("gz")) {
+ try {
+ if (destFile.exists()) {
+ destFile.delete();
+ }
+ String logFile = sourceFile + "/" + file.getName();
+ FileInputStream fis = new FileInputStream(logFile);
+ FileOutputStream fos = new FileOutputStream(destFile);
+ BufferedInputStream bis = new BufferedInputStream(fis);
+ BufferedOutputStream bos = new BufferedOutputStream(fos);
+ int len = 0;
+ while ((len = bis.read()) != -1) {
+ bos.write(len);
+ }
+ bos.flush();
+ // 关闭资源
+ fis.close();
+ bis.close();
+ fos.close();
+ bos.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 创建目录
+ *
+ * @param outputDir
+ * @param subDir
+ */
+ public static void createDirectory(String outputDir, String subDir) {
+ File file = new File(outputDir);
+ //子目录不为空
+ if (!(subDir == null || subDir.trim().equals(""))) {
+ file = new File(outputDir + "/" + subDir);
+ }
+ if (!file.exists()) {
+ if (!file.getParentFile().exists()) {
+ file.getParentFile().mkdirs();
+ }
+ file.mkdirs();
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ String sourceDir = "/Users/ltcz99/Downloads/templog";
+ String destDir = "/Users/ltcz99/Downloads/unzip/";
+ //解压.gz文件到指定的文件件下面
+ unGzipFile(sourceDir, destDir);
+ // 解压tar.gz文件到指定的文件夹下面
+ unTarGz(sourceDir, destDir);
+ //读取特定的文件到指定的文件夹下面
+ readFileToDestLogPath(sourceDir, destDir);
+ }
+}
diff --git a/docus-collector-update/src/test/java/com/docus/server/ImageProcessingExample.java b/docus-collector-update/src/test/java/com/docus/server/ImageProcessingExample.java
new file mode 100644
index 0000000..a6ebf7c
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/ImageProcessingExample.java
@@ -0,0 +1,60 @@
+package com.docus.server;
+
+import cn.hutool.core.img.ImgUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ImageProcessingExample {
+
+ public static void main(String[] args) throws Exception {
+
+// UploadBatchFileRequest uploadBatchFileParam = new UploadBatchFileRequest();
+// System.out.println(JSON.toJSON(uploadBatchFileParam));
+//
+// FileDTO fileDto = new FileDTO();
+// System.out.println(JSON.toJSON(fileDto));
+//
+// List fileDtoList = new ArrayList<>();
+// System.out.println(JSON.toJSON(fileDtoList));
+
+
+ // 1. 调整图片大小
+ ImgUtil.scale(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output-麻醉.jpg"), 0.5f);
+
+ // 2. 裁剪图片
+// ImgUtil.cut(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg"), FileUtil.file("C:\\Users\\dataexa\\Desktop\\output1.jpg"), new Rectangle(50, 50, 2400, (3527 / 2) / 2)); // 从input.jpg中裁剪出一个200x200的区域,保存为output.jpg
+
+ // 5. 图片旋转
+// Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("C:\\Users\\dataexa\\Desktop\\麻醉.jpg")), 90);
+// ImgUtil.write(image, FileUtil.file("C:\\Users\\dataexa\\Desktop\\output2.jpg"));
+
+// uploadByte("D:\\docus\\cut\\segmentation\\20230822\\c6b03e5767814895a2c155c32f174051\\麻醉.jpg");
+ }
+
+ public static void uploadByte(String path) {
+ File toFile = new File(path);
+ Map data = new HashMap();
+ data.put("file", toFile);
+ data.put("filetype", "jpg");
+ String body = HttpRequest.post("http://192.168.16.85:9999/uploadfile")
+ .form(data)
+ .contentType("multipart/form-data")
+ .execute()
+ .body();
+ if (StrUtil.isNotBlank(body)) {
+// OcrResponse jsonRootBean = JSON.parseObject(body, OcrResponse.class);
+// System.out.println(jsonRootBean);
+ }
+
+// Boolean success = (Boolean)result.get("success");
+// BigDecimal time = (BigDecimal)result.get("time");
+
+ }
+
+
+}
diff --git a/docus-collector-update/src/test/java/com/docus/server/SystemInfoUtils.java b/docus-collector-update/src/test/java/com/docus/server/SystemInfoUtils.java
new file mode 100644
index 0000000..a3f2ceb
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/SystemInfoUtils.java
@@ -0,0 +1,313 @@
+package com.docus.server;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import oshi.SystemInfo;
+import oshi.hardware.CentralProcessor;
+import oshi.hardware.GlobalMemory;
+import oshi.hardware.HardwareAbstractionLayer;
+import oshi.hardware.NetworkIF;
+import oshi.software.os.FileSystem;
+import oshi.software.os.OSFileStore;
+import oshi.software.os.OperatingSystem;
+import oshi.util.Util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.DecimalFormat;
+import java.util.Formatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+/**
+ * 系统消息工具类
+ **/
+public class SystemInfoUtils {
+
+ private static final int OSHI_WAIT_SECOND = 1000;
+ private static final int SLEEP_TIME = 2 * 1000;
+ private static SystemInfo systemInfo = new SystemInfo();
+ private static HardwareAbstractionLayer hardware = systemInfo.getHardware();
+ private static OperatingSystem operatingSystem = systemInfo.getOperatingSystem();
+
+ public static void main(String[] args) throws Exception {
+ JSONObject info = getInfo();
+ System.out.println(info);
+ }
+
+ public static JSONObject getCpuInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ CentralProcessor processor = hardware.getProcessor();
+ // CPU信息
+ long[] prevTicks = processor.getSystemCpuLoadTicks();
+ Util.sleep(OSHI_WAIT_SECOND);
+ long[] ticks = processor.getSystemCpuLoadTicks();
+ long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()];
+ long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()];
+ long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()];
+ long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()];
+ long cSys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()];
+ long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()];
+ long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()];
+ long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()];
+ long totalCpu = user + nice + cSys + idle + iowait + irq + softirq + steal;
+ //cpu核数
+ cpuInfo.put("cpuNum", processor.getLogicalProcessorCount());
+ //cpu系统使用率
+ cpuInfo.put("cSys", new DecimalFormat("#.##%").format(cSys * 1.0 / totalCpu));
+ //cpu用户使用率
+ cpuInfo.put("user", new DecimalFormat("#.##%").format(user * 1.0 / totalCpu));
+ //cpu当前等待率
+ cpuInfo.put("iowait", new DecimalFormat("#.##%").format(iowait * 1.0 / totalCpu));
+ //cpu当前使用率
+ cpuInfo.put("idle", new DecimalFormat("#.##%").format(1.0 - (idle * 1.0 / totalCpu)));
+ return cpuInfo;
+ }
+
+ /**
+ * 系统jvm信息
+ */
+ public static JSONObject getJvmInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ Properties props = System.getProperties();
+ Runtime runtime = Runtime.getRuntime();
+ long jvmTotalMemoryByte = runtime.totalMemory();
+ long freeMemoryByte = runtime.freeMemory();
+ //jvm总内存
+ cpuInfo.put("total", formatByte(runtime.totalMemory()));
+ //空闲空间
+ cpuInfo.put("free", formatByte(runtime.freeMemory()));
+ //jvm最大可申请
+ cpuInfo.put("max", formatByte(runtime.maxMemory()));
+ //vm已使用内存
+ cpuInfo.put("user", formatByte(jvmTotalMemoryByte - freeMemoryByte));
+ //jvm内存使用率
+ cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((jvmTotalMemoryByte - freeMemoryByte) * 1.0 / jvmTotalMemoryByte));
+ //jdk版本
+ cpuInfo.put("jdkVersion", props.getProperty("java.version"));
+ //jdk路径
+ cpuInfo.put("jdkHome", props.getProperty("java.home"));
+ return cpuInfo;
+ }
+
+ /**
+ * 系统内存信息
+ */
+ public static JSONObject getMemInfo() {
+ JSONObject cpuInfo = new JSONObject();
+ GlobalMemory memory = systemInfo.getHardware().getMemory();
+ //总内存
+ long totalByte = memory.getTotal();
+ //剩余
+ long acaliableByte = memory.getAvailable();
+ //总内存
+ cpuInfo.put("total", formatByte(totalByte));
+ //使用
+ cpuInfo.put("used", formatByte(totalByte - acaliableByte));
+ //剩余内存
+ cpuInfo.put("free", formatByte(acaliableByte));
+ //使用率
+ cpuInfo.put("usageRate", new DecimalFormat("#.##%").format((totalByte - acaliableByte) * 1.0 / totalByte));
+ return cpuInfo;
+ }
+
+ /**
+ * 带宽
+ */
+ public static JSONArray networkIFs() throws Exception {
+ JSONObject cpuInfo;
+ JSONArray sysFiles = new JSONArray();
+
+ List networkIFs = systemInfo.getHardware().getNetworkIFs();
+ for (NetworkIF networkIF : networkIFs) {
+ String name = networkIF.getName();
+ long receiveBytes = networkIF.getBytesRecv();
+ long transmitBytes = networkIF.getBytesSent();
+
+ cpuInfo = new JSONObject();
+ //名称
+ cpuInfo.put("name", name);
+ //网络接收
+ cpuInfo.put("receiveBytes", formatNumber(receiveBytes / (1024.0 * (2 * 1000 / 1000))));
+ //网络发送
+ cpuInfo.put("transmitBytes", formatNumber(transmitBytes / (1024.0 * (2 * 1000 / 1000))));
+
+ sysFiles.add(cpuInfo);
+ }
+ return sysFiles;
+ }
+
+ public static JSONObject getNetWork() {
+ JSONObject networkInfo = new JSONObject();
+ Properties props = System.getProperties();
+ String os = props.getProperty("os.name").toLowerCase();
+ os = os.startsWith("win") ? "windows" : "linux";
+ Map result = new HashMap<>();
+ Process pro = null;
+ Runtime r = Runtime.getRuntime();
+ BufferedReader input = null;
+ try {
+ String command = "windows".equals(os) ? "netstat -e" : "ifconfig";
+ pro = r.exec(command);
+ input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
+ long result1[] = readInLine(input, os);
+ Thread.sleep(SLEEP_TIME);
+ pro.destroy();
+ input.close();
+ pro = r.exec(command);
+ input = new BufferedReader(new InputStreamReader(pro.getInputStream()));
+ long result2[] = readInLine(input, os);
+ String rxPercent = formatNumber((result2[0] - result1[0]) / (1024.0 * (SLEEP_TIME / 1000)));// 下行速率(kB/s)
+ String txPercent = formatNumber((result2[1] - result1[1]) / (1024.0 * (SLEEP_TIME / 1000)));// 上行速率(kB/s)
+ networkInfo.put("rxPercent", rxPercent);
+ networkInfo.put("txPercent", txPercent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ if (input != null) {
+ try {
+ input.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ Optional.ofNullable(pro).ifPresent(p -> p.destroy());
+ }
+ return networkInfo;
+ }
+
+ private static long[] readInLine(BufferedReader input, String osType) {
+ long arr[] = new long[2];
+ StringTokenizer tokenStat = null;
+ try {
+ if (osType.equals("linux")) { // 获取linux环境下的网口上下行速率
+ long rx = 0, tx = 0;
+ String line = null;
+ //RX packets:4171603 errors:0 dropped:0 overruns:0 frame:0
+ //TX packets:4171603 errors:0 dropped:0 overruns:0 carrier:0
+ while ((line = input.readLine()) != null) {
+ if (line.indexOf("RX packets") >= 0) {
+ rx += Long.parseLong(line.substring(line.indexOf("RX packets") + 11, line.indexOf(" ", line.indexOf("RX packets") + 11)));
+ } else if (line.indexOf("TX packets") >= 0) {
+ tx += Long.parseLong(line.substring(line.indexOf("TX packets") + 11, line.indexOf(" ", line.indexOf("TX packets") + 11)));
+ }
+ }
+ arr[0] = rx;
+ arr[1] = tx;
+ } else { // 获取windows环境下的网口上下行速率
+ input.readLine();
+ input.readLine();
+ input.readLine();
+ input.readLine();
+ tokenStat = new StringTokenizer(input.readLine());
+ tokenStat.nextToken();
+ arr[0] = Long.parseLong(tokenStat.nextToken());
+ arr[1] = Long.parseLong(tokenStat.nextToken());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return arr;
+ }
+
+
+ private static String formatNumber(double f) {
+ return new Formatter().format("%.2f", f).toString();
+ }
+
+ /**
+ * 系统盘符信息
+ */
+ public static JSONArray getSysFileInfo() {
+ JSONObject cpuInfo;
+ JSONArray sysFiles = new JSONArray();
+ FileSystem fileSystem = operatingSystem.getFileSystem();
+ List fsArray = fileSystem.getFileStores();
+ for (OSFileStore fs : fsArray) {
+ cpuInfo = new JSONObject();
+ //盘符路径
+ cpuInfo.put("dirName", fs.getMount());
+ //盘符类型
+ cpuInfo.put("sysTypeName", fs.getType());
+ //文件类型
+ cpuInfo.put("typeName", fs.getName());
+ //总大小
+ cpuInfo.put("total", formatByte(fs.getTotalSpace()));
+ //剩余大小
+ cpuInfo.put("free", formatByte(fs.getUsableSpace()));
+ //已经使用量
+ cpuInfo.put("used", formatByte(fs.getTotalSpace() - fs.getUsableSpace()));
+ if (fs.getTotalSpace() == 0) {
+ //资源的使用率
+ cpuInfo.put("usage", 0);
+ } else {
+ cpuInfo.put("usage", new DecimalFormat("#.##%").format((fs.getTotalSpace() - fs.getUsableSpace()) * 1.0 / fs.getTotalSpace()));
+ }
+ sysFiles.add(cpuInfo);
+ }
+ return sysFiles;
+ }
+
+ /**
+ * 系统信息
+ */
+ public static JSONObject getSysInfo() throws UnknownHostException {
+ JSONObject cpuInfo = new JSONObject();
+ Properties props = System.getProperties();
+ //操作系统名
+ cpuInfo.put("osName", props.getProperty("os.name"));
+ //系统架构
+ cpuInfo.put("osArch", props.getProperty("os.arch"));
+ //服务器名称
+ cpuInfo.put("computerName", InetAddress.getLocalHost().getHostName());
+ //服务器Ip
+ cpuInfo.put("computerIp", InetAddress.getLocalHost().getHostAddress());
+ //项目路径
+ cpuInfo.put("userDir", props.getProperty("user.dir"));
+ return cpuInfo;
+ }
+
+
+ /**
+ * 所有系统信息
+ */
+ public static JSONObject getInfo() throws Exception {
+ JSONObject info = new JSONObject();
+ info.put("cpuInfo", getCpuInfo());
+ info.put("jvmInfo", getJvmInfo());
+ info.put("memInfo", getMemInfo());
+ info.put("sysInfo", getSysInfo());
+ info.put("sysFileInfo", getSysFileInfo());
+ info.put("networkInfo", getNetWork());
+ return info;
+ }
+
+ /**
+ * 单位转换
+ */
+ private static String formatByte(long byteNumber) {
+ //换算单位
+ double FORMAT = 1024.0;
+ double kbNumber = byteNumber / FORMAT;
+ if (kbNumber < FORMAT) {
+ return new DecimalFormat("#.##KB").format(kbNumber);
+ }
+ double mbNumber = kbNumber / FORMAT;
+ if (mbNumber < FORMAT) {
+ return new DecimalFormat("#.##MB").format(mbNumber);
+ }
+ double gbNumber = mbNumber / FORMAT;
+ if (gbNumber < FORMAT) {
+ return new DecimalFormat("#.##GB").format(gbNumber);
+ }
+ double tbNumber = gbNumber / FORMAT;
+ return new DecimalFormat("#.##TB").format(tbNumber);
+ }
+}
diff --git a/docus-collector-update/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java b/docus-collector-update/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java
new file mode 100644
index 0000000..9ecbf9c
--- /dev/null
+++ b/docus-collector-update/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java
@@ -0,0 +1,87 @@
+package com.docus.server;
+
+import cn.smallbun.screw.core.Configuration;
+import cn.smallbun.screw.core.engine.EngineConfig;
+import cn.smallbun.screw.core.engine.EngineFileType;
+import cn.smallbun.screw.core.engine.EngineTemplateType;
+import cn.smallbun.screw.core.execute.DocumentationExecute;
+import cn.smallbun.screw.core.process.ProcessConfig;
+import com.docus.server.api.ocr.OcrApi;
+import com.docus.server.vo.ocr.OcrResponse;
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+
+import javax.annotation.Resource;
+import javax.sql.DataSource;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+@SpringBootTest
+class ScrewTests {
+
+ @Autowired
+ private ApplicationContext applicationContext;
+ @Resource
+ private OcrApi ocrApi;
+
+ @Test
+ void test() {
+
+ HikariConfig hikariConfig = new HikariConfig();
+ hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
+ hikariConfig.setJdbcUrl("jdbc:mysql://db.docus.cn:3306/docus-collector-scheduling?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai");
+ hikariConfig.setUsername("docus");
+ hikariConfig.setPassword("docus702");
+ //设置可以获取tables remarks信息
+ hikariConfig.addDataSourceProperty("useInformationSchema", "true");
+ hikariConfig.setMinimumIdle(2);
+ hikariConfig.setMaximumPoolSize(5);
+ DataSource dataSource = new HikariDataSource(hikariConfig);
+
+ //生成文件配置
+ EngineConfig engineConfig = EngineConfig
+ .builder()
+ //文件生成路径
+ .fileOutputDir("h:\\file")
+ //打开目录
+ .openOutputDir(false)
+ //文件类型
+ .fileType(EngineFileType.HTML)
+ //生成模板实现
+ .produceType(EngineTemplateType.freemarker)
+ .build();
+ //配置想要生成的表
+ ProcessConfig processConfig = ProcessConfig
+ .builder()
+ //根据名称指定表生成
+ .designatedTableName(new ArrayList<>())
+ //根据表前缀生成
+ .designatedTablePrefix(new ArrayList<>())
+ //根据表后缀生成
+ .designatedTableSuffix(new ArrayList<>())
+ //忽略表名
+ .ignoreTableName(new ArrayList<>())
+ //忽略表前缀
+ .ignoreTablePrefix(new ArrayList<>())
+ //忽略表后缀
+ .ignoreTableSuffix(new ArrayList<>())
+ .build();
+ //生成文档配置
+ Configuration configuration = Configuration.builder()
+ .version("1.0.0")
+ .description("描述")
+ .dataSource(dataSource)
+ .engineConfig(engineConfig)
+ .produceConfig(processConfig)
+ .build();
+
+ //生成
+ new DocumentationExecute(configuration).execute();
+ }
+}
diff --git a/pom.xml b/pom.xml
index c26ae6c..49d1767 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
docus-collector-server
pom
- docus-segmentation
+ docus-collector-update
docus-api-common
docus-client-interface