组织变更记录添加
This commit is contained in:
parent
e8e7a6ea69
commit
2bd3cfd8d9
|
|
@ -3,13 +3,18 @@ package com.bonus.system.basic.controller;
|
|||
import com.bonus.common.core.domain.R;
|
||||
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.basic.domain.SysOrg;
|
||||
import com.bonus.system.basic.domain.SysOrgHistoryBean;
|
||||
import com.bonus.system.basic.domain.SysTree;
|
||||
import com.bonus.system.basic.service.SysOrgService;
|
||||
import com.bonus.system.dept.dao.ProDeptRoleDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -17,7 +22,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 组织信息
|
||||
|
|
@ -33,6 +39,9 @@ public class SysOrgController extends BaseController
|
|||
@Resource(name = "sysOrgService")
|
||||
private SysOrgService sysOrgService;
|
||||
|
||||
@Resource(name = "ProDeptRoleDao")
|
||||
private ProDeptRoleDao proDeptRoleDao;
|
||||
|
||||
/**
|
||||
* 获取组织列表
|
||||
*/
|
||||
|
|
@ -194,4 +203,19 @@ public class SysOrgController extends BaseController
|
|||
return error("系统异常");
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:orgHis:list")
|
||||
@GetMapping("/getOrgHistoryList")
|
||||
@Log(title = "系统管理->组织变动记录->查询列表", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo getOrgHistoryList(SysOrgHistoryBean bean) {
|
||||
try{
|
||||
List<SysOrgHistoryBean> list = sysOrgService.getOrgHistoryList(bean);
|
||||
return endPage(list);
|
||||
}catch (Exception e){
|
||||
logger.error(e.toString(),e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.bonus.system.basic.dao;
|
|||
|
||||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.basic.domain.SysOrgHistoryBean;
|
||||
import com.bonus.system.basic.domain.SysOrgImport;
|
||||
import com.bonus.system.basic.domain.SysTree;
|
||||
import com.bonus.system.holiday.entity.HolidayKeyBean;
|
||||
|
|
@ -140,4 +141,10 @@ public interface SysOrgDao {
|
|||
* @return
|
||||
*/
|
||||
List<SysOrg> selectOrgListPerson(@Param("bean")SysOrg sysOrg);
|
||||
/**
|
||||
* 查询组织变动记录
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<SysOrgHistoryBean> getOrgHistoryList(SysOrgHistoryBean bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
package com.bonus.system.basic.domain;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 组织管理
|
||||
* @author zys
|
||||
*/
|
||||
@Data
|
||||
public class SysOrgHistoryBean {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@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;
|
||||
/**
|
||||
* 岗位
|
||||
*/
|
||||
@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;
|
||||
|
||||
/**
|
||||
* 变动前部门名称
|
||||
*/
|
||||
@Excel(name = "变动前部门", width = 20.0,height = 20.0, orderNum = "5")
|
||||
private String oldOrgName;
|
||||
|
||||
/**
|
||||
* 变动后部门名称
|
||||
*/
|
||||
@Excel(name = "变动后部门", width = 20.0,height = 20.0, orderNum = "6")
|
||||
private String afterOrgName;
|
||||
/**
|
||||
* 变动时间
|
||||
*/
|
||||
@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;
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
package com.bonus.system.basic.service;
|
||||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.domain.MapVo;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.basic.domain.SysOrgHistoryBean;
|
||||
import com.bonus.system.basic.domain.SysTree;
|
||||
import com.bonus.system.basic.domain.vo.TreeSelect;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
@ -104,4 +107,13 @@ public interface SysOrgService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult orgUpload(MultipartFile file, HttpServletRequest request, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 查询组织变动记录
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<SysOrgHistoryBean> getOrgHistoryList(SysOrgHistoryBean bean);
|
||||
|
||||
List<MapVo> getOrgIdList(Long userId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ import com.bonus.system.api.domain.SysUser;
|
|||
import com.bonus.system.att.utils.AddressCoordinateFormatUtil;
|
||||
import com.bonus.system.att.utils.TreeUtils;
|
||||
import com.bonus.system.basic.dao.SysOrgDao;
|
||||
import com.bonus.system.basic.domain.SysNotice;
|
||||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.basic.domain.SysOrgImport;
|
||||
import com.bonus.system.basic.domain.SysTree;
|
||||
import com.bonus.system.basic.domain.*;
|
||||
import com.bonus.system.basic.domain.vo.TreeSelect;
|
||||
import com.bonus.system.basic.service.SysNoticeService;
|
||||
import com.bonus.system.basic.service.SysOrgService;
|
||||
|
|
@ -318,6 +315,47 @@ public class SysOrgServiceImpl implements SysOrgService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysOrgHistoryBean> getOrgHistoryList(SysOrgHistoryBean bean) {
|
||||
List<SysOrgHistoryBean> list =orgDao.getOrgHistoryList(bean);
|
||||
List<SysOrgHistoryBean> process = process(list);
|
||||
//后端生成的字段,无法在sql中查询
|
||||
if(bean.getOldOrgName() != null){
|
||||
process = process.stream().filter(s -> s.getOldOrgName().contains(bean.getOldOrgName())).collect(Collectors.toList());
|
||||
}
|
||||
if(bean.getAfterOrgName() != null){
|
||||
process = process.stream().filter(s -> s.getAfterOrgName().contains(bean.getAfterOrgName())).collect(Collectors.toList());
|
||||
}
|
||||
return process;
|
||||
}
|
||||
|
||||
public static List<SysOrgHistoryBean> process(List<SysOrgHistoryBean> list) {
|
||||
// 按 userId 分组
|
||||
Map<Long, List<SysOrgHistoryBean>> groupedByUserId = list.stream()
|
||||
.collect(Collectors.groupingBy(SysOrgHistoryBean::getUserId));
|
||||
List<SysOrgHistoryBean> result = new ArrayList<>();
|
||||
for (List<SysOrgHistoryBean> userList : groupedByUserId.values()) {
|
||||
// 按 changeTime 正序排序
|
||||
userList.sort(Comparator.comparing(SysOrgHistoryBean::getChangeTime));
|
||||
// 舍弃少于2条数据的 userList
|
||||
if (userList.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
// 内推 afterOrgName 到 oldOrgName
|
||||
for (int i = 0; i < userList.size() - 1; i++) {
|
||||
SysOrgHistoryBean current = userList.get(i);
|
||||
SysOrgHistoryBean next = userList.get(i + 1);
|
||||
next.setOldOrgName(current.getAfterOrgName());
|
||||
}
|
||||
// 删除第一条数据
|
||||
userList.remove(0);
|
||||
// 将处理后的 userList 添加到结果中
|
||||
result.addAll(userList);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断导入部门、请假类型 是否存在
|
||||
*
|
||||
|
|
@ -470,4 +508,13 @@ public class SysOrgServiceImpl implements SysOrgService {
|
|||
return !getChildList(list, t).isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户编号查询组织编号
|
||||
* @param userId
|
||||
*/
|
||||
@Override
|
||||
public List<MapVo> getOrgIdList(Long userId){
|
||||
return orgDao.getOrgIdList(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.bonus.system.att.service.OrgChangeService;
|
|||
import com.bonus.system.basic.dao.SysOrgDao;
|
||||
import com.bonus.system.basic.domain.SysOrg;
|
||||
import com.bonus.system.basic.domain.SysOrgExport;
|
||||
import com.bonus.system.basic.domain.SysOrgHistoryBean;
|
||||
import com.bonus.system.basic.service.SysOrgService;
|
||||
import com.bonus.system.dept.dao.ProDeptRoleDao;
|
||||
import com.bonus.system.dept.entity.EightMembersVacancyVo;
|
||||
|
|
@ -510,6 +511,32 @@ public class ExportFileController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织变更记录导出
|
||||
*
|
||||
* @param response
|
||||
* @param bean
|
||||
* @return void
|
||||
* @author:fly
|
||||
* @date:2025-03-07-10:30
|
||||
*/
|
||||
@RequiresPermissions("org:orgHis:export")
|
||||
@GetMapping("/exportOrgHis")
|
||||
public void exportOrgHis(HttpServletResponse response, SysOrgHistoryBean bean) {
|
||||
try {
|
||||
List<SysOrgHistoryBean> orgHistoryList = sysOrgService.getOrgHistoryList(bean);
|
||||
for (int i = 0; i < orgHistoryList.size(); i++) {
|
||||
// 创建一个 SimpleDateFormat 对象,用于格式化日期
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// 将 Date 转换为 String
|
||||
String dateString = formatter.format(orgHistoryList.get(i).getChangeTime());
|
||||
orgHistoryList.get(i).setUpdateTime(dateString);
|
||||
}
|
||||
extracted(orgHistoryList, SysOrgHistoryBean.class, "组织变更记录", "组织变更记录", "组织变更记录导出", response);
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日报表导出
|
||||
|
|
@ -798,40 +825,6 @@ public class ExportFileController {
|
|||
}
|
||||
}
|
||||
|
||||
private List<String> getMonthFirstAndLast(String monthString) {
|
||||
List<String> months = new ArrayList<>();
|
||||
// 定义日期格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
YearMonth yearMonth;
|
||||
// 使用预定义的 ISO_LOCAL_DATE 格式 (yyyy-MM-dd)
|
||||
DateTimeFormatter isoFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||
|
||||
try {
|
||||
// 判空及默认为当月
|
||||
if (monthString == null || monthString.trim().isEmpty()) {
|
||||
// 如果字符串为空或仅包含空白字符,取当前月份
|
||||
yearMonth = YearMonth.from(LocalDate.now());
|
||||
} else {
|
||||
// 尝试将字符串解析为 YearMonth 对象
|
||||
yearMonth = YearMonth.parse(monthString, formatter);
|
||||
}
|
||||
// 获取该月的第一天
|
||||
LocalDate firstDayOfMonth = yearMonth.atDay(1);
|
||||
// 获取该月的最后一天
|
||||
LocalDate lastDayOfMonth = yearMonth.atEndOfMonth();
|
||||
months.add(firstDayOfMonth.format(isoFormatter));
|
||||
months.add(lastDayOfMonth.format(isoFormatter));
|
||||
} catch (DateTimeParseException e) {
|
||||
// 如果解析失败,打印错误信息并使用当前月份
|
||||
YearMonth currentYearMonth = YearMonth.from(LocalDate.now());
|
||||
LocalDate firstDayOfCurrentMonth = currentYearMonth.atDay(1);
|
||||
LocalDate lastDayOfCurrentMonth = currentYearMonth.atEndOfMonth();
|
||||
months.add(firstDayOfCurrentMonth.format(isoFormatter));
|
||||
months.add(lastDayOfCurrentMonth.format(isoFormatter));
|
||||
}
|
||||
return months;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 导出excel文件
|
||||
|
|
|
|||
|
|
@ -171,6 +171,41 @@
|
|||
|
||||
</select>
|
||||
|
||||
<select id="getOrgHistoryList" resultType="com.bonus.system.basic.domain.SysOrgHistoryBean">
|
||||
SELECT
|
||||
suo.user_id,
|
||||
su.user_name,
|
||||
su.phone as phoneNumber,
|
||||
suo.org_id,
|
||||
so.org_name as afterOrgName,
|
||||
suo.update_time as changeTime,
|
||||
GROUP_CONCAT( DISTINCT sdd.dict_label ) as postName,
|
||||
GROUP_CONCAT( DISTINCT sr.role_name ) as roleName
|
||||
FROM
|
||||
sys_user_org suo
|
||||
LEFT JOIN sys_organization so ON so.id = suo.org_id
|
||||
LEFT JOIN sys_user su ON su.user_id = suo.user_id
|
||||
LEFT JOIN sys_user_post sup ON sup.user_id = suo.user_id
|
||||
LEFT JOIN sys_dict_data sdd ON sdd.dict_code = sup.post_id
|
||||
AND sdd.dict_type = 'post_list'
|
||||
AND sdd.`status` = 0
|
||||
LEFT JOIN sys_user_role sur ON sur.user_id = suo.user_id
|
||||
LEFT JOIN sys_role sr ON sr.role_id = sur.role_id
|
||||
AND sr.del_flag = 0
|
||||
WHERE
|
||||
suo.user_id IN ( SELECT user_id FROM sys_user_org GROUP BY user_id HAVING COUNT(*) > 1 )
|
||||
<if test="userName != null and userName != ''">
|
||||
AND locate(#{userName}, su.user_name)
|
||||
</if>
|
||||
<if test="month != null and month != ''">
|
||||
AND locate(#{month},suo.update_time)
|
||||
</if>
|
||||
GROUP BY
|
||||
suo.user_id,
|
||||
suo.org_id,
|
||||
suo.update_time
|
||||
</select>
|
||||
|
||||
<insert id="insertOrg" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
insert into sys_organization(org_name,
|
||||
<if test="attendanceUserId != null and attendanceUserId != '' and attendanceUserId != 'null'">
|
||||
|
|
|
|||
Loading…
Reference in New Issue