diff --git a/src/main/java/com/netsdk/SpringBootStartApplication.java b/src/main/java/com/netsdk/SpringBootStartApplication.java new file mode 100644 index 0000000..c954b10 --- /dev/null +++ b/src/main/java/com/netsdk/SpringBootStartApplication.java @@ -0,0 +1,17 @@ +package com.netsdk; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +/** + * 说明:项目以war包方式运行时用到 + * 作者:luoxiaobao + * 官网:www.qdkjchina.com + */ +public class SpringBootStartApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return builder.sources(DahuaApplication.class); //这里要指向原先用main方法执行的FHmainApplication启动类 + } +} \ No newline at end of file diff --git a/src/main/java/com/netsdk/utils/ProvincialPlatformDataPushScheduled.java b/src/main/java/com/netsdk/utils/ProvincialPlatformDataPushScheduled.java index 314b52e..7bc6029 100644 --- a/src/main/java/com/netsdk/utils/ProvincialPlatformDataPushScheduled.java +++ b/src/main/java/com/netsdk/utils/ProvincialPlatformDataPushScheduled.java @@ -3,6 +3,8 @@ package com.netsdk.utils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.netsdk.entity.PageData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -26,6 +28,7 @@ import java.util.Map; */ @Component public class ProvincialPlatformDataPushScheduled { + private static final Logger logger = LoggerFactory.getLogger(ProvincialPlatformDataPushScheduled.class); private static final String URL = "http://1.71.182.111:86/iot-cascade-receive/iot/cascade/http-report"; //省平台推送接口 @Resource @@ -108,7 +111,7 @@ public class ProvincialPlatformDataPushScheduled { try { encrypt = AESUtil.encrypt(JSON.toJSONString(dataMap)); } catch (Exception e) { - System.out.println("实时数据AES加密出现错误!"); + logger.error("实时数据AES加密出现错误!", e); throw new RuntimeException(e); } baseMap.put("data", encrypt); @@ -170,7 +173,7 @@ public class ProvincialPlatformDataPushScheduled { try { encrypt = AESUtil.encrypt(JSON.toJSONString(alarmMap)); } catch (Exception e) { - System.out.println("实时数据AES加密出现错误!"); + logger.error("实时数据AES加密出现错误!", e); throw new RuntimeException(e); } baseMap.put("data", encrypt); @@ -197,14 +200,12 @@ public class ProvincialPlatformDataPushScheduled { //处理响应 if (response.getStatusCode().is2xxSuccessful()) { - System.out.println("数据推送成功,响应内容:" + response.getBody()); + logger.info("数据推送成功,响应内容:{}", response.getBody()); } else { - System.out.println("数据推送失败,状态码:" + response.getStatusCodeValue() + - ",响应内容:" + response.getBody()); + logger.warn("数据推送失败,状态码:{},响应内容:{}", response.getStatusCodeValue(), response.getBody()); } } catch (Exception e) { - System.err.println("数据推送发生异常:" + e.getMessage()); - e.printStackTrace(); + logger.error("数据推送发生异常:{}", e.getMessage(), e); } } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index de3ff5b..b6eaa13 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -13,5 +13,8 @@ spring: password: Zcloud@redis16379 database: 10 port: 16379 +logging: + level: + com.netsdk: INFO modbus: port: 18888