소스 검색

1.sql优化。
2.考勤打卡发送微信通知改为15分钟内。
3.单独写错误日志。

tomatozq 3 년 전
부모
커밋
ac3244eaf4

+ 7 - 5
common/src/main/java/com/jpsoft/shinestar/modules/business/service/impl/WorkScheduleAttendanceServiceImpl.java

@@ -198,6 +198,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
 //            }
             PersonInfo personInfo = personInfoService.get(personId);
             long minutes = Minutes.minutesBetween(new DateTime(recordTime), DateTime.now()).getMinutes();
+            long maxInterval = 15;
 
             //todo 2.昨天及当天人员是否有排班(夜班会跨天),考勤是否在上下班时段内
 //			SimpleDateFormat ymdFormat = new SimpleDateFormat("yyyy-MM-dd");
@@ -241,7 +242,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
                     if (StringUtils.isNotEmpty(beginResult)) {
                         result = true;
                         //打卡成功发送模板消息
-                        if (minutes <= 5){
+                        if (minutes <= maxInterval){
                             //1分钟之内只通知一次
                             new Thread(()->{
                                 sendWorkRemindMessage(recordTime, personInfo,shiftInfo.getId(), "班次:" + shiftInfo.getName() + "上班打卡成功");
@@ -260,7 +261,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
                     if (StringUtils.isNotEmpty(endResult)) {
                         result = true;
                         //打卡成功发送模板消息
-                        if (minutes <= 5){
+                        if (minutes <= maxInterval){
                             //1分钟之内只通知一次
                             new Thread(()->{
                                 sendWorkRemindMessage(recordTime, personInfo,shiftInfo.getId(), "班次:" + shiftInfo.getName() +"下班打卡成功");
@@ -281,7 +282,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
 //                }
             }
 
-            if (minutes <= 5 && !result){
+            if (minutes <= maxInterval && !result){
                 //当前用户不在打卡时段,但身份是中层或高层
                 List<PersonPopedom> popedomList = personPopedomService.findByPersonId(personInfo.getId());
 
@@ -631,9 +632,9 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
         long offsetMinute = 0;
         int workMinutes = 0;
 
-        try {
-            String key = "wsa_" + personScheduleId + "_" + workShiftId + "_" + classify;
+        String key = "wsa_" + personScheduleId + "_" + workShiftId + "_" + classify;
 
+        try {
             boolean absent = valueOperations.setIfAbsent(key,true,1,TimeUnit.MINUTES);
 
             if(absent) {
@@ -715,6 +716,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
         }
         catch (Exception ex){
             log.error(ex.getMessage(),ex);
+            redisTemplate.delete(key);
         }
     }
 

+ 32 - 37
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -321,75 +321,70 @@
     </select>
     <select id="getDayAbnormalNum" resultType="java.lang.Integer">
         <![CDATA[
-
-                    select count(DISTINCT person_id) from base_person_device_filter_log
-                    where record_time >=#{startTime}
-                    and record_time <= #{endTime}
-                    and temperature_>#{temperatureMax}
-
+            select count(DISTINCT person_id) from base_person_device_filter_log
+            where record_time >=#{startTime}
+            and record_time <= #{endTime}
+            and temperature_>#{temperatureMax}
         ]]>
     </select>
     <select id="getDayAbnormalNumByCompanyList" resultType="Integer">
-        <![CDATA[
         select count(DISTINCT person_id) from base_person_device_filter_log a left join base_person_info b
         on a.person_id = b.id_
+        <foreach collection="list" index="index" item="item" open="and b.company_id in(" separator="," close=")">
+            #{item.id}
+        </foreach>
+        <![CDATA[
         where a.record_time >=#{startTime}
         and a.record_time <= #{endTime}
         and a.temperature_>#{temperatureMax}
-        ]]>
-        <foreach collection="list" index="index" item="item" open="and b.company_id in(" separator="," close=")">#{item.id}
-        </foreach>
         and a.del_flag = 0
+        ]]>
     </select>
 
     <select id="getDayCheckedPersonNumByCompanyList" resultType="Integer">
         select count(DISTINCT person_id) from base_person_device_log a left join base_person_info b
-        on a.person_id = b.id_
-        where a.record_time >=#{startTime}
-        and a.record_time &lt;= #{endTime}
-        and b.guest_enabled is not true
-        and b.company_id in
+        on a.person_id = b.id_ and b.company_id in
         <foreach collection="list" index="index" item="item" open="(" separator="," close=")">#{item.id}
         </foreach>
-        and a.del_flag = 0
-        and b.del_flag = 0
-        AND a.temperature_ > 0
         <if test="popedom!=null">
             and b.popedom_ like #{popedom}
         </if>
+        and b.guest_enabled is not true
+        and b.del_flag = 0
+        where a.record_time >=#{startTime}
+        and a.record_time &lt;= #{endTime}
+        and a.del_flag = 0
+        and a.temperature_ > 0
     </select>
 
     <select id="getDayNormalNumByCompanyId" resultType="Integer">
-        select count(DISTINCT person_id) from base_person_device_filter_log a left join base_person_info b
-        on a.person_id = b.id_
+        select count(DISTINCT person_id) from base_person_device_filter_log a
+        left join base_person_info b
+        on a.person_id = b.id_ and b.company_id = #{companyId}
         where a.record_time >=#{startTime}
         and a.record_time &lt;= #{endTime}
         and a.temperature_&lt;= #{temperatureMax}
-        and b.company_id = #{companyId}
         and a.del_flag = 0
     </select>
     <select id="countDayByPersonIdAndDate" resultType="Integer">
         <![CDATA[
-
-                    select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
-                    where a.person_id=#{personId}
-                    and a.record_time>=#{startDate}
-                    and a.record_time<#{endDate}
-                    and a.del_flag=0
-
+            select count(distinct(DATE_FORMAT(a.record_time,'%y-%m-%d'))) from base_person_device_filter_log a
+            where a.person_id=#{personId}
+            and a.record_time>=#{startDate}
+            and a.record_time<#{endDate}
+            and a.del_flag=0
         ]]>
     </select>
     <select id="countDetectedByCompanyId" resultType="int">
         <![CDATA[
-
-                    select count(distinct(a.person_id)) from base_person_device_filter_log a
-                    left join base_person_info b on a.person_id = b.id_
-                    where b.company_id=#{companyId}
-                    and a.record_time>=#{startDate}
-                    and a.record_time<#{endDate}
-                    and a.del_flag=0
-                    and b.del_flag=0
-
+            select count(distinct(a.person_id)) from base_person_device_filter_log a
+            left join base_person_info b
+            on a.person_id = b.id_ and b.company_id=#{companyId}
+            where
+            a.record_time>=#{startDate}
+            and a.record_time<#{endDate}
+            and a.del_flag=0
+            and b.del_flag=0
         ]]>
     </select>
     <select id="findUndetectedByCompanyCode"

+ 16 - 1
web/src/main/resources/logback-spring.xml

@@ -15,7 +15,20 @@
     <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
         <file>${loggerPath}/logfile.log</file>
         <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <fileNamePattern>${loggerPath}/logfile.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <fileNamePattern>${loggerPath}/log/logfile.%d{yyyy-MM-dd}.log</fileNamePattern>
+            <MaxHistory>30</MaxHistory>
+        </rollingPolicy>
+        <encoder>
+            <pattern>${pattern}</pattern>
+        </encoder>
+    </appender>
+    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>ERROR</level>
+        </filter>
+        <file>${loggerPath}/error/logfile.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${loggerPath}/error/logfile.%d{yyyy-MM-dd}.log</fileNamePattern>
             <MaxHistory>30</MaxHistory>
         </rollingPolicy>
         <encoder>
@@ -72,6 +85,7 @@
         <root level="WARN">
             <appender-ref ref="STDOUT" />
             <appender-ref ref="FILE" />
+            <appender-ref ref="ERROR_FILE" />
         </root>
         <logger name="com.jpsoft.ehome" level="${loggerLevel}" additivity="false" >
             <appender-ref ref="HK" />
@@ -84,6 +98,7 @@
         <root level="WARN">
             <appender-ref ref="STDOUT" />
             <appender-ref ref="FILE" />
+            <appender-ref ref="ERROR_FILE" />
         </root>
         <logger name="com.jpsoft.ehome" level="${loggerLevel}" additivity="false" >
             <appender-ref ref="HK" />