Authored by xuhui

爬虫数据上报

package com.ui.test;
import lombok.Data;
/**
* Created by hui.xu on 2017/5/5.
*/
@Data
public class TestCommonAlarmData {
/**
* 设备类型
*/
private String deviceType;
/**
* 系统名称
*/
private String sysName;
/**
* 系统模块名称
*/
private String sysModule;
/**
* 上报的类型,枚举类型
* success
* error
* 后续再加
*/
private String upLoadType;
/**
* 上报的内容
*/
private String upLoadContent;
/**
* 数值
*/
private Integer upLoadValue;
/**
* 保留策略,枚举类型
* 1d
* 7d
* 后续再加
*/
private String duration;
}
\ No newline at end of file
... ...
package com.ui.test;
import lombok.Data;
/**
* Created by hui.xu on 2017/5/5.
*/
@Data
public class TestCommonData<T> {
private String code;
private T data;
}
\ No newline at end of file
... ...
package com.ui.ctrl;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.test.TestCommonAlarmData;
import com.ui.test.TestCommonData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* 测试转用
*/
@Controller
@RequestMapping("testcommon")
public class TestCtrl {
Logger log = LoggerFactory.getLogger("apiTestLogger");
@Autowired
private HttpRestClient httpClient;
@RequestMapping("/testUpLoadData")
@ResponseBody
public BaseResponse<?> testUpLoadData(@RequestBody TestCommonData<TestCommonAlarmData> data) {
log.info(" ------request:" + data.toString());
BaseResponse<?> response = httpClient.defaultPost("/commonAlarmData/upLoadData",data,BaseResponse.class);
return response;
}
}
\ No newline at end of file
... ...
... ... @@ -86,6 +86,7 @@
<mvc:exclude-mapping path="/systemTest/**"/>
<mvc:exclude-mapping path="/recvMonitAlarm"/>
<mvc:exclude-mapping path="/awsapi/sns" />
<mvc:exclude-mapping path="/testcommon/testUpLoadData" />
<bean class="com.ui.interceptor.AuthInterceptor"/>
</mvc:interceptor>
... ...
... ... @@ -67,7 +67,7 @@
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="APP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="APP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.home}/logs/app.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
... ... @@ -88,10 +88,10 @@
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="BAN_IP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 按照每天生成日志文件 -->
<appender name="BAN_IP_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.home}/logs/banIP.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
... ... @@ -112,25 +112,52 @@
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level - %msg%n</pattern>
</encoder>
</appender>
<!-- root级别 DEBUG -->
<root level="INFO">
<!-- 控制台输出 -->
<appender-ref ref="STDOUT" />
<appender-ref ref="STDOUT"/>
<!-- 文件输出 -->
<appender-ref ref="DEBUG" />
<appender-ref ref="WARN" />
<appender-ref ref="DEBUG"/>
<appender-ref ref="WARN"/>
</root>
<logger name="appLogger" additivity="false">
<level value="INFO"/>
<appender-ref ref="APP_LOG"/>
</logger>
<logger name="banIPLogger" additivity="false">
<logger name="banIPLogger" additivity="false">
<level value="INFO"/>
<appender-ref ref="BAN_IP_LOG"/>
</logger>
<!-- 按照每天生成日志文件 -->
<appender name="API_TEST_LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.home}/logs/apiTest.log</file>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>
${catalina.home}/logs/apiTest.%d{yyyy-MM-dd}.%i.log.gz
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>${maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- 日志最大的历史 60天 -->
<maxHistory>${maxHistory}</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level - %msg%n</pattern>
</encoder>
</appender>
<logger name="apiTestLogger" additivity="false">
<level value="INFO"/>
<appender-ref ref="API_TEST_LOG"/>
</logger>
</configuration>
\ No newline at end of file
... ...