签到bug修复
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
package com.ruoyi.oa.mapper;
|
package com.ruoyi.oa.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||||
import com.ruoyi.oa.domain.SysOaAttendance;
|
import com.ruoyi.oa.domain.SysOaAttendance;
|
||||||
|
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo;
|
||||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||||
import com.ruoyi.oa.domain.vo.SysUserVo;
|
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);
|
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);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,10 +95,23 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
|||||||
|
|
||||||
BeanUtil.copyProperties(bo, sysOaAttendanceBo);
|
BeanUtil.copyProperties(bo, sysOaAttendanceBo);
|
||||||
sysOaAttendanceBo.setProjectId(null);
|
sysOaAttendanceBo.setProjectId(null);
|
||||||
List<SysOaAttendanceVo> sysOaAttendanceVos = this.queryList(sysOaAttendanceBo);
|
// 如果这个时间为空,则默认查询当月记录
|
||||||
|
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);
|
SysOaAttendance add = BeanUtil.toBean(bo, SysOaAttendance.class);
|
||||||
validEntityBeforeSave(add);
|
validEntityBeforeSave(add);
|
||||||
if (sysOaAttendanceVos.isEmpty()){
|
|
||||||
boolean flag = baseMapper.insert(add) > 0;
|
boolean flag = baseMapper.insert(add) > 0;
|
||||||
if (flag) {
|
if (flag) {
|
||||||
bo.setId(add.getId());
|
bo.setId(add.getId());
|
||||||
@@ -107,11 +120,9 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
|||||||
} else {
|
} else {
|
||||||
SysOaAttendanceVo sysOaAttendanceVo = sysOaAttendanceVos.get(0);
|
SysOaAttendanceVo sysOaAttendanceVo = sysOaAttendanceVos.get(0);
|
||||||
sysOaAttendanceVo.setProjectId(bo.getProjectId());
|
sysOaAttendanceVo.setProjectId(bo.getProjectId());
|
||||||
boolean flag = baseMapper.updateById(BeanUtil.toBean(sysOaAttendanceVo, SysOaAttendance.class))>0;
|
sysOaAttendanceVo.setDelFlag(0L);
|
||||||
if (flag) {
|
|
||||||
bo.setId(add.getId());
|
return baseMapper.updateDelAttendance(BeanUtil.toBean(sysOaAttendanceVo, SysOaAttendance.class)) > 0;
|
||||||
}
|
|
||||||
return flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -228,12 +239,12 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return costDataList;
|
return costDataList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除当月某日所有人的记录
|
* 删除当月某日所有人的记录
|
||||||
|
*
|
||||||
* @param day 日期
|
* @param day 日期
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -257,6 +268,7 @@ public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
|||||||
String dateLength = String.valueOf(calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
|
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));
|
return DateUtils.parseDate(DateUtils.parseDateToStr(format, time));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</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 id="selectVoListAndTime" resultType="com.ruoyi.oa.domain.vo.SysOaAttendanceVo">
|
||||||
select ANY_VALUE(id),
|
select ANY_VALUE(id),
|
||||||
@@ -126,6 +141,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and su.del_flag = '0'
|
and su.del_flag = '0'
|
||||||
</select>
|
</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 id="delOaAttendanceAll">
|
||||||
delete from sys_oa_attendance where
|
delete from sys_oa_attendance where
|
||||||
attendance_day = #{day}
|
attendance_day = #{day}
|
||||||
|
|||||||
@@ -441,8 +441,10 @@ export default {
|
|||||||
const attendanceIndex = user.attendances.findIndex(
|
const attendanceIndex = user.attendances.findIndex(
|
||||||
(i) => i.attendanceDay === dayIndex
|
(i) => i.attendanceDay === dayIndex
|
||||||
);
|
);
|
||||||
|
|
||||||
if (attendanceIndex > -1) {
|
if (attendanceIndex > -1) {
|
||||||
const attendance = user.attendances[attendanceIndex];
|
const attendance = user.attendances[attendanceIndex];
|
||||||
|
|
||||||
// 如果存在签到记录,使用对应项目的颜色
|
// 如果存在签到记录,使用对应项目的颜色
|
||||||
return {
|
return {
|
||||||
backgroundColor: attendance.color || '#fdf6e4',
|
backgroundColor: attendance.color || '#fdf6e4',
|
||||||
@@ -477,6 +479,7 @@ export default {
|
|||||||
projectId: 0,
|
projectId: 0,
|
||||||
userId: this.selectUser.userId,
|
userId: this.selectUser.userId,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
|
selectTime:this.queryParams.selectTime
|
||||||
}
|
}
|
||||||
addOaAttendance(this.form).then(res => {
|
addOaAttendance(this.form).then(res => {
|
||||||
this.getList()
|
this.getList()
|
||||||
@@ -487,6 +490,7 @@ export default {
|
|||||||
this.form = {
|
this.form = {
|
||||||
projectId: 0,
|
projectId: 0,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
|
selectTime:this.queryParams.selectTime
|
||||||
}
|
}
|
||||||
// 集体赋予状态
|
// 集体赋予状态
|
||||||
addBatchOaAttendance(this.form).then(res => {
|
addBatchOaAttendance(this.form).then(res => {
|
||||||
@@ -501,6 +505,7 @@ export default {
|
|||||||
projectId: 1,
|
projectId: 1,
|
||||||
userId: this.selectUser.userId,
|
userId: this.selectUser.userId,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
|
selectTime:this.queryParams.selectTime
|
||||||
}
|
}
|
||||||
addOaAttendance(this.form).then(res => {
|
addOaAttendance(this.form).then(res => {
|
||||||
this.getList()
|
this.getList()
|
||||||
@@ -511,6 +516,7 @@ export default {
|
|||||||
this.form = {
|
this.form = {
|
||||||
projectId: 1,
|
projectId: 1,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
|
selectTime:this.queryParams.selectTime
|
||||||
}
|
}
|
||||||
// 集体赋予状态
|
// 集体赋予状态
|
||||||
addBatchOaAttendance(this.form).then(res => {
|
addBatchOaAttendance(this.form).then(res => {
|
||||||
@@ -604,7 +610,6 @@ export default {
|
|||||||
this.$message({message: '请选择工作时长', type: 'warning'})
|
this.$message({message: '请选择工作时长', type: 'warning'})
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let time = this.timeFlag === 0 ? this.form.dayLength : this.form.hour
|
|
||||||
|
|
||||||
|
|
||||||
if (!this.selectAll) {
|
if (!this.selectAll) {
|
||||||
@@ -613,7 +618,8 @@ export default {
|
|||||||
userId: this.selectUser.userId,
|
userId: this.selectUser.userId,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
dayLength: this.timeFlag === 0 ? this.form.dayLength : undefined,
|
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 => {
|
addOaAttendance(this.form).then(res => {
|
||||||
this.selectUser = this.selectArrayIndex >= this.userList.length - 1 ? this.selectUser : this.userList[this.selectArrayIndex + 1]
|
this.selectUser = this.selectArrayIndex >= this.userList.length - 1 ? this.selectUser : this.userList[this.selectArrayIndex + 1]
|
||||||
@@ -625,7 +631,8 @@ export default {
|
|||||||
projectId: project.projectId,
|
projectId: project.projectId,
|
||||||
attendanceDay: this.selectIndex,
|
attendanceDay: this.selectIndex,
|
||||||
dayLength: this.timeFlag === 0 ? this.form.dayLength : undefined,
|
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 => {
|
addBatchOaAttendance(this.form).then(res => {
|
||||||
|
|||||||
Reference in New Issue
Block a user