diff --git a/collector-scheduling-management/pom.xml b/collector-scheduling-management/pom.xml index a35b222..c1e79e0 100644 --- a/collector-scheduling-management/pom.xml +++ b/collector-scheduling-management/pom.xml @@ -6,7 +6,7 @@ 1.0-SNAPSHOT 4.0.0 - collector-scheduling-management + collector-scheduling-management-linrf Archetype - collector-scheduling-management http://maven.apache.org diff --git a/collector-scheduling-management/src/main/java/com/docus/server/CodeGenerator.java b/collector-scheduling-management/src/main/java/com/docus/server/CodeGenerator.java index cf79a1d..bbe9875 100644 --- a/collector-scheduling-management/src/main/java/com/docus/server/CodeGenerator.java +++ b/collector-scheduling-management/src/main/java/com/docus/server/CodeGenerator.java @@ -1,33 +1,33 @@ -//package com.docus.server; -// -//import com.baomidou.mybatisplus.generator.AutoGenerator; -//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("collector-scheduling-management");//多个module,需要指定modulename -// //指定entity生成到独立module里,并生成 api interface -// BaseCodeGenerator.setClientInterfaceModuleName("docus-client-interface"); -// BaseCodeGenerator.setClientInterfaceSubFolder("scheduling.management");//文件夹 -// BaseCodeGenerator.setClientInterfaceBasePackage("com.docus.server"); -// AutoGenerator defaultConfig = BaseCodeGenerator.getDefaultConfig(); -// defaultConfig.getGlobalConfig().setSwagger2(true); -// defaultConfig.getStrategy().setEntityLombokModel(true); -// defaultConfig.getStrategy().setInclude("sch_virtual_log", "sch_collect_error_log", "sch_collect_record", "sch_collect_record_retry_log", "sch_collector", "sch_collector_config", "sch_collector_version", "sch_collector_version_file", "sch_collector_version_log", "sch_operation_log", "sch_system_params", "sch_terminator");//需要生成的表,可指定多个,留空为全部生成 -// BaseCodeGenerator.generate(defaultConfig); -// } -//} +package com.docus.server; + +import com.baomidou.mybatisplus.generator.AutoGenerator; +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("collector-scheduling-management");//多个module,需要指定modulename + //指定entity生成到独立module里,并生成 api interface + BaseCodeGenerator.setClientInterfaceModuleName("docus-client-interface"); + BaseCodeGenerator.setClientInterfaceSubFolder("scheduling.management");//文件夹 + BaseCodeGenerator.setClientInterfaceBasePackage("com.docus.server"); + AutoGenerator defaultConfig = BaseCodeGenerator.getDefaultConfig(); + defaultConfig.getGlobalConfig().setSwagger2(true); + defaultConfig.getStrategy().setEntityLombokModel(true); + defaultConfig.getStrategy().setInclude("sch_collector_copy1");//需要生成的表,可指定多个,留空为全部生成 + BaseCodeGenerator.generate(defaultConfig); + } +} diff --git a/collector-scheduling-management/src/main/java/com/docus/server/AppRunBootstrap.java b/collector-scheduling-management/src/main/java/com/docus/server/ScheduleBootstrap.java similarity index 83% rename from collector-scheduling-management/src/main/java/com/docus/server/AppRunBootstrap.java rename to collector-scheduling-management/src/main/java/com/docus/server/ScheduleBootstrap.java index 1f665fd..47bbea7 100644 --- a/collector-scheduling-management/src/main/java/com/docus/server/AppRunBootstrap.java +++ b/collector-scheduling-management/src/main/java/com/docus/server/ScheduleBootstrap.java @@ -5,14 +5,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.scheduling.annotation.EnableAsync; -import javax.annotation.PreDestroy; - @EnableAsync @EnableFeignClients(basePackages = {"com.docus.core.excel.feign", "com.docus.server.api.taskdistribute"}) @SpringBootApplication(scanBasePackages = {"com.docus"}) -public class AppRunBootstrap { +public class ScheduleBootstrap { public static void main(String[] args) { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); - SpringApplication.run(AppRunBootstrap.class, args); + SpringApplication.run(ScheduleBootstrap.class, args); } } diff --git a/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java b/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java index 9770f10..3d253b0 100644 --- a/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java +++ b/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java @@ -9,7 +9,6 @@ import com.docus.server.common.netty.server.ChannelRepository; import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; import com.docus.server.enums.BusyStateEnum; import com.docus.server.enums.OnlineStateEnum; -import com.fasterxml.jackson.core.type.TypeReference; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; @@ -22,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.io.Serializable; import java.net.InetSocketAddress; /** @@ -52,12 +52,11 @@ public class NettyBusinessHandler extends SimpleChannelInboundHandler { return; } - CommMsg commMsg = JSON.fromJSONWithGeneric(message, new TypeReference>() { - }); + CommMsg commMsg = JSON.fromJSON(message, CommMsg.class); String messageType = commMsg.getMessageType(); String messageTime = commMsg.getMessageTime(); - TerminatorContent messageContent = commMsg.getContent(); + Serializable messageContent = commMsg.getContent(); if (messageType.equals(MsgConstants.TERMINATOR_RESTART)) { log.info("接受到终端重启命令,内容{}", messageContent); diff --git a/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java b/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java index 6bac1c7..9d308c8 100644 --- a/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java +++ b/collector-scheduling-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java @@ -9,13 +9,13 @@ import com.docus.server.common.netty.server.ChannelRepository; import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; import com.docus.server.enums.BusyStateEnum; import com.docus.server.enums.OnlineStateEnum; -import com.fasterxml.jackson.core.type.TypeReference; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import lombok.extern.slf4j.Slf4j; +import java.io.Serializable; import java.net.InetSocketAddress; /** @@ -39,19 +39,18 @@ public class NettyHeartbeatHandler extends ChannelInboundHandlerAdapter { return; } - CommMsg commMsg = JSON.fromJSONWithGeneric(message, new TypeReference>() { - }); + CommMsg commMsg = JSON.fromJSON(message, CommMsg.class); String messageType = commMsg.getMessageType(); String messageTime = commMsg.getMessageTime(); - TerminatorContent messageContent = commMsg.getContent(); + Serializable content = commMsg.getContent(); if (messageType.equals(MsgConstants.HEARTBEAT_REQUEST)) { log.info("接收到客户端的心跳"); - log.info("接受到【采集器-终端】的心跳消息:消息类型={},消息时间={},消息内容={}", messageType, messageTime, messageContent); + log.info("接受到【采集器-终端】的心跳消息:消息类型={},消息时间={},消息内容={}", messageType, messageTime, content); InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress(); String clientIp = ipSocket.getAddress().getHostAddress(); diff --git a/collector-scheduling-management/src/main/resources/application.properties b/collector-scheduling-management/src/main/resources/application.properties index 63a543c..bde7d71 100644 --- a/collector-scheduling-management/src/main/resources/application.properties +++ b/collector-scheduling-management/src/main/resources/application.properties @@ -3,7 +3,7 @@ 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-collector-scheduling?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai -spring.datasource.username=root -spring.datasource.password=root +spring.datasource.username=docus +spring.datasource.password=docus702 mybatis-plus.type-enums-package=com.docus.server.enums diff --git a/collector-terminal-management/WinSW.exe b/collector-terminal-management/WinSW.exe new file mode 100644 index 0000000..6806bb4 Binary files /dev/null and b/collector-terminal-management/WinSW.exe differ diff --git a/collector-terminal-management/assembly.xml b/collector-terminal-management/assembly.xml new file mode 100644 index 0000000..cbd39ff --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/pom.xml b/collector-terminal-management/pom.xml new file mode 100644 index 0000000..d2224c7 --- /dev/null +++ b/collector-terminal-management/pom.xml @@ -0,0 +1,185 @@ + + + docus-collector-server + com.docus + 1.0-SNAPSHOT + + 4.0.0 + collector-terminal-management[0] + Archetype - collector-scheduling-management + 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/collector-terminal-management/src/main/java/com/docus/server/CodeGenerator.java b/collector-terminal-management/src/main/java/com/docus/server/CodeGenerator.java new file mode 100644 index 0000000..bbe9875 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/CodeGenerator.java @@ -0,0 +1,33 @@ +package com.docus.server; + +import com.baomidou.mybatisplus.generator.AutoGenerator; +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("collector-scheduling-management");//多个module,需要指定modulename + //指定entity生成到独立module里,并生成 api interface + BaseCodeGenerator.setClientInterfaceModuleName("docus-client-interface"); + BaseCodeGenerator.setClientInterfaceSubFolder("scheduling.management");//文件夹 + BaseCodeGenerator.setClientInterfaceBasePackage("com.docus.server"); + AutoGenerator defaultConfig = BaseCodeGenerator.getDefaultConfig(); + defaultConfig.getGlobalConfig().setSwagger2(true); + defaultConfig.getStrategy().setEntityLombokModel(true); + defaultConfig.getStrategy().setInclude("sch_collector_copy1");//需要生成的表,可指定多个,留空为全部生成 + BaseCodeGenerator.generate(defaultConfig); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/DefaultWebConfig.java b/collector-terminal-management/src/main/java/com/docus/server/DefaultWebConfig.java new file mode 100644 index 0000000..d9ec30b --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/DefaultWebConfig.java @@ -0,0 +1,17 @@ +package com.docus.server; + +import com.docus.infrastructure.WebConfig; +import com.docus.infrastructure.web.json.JsonSerializerModule; +import com.docus.server.common.serializer.DefJsonSerializerModule; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class DefaultWebConfig extends WebConfig { + + @Override + public JsonSerializerModule jsonSerializerModu1e() { + super.jsonSerializerModu1e(); + return new DefJsonSerializerModule(); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/TerminalBootstrap.java b/collector-terminal-management/src/main/java/com/docus/server/TerminalBootstrap.java new file mode 100644 index 0000000..93f3750 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/TerminalBootstrap.java @@ -0,0 +1,16 @@ +package com.docus.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableAsync; + +@EnableAsync +@EnableFeignClients(basePackages = {"com.docus.core.excel.feign", "com.docus.server.api.taskdistribute"}) +@SpringBootApplication(scanBasePackages = {"com.docus"}) +public class TerminalBootstrap { + public static void main(String[] args) { + System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"); + SpringApplication.run(TerminalBootstrap.class, args); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/MsgConstants.java b/collector-terminal-management/src/main/java/com/docus/server/common/MsgConstants.java new file mode 100644 index 0000000..019e9d9 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/MsgConstants.java @@ -0,0 +1,55 @@ +package com.docus.server.common; + +public class MsgConstants { + + /** + * 客户端与采集调度器心跳 + */ + public static final String HEARTBEAT_REQUEST = "0".trim(); + + /** + * 客户端上线注册 + */ + public static final String ONLINE_REGISTER = "1".trim(); + + /** + * 客户端下线移除 + */ + public static final String OFFLINE_REMOVE = "2".trim(); + + /** + * 客户端异常注册 + */ + public static final String EXCEPTION_REMOVE = "3".trim(); + + /** + * 终端重启命令 + */ + public static final String TERMINATOR_RESTART = "4".trim(); + + /** + * 采集器重启命令 + */ + public static final String COLLECTOR_RESTART = "5".trim(); + + /** + * 虚拟机重启命令 + */ + public static final String VIRTUAL_RESTART = "6".trim(); + + /** + * 更新采集器文件命令 + */ + public static final String UPDATE_COLLECTOR_FILE = "7".trim(); + + /** + * 更新采集器配置命令 + */ + public static final String UPDATE_COLLECTOR_CONFIG = "8".trim(); + + /** + * 采集调度器下发任务命令 + */ + public static final String SCH_DISTRIBUTE_TASKS = "9".trim(); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/RedisCollectorTaskKeyExpirationListener.java b/collector-terminal-management/src/main/java/com/docus/server/common/RedisCollectorTaskKeyExpirationListener.java new file mode 100644 index 0000000..ab0057e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/RedisCollectorTaskKeyExpirationListener.java @@ -0,0 +1,30 @@ +package com.docus.server.common; + +import com.docus.infrastructure.redis.listener.RedisKeyExpirationListener; +import com.docus.server.service.impl.RedisKeyExpirationService; +import org.springframework.data.redis.listener.RedisMessageListenerContainer; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +@Component +public class RedisCollectorTaskKeyExpirationListener extends RedisKeyExpirationListener { + + @Resource + private RedisKeyExpirationService redisKeyExpirationService; + + public RedisCollectorTaskKeyExpirationListener(RedisMessageListenerContainer listenerContainer) { + super(listenerContainer); + } + + @Override + protected void processExpireKey(String expireKey) { + redisKeyExpirationService.expired(expireKey); + } + + @Override + protected boolean validExpireKey(String expireKey) { + return expireKey.startsWith("schCollectorRecord:noRetryTask:expireKey:") + || expireKey.startsWith("schCollectorRecord:isRetryTask:expireKey:"); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/SchCollectorTask.java b/collector-terminal-management/src/main/java/com/docus/server/common/SchCollectorTask.java new file mode 100644 index 0000000..287085c --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/SchCollectorTask.java @@ -0,0 +1,439 @@ +package com.docus.server.common; + +import com.docus.core.util.DateUtil; +import com.docus.core.util.Func; +import com.docus.core.util.json.JSON; +import com.docus.infrastructure.redis.service.RedisOps; +import com.docus.server.api.taskdistribute.TaskDistributeApi; +import com.docus.server.common.netty.CommMsg; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportTaskTwoDTO; +import com.docus.server.dto.scheduling.management.schcollector.task.SchCollectorTaskDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.RetryTaskEnum; +import com.docus.server.service.ISchCollectRecordRetryLogService; +import com.docus.server.service.ISchCollectRecordService; +import com.docus.server.service.ISchCollectorService; +import com.docus.server.service.ISchTerminatorService; +import com.google.common.collect.Lists; +import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; +import io.netty.util.CharsetUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingQueue; + +@Component +@Slf4j +public class SchCollectorTask { + @Resource + private ChannelRepository channelRepository; + @Resource + private TaskDistributeApi taskDistributeApi; + @Resource + private ISchCollectRecordService iSchCollectRecordService; + @Resource + private ISchCollectRecordRetryLogService iSchCollectRecordRetryLogService; + @Resource + private ISchTerminatorService iSchTerminatorService; + @Resource + private ISchCollectorService iSchCollectorService; + @Resource + private RedisOps redisOps; + + private BlockingQueue retryTaskQueue = new LinkedBlockingQueue<>(); + + //定时任务 + // 5 * * * * ? 在每分钟的5秒执行 + @Scheduled(cron = "0/1 * * * * ?") + public void runTask() { + try { + log.info("定时任务: 开始执行"); + + //在线并且空闲的终端 + List terminalList = channelRepository.getAvailTerminator(); + + //没有可用的通道 + if (Func.isEmpty(terminalList)) { + return; + } + + //:todo 任务平台需要修改发布任务策略 + List reportDownTwoDTOList = getTask(terminalList.size()); + + if (Func.isEmpty(reportDownTwoDTOList) || Func.isBlank(reportDownTwoDTOList.get(0).getPatientId())) { + return; + } + + //只采集,有优先级的 + for (NettyTerminatorDTO terminal : terminalList) { + for (ReportDownTwoDTO report : reportDownTwoDTOList) { + //先找出有只采集的任务。 + ReportTaskTwoDTO reportTaskTwoDto = report.getTasks().get(0); + if (!CollectionUtils.isEmpty(terminal.getOnlyCollectorIds()) && terminal.getOnlyCollectorIds().contains(reportTaskTwoDto.getCollectorId()) + && BusyStateEnum.IDLE.equals(terminal.getBusyState())) { + //把这个任务派给这个终端,并且把这个终端设置成繁忙 + if (!CollectionUtils.isEmpty(terminal.getPriorityCollectorIds()) && terminal.getPriorityCollectorIds().contains(reportTaskTwoDto.getCollectorId())) { + //把这个任务派给这个终端 + terminal.setBusyState(BusyStateEnum.BUSY); + iSchTerminatorService.saveOrUpdate(terminal.getTerminatorIp(), terminal); + + tcpToClient(terminal, report); + } + return; + } + } + } + + //只采集没有优先级 + for (NettyTerminatorDTO terminal : terminalList) { + //把刚才已经分配任务过的采集器排除 + if (BusyStateEnum.BUSY.equals(terminal.getBusyState())) { + continue; + } + + for (ReportDownTwoDTO report : reportDownTwoDTOList) { + //先找出有只采集的任务。 + ReportTaskTwoDTO reportTaskTwoDto = report.getTasks().get(0); + if (!CollectionUtils.isEmpty(terminal.getOnlyCollectorIds()) && terminal.getOnlyCollectorIds().contains(reportTaskTwoDto.getCollectorId()) + && BusyStateEnum.IDLE.equals(terminal.getBusyState())) { + //把这个任务派给这个终端,并且把这个终端设置成繁忙 + terminal.setBusyState(BusyStateEnum.BUSY); + iSchTerminatorService.saveOrUpdate(terminal.getTerminatorIp(), terminal); + + tcpToClient(terminal, report); + return; + } + } + } + + + //无只采集,有优先级 + for (NettyTerminatorDTO terminal : terminalList) { + + //把刚才已经分配任务过的采集器排除 + if (BusyStateEnum.BUSY.equals(terminal.getBusyState())) { + continue; + } + + for (ReportDownTwoDTO report : reportDownTwoDTOList) { + //先找出有只采集的任务。 + ReportTaskTwoDTO reportTaskTwoDto = report.getTasks().get(0); + if (!CollectionUtils.isEmpty(terminal.getPriorityCollectorIds()) && terminal.getPriorityCollectorIds().contains(reportTaskTwoDto.getCollectorId()) + && BusyStateEnum.IDLE.equals(terminal.getBusyState())) { + //把这个任务派给这个终端 + terminal.setBusyState(BusyStateEnum.BUSY); + iSchTerminatorService.saveOrUpdate(terminal.getTerminatorIp(), terminal); + + tcpToClient(terminal, report); + return; + } + } + } + + + //无只采集,无优先级 + for (NettyTerminatorDTO terminal : terminalList) { + + //把刚才已经分配任务过的采集器排除 + if (BusyStateEnum.BUSY.equals(terminal.getBusyState())) { + continue; + } + + for (ReportDownTwoDTO report : reportDownTwoDTOList) { + //先找出有只采集的任务。 + //把这个任务派给这个终端 + ReportTaskTwoDTO reportTaskTwoDto = report.getTasks().get(0); + terminal.setBusyState(BusyStateEnum.BUSY); + iSchTerminatorService.saveOrUpdate(terminal.getTerminatorIp(), terminal); + + tcpToClient(terminal, report); + return; + } + } + + //只采集,空闲的。 + //获取只采集的任务,并且进行分配。 + for (NettyTerminatorDTO terminal : terminalList) { + //把刚才已经分配任务过的采集器排除 + if (BusyStateEnum.BUSY.equals(terminal.getBusyState())) { + continue; + } + + List onlyTaskInfos = getOnlyTaskInfos(terminal.getOnlyCollectorIds()); + + + if (CollectionUtils.isEmpty(onlyTaskInfos) || Func.isBlank(onlyTaskInfos.get(0).getPatientId())) { + return; + } + + for (ReportDownTwoDTO report : onlyTaskInfos) { + //将这条任务分配这个这个终端 + //下发 + terminal.setBusyState(BusyStateEnum.BUSY); + iSchTerminatorService.saveOrUpdate(terminal.getTerminatorIp(), terminal); + + tcpToClient(terminal, report); + + return; + } + } + log.info("定时任务: 执行完毕"); + } catch ( + Exception e) { + log.error("定时任务执行出错", e); + } + + } + + private void tcpToClient(NettyTerminatorDTO terminal, ReportDownTwoDTO reportDownTwoDTO) { + Channel channel = channelRepository.get(terminal.getTerminatorIp()); + + Map params = reportDownTwoDTO.getParams(); + + SchCollectorTaskDTO messageContent = new SchCollectorTaskDTO(); + + if (CollectionUtils.isEmpty(params)) { + //不是重试任务 + SchCollectRecord schCollectRecord = iSchCollectRecordService.saveOrUpdateRecord(terminal, reportDownTwoDTO); + + messageContent.setCollectorRecordId(schCollectRecord.getId()); + messageContent.setIsRetry(String.valueOf(RetryTaskEnum.NO_RETRY_TASK.getValue())); + messageContent.setTaskInfo(reportDownTwoDTO); + } else { + //重试任务 + SchCollectRecordRetryLog schCollectRecordRetryLog = iSchCollectRecordRetryLogService.saveOrUpdateRecordRetryLog(terminal, reportDownTwoDTO); + + messageContent.setCollectorRecordId(schCollectRecordRetryLog.getId()); + messageContent.setIsRetry(String.valueOf(RetryTaskEnum.RETRY_TASK.getValue())); + messageContent.setTaskInfo(reportDownTwoDTO); + } + + CommMsg commMsg = CommMsg.builder() + .messageType(MsgConstants.SCH_DISTRIBUTE_TASKS) + .messageTime(DateUtil.formatDateTime(new Date())) + .content(JSON.toJSON(messageContent)) + .build(); + + //tcp 下发任务到终端 + if (channel != null) { + channel.writeAndFlush(Unpooled.copiedBuffer(JSON.toJSON(commMsg), CharsetUtil.UTF_8)); + } + + String isRetry = messageContent.getIsRetry(); + Long collectorRecordId = messageContent.getCollectorRecordId(); + String collectorId = messageContent.getTaskInfo().getTasks().get(0).getCollectorId(); + SchCollector schCollector = iSchCollectorService.findByCollectorId(collectorId); + + if (RetryTaskEnum.NO_RETRY_TASK.equals(isRetry)) { + redisOps.setEx(String.format("schCollectorRecord:noRetryTask:expireKey:%s", collectorRecordId), String.valueOf(collectorRecordId), schCollector.getTaskTimeout()); + } else { + redisOps.setEx(String.format("schCollectorRecord:isRetryTask:expireKey:%s", collectorRecordId), String.valueOf(collectorRecordId), schCollector.getTaskTimeout()); + } + + + } + + + public void addRetryTask(ReportDownTwoDTO reportDownTwoDTO) { + this.retryTaskQueue.add(reportDownTwoDTO); + } + + + //根据有效终端,一次获取一批任务,例如10个终端,获取10个不同类型任务 + public List getTask(int size) throws InterruptedException { +// return taskDistributeApi.getTask(String.valueOf(size)); + + //mock + + String collectorId1 = "{\n" + + " \"createTime\": \"2022-12-03 12:39:30\",\n" + + " \"hospitals\": [\n" + + " {\n" + + " \"admissDate\": \"2023-12-31 01:01:01\",\n" + + " \"admissId\": \"amid_999901\",\n" + + " \"admissTimes\": 1,\n" + + " \"disDate\": \"2023-12-31 01:01:01\",\n" + + " \"disDeptName\": \"22222\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " }\n" + + " ],\n" + + " \"jzh\": \"jzh_999901\",\n" + + " \"patient\": {\n" + + " \"inpatientNo\": \"999901\",\n" + + " \"name\": \"ceshi\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " },\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"recordType\": \"1\",\n" + + " \"tasks\": [\n" + + " {\n" + + " \"collectorId\": \"1\",\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"taskId\": 834292710565826560\n" + + " }\n" + + " ]\n" + + "}"; + ReportDownTwoDTO reportDownTwoDTO1 = JSON.fromJSON(collectorId1, ReportDownTwoDTO.class); + + + String collectorId2 = "{\n" + + " \"createTime\": \"2022-12-03 12:39:30\",\n" + + " \"hospitals\": [\n" + + " {\n" + + " \"admissDate\": \"2023-12-31 01:01:01\",\n" + + " \"admissId\": \"amid_999901\",\n" + + " \"admissTimes\": 1,\n" + + " \"disDate\": \"2023-12-31 01:01:01\",\n" + + " \"disDeptName\": \"22222\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " }\n" + + " ],\n" + + " \"jzh\": \"jzh_999901\",\n" + + " \"patient\": {\n" + + " \"inpatientNo\": \"999901\",\n" + + " \"name\": \"ceshi\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " },\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"recordType\": \"1\",\n" + + " \"tasks\": [\n" + + " {\n" + + " \"collectorId\": \"2\",\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"taskId\": 834292712465846272\n" + + " }\n" + + " ]\n" + + "}"; + ReportDownTwoDTO reportDownTwoDTO2 = JSON.fromJSON(collectorId2, ReportDownTwoDTO.class); + + + String collectorId3 = "{\n" + + " \"createTime\": \"2023-01-09 19:26:11\",\n" + + " \"hospitals\": [\n" + + " {\n" + + " \"admissDate\": \"2023-12-31 01:01:01\",\n" + + " \"admissId\": \"amid_297974\",\n" + + " \"admissTimes\": 21,\n" + + " \"disDate\": \"2023-12-31 01:01:01\",\n" + + " \"disDeptName\": \"普外二科(甲乳胸烧伤整形)\",\n" + + " \"patientId\": \"772389719349678080\"\n" + + " }\n" + + " ],\n" + + " \"jzh\": \"jzh_297974\",\n" + + " \"patient\": {\n" + + " \"inpatientNo\": \"297974\",\n" + + " \"name\": \"曾美英\",\n" + + " \"patientId\": \"772389719349678080\"\n" + + " },\n" + + " \"patientId\": \"772389719349678080\",\n" + + " \"recordType\": \"1\",\n" + + " \"tasks\": [\n" + + " {\n" + + " \"collectorId\": \"3\",\n" + + " \"patientId\": \"772389719349678080\",\n" + + " \"taskId\": 838201379426750464\n" + + " }\n" + + " ]\n" + + "}"; + ReportDownTwoDTO reportDownTwoDTO3 = JSON.fromJSON(collectorId3, ReportDownTwoDTO.class); + +// List allTaskList = Lists.newArrayList(reportDownTwoDTO1, reportDownTwoDTO2, reportDownTwoDTO3); + List allTaskList = new ArrayList<>(); + + if (!CollectionUtils.isEmpty(this.retryTaskQueue)) { + ReportDownTwoDTO retryTask = (ReportDownTwoDTO) this.retryTaskQueue.take(); + //重试任务 + allTaskList.add(retryTask); + } + + return allTaskList; + + } + + //根据采集器id类型,一次获取一批采集器类型任务 + private List getOnlyTaskInfos(List collectorIds) { +// return taskDistributeApi.getTask(collectorIds.get(0)); + + //mock + + + String collectorId2 = "{\n" + + " \"createTime\": \"2022-12-03 12:39:30\",\n" + + " \"hospitals\": [\n" + + " {\n" + + " \"admissDate\": \"2023-12-31 01:01:01\",\n" + + " \"admissId\": \"amid_999901\",\n" + + " \"admissTimes\": 1,\n" + + " \"disDate\": \"2023-12-31 01:01:01\",\n" + + " \"disDeptName\": \"22222\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " }\n" + + " ],\n" + + " \"jzh\": \"jzh_999901\",\n" + + " \"patient\": {\n" + + " \"inpatientNo\": \"999901\",\n" + + " \"name\": \"ceshi\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " },\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"recordType\": \"1\",\n" + + " \"tasks\": [\n" + + " {\n" + + " \"collectorId\": \"2\",\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"taskId\": 834292712465846272\n" + + " }\n" + + " ]\n" + + "}"; + ReportDownTwoDTO reportDownTwoDTO2 = JSON.fromJSON(collectorId2, ReportDownTwoDTO.class); + + + String collectorId3 = "{\n" + + " \"createTime\": \"2022-12-03 12:39:30\",\n" + + " \"hospitals\": [\n" + + " {\n" + + " \"admissDate\": \"2023-12-31 01:01:01\",\n" + + " \"admissId\": \"amid_999901\",\n" + + " \"admissTimes\": 1,\n" + + " \"disDate\": \"2023-12-31 01:01:01\",\n" + + " \"disDeptName\": \"22222\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " }\n" + + " ],\n" + + " \"jzh\": \"jzh_999901\",\n" + + " \"patient\": {\n" + + " \"inpatientNo\": \"999901\",\n" + + " \"name\": \"ceshi\",\n" + + " \"patientId\": \"758878610105573376\"\n" + + " },\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"recordType\": \"1\",\n" + + " \"tasks\": [\n" + + " {\n" + + " \"collectorId\": \"3\",\n" + + " \"patientId\": \"758878610105573376\",\n" + + " \"taskId\": 834292883635392512\n" + + " }\n" + + " ]\n" + + "}"; + ReportDownTwoDTO reportDownTwoDTO3 = JSON.fromJSON(collectorId3, ReportDownTwoDTO.class); + + return Lists.newArrayList(reportDownTwoDTO2, reportDownTwoDTO3); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/TerminatorListener.java b/collector-terminal-management/src/main/java/com/docus/server/common/TerminatorListener.java new file mode 100644 index 0000000..14dda2f --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/TerminatorListener.java @@ -0,0 +1,31 @@ +package com.docus.server.common; + +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.OnlineStateEnum; +import com.docus.server.service.ISchTerminatorService; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 重启置空 + */ +@Component +public class TerminatorListener implements ApplicationListener { + @Resource + private ISchTerminatorService iSchTerminatorService; + + @Override + public void onApplicationEvent(ContextRefreshedEvent event) { + List terminators = iSchTerminatorService.findAll(); + terminators.forEach(p -> { + p.setBusyState(BusyStateEnum.IDLE); + p.setOnlineState(OnlineStateEnum.OFFLINE); + }); + iSchTerminatorService.batchUpdate(terminators); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/CommMsg.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/CommMsg.java new file mode 100644 index 0000000..ef7c42a --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/CommMsg.java @@ -0,0 +1,22 @@ +package com.docus.server.common.netty; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class CommMsg implements Serializable { + + public String messageType; + + public String messageTime; + + public MSG_CONTENT content; + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/Payload.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/Payload.java new file mode 100644 index 0000000..603e6c1 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/Payload.java @@ -0,0 +1,1073 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: CommMsg.proto + +package com.docus.server.common.netty; + +public final class Payload { + private Payload() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface MessageOrBuilder extends + // @@protoc_insertion_point(interface_extends:CommMsg) + com.google.protobuf.MessageOrBuilder { + + /** + * string client = 1; + * @return The client. + */ + String getClient(); + /** + * string client = 1; + * @return The bytes for client. + */ + com.google.protobuf.ByteString + getClientBytes(); + + /** + * .CommMsg.type cmd = 2; + * @return The enum numeric value on the wire for cmd. + */ + int getCmdValue(); + /** + * .CommMsg.type cmd = 2; + * @return The cmd. + */ + Message.type getCmd(); + + /** + * string content = 3; + * @return The content. + */ + String getContent(); + /** + * string content = 3; + * @return The bytes for content. + */ + com.google.protobuf.ByteString + getContentBytes(); + } + /** + * Protobuf type {@code CommMsg} + */ + public static final class Message extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:CommMsg) + MessageOrBuilder { + private static final long serialVersionUID = 0L; + // Use CommMsg.newBuilder() to construct. + private Message(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Message() { + client_ = ""; + cmd_ = 0; + content_ = ""; + } + + @Override + @SuppressWarnings({"unused"}) + protected Object newInstance( + UnusedPrivateParameter unused) { + return new Message(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private Message( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new NullPointerException(); + } + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + String s = input.readStringRequireUtf8(); + + client_ = s; + break; + } + case 16: { + int rawValue = input.readEnum(); + + cmd_ = rawValue; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + content_ = s; + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return Payload.internal_static_Message_descriptor; + } + + @Override + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return Payload.internal_static_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + /** + * Protobuf enum {@code CommMsg.type} + */ + public enum type + implements com.google.protobuf.ProtocolMessageEnum { + /** + *
+       *客户端心跳消息
+       * 
+ * + * HEARTBEAT_REQUEST = 0; + */ + HEARTBEAT_REQUEST(0), + /** + *
+       *服务端心跳消息
+       * 
+ * + * HEARTBEAT_RESPONSE = 1; + */ + HEARTBEAT_RESPONSE(1), + /** + *
+       * 认证
+       * 
+ * + * AUTH = 2; + */ + AUTH(2), + /** + *
+       *请求开始打印命令
+       * 
+ * + * PRINT = 3; + */ + PRINT(3), + /** + *
+       * 打印完成反馈
+       * 
+ * + * PRINT_DONE = 4; + */ + PRINT_DONE(4), + /** + *
+       * 随便是什么
+       * 
+ * + * WHATEVER = 5; + */ + WHATEVER(5), + UNRECOGNIZED(-1), + ; + + /** + *
+       *客户端心跳消息
+       * 
+ * + * HEARTBEAT_REQUEST = 0; + */ + public static final int HEARTBEAT_REQUEST_VALUE = 0; + /** + *
+       *服务端心跳消息
+       * 
+ * + * HEARTBEAT_RESPONSE = 1; + */ + public static final int HEARTBEAT_RESPONSE_VALUE = 1; + /** + *
+       * 认证
+       * 
+ * + * AUTH = 2; + */ + public static final int AUTH_VALUE = 2; + /** + *
+       *请求开始打印命令
+       * 
+ * + * PRINT = 3; + */ + public static final int PRINT_VALUE = 3; + /** + *
+       * 打印完成反馈
+       * 
+ * + * PRINT_DONE = 4; + */ + public static final int PRINT_DONE_VALUE = 4; + /** + *
+       * 随便是什么
+       * 
+ * + * WHATEVER = 5; + */ + public static final int WHATEVER_VALUE = 5; + + + @Override + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @Deprecated + public static type valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static type forNumber(int value) { + switch (value) { + case 0: return HEARTBEAT_REQUEST; + case 1: return HEARTBEAT_RESPONSE; + case 2: return AUTH; + case 3: return PRINT; + case 4: return PRINT_DONE; + case 5: return WHATEVER; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static final com.google.protobuf.Internal.EnumLiteMap< + type> internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public type findValueByNumber(int number) { + return type.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return Message.getDescriptor().getEnumTypes().get(0); + } + + private static final type[] VALUES = values(); + + public static type valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private type(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:CommMsg.type) + } + + public static final int CLIENT_FIELD_NUMBER = 1; + private volatile Object client_; + /** + * string client = 1; + * @return The client. + */ + @Override + public String getClient() { + Object ref = client_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + client_ = s; + return s; + } + } + /** + * string client = 1; + * @return The bytes for client. + */ + @Override + public com.google.protobuf.ByteString + getClientBytes() { + Object ref = client_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + client_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CMD_FIELD_NUMBER = 2; + private int cmd_; + /** + * .CommMsg.type cmd = 2; + * @return The enum numeric value on the wire for cmd. + */ + @Override public int getCmdValue() { + return cmd_; + } + /** + * .CommMsg.type cmd = 2; + * @return The cmd. + */ + @Override public type getCmd() { + @SuppressWarnings("deprecation") + type result = type.valueOf(cmd_); + return result == null ? type.UNRECOGNIZED : result; + } + + public static final int CONTENT_FIELD_NUMBER = 3; + private volatile Object content_; + /** + * string content = 3; + * @return The content. + */ + @Override + public String getContent() { + Object ref = content_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } + } + /** + * string content = 3; + * @return The bytes for content. + */ + @Override + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getClientBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, client_); + } + if (cmd_ != type.HEARTBEAT_REQUEST.getNumber()) { + output.writeEnum(2, cmd_); + } + if (!getContentBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, content_); + } + unknownFields.writeTo(output); + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getClientBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, client_); + } + if (cmd_ != type.HEARTBEAT_REQUEST.getNumber()) { + size += com.google.protobuf.CodedOutputStream + .computeEnumSize(2, cmd_); + } + if (!getContentBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, content_); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Message)) { + return super.equals(obj); + } + Message other = (Message) obj; + + if (!getClient() + .equals(other.getClient())) return false; + if (cmd_ != other.cmd_) return false; + if (!getContent() + .equals(other.getContent())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CLIENT_FIELD_NUMBER; + hash = (53 * hash) + getClient().hashCode(); + hash = (37 * hash) + CMD_FIELD_NUMBER; + hash = (53 * hash) + cmd_; + hash = (37 * hash) + CONTENT_FIELD_NUMBER; + hash = (53 * hash) + getContent().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static Message parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Message parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Message parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Message parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static Message parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static Message parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static Message parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static Message parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Message prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code CommMsg} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:CommMsg) + MessageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return Payload.internal_static_Message_descriptor; + } + + @Override + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return Payload.internal_static_Message_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Message.class, Builder.class); + } + + // Construct using com.venus.common.protobuf.Payload.CommMsg.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @Override + public Builder clear() { + super.clear(); + client_ = ""; + + cmd_ = 0; + + content_ = ""; + + return this; + } + + @Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return Payload.internal_static_Message_descriptor; + } + + @Override + public Message getDefaultInstanceForType() { + return Message.getDefaultInstance(); + } + + @Override + public Message build() { + Message result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @Override + public Message buildPartial() { + Message result = new Message(this); + result.client_ = client_; + result.cmd_ = cmd_; + result.content_ = content_; + onBuilt(); + return result; + } + + @Override + public Builder clone() { + return super.clone(); + } + @Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return super.setField(field, value); + } + @Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return super.setRepeatedField(field, index, value); + } + @Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return super.addRepeatedField(field, value); + } + @Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Message) { + return mergeFrom((Message)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Message other) { + if (other == Message.getDefaultInstance()) return this; + if (!other.getClient().isEmpty()) { + client_ = other.client_; + onChanged(); + } + if (other.cmd_ != 0) { + setCmdValue(other.getCmdValue()); + } + if (!other.getContent().isEmpty()) { + content_ = other.content_; + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @Override + public final boolean isInitialized() { + return true; + } + + @Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Message parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Message) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object client_ = ""; + /** + * string client = 1; + * @return The client. + */ + @Override + public String getClient() { + Object ref = client_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + client_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string client = 1; + * @return The bytes for client. + */ + @Override + public com.google.protobuf.ByteString + getClientBytes() { + Object ref = client_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + client_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string client = 1; + * @param value The client to set. + * @return This builder for chaining. + */ + public Builder setClient( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + client_ = value; + onChanged(); + return this; + } + /** + * string client = 1; + * @return This builder for chaining. + */ + public Builder clearClient() { + + client_ = getDefaultInstance().getClient(); + onChanged(); + return this; + } + /** + * string client = 1; + * @param value The bytes for client to set. + * @return This builder for chaining. + */ + public Builder setClientBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + client_ = value; + onChanged(); + return this; + } + + private int cmd_ = 0; + /** + * .CommMsg.type cmd = 2; + * @return The enum numeric value on the wire for cmd. + */ + @Override public int getCmdValue() { + return cmd_; + } + /** + * .CommMsg.type cmd = 2; + * @param value The enum numeric value on the wire for cmd to set. + * @return This builder for chaining. + */ + public Builder setCmdValue(int value) { + + cmd_ = value; + onChanged(); + return this; + } + /** + * .CommMsg.type cmd = 2; + * @return The cmd. + */ + @Override + public type getCmd() { + @SuppressWarnings("deprecation") + type result = type.valueOf(cmd_); + return result == null ? type.UNRECOGNIZED : result; + } + /** + * .CommMsg.type cmd = 2; + * @param value The cmd to set. + * @return This builder for chaining. + */ + public Builder setCmd(type value) { + if (value == null) { + throw new NullPointerException(); + } + + cmd_ = value.getNumber(); + onChanged(); + return this; + } + /** + * .CommMsg.type cmd = 2; + * @return This builder for chaining. + */ + public Builder clearCmd() { + + cmd_ = 0; + onChanged(); + return this; + } + + private Object content_ = ""; + /** + * string content = 3; + * @return The content. + */ + @Override + public String getContent() { + Object ref = content_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + content_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * string content = 3; + * @return The bytes for content. + */ + @Override + public com.google.protobuf.ByteString + getContentBytes() { + Object ref = content_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + content_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string content = 3; + * @param value The content to set. + * @return This builder for chaining. + */ + public Builder setContent( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + content_ = value; + onChanged(); + return this; + } + /** + * string content = 3; + * @return This builder for chaining. + */ + public Builder clearContent() { + + content_ = getDefaultInstance().getContent(); + onChanged(); + return this; + } + /** + * string content = 3; + * @param value The bytes for content to set. + * @return This builder for chaining. + */ + public Builder setContentBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + content_ = value; + onChanged(); + return this; + } + @Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:CommMsg) + } + + // @@protoc_insertion_point(class_scope:CommMsg) + private static final Message DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Message(); + } + + public static Message getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @Override + public Message parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new Message(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @Override + public Message getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_Message_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_Message_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\rCommMsg.proto\"\260\001\n\007Message\022\016\n\006client\030\001 " + + "\001(\t\022\032\n\003cmd\030\002 \001(\0162\r.CommMsg.type\022\017\n\007conte" + + "nt\030\003 \001(\t\"h\n\004type\022\025\n\021HEARTBEAT_REQUEST\020\000\022" + + "\026\n\022HEARTBEAT_RESPONSE\020\001\022\010\n\004AUTH\020\002\022\t\n\005PRI" + + "NT\020\003\022\016\n\nPRINT_DONE\020\004\022\014\n\010WHATEVER\020\005B$\n\031co" + + "m.venus.common.protobufB\007Payloadb\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_Message_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_Message_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_Message_descriptor, + new String[] { "Client", "Cmd", "Content", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClient.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClient.java new file mode 100644 index 0000000..93e1b7e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClient.java @@ -0,0 +1,71 @@ +package com.docus.server.common.netty.client; + +import com.docus.core.util.json.JSON; +import com.docus.server.common.netty.CommMsg; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.concurrent.TimeUnit; + +/** + * Created by 1-point at 2021/9/7 + * Netty客户端 + */ +@Slf4j +@Component +public class NettyClient { + + @Resource + private NettyClientProperties nettyProperties; + + @Value("${spring.application.name}") + private String appName; + + private SocketChannel socketChannel; + + /** + * 发送消息给服务端 + * + * @param message 消息内容 + */ + public void sendMessage(CommMsg message) { + boolean success = socketChannel.writeAndFlush(JSON.toJSON(message)).isSuccess(); + if (success) { + log.info("发送消息成功"); + } + } + + @PostConstruct + public void start() { + final EventLoopGroup group = new NioEventLoopGroup(); + Bootstrap bootstrap = new Bootstrap(); + bootstrap.group(group) + .channel(NioSocketChannel.class) + .remoteAddress(nettyProperties.getHost(), nettyProperties.getPort()) + .option(ChannelOption.SO_KEEPALIVE, true) + .option(ChannelOption.TCP_NODELAY, true) + .handler(new NettyClientInitializer(nettyProperties, this, appName)); + ChannelFuture future = bootstrap.connect(); + //客户端断线重连逻辑 + future.addListener((ChannelFutureListener) status -> { + if (status.isSuccess()) { + log.info("连接Netty服务端成功"); + } else { + log.warn("连接失败,进行断线重连"); + status.channel().eventLoop().schedule(this::start, nettyProperties.getReconnectSeconds(), TimeUnit.SECONDS); + } + }); + socketChannel = (SocketChannel) future.channel(); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientInitializer.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientInitializer.java new file mode 100644 index 0000000..75d34ca --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientInitializer.java @@ -0,0 +1,41 @@ +package com.docus.server.common.netty.client; + +import com.docus.server.common.netty.client.handler.ClientHandler; +import com.docus.server.common.netty.client.handler.HeartbeatHandler; +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.handler.timeout.IdleStateHandler; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; + + +@AllArgsConstructor +@NoArgsConstructor +public class NettyClientInitializer extends ChannelInitializer { + + private NettyClientProperties nettyProperties; + + private NettyClient nettyClient; + + private String appName; + + @Override + protected void initChannel(Channel channel) throws Exception { + channel.pipeline() + // 加载空闲监听器 + .addLast(new IdleStateHandler(nettyProperties.getReaderIdleTimeSeconds(), + nettyProperties.getWriterIdleTimeSeconds(), nettyProperties.getAllIdleTimeSeconds())) + // 加载加码解码处理器,同时解决粘包拆包问题 +// .addLast(new ProtobufVarint32FrameDecoder()) +// .addLast(new ProtobufDecoder(Payload.Message.getDefaultInstance())) +// .addLast(new ProtobufVarint32LengthFieldPrepender()) +// .addLast(new ProtobufEncoder()) + // 加载心跳处理器 + .addLast(new HeartbeatHandler(nettyClient, nettyProperties, appName)) + // 加载业务处理器 + .addLast(new ClientHandler()) + .addLast(); + } + + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientProperties.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientProperties.java new file mode 100644 index 0000000..92e0001 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/NettyClientProperties.java @@ -0,0 +1,32 @@ +package com.docus.server.common.netty.client; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Data +@Component +@ConfigurationProperties(prefix = NettyClientProperties.PREFIX) +public class NettyClientProperties { + + public static final String PREFIX = "netty.client"; + + // 读空闲等待时间 + private int readerIdleTimeSeconds = 0; + + // 写空闲等待时间 + private int writerIdleTimeSeconds = 10; + + // 读写空闲等待时间 + private int allIdleTimeSeconds = 0; + + // 服务主机 + private String host; + + // 服务端口 + private Integer port; + + // 重连时间/秒 + private int reconnectSeconds = 10; + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/ClientHandler.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/ClientHandler.java new file mode 100644 index 0000000..179c2ea --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/ClientHandler.java @@ -0,0 +1,76 @@ +package com.docus.server.common.netty.client.handler; + +import com.docus.core.util.StringUtils; +import com.docus.core.util.json.JSON; +import com.docus.server.common.MsgConstants; +import com.docus.server.common.netty.CommMsg; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import lombok.extern.slf4j.Slf4j; + +import java.io.Serializable; + +@Slf4j +public class ClientHandler extends SimpleChannelInboundHandler { + + @Override + protected void channelRead0(ChannelHandlerContext context, ByteBuf msg) throws Exception { + ByteBuf buf = (ByteBuf) msg; + //创建目标大小的数组 + byte[] barray = new byte[buf.readableBytes()]; + //把数据从bytebuf转移到byte[] + buf.getBytes(0, barray); + //将byte[]转成字符串用于打印 + String message = new String(barray); + + //空消息不处理 + if (!StringUtils.hasText(message)) { + return; + } + + CommMsg commMsg = JSON.fromJSON(message, CommMsg.class); + + String messageType = commMsg.getMessageType(); + String messageTime = commMsg.getMessageTime(); + Serializable messageContent = commMsg.getContent(); + + log.info("======== 收到服务端消息, 消息时间={}, 消息类型={}, 消息内容={}", messageTime, messageType, messageContent + " ======== "); + + if (messageType.equals(MsgConstants.TERMINATOR_RESTART)) { + log.info("接受到终端重启命令,内容={}", messageContent); + } + + if (messageType.equals(MsgConstants.COLLECTOR_RESTART)) { + log.info("收到采集器重启命令,内容={}", messageContent); + } + + if (messageType.equals(MsgConstants.VIRTUAL_RESTART)) { + log.info("收到虚拟机重启命令,内容={}", messageContent); + } + + if (messageType.equals(MsgConstants.UPDATE_COLLECTOR_FILE)) { + log.info("收到更新采集器文件命令,内容={}", messageContent); + } + + if (messageType.equals(MsgConstants.UPDATE_COLLECTOR_CONFIG)) { + log.info("收到更新采集器配置命令,内容={}", messageContent); + } + + if (messageType.equals(MsgConstants.SCH_DISTRIBUTE_TASKS)) { + log.info("收到采集调度器下发任务命令,内容={}", messageContent); + } + + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + cause.printStackTrace(); + Channel channel = ctx.channel(); + if (channel.isActive()) { + ctx.close(); + } + super.exceptionCaught(ctx, cause); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/HeartbeatHandler.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/HeartbeatHandler.java new file mode 100644 index 0000000..4d2eb11 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/client/handler/HeartbeatHandler.java @@ -0,0 +1,100 @@ +package com.docus.server.common.netty.client.handler; + +import com.docus.core.util.DateUtil; +import com.docus.core.util.json.JSON; +import com.docus.server.common.MsgConstants; +import com.docus.server.common.netty.CommMsg; +import com.docus.server.common.netty.client.NettyClient; +import com.docus.server.common.netty.client.NettyClientProperties; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelFutureListener; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.EventLoop; +import io.netty.handler.timeout.IdleState; +import io.netty.handler.timeout.IdleStateEvent; +import io.netty.util.CharsetUtil; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * 处理发送心跳逻辑 + */ +@Slf4j +@AllArgsConstructor +@NoArgsConstructor +public class HeartbeatHandler extends ChannelInboundHandlerAdapter { + + private NettyClient nettyClient; + + private NettyClientProperties nettyProperties; + + private String appName; + + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + log.info("通道激活......"); + +// Payload.Message.Builder builder = Payload.Message.newBuilder() +// .setClient(appName) +// .setContent("我来了") +// .setCmd(Payload.Message.type.AUTH); + + CommMsg onlineRegister = CommMsg.builder() + .messageType(MsgConstants.ONLINE_REGISTER) + .messageTime(DateUtil.formatDateTime(new Date())) + .content(appName + " 我来了") + .build(); + + ctx.writeAndFlush(Unpooled.copiedBuffer(JSON.toJSON(onlineRegister), CharsetUtil.UTF_8)); + super.channelActive(ctx); + } + + @Override + public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { + if (evt instanceof IdleStateEvent) { + IdleStateEvent idleStateEvent = (IdleStateEvent) evt; + if (idleStateEvent.state() == IdleState.WRITER_IDLE) { + // 一定时间内,通道内未传递消息,发送心跳,保证存活 + log.info("after {} seconds no message wrote", nettyProperties.getWriterIdleTimeSeconds()); + +// Payload.Message heartbeat = Payload.Message +// .newBuilder() +// .setCmd(Payload.Message.type.HEARTBEAT_REQUEST) +// .build(); + + CommMsg heartbeat = CommMsg.builder() + .messageType(MsgConstants.HEARTBEAT_REQUEST) + .messageTime(DateUtil.formatDateTime(new Date())) + .build(); + + //发送心跳消息,并在发送失败时关闭该接连 + ctx.writeAndFlush(Unpooled.copiedBuffer(JSON.toJSON(heartbeat), CharsetUtil.UTF_8)).addListener(ChannelFutureListener.CLOSE_ON_FAILURE); + } + } else { + super.userEventTriggered(ctx, evt); + } + } + + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + //如果运行过程中服务端挂了,执行重连机制 + log.info("通道释放=================="); + EventLoop eventLoop = ctx.channel().eventLoop(); + eventLoop.schedule(() -> nettyClient.start(), nettyProperties.getReconnectSeconds(), TimeUnit.SECONDS); + super.channelInactive(ctx); + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + cause.printStackTrace(); + log.error("捕获的异常:{}", cause.getMessage()); + ctx.close(); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/ChannelRepository.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/ChannelRepository.java new file mode 100644 index 0000000..9a8a58c --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/ChannelRepository.java @@ -0,0 +1,106 @@ +package com.docus.server.common.netty.server; + +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.OnlineStateEnum; +import com.docus.server.service.ISchTerminatorService; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; +import io.netty.channel.Channel; +import io.netty.util.AttributeKey; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; + +/** + * 客户端IP和通信信道的映射 + */ +@Component +@Slf4j +public class ChannelRepository { + @Resource + private ISchTerminatorService iSchTerminatorService; + + /** + * + */ + private final static Map IP_CHANNEL_CACHE_MAP = new ConcurrentHashMap<>(); + + /** + * + */ + private final static Map IP_TERMINATOR_CACHE_MAP = new ConcurrentHashMap<>(); + + /** + * 终端上线 + */ + public void put(NettyTerminatorDTO nettyTerminatorDTO, Channel channel) { + //客户端上线 + String terminatorIp = nettyTerminatorDTO.getTerminatorIp(); + + //更新数据库终端数据 + SchTerminatorVO schTerminatorVO = iSchTerminatorService.saveOrUpdate(terminatorIp, nettyTerminatorDTO); + nettyTerminatorDTO.setId(schTerminatorVO.getId()); + + //缓存 + IP_CHANNEL_CACHE_MAP.put(terminatorIp, channel); + IP_TERMINATOR_CACHE_MAP.put(terminatorIp, nettyTerminatorDTO); + + AttributeKey attributeKey = AttributeKey.valueOf("ip"); + channel.attr(attributeKey).set(terminatorIp); + + + } + + public String getClientKey(Channel channel) { + + AttributeKey key = AttributeKey.valueOf("ip"); + + if (channel.hasAttr(key)) { + return channel.attr(key).get(); + } + return null; + } + + public Channel get(String key) { + return IP_CHANNEL_CACHE_MAP.get(key); + } + + public NettyTerminatorDTO getTerminatorByIp(String key) { + return IP_TERMINATOR_CACHE_MAP.get(key); + } + + public Map getIpToChannelCacheMap() { + return IP_CHANNEL_CACHE_MAP; + } + + public Map getIpToTerminatorCacheMap() { + return IP_TERMINATOR_CACHE_MAP; + } + + public List getAvailTerminator() { + if (!CollectionUtils.isEmpty(IP_TERMINATOR_CACHE_MAP)) { + return IP_TERMINATOR_CACHE_MAP.values().stream().filter(p -> OnlineStateEnum.ONLINE.equals(p.getOnlineState()) + && BusyStateEnum.IDLE.equals(p.getBusyState())).collect(Collectors.toList()); + } + return Collections.emptyList(); + } + + /** + * 终端离线 + */ + public void remove(String key) { + IP_CHANNEL_CACHE_MAP.remove(key); + + NettyTerminatorDTO nettyTerminatorDTO = new NettyTerminatorDTO(); + nettyTerminatorDTO.setOnlineState(OnlineStateEnum.OFFLINE); + iSchTerminatorService.saveOrUpdate(key, nettyTerminatorDTO); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServer.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServer.java new file mode 100644 index 0000000..f597647 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServer.java @@ -0,0 +1,70 @@ +package com.docus.server.common.netty.server; + +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.annotation.Resource; +import java.net.InetSocketAddress; + +/** + * netty服务端初始化 + */ +@Component +@Slf4j +public class NettyServer { + + /** + * boss 线程组用于处理连接工作 + */ + private EventLoopGroup boss; + /** + * worker 线程组用于数据处理 + */ + private EventLoopGroup worker; + + @Resource + private NettyServerProperties serverProperties; + + @Resource + private NettyServerInitializer serverInitializer; + + @PostConstruct + public void start() throws InterruptedException { + boss = new NioEventLoopGroup(serverProperties.getBossThreadCount()); + worker = new NioEventLoopGroup(serverProperties.getWorkerThreadCount()); + ServerBootstrap bootstrap = new ServerBootstrap(); + bootstrap.group(boss, worker) + // 指定Channel + .channel(NioServerSocketChannel.class) + //使用指定的端口设置套接字地址 + .localAddress(new InetSocketAddress(serverProperties.getPort())) + //服务端可连接队列数,对应TCP/IP协议listen函数中backlog参数 + .option(ChannelOption.SO_BACKLOG, 1024) + //设置TCP长连接,一般如果两个小时内没有数据的通信时,TCP会自动发送一个活动探测数据报文 + .childOption(ChannelOption.SO_KEEPALIVE, true) + //将小的数据包包装成更大的帧进行传送,提高网络的负载 + .childOption(ChannelOption.TCP_NODELAY, true) + .childHandler(serverInitializer); + ChannelFuture future = bootstrap.bind().sync(); + if (future.isSuccess()) { + log.info("Start netty server successfully"); + } else { + log.error("Start netty server failed"); + } + } + + @PreDestroy + public void destroy() throws InterruptedException { + boss.shutdownGracefully().sync(); + worker.shutdownGracefully().sync(); + log.info("关闭Netty"); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerInitializer.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerInitializer.java new file mode 100644 index 0000000..04f4600 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerInitializer.java @@ -0,0 +1,52 @@ +package com.docus.server.common.netty.server; + +import com.docus.server.common.netty.server.handler.NettyBusinessHandler; +import com.docus.server.common.netty.server.handler.NettyHeartbeatHandler; +import io.netty.channel.Channel; +import io.netty.channel.ChannelInitializer; +import io.netty.handler.timeout.IdleStateHandler; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.concurrent.TimeUnit; + +/** + * netty服务端信道初始化 + */ +@Component +public class NettyServerInitializer extends ChannelInitializer { + + @Resource + private NettyServerProperties serverProperties; + + @Resource + private NettyBusinessHandler businessHandler; + + @Resource + private ChannelRepository channelRepository; + + @Override + protected void initChannel(Channel channel) throws Exception { + channel.pipeline() + //空闲检测 + .addLast(new IdleStateHandler(serverProperties.getReaderIdleTimeSeconds(), + serverProperties.getWriterIdleTimeSeconds(), + serverProperties.getAllIdleTimeSeconds(), + TimeUnit.SECONDS) + ) + // 加载加码解码处理器,同时解决粘包拆包问题 +// .addLast(new ProtobufVarint32FrameDecoder()) +// .addLast(new ProtobufDecoder(Payload.CommMsg.getDefaultInstance())) +// .addLast(new ProtobufVarint32LengthFieldPrepender()) +// .addLast(new ProtobufEncoder()) + +// .addLast(new LineBasedFrameDecoder(2048)) +// .addLast(new StringDecoder()) +// .addLast(new StringEncoder()) + + // 加载业务处理器 + .addLast(new NettyHeartbeatHandler(channelRepository)) + .addLast(businessHandler); +// .addLast(new EchoServerHandler()); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerProperties.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerProperties.java new file mode 100644 index 0000000..02f515d --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/NettyServerProperties.java @@ -0,0 +1,31 @@ +package com.docus.server.common.netty.server; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +/** + * netty服务端配置 + */ +@Data +@Component +@ConfigurationProperties(prefix = NettyServerProperties.PREFIX) +public class NettyServerProperties { + + public static final String PREFIX = "netty.server"; + + // 读空闲等待时间 + private int readerIdleTimeSeconds = 30; + + // 写空闲等待时间 + private int writerIdleTimeSeconds; + + // 读写空闲等待时间 + private int allIdleTimeSeconds; + + private Integer port; + + private int bossThreadCount; + + private int workerThreadCount; +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/EchoServerHandler.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/EchoServerHandler.java new file mode 100644 index 0000000..600aa47 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/EchoServerHandler.java @@ -0,0 +1,77 @@ +package com.docus.server.common.netty.server.handler; + +import com.docus.core.util.json.JSON; +import com.docus.server.common.netty.CommMsg; +import com.fasterxml.jackson.core.type.TypeReference; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.util.CharsetUtil; + +import java.util.Date; + +public class EchoServerHandler extends ChannelInboundHandlerAdapter { + + + //客户端连接上来,没有心跳前,属于离线状态,有心跳后,才属于在线状态。 + //客户端断开后,自动剔除,agent。 + @Override + public void channelRegistered(ChannelHandlerContext ctx) throws Exception { + ctx.fireChannelRegistered(); + Channel incoming = ctx.channel(); + System.out.println("NettyClient:" + incoming.remoteAddress() + "在线1"); + } + + + @Override + public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { + ctx.fireChannelUnregistered(); + Channel incoming = ctx.channel(); + System.out.println("NettyClient:" + incoming.remoteAddress() + "在线2"); + } + + + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + ctx.fireChannelActive(); + Channel incoming = ctx.channel(); + System.out.println("NettyClient:" + incoming.remoteAddress() + "在线3"); + } + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + try { + ByteBuf buf = (ByteBuf) msg; + //创建目标大小的数组 + byte[] barray = new byte[buf.readableBytes()]; + //把数据从bytebuf转移到byte[] + buf.getBytes(0, barray); + //将byte[]转成字符串用于打印 + String str = new String(barray); + + CommMsg commMsg = JSON.fromJSONWithGeneric(str, new TypeReference>() { + }); + + if (str.length() > 0) { + System.out.println(str); + System.out.println("收到消息回复一条消息给客户端"); + System.out.println("client channelActive.."); + ctx.writeAndFlush(Unpooled.copiedBuffer("服务器端发一条数据给客户端" + new Date().toString(), CharsetUtil.UTF_8)); // 必须有flush + System.out.flush(); + } else { + System.out.println("不能读啊"); + } + } finally { + } + } + + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + System.out.println("server occur exception:" + cause.getMessage()); + cause.printStackTrace(); + ctx.close(); // 关闭发生异常的连接 + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java new file mode 100644 index 0000000..9770f10 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyBusinessHandler.java @@ -0,0 +1,144 @@ +package com.docus.server.common.netty.server.handler; + +import com.docus.core.util.Func; +import com.docus.core.util.StringUtils; +import com.docus.core.util.json.JSON; +import com.docus.server.common.MsgConstants; +import com.docus.server.common.netty.CommMsg; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.OnlineStateEnum; +import com.fasterxml.jackson.core.type.TypeReference; +import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.group.ChannelGroup; +import io.netty.channel.group.DefaultChannelGroup; +import io.netty.util.concurrent.GlobalEventExecutor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.net.InetSocketAddress; + +/** + * 业务消息处理 + */ +@Slf4j +@ChannelHandler.Sharable +@Component +public class NettyBusinessHandler extends SimpleChannelInboundHandler { + + private static final ChannelGroup DEFAULT_CHANNEL_GROUP = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); + + @Resource + private ChannelRepository repository; + + @Override + protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf msg) throws Exception { + ByteBuf buf = (ByteBuf) msg; + //创建目标大小的数组 + byte[] barray = new byte[buf.readableBytes()]; + //把数据从bytebuf转移到byte[] + buf.getBytes(0, barray); + //将byte[]转成字符串用于打印 + String message = new String(barray); + + //空消息不处理 + if (!StringUtils.hasText(message)) { + return; + } + + CommMsg commMsg = JSON.fromJSONWithGeneric(message, new TypeReference>() { + }); + + String messageType = commMsg.getMessageType(); + String messageTime = commMsg.getMessageTime(); + TerminatorContent messageContent = commMsg.getContent(); + + if (messageType.equals(MsgConstants.TERMINATOR_RESTART)) { + log.info("接受到终端重启命令,内容{}", messageContent); + } + + if (messageType.equals(MsgConstants.COLLECTOR_RESTART)) { + log.info("收到采集器重启命令,内容{}", messageContent); + } + + if (messageType.equals(MsgConstants.VIRTUAL_RESTART)) { + log.info("收到虚拟机重启命令,内容{}", messageContent); + } + + if (messageType.equals(MsgConstants.UPDATE_COLLECTOR_FILE)) { + log.info("收到更新采集器文件命令,内容{}", messageContent); + } + + if (messageType.equals(MsgConstants.UPDATE_COLLECTOR_CONFIG)) { + log.info("收到更新采集器配置命令,内容{}", messageContent); + } + + if (messageType.equals(MsgConstants.SCH_DISTRIBUTE_TASKS)) { + log.info("收到采集调度器下发任务命令,内容{}", messageContent); + } + } + + /** + * netty client 上线 + */ + @Override + public void channelActive(ChannelHandlerContext ctx) throws Exception { + ctx.fireChannelRegistered(); + + InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress(); + String clientIp = ipSocket.getAddress().getHostAddress(); + log.info("【采集器-终端IP】:{},连接上线,IP地址信息:{}", clientIp, clientIp); + + String clientId = repository.getClientKey(ctx.channel()); + + if (Func.isBlank(clientId)) { + + NettyTerminatorDTO nettyTerminatorDTO = new NettyTerminatorDTO(); + nettyTerminatorDTO.setTerminatorIp(clientIp); + nettyTerminatorDTO.setBusyState(BusyStateEnum.IDLE); + nettyTerminatorDTO.setOnlineState(OnlineStateEnum.OFFLINE); + + repository.put(nettyTerminatorDTO, ctx.channel()); + } + + DEFAULT_CHANNEL_GROUP.add(ctx.channel()); + + System.out.println(ctx.channel().remoteAddress() + " 上线," + "【采集器-终端】在线数量:" + DEFAULT_CHANNEL_GROUP.size()); + } + + /** + * netty client 下线 + */ + @Override + public void channelInactive(ChannelHandlerContext ctx) throws Exception { + Channel channel = ctx.channel(); + System.out.println(channel.remoteAddress() + " 下线," + "【采集器-终端】在线数量:" + DEFAULT_CHANNEL_GROUP.size()); + String clientId = repository.getClientKey(channel); + log.error("客户端下线,终端连接:{}", clientId); + //移除终端,终端离线 + if (clientId != null) { + repository.remove(clientId); + } + } + + /** + * netty exception 通道异常 + */ + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + cause.printStackTrace(); + Channel channel = ctx.channel(); + if (channel.isActive()) { + ctx.close(); + } + + super.exceptionCaught(ctx, cause); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java new file mode 100644 index 0000000..6bac1c7 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/NettyHeartbeatHandler.java @@ -0,0 +1,104 @@ +package com.docus.server.common.netty.server.handler; + +import com.docus.core.util.Func; +import com.docus.core.util.StringUtils; +import com.docus.core.util.json.JSON; +import com.docus.server.common.MsgConstants; +import com.docus.server.common.netty.CommMsg; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.OnlineStateEnum; +import com.fasterxml.jackson.core.type.TypeReference; +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import lombok.extern.slf4j.Slf4j; + +import java.net.InetSocketAddress; + +/** + * 客户端和服务端心跳 + */ +@Slf4j +@ChannelHandler.Sharable +public class NettyHeartbeatHandler extends ChannelInboundHandlerAdapter { + + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + ByteBuf buf = (ByteBuf) msg; + //创建目标大小的数组 + byte[] barray = new byte[buf.readableBytes()]; + //把数据从bytebuf转移到byte[] + buf.getBytes(0, barray); + //将byte[]转成字符串用于打印 + String message = new String(barray); + //空消息不处理 + if (!StringUtils.hasText(message)) { + return; + } + + CommMsg commMsg = JSON.fromJSONWithGeneric(message, new TypeReference>() { + }); + + String messageType = commMsg.getMessageType(); + String messageTime = commMsg.getMessageTime(); + TerminatorContent messageContent = commMsg.getContent(); + + if (messageType.equals(MsgConstants.HEARTBEAT_REQUEST)) { + + log.info("接收到客户端的心跳"); + + + log.info("接受到【采集器-终端】的心跳消息:消息类型={},消息时间={},消息内容={}", messageType, messageTime, messageContent); + + InetSocketAddress ipSocket = (InetSocketAddress) ctx.channel().remoteAddress(); + String clientIp = ipSocket.getAddress().getHostAddress(); + + log.info("【采集器-终端IP】:{},连接上线,IP地址信息:{}", clientIp, clientIp); + + String clientKey = repository.getClientKey(ctx.channel()); + + if (Func.isNotBlank(clientKey)) { + + NettyTerminatorDTO nettyTerminatorDTO = new NettyTerminatorDTO(); + nettyTerminatorDTO.setTerminatorIp(clientIp); + nettyTerminatorDTO.setBusyState(BusyStateEnum.IDLE); + nettyTerminatorDTO.setOnlineState(OnlineStateEnum.ONLINE); + + //将ip和channel进行映射 + repository.put(nettyTerminatorDTO, ctx.channel()); + } + + } else { + + if (ctx.channel().isOpen()) { + //触发下一个handler + ctx.fireChannelRead(msg); + } + } + + } + + private ChannelRepository repository; + + public NettyHeartbeatHandler(ChannelRepository repository) { + this.repository = repository; + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + cause.printStackTrace(); + String clientId = repository.getClientKey(ctx.channel()); + log.error("通道发生异常,终端连接:{}", clientId); + //移除终端,终端离线 + if (clientId != null) { + repository.remove(clientId); + } + if (ctx.channel().isActive()) { + ctx.close(); + } + super.exceptionCaught(ctx, cause); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/TerminatorContent.java b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/TerminatorContent.java new file mode 100644 index 0000000..24e60b6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/netty/server/handler/TerminatorContent.java @@ -0,0 +1,22 @@ +package com.docus.server.common.netty.server.handler; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Data +public class TerminatorContent implements Serializable { + + /*终端IP*/ + private String terminatorIp; + + /*终端名称*/ + private String terminatorName; + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/process/ChannelProcessor.java b/collector-terminal-management/src/main/java/com/docus/server/common/process/ChannelProcessor.java new file mode 100644 index 0000000..076813b --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/process/ChannelProcessor.java @@ -0,0 +1,152 @@ +package com.docus.server.common.process; + +import com.docus.core.util.Func; +import com.docus.log.context.TrackContext; +import com.docus.log.processor.AbstractProcessor; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schterminator.EditSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.enums.RetryTaskEnum; +import com.docus.server.enums.StateEnum; +import com.docus.server.service.ISchCollectRecordRetryLogService; +import com.docus.server.service.ISchCollectRecordService; +import com.docus.server.service.ISchTerminatorService; +import com.docus.server.vo.scheduling.management.schcollectrecord.SchCollectRecordVO; +import com.docus.server.vo.scheduling.management.schcollectrecordretrylog.SchCollectRecordRetryLogVO; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; + +import javax.annotation.Resource; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * channel 管理 + */ +public class ChannelProcessor extends AbstractProcessor { + @Resource + private ChannelRepository channelRepository; + @Resource + private ISchTerminatorService iSchTerminatorService; + @Resource + private ISchCollectRecordService iSchCollectRecordService; + @Resource + private ISchCollectRecordRetryLogService iSchCollectRecordRetryLogService; + + @Override + protected Object doProcess(TrackContext context) { + String group = context.getGroup(); + + switch (group) { + case "SchCollectRecordController-edit": + return doSchCollectRecordControllerEdit(context); + case "SchTerminatorController": + return doSchTerminatorController(context); + case "RedisKeyExpirationService-expired": + return doRedisKeyExpired(context); + default: + return true; + } + } + + private Object doRedisKeyExpired(TrackContext context) { + boolean error = context.isError(); + String expireKey = (String) context.getArgs()[0]; + + String recordId = expireKey.substring(expireKey.lastIndexOf(":") + 1); + + if (!error) { + + if (expireKey.startsWith("schCollectorRecord:isRetryTask:expireKey:")) { + retryTask(recordId); + } + if (expireKey.startsWith("schCollectorRecord:noRetryTask:expireKey:")) { + noRetryTask(recordId); + + } + } + return null; + } + + private boolean doSchCollectRecordControllerEdit(TrackContext context) { + return logCollectRecord(context); + } + + private boolean doSchTerminatorController(TrackContext context) { + return logTerminator(context); + } + + private boolean logCollectRecord(TrackContext context) { + boolean error = context.isError(); + + EditSchCollectRecordDTO collectRecordDTO = (EditSchCollectRecordDTO) context.getArgs()[0]; + + if (!error) { + + if (RetryTaskEnum.NO_RETRY_TASK.equals(collectRecordDTO.getIsRetryTask())) { + + noRetryTask(String.valueOf(collectRecordDTO.getId())); + + } else if (RetryTaskEnum.RETRY_TASK.equals(collectRecordDTO.getIsRetryTask())) { + + retryTask(String.valueOf(collectRecordDTO.getId())); + + } + + } + return error; + + } + + private void retryTask(String recordLogId) { + SchCollectRecordRetryLogVO retryLogVO = iSchCollectRecordRetryLogService.findById(recordLogId); + + updateTerminatorState(retryLogVO.getTerminatorId(), retryLogVO.getTaskExecState()); + + } + + private void noRetryTask(String recordId) { + + SchCollectRecordVO schCollectRecordVO = iSchCollectRecordService.findById(recordId); + + updateTerminatorState(schCollectRecordVO.getTerminatorId(), schCollectRecordVO.getTaskExecState()); + } + + private void updateTerminatorState(Long terminatorId, StateEnum taskExecState) { + SchTerminatorVO schTerminatorVO = iSchTerminatorService.findById(String.valueOf(terminatorId)); + + NettyTerminatorDTO nettyTerminatorDTO = channelRepository.getTerminatorByIp(String.valueOf(schTerminatorVO.getTerminatorIp())); + + if (Func.isEmpty(nettyTerminatorDTO)) { + return; + } + + List stateEnums = Arrays.asList(StateEnum.values()); + + if (stateEnums.contains(taskExecState)) { + nettyTerminatorDTO.setBusyState(BusyStateEnum.IDLE); + } + } + + private boolean logTerminator(TrackContext context) { + boolean error = context.isError(); + EditSchTerminatorDTO terminatorDTO = (EditSchTerminatorDTO) context.getArgs()[0]; + if (!error) { + SchTerminatorVO terminatorVO = iSchTerminatorService.findById(String.valueOf(terminatorDTO.getId())); + + NettyTerminatorDTO nettyTerminatorDTO = channelRepository.getTerminatorByIp(terminatorVO.getTerminatorIp()); + + if (Func.isNotBlank(terminatorDTO.getOnlyCollectorIds())) { + List onlyList = Arrays.stream(terminatorDTO.getOnlyCollectorIds().split(",")).map(String::valueOf).collect(Collectors.toList()); + nettyTerminatorDTO.setOnlyCollectorIds(onlyList); + } + if (Func.isNotBlank(terminatorDTO.getPriorityCollectorIds())) { + List priList = Arrays.stream(terminatorDTO.getPriorityCollectorIds().split(",")).map(String::valueOf).collect(Collectors.toList()); + nettyTerminatorDTO.setPriorityCollectorIds(priList); + } + } + return error; + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/process/CollectorVersionProcessor.java b/collector-terminal-management/src/main/java/com/docus/server/common/process/CollectorVersionProcessor.java new file mode 100644 index 0000000..ac4c504 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/process/CollectorVersionProcessor.java @@ -0,0 +1,72 @@ +package com.docus.server.common.process; + +import com.docus.infrastructure.redis.service.IdService; +import com.docus.log.context.TrackContext; +import com.docus.log.processor.AbstractProcessor; +import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.enums.StateEnum; +import com.docus.server.infrastructure.dao.ISchCollectorDao; +import com.docus.server.infrastructure.dao.ISchCollectorVersionDao; +import com.docus.server.infrastructure.dao.ISchCollectorVersionLogDao; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; + +import javax.annotation.Resource; + +/** + * 日志管理 + */ +public class CollectorVersionProcessor extends AbstractProcessor { + @Resource + private ISchCollectorVersionLogDao iSchCollectorVersionLogDao; + @Resource + private ISchCollectorVersionDao iSchCollectorVersionDao; + @Resource + private ISchSystemParamsDao iSchSystemParamsDao; + @Resource + private ISchCollectorDao iSchCollectorDao; + @Resource + private IdService idService; + + @Override + public Object beforeProcess(TrackContext context) { + super.beforeProcess(context); + UpdateSchCollectorDTO updateDTO = (UpdateSchCollectorDTO) context.getArgs()[0]; + Long collectorId = updateDTO.getCollectorId(); + SchCollector schCollector = iSchCollectorDao.findOneBy("collectorId", collectorId); + SchCollectorVersion preVersion = iSchCollectorVersionDao.findById(schCollector.getCollectorVersionId()); + return preVersion.getCollectVersion(); + } + + @Override + protected Object doProcess(TrackContext context) { + logProcess(context); + return null; + } + + private void logProcess(TrackContext context) { + + boolean error = context.isError(); + + UpdateSchCollectorDTO updateDTO = (UpdateSchCollectorDTO) context.getArgs()[0]; + Long collectorId = updateDTO.getCollectorId(); + String preVersion = (String) context.getBeforeResult(); + SchCollectorVersion curVersion = iSchCollectorVersionDao.findById(updateDTO.getCollectorVersionId()); + SchSystemParams schSystemParams = iSchSystemParamsDao.findOneBy("paramValue", collectorId); + + SchCollectorVersionLog log = new SchCollectorVersionLog(); + log.setId(idService.getDateSeq()); + log.setCollectorId(collectorId); + log.setOperationModule(context.getGroup()); + log.setOperationType(context.getAction()); + log.setOperationDesc(context.getDesc()); + log.setOperationContent(String.format("采集器:%s,上一个版本是:%s,更换成当前版本是:%s", schSystemParams.getParamName(), preVersion, curVersion.getCollectVersion())); + log.setState(error ? StateEnum.FAIL : StateEnum.OK); + + iSchCollectorVersionLogDao.save(log); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/process/TcpProcessor.java b/collector-terminal-management/src/main/java/com/docus/server/common/process/TcpProcessor.java new file mode 100644 index 0000000..49831e6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/process/TcpProcessor.java @@ -0,0 +1,62 @@ +package com.docus.server.common.process; + +import com.docus.core.util.json.JSON; +import com.docus.log.context.TrackContext; +import com.docus.log.processor.AbstractProcessor; +import com.docus.server.common.MsgConstants; +import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.docus.server.service.ICommMsgService; +import com.docus.server.service.ISchCollectorVersionFileService; +import com.docus.server.service.ISchCollectorVersionService; +import com.docus.server.vo.scheduling.management.schcollectorversion.SchCollectorVersionVO; +import com.docus.server.vo.scheduling.management.schcollectorversion.TcpSchCollectorVersionContentVO; +import com.google.common.collect.Lists; + +import javax.annotation.Resource; +import java.util.List; + +/** + * tcp 管理 + */ +public class TcpProcessor extends AbstractProcessor { + @Resource + private ICommMsgService iCommMsgService; + @Resource + private ISchCollectorVersionFileService iSchCollectorVersionFileService; + @Resource + private ISchCollectorVersionService iSchCollectorVersionService; + + @Override + protected Object doProcess(TrackContext context) { + return logProcess(context); + } + + private boolean logProcess(TrackContext context) { + boolean error = context.isError(); + if (!error) { + UpdateSchCollectorDTO updateSchCollectorDTO = (UpdateSchCollectorDTO) context.getArgs()[0]; + Long collectorId = updateSchCollectorDTO.getCollectorId(); + Long collectorVersionId = updateSchCollectorDTO.getCollectorVersionId(); + + SchCollectorVersionFile schCollectorVersionFile = iSchCollectorVersionFileService.findByCollectorIdAndVersionId(collectorId, collectorVersionId); + SchCollectorVersionVO schCollectorVersionVO = iSchCollectorVersionService.findById(String.valueOf(collectorVersionId)); + + TcpSchCollectorVersionContentVO tcpSchCollectorVersionContentVO = new TcpSchCollectorVersionContentVO(); + tcpSchCollectorVersionContentVO.setCollectorId(collectorId); + tcpSchCollectorVersionContentVO.setFilePath(schCollectorVersionFile.getFilePath()); + tcpSchCollectorVersionContentVO.setCollectorVersion(schCollectorVersionVO.getCollectVersion()); + + List tcpSchCollectorVersionContentVOList = Lists.newArrayList(tcpSchCollectorVersionContentVO); + + CommMsgDTO commMsgDTO = CommMsgDTO.builder() + .content(JSON.toJSON(tcpSchCollectorVersionContentVOList)) + .messageType(MsgConstants.UPDATE_COLLECTOR_FILE) + .build(); + + iCommMsgService.clientsCommand(commMsgDTO); + } + return error; + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/serializer/DefJsonSerializerModule.java b/collector-terminal-management/src/main/java/com/docus/server/common/serializer/DefJsonSerializerModule.java new file mode 100644 index 0000000..b5033ed --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/serializer/DefJsonSerializerModule.java @@ -0,0 +1,25 @@ +package com.docus.server.common.serializer; + +import com.docus.core.util.Convert; +import com.docus.infrastructure.web.json.JsonSerializerModule; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; +import java.time.ZoneId; +import java.util.Date; +import java.util.TimeZone; + +public class DefJsonSerializerModule extends JsonSerializerModule { + public DefJsonSerializerModule() { + + addSerializer(Date.class, new JsonSerializer() { + @Override + public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(date == null ? null : Convert.toString(date, Convert.DATA_FORMAT_DATETIME_SLASH, TimeZone.getTimeZone(ZoneId.systemDefault()))); + } + }); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/serializer/StringToDateConverter.java b/collector-terminal-management/src/main/java/com/docus/server/common/serializer/StringToDateConverter.java new file mode 100644 index 0000000..4663077 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/serializer/StringToDateConverter.java @@ -0,0 +1,64 @@ +package com.docus.server.common.serializer; + +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 全局handler前日期统一处理 + */ +@Component +public class StringToDateConverter implements Converter { + + private static final List DATE_FORMARTS = new ArrayList<>(4); + + static { + DATE_FORMARTS.add("yyyy-MM"); + DATE_FORMARTS.add("yyyy-MM-dd"); + DATE_FORMARTS.add("yyyy-MM-dd hh:mm"); + DATE_FORMARTS.add("yyyy-MM-dd hh:mm:ss"); + } + + @Override + public Date convert(String source) { + String value = source.trim(); + if ("".equals(value)) { + return null; + } + if (source.matches("^\\d{4}-\\d{1,2}$")) { + return parseDate(source, DATE_FORMARTS.get(0)); + } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2}$")) { + return parseDate(source, DATE_FORMARTS.get(1)); + } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}$")) { + return parseDate(source, DATE_FORMARTS.get(2)); + } else if (source.matches("^\\d{4}-\\d{1,2}-\\d{1,2} {1}\\d{1,2}:\\d{1,2}:\\d{1,2}$")) { + return parseDate(source, DATE_FORMARTS.get(3)); + } else { + throw new IllegalArgumentException("Invalid boolean value '" + source + "'"); + } + } + + /** + * 格式化日期 + * + * @param dateStr String 字符型日期 + * @param format String 格式 + * @return Date 日期 + */ + public Date parseDate(String dateStr, String format) { + Date date = null; + try { + DateFormat dateFormat = new SimpleDateFormat(format); + date = dateFormat.parse(dateStr); + } catch (Exception e) { + System.out.println(String.format("日期%s转换%s错误", dateStr, format)); + } + return date; + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/test/DispatchService.java b/collector-terminal-management/src/main/java/com/docus/server/common/test/DispatchService.java new file mode 100644 index 0000000..8132d99 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/test/DispatchService.java @@ -0,0 +1,107 @@ +package com.docus.server.common.test; + +import java.util.ArrayList; +import java.util.List; + +public class DispatchService { + + public void dispatch() { + + + //获取所有空闲的终端 + List terminalList = new ArrayList<>(); + List taskInfos = this.getTaskInfos(terminalList.size()); + + + + //只采集,有优先级的 + for (Terminal terminal : terminalList) { + for (TaskInfo taskInfo : taskInfos) { + //先找出有只采集的任务。 + if (terminal.getOnlyTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端,并且把这个终端设置成繁忙 + if (terminal.getPriorityTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端 + terminal.setState(1); + return; + } + } + } + } + + //只采集没有优先级 + for (Terminal terminal : terminalList) { + //把刚才已经分配任务过的采集器排除 + if (terminal.getState() == 1) { + continue; + } + + for (TaskInfo taskInfo : taskInfos) { + //先找出有只采集的任务。 + if (terminal.getOnlyTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端,并且把这个终端设置成繁忙 + + terminal.setState(1); + return; + } + } + } + + + //无只采集,有优先级 + for (Terminal terminal : terminalList) { + + //把刚才已经分配任务过的采集器排除 + if (terminal.getState() == 1) { + continue; + } + + for (TaskInfo taskInfo : taskInfos) { + //先找出有只采集的任务。 + if (terminal.getPriorityTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端 + terminal.setState(1); + return; + } + } + } + + + //无只采集,无优先级 + for (Terminal terminal : terminalList) { + + //把刚才已经分配任务过的采集器排除 + if (terminal.getState() == 1) { + continue; + } + + for (TaskInfo taskInfo : taskInfos) { + //先找出有只采集的任务。 + //把这个任务派给这个终端 + terminal.setState(1); + return; + } + } + + } + + private void dispatchTask(List taskInfos, Terminal terminal) { + for (TaskInfo taskInfo : taskInfos) { + //先找出有只采集的任务。 + if (terminal.getOnlyTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端 + return; + } + if (terminal.getPriorityTags().contains(taskInfo.getCollectType())) { + //把这个任务派给这个终端 + return; + } + } + } + + + public List getTaskInfos(int size) { + return null; + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/test/TaskInfo.java b/collector-terminal-management/src/main/java/com/docus/server/common/test/TaskInfo.java new file mode 100644 index 0000000..08f8b45 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/test/TaskInfo.java @@ -0,0 +1,14 @@ +package com.docus.server.common.test; + +import lombok.Data; + +@Data +public class TaskInfo { + + private Long taskId; + + private String collectType; + + private String info; + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/common/test/Terminal.java b/collector-terminal-management/src/main/java/com/docus/server/common/test/Terminal.java new file mode 100644 index 0000000..4af50fa --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/common/test/Terminal.java @@ -0,0 +1,16 @@ +package com.docus.server.common.test; + +import lombok.Data; + +import java.util.List; + +@Data +public class Terminal { + + private String id; + private String collectType; + private List priorityTags; + private List onlyTags; + private Integer state; + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/CommMsgController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/CommMsgController.java new file mode 100644 index 0000000..437f03c --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/CommMsgController.java @@ -0,0 +1,25 @@ +package com.docus.server.controller; + +import com.docus.server.api.scheduling.management.CommMsgApi; +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; +import com.docus.server.service.ICommMsgService; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 通用消息体 TCP API + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class CommMsgController implements CommMsgApi { + @Resource + private ICommMsgService iCommMsgService; + + @Override + public void clientCommand(CommMsgDTO commMsgDTO) { + iCommMsgService.clientCommand(commMsgDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/FileController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/FileController.java new file mode 100644 index 0000000..dc42eab --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/FileController.java @@ -0,0 +1,31 @@ +package com.docus.server.controller; + +import com.docus.server.api.scheduling.management.FileApi; +import com.docus.server.service.IFileUploadService; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; + +/** + * 文件上传下载 API + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class FileController implements FileApi { + @Resource + private IFileUploadService iFileUploadService; + + @Override + public void downloadFile(String filePath, HttpServletResponse response) throws Exception { + iFileUploadService.downloadFile(filePath, response); + } + + @Override + public void uploadFile(MultipartFile[] multipartFiles, String pathKey) throws Exception { + iFileUploadService.uploadFile(multipartFiles, pathKey); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectErrorLogController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectErrorLogController.java new file mode 100644 index 0000000..ca41df1 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectErrorLogController.java @@ -0,0 +1,81 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectErrorLogApi; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.AddSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.DeleteSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.EditSchCollectErrorLogDTO; +import com.docus.server.service.ISchCollectErrorLogService; +import com.docus.server.vo.scheduling.management.schcollecterrorlog.SchCollectErrorLogVO; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 采集器异常日志 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectErrorLogController implements SchCollectErrorLogApi { + @Resource + private ISchCollectErrorLogService iSchCollectErrorLogService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectErrorLogVO findById(String id) { + return iSchCollectErrorLogService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectErrorLogService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectErrorLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectErrorLogDTO addSchCollectErrorLogDTO, MultipartFile[] multipartFiles) throws Exception { + return iSchCollectErrorLogService.add(addSchCollectErrorLogDTO, multipartFiles); + } + + /** + * 编辑 + * + * @param editSchCollectErrorLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectErrorLogDTO editSchCollectErrorLogDTO) { + return iSchCollectErrorLogService.edit(editSchCollectErrorLogDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectErrorLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectErrorLogDTO deleteSchCollectErrorLogDTO) { + return iSchCollectErrorLogService.delete(deleteSchCollectErrorLogDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordController.java new file mode 100644 index 0000000..f39a5a1 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordController.java @@ -0,0 +1,103 @@ +package com.docus.server.controller; + +import com.docus.core.util.ParamsUtils; +import com.docus.core.util.json.JSON; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.log.annotation.TrackGroup; +import com.docus.server.api.scheduling.management.SchCollectRecordApi; +import com.docus.server.common.SchCollectorTask; +import com.docus.server.common.process.ChannelProcessor; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.AddSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.DeleteSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.RetrySchCollectRecordDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.enums.RetryTaskEnum; +import com.docus.server.service.ISchCollectRecordService; +import com.docus.server.vo.scheduling.management.schcollectrecord.SchCollectRecordVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集记录表 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectRecordController implements SchCollectRecordApi { + @Resource + private ISchCollectRecordService iSchCollectRecordService; + @Resource + private SchCollectorTask schedulerTask; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecordVO findById(String id) { + return iSchCollectRecordService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectRecordService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectRecordDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public SchCollectRecord add(AddSchCollectRecordDTO addSchCollectRecordDTO) { + return iSchCollectRecordService.add(addSchCollectRecordDTO); + } + + /** + * 编辑 + * + * @param editSchCollectRecordDTO 编辑参数 + * @return 成功或失败 + */ + @TrackGroup(group = "SchCollectRecordController-edit", processor = ChannelProcessor.class) + @Override + public boolean edit(EditSchCollectRecordDTO editSchCollectRecordDTO) { + return iSchCollectRecordService.edit(editSchCollectRecordDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectRecordDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectRecordDTO deleteSchCollectRecordDTO) { + return iSchCollectRecordService.delete(deleteSchCollectRecordDTO); + } + + @Override + public void retryTask(RetrySchCollectRecordDTO retrySchCollectRecordDTO) { + ReportDownTwoDTO report = JSON.fromJSON(retrySchCollectRecordDTO.getTaskOriginJson(), ReportDownTwoDTO.class); + + report.setParams(ParamsUtils + .addParam("collectRecordId", retrySchCollectRecordDTO.getId()) + .addParam("isRetryTask", RetryTaskEnum.RETRY_TASK.getValue()) + .param()); + schedulerTask.addRetryTask(report); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordRetryLogController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordRetryLogController.java new file mode 100644 index 0000000..cad13fa --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectRecordRetryLogController.java @@ -0,0 +1,81 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectRecordRetryLogApi; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.AddSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.DeleteSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.EditSchCollectRecordRetryLogDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.service.ISchCollectRecordRetryLogService; +import com.docus.server.vo.scheduling.management.schcollectrecordretrylog.SchCollectRecordRetryLogVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集记录表重试表 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectRecordRetryLogController implements SchCollectRecordRetryLogApi { + @Resource + private ISchCollectRecordRetryLogService iSchCollectRecordRetryLogService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecordRetryLogVO findById(String id) { + return iSchCollectRecordRetryLogService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectRecordRetryLogService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectRecordRetryLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public SchCollectRecordRetryLog add(AddSchCollectRecordRetryLogDTO addSchCollectRecordRetryLogDTO) { + return iSchCollectRecordRetryLogService.add(addSchCollectRecordRetryLogDTO); + } + + /** + * 编辑 + * + * @param editSchCollectRecordRetryLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectRecordRetryLogDTO editSchCollectRecordRetryLogDTO) { + return iSchCollectRecordRetryLogService.edit(editSchCollectRecordRetryLogDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectRecordRetryLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectRecordRetryLogDTO deleteSchCollectRecordRetryLogDTO) { + return iSchCollectRecordRetryLogService.delete(deleteSchCollectRecordRetryLogDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorConfigController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorConfigController.java new file mode 100644 index 0000000..e630329 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorConfigController.java @@ -0,0 +1,94 @@ +package com.docus.server.controller; + +import com.docus.core.util.json.JSON; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectorConfigApi; +import com.docus.server.dto.scheduling.management.schcollectorconfig.AddSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.DeleteSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.EditSchCollectorConfigDTO; +import com.docus.server.service.ISchCollectorConfigService; +import com.docus.server.vo.scheduling.management.schcollectorconfig.SchCollectorConfigVO; +import com.google.common.collect.Maps; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.HashMap; + +/** + * 采集器配置 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectorConfigController implements SchCollectorConfigApi { + @Resource + private ISchCollectorConfigService iSchCollectorConfigService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorConfigVO findById(String id) { + return iSchCollectorConfigService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectorConfigService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectorConfigDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorConfigDTO addSchCollectorConfigDTO) { + return iSchCollectorConfigService.add(addSchCollectorConfigDTO); + } + + /** + * 编辑 + * + * @param editSchCollectorConfigDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorConfigDTO editSchCollectorConfigDTO) { + return iSchCollectorConfigService.edit(editSchCollectorConfigDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorConfigDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorConfigDTO deleteSchCollectorConfigDTO) { + return iSchCollectorConfigService.delete(deleteSchCollectorConfigDTO); + } + + + public static void main(String[] args) { + + HashMap objectObjectHashMap = Maps.newHashMap(); + objectObjectHashMap.put("ocr.url", "http://192.168.2.13/ocr"); + objectObjectHashMap.put("ocr.name", "lin"); + objectObjectHashMap.put("ocr.pwd", "123"); + System.out.println(JSON.toJSON(objectObjectHashMap)); + + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorController.java new file mode 100644 index 0000000..5c1ae14 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorController.java @@ -0,0 +1,94 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.log.annotation.TrackLogGroup; +import com.docus.server.api.scheduling.management.SchCollectorApi; +import com.docus.server.common.process.CollectorVersionProcessor; +import com.docus.server.dto.scheduling.management.schcollector.AddSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.DeleteSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.EditSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO; +import com.docus.server.service.ISchCollectorService; +import com.docus.server.vo.scheduling.management.schcollector.SchCollectorVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集器管理 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectorController implements SchCollectorApi { + @Resource + private ISchCollectorService iSchCollectorService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVO findById(String id) { + return iSchCollectorService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectorService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorDTO addSchCollectorDTO) { + return iSchCollectorService.add(addSchCollectorDTO); + } + + /** + * 编辑 + * + * @param editSchCollectorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorDTO editSchCollectorDTO) { + return iSchCollectorService.edit(editSchCollectorDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorDTO deleteSchCollectorDTO) { + return iSchCollectorService.delete(deleteSchCollectorDTO); + } + + /** + * 选为当前版本并更新 + * + * @return 成功或失败 + */ + @TrackLogGroup(group = "采集器管理", action = "更新", desc = "更新采集器版本", processor = CollectorVersionProcessor.class) + @Override + public boolean updateVersion(UpdateSchCollectorDTO updateDTO) { + return iSchCollectorService.updateVersion(updateDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionController.java new file mode 100644 index 0000000..0ceb4d2 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionController.java @@ -0,0 +1,84 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectorVersionApi; +import com.docus.server.dto.scheduling.management.schcollectorversion.AddSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.DeleteSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.EditSchCollectorVersionDTO; +import com.docus.server.service.ISchCollectorService; +import com.docus.server.service.ISchCollectorVersionService; +import com.docus.server.vo.scheduling.management.schcollectorversion.SchCollectorVersionVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集器版本列表管理 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectorVersionController implements SchCollectorVersionApi { + @Resource + private ISchCollectorVersionService iSchCollectorVersionService; + @Resource + private ISchCollectorService iSchCollectorService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionVO findById(String id) { + return iSchCollectorVersionService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectorVersionService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectorVersionDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionDTO addSchCollectorVersionDTO) { + return iSchCollectorVersionService.add(addSchCollectorVersionDTO); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionDTO editSchCollectorVersionDTO) { + return iSchCollectorVersionService.edit(editSchCollectorVersionDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionDTO deleteSchCollectorVersionDTO) { + return iSchCollectorVersionService.delete(deleteSchCollectorVersionDTO); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionFileController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionFileController.java new file mode 100644 index 0000000..4e33b9f --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionFileController.java @@ -0,0 +1,114 @@ +package com.docus.server.controller; + +import cn.hutool.core.util.StrUtil; +import com.docus.core.util.Func; +import com.docus.infrastructure.web.exception.ApiException; +import com.docus.infrastructure.web.exception.ExceptionCode; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectorVersionFileApi; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.AddSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.DeleteSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.EditSchCollectorVersionFileDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.service.ISchCollectorVersionFileService; +import com.docus.server.service.ISchCollectorVersionService; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.SchCollectorVersionFileVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * 采集器版本列表更新包管理 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +@Slf4j +public class SchCollectorVersionFileController implements SchCollectorVersionFileApi { + @Resource + private ISchCollectorVersionFileService iSchCollectorVersionFileService; + @Resource + private ISchCollectorVersionService iSchCollectorVersionService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionFileVO findById(String id) { + return iSchCollectorVersionFileService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectorVersionFileService.search(searchDTO); + } + + /** + * 新增 + * + * @param addDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionFileDTO addDTO, MultipartFile[] multipartFiles) throws Exception { + if (fileValid(multipartFiles, addDTO)) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "请选择文件和填写上传文件信息!"); + } + + SchCollectorVersion schCollectorVersion = iSchCollectorVersionService.findByVersion(addDTO.getCollectorId(), addDTO.getCollectorVersionNo()); + + if (null != schCollectorVersion) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "当前采集器版本号已存在!"); + } + + iSchCollectorVersionFileService.addVersionAndFile(addDTO, multipartFiles); + + return true; + } + + private boolean fileValid(MultipartFile[] multipartFiles, AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO) { + return multipartFiles == null + || multipartFiles.length == 0 + || StrUtil.isBlank(addSchCollectorVersionFileDTO.getCollectorVersionNo()) + || Func.isEmpty(addSchCollectorVersionFileDTO.getCollectorId()); + } + + public boolean add(AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO) { + return iSchCollectorVersionFileService.add(addSchCollectorVersionFileDTO); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionFileDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionFileDTO editSchCollectorVersionFileDTO) { + return iSchCollectorVersionFileService.edit(editSchCollectorVersionFileDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionFileDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionFileDTO deleteSchCollectorVersionFileDTO) { + return iSchCollectorVersionFileService.delete(deleteSchCollectorVersionFileDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionLogController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionLogController.java new file mode 100644 index 0000000..b9430cd --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchCollectorVersionLogController.java @@ -0,0 +1,80 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchCollectorVersionLogApi; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.AddSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.DeleteSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.EditSchCollectorVersionLogDTO; +import com.docus.server.service.ISchCollectorVersionLogService; +import com.docus.server.vo.scheduling.management.schcollectorversionlog.SchCollectorVersionLogVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集器版本更新日志管理 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchCollectorVersionLogController implements SchCollectorVersionLogApi { + @Resource + private ISchCollectorVersionLogService iSchCollectorVersionLogService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionLogVO findById(String id) { + return iSchCollectorVersionLogService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchCollectorVersionLogService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchCollectorVersionLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionLogDTO addSchCollectorVersionLogDTO) { + return iSchCollectorVersionLogService.add(addSchCollectorVersionLogDTO); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionLogDTO editSchCollectorVersionLogDTO) { + return iSchCollectorVersionLogService.edit(editSchCollectorVersionLogDTO); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionLogDTO deleteSchCollectorVersionLogDTO) { + return iSchCollectorVersionLogService.delete(deleteSchCollectorVersionLogDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchOperationLogController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchOperationLogController.java new file mode 100644 index 0000000..ab44752 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchOperationLogController.java @@ -0,0 +1,80 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchOperationLogApi; +import com.docus.server.dto.scheduling.management.schoperationlog.AddSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.DeleteSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.EditSchOperationLogDTO; +import com.docus.server.service.ISchOperationLogService; +import com.docus.server.vo.scheduling.management.schoperationlog.SchOperationLogVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 采集调度器操作日志 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchOperationLogController implements SchOperationLogApi { + @Resource + private ISchOperationLogService iSchOperationLogService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchOperationLogVO findById(String id) { + return iSchOperationLogService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchOperationLogService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchOperationLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchOperationLogDTO addSchOperationLogDTO) { + return iSchOperationLogService.add(addSchOperationLogDTO); + } + + /** + * 编辑 + * + * @param editSchOperationLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchOperationLogDTO editSchOperationLogDTO) { + return iSchOperationLogService.edit(editSchOperationLogDTO); + } + + /** + * 批量删除 + * + * @param deleteSchOperationLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchOperationLogDTO deleteSchOperationLogDTO) { + return iSchOperationLogService.delete(deleteSchOperationLogDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchSystemParamsController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchSystemParamsController.java new file mode 100644 index 0000000..78ec4cf --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchSystemParamsController.java @@ -0,0 +1,80 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchSystemParamsApi; +import com.docus.server.dto.scheduling.management.schsystemparams.AddSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.DeleteSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.EditSchSystemParamsDTO; +import com.docus.server.service.ISchSystemParamsService; +import com.docus.server.vo.scheduling.management.schsystemparams.SchSystemParamsVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 系统参数表 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchSystemParamsController implements SchSystemParamsApi { + @Resource + private ISchSystemParamsService iSchSystemParamsService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchSystemParamsVO findById(String id) { + return iSchSystemParamsService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchSystemParamsService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchSystemParamsDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchSystemParamsDTO addSchSystemParamsDTO) { + return iSchSystemParamsService.add(addSchSystemParamsDTO); + } + + /** + * 编辑 + * + * @param editSchSystemParamsDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchSystemParamsDTO editSchSystemParamsDTO) { + return iSchSystemParamsService.edit(editSchSystemParamsDTO); + } + + /** + * 批量删除 + * + * @param deleteSchSystemParamsDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchSystemParamsDTO deleteSchSystemParamsDTO) { + return iSchSystemParamsService.delete(deleteSchSystemParamsDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchTerminatorController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchTerminatorController.java new file mode 100644 index 0000000..65700e2 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchTerminatorController.java @@ -0,0 +1,87 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.log.annotation.TrackGroup; +import com.docus.server.api.scheduling.management.SchTerminatorApi; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.common.process.ChannelProcessor; +import com.docus.server.dto.scheduling.management.schterminator.AddSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.DeleteSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.EditSchTerminatorDTO; +import com.docus.server.service.ISchTerminatorService; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 执行管理器 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchTerminatorController implements SchTerminatorApi { + @Resource + private ISchTerminatorService iSchTerminatorService; + @Resource + private ChannelRepository channelRepository; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchTerminatorVO findById(String id) { + return iSchTerminatorService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchTerminatorService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchTerminatorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchTerminatorDTO addSchTerminatorDTO) { + return iSchTerminatorService.add(addSchTerminatorDTO); + } + + /** + * 编辑 + * + * @param editSchTerminatorDTO 编辑参数 + * @return 成功或失败 + */ + @TrackGroup(group = "SchTerminatorController", processor = ChannelProcessor.class) + @Override + public boolean edit(EditSchTerminatorDTO editSchTerminatorDTO) { + return iSchTerminatorService.edit(editSchTerminatorDTO); + } + + /** + * 批量删除 + * + * @param deleteSchTerminatorDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchTerminatorDTO deleteSchTerminatorDTO) { + return iSchTerminatorService.delete(deleteSchTerminatorDTO); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/controller/SchVirtualLogController.java b/collector-terminal-management/src/main/java/com/docus/server/controller/SchVirtualLogController.java new file mode 100644 index 0000000..181b93e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/controller/SchVirtualLogController.java @@ -0,0 +1,80 @@ +package com.docus.server.controller; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.api.scheduling.management.SchVirtualLogApi; +import com.docus.server.dto.scheduling.management.schvirtuallog.AddSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.DeleteSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.EditSchVirtualLogDTO; +import com.docus.server.service.ISchVirtualLogService; +import com.docus.server.vo.scheduling.management.schvirtuallog.SchVirtualLogVO; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 虚拟机使用情况 控制器类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@RestController +public class SchVirtualLogController implements SchVirtualLogApi { + @Resource + private ISchVirtualLogService iSchVirtualLogService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchVirtualLogVO findById(String id) { + return iSchVirtualLogService.findById(id); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return iSchVirtualLogService.search(searchDTO); + } + + /** + * 新增 + * + * @param addSchVirtualLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchVirtualLogDTO addSchVirtualLogDTO) { + return iSchVirtualLogService.add(addSchVirtualLogDTO); + } + + /** + * 编辑 + * + * @param editSchVirtualLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchVirtualLogDTO editSchVirtualLogDTO) { + return iSchVirtualLogService.edit(editSchVirtualLogDTO); + } + + /** + * 批量删除 + * + * @param deleteSchVirtualLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchVirtualLogDTO deleteSchVirtualLogDTO) { + return iSchVirtualLogService.delete(deleteSchVirtualLogDTO); + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/CommMsgConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/CommMsgConvert.java new file mode 100644 index 0000000..fae23c5 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/CommMsgConvert.java @@ -0,0 +1,24 @@ +package com.docus.server.convert; + +import com.docus.server.common.netty.CommMsg; +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +/** + * 通用消息转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface CommMsgConvert { + + CommMsgConvert INSTANCE = Mappers.getMapper(CommMsgConvert.class); + + @Mappings({}) + CommMsg convertDO(CommMsgDTO commMsgDTO); + +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectErrorLogConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectErrorLogConvert.java new file mode 100644 index 0000000..b3c3c7f --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectErrorLogConvert.java @@ -0,0 +1,48 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectErrorLog; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.AddSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.EditSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.DeleteSchCollectErrorLogDTO; +import com.docus.server.vo.scheduling.management.schcollecterrorlog.SchCollectErrorLogVO; + +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器异常日志 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectErrorLogConvert { + + SchCollectErrorLogConvert INSTANCE = Mappers.getMapper(SchCollectErrorLogConvert.class); + + @Mappings({}) + SchCollectErrorLog convertDO(AddSchCollectErrorLogDTO addSchCollectErrorLogDTO); + + @Mappings({}) + SchCollectErrorLog convertDO(EditSchCollectErrorLogDTO editSchCollectErrorLogDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectErrorLogDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectErrorLogDTO); + + @Mappings({}) + SchCollectErrorLogVO convertVO(SchCollectErrorLog schCollectErrorLog); + + @Mappings({}) + List convertVO(List schCollectErrorLogList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordConvert.java new file mode 100644 index 0000000..2ead1ea --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordConvert.java @@ -0,0 +1,47 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectrecord.AddSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.vo.scheduling.management.schcollectrecord.SchCollectRecordVO; +import org.mapstruct.Mapper; +import org.mapstruct.MappingTarget; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集记录表 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectRecordConvert { + + SchCollectRecordConvert INSTANCE = Mappers.getMapper(SchCollectRecordConvert.class); + + @Mappings({}) + SchCollectRecord convertDO(AddSchCollectRecordDTO addSchCollectRecordDTO); + + @Mappings({}) + SchCollectRecord convertDO(EditSchCollectRecordDTO editSchCollectRecordDTO, @MappingTarget SchCollectRecord schCollectRecord); + + @Mappings({}) + List convertAddDOList(List addSchCollectRecordDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectRecordDTO); + + @Mappings({}) + SchCollectRecordVO convertVO(SchCollectRecord schCollectRecord); + + @Mappings({}) + List convertVO(List schCollectRecordList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordRetryLogConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordRetryLogConvert.java new file mode 100644 index 0000000..8a4ccdd --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectRecordRetryLogConvert.java @@ -0,0 +1,51 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.AddSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.EditSchCollectRecordRetryLogDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.vo.scheduling.management.schcollectrecordretrylog.SchCollectRecordRetryLogVO; +import org.mapstruct.Mapper; +import org.mapstruct.MappingTarget; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集记录表重试表 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectRecordRetryLogConvert { + + SchCollectRecordRetryLogConvert INSTANCE = Mappers.getMapper(SchCollectRecordRetryLogConvert.class); + + @Mappings({}) + SchCollectRecordRetryLog convertDO(EditSchCollectRecordDTO editSchCollectRecordDTO, @MappingTarget SchCollectRecordRetryLog schCollectRecordRetryLog); + + @Mappings({}) + SchCollectRecordRetryLog convertDO(AddSchCollectRecordRetryLogDTO addSchCollectRecordRetryLogDTO); + + @Mappings({}) + SchCollectRecordRetryLog convertDO(EditSchCollectRecordRetryLogDTO editSchCollectRecordRetryLogDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectRecordRetryLogDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectRecordRetryLogDTO); + + @Mappings({}) + SchCollectRecordRetryLogVO convertVO(SchCollectRecordRetryLog schCollectRecordRetryLog); + + @Mappings({}) + List convertVO(List schCollectRecordRetryLogList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConfigConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConfigConvert.java new file mode 100644 index 0000000..e7ccd72 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConfigConvert.java @@ -0,0 +1,44 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorconfig.AddSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.EditSchCollectorConfigDTO; +import com.docus.server.entity.scheduling.management.SchCollectorConfig; +import com.docus.server.vo.scheduling.management.schcollectorconfig.SchCollectorConfigVO; +import com.docus.server.vo.scheduling.management.schcollectorconfig.TcpSchCollectorConfigVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器配置 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectorConfigConvert { + + SchCollectorConfigConvert INSTANCE = Mappers.getMapper(SchCollectorConfigConvert.class); + + @Mappings({}) + SchCollectorConfig convertDO(AddSchCollectorConfigDTO addSchCollectorConfigDTO); + + @Mappings({}) + SchCollectorConfig convertDO(EditSchCollectorConfigDTO editSchCollectorConfigDTO); + + @Mappings({}) + SchCollectorConfigVO convertVO(SchCollectorConfig schCollectorConfig); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); + + @Mappings({}) + List convertTcpVOList(List publicConfig); + + @Mappings({}) + TcpSchCollectorConfigVO convertTcpVO(SchCollectorConfig schCollectorConfig); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConvert.java new file mode 100644 index 0000000..c2d2f16 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorConvert.java @@ -0,0 +1,47 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollector.AddSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.EditSchCollectorDTO; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.vo.scheduling.management.schcollector.SchCollectorVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器管理 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectorConvert { + + SchCollectorConvert INSTANCE = Mappers.getMapper(SchCollectorConvert.class); + + @Mappings({}) + SchCollector convertDO(AddSchCollectorDTO addSchCollectorDTO); + + @Mappings({}) + SchCollector convertDO(EditSchCollectorDTO editSchCollectorDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectorDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectorDTO); + + @Mappings({}) + SchCollectorVO convertVO(SchCollector schCollector); + + @Mappings({}) + List convertVO(List schCollectorList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); + +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionConvert.java new file mode 100644 index 0000000..131d256 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionConvert.java @@ -0,0 +1,46 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorversion.AddSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.EditSchCollectorVersionDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.vo.scheduling.management.schcollectorversion.SchCollectorVersionVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器版本列表管理 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectorVersionConvert { + + SchCollectorVersionConvert INSTANCE = Mappers.getMapper(SchCollectorVersionConvert.class); + + @Mappings({}) + SchCollectorVersion convertDO(AddSchCollectorVersionDTO addSchCollectorVersionDTO); + + @Mappings({}) + SchCollectorVersion convertDO(EditSchCollectorVersionDTO editSchCollectorVersionDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectorVersionDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectorVersionDTO); + + @Mappings({}) + SchCollectorVersionVO convertVO(SchCollectorVersion schCollectorVersion); + + @Mappings({}) + List convertVO(List schCollectorVersionList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionFileConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionFileConvert.java new file mode 100644 index 0000000..cbfdcac --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionFileConvert.java @@ -0,0 +1,48 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.AddSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.EditSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.DeleteSchCollectorVersionFileDTO; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.SchCollectorVersionFileVO; + +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器版本列表更新包管理 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectorVersionFileConvert { + + SchCollectorVersionFileConvert INSTANCE = Mappers.getMapper(SchCollectorVersionFileConvert.class); + + @Mappings({}) + SchCollectorVersionFile convertDO(AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO); + + @Mappings({}) + SchCollectorVersionFile convertDO(EditSchCollectorVersionFileDTO editSchCollectorVersionFileDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectorVersionFileDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectorVersionFileDTO); + + @Mappings({}) + SchCollectorVersionFileVO convertVO(SchCollectorVersionFile schCollectorVersionFile); + + @Mappings({}) + List convertVO(List schCollectorVersionFileList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionLogConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionLogConvert.java new file mode 100644 index 0000000..6ed24c6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchCollectorVersionLogConvert.java @@ -0,0 +1,48 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.AddSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.EditSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.DeleteSchCollectorVersionLogDTO; +import com.docus.server.vo.scheduling.management.schcollectorversionlog.SchCollectorVersionLogVO; + +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集器版本更新日志管理 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchCollectorVersionLogConvert { + + SchCollectorVersionLogConvert INSTANCE = Mappers.getMapper(SchCollectorVersionLogConvert.class); + + @Mappings({}) + SchCollectorVersionLog convertDO(AddSchCollectorVersionLogDTO addSchCollectorVersionLogDTO); + + @Mappings({}) + SchCollectorVersionLog convertDO(EditSchCollectorVersionLogDTO editSchCollectorVersionLogDTO); + + @Mappings({}) + List convertAddDOList(List addSchCollectorVersionLogDTO); + + @Mappings({}) + List convertEditDOList(List editSchCollectorVersionLogDTO); + + @Mappings({}) + SchCollectorVersionLogVO convertVO(SchCollectorVersionLog schCollectorVersionLog); + + @Mappings({}) + List convertVO(List schCollectorVersionLogList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchOperationLogConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchOperationLogConvert.java new file mode 100644 index 0000000..5c98766 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchOperationLogConvert.java @@ -0,0 +1,48 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchOperationLog; +import com.docus.server.dto.scheduling.management.schoperationlog.AddSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.EditSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.DeleteSchOperationLogDTO; +import com.docus.server.vo.scheduling.management.schoperationlog.SchOperationLogVO; + +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 采集调度器操作日志 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchOperationLogConvert { + + SchOperationLogConvert INSTANCE = Mappers.getMapper(SchOperationLogConvert.class); + + @Mappings({}) + SchOperationLog convertDO(AddSchOperationLogDTO addSchOperationLogDTO); + + @Mappings({}) + SchOperationLog convertDO(EditSchOperationLogDTO editSchOperationLogDTO); + + @Mappings({}) + List convertAddDOList(List addSchOperationLogDTO); + + @Mappings({}) + List convertEditDOList(List editSchOperationLogDTO); + + @Mappings({}) + SchOperationLogVO convertVO(SchOperationLog schOperationLog); + + @Mappings({}) + List convertVO(List schOperationLogList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchSystemParamsConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchSystemParamsConvert.java new file mode 100644 index 0000000..f3bb4c2 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchSystemParamsConvert.java @@ -0,0 +1,48 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.dto.scheduling.management.schsystemparams.AddSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.EditSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.DeleteSchSystemParamsDTO; +import com.docus.server.vo.scheduling.management.schsystemparams.SchSystemParamsVO; + +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 系统参数表 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchSystemParamsConvert { + + SchSystemParamsConvert INSTANCE = Mappers.getMapper(SchSystemParamsConvert.class); + + @Mappings({}) + SchSystemParams convertDO(AddSchSystemParamsDTO addSchSystemParamsDTO); + + @Mappings({}) + SchSystemParams convertDO(EditSchSystemParamsDTO editSchSystemParamsDTO); + + @Mappings({}) + List convertAddDOList(List addSchSystemParamsDTO); + + @Mappings({}) + List convertEditDOList(List editSchSystemParamsDTO); + + @Mappings({}) + SchSystemParamsVO convertVO(SchSystemParams schSystemParams); + + @Mappings({}) + List convertVO(List schSystemParamsList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchTerminatorConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchTerminatorConvert.java new file mode 100644 index 0000000..4df7807 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchTerminatorConvert.java @@ -0,0 +1,42 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schterminator.AddSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.EditSchTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; +import org.mapstruct.Mapper; +import org.mapstruct.MappingTarget; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 执行管理器 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchTerminatorConvert { + + SchTerminatorConvert INSTANCE = Mappers.getMapper(SchTerminatorConvert.class); + + @Mappings({}) + SchTerminator convertDO(AddSchTerminatorDTO addSchTerminatorDTO); + + @Mappings({}) + SchTerminator convertDO(EditSchTerminatorDTO editSchTerminatorDTO, @MappingTarget SchTerminator schTerminator1); + + @Mappings({}) + SchTerminatorVO convertVO(SchTerminator schTerminator); + + @Mappings({}) + List convertVO(List schTerminatorList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); + +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/convert/SchVirtualLogConvert.java b/collector-terminal-management/src/main/java/com/docus/server/convert/SchVirtualLogConvert.java new file mode 100644 index 0000000..48555b2 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/convert/SchVirtualLogConvert.java @@ -0,0 +1,46 @@ +package com.docus.server.convert; + +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schvirtuallog.AddSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.EditSchVirtualLogDTO; +import com.docus.server.entity.scheduling.management.SchVirtualLog; +import com.docus.server.vo.scheduling.management.schvirtuallog.SchVirtualLogVO; +import org.mapstruct.Mapper; +import org.mapstruct.Mappings; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 虚拟机使用情况 服务转换器 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Mapper +public interface SchVirtualLogConvert { + + SchVirtualLogConvert INSTANCE = Mappers.getMapper(SchVirtualLogConvert.class); + + @Mappings({}) + SchVirtualLog convertDO(AddSchVirtualLogDTO addSchVirtualLogDTO); + + @Mappings({}) + SchVirtualLog convertDO(EditSchVirtualLogDTO editSchVirtualLogDTO); + + @Mappings({}) + List convertAddDOList(List addSchVirtualLogDTO); + + @Mappings({}) + List convertEditDOList(List editSchVirtualLogDTO); + + @Mappings({}) + SchVirtualLogVO convertVO(SchVirtualLog schVirtualLog); + + @Mappings({}) + List convertVO(List schVirtualLogList); + + @Mappings({}) + PageResult convertVO(PageResult pageResult); +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/cache/TaskCacheLayer.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/cache/TaskCacheLayer.java new file mode 100644 index 0000000..6fea6c6 --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/java/com/docus/server/infrastructure/client/DownLoadAPI.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/client/DownLoadAPI.java new file mode 100644 index 0000000..56f84f1 --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectErrorLogDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectErrorLogDao.java new file mode 100644 index 0000000..7b348ba --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectErrorLogDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectErrorLog; + +import java.util.List; + +/** + * 采集器异常日志 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectErrorLogDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectErrorLog findById(String id); + + /** + * 新增 + * + * @param schCollectErrorLog 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectErrorLog schCollectErrorLog); + + /** + * 编辑 + * + * @param schCollectErrorLog 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectErrorLog schCollectErrorLog); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordDao.java new file mode 100644 index 0000000..02c920a --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectRecord; + +import java.util.List; + +/** + * 采集记录表 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectRecordDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectRecord findById(String id); + + /** + * 新增 + * + * @param schCollectRecord 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectRecord schCollectRecord); + + /** + * 编辑 + * + * @param schCollectRecord 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectRecord schCollectRecord); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordRetryLogDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordRetryLogDao.java new file mode 100644 index 0000000..e8e4e67 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectRecordRetryLogDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; + +import java.util.List; + +/** + * 采集记录表重试表 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectRecordRetryLogDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectRecordRetryLog findById(String id); + + /** + * 新增 + * + * @param schCollectRecordRetryLog 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectRecordRetryLog schCollectRecordRetryLog); + + /** + * 编辑 + * + * @param schCollectRecordRetryLog 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectRecordRetryLog schCollectRecordRetryLog); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorConfigDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorConfigDao.java new file mode 100644 index 0000000..77667d7 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorConfigDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorConfig; + +import java.util.List; + +/** + * 采集器配置 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorConfigDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorConfig findById(String id); + + /** + * 新增 + * + * @param schCollectorConfig 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectorConfig schCollectorConfig); + + /** + * 编辑 + * + * @param schCollectorConfig 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectorConfig schCollectorConfig); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorDao.java new file mode 100644 index 0000000..0c01fea --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollector; + +import java.util.List; + +/** + * 采集器管理 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollector findById(String id); + + /** + * 新增 + * + * @param schCollector 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollector schCollector); + + /** + * 编辑 + * + * @param schCollector 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollector schCollector); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionDao.java new file mode 100644 index 0000000..6922d3e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionDao.java @@ -0,0 +1,66 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; + +import java.util.List; + +/** + * 采集器版本列表管理 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersion findById(String id); + + /** + * 新增 + * + * @param schCollectorVersion 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectorVersion schCollectorVersion); + + /** + * 编辑 + * + * @param schCollectorVersion 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectorVersion schCollectorVersion); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 根据采集器id和版本号查询是否重复 + * + * @param collectorId 采集器id + * @param collectorVersionNo 版本号码 + * @return SchCollectorVersion + */ + SchCollectorVersion findByVersion(Long collectorId, String collectorVersionNo); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionFileDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionFileDao.java new file mode 100644 index 0000000..7ad13d0 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionFileDao.java @@ -0,0 +1,58 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; + +import java.util.List; + +/** + * 采集器版本列表更新包管理 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionFileDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersionFile findById(String id); + + /** + * 新增 + * + * @param schCollectorVersionFile 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectorVersionFile schCollectorVersionFile); + + /** + * 编辑 + * + * @param schCollectorVersionFile 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectorVersionFile schCollectorVersionFile); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + SchCollectorVersionFile findByVersionIdAndCollectorId(Long collectorId, Long collectorVersionId); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionLogDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionLogDao.java new file mode 100644 index 0000000..b643b9d --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchCollectorVersionLogDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; + +import java.util.List; + +/** + * 采集器版本更新日志管理 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionLogDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersionLog findById(String id); + + /** + * 新增 + * + * @param schCollectorVersionLog 新增参数 + * @return 成功或失败 + */ + boolean add(SchCollectorVersionLog schCollectorVersionLog); + + /** + * 编辑 + * + * @param schCollectorVersionLog 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchCollectorVersionLog schCollectorVersionLog); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchOperationLogDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchOperationLogDao.java new file mode 100644 index 0000000..c7cd7f0 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchOperationLogDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchOperationLog; + +import java.util.List; + +/** + * 采集调度器操作日志 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchOperationLogDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchOperationLog findById(String id); + + /** + * 新增 + * + * @param schOperationLog 新增参数 + * @return 成功或失败 + */ + boolean add(SchOperationLog schOperationLog); + + /** + * 编辑 + * + * @param schOperationLog 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchOperationLog schOperationLog); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchSystemParamsDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchSystemParamsDao.java new file mode 100644 index 0000000..c0a6f92 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchSystemParamsDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchSystemParams; + +import java.util.List; + +/** + * 系统参数表 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchSystemParamsDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchSystemParams findById(String id); + + /** + * 新增 + * + * @param schSystemParams 新增参数 + * @return 成功或失败 + */ + boolean add(SchSystemParams schSystemParams); + + /** + * 编辑 + * + * @param schSystemParams 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchSystemParams schSystemParams); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchTerminatorDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchTerminatorDao.java new file mode 100644 index 0000000..dc31c51 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchTerminatorDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchTerminator; + +import java.util.List; + +/** + * 执行管理器 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchTerminatorDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchTerminator findById(String id); + + /** + * 新增 + * + * @param schTerminator 新增参数 + * @return 成功或失败 + */ + boolean add(SchTerminator schTerminator); + + /** + * 编辑 + * + * @param schTerminator 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchTerminator schTerminator); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchVirtualLogDao.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchVirtualLogDao.java new file mode 100644 index 0000000..3c4d740 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/ISchVirtualLogDao.java @@ -0,0 +1,57 @@ +package com.docus.server.infrastructure.dao; + +import com.docus.infrastructure.core.db.dao.IBaseDao; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchVirtualLog; + +import java.util.List; + +/** + * 虚拟机使用情况 数据访问接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchVirtualLogDao extends IBaseDao { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchVirtualLog findById(String id); + + /** + * 新增 + * + * @param schVirtualLog 新增参数 + * @return 成功或失败 + */ + boolean add(SchVirtualLog schVirtualLog); + + /** + * 编辑 + * + * @param schVirtualLog 编辑参数 + * @return 成功或失败 + */ + boolean edit(SchVirtualLog schVirtualLog); + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + int delete(List ids); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectErrorLogDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectErrorLogDaoImpl.java new file mode 100644 index 0000000..7b5d50d --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectErrorLogDaoImpl.java @@ -0,0 +1,104 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectErrorLog; +import com.docus.server.infrastructure.dao.ISchCollectErrorLogDao; +import com.docus.server.infrastructure.mapper.SchCollectErrorLogMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器异常日志 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectErrorLogDaoImpl extends BaseDaoImpl implements ISchCollectErrorLogDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectErrorLog findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectErrorLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectErrorLog schCollectErrorLog) { + return super.save(schCollectErrorLog); + } + + /** + * 编辑 + * + * @param schCollectErrorLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectErrorLog schCollectErrorLog) { + return super.updateById(schCollectErrorLog); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectErrorLog::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectErrorLog::getCreateTime, endTime); + } + //关键字比较,多个列or + //if (!StringUtils.isEmpty(searchDTO.getKeyword())) { + //单个列用like + //query. like(SchCollectErrorLog::getxxx, searchDTO.getKeyword()); + //多个列用like + //query. and(sub -> sub.like(SchCollectErrorLog::getxx1, searchDTO.getKeyword()) + // оr(). like(SchCollectErrorLog::getXX2, searchDTO.getKeyword())) + //); + //} + //默认createTime倒序排序 + query.orderByDesc(SchCollectErrorLog::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordDaoImpl.java new file mode 100644 index 0000000..7bc4249 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordDaoImpl.java @@ -0,0 +1,101 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.infrastructure.dao.ISchCollectRecordDao; +import com.docus.server.infrastructure.mapper.SchCollectRecordMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 采集记录表 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectRecordDaoImpl extends BaseDaoImpl implements ISchCollectRecordDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecord findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectRecord 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectRecord schCollectRecord) { + return super.save(schCollectRecord); + } + + /** + * 编辑 + * + * @param schCollectRecord 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectRecord schCollectRecord) { + return super.updateById(schCollectRecord); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectRecord::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + query.le(SchCollectRecord::getCreateTime, searchDTO.getEndTime()); + } + + Object collectorId = searchDTO.getParams("collectorId"); + + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollectRecord::getCollectorId, collectorId); + } + + //默认createTime倒序排序 + query.orderByDesc(SchCollectRecord::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordRetryLogDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordRetryLogDaoImpl.java new file mode 100644 index 0000000..b946fdf --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectRecordRetryLogDaoImpl.java @@ -0,0 +1,100 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.infrastructure.dao.ISchCollectRecordRetryLogDao; +import com.docus.server.infrastructure.mapper.SchCollectRecordRetryLogMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.List; + +/** + * 采集记录表重试表 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectRecordRetryLogDaoImpl extends BaseDaoImpl implements ISchCollectRecordRetryLogDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecordRetryLog findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectRecordRetryLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectRecordRetryLog schCollectRecordRetryLog) { + return super.save(schCollectRecordRetryLog); + } + + /** + * 编辑 + * + * @param schCollectRecordRetryLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectRecordRetryLog schCollectRecordRetryLog) { + return super.updateById(schCollectRecordRetryLog); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectRecordRetryLog::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + query.le(SchCollectRecordRetryLog::getCreateTime, searchDTO.getEndTime()); + } + + Object collectorId = searchDTO.getParams("collectorId"); + + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollectRecordRetryLog::getCollectorId, collectorId); + } + //默认createTime倒序排序 + query.orderByDesc(SchCollectRecordRetryLog::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorConfigDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorConfigDaoImpl.java new file mode 100644 index 0000000..4a8a128 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorConfigDaoImpl.java @@ -0,0 +1,109 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorConfig; +import com.docus.server.infrastructure.dao.ISchCollectorConfigDao; +import com.docus.server.infrastructure.mapper.SchCollectorConfigMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器配置 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectorConfigDaoImpl extends BaseDaoImpl implements ISchCollectorConfigDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorConfig findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectorConfig 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectorConfig schCollectorConfig) { + return super.save(schCollectorConfig); + } + + /** + * 编辑 + * + * @param schCollectorConfig 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectorConfig schCollectorConfig) { + return super.updateById(schCollectorConfig); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectorConfig::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectorConfig::getCreateTime, endTime); + } + + if (searchDTO.getParams("collectorId") != null && searchDTO.getParams("collectorId") != "") { + query.eq(SchCollectorConfig::getCollectorId, searchDTO.getParams("collectorId")); + } + + if (searchDTO.getParams("configType") != null && searchDTO.getParams("configType") != "") { + query.eq(SchCollectorConfig::getConfigType, searchDTO.getParams("configType")); + } + + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectorConfig::getCreateTime, endTime); + } + + //默认createTime倒序排序 + query.orderByDesc(SchCollectorConfig::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorDaoImpl.java new file mode 100644 index 0000000..b7a4582 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorDaoImpl.java @@ -0,0 +1,102 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.infrastructure.dao.ISchCollectorDao; +import com.docus.server.infrastructure.mapper.SchCollectorMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器管理 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectorDaoImpl extends BaseDaoImpl implements ISchCollectorDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollector findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollector 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollector schCollector) { + return super.save(schCollector); + } + + /** + * 编辑 + * + * @param schCollector 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollector schCollector) { + return super.updateById(schCollector); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollector::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollector::getCreateTime, endTime); + } + + Object collectorId = searchDTO.getParams("collectorId"); + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollector::getCollectorId, collectorId); + } + + //默认createTime倒序排序 + query.orderByDesc(SchCollector::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionDaoImpl.java new file mode 100644 index 0000000..5b2d1af --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionDaoImpl.java @@ -0,0 +1,117 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.infrastructure.dao.ISchCollectorVersionDao; +import com.docus.server.infrastructure.mapper.SchCollectorVersionMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器版本列表管理 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectorVersionDaoImpl extends BaseDaoImpl implements ISchCollectorVersionDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersion findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectorVersion 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectorVersion schCollectorVersion) { + return super.save(schCollectorVersion); + } + + /** + * 编辑 + * + * @param schCollectorVersion 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectorVersion schCollectorVersion) { + return super.updateById(schCollectorVersion); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectorVersion::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectorVersion::getCreateTime, endTime); + } + + Object collectorId = searchDTO.getParams("collectorId"); + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollectorVersion::getCollectorId, collectorId); + } + + //默认createTime倒序排序 + query.orderByDesc(SchCollectorVersion::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + + @Override + public SchCollectorVersion findByVersion(Long collectorId, String collectorVersionNo) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + + if (Func.isNotEmpty(collectorId)) { + query.ge(SchCollectorVersion::getCollectorId, collectorId); + } + if (Func.isNotBlank(collectorVersionNo)) { + query.le(SchCollectorVersion::getCollectVersion, collectorVersionNo); + } + + return super.findOne(query); + + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionFileDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionFileDaoImpl.java new file mode 100644 index 0000000..35bdb84 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionFileDaoImpl.java @@ -0,0 +1,112 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.docus.server.enums.CancelEnum; +import com.docus.server.infrastructure.dao.ISchCollectorVersionFileDao; +import com.docus.server.infrastructure.mapper.SchCollectorVersionFileMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器版本列表更新包管理 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectorVersionFileDaoImpl extends BaseDaoImpl implements ISchCollectorVersionFileDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionFile findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectorVersionFile 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectorVersionFile schCollectorVersionFile) { + return super.save(schCollectorVersionFile); + } + + /** + * 编辑 + * + * @param schCollectorVersionFile 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectorVersionFile schCollectorVersionFile) { + return super.updateById(schCollectorVersionFile); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectorVersionFile::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectorVersionFile::getCreateTime, endTime); + } + + //默认createTime倒序排序 + query.orderByDesc(SchCollectorVersionFile::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + + @Override + public SchCollectorVersionFile findByVersionIdAndCollectorId(Long collectorId, Long collectorVersionId) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollectorVersionFile::getCollectorId, collectorId); + } + if (Func.isNotEmpty(collectorVersionId)) { + query.eq(SchCollectorVersionFile::getCollectorVersionId, collectorVersionId); + } + query.ne(SchCollectorVersionFile::getState, CancelEnum.CANCEL); + + return super.findOne(query); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionLogDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionLogDaoImpl.java new file mode 100644 index 0000000..f18fe88 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchCollectorVersionLogDaoImpl.java @@ -0,0 +1,100 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; +import com.docus.server.infrastructure.dao.ISchCollectorVersionLogDao; +import com.docus.server.infrastructure.mapper.SchCollectorVersionLogMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集器版本更新日志管理 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchCollectorVersionLogDaoImpl extends BaseDaoImpl implements ISchCollectorVersionLogDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionLog findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schCollectorVersionLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchCollectorVersionLog schCollectorVersionLog) { + return super.save(schCollectorVersionLog); + } + + /** + * 编辑 + * + * @param schCollectorVersionLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchCollectorVersionLog schCollectorVersionLog) { + return super.updateById(schCollectorVersionLog); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchCollectorVersionLog::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchCollectorVersionLog::getCreateTime, endTime); + } + Object collectorId = searchDTO.getParams("collectorId"); + if (Func.isNotEmpty(collectorId)) { + query.eq(SchCollectorVersionLog::getCollectorId, collectorId); + } + //默认createTime倒序排序 + query.orderByDesc(SchCollectorVersionLog::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchOperationLogDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchOperationLogDaoImpl.java new file mode 100644 index 0000000..15ee014 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchOperationLogDaoImpl.java @@ -0,0 +1,104 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchOperationLog; +import com.docus.server.infrastructure.dao.ISchOperationLogDao; +import com.docus.server.infrastructure.mapper.SchOperationLogMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 采集调度器操作日志 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchOperationLogDaoImpl extends BaseDaoImpl implements ISchOperationLogDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchOperationLog findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schOperationLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchOperationLog schOperationLog) { + return super.save(schOperationLog); + } + + /** + * 编辑 + * + * @param schOperationLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchOperationLog schOperationLog) { + return super.updateById(schOperationLog); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchOperationLog::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchOperationLog::getCreateTime, endTime); + } + //关键字比较,多个列or + //if (!StringUtils.isEmpty(searchDTO.getKeyword())) { + //单个列用like + //query. like(SchOperationLog::getxxx, searchDTO.getKeyword()); + //多个列用like + //query. and(sub -> sub.like(SchOperationLog::getxx1, searchDTO.getKeyword()) + // оr(). like(SchOperationLog::getXX2, searchDTO.getKeyword())) + //); + //} + //默认createTime倒序排序 + query.orderByDesc(SchOperationLog::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchSystemParamsDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchSystemParamsDaoImpl.java new file mode 100644 index 0000000..aee63ab --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchSystemParamsDaoImpl.java @@ -0,0 +1,103 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; +import com.docus.server.infrastructure.mapper.SchSystemParamsMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 系统参数表 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchSystemParamsDaoImpl extends BaseDaoImpl implements ISchSystemParamsDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchSystemParams findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schSystemParams 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchSystemParams schSystemParams) { + return super.save(schSystemParams); + } + + /** + * 编辑 + * + * @param schSystemParams 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchSystemParams schSystemParams) { + return super.updateById(schSystemParams); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchSystemParams::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchSystemParams::getCreateTime, endTime); + } + + //分组查询系统参数表 + String paramGroup = String.valueOf(searchDTO.getParams("paramGroup")); + if (Func.isNotBlank(paramGroup)) { + query.eq(SchSystemParams::getParamGroup, paramGroup); + } + + //默认createTime倒序排序 + query.orderByDesc(SchSystemParams::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchTerminatorDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchTerminatorDaoImpl.java new file mode 100644 index 0000000..dfe4493 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchTerminatorDaoImpl.java @@ -0,0 +1,101 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.docus.server.infrastructure.dao.ISchTerminatorDao; +import com.docus.server.infrastructure.mapper.SchTerminatorMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 执行管理器 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchTerminatorDaoImpl extends BaseDaoImpl implements ISchTerminatorDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchTerminator findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schTerminator 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchTerminator schTerminator) { + return super.save(schTerminator); + } + + /** + * 编辑 + * + * @param schTerminator 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchTerminator schTerminator) { + return super.updateById(schTerminator); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchTerminator::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchTerminator::getCreateTime, endTime); + } + + //在线状态 + if (searchDTO.getParams("onlineState") != null) { + query.eq(SchTerminator::getOnlineState, searchDTO.getParams("onlineState")); + } + + //默认createTime倒序排序 + query.orderByDesc(SchTerminator::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchVirtualLogDaoImpl.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchVirtualLogDaoImpl.java new file mode 100644 index 0000000..685a5ce --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/dao/impl/SchVirtualLogDaoImpl.java @@ -0,0 +1,104 @@ +package com.docus.server.infrastructure.dao.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.entity.scheduling.management.SchVirtualLog; +import com.docus.server.infrastructure.dao.ISchVirtualLogDao; +import com.docus.server.infrastructure.mapper.SchVirtualLogMapper; +import com.github.pagehelper.PageHelper; +import org.springframework.stereotype.Repository; + +import java.util.Date; +import java.util.List; + +/** + * 虚拟机使用情况 数据访问实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Repository +public class SchVirtualLogDaoImpl extends BaseDaoImpl implements ISchVirtualLogDao { + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchVirtualLog findById(String id) { + return super.findById(id); + } + + /** + * 新增 + * + * @param schVirtualLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(SchVirtualLog schVirtualLog) { + return super.save(schVirtualLog); + } + + /** + * 编辑 + * + * @param schVirtualLog 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(SchVirtualLog schVirtualLog) { + return super.updateById(schVirtualLog); + } + + /** + * 批量删除 + * + * @param ids 主键ids + * @return 成功或失败 + */ + @Override + public int delete(List ids) { + return super.deleteByIds(ids); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + //分页 + PageHelper.startPage(searchDTO.getPageNum(), searchDTO.getPageSize()); + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + //时间范围,默认按createTime + if (searchDTO.getBeginTime() != null) { + query.ge(SchVirtualLog::getCreateTime, searchDTO.getBeginTime()); + } + if (searchDTO.getEndTime() != null) { + Date endTime = searchDTO.getEndTime(); + query.le(SchVirtualLog::getCreateTime, endTime); + } + //关键字比较,多个列or + //if (!StringUtils.isEmpty(searchDTO.getKeyword())) { + //单个列用like + //query. like(SchVirtualLog::getxxx, searchDTO.getKeyword()); + //多个列用like + //query. and(sub -> sub.like(SchVirtualLog::getxx1, searchDTO.getKeyword()) + // оr(). like(SchVirtualLog::getXX2, searchDTO.getKeyword())) + //); + //} + //默认createTime倒序排序 + query.orderByDesc(SchVirtualLog::getCreateTime); + List list = super.find(query); + return new PageResult<>(list); + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectErrorLogMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectErrorLogMapper.java new file mode 100644 index 0000000..edae3c3 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectErrorLogMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectErrorLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器异常日志 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectErrorLogMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordMapper.java new file mode 100644 index 0000000..6ffdc55 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集记录表 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectRecordMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordRetryLogMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordRetryLogMapper.java new file mode 100644 index 0000000..9759a7d --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectRecordRetryLogMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集记录表重试表 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectRecordRetryLogMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorConfigMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorConfigMapper.java new file mode 100644 index 0000000..70ffe03 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorConfigMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectorConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器配置 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectorConfigMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorMapper.java new file mode 100644 index 0000000..f23ff29 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollector; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器管理 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectorMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionFileMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionFileMapper.java new file mode 100644 index 0000000..eabc60e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionFileMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器版本列表更新包管理 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectorVersionFileMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionLogMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionLogMapper.java new file mode 100644 index 0000000..55c8ca1 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionLogMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器版本更新日志管理 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectorVersionLogMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionMapper.java new file mode 100644 index 0000000..452219e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchCollectorVersionMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集器版本列表管理 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchCollectorVersionMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchOperationLogMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchOperationLogMapper.java new file mode 100644 index 0000000..97ef0f1 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchOperationLogMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchOperationLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 采集调度器操作日志 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchOperationLogMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchSystemParamsMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchSystemParamsMapper.java new file mode 100644 index 0000000..7305c16 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchSystemParamsMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 系统参数表 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchSystemParamsMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchTerminatorMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchTerminatorMapper.java new file mode 100644 index 0000000..910a074 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchTerminatorMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 执行管理器 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchTerminatorMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchVirtualLogMapper.java b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchVirtualLogMapper.java new file mode 100644 index 0000000..168b239 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/infrastructure/mapper/SchVirtualLogMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.infrastructure.mapper; + +import com.docus.server.entity.scheduling.management.SchVirtualLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* +* 虚拟机使用情况 Mapper 接口 +* +* @author AutoGenerator +* @since 2023-07-15 +*/ +@Mapper +public interface SchVirtualLogMapper extends BaseMapper { + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ICommMsgService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ICommMsgService.java new file mode 100644 index 0000000..615eee7 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ICommMsgService.java @@ -0,0 +1,21 @@ +package com.docus.server.service; + +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; + +public interface ICommMsgService { + + /** + * 向客户端发送TCP命令 + * + * @param commMsgDTO 消息体 + */ + void clientCommand(CommMsgDTO commMsgDTO); + + /** + * 向所有客户端发送TCP命令 + * + * @param commMsgDTO 消息体 + */ + void clientsCommand(CommMsgDTO commMsgDTO); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/IFileUploadService.java b/collector-terminal-management/src/main/java/com/docus/server/service/IFileUploadService.java new file mode 100644 index 0000000..00e46ec --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/IFileUploadService.java @@ -0,0 +1,14 @@ +package com.docus.server.service; + +import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +public interface IFileUploadService { + + List uploadFile(MultipartFile[] multipartFiles, String pathKey) throws Exception; + + void downloadFile(String filePath, HttpServletResponse response); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectErrorLogService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectErrorLogService.java new file mode 100644 index 0000000..8e96d9f --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectErrorLogService.java @@ -0,0 +1,58 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.AddSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.DeleteSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.EditSchCollectErrorLogDTO; +import com.docus.server.vo.scheduling.management.schcollecterrorlog.SchCollectErrorLogVO; +import org.springframework.web.multipart.MultipartFile; + +/** + * 采集器异常日志 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectErrorLogService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectErrorLogVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectErrorLogDTO 新增参数 + * @param multipartFiles 异常任务截图 + * @return 成功或失败 + */ + boolean add(AddSchCollectErrorLogDTO addSchCollectErrorLogDTO, MultipartFile[] multipartFiles) throws Exception; + + /** + * 编辑 + * + * @param editSchCollectErrorLogDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectErrorLogDTO editSchCollectErrorLogDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectErrorLogDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectErrorLogDTO deleteSchCollectErrorLogDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordRetryLogService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordRetryLogService.java new file mode 100644 index 0000000..d45ea0e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordRetryLogService.java @@ -0,0 +1,61 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.AddSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.DeleteSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.EditSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.vo.scheduling.management.schcollectrecordretrylog.SchCollectRecordRetryLogVO; + +/** + * 采集记录表重试表 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectRecordRetryLogService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectRecordRetryLogVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectRecordRetryLogDTO 新增参数 + * @return 成功或失败 + */ + SchCollectRecordRetryLog add(AddSchCollectRecordRetryLogDTO addSchCollectRecordRetryLogDTO); + + /** + * 编辑 + * + * @param editSchCollectRecordRetryLogDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectRecordRetryLogDTO editSchCollectRecordRetryLogDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectRecordRetryLogDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectRecordRetryLogDTO deleteSchCollectRecordRetryLogDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + SchCollectRecordRetryLog saveOrUpdateRecordRetryLog(NettyTerminatorDTO terminal, ReportDownTwoDTO reportDownTwoDTO); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordService.java new file mode 100644 index 0000000..c06f13b --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectRecordService.java @@ -0,0 +1,61 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.AddSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.DeleteSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.vo.scheduling.management.schcollectrecord.SchCollectRecordVO; + +/** + * 采集记录表 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectRecordService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectRecordVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectRecordDTO 新增参数 + * @return 成功或失败 + */ + SchCollectRecord add(AddSchCollectRecordDTO addSchCollectRecordDTO); + + /** + * 编辑 + * + * @param editSchCollectRecordDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectRecordDTO editSchCollectRecordDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectRecordDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectRecordDTO deleteSchCollectRecordDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + SchCollectRecord saveOrUpdateRecord(NettyTerminatorDTO terminal, ReportDownTwoDTO messageContent); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorConfigService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorConfigService.java new file mode 100644 index 0000000..23398eb --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorConfigService.java @@ -0,0 +1,61 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorconfig.AddSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.DeleteSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.EditSchCollectorConfigDTO; +import com.docus.server.vo.scheduling.management.schcollectorconfig.SchCollectorConfigVO; + +/** + * 采集器配置 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorConfigService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorConfigVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectorConfigDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchCollectorConfigDTO addSchCollectorConfigDTO); + + /** + * 编辑 + * + * @param editSchCollectorConfigDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectorConfigDTO editSchCollectorConfigDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectorConfigDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectorConfigDTO deleteSchCollectorConfigDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 更新采集器配置 + */ + void updateCollectorConfig(); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorService.java new file mode 100644 index 0000000..7278571 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorService.java @@ -0,0 +1,68 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollector.AddSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.DeleteSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.EditSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.vo.scheduling.management.schcollector.SchCollectorVO; + +/** + * 采集器管理 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectorDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchCollectorDTO addSchCollectorDTO); + + /** + * 编辑 + * + * @param editSchCollectorDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectorDTO editSchCollectorDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectorDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectorDTO deleteSchCollectorDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 选为当前版本并更新 + * + * @return 成功或失败 + */ + boolean updateVersion(UpdateSchCollectorDTO schCollector); + + SchCollector findByCollectorId(String collectorId); + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionFileService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionFileService.java new file mode 100644 index 0000000..92ad266 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionFileService.java @@ -0,0 +1,65 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.AddSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.DeleteSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.EditSchCollectorVersionFileDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.SchCollectorVersionFileVO; +import org.springframework.web.multipart.MultipartFile; + +/** + * 采集器版本列表更新包管理 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionFileService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersionFileVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectorVersionFileDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO); + + /** + * 编辑 + * + * @param editSchCollectorVersionFileDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectorVersionFileDTO editSchCollectorVersionFileDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionFileDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectorVersionFileDTO deleteSchCollectorVersionFileDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 新增版本和版本文件 + */ + void addVersionAndFile(AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO, MultipartFile[] multipartFiles) throws Exception; + + SchCollectorVersionFile findByCollectorIdAndVersionId(Long collectorId, Long collectorVersionId); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionLogService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionLogService.java new file mode 100644 index 0000000..9cd38a6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionLogService.java @@ -0,0 +1,56 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.AddSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.DeleteSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.EditSchCollectorVersionLogDTO; +import com.docus.server.vo.scheduling.management.schcollectorversionlog.SchCollectorVersionLogVO; + +/** + * 采集器版本更新日志管理 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionLogService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersionLogVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectorVersionLogDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchCollectorVersionLogDTO addSchCollectorVersionLogDTO); + + /** + * 编辑 + * + * @param editSchCollectorVersionLogDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectorVersionLogDTO editSchCollectorVersionLogDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionLogDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectorVersionLogDTO deleteSchCollectorVersionLogDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionService.java new file mode 100644 index 0000000..edeaac4 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchCollectorVersionService.java @@ -0,0 +1,65 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schcollectorversion.AddSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.DeleteSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.EditSchCollectorVersionDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.vo.scheduling.management.schcollectorversion.SchCollectorVersionVO; + +/** + * 采集器版本列表管理 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchCollectorVersionService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchCollectorVersionVO findById(String id); + + /** + * 新增 + * + * @param addSchCollectorVersionDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchCollectorVersionDTO addSchCollectorVersionDTO); + + /** + * 编辑 + * + * @param editSchCollectorVersionDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchCollectorVersionDTO editSchCollectorVersionDTO); + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchCollectorVersionDTO deleteSchCollectorVersionDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 查询当前采集器和版本号是否重复 + * @param collectorId + * @param collectorVersionNo + * @return + */ + SchCollectorVersion findByVersion(Long collectorId, String collectorVersionNo); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchOperationLogService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchOperationLogService.java new file mode 100644 index 0000000..a63ad23 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchOperationLogService.java @@ -0,0 +1,56 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schoperationlog.AddSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.DeleteSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.EditSchOperationLogDTO; +import com.docus.server.vo.scheduling.management.schoperationlog.SchOperationLogVO; + +/** + * 采集调度器操作日志 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchOperationLogService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchOperationLogVO findById(String id); + + /** + * 新增 + * + * @param addSchOperationLogDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchOperationLogDTO addSchOperationLogDTO); + + /** + * 编辑 + * + * @param editSchOperationLogDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchOperationLogDTO editSchOperationLogDTO); + + /** + * 批量删除 + * + * @param deleteSchOperationLogDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchOperationLogDTO deleteSchOperationLogDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchSystemParamsService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchSystemParamsService.java new file mode 100644 index 0000000..c62ece0 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchSystemParamsService.java @@ -0,0 +1,69 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schsystemparams.AddSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.DeleteSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.EditSchSystemParamsDTO; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.vo.scheduling.management.schsystemparams.SchSystemParamsVO; + +import java.util.List; +import java.util.Map; + +/** + * 系统参数表 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchSystemParamsService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchSystemParamsVO findById(String id); + + /** + * 新增 + * + * @param addSchSystemParamsDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchSystemParamsDTO addSchSystemParamsDTO); + + /** + * 编辑 + * + * @param editSchSystemParamsDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchSystemParamsDTO editSchSystemParamsDTO); + + /** + * 批量删除 + * + * @param deleteSchSystemParamsDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchSystemParamsDTO deleteSchSystemParamsDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + + /** + * 采集器id获取采集器名称 + * + * @param paramValueIds 采集器ids + * @return Map + */ + Map find(List paramValueIds); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchTerminatorService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchTerminatorService.java new file mode 100644 index 0000000..af4064f --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchTerminatorService.java @@ -0,0 +1,72 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schterminator.AddSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.DeleteSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.EditSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; + +import java.util.List; + +/** + * 执行管理器 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchTerminatorService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchTerminatorVO findById(String id); + + /** + * 新增 + * + * @param addSchTerminatorDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchTerminatorDTO addSchTerminatorDTO); + + /** + * 编辑 + * + * @param editSchTerminatorDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchTerminatorDTO editSchTerminatorDTO); + + /** + * 批量删除 + * + * @param deleteSchTerminatorDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchTerminatorDTO deleteSchTerminatorDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); + + /** + * 新增或更新 + * @param terminatorIp + * @param nettyTerminatorDTO + * @return + */ + SchTerminatorVO saveOrUpdate(String terminatorIp, NettyTerminatorDTO nettyTerminatorDTO); + + List findAll(); + + void batchUpdate(List terminators); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/ISchVirtualLogService.java b/collector-terminal-management/src/main/java/com/docus/server/service/ISchVirtualLogService.java new file mode 100644 index 0000000..be3fe7e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/ISchVirtualLogService.java @@ -0,0 +1,56 @@ +package com.docus.server.service; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.dto.scheduling.management.schvirtuallog.AddSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.DeleteSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.EditSchVirtualLogDTO; +import com.docus.server.vo.scheduling.management.schvirtuallog.SchVirtualLogVO; + +/** + * 虚拟机使用情况 服务接口 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +public interface ISchVirtualLogService { + /** + * 按主键查询 + * + * @param id 主键id + * @return 实体 + */ + SchVirtualLogVO findById(String id); + + /** + * 新增 + * + * @param addSchVirtualLogDTO 新增参数 + * @return 成功或失败 + */ + boolean add(AddSchVirtualLogDTO addSchVirtualLogDTO); + + /** + * 编辑 + * + * @param editSchVirtualLogDTO 编辑参数 + * @return 成功或失败 + */ + boolean edit(EditSchVirtualLogDTO editSchVirtualLogDTO); + + /** + * 批量删除 + * + * @param deleteSchVirtualLogDTO 删除参数 + * @return 成功或失败 + */ + int delete(DeleteSchVirtualLogDTO deleteSchVirtualLogDTO); + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + PageResult search(SearchDTO searchDTO); +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/CommMsgServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/CommMsgServiceImpl.java new file mode 100644 index 0000000..7e4f4d0 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/CommMsgServiceImpl.java @@ -0,0 +1,58 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.DateUtil; +import com.docus.core.util.json.JSON; +import com.docus.server.common.netty.CommMsg; +import com.docus.server.common.netty.server.ChannelRepository; +import com.docus.server.convert.CommMsgConvert; +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; +import com.docus.server.service.ICommMsgService; +import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; +import io.netty.util.CharsetUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.Map; +import java.util.Set; + +@Service +@Slf4j +public class CommMsgServiceImpl implements ICommMsgService { + + @Resource + private ChannelRepository channelRepository; + + @Override + public void clientCommand(CommMsgDTO commMsgDTO) { + Channel channel = channelRepository.get(commMsgDTO.getTerminatorIp()); + + CommMsg commMsg = CommMsgConvert.INSTANCE.convertDO(commMsgDTO); + commMsg.setMessageTime(DateUtil.formatDateTime(new Date())); + + if (channel != null) { + channel.writeAndFlush(Unpooled.copiedBuffer(JSON.toJSON(commMsg), CharsetUtil.UTF_8)); + } + } + + @Override + public void clientsCommand(CommMsgDTO commMsgDTO) { + + Map channelMap = channelRepository.getIpToChannelCacheMap(); + Set keySet = channelMap.keySet(); + + for (String clientIp : keySet) { + Channel channel = channelMap.get(clientIp); + + CommMsg commMsg = CommMsgConvert.INSTANCE.convertDO(commMsgDTO); + commMsg.setMessageTime(DateUtil.formatDateTime(new Date())); + + if (channel != null) { + channel.writeAndFlush(Unpooled.copiedBuffer(JSON.toJSON(commMsg), CharsetUtil.UTF_8)); + } + + } + } +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/FileUploadServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/FileUploadServiceImpl.java new file mode 100644 index 0000000..647a2bb --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/FileUploadServiceImpl.java @@ -0,0 +1,137 @@ +package com.docus.server.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.docus.core.util.Func; +import com.docus.infrastructure.web.exception.ApiException; +import com.docus.infrastructure.web.exception.ExceptionCode; +import com.docus.server.service.IFileUploadService; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +@Service +@Slf4j +public class FileUploadServiceImpl implements IFileUploadService { + + @Value("${file.uploadFolder:D://docus/}") + private String saveFilePath; + + private static final String COLLECTOR_PACKAGES = "collector_packages"; + + private static DateTimeFormatter ymdDtf = DateTimeFormatter.ofPattern("yyyyMMdd"); + + @Override + public List uploadFile(MultipartFile[] multipartFiles, String pathKey) throws Exception { + + if (Func.isBlank(pathKey)) { + pathKey = COLLECTOR_PACKAGES; + } + + List uploadFileVOList = new ArrayList<>(); + + for (MultipartFile multipartFile : multipartFiles) { + + valid(multipartFile); + + uploadFileVOList.add(actionUploadFile(multipartFile, pathKey)); + } + return uploadFileVOList; + + } + + private UploadFileVO actionUploadFile(MultipartFile multipartFile, String pathKey) throws Exception { + + String todayFormat = ymdDtf.format(LocalDateTime.now()); + + String path = pathKey + "/" + todayFormat + "/" + UUID.randomUUID().toString() + "/"; + File fileDir = new File(saveFilePath + path); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + String fileName = path + multipartFile.getOriginalFilename(); + + File dest = new File(saveFilePath + fileName); + + multipartFile.transferTo(dest); + + + UploadFileVO uploadFileVO = new UploadFileVO(); + uploadFileVO.setFileName(multipartFile.getOriginalFilename()); + uploadFileVO.setFileSize(multipartFile.getSize()); + uploadFileVO.setFileTitle(multipartFile.getName()); + uploadFileVO.setFileType(multipartFile.getContentType()); + uploadFileVO.setFilePath(fileName); + + return uploadFileVO; + } + + @Override + public void downloadFile(String path, HttpServletResponse response) { + + try { + //获取要下载的文件 + File file = new File(saveFilePath + "/" + path); + + //设置响应的内容类型为二进制流,即文件类型 + response.setContentType("application/octet-stream"); + + //设置文件名 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), "UTF-8")); + + //创建输入流 + FileInputStream inputStream = new FileInputStream(file); + BufferedInputStream buffInputStream = new BufferedInputStream(inputStream); + + //创建输出流 + ServletOutputStream outputStream = response.getOutputStream(); + BufferedOutputStream buffOutputStream = new BufferedOutputStream(outputStream); + + //循环读取数据并写入到响应输出流中 + byte[] buffer = new byte[1024]; + int len = -1; + while ((len = buffInputStream.read(buffer)) != -1) { + buffOutputStream.write(buffer, 0, len); + } + + //关闭流 + buffOutputStream.flush(); + buffOutputStream.close(); + outputStream.flush(); + outputStream.close(); + buffInputStream.close(); + inputStream.close(); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + } + + private void valid(MultipartFile multipartFile) { + if (multipartFile.isEmpty()) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "上传失败,请选择文件!"); + } + + String originalFilename = multipartFile.getOriginalFilename(); + if (StrUtil.isBlank(originalFilename)) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "未找到原文件文件名!"); + } + if (!originalFilename.contains(".")) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "原文件名未识别到后缀!"); + } + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/RedisKeyExpirationService.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/RedisKeyExpirationService.java new file mode 100644 index 0000000..51230cc --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/RedisKeyExpirationService.java @@ -0,0 +1,56 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.DateUtil; +import com.docus.log.annotation.TrackGroup; +import com.docus.server.common.process.ChannelProcessor; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.enums.StateEnum; +import com.docus.server.enums.SubStateEnum; +import com.docus.server.infrastructure.dao.ISchCollectRecordDao; +import com.docus.server.infrastructure.dao.ISchCollectRecordRetryLogDao; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class RedisKeyExpirationService { + @Resource + private ISchCollectRecordDao iSchCollectRecordDao; + @Resource + private ISchCollectRecordRetryLogDao iSchCollectRecordRetryLogDao; + + @TrackGroup(group = "RedisKeyExpirationService-expired", processor = ChannelProcessor.class) + public void expired(String expireKey) { + + if (expireKey.startsWith("schCollectorRecord:noRetryTask:expireKey:")) { + System.out.println("expireKey过期了===" + expireKey); + + String recordId = expireKey.substring(expireKey.lastIndexOf(":") + 1); + + SchCollectRecord collectRecord = iSchCollectRecordDao.findById(recordId); + collectRecord.setTaskExecState(StateEnum.FAIL); + //超时作废 + collectRecord.setSubTaskExecState(SubStateEnum.CANCEL); + collectRecord.setUpdateTime(DateUtil.now()); + collectRecord.setLastTaskErrorMsg("任务超时,触发任务作废"); + iSchCollectRecordDao.updateById(collectRecord); + + } + if (expireKey.startsWith("schCollectorRecord:isRetryTask:expireKey:")) { + System.out.println("expireKey过期了===" + expireKey); + + String logRecordId = expireKey.substring(expireKey.lastIndexOf(":") + 1); + + SchCollectRecordRetryLog recordRetryLog = iSchCollectRecordRetryLogDao.findById(logRecordId); + recordRetryLog.setTaskExecState(StateEnum.FAIL); + recordRetryLog.setSubTaskExecState(SubStateEnum.CANCEL); + recordRetryLog.setUpdateTime(DateUtil.now()); + recordRetryLog.setLastTaskErrorMsg("任务超时,触发任务作废"); + iSchCollectRecordRetryLogDao.updateById(recordRetryLog); + + } + + } + +} diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectErrorLogServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectErrorLogServiceImpl.java new file mode 100644 index 0000000..0c1c8a6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectErrorLogServiceImpl.java @@ -0,0 +1,103 @@ +package com.docus.server.service.impl; + +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectErrorLogConvert; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.AddSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.DeleteSchCollectErrorLogDTO; +import com.docus.server.dto.scheduling.management.schcollecterrorlog.EditSchCollectErrorLogDTO; +import com.docus.server.entity.scheduling.management.SchCollectErrorLog; +import com.docus.server.infrastructure.dao.ISchCollectErrorLogDao; +import com.docus.server.service.IFileUploadService; +import com.docus.server.service.ISchCollectErrorLogService; +import com.docus.server.vo.scheduling.management.schcollecterrorlog.SchCollectErrorLogVO; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 采集器异常日志 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectErrorLogServiceImpl implements ISchCollectErrorLogService { + @Resource + private ISchCollectErrorLogDao iSchCollectErrorLogDao; + @Resource + private IFileUploadService iFileUploadService; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectErrorLogVO findById(String id) { + return SchCollectErrorLogConvert.INSTANCE.convertVO(iSchCollectErrorLogDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchCollectErrorLogConvert.INSTANCE.convertVO(iSchCollectErrorLogDao.search(searchDTO)); + } + + /** + * 新增 + * + * @param addSchCollectErrorLogDTO 编辑参数 + * @param multipartFiles 采集器异常任务截图 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectErrorLogDTO addSchCollectErrorLogDTO, MultipartFile[] multipartFiles) throws Exception { + + List uploadFileVOList = iFileUploadService.uploadFile(multipartFiles, "COLLECTOR_TASK_ERROR_LOG"); + + SchCollectErrorLog schCollectErrorLog = SchCollectErrorLogConvert.INSTANCE.convertDO(addSchCollectErrorLogDTO); + if (!CollectionUtils.isEmpty(uploadFileVOList)) { + schCollectErrorLog.setScreenPath(uploadFileVOList.get(0).getFilePath()); + } + schCollectErrorLog.setId(idService.getDateSeq()); + return iSchCollectErrorLogDao.add(schCollectErrorLog); + } + + /** + * 编辑 + * + * @param editSchCollectErrorLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectErrorLogDTO editSchCollectErrorLogDTO) { + SchCollectErrorLog schCollectErrorLog = SchCollectErrorLogConvert.INSTANCE.convertDO(editSchCollectErrorLogDTO); + return iSchCollectErrorLogDao.edit(schCollectErrorLog); + } + + /** + * 批量删除 + * + * @param deleteSchCollectErrorLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectErrorLogDTO deleteSchCollectErrorLogDTO) { + return iSchCollectErrorLogDao.delete(deleteSchCollectErrorLogDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordRetryLogServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordRetryLogServiceImpl.java new file mode 100644 index 0000000..1d26223 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordRetryLogServiceImpl.java @@ -0,0 +1,141 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.DateUtil; +import com.docus.core.util.ListUtils; +import com.docus.core.util.json.JSON; +import com.docus.core.util.property.Setters; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectRecordRetryLogConvert; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.AddSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.DeleteSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schcollectrecordretrylog.EditSchCollectRecordRetryLogDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.enums.SubStateEnum; +import com.docus.server.infrastructure.dao.ISchCollectRecordRetryLogDao; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; +import com.docus.server.service.ISchCollectRecordRetryLogService; +import com.docus.server.vo.scheduling.management.schcollectrecordretrylog.SchCollectRecordRetryLogVO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 采集记录表重试表 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectRecordRetryLogServiceImpl implements ISchCollectRecordRetryLogService { + @Resource + private ISchCollectRecordRetryLogDao iSchCollectRecordRetryLogDao; + @Resource + private ISchSystemParamsDao iSchSystemParamsDao; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecordRetryLogVO findById(String id) { + return SchCollectRecordRetryLogConvert.INSTANCE.convertVO(iSchCollectRecordRetryLogDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + PageResult result = SchCollectRecordRetryLogConvert.INSTANCE.convertVO(iSchCollectRecordRetryLogDao.search(searchDTO)); + + if (CollectionUtils.isEmpty(result.getList())) { + return new PageResult<>(); + } + + List schSystemParams = iSchSystemParamsDao.findBy("paramValue", ListUtils.distinctSelect(result.getList(), SchCollectRecordRetryLogVO::getCollectorId)); + Map taskConfigRetryLogMap = ListUtils.toMap(schSystemParams, SchSystemParams::getParamValue); + + Setters.instance().list(result.getList()).cycleSetProperties(p -> { + String collectorId = String.valueOf(p.getCollectorId()); + if (taskConfigRetryLogMap.containsKey(collectorId)) { + p.setCollectorName(taskConfigRetryLogMap.get(collectorId).getParamName()); + } + }); + + return result; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SchCollectRecordRetryLog saveOrUpdateRecordRetryLog(NettyTerminatorDTO terminal, ReportDownTwoDTO messageContent) { + //新增采集记录表 + AddSchCollectRecordRetryLogDTO retryLogDTO = new AddSchCollectRecordRetryLogDTO(); + retryLogDTO.setId(idService.getDateSeq()); + retryLogDTO.setCollectRecordId(Long.valueOf(String.valueOf(messageContent.getParams().get("collectRecordId")))); + retryLogDTO.setCollectorId(Long.valueOf(messageContent.getTasks().get(0).getCollectorId())); + retryLogDTO.setTerminatorId(terminal.getId()); + retryLogDTO.setTaskId(messageContent.getTasks().get(0).getTaskId()); + SchSystemParams params = iSchSystemParamsDao.findOneBy("paramValue", messageContent.getTasks().get(0).getCollectorId()); + retryLogDTO.setTaskName(String.format("%s%s%s", messageContent.getPatient().getName(), params.getParamName(), "采集")); + retryLogDTO.setTaskMemo(String.format("%s%s%s", messageContent.getPatient().getName(), params.getParamName(), "采集")); + retryLogDTO.setStartTime(DateUtil.now()); + retryLogDTO.setTaskDetailInfo(String.format("病案号:%s,姓名:%s,采集类型:%s", messageContent.getPatientId(), messageContent.getPatient().getName(), params.getParamName())); + retryLogDTO.setSubTaskExecState(SubStateEnum.RECEIVE); + retryLogDTO.setTaskOriginJson(JSON.toJSON(messageContent)); + + return this.add(retryLogDTO); + } + + /** + * 新增 + * + * @param addSchCollectRecordRetryLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public SchCollectRecordRetryLog add(AddSchCollectRecordRetryLogDTO addSchCollectRecordRetryLogDTO) { + SchCollectRecordRetryLog schCollectRecordRetryLog = SchCollectRecordRetryLogConvert.INSTANCE.convertDO(addSchCollectRecordRetryLogDTO); + iSchCollectRecordRetryLogDao.add(schCollectRecordRetryLog); + return schCollectRecordRetryLog; + } + + /** + * 编辑 + * + * @param editSchCollectRecordRetryLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectRecordRetryLogDTO editSchCollectRecordRetryLogDTO) { + SchCollectRecordRetryLog schCollectRecordRetryLog = SchCollectRecordRetryLogConvert.INSTANCE.convertDO(editSchCollectRecordRetryLogDTO); + return iSchCollectRecordRetryLogDao.edit(schCollectRecordRetryLog); + } + + /** + * 批量删除 + * + * @param deleteSchCollectRecordRetryLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectRecordRetryLogDTO deleteSchCollectRecordRetryLogDTO) { + return iSchCollectRecordRetryLogDao.delete(deleteSchCollectRecordRetryLogDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordServiceImpl.java new file mode 100644 index 0000000..152f416 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectRecordServiceImpl.java @@ -0,0 +1,173 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.DateUtil; +import com.docus.core.util.ListUtils; +import com.docus.core.util.json.JSON; +import com.docus.core.util.property.Setters; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.exception.ApiException; +import com.docus.infrastructure.web.exception.ExceptionCode; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectRecordConvert; +import com.docus.server.convert.SchCollectRecordRetryLogConvert; +import com.docus.server.dto.scheduling.management.schcollector.task.ReportDownTwoDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.AddSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.DeleteSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schcollectrecord.EditSchCollectRecordDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchCollectRecord; +import com.docus.server.entity.scheduling.management.SchCollectRecordRetryLog; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.enums.RetryTaskEnum; +import com.docus.server.enums.SubStateEnum; +import com.docus.server.infrastructure.dao.ISchCollectRecordDao; +import com.docus.server.infrastructure.dao.ISchCollectRecordRetryLogDao; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; +import com.docus.server.infrastructure.dao.ISchTerminatorDao; +import com.docus.server.service.ISchCollectRecordService; +import com.docus.server.vo.scheduling.management.schcollectrecord.SchCollectRecordVO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 采集记录表 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectRecordServiceImpl implements ISchCollectRecordService { + @Resource + private ISchCollectRecordDao iSchCollectRecordDao; + @Resource + private ISchTerminatorDao iSchTerminatorDao; + @Resource + private ISchCollectRecordRetryLogDao iSchCollectRecordRetryLogDao; + @Resource + private ISchSystemParamsDao iSchSystemParamsDao; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectRecordVO findById(String id) { + return SchCollectRecordConvert.INSTANCE.convertVO(iSchCollectRecordDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + PageResult result = SchCollectRecordConvert.INSTANCE.convertVO(iSchCollectRecordDao.search(searchDTO)); + + if (CollectionUtils.isEmpty(result.getList())) { + return new PageResult<>(); + } + + List schSystemParams = iSchSystemParamsDao.findBy("paramValue", ListUtils.distinctSelect(result.getList(), SchCollectRecordVO::getCollectorId)); + Map taskConfigRetryLogMap = ListUtils.toMap(schSystemParams, SchSystemParams::getParamValue); + + Setters.instance().list(result.getList()).cycleSetProperties(p -> { + String collectorId = String.valueOf(p.getCollectorId()); + if (taskConfigRetryLogMap.containsKey(collectorId)) { + p.setCollectorName(taskConfigRetryLogMap.get(collectorId).getParamName()); + } + }); + + return result; + } + + @Transactional(rollbackFor = Exception.class) + @Override + public SchCollectRecord saveOrUpdateRecord(NettyTerminatorDTO terminal, ReportDownTwoDTO messageContent) { + //新增采集记录表 + AddSchCollectRecordDTO addSchCollectRecordDTO = new AddSchCollectRecordDTO(); + addSchCollectRecordDTO.setId(idService.getDateSeq()); + addSchCollectRecordDTO.setCollectorId(Long.valueOf(messageContent.getTasks().get(0).getCollectorId())); + addSchCollectRecordDTO.setTerminatorId(terminal.getId()); + addSchCollectRecordDTO.setTaskId(messageContent.getTasks().get(0).getTaskId()); + SchSystemParams params = iSchSystemParamsDao.findOneBy("paramValue", messageContent.getTasks().get(0).getCollectorId()); + addSchCollectRecordDTO.setTaskName(String.format("%s%s%s", messageContent.getPatient().getName(), params.getParamName(), "采集")); + addSchCollectRecordDTO.setTaskMemo(String.format("%s%s%s", messageContent.getPatient().getName(), params.getParamName(), "采集")); + addSchCollectRecordDTO.setStartTime(DateUtil.now()); + addSchCollectRecordDTO.setTaskDetailInfo(String.format("病案号:%s,姓名:%s,采集类型:%s", messageContent.getPatientId(), messageContent.getPatient().getName(), params.getParamName())); + addSchCollectRecordDTO.setSubTaskExecState(SubStateEnum.RECEIVE); + addSchCollectRecordDTO.setTaskOriginJson(JSON.toJSON(messageContent)); + + return this.add(addSchCollectRecordDTO); + } + + /** + * 新增 + * + * @param addSchCollectRecordDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public SchCollectRecord add(AddSchCollectRecordDTO addSchCollectRecordDTO) { + SchCollectRecord schCollectRecord = SchCollectRecordConvert.INSTANCE.convertDO(addSchCollectRecordDTO); + iSchCollectRecordDao.add(schCollectRecord); + return schCollectRecord; + } + + /** + * 编辑 + * + * @param editSchCollectRecordDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectRecordDTO editSchCollectRecordDTO) { + RetryTaskEnum isRetryTask = editSchCollectRecordDTO.getIsRetryTask(); + Long id = editSchCollectRecordDTO.getId(); + + if (RetryTaskEnum.NO_RETRY_TASK.equals(isRetryTask)) { + //不是重试任务 + SchCollectRecord schCollectRecord = iSchCollectRecordDao.findById(id); + + if (null == schCollectRecord) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "不重复任务采集记录不存在!" + id); + } + + schCollectRecord = SchCollectRecordConvert.INSTANCE.convertDO(editSchCollectRecordDTO, schCollectRecord); + + return iSchCollectRecordDao.updateById(schCollectRecord); + } else { + //重试任务 + SchCollectRecordRetryLog schCollectRecordRetryLog = iSchCollectRecordRetryLogDao.findById(id); + + if (null == schCollectRecordRetryLog) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "不重复任务采集记录不存在!" + id); + } + schCollectRecordRetryLog = SchCollectRecordRetryLogConvert.INSTANCE.convertDO(editSchCollectRecordDTO, schCollectRecordRetryLog); + return iSchCollectRecordRetryLogDao.updateById(schCollectRecordRetryLog); + } + } + + /** + * 批量删除 + * + * @param deleteSchCollectRecordDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectRecordDTO deleteSchCollectRecordDTO) { + return iSchCollectRecordDao.delete(deleteSchCollectRecordDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorConfigServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorConfigServiceImpl.java new file mode 100644 index 0000000..6c4adcc --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorConfigServiceImpl.java @@ -0,0 +1,167 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.Func; +import com.docus.core.util.ListUtils; +import com.docus.core.util.json.JSON; +import com.docus.core.util.property.Setters; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.exception.ApiException; +import com.docus.infrastructure.web.exception.ExceptionCode; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.common.MsgConstants; +import com.docus.server.convert.SchCollectorConfigConvert; +import com.docus.server.dto.scheduling.management.schcollectorconfig.AddSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.DeleteSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schcollectorconfig.EditSchCollectorConfigDTO; +import com.docus.server.dto.scheduling.management.schterminator.CommMsgDTO; +import com.docus.server.entity.scheduling.management.SchCollectorConfig; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.enums.ConfigTypeEnum; +import com.docus.server.infrastructure.dao.ISchCollectorConfigDao; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; +import com.docus.server.service.ICommMsgService; +import com.docus.server.service.ISchCollectorConfigService; +import com.docus.server.vo.scheduling.management.schcollectorconfig.SchCollectorConfigVO; +import com.docus.server.vo.scheduling.management.schcollectorconfig.TcpSchCollectorConfigContentVO; +import com.docus.server.vo.scheduling.management.schcollectorconfig.TcpSchCollectorConfigVO; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 采集器配置 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectorConfigServiceImpl implements ISchCollectorConfigService { + @Resource + private ISchCollectorConfigDao iSchCollectorConfigDao; + @Resource + private ISchSystemParamsDao iSchSystemParamsDao; + @Resource + private IdService idService; + @Resource + private ICommMsgService iCommMsgService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorConfigVO findById(String id) { + return SchCollectorConfigConvert.INSTANCE.convertVO(iSchCollectorConfigDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + + PageResult result = SchCollectorConfigConvert.INSTANCE.convertVO(iSchCollectorConfigDao.search(searchDTO)); + if (CollectionUtils.isEmpty(result.getList())) { + return new PageResult<>(); + } + + List schSystemParams = iSchSystemParamsDao.findBy("paramValue", ListUtils.distinctSelect(result.getList(), SchCollectorConfigVO::getCollectorId)); + Map taskConfigRetryLogMap = ListUtils.toMap(schSystemParams, SchSystemParams::getParamValue); + + Setters.instance().list(result.getList()).cycleSetProperties(p -> { + String collectorId = String.valueOf(p.getCollectorId()); + if (taskConfigRetryLogMap.containsKey(collectorId)) { + p.setCollectorName(taskConfigRetryLogMap.get(collectorId).getParamName()); + } else { + p.setCollectorName("公共"); + } + }); + + return result; + } + + /** + * 新增 + * + * @param addSchCollectorConfigDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorConfigDTO addSchCollectorConfigDTO) { + + Long collectorId = addSchCollectorConfigDTO.getCollectorId(); + + SchCollectorConfig schCollectorConfigDO = iSchCollectorConfigDao.findOneBy("collectorId", collectorId); + + if (Func.notNull(schCollectorConfigDO)) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "采集器类型已经存在"); + } + + SchCollectorConfig schCollectorConfig = SchCollectorConfigConvert.INSTANCE.convertDO(addSchCollectorConfigDTO); + schCollectorConfig.setId(idService.getDateSeq()); + if (addSchCollectorConfigDTO.getConfigType().equals(ConfigTypeEnum.PUBLIC_CONFIG)) { + schCollectorConfig.setCollectorId(0L); //共有类型 + } + + return iSchCollectorConfigDao.add(schCollectorConfig); + + } + + /** + * 编辑 + * + * @param editSchCollectorConfigDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorConfigDTO editSchCollectorConfigDTO) { + SchCollectorConfig schCollectorConfig = iSchCollectorConfigDao.findById(editSchCollectorConfigDTO.getId()); + schCollectorConfig.setConfigJson(editSchCollectorConfigDTO.getConfigJson()); + return iSchCollectorConfigDao.edit(schCollectorConfig); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorConfigDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorConfigDTO deleteSchCollectorConfigDTO) { + return iSchCollectorConfigDao.delete(deleteSchCollectorConfigDTO.getIds()); + } + + /** + * 更新采集器配置文件 + */ + @Override + public void updateCollectorConfig() { + List publicConfig = iSchCollectorConfigDao.findBy("configType", ConfigTypeEnum.PUBLIC_CONFIG); + List privateConfig = iSchCollectorConfigDao.findBy("configType", ConfigTypeEnum.PRIVATE_CONFIG); + + List publicConfigVO = SchCollectorConfigConvert.INSTANCE.convertTcpVOList(publicConfig); + List privateConfigVO = SchCollectorConfigConvert.INSTANCE.convertTcpVOList(privateConfig); + + TcpSchCollectorConfigContentVO tcpSchCollectorConfigVO = TcpSchCollectorConfigContentVO.builder() + .publicConfigList(publicConfigVO) + .privateConfigList(privateConfigVO) + .build(); + + CommMsgDTO commMsgDTO = CommMsgDTO.builder() + .content(JSON.toJSON(tcpSchCollectorConfigVO)) + .messageType(MsgConstants.UPDATE_COLLECTOR_CONFIG) + .build(); + + iCommMsgService.clientsCommand(commMsgDTO); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorServiceImpl.java new file mode 100644 index 0000000..185a7d6 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorServiceImpl.java @@ -0,0 +1,160 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.Func; +import com.docus.core.util.ListUtils; +import com.docus.core.util.property.Setters; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.exception.ApiException; +import com.docus.infrastructure.web.exception.ExceptionCode; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.log.annotation.TrackGroup; +import com.docus.server.common.process.TcpProcessor; +import com.docus.server.convert.SchCollectorConvert; +import com.docus.server.dto.scheduling.management.schcollector.AddSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.DeleteSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.EditSchCollectorDTO; +import com.docus.server.dto.scheduling.management.schcollector.UpdateSchCollectorDTO; +import com.docus.server.entity.scheduling.management.SchCollector; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.infrastructure.dao.ISchCollectorDao; +import com.docus.server.service.ISchCollectorService; +import com.docus.server.service.ISchSystemParamsService; +import com.docus.server.vo.scheduling.management.schcollector.SchCollectorVO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.Map; + +/** + * 采集器管理 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectorServiceImpl implements ISchCollectorService { + @Resource + private ISchCollectorDao iSchCollectorDao; + @Resource + private ISchSystemParamsService iSchSystemParamsService; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVO findById(String id) { + return SchCollectorConvert.INSTANCE.convertVO(iSchCollectorDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + PageResult result = SchCollectorConvert.INSTANCE.convertVO(iSchCollectorDao.search(searchDTO)); + + if (CollectionUtils.isEmpty(result.getList())) { + return new PageResult<>(); + } + + Map map = iSchSystemParamsService.find(ListUtils.distinctSelect(result.getList(), SchCollectorVO::getCollectorId)); + + Setters.instance().list(result.getList()).cycleSetProperties(p -> { + String collectorId = String.valueOf(p.getCollectorId()); + if (map.containsKey(collectorId)) { + p.setCollectorName(map.get(collectorId).getParamName()); + } + }); + + return result; + } + + /** + * 选为当前版本并更新 + * + * @return 成功或失败 + */ + @TrackGroup(group = "SchCollectorServiceImpl", processor = TcpProcessor.class) + @Transactional(rollbackFor = Exception.class) + @Override + public boolean updateVersion(UpdateSchCollectorDTO updateDTO) { + SchCollector schCollector = iSchCollectorDao.findOneBy("collectorId", updateDTO.getCollectorId()); + schCollector.setCollectorVersionId(updateDTO.getCollectorVersionId()); + return iSchCollectorDao.updateById(schCollector); + } + + @Override + public SchCollector findByCollectorId(String collectorId) { + return iSchCollectorDao.findOneBy("collectorId", collectorId); + } + + /** + * 新增 + * + * @param addSchCollectorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorDTO addSchCollectorDTO) { + + Long collectorId = addSchCollectorDTO.getCollectorId(); + + SchCollector schCollectorDO = iSchCollectorDao.findOneBy("collectorId", collectorId); + + if (Func.notNull(schCollectorDO)) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "采集器类型已经存在"); + } + + SchCollector schCollector = SchCollectorConvert.INSTANCE.convertDO(addSchCollectorDTO); + schCollector.setId(idService.getDateSeq()); + return iSchCollectorDao.add(schCollector); + } + + /** + * 编辑 + * + * @param editSchCollectorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorDTO editSchCollectorDTO) { + + Long id = editSchCollectorDTO.getId(); + + SchCollector schCollector = iSchCollectorDao.findById(id); + + if (Func.isNull(schCollector)) { + throw new ApiException(ExceptionCode.ParamIllegal.getCode(), "采集器不存在,无法更新"); + } + + schCollector.setCollectLanguage(editSchCollectorDTO.getCollectLanguage()); + schCollector.setStartMode(editSchCollectorDTO.getStartMode()); + schCollector.setTaskTimeout(editSchCollectorDTO.getTaskTimeout()); + schCollector.setUpdateTime(new Date()); + return iSchCollectorDao.edit(schCollector); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorDTO deleteSchCollectorDTO) { + return iSchCollectorDao.delete(deleteSchCollectorDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionFileServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionFileServiceImpl.java new file mode 100644 index 0000000..c6599fd --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionFileServiceImpl.java @@ -0,0 +1,136 @@ +package com.docus.server.service.impl; + +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectorVersionFileConvert; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.AddSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.DeleteSchCollectorVersionFileDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionfile.EditSchCollectorVersionFileDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.entity.scheduling.management.SchCollectorVersionFile; +import com.docus.server.enums.CancelEnum; +import com.docus.server.infrastructure.dao.ISchCollectorVersionDao; +import com.docus.server.infrastructure.dao.ISchCollectorVersionFileDao; +import com.docus.server.service.IFileUploadService; +import com.docus.server.service.ISchCollectorVersionFileService; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.SchCollectorVersionFileVO; +import com.docus.server.vo.scheduling.management.schcollectorversionfile.UploadFileVO; +import com.google.common.collect.Lists; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 采集器版本列表更新包管理 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectorVersionFileServiceImpl implements ISchCollectorVersionFileService { + @Resource + private ISchCollectorVersionFileDao iSchCollectorVersionFileDao; + @Resource + private ISchCollectorVersionDao iSchCollectorVersionDao; + @Resource + private IdService idService; + @Resource + private IFileUploadService iFileUploadService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionFileVO findById(String id) { + return SchCollectorVersionFileConvert.INSTANCE.convertVO(iSchCollectorVersionFileDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchCollectorVersionFileConvert.INSTANCE.convertVO(iSchCollectorVersionFileDao.search(searchDTO)); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public void addVersionAndFile(AddSchCollectorVersionFileDTO addDTO, MultipartFile[] multipartFiles) throws Exception { + List uploadFileVOList = iFileUploadService.uploadFile(multipartFiles, null); + + SchCollectorVersion schCollectorVersion = new SchCollectorVersion(); + schCollectorVersion.setId(idService.getDateSeq()); + schCollectorVersion.setCollectorId(addDTO.getCollectorId()); + schCollectorVersion.setCollectVersion(addDTO.getCollectorVersionNo()); + iSchCollectorVersionDao.save(schCollectorVersion); + + List schCollectorVersionFiles = Lists.newArrayList(); + + uploadFileVOList.forEach(p -> { + SchCollectorVersionFile schCollectorVersionFile = new SchCollectorVersionFile(); + schCollectorVersionFile.setId(idService.getDateSeq()); + schCollectorVersionFile.setCollectorId(addDTO.getCollectorId()); + schCollectorVersionFile.setCollectorVersionId(schCollectorVersion.getId()); + schCollectorVersionFile.setFileTitle(p.getFileTitle()); + schCollectorVersionFile.setFilePath(p.getFilePath()); + schCollectorVersionFile.setFileName(p.getFileName()); + schCollectorVersionFile.setFileSize(p.getFileSize()); + schCollectorVersionFile.setFileType(p.getFileType()); + schCollectorVersionFile.setState(CancelEnum.NO_CANCEL); + schCollectorVersionFiles.add(schCollectorVersionFile); + }); + + iSchCollectorVersionFileDao.saveBatch(schCollectorVersionFiles, 500); + } + + @Override + public SchCollectorVersionFile findByCollectorIdAndVersionId(Long collectorId, Long collectorVersionId) { + return iSchCollectorVersionFileDao.findByVersionIdAndCollectorId(collectorId, collectorVersionId); + } + + /** + * 新增 + * + * @param addSchCollectorVersionFileDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionFileDTO addSchCollectorVersionFileDTO) { + SchCollectorVersionFile schCollectorVersionFile = SchCollectorVersionFileConvert.INSTANCE.convertDO(addSchCollectorVersionFileDTO); + return iSchCollectorVersionFileDao.add(schCollectorVersionFile); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionFileDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionFileDTO editSchCollectorVersionFileDTO) { + SchCollectorVersionFile schCollectorVersionFile = SchCollectorVersionFileConvert.INSTANCE.convertDO(editSchCollectorVersionFileDTO); + return iSchCollectorVersionFileDao.edit(schCollectorVersionFile); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionFileDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionFileDTO deleteSchCollectorVersionFileDTO) { + return iSchCollectorVersionFileDao.delete(deleteSchCollectorVersionFileDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionLogServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionLogServiceImpl.java new file mode 100644 index 0000000..5347328 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionLogServiceImpl.java @@ -0,0 +1,85 @@ +package com.docus.server.service.impl; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectorVersionLogConvert; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.AddSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.DeleteSchCollectorVersionLogDTO; +import com.docus.server.dto.scheduling.management.schcollectorversionlog.EditSchCollectorVersionLogDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersionLog; +import com.docus.server.infrastructure.dao.ISchCollectorVersionLogDao; +import com.docus.server.service.ISchCollectorVersionLogService; +import com.docus.server.vo.scheduling.management.schcollectorversionlog.SchCollectorVersionLogVO; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 采集器版本更新日志管理 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectorVersionLogServiceImpl implements ISchCollectorVersionLogService { + @Resource + private ISchCollectorVersionLogDao iSchCollectorVersionLogDao; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionLogVO findById(String id) { + return SchCollectorVersionLogConvert.INSTANCE.convertVO(iSchCollectorVersionLogDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchCollectorVersionLogConvert.INSTANCE.convertVO(iSchCollectorVersionLogDao.search(searchDTO)); + } + + /** + * 新增 + * + * @param addSchCollectorVersionLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionLogDTO addSchCollectorVersionLogDTO) { + SchCollectorVersionLog schCollectorVersionLog = SchCollectorVersionLogConvert.INSTANCE.convertDO(addSchCollectorVersionLogDTO); + return iSchCollectorVersionLogDao.add(schCollectorVersionLog); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionLogDTO editSchCollectorVersionLogDTO) { + SchCollectorVersionLog schCollectorVersionLog = SchCollectorVersionLogConvert.INSTANCE.convertDO(editSchCollectorVersionLogDTO); + return iSchCollectorVersionLogDao.edit(schCollectorVersionLog); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionLogDTO deleteSchCollectorVersionLogDTO) { + return iSchCollectorVersionLogDao.delete(deleteSchCollectorVersionLogDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionServiceImpl.java new file mode 100644 index 0000000..79b9d1e --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchCollectorVersionServiceImpl.java @@ -0,0 +1,118 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.ListUtils; +import com.docus.core.util.property.Setters; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchCollectorVersionConvert; +import com.docus.server.dto.scheduling.management.schcollectorversion.AddSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.DeleteSchCollectorVersionDTO; +import com.docus.server.dto.scheduling.management.schcollectorversion.EditSchCollectorVersionDTO; +import com.docus.server.entity.scheduling.management.SchCollectorVersion; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.infrastructure.dao.ISchCollectorVersionDao; +import com.docus.server.service.ISchCollectorVersionService; +import com.docus.server.service.ISchSystemParamsService; +import com.docus.server.vo.scheduling.management.schcollectorversion.SchCollectorVersionVO; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import javax.annotation.Resource; +import java.util.Map; + +/** + * 采集器版本列表管理 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchCollectorVersionServiceImpl implements ISchCollectorVersionService { + @Resource + private ISchCollectorVersionDao iSchCollectorVersionDao; + @Resource + private ISchSystemParamsService iSchSystemParamsService; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchCollectorVersionVO findById(String id) { + return SchCollectorVersionConvert.INSTANCE.convertVO(iSchCollectorVersionDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + + PageResult result = SchCollectorVersionConvert.INSTANCE.convertVO(iSchCollectorVersionDao.search(searchDTO)); + + if (CollectionUtils.isEmpty(result.getList())) { + return new PageResult<>(); + } + + Map map = iSchSystemParamsService.find(ListUtils.distinctSelect(result.getList(), SchCollectorVersionVO::getCollectorId)); + + Setters.instance().list(result.getList()).cycleSetProperties(p -> { + String collectorId = String.valueOf(p.getCollectorId()); + if (map.containsKey(collectorId)) { + p.setCollectorName(map.get(collectorId).getParamName()); + } + }); + + return result; + } + + @Override + public SchCollectorVersion findByVersion(Long collectorId, String collectorVersionNo) { + return iSchCollectorVersionDao.findByVersion(collectorId, collectorVersionNo); + } + + /** + * 新增 + * + * @param addSchCollectorVersionDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchCollectorVersionDTO addSchCollectorVersionDTO) { + SchCollectorVersion schCollectorVersion = SchCollectorVersionConvert.INSTANCE.convertDO(addSchCollectorVersionDTO); + schCollectorVersion.setId(idService.getDateSeq()); + return iSchCollectorVersionDao.add(schCollectorVersion); + } + + /** + * 编辑 + * + * @param editSchCollectorVersionDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchCollectorVersionDTO editSchCollectorVersionDTO) { + SchCollectorVersion schCollectorVersion = SchCollectorVersionConvert.INSTANCE.convertDO(editSchCollectorVersionDTO); + return iSchCollectorVersionDao.edit(schCollectorVersion); + } + + /** + * 批量删除 + * + * @param deleteSchCollectorVersionDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchCollectorVersionDTO deleteSchCollectorVersionDTO) { + return iSchCollectorVersionDao.delete(deleteSchCollectorVersionDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchOperationLogServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchOperationLogServiceImpl.java new file mode 100644 index 0000000..8c7248a --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchOperationLogServiceImpl.java @@ -0,0 +1,85 @@ +package com.docus.server.service.impl; + +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchOperationLogConvert; +import com.docus.server.dto.scheduling.management.schoperationlog.AddSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.DeleteSchOperationLogDTO; +import com.docus.server.dto.scheduling.management.schoperationlog.EditSchOperationLogDTO; +import com.docus.server.entity.scheduling.management.SchOperationLog; +import com.docus.server.infrastructure.dao.ISchOperationLogDao; +import com.docus.server.service.ISchOperationLogService; +import com.docus.server.vo.scheduling.management.schoperationlog.SchOperationLogVO; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 采集调度器操作日志 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchOperationLogServiceImpl implements ISchOperationLogService { + @Resource + private ISchOperationLogDao iSchOperationLogDao; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchOperationLogVO findById(String id) { + return SchOperationLogConvert.INSTANCE.convertVO(iSchOperationLogDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchOperationLogConvert.INSTANCE.convertVO(iSchOperationLogDao.search(searchDTO)); + } + + /** + * 新增 + * + * @param addSchOperationLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchOperationLogDTO addSchOperationLogDTO) { + SchOperationLog schOperationLog = SchOperationLogConvert.INSTANCE.convertDO(addSchOperationLogDTO); + return iSchOperationLogDao.add(schOperationLog); + } + + /** + * 编辑 + * + * @param editSchOperationLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchOperationLogDTO editSchOperationLogDTO) { + SchOperationLog schOperationLog = SchOperationLogConvert.INSTANCE.convertDO(editSchOperationLogDTO); + return iSchOperationLogDao.edit(schOperationLog); + } + + /** + * 批量删除 + * + * @param deleteSchOperationLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchOperationLogDTO deleteSchOperationLogDTO) { + return iSchOperationLogDao.delete(deleteSchOperationLogDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchSystemParamsServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchSystemParamsServiceImpl.java new file mode 100644 index 0000000..837f456 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchSystemParamsServiceImpl.java @@ -0,0 +1,95 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.ListUtils; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchSystemParamsConvert; +import com.docus.server.dto.scheduling.management.schsystemparams.AddSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.DeleteSchSystemParamsDTO; +import com.docus.server.dto.scheduling.management.schsystemparams.EditSchSystemParamsDTO; +import com.docus.server.entity.scheduling.management.SchSystemParams; +import com.docus.server.infrastructure.dao.ISchSystemParamsDao; +import com.docus.server.service.ISchSystemParamsService; +import com.docus.server.vo.scheduling.management.schsystemparams.SchSystemParamsVO; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +/** + * 系统参数表 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchSystemParamsServiceImpl implements ISchSystemParamsService { + @Resource + private ISchSystemParamsDao iSchSystemParamsDao; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchSystemParamsVO findById(String id) { + return SchSystemParamsConvert.INSTANCE.convertVO(iSchSystemParamsDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchSystemParamsConvert.INSTANCE.convertVO(iSchSystemParamsDao.search(searchDTO)); + } + + /** + * 新增 + * + * @param addSchSystemParamsDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchSystemParamsDTO addSchSystemParamsDTO) { + SchSystemParams schSystemParams = SchSystemParamsConvert.INSTANCE.convertDO(addSchSystemParamsDTO); + return iSchSystemParamsDao.add(schSystemParams); + } + + /** + * 编辑 + * + * @param editSchSystemParamsDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchSystemParamsDTO editSchSystemParamsDTO) { + SchSystemParams schSystemParams = SchSystemParamsConvert.INSTANCE.convertDO(editSchSystemParamsDTO); + return iSchSystemParamsDao.edit(schSystemParams); + } + + /** + * 批量删除 + * + * @param deleteSchSystemParamsDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchSystemParamsDTO deleteSchSystemParamsDTO) { + return iSchSystemParamsDao.delete(deleteSchSystemParamsDTO.getIds()); + } + + @Override + public Map find(List paramValueIds) { + List schSystemParams = iSchSystemParamsDao.findBy("paramValue", paramValueIds); + return ListUtils.toMap(schSystemParams, SchSystemParams::getParamValue); + } + +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchTerminatorServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchTerminatorServiceImpl.java new file mode 100644 index 0000000..4421e83 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchTerminatorServiceImpl.java @@ -0,0 +1,136 @@ +package com.docus.server.service.impl; + +import com.docus.core.util.Func; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchTerminatorConvert; +import com.docus.server.dto.scheduling.management.schterminator.AddSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.DeleteSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.EditSchTerminatorDTO; +import com.docus.server.dto.scheduling.management.schterminator.NettyTerminatorDTO; +import com.docus.server.entity.scheduling.management.SchTerminator; +import com.docus.server.enums.BusyStateEnum; +import com.docus.server.infrastructure.dao.ISchTerminatorDao; +import com.docus.server.service.ISchTerminatorService; +import com.docus.server.vo.scheduling.management.schterminator.SchTerminatorVO; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * 执行管理器 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchTerminatorServiceImpl implements ISchTerminatorService { + @Resource + private ISchTerminatorDao iSchTerminatorDao; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchTerminatorVO findById(String id) { + return SchTerminatorConvert.INSTANCE.convertVO(iSchTerminatorDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchTerminatorConvert.INSTANCE.convertVO(iSchTerminatorDao.search(searchDTO)); + } + + @Override + public SchTerminatorVO saveOrUpdate(String terminatorIp, NettyTerminatorDTO nettyTerminatorDTO) { + + SchTerminator schTerminator = iSchTerminatorDao.findOneBy("terminatorIp", terminatorIp); + + //新增 + if (Func.isNull(schTerminator)) { + SchTerminator schTerminatorDO = new SchTerminator(); + + schTerminatorDO.setId(idService.getDateSeq()); + schTerminatorDO.setTerminatorIp(terminatorIp); + schTerminatorDO.setTerminatorName(terminatorIp); + schTerminatorDO.setOnlineState(nettyTerminatorDTO.getOnlineState()); + schTerminatorDO.setBusyState(BusyStateEnum.IDLE); + + iSchTerminatorDao.save(schTerminatorDO); + + return SchTerminatorConvert.INSTANCE.convertVO(schTerminatorDO); + } else { + //更新 + schTerminator.setBusyState(nettyTerminatorDTO.getBusyState()); + schTerminator.setOnlineState(nettyTerminatorDTO.getOnlineState()); + schTerminator.setUpdateTime(new Date()); + + iSchTerminatorDao.updateById(schTerminator); + + return SchTerminatorConvert.INSTANCE.convertVO(schTerminator); + } + + } + + @Override + public List findAll() { + return iSchTerminatorDao.findAll(); + } + + @Override + public void batchUpdate(List terminators) { + iSchTerminatorDao.updateBatchById(terminators, 20); + } + + /** + * 新增 + * + * @param addSchTerminatorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchTerminatorDTO addSchTerminatorDTO) { + SchTerminator schTerminator = SchTerminatorConvert.INSTANCE.convertDO(addSchTerminatorDTO); + return iSchTerminatorDao.add(schTerminator); + } + + /** + * 编辑 + * + * @param editSchTerminatorDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchTerminatorDTO editSchTerminatorDTO) { + Long id = editSchTerminatorDTO.getId(); + SchTerminator schTerminatorDO = iSchTerminatorDao.findById(id); + SchTerminator schTerminator = SchTerminatorConvert.INSTANCE.convertDO(editSchTerminatorDTO, schTerminatorDO); + return iSchTerminatorDao.edit(schTerminator); + } + + /** + * 批量删除 + * + * @param deleteSchTerminatorDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchTerminatorDTO deleteSchTerminatorDTO) { + return iSchTerminatorDao.delete(deleteSchTerminatorDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchVirtualLogServiceImpl.java b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchVirtualLogServiceImpl.java new file mode 100644 index 0000000..92ceaa5 --- /dev/null +++ b/collector-terminal-management/src/main/java/com/docus/server/service/impl/SchVirtualLogServiceImpl.java @@ -0,0 +1,89 @@ +package com.docus.server.service.impl; + +import com.docus.infrastructure.redis.service.IdService; +import com.docus.infrastructure.web.request.SearchDTO; +import com.docus.infrastructure.web.response.PageResult; +import com.docus.server.convert.SchVirtualLogConvert; +import com.docus.server.dto.scheduling.management.schvirtuallog.AddSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.DeleteSchVirtualLogDTO; +import com.docus.server.dto.scheduling.management.schvirtuallog.EditSchVirtualLogDTO; +import com.docus.server.entity.scheduling.management.SchVirtualLog; +import com.docus.server.infrastructure.dao.ISchVirtualLogDao; +import com.docus.server.service.ISchVirtualLogService; +import com.docus.server.vo.scheduling.management.schvirtuallog.SchVirtualLogVO; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +/** + * 虚拟机使用情况 服务实现类 + * + * @author AutoGenerator + * @since 2023-07-15 + */ +@Service +public class SchVirtualLogServiceImpl implements ISchVirtualLogService { + @Resource + private ISchVirtualLogDao iSchVirtualLogDao; + @Resource + private IdService idService; + + /** + * 按主键查询 + * + * @param id 主键Id + * @return 实体 + */ + @Override + public SchVirtualLogVO findById(String id) { + return SchVirtualLogConvert.INSTANCE.convertVO(iSchVirtualLogDao.findById(id)); + } + + /** + * 关键字搜索 + * + * @param searchDTO 搜索参数 + * @return 分页列表 + */ + @Override + public PageResult search(SearchDTO searchDTO) { + return SchVirtualLogConvert.INSTANCE.convertVO(iSchVirtualLogDao.search(searchDTO)); + } + + /** + * 新增 + * + * @param addSchVirtualLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean add(AddSchVirtualLogDTO addSchVirtualLogDTO) { + SchVirtualLog schVirtualLog = SchVirtualLogConvert.INSTANCE.convertDO(addSchVirtualLogDTO); + schVirtualLog.setId(idService.getDateSeq()); + return iSchVirtualLogDao.add(schVirtualLog); + } + + /** + * 编辑 + * + * @param editSchVirtualLogDTO 编辑参数 + * @return 成功或失败 + */ + @Override + public boolean edit(EditSchVirtualLogDTO editSchVirtualLogDTO) { + SchVirtualLog schVirtualLog = SchVirtualLogConvert.INSTANCE.convertDO(editSchVirtualLogDTO); + return iSchVirtualLogDao.edit(schVirtualLog); + } + + /** + * 批量删除 + * + * @param deleteSchVirtualLogDTO 删除参数 + * @return 成功或失败 + */ + @Override + public int delete(DeleteSchVirtualLogDTO deleteSchVirtualLogDTO) { + return iSchVirtualLogDao.delete(deleteSchVirtualLogDTO.getIds()); + } +} + diff --git a/collector-terminal-management/src/main/resources/application.properties b/collector-terminal-management/src/main/resources/application.properties new file mode 100644 index 0000000..bde7d71 --- /dev/null +++ b/collector-terminal-management/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-collector-scheduling?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/collector-terminal-management/src/main/resources/bin/auto.bat b/collector-terminal-management/src/main/resources/bin/auto.bat new file mode 100644 index 0000000..b07af42 --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/resources/bin/jenkins-update.bat b/collector-terminal-management/src/main/resources/bin/jenkins-update.bat new file mode 100644 index 0000000..19d3f53 --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/resources/bin/start.bat b/collector-terminal-management/src/main/resources/bin/start.bat new file mode 100644 index 0000000..58c25cb --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/resources/bin/stop.bat b/collector-terminal-management/src/main/resources/bin/stop.bat new file mode 100644 index 0000000..1e224c0 --- /dev/null +++ b/collector-terminal-management/src/main/resources/bin/stop.bat @@ -0,0 +1,3 @@ +@echo off + +winsw stop diff --git a/collector-terminal-management/src/main/resources/bin/update.bat b/collector-terminal-management/src/main/resources/bin/update.bat new file mode 100644 index 0000000..67730ec --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/resources/bin/winsw.xml b/collector-terminal-management/src/main/resources/bin/winsw.xml new file mode 100644 index 0000000..64b054a --- /dev/null +++ b/collector-terminal-management/src/main/resources/bin/winsw.xml @@ -0,0 +1,10 @@ + + collector-scheduling-management + 生产-采集调度器(collector-scheduling-management)-服务 + 生产-采集调度器(collector-scheduling-management)-服务 + Automatic + %BASE%\start.bat + + nacos + seata-server + \ No newline at end of file diff --git a/collector-terminal-management/src/main/resources/bootstrap.yml b/collector-terminal-management/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..38ba207 --- /dev/null +++ b/collector-terminal-management/src/main/resources/bootstrap.yml @@ -0,0 +1,73 @@ +server: + port: 9114 +spring: + profiles: + active: dev + application: + name: @artifactId@ + datasource: + dynamic: + primary: master #设置默认的数据源,默认值为master + strict: false #是否弃用严格模式,如果启用在味匹配到指定数据源时抛出异常 + datasource: + #公司病案的文件服务数据库 + master: + url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus-collector-scheduling?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 + type: com.alibaba.druid.pool.DruidDataSource + 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 + +netty: + client: + host: 192.168.16.110 + port: 65535 + reader-idle-time-seconds: 0 + writer-idle-time-seconds: 5 + all-idle-time-seconds: 0 + reconnect-seconds: 10 + server: + port: 65534 + boss-thread-count: 1 + worker-thread-count: 20 + reader-idle-time-seconds: 30 + writer-idle-time-seconds: 0 + all-idle-time-seconds: 0 + +file: + uploadFolder: D://docus/ + +docus: + redisKeyExpiration: true diff --git a/collector-terminal-management/src/main/resources/log4jdbc.log4j2.properties b/collector-terminal-management/src/main/resources/log4jdbc.log4j2.properties new file mode 100644 index 0000000..5cb6f99 --- /dev/null +++ b/collector-terminal-management/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/collector-terminal-management/src/main/resources/logback.xml b/collector-terminal-management/src/main/resources/logback.xml new file mode 100644 index 0000000..1c6a406 --- /dev/null +++ b/collector-terminal-management/src/main/resources/logback.xml @@ -0,0 +1,104 @@ + + + collector-terminal-management[0] + + + + + [%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/collector-terminal-management/src/main/resources/mapper/SchCollectErrorLogMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectErrorLogMapper.xml new file mode 100644 index 0000000..dee1812 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectErrorLogMapper.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + id, terminator_ip, collector_id, collect_record_id, task_id, is_retry_task, level, description, exception_info, screen_path, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectRecordMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectRecordMapper.xml new file mode 100644 index 0000000..fcf26b1 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectRecordMapper.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + id, terminator_id, collector_id, task_id, task_name, task_memo, start_time, end_time, elapsed_time, task_detail_info, task_exec_state, sub_task_exec_state, last_task_error_msg, create_time, update_time, task_origin_json + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectRecordRetryLogMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectRecordRetryLogMapper.xml new file mode 100644 index 0000000..efb3c4f --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectRecordRetryLogMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, collect_record_id, terminator_id, collector_id, task_id, task_name, task_memo, start_time, end_time, elapsed_time,task_detail_info, task_exec_state, sub_task_exec_state,last_task_error_msg, create_time, update_time,task_origin_json + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectorConfigMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectorConfigMapper.xml new file mode 100644 index 0000000..579ecab --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectorConfigMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + id, collector_id, config_type, config_json, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectorMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectorMapper.xml new file mode 100644 index 0000000..13cc77d --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectorMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + id, collector_version_id, collect_language, collector_id, start_mode, task_timeout, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionFileMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionFileMapper.xml new file mode 100644 index 0000000..97ed6e1 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionFileMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + id, collector_version_id, collector_id, file_title, file_path, file_name, file_size, file_type, state, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionLogMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionLogMapper.xml new file mode 100644 index 0000000..e4e283a --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionLogMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + id, collector_id, operation_module, operation_type, operation_desc, operation_content, state, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionMapper.xml new file mode 100644 index 0000000..de0d192 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchCollectorVersionMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + id, collector_id, collect_version, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchOperationLogMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchOperationLogMapper.xml new file mode 100644 index 0000000..0371e95 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchOperationLogMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + id, operation_module, operation_type, operation_desc, operation_content, state, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchSystemParamsMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchSystemParamsMapper.xml new file mode 100644 index 0000000..136051f --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchSystemParamsMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + id, parent_id, param_code, param_name, param_info, param_value, param_group, sort_no, need_encrypt, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchTerminatorMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchTerminatorMapper.xml new file mode 100644 index 0000000..abc19a3 --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchTerminatorMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + id, terminator_ip, terminator_name, only_collector_ids, priority_collector_ids, restrict_state, busy_state, online_state, last_task_exec_time, executing_task_name, last_task_error_msg, create_time, update_time + + + diff --git a/collector-terminal-management/src/main/resources/mapper/SchVirtualLogMapper.xml b/collector-terminal-management/src/main/resources/mapper/SchVirtualLogMapper.xml new file mode 100644 index 0000000..381780a --- /dev/null +++ b/collector-terminal-management/src/main/resources/mapper/SchVirtualLogMapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + id, cpu_utilization, memory_total, memory_allowance, uplink_rate, descending_rate, ip, create_time, update_time, client_time, disk_json + + + diff --git a/collector-terminal-management/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java b/collector-terminal-management/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java new file mode 100644 index 0000000..18fefea --- /dev/null +++ b/collector-terminal-management/src/test/java/com/docus/server/TsmsAuthApiApplicationTests.java @@ -0,0 +1,79 @@ +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.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.sql.DataSource; +import java.util.ArrayList; + +@SpringBootTest +class ScrewTests { + + @Autowired + private ApplicationContext applicationContext; + + @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(); + } +}