考勤功能完成
This commit is contained in:
@@ -157,6 +157,7 @@ public class SysUser extends BaseEntity {
|
||||
|
||||
private Long laborCost;
|
||||
|
||||
|
||||
/**
|
||||
* 数据权限 当前角色ID
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.ruoyi.oa.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.ruoyi.oa.domain.vo.SysUserVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import com.ruoyi.common.annotation.RepeatSubmit;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo;
|
||||
import com.ruoyi.oa.service.ISysOaAttendanceService;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 人员考勤
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/oa/oaAttendance")
|
||||
public class SysOaAttendanceController extends BaseController {
|
||||
|
||||
private final ISysOaAttendanceService iSysOaAttendanceService;
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysOaAttendanceVo> list(SysOaAttendanceBo bo, PageQuery pageQuery) {
|
||||
return iSysOaAttendanceService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:list")
|
||||
@GetMapping("/worker/list")
|
||||
public R<List<SysUserVo>> workerList(SysOaAttendanceBo bo) {
|
||||
|
||||
return R.ok(iSysOaAttendanceService.workerList(bo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出人员考勤列表
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:export")
|
||||
@Log(title = "人员考勤", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(SysOaAttendanceBo bo, HttpServletResponse response) {
|
||||
List<SysOaAttendanceVo> list = iSysOaAttendanceService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "人员考勤", SysOaAttendanceVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取人员考勤详细信息
|
||||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:query")
|
||||
@GetMapping("/{id}")
|
||||
public R<SysOaAttendanceVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long id) {
|
||||
return R.ok(iSysOaAttendanceService.queryById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增人员考勤
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:add")
|
||||
@Log(title = "人员考勤", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody SysOaAttendanceBo bo) {
|
||||
return toAjax(iSysOaAttendanceService.insertByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改人员考勤
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:edit")
|
||||
@Log(title = "人员考勤", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody SysOaAttendanceBo bo) {
|
||||
return toAjax(iSysOaAttendanceService.updateByBo(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除人员考勤
|
||||
*
|
||||
* @param ids 主键串
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:remove")
|
||||
@Log(title = "人员考勤", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(iSysOaAttendanceService.deleteWithValidByIds(Arrays.asList(ids), true));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增人员考勤
|
||||
*/
|
||||
@SaCheckPermission("system:oaAttendance:add")
|
||||
@Log(title = "人员考勤", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping("/insertBatch")
|
||||
public R<Void> insertBatch(@Validated(AddGroup.class) @RequestBody SysOaAttendanceBo bo) {
|
||||
return toAjax( iSysOaAttendanceService.insertBatch(bo));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ruoyi.oa.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 人员考勤对象 sys_oa_attendance
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_oa_attendance")
|
||||
public class SysOaAttendance extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
private Long id;
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long userId;
|
||||
/**
|
||||
* 签到日
|
||||
*/
|
||||
private Long attendanceDay;
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long projectId;
|
||||
/**
|
||||
* 时长(天)1|0.5
|
||||
*/
|
||||
private Long dayLength;
|
||||
/**
|
||||
* 时长(小时)
|
||||
*/
|
||||
private Long hour;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 删除标志
|
||||
*/
|
||||
@TableLogic
|
||||
private Long delFlag;
|
||||
|
||||
}
|
||||
@@ -129,4 +129,9 @@ public class SysOaProject extends BaseEntity {
|
||||
* 延期至
|
||||
*/
|
||||
private Date postponeTime;
|
||||
|
||||
/**
|
||||
* 项目代表色
|
||||
*/
|
||||
private String color;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.ruoyi.oa.domain.bo;
|
||||
|
||||
import com.ruoyi.common.core.validate.AddGroup;
|
||||
import com.ruoyi.common.core.validate.EditGroup;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 人员考勤业务对象 sys_oa_attendance
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SysOaAttendanceBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 签到日
|
||||
*/
|
||||
@NotNull(message = "签到日不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long attendanceDay;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@NotNull(message = "项目id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 时长(天)1|0.5
|
||||
*/
|
||||
private Double dayLength;
|
||||
|
||||
/**
|
||||
* 时长(小时)
|
||||
*/
|
||||
private Double hour;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -156,4 +156,10 @@ public class SysOaProjectBo extends BaseEntity {
|
||||
*/
|
||||
private Date postponeTime;
|
||||
|
||||
|
||||
/**
|
||||
* 项目代表色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.ruoyi.oa.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.oa.domain.SysOaProject;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/**
|
||||
* 人员考勤视图对象 sys_oa_attendance
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class SysOaAttendanceVo {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ExcelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 员工id
|
||||
*/
|
||||
@ExcelProperty(value = "员工id")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 签到日
|
||||
*/
|
||||
@ExcelProperty(value = "签到日")
|
||||
private Long attendanceDay;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
@ExcelProperty(value = "项目id")
|
||||
private Long projectId;
|
||||
|
||||
/**
|
||||
* 时长(天)1|0.5
|
||||
*/
|
||||
@ExcelProperty(value = "时长", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "天=")
|
||||
private Long dayLength;
|
||||
|
||||
/**
|
||||
* 时长(小时)
|
||||
*/
|
||||
@ExcelProperty(value = "时长", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(readConverterExp = "小=时")
|
||||
private Long hour;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
private SysUser sysUser;
|
||||
|
||||
private SysOaProjectVo sysOaProjectVo;
|
||||
|
||||
private String color;
|
||||
|
||||
|
||||
}
|
||||
@@ -180,4 +180,10 @@ public class SysOaProjectVo {
|
||||
*/
|
||||
private Date postponeTime;
|
||||
|
||||
|
||||
/**
|
||||
* 项目代表色
|
||||
*/
|
||||
private String color;
|
||||
|
||||
}
|
||||
|
||||
15
ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysUserVo.java
Normal file
15
ruoyi-oa/src/main/java/com/ruoyi/oa/domain/vo/SysUserVo.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.oa.domain.vo;
|
||||
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
public class SysUserVo extends SysUser {
|
||||
|
||||
private List<SysOaAttendanceVo> attendances;
|
||||
|
||||
private List<SysOaProjectVo> projects;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.oa.mapper;
|
||||
|
||||
import com.ruoyi.oa.domain.SysOaAttendance;
|
||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||
import com.ruoyi.common.core.mapper.BaseMapperPlus;
|
||||
|
||||
/**
|
||||
* 人员考勤Mapper接口
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
public interface SysOaAttendanceMapper extends BaseMapperPlus<SysOaAttendanceMapper, SysOaAttendance, SysOaAttendanceVo> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.ruoyi.oa.service;
|
||||
|
||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.oa.domain.vo.SysUserVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员考勤Service接口
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
public interface ISysOaAttendanceService {
|
||||
|
||||
/**
|
||||
* 查询人员考勤
|
||||
*/
|
||||
SysOaAttendanceVo queryById(Long id);
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
TableDataInfo<SysOaAttendanceVo> queryPageList(SysOaAttendanceBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
List<SysOaAttendanceVo> queryList(SysOaAttendanceBo bo);
|
||||
|
||||
/**
|
||||
* 新增人员考勤
|
||||
*/
|
||||
Boolean insertByBo(SysOaAttendanceBo bo);
|
||||
|
||||
/**
|
||||
* 修改人员考勤
|
||||
*/
|
||||
Boolean updateByBo(SysOaAttendanceBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除人员考勤信息
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
List<SysUserVo> workerList(SysOaAttendanceBo bo);
|
||||
|
||||
int insertBatch(SysOaAttendanceBo bo);
|
||||
}
|
||||
@@ -0,0 +1,185 @@
|
||||
package com.ruoyi.oa.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.oa.domain.vo.SysOaProjectVo;
|
||||
import com.ruoyi.oa.domain.vo.SysUserVo;
|
||||
import com.ruoyi.oa.service.ISysOaProjectService;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.oa.domain.bo.SysOaAttendanceBo;
|
||||
import com.ruoyi.oa.domain.vo.SysOaAttendanceVo;
|
||||
import com.ruoyi.oa.domain.SysOaAttendance;
|
||||
import com.ruoyi.oa.mapper.SysOaAttendanceMapper;
|
||||
import com.ruoyi.oa.service.ISysOaAttendanceService;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 人员考勤Service业务层处理
|
||||
*
|
||||
* @author hdka
|
||||
* @date 2024-11-05
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class SysOaAttendanceServiceImpl implements ISysOaAttendanceService {
|
||||
|
||||
private final SysOaAttendanceMapper baseMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysOaProjectService projectService;
|
||||
|
||||
/**
|
||||
* 查询人员考勤
|
||||
*/
|
||||
@Override
|
||||
public SysOaAttendanceVo queryById(Long id){
|
||||
return baseMapper.selectVoById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysOaAttendanceVo> queryPageList(SysOaAttendanceBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysOaAttendance> lqw = buildQueryWrapper(bo);
|
||||
Page<SysOaAttendanceVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询人员考勤列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysOaAttendanceVo> queryList(SysOaAttendanceBo bo) {
|
||||
LambdaQueryWrapper<SysOaAttendance> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysOaAttendance> buildQueryWrapper(SysOaAttendanceBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysOaAttendance> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(bo.getUserId() != null, SysOaAttendance::getUserId, bo.getUserId());
|
||||
lqw.eq(bo.getAttendanceDay() != null, SysOaAttendance::getAttendanceDay, bo.getAttendanceDay());
|
||||
lqw.eq(bo.getProjectId() != null, SysOaAttendance::getProjectId, bo.getProjectId());
|
||||
lqw.eq(bo.getDayLength() != null, SysOaAttendance::getDayLength, bo.getDayLength());
|
||||
lqw.eq(bo.getHour() != null, SysOaAttendance::getHour, bo.getHour());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增人员考勤
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(SysOaAttendanceBo bo) {
|
||||
SysOaAttendanceBo sysOaAttendanceBo = new SysOaAttendanceBo();
|
||||
|
||||
BeanUtil.copyProperties(bo, sysOaAttendanceBo);
|
||||
sysOaAttendanceBo.setProjectId(null);
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = this.queryList(sysOaAttendanceBo);
|
||||
SysOaAttendance add = BeanUtil.toBean(bo, SysOaAttendance.class);
|
||||
validEntityBeforeSave(add);
|
||||
if (sysOaAttendanceVos.size()<=0){
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setId(add.getId());
|
||||
}
|
||||
return flag;
|
||||
}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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改人员考勤
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateByBo(SysOaAttendanceBo bo) {
|
||||
SysOaAttendance update = BeanUtil.toBean(bo, SysOaAttendance.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*/
|
||||
private void validEntityBeforeSave(SysOaAttendance entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除人员考勤
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserVo> workerList(SysOaAttendanceBo bo) {
|
||||
List<Long> userIds = sysUserRoleMapper.selectUserIdsByRoleId(1852970465740505090L);
|
||||
LocalDate localDate = LocalDate.now();
|
||||
int year = localDate.getYear();
|
||||
int month = localDate.getMonthValue();
|
||||
List<SysUserVo> sysUserVos = new ArrayList<>();
|
||||
for (Long userId : userIds) {
|
||||
SysUserVo sysUser = BeanUtil.toBean(sysUserService.selectUserById(userId), SysUserVo.class);
|
||||
SysOaAttendanceVo sysOaAttendanceVo = new SysOaAttendanceVo();
|
||||
sysOaAttendanceVo.setUserId(sysUser.getUserId());
|
||||
LambdaQueryWrapper<SysOaAttendance> lqw = Wrappers.lambdaQuery();
|
||||
|
||||
// 查询当月记录
|
||||
lqw.eq(SysOaAttendance::getUserId, userId)
|
||||
.ge(SysOaAttendance::getCreateTime,LocalDate.of(year,month,1))
|
||||
.le(SysOaAttendance::getCreateTime,LocalDate.of(year,month,localDate.lengthOfMonth()));
|
||||
List<SysOaAttendanceVo> sysOaAttendanceVos = baseMapper.selectVoList(lqw);
|
||||
|
||||
List<SysOaProjectVo> projectVos = new ArrayList<>();
|
||||
for (SysOaAttendanceVo oaAttendanceVo : sysOaAttendanceVos) {
|
||||
SysOaProjectVo sysOaProjectVo = projectService.queryById(oaAttendanceVo.getProjectId());
|
||||
oaAttendanceVo.setColor(sysOaProjectVo.getColor());
|
||||
projectVos.add(sysOaProjectVo);
|
||||
}
|
||||
sysUser.setProjects(projectVos);
|
||||
sysUser.setAttendances(sysOaAttendanceVos);
|
||||
sysUserVos.add(sysUser);
|
||||
}
|
||||
return sysUserVos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBatch(SysOaAttendanceBo bo) {
|
||||
List<Long> userIds = sysUserRoleMapper.selectUserIdsByRoleId(1852970465740505090L);
|
||||
for (Long userId : userIds) {
|
||||
SysOaAttendanceBo sysOaAttendanceBo = BeanUtil.toBean(bo,SysOaAttendanceBo.class);
|
||||
sysOaAttendanceBo.setUserId(userId);
|
||||
this.insertByBo(sysOaAttendanceBo);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.oa.mapper.SysOaAttendanceMapper">
|
||||
|
||||
<resultMap type="com.ruoyi.oa.domain.SysOaAttendance" id="SysOaAttendanceResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="attendanceDay" column="attendance_day"/>
|
||||
<result property="projectId" column="project_id"/>
|
||||
<result property="dayLength" column="day_length"/>
|
||||
<result property="hour" column="hour"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
</mapper>
|
||||
53
ruoyi-ui/src/api/oa/oaAttendance.js
Normal file
53
ruoyi-ui/src/api/oa/oaAttendance.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询人员考勤列表
|
||||
export function listOaAttendance(query) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance/worker/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询人员考勤详细
|
||||
export function getOaAttendance(id) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增人员考勤
|
||||
export function addOaAttendance(data) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 新增人员考勤
|
||||
export function addBatchOaAttendance(data) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance/insertBatch',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改人员考勤
|
||||
export function updateOaAttendance(data) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除人员考勤
|
||||
export function delOaAttendance(id) {
|
||||
return request({
|
||||
url: '/oa/oaAttendance/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
@@ -101,7 +101,9 @@
|
||||
<!-- <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>-->
|
||||
</div>
|
||||
<div v-for="(v, k) in noticeList" :key="k" class="text item" @click="toDrawer(v.noticeId)" type="primary" style="margin-left: 3px;margin-bottom: 5px;">
|
||||
<span class="pull-right">{{ parseTime(v.createTime, '{y}-{m}-{d}') }}</span> <i class="el-icon-arrow-right"></i> {{v.noticeTitle}}
|
||||
<span class="pull-right">{{ parseTime(v.createTime, '{y}-{m}-{d}') }}</span>
|
||||
<i class="el-icon-arrow-right"></i>
|
||||
{{v.noticeTitle}}
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
|
||||
253
ruoyi-ui/src/views/oa/attendance/index.vue
Normal file
253
ruoyi-ui/src/views/oa/attendance/index.vue
Normal file
@@ -0,0 +1,253 @@
|
||||
<template>
|
||||
<div class="app-container" v-loading="loading">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="14">
|
||||
签到表
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="80"></th>
|
||||
<th v-for="(item,index) in 31" :class="selectHead===index+1?'selectBox':''" @click="selectMany(index+1)">
|
||||
{{ index + 1 }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(item,index) in userList">
|
||||
<td :class="(item.userId===selectUser.userId || selectAll)?'selectBox':''">{{ item.nickName }}</td>
|
||||
<td v-for="(item2,index2) in 31" @click="selectAttendDay(item,index,index2+1)"
|
||||
:style="{backgroundColor:(item.attendances.length>0 && item.attendances.findIndex(i=>i.attendanceDay === index2+1) >-1) ?item.attendances[item.attendances.findIndex(i=>i.attendanceDay === index2+1)].color:(index2+1===selectIndex&&(item.userId===selectUser.userId || selectAll)?'#f3ff52':'')}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</el-col>
|
||||
<el-col :span="5">
|
||||
|
||||
|
||||
<el-card class="box-card">
|
||||
<div slot="" class="">
|
||||
<span><i class="el-icon-s-order"></i> 项目列表</span>
|
||||
<!-- <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>-->
|
||||
</div>
|
||||
<div v-for="(item,index) in projectList" style="display: flex;justify-content: space-between">
|
||||
<el-button class="text" :style="{backgroundColor:item.color===''?'':item.color}" @click="signIn(item)">{{ item.projectName }}
|
||||
</el-button>
|
||||
<el-color-picker class="text" v-model="item.color" @change="changeItemColor(item)"></el-color-picker>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
<el-col :span="5">
|
||||
|
||||
|
||||
<el-card class="box-card">
|
||||
<div slot="" class="">
|
||||
<span><i class="el-icon-timer"></i>工作时长</span>
|
||||
<div style="margin: 20px 0 ">
|
||||
<el-radio-group v-model="timeFlag">
|
||||
<el-radio :label="0">天计</el-radio>
|
||||
<el-radio :label="1">小时计</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
<el-select v-if="timeFlag===0" v-model="form.dayLength" placeholder="请选择工作时长">
|
||||
<el-option
|
||||
v-for="dict in dict.type.work_time_length"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
|
||||
<el-select v-if="timeFlag===1" v-model="form.hour" placeholder="请选择工作时长">
|
||||
<el-option
|
||||
v-for="dict in dict.type.work_time_length_hour"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {listWorker} from "@/api/system/user";
|
||||
import {listProject, updateProject} from "@/api/oa/project";
|
||||
import {listOaAttendance} from "@/api/oa/oaAttendance";
|
||||
import {addBatchOaAttendance, addOaAttendance} from "../../../api/oa/oaAttendance";
|
||||
|
||||
export default {
|
||||
name: "Project",
|
||||
dicts: ['work_time_length','work_time_length_hour'],
|
||||
data() {
|
||||
return {
|
||||
// 选择索引
|
||||
selectIndex: new Date().getDate(),
|
||||
// 用户列表
|
||||
userList: [],
|
||||
// 项目列表
|
||||
projectList: [],
|
||||
loading: true,
|
||||
selectHead: new Date().getDate(),
|
||||
// 提交表单
|
||||
form: {},
|
||||
// 查询参数
|
||||
userQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
userName: undefined,
|
||||
phonenumber: undefined,
|
||||
status: undefined,
|
||||
deptId: undefined
|
||||
},
|
||||
queryParams:{
|
||||
pageNum: 1,
|
||||
pageSize: 50,
|
||||
},
|
||||
selectArrayIndex:new Date().getDate(),
|
||||
timeFlag: 0,
|
||||
// 项目查询参数
|
||||
projectQueryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectName: undefined,
|
||||
projectNum: undefined,
|
||||
beginTime: undefined,
|
||||
finishTime: undefined
|
||||
},
|
||||
selectUser: {},
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
selectAll: true,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const day = new Date().getDate();
|
||||
},
|
||||
created() {
|
||||
|
||||
this.getList();
|
||||
},
|
||||
|
||||
methods: {
|
||||
selectAttendDay(item,index, index2) {
|
||||
this.selectIndex = index2;
|
||||
this.selectAll = false;
|
||||
this.selectUser = item;
|
||||
this.selectHead = index2
|
||||
this.selectArrayIndex = index
|
||||
},
|
||||
|
||||
selectMany(index) {
|
||||
this.selectAll = true;
|
||||
this.selectIndex = index;
|
||||
this.selectHead = index
|
||||
},
|
||||
/** 查询用户列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listOaAttendance(this.queryParams).then(res=>{
|
||||
console.log(res.data)
|
||||
this.userList = res.data;
|
||||
this.total = res.total;
|
||||
});
|
||||
listProject(this.projectQueryParams).then(response => {
|
||||
this.projectList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
|
||||
changeItemColor(item) {
|
||||
updateProject(item);
|
||||
this.getList();
|
||||
},
|
||||
signIn(project){
|
||||
// 一个签到
|
||||
if (this.form.dayLength === undefined && this.timeFlag === 0) {
|
||||
this.$message({ message: '请选择工作时长', type: 'warning' })
|
||||
return;
|
||||
}
|
||||
if (this.form.hour === undefined && this.timeFlag === 1) {
|
||||
this.$message({ message: '请选择工作时长', type: 'warning' })
|
||||
return;
|
||||
}
|
||||
let time = this.timeFlag===0?this.form.dayLength:this.form.hour
|
||||
|
||||
|
||||
if (!this.selectAll){
|
||||
this.form = {
|
||||
projectId:project.projectId,
|
||||
userId:this.selectUser.userId,
|
||||
attendanceDay:this.selectIndex,
|
||||
dayLength: this.timeFlag===0?this.form.dayLength:undefined,
|
||||
hour:this.timeFlag===1?this.form.hour:undefined
|
||||
}
|
||||
addOaAttendance(this.form).then(res=>{
|
||||
this.selectUser = this.selectArrayIndex>=this.userList.length-1?this.selectUser:this.userList[this.selectArrayIndex+1]
|
||||
|
||||
this.getList()
|
||||
|
||||
})
|
||||
}else{
|
||||
|
||||
this.form = {
|
||||
projectId:project.projectId,
|
||||
attendanceDay:this.selectIndex,
|
||||
dayLength: this.timeFlag===0?this.form.dayLength:undefined,
|
||||
hour:this.timeFlag===1?this.form.hour:undefined
|
||||
}
|
||||
// 集体赋予状态
|
||||
addBatchOaAttendance(this.form).then(res=>{
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
table {
|
||||
border: 1px solid #000;
|
||||
table-layout: fixed;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th {
|
||||
border: 1px solid;
|
||||
|
||||
height: 15px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
td {
|
||||
border: 1px solid;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.selectDay {
|
||||
background-color: #00afff;
|
||||
}
|
||||
|
||||
.selectBox {
|
||||
background-color: #f3ff52;
|
||||
}
|
||||
|
||||
.text {
|
||||
font-size: 16px;
|
||||
border-bottom: #cccccc 1px dashed;
|
||||
margin: 5px 0;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user