Commit e6c43358 by zzrdark

1.add logging

2.增加 查询设备信息
parent 034fca8b
......@@ -11,12 +11,12 @@
<module name="cneeds-common-utils" />
<module name="cneeds-common-data" />
<module name="cneeds-server-eureka" />
<module name="cneeds-common-hadoop-dfs" />
<module name="cneeds-common-pojo" />
<module name="cneeds-server-device_activate" />
<module name="cneeds-server-logupload" />
<module name="cneeds-server-authorization" />
<module name="cneeds-server-user" />
<module name="cneeds-server-logupload" />
<module name="cneeds-common-hadoop-dfs" />
<module name="cneeds-server-device" />
</profile>
</annotationProcessing>
......
......@@ -23,6 +23,7 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter {
"/device/device/getChannel_nums",
"/wechat/wechatFileUpload",
"/wechat/wechatDownload/**",
"/logFile/logfile/DeviceLogFileUpload",
// "/user/info",
"/statics/**")
.permitAll()
......
......@@ -191,5 +191,11 @@ public class DeviceController {
}
@PostMapping("/device/queryDeviceByImei")
public R queryDeviceByImei(@RequestParam(value = "imei") String imei){
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(imei);
return R.ok().put("data",deviceInfoDto);
}
}
......@@ -3,6 +3,7 @@ package com.mx.cneeds.server.datashow.web.device;
import com.google.gson.Gson;
import com.mx.cneeds.common.UserUtils;
import com.mx.cneeds.common.constant.FilePath;
import com.mx.cneeds.common.constant.ResultCode;
import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.result.R;
......@@ -81,6 +82,11 @@ public class LogFlieController {
DeviceLogFileDto dto = new DeviceLogFileDto();
BeanUtils.copyProperties(vo, dto);
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
if (deviceInfoDto == null){
return R.error(ResultCode.NOTFOUND_IMEI,"没有该imei");
}
// 把图片存入oos 返回路径
StringBuffer dir = new StringBuffer(FilePath.LogFilePath);
dir.append(vo.getLogAcceptId());
......@@ -88,7 +94,7 @@ public class LogFlieController {
dto.setLogfileUrl(dir.toString()+"/"+file.getOriginalFilename());
dto.setLogfileSize(file.getSize());
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
dto.setDeviceId(deviceInfoDto.getDeviceId());
logFileClient.uploadLogFile(dto);
return R.ok();
......
......@@ -17,4 +17,7 @@ spring:
servlet:
multipart:
max-file-size: 100000MB
max-request-size: 100000MB
\ No newline at end of file
max-request-size: 100000MB
logging:
config: classpath:logback-spring-dev.xml
\ No newline at end of file
......@@ -16,4 +16,7 @@ spring:
servlet:
multipart:
max-file-size: 100000MB
max-request-size: 100000MB
\ No newline at end of file
max-request-size: 100000MB
logging:
config: classpath:logback-spring-prod.xml
eureka:
client:
service-url:
defaultZone: http://192.168.2.244:8761/eureka/
instance:
prefer-ip-address: true
spring:
hadoop:
hdfs:
# hadoopConfigDir: D:\hadoop2.6_Win_x64\etc\hadoop
hadoopConfigDir: /home/fengte/hadoop/etc/hadoop/
hdfsUrl: hdfs://192.168.2.244:9100
defaultBlockSize: 128000000
bufferSize: 512000
servlet:
multipart:
max-file-size: 100000MB
max-request-size: 100000MB
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="E:/cneedsLog/log/datashow" />
<!--<property name="log.path" value="/root/cneeds-server/cneedsLog" />-->
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="debug">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
<root level="info">
<appender-ref ref="INFO_FILE" />
</root>
<!--<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="TRACE" />-->
<!-- 开发、测试环境 -->
<springProfile name="dev,test,pro">
<logger name="org.springframework" level="debug"/>
<logger name="org.springboot" level="debug" />
<logger name="com.mx" level="debug" />
</springProfile>
<!--&lt;!&ndash; 生产环境 &ndash;&gt;
<springProfile name="pro">
<logger name="org.springframework" level="info"/>
<logger name="org.springboot" level="info" />
<logger name="com.mx" level="info" />
</springProfile>-->
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<!-- <property name="log.path" value="E:/cneedsLog/log" />-->
<property name="log.path" value="/root/cneeds-server/cneedsLog/datashow" />
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 -->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<root level="debug">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
<root level="info">
<appender-ref ref="INFO_FILE" />
</root>
<!--<logger name="org.springframework.web" level="INFO"/>
<logger name="org.springboot.sample" level="TRACE" />-->
<!-- 开发、测试环境 -->
<springProfile name="dev,test,pro">
<logger name="org.springframework" level="debug"/>
<logger name="org.springboot" level="debug" />
<logger name="com.mx" level="debug" />
</springProfile>
<!--&lt;!&ndash; 生产环境 &ndash;&gt;
<springProfile name="pro">
<logger name="org.springframework" level="info"/>
<logger name="org.springboot" level="info" />
<logger name="com.mx" level="info" />
</springProfile>-->
</configuration>
\ No newline at end of file
......@@ -22,5 +22,7 @@ public interface ProductSeriesService extends IService<ProductSeriesEntity> {
List<ProductSeriesEntity> queryListById(Collection<Long> array);
List<ProductSeriesEntity> queryList(Map<String, Object> params);
ProductSeriesEntity queryOne(Long seriesId);
}
......@@ -39,7 +39,15 @@ public class ProductSeriesServiceImpl extends ServiceImpl<ProductSeriesDao, Prod
@Override
public List<ProductSeriesEntity> queryList(Map<String, Object> params) {
return baseMapper.queryList(params);
}
@Override
public ProductSeriesEntity queryOne(Long seriesId){
ProductSeriesEntity seriesEntity = getById(seriesId);
return seriesEntity;
}
}
......@@ -8,7 +8,9 @@ import com.mx.cneeds.common.pager.PageUtils;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.validator.ValidatorUtils;
import com.mx.cneeds.server.device.service.DeviceInfoService;
import com.mx.cneeds.server.device.service.ProductSeriesService;
import com.mx.cneeds.server.entity.DeviceInfoEntity;
import com.mx.cneeds.server.entity.ProductSeriesEntity;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -32,6 +34,9 @@ public class DeviceInfoController {
@Autowired
private DeviceInfoService deviceInfoService;
@Autowired
private ProductSeriesService productSeriesService;
/**
* 列表
*/
......@@ -62,11 +67,14 @@ public class DeviceInfoController {
DeviceInfoDto deviceInfoDto = new DeviceInfoDto();
if (deviceInfoEntity != null){
BeanUtils.copyProperties(deviceInfoEntity,deviceInfoDto);
if (deviceInfoEntity.getSeriesId()!=null){
ProductSeriesEntity seriesEntity = productSeriesService.queryOne(deviceInfoEntity.getSeriesId());
deviceInfoDto.setSeriesNum(seriesEntity.getSeriesNum());
}
return deviceInfoDto;
}else{
return null;
}
}
@RequestMapping("/infoByIds")
......
......@@ -50,29 +50,5 @@ eureka:
defaultZone: http://192.168.2.244:8761/eureka/
instance:
prefer-ip-address: true
# ip-address: 192.168.2.244
mybatis-plus:
mapper-locations: classpath:mapper/*.xml
#实体扫描,多个package用逗号或者分号分隔
typeAliasesPackage: com.mx.cneeds.server.entity
global-config:
#数据库相关配置
db-config:
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID";
id-type: AUTO
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断"
field-strategy: NOT_NULL
#驼峰下划线转换
column-underline: true
logic-delete-value: -1
logic-not-delete-value: 0
banner: false
#原生配置
configuration:
map-underscore-to-camel-case: true
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
ip-address: 192.168.2.244
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment