Commit d7a87cf4 authored by gaoyingwei's avatar gaoyingwei

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

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