Browse Source

Merge remote-tracking branch 'origin/master'

master
zhangzhiqiang 2 years ago
parent
commit
37d8bcc44e
  1. 38
      nladmin-system/nlsso-server/pom.xml
  2. 29
      nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java
  3. 14
      nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java
  4. 10
      nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java
  5. 17
      nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

38
nladmin-system/nlsso-server/pom.xml

@ -24,15 +24,32 @@
<commons-pool2.version>2.5.0</commons-pool2.version>
<mapstruct.version>1.3.1.Final</mapstruct.version>
<sa-token.version>1.31.0</sa-token.version>
<hutool.version>5.7.14</hutool.version>
<hutool.version>5.8.1</hutool.version>
<jjwt.version>0.11.1</jjwt.version>
<!-- oshi监控需要指定jna版本, 问题详见 https://github.com/oshi/oshi/issues/1040 -->
<jna.version>5.9.0</jna.version>
<jna.version>5.8.0</jna.version>
<configuration.version>1.9</configuration.version>
<netty.version>4.1.59.Final</netty.version>
</properties>
<dependencies>
<!-- 将p6spy导入 p6spy实现sql监控 -->
<dependency>
<groupId>p6spy</groupId>
<artifactId>p6spy</artifactId>
<version>3.8.6</version>
</dependency>
<!-- 日志链路追踪 https://tlog.yomahub.com/pages/f62a84/#%E5%90%8C%E6%AD%A5%E6%97%A5%E5%BF%97-->
<dependency>
<groupId>com.yomahub</groupId>
<artifactId>tlog-all-spring-boot-starter</artifactId>
<version>1.5.0</version>
</dependency>
<!-- elasticsearch-->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -47,6 +64,13 @@
<version>1.6</version>
</dependency>
<!-- https://onew.me/logback/2018/09/17/logback_win.html 控制台彩色日志-->
<dependency>
<groupId>org.fusesource.jansi</groupId>
<artifactId>jansi</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>cn.dynamictp</groupId>
@ -380,6 +404,14 @@
<version>1.9.2</version>
</dependency>
<!-- 重试机制-->
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
</dependency>
<!--接口限流-->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -472,7 +504,7 @@
<dependency>
<groupId>com.github.oshi</groupId>
<artifactId>oshi-core</artifactId>
<version>5.0.1</version>
<version>6.1.4</version>
</dependency>
<dependency>

29
nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java

@ -1,8 +1,10 @@
package org.nl;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
import com.alicp.jetcache.anno.config.EnableMethodCache;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.nl.common.utils.SpringContextHolder;
import org.springframework.boot.SpringApplication;
@ -11,9 +13,10 @@ import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactor
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
import org.springframework.retry.annotation.EnableRetry;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
@ -35,6 +38,9 @@ import org.springframework.web.bind.annotation.RestController;
@EnableMethodCache(basePackages = "org.nl")
@EnableCreateCacheAnnotation
@MapperScan("org.nl.**.mapper")
@EnableRetry //https://juejin.cn/post/7094613787973517343
@Slf4j
public class AppRun {
public static void main(String[] args) {
@ -53,15 +59,16 @@ public class AppRun {
return fa;
}
// /**
// * 访问首页提示
// *
// * @return /
// */
// @GetMapping("/")
// @SaIgnore
// public String index() {
// return "Backend service started successfully";
// }
/**
* 访问首页提示
*
* @return /
*/
@GetMapping("/")
@SaIgnore
public String index() {
log.info("123");
return "Backend service started successfully";
}
}

14
nladmin-system/nlsso-server/src/main/java/org/nl/system/service/param/impl/SysParamServiceImpl.java

@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yomahub.tlog.core.annotation.TLogAspect;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.aspect.exception.BadRequestException;
@ -22,9 +23,7 @@ import java.util.List;
import java.util.Map;
/**
* <p>
* 系统参数表 服务实现类
* </p>
*
* @author generator
* @since 2022-12-14
@ -33,13 +32,20 @@ import java.util.Map;
@RequiredArgsConstructor
@Slf4j
@Transactional
public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param> implements ISysParamService {
public class SysParamServiceImpl extends ServiceImpl<SysParamMapper, Param>
implements ISysParamService {
private final SysParamMapper paramMapper;
@Override
@TLogAspect
public Page<Param> queryPage(Map whereJson, PageQuery page) {
log.info("111");
log.info("这是第一条日志");
log.info("这是第二条日志");
log.info("这是第三条日志");
new Thread(() -> log.info("这是异步日志")).start();
QueryWrapper<Param> queryWrapper = new QueryWrapper<>();
queryWrapper.orderBy(true, true, "create_time");
Page<Param> paramPage = paramMapper.selectPage(page.build(), queryWrapper);

10
nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/utils/ExecutionJob.java

@ -2,6 +2,7 @@ package org.nl.system.service.quartz.utils;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.yomahub.tlog.task.quartz.TLogQuartzJobBean;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.utils.RedisUtils;
import org.nl.common.utils.SpringContextHolder;
@ -12,10 +13,10 @@ import org.nl.system.service.quartz.dao.SysQuartzJob;
import org.nl.system.service.quartz.dao.SysQuartzLog;
import org.nl.system.service.quartz.dao.mapper.SysQuartzLogMapper;
import org.nl.system.service.quartz.impl.SysQuartzJobServiceImpl;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.quartz.QuartzJobBean;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
@ -28,14 +29,16 @@ import java.util.concurrent.ThreadPoolExecutor;
@Async
@SuppressWarnings({"unchecked", "all"})
@Slf4j
public class ExecutionJob extends QuartzJobBean {
@DisallowConcurrentExecution
//public class ExecutionJob extends QuartzJobBean {
public class ExecutionJob extends TLogQuartzJobBean {
/**
* 该处仅供参考
*/
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
public void executeTask(JobExecutionContext context) throws JobExecutionException {
SysQuartzJob quartzJob = (SysQuartzJob) context.getMergedJobDataMap().get(SysQuartzJob.JOB_KEY);
// 获取spring bean
ISysQuartzJobService quartzJobService = SpringContextHolder.getBean(SysQuartzJobServiceImpl.class);
@ -99,4 +102,5 @@ public class ExecutionJob extends QuartzJobBean {
}
}
}

17
nladmin-system/nlsso-server/src/main/resources/logback-spring.xml

@ -21,9 +21,12 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/MesToErp.xml"/>-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- 控制台彩色日志-->
<withJansi>true</withJansi>
<!-- <encoder>-->
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
<pattern>${log.pattern}</pattern>
<charset>${log.charset}</charset>
<!-- <charset>${log.charset}</charset>-->
</encoder>
</appender>
@ -41,15 +44,20 @@ https://juejin.cn/post/6844903775631572999
<!--所有日志最多占多大容量-->
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!-- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">-->
<!--这里替换成AspectLogbackEncoder-->
<encoder class="com.yomahub.tlog.core.enhance.logback.AspectLogbackEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<!--异步到文件-->
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<!-- 这里替换成AspectLogbackAsyncAppender -->
<appender name="asyncFileAppender" class="com.yomahub.tlog.core.enhance.logback.async.AspectLogbackAsyncAppender">
<!-- <appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">-->
<discardingThreshold>0</discardingThreshold>
<queueSize>500</queueSize>
<appender-ref ref="FILE"/>
@ -121,6 +129,7 @@ https://juejin.cn/post/6844903775631572999
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="esLogAppender"/>
<appender-ref ref="asyncFileAppender"/>
</root>
<logger name="es-logger" level="warn" additivity="false">
<appender-ref ref="esLogAppender"/>

Loading…
Cancel
Save