diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttChangeController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttChangeController.java new file mode 100644 index 0000000..c6e1692 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/AttChangeController.java @@ -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); + } + + +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/AttChangeDao.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/AttChangeDao.java new file mode 100644 index 0000000..63f393a --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/AttChangeDao.java @@ -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 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 getAttGroup(); + + /** + * 获取人员考勤信息 + * @param bean + * @return + */ + AttChangeBean getOldData(AttChangeBean bean); + + /** + * 获取人员信息 + * @param bean + * @return + */ + int getUser(AttChangeBean bean); + + /** + * 新增考勤信息 + * @param bean + */ + void addAtt(AttChangeBean bean); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/AttChangeBean.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/AttChangeBean.java new file mode 100644 index 0000000..d5a4e20 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/AttChangeBean.java @@ -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 orgList; + + private String createName; + private String createUserId; + private String createTime; +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeService.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeService.java new file mode 100644 index 0000000..4a5717d --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeService.java @@ -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 getChangeList(AttChangeBean bean); + + /** + * 新增考勤规则变更 + * @param bean + * @return + */ + AjaxResult insertAtt(AttChangeBean bean); + + /** + * 获取考勤规则变更下拉框 + * @return + */ + AjaxResult getAttGroup(); + + /** + * 获取考勤规则变更数据 + * @param bean + * @return + */ + AjaxResult getOldData(AttChangeBean bean); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeServiceImpl.java new file mode 100644 index 0000000..58ee20f --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/AttChangeServiceImpl.java @@ -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 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 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(); + } + } +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/holiday/entity/HolidayBean.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/holiday/entity/HolidayBean.java index 4cd4721..738bc25 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/holiday/entity/HolidayBean.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/holiday/entity/HolidayBean.java @@ -143,6 +143,12 @@ public class HolidayBean extends BaseBean { */ private String isAgree; + /** + * 是否因公 1是0否 + */ + private String isBusiness; + + /** * 是否培训 1 是 0 否 */ diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/LeaveReporting/LeaveReportingMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/LeaveReporting/LeaveReportingMapper.xml index 590fc2a..68d9710 100644 --- a/bonus-modules/bonus-system/src/main/resources/mapper/LeaveReporting/LeaveReportingMapper.xml +++ b/bonus-modules/bonus-system/src/main/resources/mapper/LeaveReporting/LeaveReportingMapper.xml @@ -181,8 +181,8 @@ UNION ALL SELECT su.user_id as userId , su.user_name as userName 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} - WHERE 1=1 + LEFT JOIN sys_user_org suo ON su.user_id = suo.user_id And suo.is_active= '1' + WHERE 1=1 and su.user_id !=#{params.id} and suo.org_id in ( diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/att/AttChangeMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/att/AttChangeMapper.xml new file mode 100644 index 0000000..553a362 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/resources/mapper/att/AttChangeMapper.xml @@ -0,0 +1,89 @@ + + + + + insert into att_group_person_relation(group_id, user_id, effective_time) + values (#{afterAttId}, #{userId}, now()) + + + + 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}) + + + + UPDATE sys_user_org + SET `org_id` = #{afterOrgId} + WHERE `user_id` = #{userId} and `is_active` = '1' + + + + UPDATE `att_group_person_relation` SET `group_id` = #{afterAttId} WHERE `user_id` = #{userId} and `is_active` = '1' + + + + + + + + + + + + \ No newline at end of file diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/holiday/HolidayMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/holiday/HolidayMapper.xml index be26174..0181bb7 100644 --- a/bonus-modules/bonus-system/src/main/resources/mapper/holiday/HolidayMapper.xml +++ b/bonus-modules/bonus-system/src/main/resources/mapper/holiday/HolidayMapper.xml @@ -13,7 +13,7 @@ leave_end_interval, - 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}, #{leaveStartDate}, @@ -24,7 +24,7 @@ #{leaveEndInterval}, #{leaveDuration},#{examineStatus},#{source},#{createUserId}, #{isAgree}, #{location}, #{hostUserId}, #{remark}, - #{type}) + #{type},#{isBusiness}) UPDATE leave_apply @@ -58,7 +58,8 @@ is_agree = #{isAgree}, location = #{location}, host_user_id = #{hostUserId}, - remark = #{remark} + remark = #{remark}, + is_business = #{isBusiness} where id = #{id} @@ -204,6 +205,7 @@ examine_status, examine_opinion, is_agree, + is_business, location, host_user_id, remark