浏览代码

每次打卡记录与考勤时间的偏差。

zhengqiang 4 年之前
父节点
当前提交
a491824993

+ 3 - 1
common/src/main/java/com/jpsoft/shinestar/modules/business/entity/WorkScheduleAttendance.java

@@ -112,7 +112,6 @@ public class WorkScheduleAttendance {
     @ApiModelProperty(value = "班次编号")
     @ApiModelProperty(value = "班次编号")
     private String workShiftNumber;
     private String workShiftNumber;
 
 
-
     @ApiModelProperty(value = "补卡对应人员id")
     @ApiModelProperty(value = "补卡对应人员id")
     private String supplementWorkPersonId;
     private String supplementWorkPersonId;
 
 
@@ -125,6 +124,9 @@ public class WorkScheduleAttendance {
     @ApiModelProperty(value = "加班人员表主键")
     @ApiModelProperty(value = "加班人员表主键")
     private String workOverPersonId;
     private String workOverPersonId;
 
 
+    @ApiModelProperty(value = "与考勤时间相差分钟")
+    private BigDecimal offsetMinute;
+
     @Transient
     @Transient
     private WorkOverPerson workOverPerson;
     private WorkOverPerson workOverPerson;
 }
 }

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

@@ -19,12 +19,13 @@ import com.jpsoft.shinestar.modules.common.utils.StringUtils;
 import com.jpsoft.shinestar.modules.common.utils.WechatMessageUtil;
 import com.jpsoft.shinestar.modules.common.utils.WechatMessageUtil;
 import com.jpsoft.shinestar.modules.sys.entity.DataDictionary;
 import com.jpsoft.shinestar.modules.sys.entity.DataDictionary;
 import com.jpsoft.shinestar.modules.sys.service.DataDictionaryService;
 import com.jpsoft.shinestar.modules.sys.service.DataDictionaryService;
-import com.sun.corba.se.spi.orbutil.threadpool.Work;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.joda.time.DateTime;
 import org.joda.time.DateTime;
 import org.joda.time.Days;
 import org.joda.time.Days;
 import org.joda.time.Hours;
 import org.joda.time.Hours;
 import org.joda.time.Minutes;
 import org.joda.time.Minutes;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.data.redis.core.ValueOperations;
@@ -611,6 +612,33 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
     private void saveWorkAttendance(Long personId, BigDecimal temperature, Date recordTime, String attendanceDate,
     private void saveWorkAttendance(Long personId, BigDecimal temperature, Date recordTime, String attendanceDate,
                                     String personScheduleId, String workShiftId, String result, Integer minutes,
                                     String personScheduleId, String workShiftId, String result, Integer minutes,
                                     String classify, String workStatus, WorkOverPerson workOverPerson) {
                                     String classify, String workStatus, WorkOverPerson workOverPerson) {
+        long offsetMinute = 0;
+
+        try {
+            WorkShiftInfo workShiftInfo = workShiftInfoService.get(workShiftId);
+
+            if (workShiftInfo != null) {
+                DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
+
+                if ("1".equals(classify)) {
+                    //上班
+                    DateTime workTime = DateTime.parse(attendanceDate + " " + workShiftInfo.getWorkTime(), formatter);
+                    workTime = workTime.plusDays(workShiftInfo.getWorkDayType());
+
+                    offsetMinute = Minutes.minutesBetween(new DateTime(recordTime), workTime).getMinutes();
+                } else {
+                    //下班
+                    DateTime closingTime = DateTime.parse(attendanceDate + " " + workShiftInfo.getClosingTime(), formatter);
+                    closingTime = closingTime.plusDays(workShiftInfo.getClosingDayType());
+
+                    offsetMinute = Minutes.minutesBetween(new DateTime(recordTime), closingTime).getMinutes();
+                }
+            }
+        }
+        catch (Exception ex){
+            log.error(ex.getMessage(),ex);
+        }
+
         WorkScheduleAttendance workEndAttendance = new WorkScheduleAttendance();
         WorkScheduleAttendance workEndAttendance = new WorkScheduleAttendance();
 
 
         List<WorkScheduleAttendance> attendanceList = workScheduleAttendanceDAO.findByPersonScheduleIdAndClassify(personScheduleId, workShiftId, classify);
         List<WorkScheduleAttendance> attendanceList = workScheduleAttendanceDAO.findByPersonScheduleIdAndClassify(personScheduleId, workShiftId, classify);
@@ -629,6 +657,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
             workEndAttendance.setTemperature(temperature);
             workEndAttendance.setTemperature(temperature);
             workEndAttendance.setRecordTime(recordTime);
             workEndAttendance.setRecordTime(recordTime);
             workEndAttendance.setCreateTime(new Date());
             workEndAttendance.setCreateTime(new Date());
+            workEndAttendance.setOffsetMinute(new BigDecimal(offsetMinute));
 
 
             if(workOverPerson!=null){
             if(workOverPerson!=null){
                 workEndAttendance.setWorkOverPersonId(workOverPerson.getId());
                 workEndAttendance.setWorkOverPersonId(workOverPerson.getId());
@@ -645,6 +674,7 @@ public class WorkScheduleAttendanceServiceImpl implements WorkScheduleAttendance
             workEndAttendance.setTemperature(temperature);
             workEndAttendance.setTemperature(temperature);
             workEndAttendance.setRecordTime(recordTime);
             workEndAttendance.setRecordTime(recordTime);
             workEndAttendance.setUpdateTime(new Date());
             workEndAttendance.setUpdateTime(new Date());
+            workEndAttendance.setOffsetMinute(new BigDecimal(offsetMinute));
 
 
             if(workOverPerson!=null){
             if(workOverPerson!=null){
                 workEndAttendance.setWorkOverPersonId(workOverPerson.getId());
                 workEndAttendance.setWorkOverPersonId(workOverPerson.getId());

+ 6 - 1
common/src/main/resources/mapper/business/WorkScheduleAttendance.xml

@@ -26,6 +26,7 @@
         <result property="lateLeaveMinute" column="late_leave_minute"/>
         <result property="lateLeaveMinute" column="late_leave_minute"/>
         <result property="coefficientDays" column="coefficient_days"/>
         <result property="coefficientDays" column="coefficient_days"/>
         <result property="workOverPersonId" column="work_over_person_id"/>
         <result property="workOverPersonId" column="work_over_person_id"/>
+        <result property="offsetMinute" column="offset_minute"/>
     </resultMap>
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.shinestar.modules.business.entity.WorkScheduleAttendance">
     <insert id="insert" parameterType="com.jpsoft.shinestar.modules.business.entity.WorkScheduleAttendance">
         <!--
         <!--
@@ -37,7 +38,7 @@
 		insert into business_work_schedule_attendance
 		insert into business_work_schedule_attendance
 	    (id_,person_schedule_id,work_shift_id,attendance_date,classify_,person_id,result_,temperature_,
 	    (id_,person_schedule_id,work_shift_id,attendance_date,classify_,person_id,result_,temperature_,
 	    record_time,create_by,create_time,update_by,update_time,del_flag,work_status,remark_,supplement_work_person_id,
 	    record_time,create_by,create_time,update_by,update_time,del_flag,work_status,remark_,supplement_work_person_id,
-	    late_leave_minute,work_over_person_id)
+	    late_leave_minute,work_over_person_id,offset_minute)
 		values
 		values
 		(
 		(
             #{id,jdbcType=VARCHAR}
             #{id,jdbcType=VARCHAR}
@@ -59,6 +60,7 @@
             ,#{supplementWorkPersonId,jdbcType=VARCHAR}
             ,#{supplementWorkPersonId,jdbcType=VARCHAR}
             ,#{lateLeaveMinute,jdbcType=NUMERIC}
             ,#{lateLeaveMinute,jdbcType=NUMERIC}
             ,#{workOverPersonId,jdbcType=VARCHAR}
             ,#{workOverPersonId,jdbcType=VARCHAR}
+            ,#{offsetMinute,jdbcType=NUMERIC}
 		)
 		)
 	]]>
 	]]>
     </insert>
     </insert>
@@ -122,6 +124,9 @@
             <if test="workOverPersonId!=null">
             <if test="workOverPersonId!=null">
                 work_over_person_id=#{workOverPersonId, jdbcType=NUMERIC},
                 work_over_person_id=#{workOverPersonId, jdbcType=NUMERIC},
             </if>
             </if>
+            <if test="offsetMinute!=null">
+                offset_minute=#{offsetMinute,jdbcType=NUMERIC},
+            </if>
         </set>
         </set>
         where id_=#{id}
         where id_=#{id}
     </update>
     </update>