临时外出申请-新增字段因公外出;考勤规则变更功能开发

Signed-off-by: lSun <15893999301@qq.com>
This commit is contained in:
lSun 2025-07-29 14:30:47 +08:00
parent b32b1b522b
commit bdaeaec520
9 changed files with 571 additions and 5 deletions

View File

@ -0,0 +1,85 @@
package com.bonus.system.att.controller;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.Log;
import com.bonus.common.log.enums.BusinessType;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.MapVo;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.att.entity.*;
import com.bonus.system.att.service.AttChangeService;
import com.bonus.system.att.service.AttendanceDetailsService;
import com.bonus.system.basic.dao.SysOrgDao;
import com.bonus.system.basic.dao.SysUserMapper;
import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.basic.service.SysOrgService;
import com.bonus.system.dept.dao.ProDeptRoleDao;
import com.bonus.system.holiday.dao.WorkReportDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* 考勤规则变更
*
* @author lsun
*/
@RestController
@RequestMapping("/attChange")
@Slf4j
public class AttChangeController extends BaseController {
@Resource(name = "attChangeService")
private AttChangeService attChangeService;
/**
* 获取考勤规则变更列表
*/
@RequiresPermissions("att:change:list")
@GetMapping("/getChangeList")
@Log(title = "考勤设置->考勤规则变更->列表查询", businessType = BusinessType.QUERY)
public TableDataInfo getChangeList(AttChangeBean bean) {
try{
startPage();
return getDataTable(attChangeService.getChangeList(bean));
}catch (Exception e){
log.error(e.toString(),e);
}
return getDataTableError(new ArrayList<>());
}
/**
* 考勤规则变更列表
*/
@RequiresPermissions("att:change:add")
@PostMapping("/addAtt")
@Log(title = "考勤设置->考勤规则变更->新增", businessType = BusinessType.INSERT)
public AjaxResult add(@Validated @RequestBody AttChangeBean bean) {
return attChangeService.insertAtt(bean);
}
/**
* 查询所有的考勤规则
*/
@GetMapping("getAttGroup")
public AjaxResult getAttGroup() {
return attChangeService.getAttGroup();
}
/**
* 查询之前的考勤数据
*/
@GetMapping("getOldData")
public AjaxResult getOldData(AttChangeBean bean) {
return attChangeService.getOldData(bean);
}
}

View File

@ -0,0 +1,77 @@
package com.bonus.system.att.dao;
import com.bonus.system.api.domain.MapVo;
import com.bonus.system.att.entity.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* 考勤规则变更-数据访问层
* @author zys
*/
@Repository("attChangeDao")
public interface AttChangeDao {
/**
* 获取考勤规则变更列表
* @param bean
* @return
*/
List<AttChangeBean> getChangeList(AttChangeBean bean);
/**
* 先去人员信息修改部门信息
* @param bean
* @return
*/
int updateUser(AttChangeBean bean);
/**
* 是否有该人员信息
* @param bean
* @return
*/
AttChangeBean getAttPerson(AttChangeBean bean);
/**
* 修改考勤人员信息
* @param bean
* @return
*/
int updateAttPerson(AttChangeBean bean);
/**
* 新增考勤人员信息
* @param bean
* @return
*/
int insertAttPerson(AttChangeBean bean);
/**
* 获取考勤组
* @return
*/
List<AttChangeBean> getAttGroup();
/**
* 获取人员考勤信息
* @param bean
* @return
*/
AttChangeBean getOldData(AttChangeBean bean);
/**
* 获取人员信息
* @param bean
* @return
*/
int getUser(AttChangeBean bean);
/**
* 新增考勤信息
* @param bean
*/
void addAtt(AttChangeBean bean);
}

View File

@ -0,0 +1,117 @@
package com.bonus.system.att.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* 考勤规则变更
* @author lsun
*/
@Data
public class AttChangeBean {
/**
* 编号
*/
@Excel(name = "序号", width = 10.0,height = 20.0, orderNum = "0")
private Long id;
private Long userId;
@Excel(name = "姓名", width = 10.0,height = 20.0, orderNum = "1")
private String userName;
/**
* 手机号
*/
@Excel(name = "手机号", width = 20.0,height = 20.0, orderNum = "2")
private String phoneNumber;
private String phone;
/**
* 岗位
*/
@Excel(name = "岗位", width = 20.0,height = 20.0, orderNum = "3")
private String postName;
/**
* 角色
*/
@Excel(name = "角色", width = 20.0,height = 20.0, orderNum = "4")
private String roleName;
/**
* 变动前部门id
*/
@Excel(name = "变动前部门", width = 20.0,height = 20.0, orderNum = "5")
private String oldOrgId;
/**
* 变动前部门名称
*/
@Excel(name = "变动前部门", width = 20.0,height = 20.0, orderNum = "5")
private String oldOrgName;
/**
* 变动后部门id
*/
@Excel(name = "变动后部门id", width = 20.0,height = 20.0, orderNum = "6")
private String afterOrgId;
/**
* 变动后部门名称
*/
@Excel(name = "变动后部门", width = 20.0,height = 20.0, orderNum = "6")
private String afterOrgName;
/**
* 变动前考勤规则id
*/
@Excel(name = "变动前考勤规则", width = 20.0,height = 20.0, orderNum = "5")
private String oldAttId;
/**
* 变动前考勤规则
*/
@Excel(name = "变动前考勤规则", width = 20.0,height = 20.0, orderNum = "5")
private String oldAttName;
/**
* 变动后考勤规则id
*/
@Excel(name = "变动后考勤规则id", width = 20.0,height = 20.0, orderNum = "6")
private String afterAttId;
/**
* 变动后考勤规则
*/
@Excel(name = "变动后考勤规则", width = 20.0,height = 20.0, orderNum = "6")
private String afterAttName;
/**
* 变动时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date changeTime;
/**
* 导出变动时间
*/
@Excel(name = "变动时间", width = 20.0,height = 20.0, orderNum = "7")
private String updateTime;
private String month;
/**
* 自己项目部所在分公司下的所有项目部id
*/
private List<String> orgList;
private String createName;
private String createUserId;
private String createTime;
}

View File

@ -0,0 +1,42 @@
package com.bonus.system.att.service;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.system.api.domain.MapVo;
import com.bonus.system.att.entity.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 考勤规则变更-业务层
* @author lsun
*/
public interface AttChangeService {
/**
* 获取考勤规则变更列表
* @param bean
* @return
*/
List<AttChangeBean> getChangeList(AttChangeBean bean);
/**
* 新增考勤规则变更
* @param bean
* @return
*/
AjaxResult insertAtt(AttChangeBean bean);
/**
* 获取考勤规则变更下拉框
* @return
*/
AjaxResult getAttGroup();
/**
* 获取考勤规则变更数据
* @param bean
* @return
*/
AjaxResult getOldData(AttChangeBean bean);
}

View File

@ -0,0 +1,148 @@
package com.bonus.system.att.service;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.utils.DateTimeHelper;
import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.system.api.domain.MapVo;
import com.bonus.system.api.domain.SysUser;
import com.bonus.system.att.dao.AttChangeDao;
import com.bonus.system.att.dao.AttSourceDataDao;
import com.bonus.system.att.dao.AttendanceDetailsDao;
import com.bonus.system.att.entity.*;
import com.bonus.system.att.tasks.NewAttTask;
import com.bonus.system.att.utils.RoleUtil;
import com.bonus.system.att.utils.WorkdayCalculator;
import com.bonus.system.basic.domain.SysNotice;
import com.bonus.system.basic.service.SysNoticeService;
import com.bonus.system.file.service.FileUploadService;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
/**
* 考勤规则变更-业务层
*
* @author lsun
*/
@Service("attChangeService")
@Log4j2
public class AttChangeServiceImpl implements AttChangeService {
@Resource(name = "attChangeDao")
private AttChangeDao attChangeDao;
/**
* 考勤规则变更-列表查询
* @param bean
* @return
*/
@Override
public List<AttChangeBean> getChangeList(AttChangeBean bean) {
return attChangeDao.getChangeList( bean);
}
/**
* 考勤规则变更-新增
* @param bean
* @return
*/
@Override
public AjaxResult insertAtt(AttChangeBean bean) {
try{
// 数据预处理将空字符串转换为null
if (bean.getOldAttId() != null && bean.getOldAttId().isEmpty()) {
bean.setOldAttId(null);
}
if (bean.getAfterAttId() != null && bean.getAfterAttId().isEmpty()) {
bean.setAfterAttId(null);
}
if (bean.getOldOrgId() != null && bean.getOldOrgId().isEmpty()) {
bean.setOldOrgId(null);
}
if (bean.getAfterOrgId() != null && bean.getAfterOrgId().isEmpty()) {
bean.setAfterOrgId(null);
}
//先去查询人员信息修改部门信息
int i = attChangeDao.getUser(bean);
if(i>0){
//修改部门信息
int l = attChangeDao.updateUser(bean);
//先去判断是否有该人员信息
AttChangeBean o = attChangeDao.getAttPerson(bean);
if(o!=null && o.getId()>0){
// 进行修改
int j = attChangeDao.updateAttPerson(bean);
if(j>0){
//添加变更记录
bean.setCreateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
attChangeDao.addAtt( bean);
return AjaxResult.success();
}else{
return AjaxResult.error("修改人员信息失败");
}
}else{
// 进行新增
int k = attChangeDao.insertAttPerson(bean);
if (k>0){
//添加变更记录
bean.setCreateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
attChangeDao.addAtt( bean);
return AjaxResult.success();
}else{
return AjaxResult.error("新增人员信息失败");
}
}
}else{
return AjaxResult.error("修改人员信息失败");
}
} catch (Exception e) {
log.error(e.toString(),e);
return AjaxResult.error();
}
}
/**
* 考勤规则变更-获取考勤组
* @return
*/
@Override
public AjaxResult getAttGroup() {
try {
List<AttChangeBean> list = attChangeDao.getAttGroup();
return AjaxResult.success(list);
} catch (Exception e) {
log.error(e.toString(),e);
return AjaxResult.error();
}
}
/**
* 获取考勤规则变更数据
* @param bean
* @return
*/
@Override
public AjaxResult getOldData(AttChangeBean bean) {
try {
AttChangeBean o = attChangeDao.getOldData(bean);
return AjaxResult.success(o);
} catch (Exception e) {
log.error(e.toString(),e);
return AjaxResult.error();
}
}
}

View File

@ -143,6 +143,12 @@ public class HolidayBean extends BaseBean {
*/ */
private String isAgree; private String isAgree;
/**
* 是否因公 1是0否
*/
private String isBusiness;
/** /**
* 是否培训 1 0 * 是否培训 1 0
*/ */

View File

@ -181,8 +181,8 @@
UNION ALL UNION ALL
SELECT su.user_id as userId , su.user_name as userName SELECT su.user_id as userId , su.user_name as userName
FROM sys_user su FROM sys_user su
LEFT JOIN sys_user_org suo ON su.user_id = suo.user_id And suo.is_active= '1' and su.user_id !=#{params.id} LEFT JOIN sys_user_org suo ON su.user_id = suo.user_id And suo.is_active= '1'
WHERE 1=1 WHERE 1=1 and su.user_id !=#{params.id}
<if test='params.orgList != null and params.orgList.size() > 0'> <if test='params.orgList != null and params.orgList.size() > 0'>
and suo.org_id in ( and suo.org_id in (
<foreach collection="params.orgList" item="item" separator=","> <foreach collection="params.orgList" item="item" separator=",">

View File

@ -0,0 +1,89 @@
<?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.bonus.system.att.dao.AttChangeDao">
<insert id="insertAttPerson">
insert into att_group_person_relation(group_id, user_id, effective_time)
values (#{afterAttId}, #{userId}, now())
</insert>
<insert id="addAtt">
INSERT INTO `att_change`(`user_id`, `old_att_id`, `after_att_id`, `old_org_id`, `after_org_id`, `create_user_id`)
VALUES (#{userId}, #{oldAttId}, #{afterAttId}, #{oldOrgId}, #{afterOrgId}, #{createUserId})
</insert>
<update id="updateUser">
UPDATE sys_user_org
SET `org_id` = #{afterOrgId}
WHERE `user_id` = #{userId} and `is_active` = '1'
</update>
<update id="updateAttPerson">
UPDATE `att_group_person_relation` SET `group_id` = #{afterAttId} WHERE `user_id` = #{userId} and `is_active` = '1'
</update>
<select id="getChangeList" resultType="com.bonus.system.att.entity.AttChangeBean">
SELECT att.id,
att.user_id as userId,
su.user_name as userName,
su.phone as phone,
att.old_att_id,
gr1.group_name as oldAttName,
att.after_att_id,
gr2.group_name as afterAttName,
att.old_org_id,
org1.org_name as oldOrgName,
att.after_org_id,
org1.org_name as afterOrgName,
att.create_user_id,
su2.user_name as createName,
att.create_time as createTime
FROM att_change att
LEFT JOIN sys_user su ON su.user_id = att.user_id
LEFT JOIN sys_organization org1 on org1.id = att.old_org_id
LEFT JOIN sys_organization org2 on org2.id = att.after_org_id
LEFT JOIN att_group gr1 on gr1.id = att.old_att_id
LEFT JOIN att_group gr2 on gr2.id = att.after_att_id
LEFT JOIN sys_user su2 ON su2.user_id = att.create_user_id
<where>
<if test="userName != null and userName != ''">
and su.user_name like concat('%',#{userName},'%')
</if>
<if test="phone != null and phone != ''">
and su.phone like concat('%',#{phone},'%')
</if>
</where>
</select>
<select id="getAttPerson" resultType="com.bonus.system.att.entity.AttChangeBean">
SELECT id FROM `att_group_person_relation`
WHERE is_active = '1' AND user_id = #{userId}
</select>
<select id="getAttGroup" resultType="com.bonus.system.att.entity.AttChangeBean">
SELECT id as afterAttId, group_name as afterAttName FROM att_group
WHERE is_active = '1'
</select>
<select id="getOldData" resultType="com.bonus.system.att.entity.AttChangeBean">
SELECT su.user_name as userName,
su.phone as phoneNumber,
org.id as oldOrgId,
org.org_name as oldOrgName,
gr.id as oldAttId,
gr.group_name as oldAttName
FROM sys_user su
LEFT JOIN sys_user_org suo ON su.user_id = suo.user_id and suo.is_active = '1'
LEFT JOIN sys_organization org ON org.id = suo.org_id AND org.is_active ='1'
LEFT JOIN att_group_person_relation pr ON pr.user_id = su.user_id AND pr.is_active ='1'
LEFT JOIN att_group gr ON gr.id = pr.group_id
WHERE su.user_id = #{userId}
</select>
<select id="getUser" resultType="java.lang.Integer">
select count(1) from sys_user_org
WHERE `user_id` = #{userId} and `is_active` = '1'
</select>
</mapper>

View File

@ -13,7 +13,7 @@
<if test="leaveEndInterval != null"> <if test="leaveEndInterval != null">
leave_end_interval, leave_end_interval,
</if> </if>
leave_duration,examine_status,source,create_user_id,is_agree, location, host_user_id, remark,type) leave_duration,examine_status,source,create_user_id,is_agree, location, host_user_id, remark,type,is_business)
VALUES(#{userId},#{userName},#{orgId},#{orgName},#{leaveType},#{leaveReason}, VALUES(#{userId},#{userName},#{orgId},#{orgName},#{leaveType},#{leaveReason},
#{leaveStartDate}, #{leaveStartDate},
<if test="leaveStartInterval != null"> <if test="leaveStartInterval != null">
@ -24,7 +24,7 @@
#{leaveEndInterval}, #{leaveEndInterval},
</if> </if>
#{leaveDuration},#{examineStatus},#{source},#{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{remark}, #{leaveDuration},#{examineStatus},#{source},#{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{remark},
#{type}) #{type},#{isBusiness})
</insert> </insert>
<update id="updateHoliday"> <update id="updateHoliday">
UPDATE leave_apply UPDATE leave_apply
@ -58,7 +58,8 @@
is_agree = #{isAgree}, is_agree = #{isAgree},
location = #{location}, location = #{location},
host_user_id = #{hostUserId}, host_user_id = #{hostUserId},
remark = #{remark} remark = #{remark},
is_business = #{isBusiness}
</set> </set>
where id = #{id} where id = #{id}
</update> </update>
@ -204,6 +205,7 @@
examine_status, examine_status,
examine_opinion, examine_opinion,
is_agree, is_agree,
is_business,
location, location,
host_user_id, host_user_id,
remark remark