diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/OrgChangeController.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/OrgChangeController.java new file mode 100644 index 0000000..fda1c79 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/controller/OrgChangeController.java @@ -0,0 +1,123 @@ +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.system.att.entity.AttGroupBean; +import com.bonus.system.att.entity.OrgChangeBean; +import com.bonus.system.att.service.OrgChangeService; +import com.bonus.system.basic.domain.SysTree; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +/** + * 组织架构变更 + * + * @author fly + */ +@RestController +@RequestMapping("/orgChange") +@Slf4j +public class OrgChangeController extends BaseController { + + @Resource(name = "OrgChangeService") + private OrgChangeService orgChangeService; + + /** + * 获取组织架构列表 + */ + @RequiresPermissions("att:org:change:list") + @GetMapping("/list") + @Log(title = "考勤设置->组织架构变更->列表查询", businessType = BusinessType.QUERY) + public TableDataInfo list(OrgChangeBean bean) { + try{ + startPage(); + return getDataTable(orgChangeService.selectOrgChangeList(bean)); + }catch (Exception e){ + log.error(e.toString(),e); + } + return getDataTableError(new ArrayList<>()); + } + + /** + * 新增组织架构变更单 + */ + @RequiresPermissions("att:org:change:add") + @PostMapping + @Log(title = "考勤设置->组织架构变更->组织架构新增", businessType = BusinessType.INSERT) + public AjaxResult add(@RequestBody OrgChangeBean bean) { + try{ + return toAjax(orgChangeService.insertOrgChange(bean)); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 根据组织架构编号获取详细信息 + */ + @RequiresPermissions("att:org:change:query") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable Long id) { + try{ + return success(orgChangeService.selectOrgChangeById(id)); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 修改组织架构 + */ + @RequiresPermissions("att:org:change:edit") + @PutMapping + @Log(title = "考勤设置->组织架构变更->组织架构修改", businessType = BusinessType.UPDATE) + public AjaxResult edit(@RequestBody OrgChangeBean bean) { + try{ + return toAjax(orgChangeService.updateOrgChange(bean)); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 删除组织架构 + */ + @RequiresPermissions("att:group:remove") + @DeleteMapping("/{groupId}") + @Log(title = "考勤设置->组织架构变更->组织架构删除", businessType = BusinessType.DELETE) + public AjaxResult remove(@PathVariable("groupId") Long groupId) { + try{ + return toAjax(orgChangeService.deleteAttGroup(groupId)); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + + /** + * 查询组织选择列表 + */ + @PostMapping("/selectOrgList") + @Log(title = "考勤设置->查询组织选择列表", businessType = BusinessType.QUERY) + public AjaxResult selectOrgList() { + try{ + List sysTrees = orgChangeService.selectOrgList(); + return success(sysTrees); + }catch (Exception e){ + log.error(e.toString(),e); + } + return error("系统异常"); + } + +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/OrgChangeDao.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/OrgChangeDao.java new file mode 100644 index 0000000..d626b0a --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/dao/OrgChangeDao.java @@ -0,0 +1,116 @@ +package com.bonus.system.att.dao; + +import com.bonus.system.att.entity.AttGroupBean; +import com.bonus.system.att.entity.AttGroupCheckOrgBean; +import com.bonus.system.att.entity.OrgChangeBean; +import com.bonus.system.basic.domain.SysTree; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.ArrayList; +import java.util.List; + +/** + * 考勤组-数据访问层 + * @author zys + */ +@Repository("OrgChangeDao") +public interface OrgChangeDao { + + /** + * 获取考勤组列表 + * @param bean 参数 + * @return list bean + */ + List selectOrgChangeList(OrgChangeBean bean); + + /** + * 查询组织选择列表 + * @return list bean + */ + List selectOrgList(); + + /** + * 删除考勤组 + * @param groupId 考勤组编号 + * @return 1|0 + */ + int deleteAttGroup(Long groupId); + + /** + * 上传考勤组表 + * @param bean 参数 + * @return 1|0 + */ + int insertOrgChange(OrgChangeBean bean); + + /** + * 上传考勤组设置表 + * @param bean 参数 + * @return 1|0 + */ + int insertAttGroupSetting(AttGroupBean bean); + + /** + * 上传考勤人员绑定表 + * @param checkOrgList 参数 + * @return 1|0 + */ + int insertAttGroupPerson(List checkOrgList); + + /** + * 根据考勤组编号获取详细信息 + * @param groupId 考勤组编号 + * @return bean + */ + AttGroupBean selectAttGroupById(Long groupId); + + /** + * 根据考勤组编号获取人员绑定情况 + * @param groupId 考勤组编号 + * @return list bean + */ + OrgChangeBean selectOrgChangeById(Long id); + + /** + * 删除考勤组绑定人员 + * @param groupId 考勤组编号 + */ + void deleteAttGroupRelationPerson(Long groupId); + + /** + * 修改考勤组 + * @param bean 参数 + * @return 1|0 + */ + int updateOrgChange(OrgChangeBean bean); + + /** + * 修改考勤组设置表 + * @param bean 参数 + * @return 1|0 + */ + int updateAttGroupSetting(AttGroupBean bean); + + /** + * 查询人员是否绑定考勤组 + * @param id 用户编号 + * @return 1|0 + */ + String getAttGroupPersonIsBind(long id); + + /** + * 查询出可选中人员 + * @return list bean + */ + List getAttGroupCheckPerson(); + + /** + * + * 根据组织编号获取人员 + * @param idList 组织编号 + * @param groupId 考勤组(当前考情组) + * @return list bean + */ + List getUserByOrg(@Param("idList")ArrayList idList, @Param("groupId")Long groupId); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/OrgChangeBean.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/OrgChangeBean.java new file mode 100644 index 0000000..9a37708 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/entity/OrgChangeBean.java @@ -0,0 +1,98 @@ +package com.bonus.system.att.entity; + +import com.bonus.system.basic.domain.SysTree; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 组织架构变更实体类 + * @author fly + */ +@Data +@NoArgsConstructor +public class OrgChangeBean { + + /** + * 编号 + */ + private Long id; + + /** + * 申请人编号 + */ + private Long userId; + + /** + * 申请人 + */ + private String userName; + + /** + * 变更前部门编号 + */ + private Long oldOrgId; + + /** + * 变更前部门 + */ + private String oldOrgName; + + /** + * 变更后部门编号 + */ + private Long newOrgId; + + /** + * 变更后部门 + */ + private String newOrgName; + + /** + * 是否变更考勤组 0 不变 1 变 + */ + private String isChangeAttGroup; + + /** + * 变更前考勤组编号 + */ + private Long oldAttGroup; + + /** + * 变更后考勤组编号 + */ + private String newAttGroup; + + /** + * 生效日期 + */ + private Long changeEffectiveDate; + + /** + * 是否审核通过 0 未审核 1 已通过 2 未通过 + */ + private Long isCheck; + + /** + * 审核人编号 + */ + private Long checkUserId; + + /** + * 审核时间 + */ + private Long checkTime; + + /** + * 备注 + */ + private String remark; + + /** + * 是否有效 + */ + private Integer isActive; + + +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeService.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeService.java new file mode 100644 index 0000000..27c6f66 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeService.java @@ -0,0 +1,55 @@ +package com.bonus.system.att.service; + +import com.bonus.system.att.entity.AttGroupBean; +import com.bonus.system.att.entity.OrgChangeBean; +import com.bonus.system.basic.domain.SysTree; + +import java.util.List; + +/** + * 考勤组-业务层 + * @author zys + */ +public interface OrgChangeService { + + /** + * 获取考勤组列表 + * @param bean 参数 + * @return list bean + */ + List selectOrgChangeList(OrgChangeBean bean); + + /** + * 查询组织选择列表 + * @return map + */ + List selectOrgList(); + + /** + * 删除考勤组 + * @param groupId 考勤组编号 + * @return 1|0 + */ + int deleteAttGroup(Long groupId); + + /** + * 新增考勤组 + * @param bean 参数 + * @return 1|0 + */ + int insertOrgChange(OrgChangeBean bean); + + /** + * 根据考勤组编号获取详细信息 + * @param groupId 考勤组编号 + * @return bean + */ + OrgChangeBean selectOrgChangeById(Long groupId); + + /** + * 修改考勤组 + * @param bean 参数 + * @return 1|0 + */ + int updateOrgChange(OrgChangeBean bean); +} diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeServiceImpl.java new file mode 100644 index 0000000..2b87ca4 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/att/service/OrgChangeServiceImpl.java @@ -0,0 +1,111 @@ +package com.bonus.system.att.service; + +import com.bonus.common.core.constant.Constants; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.system.att.dao.OrgChangeDao; +import com.bonus.system.att.entity.AttGroupBean; +import com.bonus.system.att.entity.AttGroupCheckOrgBean; +import com.bonus.system.att.entity.OrgChangeBean; +import com.bonus.system.att.utils.TreeUtils; +import com.bonus.system.basic.domain.SysTree; +import com.bonus.system.dept.dao.ProDeptRoleDao; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 考勤组-业务层 + * + * @author zys + */ +@Service("OrgChangeService") +public class OrgChangeServiceImpl implements OrgChangeService { + + @Resource(name = "OrgChangeDao") + private OrgChangeDao orgChangeDao; + + @Resource(name = "ProDeptRoleDao") + private ProDeptRoleDao proDeptRoleDao; + + @Override + public List selectOrgChangeList(OrgChangeBean bean) { + return orgChangeDao.selectOrgChangeList(bean); + } + + @Override + public List selectOrgList() { + List listTree = orgChangeDao.getAttGroupCheckPerson(); + // 返回处理后的树形结构 + return listTree.stream() + .filter(m -> m.getParentId() == null) + .peek(m -> m.setChildren(TreeUtils.getOrgTreeChild(m, listTree, 0))) + .collect(Collectors.toList()); + } + + @Override + public int deleteAttGroup(Long groupId) { + return orgChangeDao.deleteAttGroup(groupId); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public int insertOrgChange(OrgChangeBean bean) { + //新增考勤组表 + return orgChangeDao.insertOrgChange(bean); + } + + @Override + public OrgChangeBean selectOrgChangeById(Long id) { + return orgChangeDao.selectOrgChangeById(id); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public int updateOrgChange(OrgChangeBean bean) { + return orgChangeDao.updateOrgChange(bean); + } + + private List dealWithOrgUser(AttGroupBean bean, Long bean1) { + //只有部门的将部门变成部门下所有人(去除掉其他考勤组选的人) + List checkOrgAllList = bean.getCheckOrgList(); + List checkOrgList = new ArrayList<>(); + checkOrgAllList.forEach(c -> { + if (!"".equals(c.getOrgId()) && "".equals(c.getUserId())) { + String id = proDeptRoleDao.getOrgChildById(Long.valueOf(c.getOrgId())); + // 使用 Arrays.asList() 将数组转换为 ArrayList + ArrayList idList = new ArrayList<>(Arrays.asList(id.split(","))); + List userList = orgChangeDao.getUserByOrg(idList, bean1); + checkOrgList.addAll(userList); + } + } + ); + checkOrgAllList.addAll(checkOrgList); + // 使用 Iterator 来安全地遍历并移除元素 + Iterator iterator = checkOrgAllList.iterator(); + while (iterator.hasNext()) { + AttGroupCheckOrgBean person = iterator.next(); + if (person.getUserId().isEmpty()) { + // 如果 userId 为空或空字符串,则移除该元素 + iterator.remove(); + } else { + // 否则,设置 groupId + person.setGroupId(bean.getGroupId()); + } + } + return checkOrgAllList; + } + + private List getOrgCheckList(List orgList, List checkList) { + // 使用forEach结合stream进行比对 + checkList.forEach(c -> orgList.stream().filter(v -> (c.getUserId() + Constants.VERTICAL + + c.getOrgId()).equals(v.getId())).forEach(x -> x.setIsChecked(true))); + return orgList; + } + +} diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/att/OrgChangeMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/att/OrgChangeMapper.xml new file mode 100644 index 0000000..ef60ec4 --- /dev/null +++ b/bonus-modules/bonus-system/src/main/resources/mapper/att/OrgChangeMapper.xml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + update att_group + set is_active = 0 + where id = #{groupId}; + update att_group_setting + set is_active = 0 + where group_id = #{groupId}; + update att_group_person_relation + set is_active = 0 + where group_id = #{groupId}; + + + + update att_group_person_relation + set is_active = 0 + where group_id = #{groupId}; + + + + insert into org_change(user_id, old_org_id, new_org_id,is_change_att_group, change_effective_date, is_check + remark) + values (#{userId},#{oldOrgId},#{newOrgId},#{isChangeAttGroup},#{changeTime},#{createUserId},#{remark}) + ,old_att_group + ,new_att_group + ) values (#{userId},#{oldOrgId},#{newOrgId},#{isChangeAttGroup},#{changeEffectiveDate},#{isCheck} + ,#{oldAttGroup} + ,#{newAttGroup} + ) + + + + insert into att_group_setting(group_id, att_day + ,to_work_time + ,off_work_time + ,late_minute + ,leave_minute + ,absenteeism_late_minute + ,absenteeism_leave_minute + ,entry_abnormal_minute + ,today_clock_num + ,attendance_duration + )values( #{groupId}, #{attDay} + ,#{toWorkTime} + ,#{offWorkTime} + ,#{lateMinute} + ,#{leaveMinute} + ,#{absenteeismLateMinute} + ,#{absenteeismLeaveMinute} + ,#{entryAbnormalMinute} + ,#{todayClockNum} + ,#{attendanceDuration} + ) + + + + insert into att_group_person_relation(group_id, org_id, user_id) + values + + (#{params.groupId}, #{params.orgId}, #{params.userId}) + + + + + update att_group + set group_name = #{groupName}, + att_type = #{attType}, + update_user_id = #{updateUserId} + where id = #{groupId} + + + + update att_group_setting set att_day = #{attDay} + ,to_work_time = #{toWorkTime} + ,off_work_time = #{offWorkTime} + ,late_minute = #{lateMinute} + ,leave_minute = #{leaveMinute} + ,absenteeism_late_minute = + #{absenteeismLateMinute} + + ,absenteeism_leave_minute = + #{absenteeismLeaveMinute} + + ,entry_abnormal_minute = + #{entryAbnormalMinute} + + ,today_clock_num = #{todayClockNum} + ,attendance_duration = + #{attendanceDuration} + + where group_id = #{groupId} + + \ No newline at end of file