Prechádzať zdrojové kódy

老师端、后台添加单独的业务日志处理。

zouxuan 2 rokov pred
rodič
commit
5af88fcde9

+ 5 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -176,7 +176,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     @Autowired
 	private CourseScheduleConvertDao courseScheduleConvertDao;
 
-    private final Logger LOGGER = LoggerFactory
+    private final Logger businessLogger = LoggerFactory
             .getLogger(this.getClass());
 
     @Override
@@ -1511,6 +1511,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
     	if(CollectionUtils.isEmpty(courseSchedules)){
     		throw new BizException("请指定课程");
 		}
+		businessLogger.info("courseAdjustOnlyWithClassDate: {}",JSON.toJSONString(courseSchedules));
 		Map<Long, CourseSchedule> idCourseMap = courseSchedules.stream().collect(Collectors.toMap(CourseSchedule::getId, c -> c));
 		List<Long> courseIds = courseSchedules.stream().map(CourseSchedule::getId).collect(Collectors.toList());
 		List<CourseSchedule> existCourses = courseScheduleDao.findByCourseScheduleIds(courseIds);
@@ -4124,7 +4125,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			try {
 				tenantAssetsInfoService.deductAmount(updateList);
 			}catch (Exception e){
-				LOGGER.error("deductAmount  >>>>>>>>>",e.getCause());
+				businessLogger.info("deductAmount  >>>>>>>>>",e.getCause());
 			}
 			courseIds = updateList.stream().map(CourseSchedule::getId).collect(Collectors.toList());
 			List<CourseSchedule> beMergeCourses = courseScheduleDao.getBeMergeCourseWithMainCourseIds(courseIds);
@@ -4936,7 +4937,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         if(StringUtils.isEmpty(courseScheduleIds)){
             throw new BizException("参数校验失败");
         }
-        LOGGER.info("清空老师和学生考勤,user:{},参数:{}",user.getId(),courseScheduleIds);
+		businessLogger.info("清空老师和学生考勤,user:{},参数:{}",user.getId(),courseScheduleIds);
         List<Long> courseScheduleId = courseScheduleTeacherSalaryService.querySettlementScheduleId(courseScheduleIds);
         if(courseScheduleId == null || courseScheduleId.size() == 0){
             throw new BizException("课程已结算,无法清除考勤");
@@ -5293,7 +5294,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(schedule == null){
 			throw new BizException("课程不存在");
 		}
-		LOGGER.warn("teacherCourseRates courseScheduleId:{},userId{}",courseScheduleId,user.getId());
+		businessLogger.info("teacherCourseRates courseScheduleId:{},userId{}",courseScheduleId,user.getId());
 		//如果是乐团课
 		List<CourseScheduleRateDto> courseScheduleRateDtos;
 		CourseSchedule courseSchedule;

+ 11 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/TeacherApplication.java

@@ -5,6 +5,8 @@ import javax.servlet.Filter;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.logging.LogLevel;
+import org.springframework.boot.logging.LoggingSystem;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
@@ -30,6 +32,8 @@ public class TeacherApplication {
 
 	public static void main(String[] args) {
 		SpringApplication.run(TeacherApplication.class, args);
+
+		configureGlobalLogger();
 	}
 
 	@Bean
@@ -55,4 +59,11 @@ public class TeacherApplication {
 		registration.setOrder(1);
 		return registration;
 	}
+
+
+	private static void configureGlobalLogger() {
+		LoggingSystem loggingSystem = LoggingSystem.get(ClassLoader.getSystemClassLoader());
+		// 设置业务日志记录器的日志级别为INFO
+		loggingSystem.setLogLevel("businessLogger", LogLevel.INFO);
+	}
 }

+ 11 - 0
mec-web/src/main/java/com/ym/mec/web/WebApplication.java

@@ -5,6 +5,8 @@ import javax.servlet.Filter;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.logging.LogLevel;
+import org.springframework.boot.logging.LoggingSystem;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.client.loadbalancer.LoadBalanced;
@@ -30,6 +32,9 @@ public class WebApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(WebApplication.class, args);
+
+        // 配置全局的日志记录器
+        configureGlobalLogger();
     }
 
     @Bean
@@ -57,4 +62,10 @@ public class WebApplication {
         return registration;
     }
 
+    private static void configureGlobalLogger() {
+        LoggingSystem loggingSystem = LoggingSystem.get(ClassLoader.getSystemClassLoader());
+        // 设置业务日志记录器的日志级别为INFO
+        loggingSystem.setLogLevel("businessLogger", LogLevel.INFO);
+    }
+
 }

+ 3 - 1
mec-web/src/main/java/com/ym/mec/web/controller/StudentInstrumentController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.web.controller;
 
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -31,6 +32,8 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -62,7 +65,6 @@ public class StudentInstrumentController extends BaseController {
     @Autowired
     private StudentInstrumentDao studentInstrumentDao;
 
-
     @ApiOperation(value = "乐器保养列表")
     @GetMapping("/getList")
     //@PreAuthorize("@pcs.hasPermissions('studentInstrument/getList')")