Commit d7a87cf4 authored by gaoyingwei's avatar gaoyingwei

修改 考勤定时同步,用户加权重

parent 0e457e05
...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
@RestController @RestController
@RequestMapping("/attendance") @RequestMapping("/attendance")
...@@ -27,7 +28,7 @@ public class AttendanceController extends CyPaginationController<Attendance> { ...@@ -27,7 +28,7 @@ public class AttendanceController extends CyPaginationController<Attendance> {
@CyOpeLogAnno(title = "system-通行记录信息表管理-查询通行记录信息表", businessType = CyLogTypeEnum.QUERY) @CyOpeLogAnno(title = "system-通行记录信息表管理-查询通行记录信息表", businessType = CyLogTypeEnum.QUERY)
@ApiOperation(value = "查询通行记录信息表集合", notes = "查询通行记录信息表集合") @ApiOperation(value = "查询通行记录信息表集合", notes = "查询通行记录信息表集合")
@GetMapping(value = "/queryKQRecords") @GetMapping(value = "/queryKQRecords")
public CyResult queryKQRecords(Attendance attendance) { public CyResult queryKQRecords(Attendance attendance) throws ParseException {
return CyResultGenUtil.builder(new CyPersistModel(1), return CyResultGenUtil.builder(new CyPersistModel(1),
CyMessCons.MESSAGE_ALERT_SUCCESS, CyMessCons.MESSAGE_ALERT_SUCCESS,
CyMessCons.MESSAGE_ALERT_ERROR, CyMessCons.MESSAGE_ALERT_ERROR,
......
...@@ -78,15 +78,18 @@ public class AttendanceSyncSchedule { ...@@ -78,15 +78,18 @@ public class AttendanceSyncSchedule {
attendanceSync.setFlag(all.get(i).getKqFlag()); attendanceSync.setFlag(all.get(i).getKqFlag());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(all.get(i).getCrossTime()); attendanceSync.setPassageTime(all.get(i).getCrossTime());
if (attendanceSync.getFlag().equals("正常")) {
attendanceSync.setFlag("1");
} else if (attendanceSync.getFlag().equals("异常")) {
attendanceSync.setFlag("0");
}
// 判断考勤是否已经存在,已经存在不会添加 // 判断考勤是否已经存在,已经存在不会添加
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
if (attendanceSync.getFlag().equals("正常")) { wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
attendanceSync.setFlag("1"); wrapper.eq("user_id",attendanceSync.getUserId());
} else if (attendanceSync.getFlag().equals("异常")) { List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
attendanceSync.setFlag("0"); if(attendanceSyncList.size()==0)
}
attendanceSyncRepository.addAttendanceSync(attendanceSync); attendanceSyncRepository.addAttendanceSync(attendanceSync);
}
} }
} }
SysUser user = new SysUser(); SysUser user = new SysUser();
...@@ -115,11 +118,14 @@ public class AttendanceSyncSchedule { ...@@ -115,11 +118,14 @@ public class AttendanceSyncSchedule {
attendanceSync.setNltBzLabel(sysUser.getNltBzLabel()); attendanceSync.setNltBzLabel(sysUser.getNltBzLabel());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(null); attendanceSync.setPassageTime(null);
attendanceSync.setFlag("0");
// 判断考勤是否已经存在,已经存在不会添加 // 判断考勤是否已经存在,已经存在不会添加
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
attendanceSync.setFlag("0"); wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
wrapper.eq("user_id",attendanceSync.getUserId());
List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
if(attendanceSyncList.size()==0)
attendanceSyncRepository.addAttendanceSync(attendanceSync); attendanceSyncRepository.addAttendanceSync(attendanceSync);
}
} }
ScheduledResult scheduledResult = new ScheduledResult(); ScheduledResult scheduledResult = new ScheduledResult();
scheduledResult.setType("考勤同步"); scheduledResult.setType("考勤同步");
......
...@@ -4,6 +4,7 @@ import org.rcisoft.sys.attendance.entity.Attendance; ...@@ -4,6 +4,7 @@ import org.rcisoft.sys.attendance.entity.Attendance;
import org.rcisoft.sys.sysuser.entity.DoorRecord; import org.rcisoft.sys.sysuser.entity.DoorRecord;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.util.List; import java.util.List;
public interface AttendanceService { public interface AttendanceService {
...@@ -14,7 +15,7 @@ public interface AttendanceService { ...@@ -14,7 +15,7 @@ public interface AttendanceService {
* @param attendance * @param attendance
* @return * @return
*/ */
List<Attendance> findAll(Attendance attendance); List<Attendance> findAll(Attendance attendance) throws ParseException;
//查询全部考勤 //查询全部考勤
List<DoorRecord> findAllBy(Attendance attendance, HttpServletRequest request); List<DoorRecord> findAllBy(Attendance attendance, HttpServletRequest request);
......
...@@ -42,7 +42,7 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -42,7 +42,7 @@ public class AttendanceServiceImpl implements AttendanceService {
private CyJwtUtil cyJwtUtil; private CyJwtUtil cyJwtUtil;
@Override @Override
public List<Attendance> findAll(Attendance attendance) { public List<Attendance> findAll(Attendance attendance) throws ParseException {
List<Attendance> attendanceList = new ArrayList<>(); List<Attendance> attendanceList = new ArrayList<>();
// 根据时间范围筛选所有打卡成功的记录 // 根据时间范围筛选所有打卡成功的记录
// 获取前一天的时间 // 获取前一天的时间
...@@ -78,9 +78,10 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -78,9 +78,10 @@ public class AttendanceServiceImpl implements AttendanceService {
} }
// 整合考勤信息 // 整合考勤信息
public Attendance setValue(List<DoorRecord> records, Attendance attendance) { public Attendance setValue(List<DoorRecord> records, Attendance attendance) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat day = new SimpleDateFormat("yyyy-MM-dd");
attendance.setDuration(BigDecimal.ZERO); attendance.setDuration(BigDecimal.ZERO);
// 根据时间升序排序 // 根据时间升序排序
records = records.stream().sorted(Comparator.comparing(DoorRecord::getCrossTime)).collect(Collectors.toList()); records = records.stream().sorted(Comparator.comparing(DoorRecord::getCrossTime)).collect(Collectors.toList());
...@@ -100,10 +101,37 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -100,10 +101,37 @@ public class AttendanceServiceImpl implements AttendanceService {
attendance.setWorkDeviceName(work.getDeviceName()); attendance.setWorkDeviceName(work.getDeviceName());
attendance.setClosingTime(sdf.format(out.getCrossTime())); attendance.setClosingTime(sdf.format(out.getCrossTime()));
attendance.setOfficeDeviceName(out.getDeviceName()); attendance.setOfficeDeviceName(out.getDeviceName());
} else if (work != null) { //如果进数据存在,出数据为空,出站时间算23:59:59
String begin = time.format(work.getCrossTime());
String end = day.format(work.getCrossTime())+" 23:59:59";
if (begin.compareTo(end) > 0)
return null;
attendance.setWorkShift(sdf.format(work.getCrossTime()));
attendance.setWorkDeviceName(work.getDeviceName());
attendance.setClosingTime("23:59");
// attendance.setOfficeDeviceName(null);
} else if (out != null) { //如果进数据为空,出数据存在,入站时间算00:00:01
String begin = day.format(out.getCrossTime())+" 00:00:01";
String end = time.format(out.getCrossTime());
if (begin.compareTo(end) > 0)
return null;
attendance.setWorkShift("00:00");
// attendance.setWorkDeviceName(work.getDeviceName());
attendance.setClosingTime(sdf.format(out.getCrossTime()));
attendance.setOfficeDeviceName(out.getDeviceName());
} else } else
return null; return null;
Date beginTime = work.getCrossTime();
Date endTime = out.getCrossTime(); Date beginTime = null;
if (work != null)
beginTime = work.getCrossTime();
else
beginTime = time.parse(day.format(out.getCrossTime())+" 00:00:01");
Date endTime = null;
if (out != null)
endTime = out.getCrossTime();
else
endTime = time.parse(day.format(work.getCrossTime())+" 23:59:59");
long sumTime = 0l; long sumTime = 0l;
/* for (int i = 0; i < records.size(); i++) { /* for (int i = 0; i < records.size(); i++) {
if (records.get(i).getDeviceType().equals("1")) if (records.get(i).getDeviceType().equals("1"))
......
...@@ -100,15 +100,18 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos ...@@ -100,15 +100,18 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos
attendanceSync.setFlag(all.get(i).getKqFlag()); attendanceSync.setFlag(all.get(i).getKqFlag());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(all.get(i).getCrossTime()); attendanceSync.setPassageTime(all.get(i).getCrossTime());
if (attendanceSync.getFlag().equals("正常")) {
attendanceSync.setFlag("1");
} else if (attendanceSync.getFlag().equals("异常")) {
attendanceSync.setFlag("0");
}
// 判断考勤是否已经存在,已经存在不会添加 // 判断考勤是否已经存在,已经存在不会添加
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
if (attendanceSync.getFlag().equals("正常")) { wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
attendanceSync.setFlag("1"); wrapper.eq("user_id",attendanceSync.getUserId());
} else if (attendanceSync.getFlag().equals("异常")) { List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
attendanceSync.setFlag("0"); if(attendanceSyncList.size()==0)
}
attendanceSyncRepository.addAttendanceSync(attendanceSync); attendanceSyncRepository.addAttendanceSync(attendanceSync);
}
} }
} }
SysUser user = new SysUser(); SysUser user = new SysUser();
...@@ -137,11 +140,14 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos ...@@ -137,11 +140,14 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos
attendanceSync.setNltBzLabel(sysUser.getNltBzLabel()); attendanceSync.setNltBzLabel(sysUser.getNltBzLabel());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(null); attendanceSync.setPassageTime(null);
attendanceSync.setFlag("0");
// 判断考勤是否已经存在,已经存在不会添加 // 判断考勤是否已经存在,已经存在不会添加
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
attendanceSync.setFlag("0"); wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
wrapper.eq("user_id",attendanceSync.getUserId());
List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
if(attendanceSyncList.size()==0)
attendanceSyncRepository.addAttendanceSync(attendanceSync); attendanceSyncRepository.addAttendanceSync(attendanceSync);
}
} }
scheduledResult.setType("考勤同步"); scheduledResult.setType("考勤同步");
scheduledResult.setKqDate(TimeUtils.getDateNotTime(scheduledResult.getKqDate())); scheduledResult.setKqDate(TimeUtils.getDateNotTime(scheduledResult.getKqDate()));
...@@ -189,15 +195,18 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos ...@@ -189,15 +195,18 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos
attendanceSync.setFlag(all.get(i).getKqFlag()); attendanceSync.setFlag(all.get(i).getKqFlag());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(all.get(i).getCrossTime()); attendanceSync.setPassageTime(all.get(i).getCrossTime());
// 判断考勤是否已经存在,已经存在不会添加 if (attendanceSync.getFlag().equals("正常")) {
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { attendanceSync.setFlag("1");
if (attendanceSync.getFlag().equals("正常")) { } else if (attendanceSync.getFlag().equals("异常")) {
attendanceSync.setFlag("1"); attendanceSync.setFlag("0");
} else if (attendanceSync.getFlag().equals("异常")) {
attendanceSync.setFlag("0");
}
attendanceSyncRepository.addAttendanceSync(attendanceSync);
} }
// 判断考勤是否已经存在,已经存在不会添加
QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
wrapper.eq("user_id",attendanceSync.getUserId());
List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
if(attendanceSyncList.size()==0)
attendanceSyncRepository.addAttendanceSync(attendanceSync);
} }
} }
SysUser user = new SysUser(); SysUser user = new SysUser();
...@@ -229,18 +238,21 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos ...@@ -229,18 +238,21 @@ public class ScheduledResultServiceImpl extends ServiceImpl<ScheduledResultRepos
attendanceSync.setNltBzLabel(sysUser.getNltBzLabel()); attendanceSync.setNltBzLabel(sysUser.getNltBzLabel());
attendanceSync.setCreateDate(new Date()); attendanceSync.setCreateDate(new Date());
attendanceSync.setPassageTime(null); attendanceSync.setPassageTime(null);
// 判断考勤是否已经存在,已经存在不会添加 attendanceSync.setFlag("0");
if (attendanceSyncRepository.queryAttendanceSyncs(attendanceSync).size() == 0) { // 判断考勤是否已经存在,已经存在不会添加
attendanceSync.setFlag("0"); QueryWrapper<AttendanceSync> wrapper = new QueryWrapper();
wrapper.eq("date_of_attendance",attendanceSync.getDateOfAttendance());
wrapper.eq("user_id",attendanceSync.getUserId());
List<AttendanceSync> attendanceSyncList = attendanceSyncRepository.selectList(wrapper);
if(attendanceSyncList.size()==0)
attendanceSyncRepository.addAttendanceSync(attendanceSync); attendanceSyncRepository.addAttendanceSync(attendanceSync);
}
} }
} }
} }
return new CyPersistModel(1); return new CyPersistModel(1);
} }
List<Attendance> selectAttendanceList(Attendance attendance, ScheduledResult scheduledResult){ List<Attendance> selectAttendanceList(Attendance attendance, ScheduledResult scheduledResult) throws ParseException {
List<Attendance> attendanceList = new ArrayList<>(); List<Attendance> attendanceList = new ArrayList<>();
// 根据时间范围筛选所有打卡成功的记录 // 根据时间范围筛选所有打卡成功的记录
// 获取前一天的时间 // 获取前一天的时间
......
...@@ -67,7 +67,7 @@ public class SysUser extends CyIdIncreEntity<SysUser> { ...@@ -67,7 +67,7 @@ public class SysUser extends CyIdIncreEntity<SysUser> {
private String deptName; private String deptName;
//排序 //排序
@Transient // @Transient
private String sort; private String sort;
@Transient @Transient
......
...@@ -89,14 +89,15 @@ ...@@ -89,14 +89,15 @@
<if test="entity.nltBz != null and entity.nltBz != ''"> <if test="entity.nltBz != null and entity.nltBz != ''">
and attendance_sync.nlt_bz = #{entity.nltBz} and attendance_sync.nlt_bz = #{entity.nltBz}
</if> </if>
order by IF(ISNULL(sd.weight),1,0) , sd.weight, IF(ISNULL(su.sort),1,0) ,su.sort , attendance_sync.date_of_attendance desc ,
<if test="entity.sort == '0'.toString()"> <if test="entity.sort == '0'.toString()">
order by attendance_sync.date_of_attendance desc ,IF(ISNULL(sd.weight),1,0) , sd.weight, attendance_sync.work_hours desc attendance_sync.work_hours desc
</if> </if>
<if test="entity.sort == '1'.toString()"> <if test="entity.sort == '1'.toString()">
order by attendance_sync.date_of_attendance desc ,IF(ISNULL(sd.weight),1,0) , sd.weight, attendance_sync.off_hours desc attendance_sync.off_hours desc
</if> </if>
<if test="entity.sort == '2'.toString()"> <if test="entity.sort == '2'.toString()">
order by attendance_sync.date_of_attendance desc ,IF(ISNULL(sd.weight),1,0) , sd.weight, attendance_sync.time_on_job + 0 attendance_sync.time_on_job + 0
</if> </if>
</select> </select>
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<result column="address" jdbcType="VARCHAR" property="address"/> <result column="address" jdbcType="VARCHAR" property="address"/>
<result column="face_address" jdbcType="VARCHAR" property="faceAddress"/> <result column="face_address" jdbcType="VARCHAR" property="faceAddress"/>
<result column="blacklist_flag" jdbcType="VARCHAR" property="blacklistFlag"/> <result column="blacklist_flag" jdbcType="VARCHAR" property="blacklistFlag"/>
<result column="sort" jdbcType="BIGINT" property="sort"/>
<result column="positionLabel" jdbcType="VARCHAR" property="positionLabel"/> <result column="positionLabel" jdbcType="VARCHAR" property="positionLabel"/>
<result column="nltBzLabel" jdbcType="VARCHAR" property="nltBzLabel"/> <result column="nltBzLabel" jdbcType="VARCHAR" property="nltBzLabel"/>
<result column="deptName" jdbcType="VARCHAR" property="deptName"/> <result column="deptName" jdbcType="VARCHAR" property="deptName"/>
...@@ -240,6 +240,7 @@ ...@@ -240,6 +240,7 @@
<if test="addressLabel != null">address_label ,</if> <if test="addressLabel != null">address_label ,</if>
<if test="positionLabel != null">position_label ,</if> <if test="positionLabel != null">position_label ,</if>
<if test="nltBzLabel != null">nlt_bz_label ,</if> <if test="nltBzLabel != null">nlt_bz_label ,</if>
<if test="sort != null">sort ,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">#{username},</if> <if test="username != null">#{username},</if>
...@@ -260,6 +261,7 @@ ...@@ -260,6 +261,7 @@
<if test="addressLabel != null">#{addressLabel},</if> <if test="addressLabel != null">#{addressLabel},</if>
<if test="positionLabel != null">#{positionLabel},</if> <if test="positionLabel != null">#{positionLabel},</if>
<if test="nltBzLabel != null">#{nltBzLabel},</if> <if test="nltBzLabel != null">#{nltBzLabel},</if>
<if test="sort != null">#{sort},</if>
</trim> </trim>
</insert> </insert>
...@@ -287,6 +289,7 @@ ...@@ -287,6 +289,7 @@
<if test="addressLabel != null">address_label ,</if> <if test="addressLabel != null">address_label ,</if>
<if test="positionLabel != null">position_label ,</if> <if test="positionLabel != null">position_label ,</if>
<if test="nltBzLabel != null">nlt_bz_label ,</if> <if test="nltBzLabel != null">nlt_bz_label ,</if>
<if test="sort != null">sort ,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="username != null">#{username},</if> <if test="username != null">#{username},</if>
...@@ -310,6 +313,7 @@ ...@@ -310,6 +313,7 @@
<if test="addressLabel != null">#{addressLabel},</if> <if test="addressLabel != null">#{addressLabel},</if>
<if test="positionLabel != null">#{positionLabel},</if> <if test="positionLabel != null">#{positionLabel},</if>
<if test="nltBzLabel != null">#{nltBzLabel},</if> <if test="nltBzLabel != null">#{nltBzLabel},</if>
<if test="sort != null">#{sort},</if>
</trim> </trim>
</insert> </insert>
...@@ -339,6 +343,7 @@ ...@@ -339,6 +343,7 @@
<if test="entity.glFlag != null and entity.glFlag !=''">gl_flag = #{entity.glFlag},</if> <if test="entity.glFlag != null and entity.glFlag !=''">gl_flag = #{entity.glFlag},</if>
<if test="entity.addressLabel != null and entity.addressLabel !=''">address_label = #{entity.addressLabel} ,</if> <if test="entity.addressLabel != null and entity.addressLabel !=''">address_label = #{entity.addressLabel} ,</if>
<if test="entity.positionLabel != null and entity.positionLabel !=''">position_label = #{entity.positionLabel},</if> <if test="entity.positionLabel != null and entity.positionLabel !=''">position_label = #{entity.positionLabel},</if>
<if test="entity.sort != null and entity.sort !='' ">sort = #{entity.sort},</if>
</trim> </trim>
where business_id = #{entity.businessId} where business_id = #{entity.businessId}
</update> </update>
...@@ -355,7 +360,8 @@ ...@@ -355,7 +360,8 @@
position, position,
person_id, person_id,
nlt_bz, nlt_bz,
flag flag,
sort
from sys_user from sys_user
where del_flag = 0 where del_flag = 0
and business_id = #{businessId} and business_id = #{businessId}
......
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 to comment