Browse Source

1.考勤查询修改。

zhengqiang 5 years ago
parent
commit
9310dabb68

+ 1 - 3
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceFilterLogDAO.java

@@ -47,10 +47,8 @@ public interface PersonDeviceFilterLogDAO {
     PersonDeviceFilterLog get(Long id);
 
     long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status, Date startDate, Date endDate);
-
-    List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime);
-
     long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
 
+    List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime);
     List<PersonInfo> queryAttendanceList(String companyCode, Date startTime, Date endTime);
 }

+ 4 - 2
common/src/main/java/com/jpsoft/smart/modules/base/dao/PersonDeviceLogDAO.java

@@ -1,6 +1,7 @@
 package com.jpsoft.smart.modules.base.dao;
 
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
@@ -23,9 +24,10 @@ public interface PersonDeviceLogDAO {
 
     List<PersonDeviceLog> simpleSearch(Map<String, Object> searchParams, List<Sort> sortList);
 
-    List<PersonDeviceLog> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+    List<PersonDeviceLog> findByPersonAndDate(@Param("personId") Long personId, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
 
     PersonDeviceLog  get(String id);
 
-
+    List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime);
+    List<PersonInfo> queryAttendanceList(String companyCode, Date startTime, Date endTime);
 }

+ 0 - 4
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceFilterLogService.java

@@ -48,10 +48,6 @@ public interface PersonDeviceFilterLogService {
     PersonDeviceFilterLog get(Long id);
 
     long countByTimeRangeAndCompanyCode(String companyCode,Long personId,int status,Date startTime, Date endTime);
-
-    List<PersonInfo> queryUnAttendanceList(String companyId, Date startTime, Date endTime);
-
     long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime);
 
-    List<PersonInfo> queryAttendanceList(String companyCode, Date toDate, Date toDate1);
 }

+ 7 - 2
common/src/main/java/com/jpsoft/smart/modules/base/service/PersonDeviceLogService.java

@@ -1,7 +1,9 @@
 package com.jpsoft.smart.modules.base.service;
 
 import cn.hutool.json.JSONObject;
+import com.jpsoft.smart.modules.base.entity.PersonDeviceFilterLog;
 import com.jpsoft.smart.modules.base.entity.PersonDeviceLog;
+import com.jpsoft.smart.modules.base.entity.PersonInfo;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.github.pagehelper.Page;
 
@@ -28,8 +30,11 @@ public interface PersonDeviceLogService {
     void deviceInsertLog(String deviceNo, BigDecimal temperature, JSONObject faceImageJson, JSONObject libMatInfoListJson, JSONObject matchPersonInfo, Date date) ;
 
     Page<PersonDeviceLog> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
-    List<PersonDeviceLog> findByPersonAndDate(Long personId,String startDate,String endDate);
+    List<PersonDeviceLog> findByPersonAndDate(Long personId,Date startDate,Date endDate);
     Page<PersonDeviceLog> simplePageSearch(Map<String, Object> searchParams, int pageNum, int pageSize,boolean count, List<Sort> sortList);
-
     PersonDeviceLog get(String id);
+
+
+    List<PersonInfo> queryUnAttendanceList(String companyId, Date startTime, Date endTime);
+    List<PersonInfo> queryAttendanceList(String companyCode, Date toDate, Date toDate1);
 }

+ 0 - 10
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceFilterLogServiceImpl.java

@@ -198,16 +198,6 @@ public class PersonDeviceFilterLogServiceImpl implements PersonDeviceFilterLogSe
         return personDeviceFilterLogDAO.unusualStatistics(companyCode,personId,temperature,startDate,endDate);
     }
 
-    @Override
-    public List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime) {
-        return personDeviceFilterLogDAO.queryUnAttendanceList(companyCode,startTime,endTime);
-    }
-
-    @Override
-    public List<PersonInfo> queryAttendanceList(String companyCode, Date startTime, Date endTime) {
-        return personDeviceFilterLogDAO.queryAttendanceList(companyCode,startTime,endTime);
-    }
-
     @Override
     public long countUndetectedByCompanyCode(String companyCode,Long personId, Date startTime, Date endTime) {
         return personDeviceFilterLogDAO.countUndetectedByCompanyCode(companyCode,personId,startTime,endTime);

+ 12 - 1
common/src/main/java/com/jpsoft/smart/modules/base/service/impl/PersonDeviceLogServiceImpl.java

@@ -182,7 +182,18 @@ public class PersonDeviceLogServiceImpl implements PersonDeviceLogService {
     }
 
     @Override
-    public List<PersonDeviceLog> findByPersonAndDate(Long personId, String startDate, String endDate) {
+    public List<PersonDeviceLog> findByPersonAndDate(Long personId, Date startDate, Date endDate) {
         return personDeviceLogDAO.findByPersonAndDate(personId, startDate, endDate);
     }
+
+
+    @Override
+    public List<PersonInfo> queryUnAttendanceList(String companyCode, Date startTime, Date endTime) {
+        return personDeviceLogDAO.queryUnAttendanceList(companyCode,startTime,endTime);
+    }
+
+    @Override
+    public List<PersonInfo> queryAttendanceList(String companyCode, Date startTime, Date endTime) {
+        return personDeviceLogDAO.queryAttendanceList(companyCode,startTime,endTime);
+    }
 }

+ 15 - 0
common/src/main/java/com/jpsoft/smart/modules/business/entity/WorkAttendance.java

@@ -87,4 +87,19 @@ public class WorkAttendance {
      */
     @ApiModelProperty(value = "人员编号")
     private Long personId;
+
+    /**
+     * 记录时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
+    @ApiModelProperty(value = "记录时间")
+    private Date recordTime;
+
+
+    /**
+     * 记录温度
+     */
+    @ApiModelProperty(value = "记录温度")
+    private BigDecimal temperature;
 }

+ 0 - 24
common/src/main/resources/mapper/base/PersonDeviceFilterLog.xml

@@ -276,30 +276,6 @@
         ]]>
         </if>
     </select>
-    <select id="queryUnAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
-    <![CDATA[
-        select * from base_person_info a,base_company_info b
-        where a.company_id=b.id_ and b.code_ like #{companyCode}
-        and a.del_flag=0
-        and a.id_ not in (
-            select person_id from base_person_device_filter_log
-            where record_time>=#{startTime}
-            and record_time <= #{endTime}
-        )
-    ]]>
-    </select>
-    <select id="queryAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
-    <![CDATA[
-        select a.* from base_person_info a,base_company_info b,base_person_device_filter_log c
-        where a.company_id=b.id_
-        and b.code_ like #{companyCode}
-        and a.del_flag=0
-        and a.id_ = c.person_id
-        and c.record_time>=#{startTime}
-        and c.record_time<=#{endTime}
-        and c.del_flag=0
-    ]]>
-    </select>
     <select id="countUndetectedByCompanyCode" resultType="long">
         <![CDATA[
             select count(*) from base_person_info a,base_company_info b

+ 25 - 2
common/src/main/resources/mapper/base/PersonDeviceLog.xml

@@ -99,7 +99,7 @@
 		<![CDATA[
            and record_time >= #{startDate} and record_time <= #{endDate}
         ]]>
-        order by record_time desc
+        order by record_time asc
 	</select>
 
     <select id="search" parameterType="hashmap" resultMap="PersonDeviceLogMap">
@@ -164,5 +164,28 @@
     <select id="get" resultMap="SimpleMap">
         select * from base_person_device_log where id_=#{0}
     </select>
-
+    <select id="queryUnAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
+        <![CDATA[
+        select a.* from base_person_info a,base_company_info b
+        where a.company_id=b.id_ and b.code_ like #{companyCode}
+        and a.del_flag=0
+        and a.id_ not in (
+            select person_id from base_person_device_log
+            where record_time>=#{startTime}
+            and record_time <= #{endTime}
+        )
+    ]]>
+    </select>
+    <select id="queryAttendanceList" resultMap="com.jpsoft.smart.modules.base.dao.PersonInfoDAO.PersonInfoMap">
+        <![CDATA[
+        select a.* from base_person_info a,base_company_info b,base_person_device_log c
+        where a.company_id=b.id_
+        and b.code_ like #{companyCode}
+        and a.del_flag=0
+        and a.id_ = c.person_id
+        and c.record_time>=#{startTime}
+        and c.record_time<=#{endTime}
+        and c.del_flag=0
+    ]]>
+    </select>
 </mapper>

+ 10 - 1
common/src/main/resources/mapper/business/WorkAttendance.xml

@@ -8,6 +8,7 @@
         <result property="alarmConfigId" column="alarm_config_id"/>
         <result property="personId" column="person_id"/>
         <result property="result" column="result_"/>
+        <result property="temperature" column="temperature_"/>
         <result property="createBy" column="create_by"/>
         <result property="createTime" column="create_time"/>
         <result property="updateBy" column="update_by"/>
@@ -22,7 +23,7 @@
         -->
         <![CDATA[
 		insert into business_work_attendance
-	    (id_,alarm_config_id,person_id,result_,create_by,create_time,update_by,update_time,del_flag)
+	    (id_,alarm_config_id,person_id,result_,create_by,create_time,update_by,update_time,del_flag,record_time,temperature_)
 		values
 		(
 			#{id,jdbcType=VARCHAR}
@@ -34,6 +35,8 @@
 			,#{updateBy,jdbcType=VARCHAR}
 			,#{updateTime,jdbcType= TIMESTAMP }
 			,#{delFlag,jdbcType= NUMERIC }
+			,#{recordTime,jdbcType= TIMESTAMP }
+			,#{temperature,jdbcType= NUMERIC }
 		)
 	]]>
     </insert>
@@ -67,6 +70,12 @@
             <if test="delFlag!=null">
                 del_flag=#{delFlag,jdbcType= NUMERIC },
             </if>
+            <if test="recordTime!=null">
+                record_time=#{recordTime,jdbcType= TIMESTAMP },
+            </if>
+            <if test="temperature_!=null">
+                temperature_=#{temperature,jdbcType= NUMERIC },
+            </if>
         </set>
         where id_=#{id}
     </update>

+ 5 - 5
web/src/main/java/com/jpsoft/smart/modules/mobile/controller/PersonDeviceFilterLogController.java

@@ -3,10 +3,7 @@ package com.jpsoft.smart.modules.mobile.controller;
 import com.github.pagehelper.Page;
 import com.jpsoft.smart.modules.base.dto.PersonDeviceFilterLogDTO;
 import com.jpsoft.smart.modules.base.entity.*;
-import com.jpsoft.smart.modules.base.service.AlarmConfigService;
-import com.jpsoft.smart.modules.base.service.DeviceInfoService;
-import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
-import com.jpsoft.smart.modules.base.service.PersonInfoService;
+import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.common.dto.MessageResult;
 import com.jpsoft.smart.modules.common.dto.Sort;
 import com.jpsoft.smart.modules.common.utils.PojoUtils;
@@ -32,6 +29,9 @@ public class PersonDeviceFilterLogController {
     @Autowired
     private PersonDeviceFilterLogService personDeviceFilterLogService;
 
+    @Autowired
+    private PersonDeviceLogService personDeviceLogService;
+
     @Autowired
     private DeviceInfoService deviceInfoService;
 
@@ -186,7 +186,7 @@ public class PersonDeviceFilterLogController {
                 DateTime startTime = new DateTime(sdf.parse(dateStr + " " + alarmConfig.getStartTime()));
                 DateTime endTime = new DateTime(sdf.parse(dateStr + " " + alarmConfig.getEndTime()));
 
-                List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnAttendanceList(personInfo.getCompanyId(),startTime.toDate(),endTime.toDate());
+                List<PersonInfo> unmeasuredList = personDeviceLogService.queryUnAttendanceList(personInfo.getCompanyId(),startTime.toDate(),endTime.toDate());
 
                 map.put("startTime",alarmConfig.getStartTime());
                 map.put("endTime",alarmConfig.getEndTime());

+ 26 - 9
web/src/main/java/com/jpsoft/smart/schduled/UnmeasureTemperatureAlarmTask.java

@@ -2,10 +2,7 @@ package com.jpsoft.smart.schduled;
 
 import com.jpsoft.smart.config.WxConfig;
 import com.jpsoft.smart.modules.base.entity.*;
-import com.jpsoft.smart.modules.base.service.AlarmConfigService;
-import com.jpsoft.smart.modules.base.service.CompanyInfoService;
-import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
-import com.jpsoft.smart.modules.base.service.WarningPusherService;
+import com.jpsoft.smart.modules.base.service.*;
 import com.jpsoft.smart.modules.business.entity.WorkAttendance;
 import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
 import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
@@ -41,6 +38,9 @@ public class UnmeasureTemperatureAlarmTask {
     @Autowired
     private WorkAttendanceService workAttendanceService;
 
+    @Autowired
+    private PersonDeviceLogService personDeviceLogService;
+
     @Autowired
     private WxConfig wxConfig;
 
@@ -138,7 +138,7 @@ public class UnmeasureTemperatureAlarmTask {
         }
 
         //todo 查询该单位当前时间段未考勤人员列表
-        List<PersonInfo> attendanceList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startDate,endDate);
+        List<PersonInfo> attendanceList = personDeviceLogService.queryUnAttendanceList(companyCode,startDate,endDate);
 
         for (PersonInfo personInfo: attendanceList) {
             WorkAttendance workAttendance = new WorkAttendance();
@@ -167,9 +167,9 @@ public class UnmeasureTemperatureAlarmTask {
         }
 
         //todo 查询该单位当前时间段考勤人员列表
-        List<PersonInfo> unAttendanceList = personDeviceFilterLogService.queryAttendanceList(companyCode,startDate,endDate);
+        List<PersonInfo> attendanceList = personDeviceLogService.queryAttendanceList(companyCode,startDate,endDate);
 
-        for (PersonInfo personInfo: unAttendanceList) {
+        for (PersonInfo personInfo: attendanceList) {
             WorkAttendance workAttendance = new WorkAttendance();
             workAttendance.setId(UUID.randomUUID().toString());
             workAttendance.setPersonId(personInfo.getId());
@@ -177,6 +177,23 @@ public class UnmeasureTemperatureAlarmTask {
             workAttendance.setCreateTime(new Date());
             workAttendance.setResult(result);
 
+            List<PersonDeviceLog> logList = personDeviceLogService.findByPersonAndDate(personInfo.getId(),startDate,endDate);
+
+            if (logList.size()>0) {
+                PersonDeviceLog personDeviceLog = null;
+
+                if (alarmConfig.getClassifier().equals(1)) {
+                    //上班算最早一次考勤
+                    personDeviceLog = logList.get(0);
+                } else {
+                    //下班算最迟一次考勤
+                    personDeviceLog = logList.get(logList.size()-1);
+                }
+
+                workAttendance.setRecordTime(personDeviceLog.getRecordTime());
+                workAttendance.setTemperature(personDeviceLog.getTemperature());
+            }
+
             workAttendanceService.insert(workAttendance);
         }
     }
@@ -192,7 +209,7 @@ public class UnmeasureTemperatureAlarmTask {
         }
 
         //todo 查询该单位当前时间段是否有人员未测体温
-        List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
+        List<PersonInfo> unmeasuredList = personDeviceLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
 
         if (unmeasuredList.size()==0){
             return;
@@ -222,7 +239,7 @@ public class UnmeasureTemperatureAlarmTask {
         }
 
         //todo 查询该单位当前时间段是否有人员未测体温
-        List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
+        List<PersonInfo> unmeasuredList = personDeviceLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
 
         if (unmeasuredList.size()==0){
             return;