模块数据隔离,bug修改

Signed-off-by: lSun <15893999301@qq.com>
This commit is contained in:
lSun 2025-01-11 21:06:33 +08:00
parent 7ed73c85bd
commit 652e492770
12 changed files with 256 additions and 38 deletions

View File

@ -127,6 +127,25 @@ public class AttDetailByMonthController extends BaseController {
@GetMapping("/export")
public void export(HttpServletResponse response, AttDetailByMonthBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if( roleId !=null && !roleId.isEmpty()){
if (Collections.frequency(roleId, "1")==0 && Collections.frequency(roleId, "16")==0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
bean.setOrgList(ids);
}
}
}
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
//将表格时间区间取出来做标题
String title = bean.getAttCurrentMonth();

View File

@ -26,7 +26,7 @@ public interface AttendanceDetailsDao {
* @param bean 参数
* @return list bean
*/
List<AttDataDetailsBean> exportAttDetailsList(AttDataDetailsBean bean);
List<AttDataDetailsBean> exportAttDetailsList(@Param("bean") AttDataDetailsBean bean);
/**
* 获取考勤原始明细列表
@ -40,7 +40,7 @@ public interface AttendanceDetailsDao {
* @param bean 参数
* @return list bean
*/
List<AttDataDetailsBean> exportAttOriginalsList(AttDataDetailsBean bean);
List<AttDataDetailsBean> exportAttOriginalsList(@Param("bean") AttDataDetailsBean bean);
/**
* 修改考勤数据
@ -84,7 +84,7 @@ public interface AttendanceDetailsDao {
*/
List<AttDataDetailsBean> getAttDayReportDetailsList(AttDataDetailsBean bean);
List<AttDataDetailsBean> getOutCountList(AttDataDetailsBean bean);
List<AttDataDetailsBean> getOutCountList(@Param("bean") AttDataDetailsBean bean);
List<AttDataDetailsBean> getAttDayList(AttDataDetailsBean bean);

View File

@ -227,6 +227,11 @@ public class AttDataDetailsBean {
private String roleType;
private String orgListId;
/**
* 自己项目部所在分公司下的所有项目部id
*/
private List<String> orgIdList;
/**
* 考勤类型
*/

View File

@ -118,4 +118,9 @@ public class AttDetailBean {
/** 部门列表 */
private List<String> orgList;
/**
* 自己项目部所在分公司下的所有项目部id
*/
private List<String> orgIdList;
}

View File

@ -217,6 +217,25 @@ public class SysUserController extends BaseController {
@Log(title = "系统管理->人员信息->导出excel", businessType = BusinessType.EXPORT)
public void export(HttpServletResponse response, SysUser user) {
try{
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if( roleId !=null && !roleId.isEmpty()){
if (Collections.frequency(roleId, "1")==0 && Collections.frequency(roleId, "16")==0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
user.setOrgIdList(ids);
}
}
}
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "人员数据");

View File

@ -14,6 +14,8 @@ import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.utils.poi.MultiSheetExcelExporter;
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.AttDetailByMonthService;
import com.bonus.system.att.service.AttendanceDetailsService;
@ -21,6 +23,7 @@ import com.bonus.system.att.service.OrgChangeService;
import com.bonus.system.basic.domain.SysOrg;
import com.bonus.system.basic.domain.SysOrgExport;
import com.bonus.system.basic.service.SysOrgService;
import com.bonus.system.dept.dao.ProDeptRoleDao;
import com.bonus.system.dept.entity.SubOrgBean;
import com.bonus.system.dept.service.SubOrgService;
import com.bonus.system.evection.entity.EvectionBean;
@ -130,6 +133,9 @@ public class ExportFileController {
@Resource(name = "attDetailByMonthService")
private AttDetailByMonthService attDetailByMonthService;
@Resource(name = "ProDeptRoleDao")
private ProDeptRoleDao proDeptRoleDao;
/**
* 分公司项目部导出
@ -222,6 +228,26 @@ public class ExportFileController {
@GetMapping("/exportAttRecord")
public void att(HttpServletResponse response, AttDataDetailsBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if( roleId !=null && !roleId.isEmpty()){
if (Collections.frequency(roleId, "1")==0 && Collections.frequency(roleId, "16")==0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
bean.setOrgList(ids);
}
}
}
List<AttDataDetailsBean> attList;
if ("考勤明细".equals(bean.getExportType())) {
attList = attendanceDetailsService.exportAttDetailsList(bean);
@ -550,6 +576,26 @@ public class ExportFileController {
@GetMapping("/exportMonthReport")
public void exportMonthReport(HttpServletResponse response, AttMonthReportBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if (roleId != null && !roleId.isEmpty()) {
if (Collections.frequency(roleId, "1") == 0 && Collections.frequency(roleId, "16") == 0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
bean.setOrgList(ids);
}
}
}
MultiSheetExcelExporter exporter = new MultiSheetExcelExporter();
//将表格时间区间取出来做标题
String title = bean.getMonth();
@ -954,6 +1000,25 @@ public class ExportFileController {
@GetMapping("/exportWechatLeaveReporting")
public void exportWechatLeaveReporting(HttpServletResponse response, WechatLeaveReportingBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if( roleId !=null && !roleId.isEmpty()){
if (Collections.frequency(roleId, "1")==0 && Collections.frequency(roleId, "16")==0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
bean.setOrgList(ids);
}
}
}
List<WechatLeaveReportingBean> personExportVoList = new ArrayList<>();
List<WechatLeaveReportingBean> personLists = wechatLeaveReportingService.getLeaveReportingList(bean);
for (int i = 0; i < personLists.size(); i++) {
@ -994,6 +1059,25 @@ public class ExportFileController {
@GetMapping("/exportWechatEvection")
public void exportWechatEvection(HttpServletResponse response, WechatEvectionBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if (roleId != null && !roleId.isEmpty()) {
if (Collections.frequency(roleId, "1") == 0 && Collections.frequency(roleId, "16") == 0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
// ids.add(String.valueOf(mapVo.getId()));
}
bean.setOrgList(ids);
}
}
}
List<WechatEvectionBean> personExportVoList = new ArrayList<>();
List<WechatEvectionBean> personLists = wechatevectionService.getEvectionList(bean);
for (int i = 0; i < personLists.size(); i++) {

View File

@ -97,6 +97,25 @@ public class WechatController extends BaseController {
@SysLog(title = "小程序打卡数据", businessType = OperaType.EXPORT,module = "小程序打卡数据")
public void export(HttpServletResponse response, WechatBean bean) {
try {
SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
List<String> roleId = sysUser.getRoleList();
//管理员与人资角色可以看到所有
if( roleId !=null && !roleId.isEmpty()){
if (Collections.frequency(roleId, "1")==0 && Collections.frequency(roleId, "16")==0) {
List<MapVo> orgList = sysUser.getOrgList();
if (!orgList.isEmpty()) {
ArrayList<String> ids = new ArrayList<>();
for (MapVo mapVo : orgList) {
// ids.add(String.valueOf(mapVo.getId()));
String id = proDeptRoleDao.getOrgChildById(mapVo.getId());
// 使用 Arrays.asList() 将数组转换为 ArrayList
ArrayList<String> idList = new ArrayList<>(Arrays.asList(id.split(",")));
ids.addAll(idList);
}
bean.setOrgList(ids);
}
}
}
//先查询小程序打卡数据
List<WechatBean> list = wechatService.getWechatList(bean);
//轮休数据

View File

@ -28,5 +28,5 @@ public interface WechatDao {
* @param bean
* @return
*/
List<WechatBean> getWechatUserList(WechatBean bean);
List<WechatBean> getWechatUserList(@Param("bean") WechatBean bean);
}

View File

@ -15,7 +15,7 @@
leave_end_interval,
</if>
leave_duration, source, create_user_id, is_agree, location, host_user_id,host_user_name, remark,examine_status)
VALUES (#{userId}, #{userName}, #{orgId}, #{orgName}, '请假' , #{type}, #{leaveReason},
VALUES (#{userId}, #{userName}, #{orgId}, #{orgName}, #{type} , '请假', #{leaveReason},
#{leaveStartDate},
<if test="leaveStartInterval != null">
#{leaveStartInterval},
@ -44,7 +44,7 @@
</if>
<if test="type != null and type != ''">
type = #{type},
leave_type = #{type},
</if>
<if test="hostUserId != null and hostUserId != ''">
host_user_id = #{hostUserId},

View File

@ -67,17 +67,42 @@
v_att_update_data v
LEFT JOIN sys_user su ON su.user_id = v.user_id
LEFT JOIN sys_organization so ON so.id = v.org_id
LEFT JOIN (SELECT user_id,att_current_day,count(user_id) as outCount FROM att_work_abnormal GROUP BY att_current_day,user_id) awa ON v.user_id = awa.user_id
AND v.att_current_day = awa.att_current_day
LEFT JOIN att_source_data asd ON su.user_name = asd.`name` and asd.att_current_day = v.att_current_day
WHERE
v.att_current_day BETWEEN #{startDate} AND #{endDate} and su.is_active = 1
<if test="orgId != null and orgId != ''">
AND v.org_id = #{orgId}
v.att_current_day BETWEEN #{bean.startDate} AND #{bean.endDate} and su.is_active = 1
<if test="bean.orgId != null and bean.orgId != ''">
AND v.org_id = #{bean.orgId}
</if>
<if test="userName != null and userName != ''">
AND su.user_name like concat('%', #{userName}, '%')
<if test="bean.userName != null and bean.userName != ''">
AND su.user_name like concat('%', #{bean.userName}, '%')
</if>
<if test="attStatus != null and attStatus != ''">
AND v.toWorkAttStatus = #{attStatus} AND v.offWorkAttStatus = #{attStatus}
<if test='bean.attStatus != null and bean.attStatus == "6"'>
and (v.toWorkAttStatus in (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status' and is_leave = '1') or v.offWorkAttStatus in (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status' and is_leave = '1'))
</if>
<if test='bean.attStatus != null and bean.attStatus != "6"'>
<if test='bean.attStatus == "1"'>
and ( toWorkAttStatus = #{bean.attStatus} and offWorkAttStatus = #{bean.attStatus} )
</if>
<if test='bean.attStatus != "1"'>
and ( toWorkAttStatus = #{bean.attStatus} or offWorkAttStatus = #{bean.attStatus} )
</if>
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and v.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
GROUP BY v.user_id,v.att_current_day
ORDER BY CHAR_LENGTH(GROUP_CONCAT(DISTINCT so.org_name)) DESC
</select>
@ -98,17 +123,42 @@
v_att_data v
LEFT JOIN sys_user su ON su.user_id = v.user_id
LEFT JOIN sys_organization so ON so.id = v.org_id
LEFT JOIN (SELECT user_id,att_current_day,count(user_id) as outCount FROM att_work_abnormal GROUP BY att_current_day,user_id) awa ON v.user_id = awa.user_id
AND v.att_current_day = awa.att_current_day
LEFT JOIN att_source_data asd ON su.user_name = asd.`name` and asd.att_current_day = v.att_current_day
WHERE
v.att_current_day BETWEEN #{startDate} AND #{endDate} and su.is_active = 1
<if test="orgId != null and orgId != ''">
AND v.org_id = #{orgId}
v.att_current_day BETWEEN #{bean.startDate} AND #{bean.endDate} and su.is_active = 1
<if test="bean.orgId != null and bean.orgId != ''">
AND v.org_id = #{bean.orgId}
</if>
<if test="userName != null and userName != ''">
AND su.user_name like concat('%', #{userName}, '%')
<if test="bean.userName != null and bean.userName != ''">
AND su.user_name like concat('%', #{bean.userName}, '%')
</if>
<if test="attStatus != null and attStatus != ''">
AND v.toWorkAttStatus = #{attStatus} AND v.offWorkAttStatus = #{attStatus}
<if test='bean.attStatus != null and bean.attStatus == "6"'>
and (v.toWorkAttStatus in (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status' and is_leave = '1') or v.offWorkAttStatus in (SELECT dict_value
FROM sys_dict_data
where dict_type = 'att_status' and is_leave = '1'))
</if>
<if test='bean.attStatus != null and bean.attStatus != "6"'>
<if test='bean.attStatus == "1"'>
and ( toWorkAttStatus = #{bean.attStatus} and offWorkAttStatus = #{bean.attStatus} )
</if>
<if test='bean.attStatus != "1"'>
and ( toWorkAttStatus = #{bean.attStatus} or offWorkAttStatus = #{bean.attStatus} )
</if>
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and v.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
GROUP BY v.user_id,v.att_current_day
ORDER BY CHAR_LENGTH(GROUP_CONCAT(DISTINCT so.org_name)) DESC
</select>
@ -236,20 +286,28 @@
att_work_abnormal awa
LEFT JOIN sys_organization so ON so.id = awa.org_id and so.is_active = '1'
<where>
<if test="attCurrentDay != null and attCurrentDay != ''">
and awa.att_current_day = #{attCurrentDay}
<if test="bean.attCurrentDay != null and bean.attCurrentDay != ''">
and awa.att_current_day = #{bean.attCurrentDay}
</if>
<if test="startDate != null and startDate != '' and endDate != null and endDate != ''">
and awa.att_current_day between #{startDate} AND #{endDate}
<if test="bean.startDate != null and bean.startDate != '' and bean.endDate != null and bean.endDate != ''">
and awa.att_current_day between #{bean.startDate} AND #{bean.endDate}
</if>
<if test="userId != null and userId != ''">
and awa.user_id = #{userId}
<if test="bean.userId != null and bean.userId != ''">
and awa.user_id = #{bean.userId}
</if>
<if test="userName != null and userName != ''">
and locate(#{userName},awa.user_name)
<if test="bean.userName != null and bean.userName != ''">
and locate(#{bean.userName},awa.user_name)
</if>
<if test="attCurrentMonth != null and attCurrentMonth != ''">
and locate(#{attCurrentMonth},awa.att_current_day)
<if test="bean.attCurrentMonth != null and bean.attCurrentMonth != ''">
and locate(#{bean.attCurrentMonth},awa.att_current_day)
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and so.id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
</where>
ORDER BY

View File

@ -5,7 +5,7 @@
<mapper namespace="com.bonus.system.evection.dao.EvectionDao">
<insert id="insertEvection">
INSERT INTO leave_apply(user_id, user_name, org_id, org_name, leave_type, leave_reason,
INSERT INTO leave_apply(user_id, user_name, org_id, org_name, leave_type,type, leave_reason,
leave_start_date,
<if test="leaveStartInterval != null">
leave_start_interval,
@ -16,7 +16,7 @@
</if>
leave_duration, source, create_user_id, is_agree, location, host_user_id,host_user_name, remark
, leave_form_id, submit_id,examine_status,is_outside,is_xizang)
VALUES (#{userId}, #{userName}, #{orgId}, #{orgName}, '出差', #{leaveReason},
VALUES (#{userId}, #{userName}, #{orgId}, #{orgName}, '出差','出差', #{leaveReason},
#{leaveStartDate},
<if test="leaveStartInterval != null">
#{leaveStartInterval},

View File

@ -71,22 +71,31 @@
FROM
att_data ad
LEFT JOIN sys_user su ON ad.user_id = su.user_id
LEFT JOIN sys_user_org suo on su.user_id = suo.user_id
LEFT JOIN ( SELECT * FROM sys_dict_data WHERE dict_type = 'att_status' ) sd ON ad.att_status = sd.dict_value
WHERE
ad.is_active = '1' AND
ad.data_source = '3'
AND sd.dict_value IN ( '1', '2', '4', '7', '8', '9', '10', '19' )
<if test="userId!=null and userId!=''">
AND ad.user_id = #{userId}
<if test="bean.userId!=null and bean.userId!=''">
AND ad.user_id = #{bean.userId}
</if>
<if test="userName!=null and userName!=''">
AND su.user_name like concat('%', #{userName}, '%')
<if test="bean.userName!=null and bean.userName!=''">
AND su.user_name like concat('%', #{bean.userName}, '%')
</if>
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
AND ad.att_current_day BETWEEN #{startDate} AND #{endDate}
<if test="bean.startDate!=null and bean.startDate!='' and bean.endDate!=null and bean.endDate!=''">
AND ad.att_current_day BETWEEN #{bean.startDate} AND #{bean.endDate}
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and suo.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
ORDER BY att_current_time DESC
</select>