Commit 820ffaaa by huangjy

fix:log

parent 6e9fb814
...@@ -143,6 +143,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -143,6 +143,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
continue; continue;
} }
String tenantId = elder.getTenantId(); String tenantId = elder.getTenantId();
String reportStartTime = "";
String reportEndTime = "";
for (String hourRange : dayHourRangeList) { for (String hourRange : dayHourRangeList) {
String[] hourRangeArray = hourRange.split("~"); String[] hourRangeArray = hourRange.split("~");
List<DeviceOperationLogEntity> deviceOperationLogEntities = productDeviceService.getDeviceLogByTimeRange(platRoomBedDevice.getDeviceId(), "reportProperty", 5000, hourRangeArray[0], hourRangeArray[1]); List<DeviceOperationLogEntity> deviceOperationLogEntities = productDeviceService.getDeviceLogByTimeRange(platRoomBedDevice.getDeviceId(), "reportProperty", 5000, hourRangeArray[0], hourRangeArray[1]);
...@@ -163,7 +165,13 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -163,7 +165,13 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
List<DeviceInfoContentBreathe> deviceInfoContentBreathes; List<DeviceInfoContentBreathe> deviceInfoContentBreathes;
// 统计每小时的体动和翻身 // 统计每小时的体动和翻身
Map<String, AnalysisVO> statisticsMap = Maps.newHashMap(); Map<String, AnalysisVO> statisticsMap = Maps.newHashMap();
for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) { for (Map.Entry<String, List<DeviceInfoContentBreathe>> entry : minuteMap.entrySet()) {
if (StringUtils.isEmpty(reportStartTime)) {
reportStartTime = entry.getKey();
}
reportEndTime = entry.getKey();
deviceInfoContentBreathes = entry.getValue(); deviceInfoContentBreathes = entry.getValue();
DeviceInfoContentBreathe.Properties breatheProperties; DeviceInfoContentBreathe.Properties breatheProperties;
Integer bodymove; Integer bodymove;
...@@ -453,12 +461,19 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -453,12 +461,19 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
} }
int timeHourRange = 24;
if (StringUtils.isNotEmpty(reportStartTime) && StringUtils.isNotEmpty(reportEndTime)) {
Long durationRange = getDurationRange(reportStartTime, reportEndTime);
timeHourRange = (int) (durationRange / 60);
}
// 判断是否满足配置的呼吸心率异常类型 // 判断是否满足配置的呼吸心率异常类型
BigDecimal dayBrStopRate = brStopCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brStopCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrStopRate = brStopCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brStopCount), 2, RoundingMode.HALF_UP);
BigDecimal dayBrSlowRate = brSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brSlowCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrSlowRate = brSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brSlowCount), 2, RoundingMode.HALF_UP);
BigDecimal dayBrFastRate = brFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(brFastCount), 2, RoundingMode.HALF_UP); BigDecimal dayBrFastRate = brFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(brFastCount), 2, RoundingMode.HALF_UP);
BigDecimal dayHrFastRate = hrFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(hrFastCount), 2, RoundingMode.HALF_UP); BigDecimal dayHrFastRate = hrFastCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(hrFastCount), 2, RoundingMode.HALF_UP);
BigDecimal dayHrSlowRate = hrSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(24).divide(new BigDecimal(hrSlowCount), 2, RoundingMode.HALF_UP); BigDecimal dayHrSlowRate = hrSlowCount == 0 ? BigDecimal.ZERO : new BigDecimal(timeHourRange).divide(new BigDecimal(hrSlowCount), 2, RoundingMode.HALF_UP);
boolean brStopFlag = false; boolean brStopFlag = false;
boolean brFastFlag = false; boolean brFastFlag = false;
...@@ -537,8 +552,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -537,8 +552,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
// 插入呼吸分析表 // 插入呼吸分析表
PlatElderBreatheAnalysis platElderBreatheAnalysis = new PlatElderBreatheAnalysis(); PlatElderBreatheAnalysis platElderBreatheAnalysis = new PlatElderBreatheAnalysis();
platElderBreatheAnalysis.setElderId(elder.getId()); platElderBreatheAnalysis.setElderId(elder.getId());
platElderBreatheAnalysis.setAvgBreatheRate(String.valueOf(dayTotalBr / 86400)); platElderBreatheAnalysis.setAvgBreatheRate(String.valueOf(dayTotalBr / (timeHourRange * 60 * 60)));
platElderBreatheAnalysis.setAvgHeartRate(String.valueOf(dayTotalHr / 86400)); platElderBreatheAnalysis.setAvgHeartRate(String.valueOf(dayTotalHr / (timeHourRange * 60 * 60)));
platElderBreatheAnalysis.setBreatheScore(finalReport.getScore()); platElderBreatheAnalysis.setBreatheScore(finalReport.getScore());
platElderBreatheAnalysis.setHappenDate(currentDate); platElderBreatheAnalysis.setHappenDate(currentDate);
platElderBreatheAnalysis.setTenantId(tenantId); platElderBreatheAnalysis.setTenantId(tenantId);
......
...@@ -91,15 +91,6 @@ public class IotSyncTask { ...@@ -91,15 +91,6 @@ public class IotSyncTask {
} }
@Scheduled(cron = "0 0 */1 * * ?")
public void syncDeviceLog() {
log.info("开始同步设备日志");
log.info("同步设备日志结束");
}
private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) { private Collection<PlatDevice> convertToPlatDevice(List<DeviceInstanceEntity> iotDeviceList, List<PlatDevice> deviceList, String tenantId, Map<String, String> dicNameIdMap) {
Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a)); Map<String, PlatDevice> deviceMap = deviceList.stream().collect(Collectors.toMap(PlatDevice::getOriDeviceId, v -> v, (a, b) -> a));
iotDeviceList.forEach(iotDevice -> { iotDeviceList.forEach(iotDevice -> {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<configuration> <!-- 从高到地低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志 -->
<!-- 属性描述 scan:性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。
debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<contextName>d1money-web-ys-ems</contextName>
<!-- 定义日志文件 输入位置 -->
<property name="logback.logdir" value="/home/group1_lzy/iot-plafform-server/logs"/> <property name="logback.logdir" value="/home/group1_lzy/iot-plafform-server/logs"/>
<property name="logback.appname" value="app"/> <!-- 日志最大的历史 30天 -->
<property name="maxHistory" value="180" />
<property name="pattern" <property name="maxFileSize" value="10MB" />
value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%X{appName}] [%X{profile}] [%X{traceId:-},%X{spanId:-}] [%X{requestId}] [%X{userId}] [%thread] %-5level %logger{50} - %msg%n"/> <!-- ERROR级别日志 -->
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender -->
<springProfile name="prod"> <appender name="ERROR"
<property name="logback.logdir" value="/home/group1_lzy/iot-plafform-server/logs"/> class="ch.qos.logback.core.rolling.RollingFileAppender">
<property name="logback.appname" value="app"/> <!-- 过滤器,只记录WARN级别的日志 -->
</springProfile> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>DEBUG</level>
</filter>
<encoder>
<pattern>${pattern}</pattern>
</encoder>
</appender>
<!-- info -->
<appender name="FILELOGGING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<file>${logback.logdir}/${logback.appname}/logging/logging.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/logging/logging.%d{yyyy-MM-dd}.%i.log
</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- info -->
<appender name="FILEINFOLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<file>${logback.logdir}/${logback.appname}/info/log_info.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/info/log_info.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<maxHistory>30</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>${pattern}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- error -->
<appender name="FILEERRORLOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level> <level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter> </filter>
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
<file>${logback.logdir}/${logback.appname}/error/log_error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/error/log_error.%d{yyyy-MM-dd}.%i.log <!--日志输出位置 可相对、和绝对路径 -->
</FileNamePattern> <fileNamePattern>
<maxHistory>30</maxHistory> ${log_dir}/app_error.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件假设设置每个月滚动,且<maxHistory>是6, 则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除 -->
<maxHistory>${maxHistory}</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize> <maxFileSize>${maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy> </timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy> </rollingPolicy>
<!-- 按照固定窗口模式生成日志文件,当文件大于20MB时,生成新的日志文件。窗口大小是1到3,当保存了3个归档文件后,将覆盖最早的日志。
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${log_dir}/%d{yyyy-MM-dd}/.log.zip</fileNamePattern> <minIndex>1</minIndex>
<maxIndex>3</maxIndex> </rollingPolicy> -->
<!-- 查看当前活动文件的大小,如果超过指定大小会告知RollingFileAppender 触发当前活动文件滚动 <triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> <maxFileSize>5MB</maxFileSize>
</triggeringPolicy> -->
<encoder> <encoder>
<pattern>${pattern}</pattern> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder> </encoder>
</appender> </appender>
<!-- INFO级别日志 appender -->
<!-- WARN --> <appender name="INFO"
<appender name="FILEWARNLOG" class="ch.qos.logback.core.rolling.RollingFileAppender"> class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> <!-- 过滤器,只记录INFO级别的日志 -->
<level>WARN</level> <filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter> </filter>
<file>${logback.logdir}/${logback.appname}/warn/log_warn.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logback.logdir}/${logback.appname}/warn/log_warn.%d{yyyy-MM-dd}.%i.log</FileNamePattern> <!-- 按天回滚 daily -->
<maxHistory>30</maxHistory> <fileNamePattern>
${log_dir}/app_info.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<!-- 日志最大的历史 30天 -->
<maxHistory>${maxHistory}</maxHistory>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>20MB</maxFileSize> <maxFileSize>${maxFileSize}</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy> </timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${pattern}</pattern> <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder> </encoder>
</appender> </appender>
<springProfile name="dev,dev2"> <logger name="java.sql.PreparedStatement" value="DEBUG" />
<root level="INFO"> <logger name="java.sql.Connection" value="DEBUG" />
<appender-ref ref="CONSOLE"/> <logger name="java.sql.Statement" value="DEBUG" />
</root> <logger name="com.ibatis" value="DEBUG" />
<logger name="com.makeit" level="INFO" additivity="false"> <logger name="com.ibatis.common.jdbc.SimpleDataSource" value="DEBUG" />
<appender-ref ref="CONSOLE"/> <logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" />
</logger> <logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate"
</springProfile> value="DEBUG" />
<!-- root级别 DEBUG -->
<springProfile name="test"> <root level="debug">
<root level="INFO"> <!-- 文件输出 -->
<appender-ref ref="FILEINFOLOG"/> <appender-ref ref="ERROR" />
<appender-ref ref="FILEERRORLOG"/> <appender-ref ref="INFO" />
<appender-ref ref="FILEWARNLOG"/> </root>
</root> </configuration>
<logger name="com.makeit" level="DEBUG" additivity="false"> \ No newline at end of file
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</logger>
</springProfile>
<springProfile name="prod">
<property name="logback.logdir" value="/home/project/jianfa-integral/logs"/>
<property name="logback.appname" value="app"/>
<root level="INFO">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</root>
<logger name="com.makeit" level="DEBUG" additivity="false">
<appender-ref ref="FILEINFOLOG"/>
<appender-ref ref="FILEERRORLOG"/>
<appender-ref ref="FILEWARNLOG"/>
</logger>
</springProfile>
</configuration>
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 sign in to comment