签到bug修复
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.ruoyi.oa.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.ruoyi.oa.domain.SysOaAttendance;
|
||||
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo;
|
||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
import com.ruoyi.oa.domain.vo.SysUserVo;
|
||||
@@ -22,4 +24,12 @@ public interface SysOaAttendanceMapper extends BaseMapperPlus<SysOaAttendanceMap
|
||||
int delOaAttendanceAll(@Param("firstDay") Date firstDay, @Param("lastDay")Date lastDay,@Param("day")Long day);
|
||||
|
||||
List<SysUserVo> selectUserListAndAttendanceListAndProjectListByUserIds(@Param("userIds") List<Long> userIds, @Param("firstDay") Date firstDay,@Param("lastDay") Date lastDay);
|
||||
|
||||
int updateDelAttendance(SysOaAttendance attendance);
|
||||
|
||||
List<SysOaAttendanceVo> queryListByTime(@Param("userId") Long userId,
|
||||
@Param("attendanceDay") Long attendanceDay,
|
||||
@Param("startTime") Date startTime,
|
||||
@Param("endTime") Date endTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
* 查询人员考勤
|
||||
*/
|
||||
@Override
|
||||
public SysOaAttendanceVo queryById(Long id){
|
||||
public SysOaAttendanceVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
@@ -95,23 +95,34 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
|
||||
BeanUtil.copyProperties(bo, sysOaAttendanceBo);
|
||||
sysOaAttendanceBo.setProjectId(null);
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = this.queryList(sysOaAttendanceBo);
|
||||
SysOaAttendance add = BeanUtil.toBean(bo, SysOaAttendance.class);
|
||||
validEntityBeforeSave(add);
|
||||
if (sysOaAttendanceVos.isEmpty()){
|
||||
// 如果这个时间为空,则默认查询当月记录
|
||||
Date firstDay;
|
||||
Date lastDay;
|
||||
if (Objects.isNull(bo.getSelectTime())) {
|
||||
firstDay = getFirstDay(new Date());
|
||||
|
||||
} else {
|
||||
firstDay = getFirstDay(bo.getSelectTime());
|
||||
}
|
||||
lastDay = getLastDay(firstDay);
|
||||
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = baseMapper.queryListByTime(sysOaAttendanceBo.getUserId(), sysOaAttendanceBo.getAttendanceDay(), firstDay, lastDay);
|
||||
|
||||
if (sysOaAttendanceVos.isEmpty()) {
|
||||
bo.setCreateTime(firstDay);
|
||||
SysOaAttendance add = BeanUtil.toBean(bo, SysOaAttendance.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}else{
|
||||
} else {
|
||||
SysOaAttendanceVo sysOaAttendanceVo = sysOaAttendanceVos.get(0);
|
||||
sysOaAttendanceVo.setProjectId(bo.getProjectId());
|
||||
boolean flag = baseMapper.updateById(BeanUtil.toBean(sysOaAttendanceVo, SysOaAttendance.class))>0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
sysOaAttendanceVo.setDelFlag(0L);
|
||||
|
||||
return baseMapper.updateDelAttendance(BeanUtil.toBean(sysOaAttendanceVo, SysOaAttendance.class)) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,7 +140,7 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SysOaAttendance entity){
|
||||
private void validEntityBeforeSave(SysOaAttendance entity) {
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
@@ -138,7 +149,7 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
if (isValid) {
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
@@ -150,15 +161,15 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
// 如果这个时间为空,则默认查询当月记录
|
||||
Date firstDay;
|
||||
Date lastDay;
|
||||
if (Objects.isNull(bo.getSelectTime())){
|
||||
if (Objects.isNull(bo.getSelectTime())) {
|
||||
firstDay = getFirstDay(new Date());
|
||||
|
||||
}else{
|
||||
} else {
|
||||
firstDay = getFirstDay(bo.getSelectTime());
|
||||
}
|
||||
lastDay = getLastDay(firstDay);
|
||||
Page<SysUserVo> result = new Page<>();
|
||||
result.setRecords(baseMapper.selectUserListAndAttendanceListAndProjectListByUserIds(userIds,firstDay,lastDay));
|
||||
result.setRecords(baseMapper.selectUserListAndAttendanceListAndProjectListByUserIds(userIds, firstDay, lastDay));
|
||||
|
||||
// 这个total写当月有多长时间
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
@@ -172,7 +183,7 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
public int insertBatch(SysOaAttendanceBo bo) {
|
||||
List<Long> userIds = sysUserRoleMapper.selectUserIdsByRoleId(1852970465740505090L);
|
||||
for (Long userId : userIds) {
|
||||
SysOaAttendanceBo sysOaAttendanceBo = BeanUtil.toBean(bo,SysOaAttendanceBo.class);
|
||||
SysOaAttendanceBo sysOaAttendanceBo = BeanUtil.toBean(bo, SysOaAttendanceBo.class);
|
||||
sysOaAttendanceBo.setUserId(userId);
|
||||
this.insertByBo(sysOaAttendanceBo);
|
||||
}
|
||||
@@ -200,20 +211,20 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
sysOaAttendanceVo.setUserId(sysUser.getUserId());
|
||||
|
||||
// 查询某月记录
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = baseMapper.selectVoListAndTime(userId, firstDay,lastDay);
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = baseMapper.selectVoListAndTime(userId, firstDay, lastDay);
|
||||
List<SysOaProjectVo> projectVos = new ArrayList<>();
|
||||
Double workTimes = 0.0;
|
||||
Double hourWorkTimes = 0.0;
|
||||
for (SysOaAttendanceVo oaAttendanceVo : sysOaAttendanceVos) {
|
||||
|
||||
// 出差问题解决
|
||||
if (oaAttendanceVo.getProjectId()!=0 && oaAttendanceVo.getProjectId()!=1){
|
||||
if (oaAttendanceVo.getProjectId() != 0 && oaAttendanceVo.getProjectId() != 1) {
|
||||
SysOaProjectVo sysOaProjectVo = projectService.queryById(oaAttendanceVo.getProjectId());
|
||||
oaAttendanceVo.setColor(sysOaProjectVo.getColor());
|
||||
oaAttendanceVo.setSysOaProjectVo(sysOaProjectVo);
|
||||
oaAttendanceVo.setProjectName(sysOaProjectVo.getProjectName());
|
||||
projectVos.add(sysOaProjectVo);
|
||||
workTimes+=oaAttendanceVo.getWorkTimes();
|
||||
workTimes += oaAttendanceVo.getWorkTimes();
|
||||
hourWorkTimes += oaAttendanceVo.getHourWorkTimes();
|
||||
}
|
||||
}
|
||||
@@ -228,12 +239,12 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
return costDataList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除当月某日所有人的记录
|
||||
*
|
||||
* @param day 日期
|
||||
* @return
|
||||
*/
|
||||
@@ -241,22 +252,23 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
public int delOaAttendanceAll(Long day) {
|
||||
|
||||
Date now = new Date();
|
||||
return baseMapper.delOaAttendanceAll(getFirstDay(now),getLastDay(now),day);
|
||||
return baseMapper.delOaAttendanceAll(getFirstDay(now), getLastDay(now), day);
|
||||
}
|
||||
|
||||
private Date getFirstDay(Date time){
|
||||
private Date getFirstDay(Date time) {
|
||||
String firstDay = DateUtils.parseDateToStr("yyyy-MM-01", time);
|
||||
return DateUtils.parseDate(firstDay);
|
||||
return DateUtils.parseDate(firstDay);
|
||||
}
|
||||
|
||||
private Date getLastDay(Date time){
|
||||
private Date getLastDay(Date time) {
|
||||
String format = "yyyy-MM-";
|
||||
// 计算某月的天数
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(time);
|
||||
String dateLength = String.valueOf(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
||||
// 将字符串拼接
|
||||
format +=dateLength;
|
||||
format += dateLength;
|
||||
format += " 23:59:59";
|
||||
|
||||
return DateUtils.parseDate(DateUtils.parseDateToStr(format, time));
|
||||
}
|
||||
|
||||
@@ -79,6 +79,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
|
||||
<update id="updateDelAttendance" parameterType="com.ruoyi.oa.domain.SysOaAttendance">
|
||||
update fad_oa.sys_oa_attendance
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="projectId != null and projectId!=''">project_id=#{projectId},</if>
|
||||
<if test="userId != null and userId!=''">user_id = #{userId},</if>
|
||||
<if test="attendanceDay != null and attendanceDay!=''">attendance_day = #{attendanceDay},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="dayLength != null and dayLength!=''">day_length = #{dayLength},</if>
|
||||
<if test="hour != null and hour!=''">hour = #{hour},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
|
||||
<select id="selectVoListAndTime" resultType="com.ruoyi.oa.domain.vo.SysOaAttendanceVo">
|
||||
select ANY_VALUE(id),
|
||||
@@ -126,6 +141,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and su.del_flag = '0'
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryListByTime" resultMap="SysOaAttendanceResult">
|
||||
SELECT id, user_id, attendance_day, project_id, day_length, hour, create_time, create_by, update_time, update_by, remark, del_flag
|
||||
FROM sys_oa_attendance
|
||||
WHERE create_time BETWEEN #{startTime} AND #{endTime}
|
||||
AND user_id = #{userId}
|
||||
AND attendance_day = #{attendanceDay}
|
||||
</select>
|
||||
|
||||
<delete id="delOaAttendanceAll">
|
||||
delete from sys_oa_attendance where
|
||||
attendance_day = #{day}
|
||||
|
||||
@@ -441,8 +441,10 @@ export default {
|
||||
const attendanceIndex = user.attendances.findIndex(
|
||||
(i) => i.attendanceDay === dayIndex
|
||||
);
|
||||
|
||||
if (attendanceIndex > -1) {
|
||||
const attendance = user.attendances[attendanceIndex];
|
||||
|
||||
// 如果存在签到记录,使用对应项目的颜色
|
||||
return {
|
||||
backgroundColor: attendance.color || '#fdf6e4',
|
||||
@@ -477,6 +479,7 @@ export default {
|
||||
projectId: 0,
|
||||
userId: this.selectUser.userId,
|
||||
attendanceDay: this.selectIndex,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
addOaAttendance(this.form).then(res => {
|
||||
this.getList()
|
||||
@@ -487,6 +490,7 @@ export default {
|
||||
this.form = {
|
||||
projectId: 0,
|
||||
attendanceDay: this.selectIndex,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
// 集体赋予状态
|
||||
addBatchOaAttendance(this.form).then(res => {
|
||||
@@ -501,6 +505,7 @@ export default {
|
||||
projectId: 1,
|
||||
userId: this.selectUser.userId,
|
||||
attendanceDay: this.selectIndex,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
addOaAttendance(this.form).then(res => {
|
||||
this.getList()
|
||||
@@ -511,6 +516,7 @@ export default {
|
||||
this.form = {
|
||||
projectId: 1,
|
||||
attendanceDay: this.selectIndex,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
// 集体赋予状态
|
||||
addBatchOaAttendance(this.form).then(res => {
|
||||
@@ -604,7 +610,6 @@ export default {
|
||||
this.$message({message: '请选择工作时长', type: 'warning'})
|
||||
return;
|
||||
}
|
||||
let time = this.timeFlag === 0 ? this.form.dayLength : this.form.hour
|
||||
|
||||
|
||||
if (!this.selectAll) {
|
||||
@@ -613,7 +618,8 @@ export default {
|
||||
userId: this.selectUser.userId,
|
||||
attendanceDay: this.selectIndex,
|
||||
dayLength: this.timeFlag === 0 ? this.form.dayLength : undefined,
|
||||
hour: this.timeFlag === 1 ? this.form.hour : undefined
|
||||
hour: this.timeFlag === 1 ? this.form.hour : undefined,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
addOaAttendance(this.form).then(res => {
|
||||
this.selectUser = this.selectArrayIndex >= this.userList.length - 1 ? this.selectUser : this.userList[this.selectArrayIndex + 1]
|
||||
@@ -625,7 +631,8 @@ export default {
|
||||
projectId: project.projectId,
|
||||
attendanceDay: this.selectIndex,
|
||||
dayLength: this.timeFlag === 0 ? this.form.dayLength : undefined,
|
||||
hour: this.timeFlag === 1 ? this.form.hour : undefined
|
||||
hour: this.timeFlag === 1 ? this.form.hour : undefined,
|
||||
selectTime:this.queryParams.selectTime
|
||||
}
|
||||
// 集体赋予状态
|
||||
addBatchOaAttendance(this.form).then(res => {
|
||||
|
||||
Reference in New Issue
Block a user