模块数据隔离,bug修改

Signed-off-by: lSun <15893999301@qq.com>
This commit is contained in:
lSun 2024-12-26 16:01:07 +08:00
parent 5d999bd16b
commit 35369ecc3f
18 changed files with 246 additions and 11 deletions

View File

@ -56,6 +56,39 @@ public class AttendanceDetailsController extends BaseController {
@Log(title = "考勤报表->考勤明细->列表查询", businessType = BusinessType.QUERY)
public TableDataInfo getOriginalList(AttDataDetailsBean bean) {
try{
// 部门负责人和部门考勤员可以在考勤明细页面看到本部门人员的考勤信息管理员和人资专员可以看所有数据普通人员看到自己数据
Long userId = SecurityUtils.getUserId();
List<SysRole> sysRoleList = dao.getRoleListByUserId(userId);
int roleCount = 0;
if(!sysRoleList.isEmpty()){
for (SysRole sysRole : sysRoleList) {
if(sysRole.getRoleId().equals(1L)){
roleCount = 1;
break;
}else if(sysRole.getRoleId().equals(16L)){
roleCount = 1;
break;
}else if(sysRole.getRoleId().equals(14L)){
roleCount = 2;
break;
}else if(sysRole.getRoleId().equals(13L)){
roleCount = 2;
break;
}else if(sysRole.getRoleId().equals(15L)){
roleCount = 3;
break;
}
}
}
if(roleCount==2){
String ids = userMapper.getOrg(userId);
bean.setRoleType("2");
bean.setOrgListId(ids);
}else if(roleCount==3){
bean.setRoleType("3");
bean.setUserId(userId);
}
startPage();
return getDataTable(attendanceDetailsService.selectAttOriginalList(bean));
}catch (Exception e){
@ -78,19 +111,19 @@ public class AttendanceDetailsController extends BaseController {
int roleCount = 0;
if(!sysRoleList.isEmpty()){
for (SysRole sysRole : sysRoleList) {
if(sysRole.getRoleName().contains("管理员")){
if(sysRole.getRoleId().equals(1L)){
roleCount = 1;
break;
}else if(sysRole.getRoleName().contains("人资专员")){
}else if(sysRole.getRoleId().equals(16L)){
roleCount = 1;
break;
}else if(sysRole.getRoleName().contains("部门负责人")){
}else if(sysRole.getRoleId().equals(14L)){
roleCount = 2;
break;
}else if(sysRole.getRoleName().contains("部门考勤员")){
}else if(sysRole.getRoleId().equals(13L)){
roleCount = 2;
break;
}else if(sysRole.getRoleName().contains("普通人员")){
}else if(sysRole.getRoleId().equals(15L)){
roleCount = 3;
break;
}

View File

@ -54,7 +54,7 @@ public class EvectionServiceImpl implements EvectionService {
o.setUuid(uuId);
o.setCreateUserId(userId);
o.setSource("1");
String travelers = o.getTravelers();
String travelers = o.getTravelers();
String[] split = travelers.split(",");
String[] splitName = o.getTravelersName().split(",");
int k = 0;

View File

@ -161,4 +161,37 @@ public class LeaveReportingController extends BaseController {
return error("系统异常");
}
/**
* 根据用户id 临时外出审核 代理主持工作人员
*/
@GetMapping(value = "/getUserListCheck/{id}")
@Log(title = "流程管理->临时外出审核->查询同部门人员", businessType = BusinessType.QUERY)
public AjaxResult getUserListCheck(@PathVariable Long id) {
try{
return success(leaveReportingService.getUserListCheck(id));
}catch (Exception e){
log.error(e.toString(),e);
}
return error("系统异常");
}
/**
* 休假时间去除周末以及法定节假日
* 1查询出所有周末以及节假日的日期
* 2传入开始日期和结束日期判断是否含有周末或者节假日
* 3计算去除周末或节假日后剩余天数
*/
@PostMapping("/getDays")
@Log(title = "流程管理->休假报备->计算时间", businessType = BusinessType.QUERY)
public AjaxResult getDays(@Validated @RequestBody LeaveReportingBean bean){
try {
return success(leaveReportingService.getDays(bean));
} catch (Exception e) {
log.error(e.toString(),e);
}
return error("操作失败");
}
}

View File

@ -37,4 +37,6 @@ public interface LeaveReportingDao {
LeaveReportingBean getPostName(Long id);
List<LeaveReportingBean> getUserList(@Param("params")LeaveReportingBean bean);
List<LeaveReportingBean> getFestivalAndHoliday(LeaveReportingBean bean);
}

View File

@ -160,4 +160,7 @@ public class LeaveReportingBean extends BaseBean {
*/
private List<String> orgList;
private String date;
private String name;
}

View File

@ -62,4 +62,9 @@ public interface LeaveReportingService {
LeaveReportingBean getPostName(Long id);
AjaxResult getUserList(Long id);
LeaveReportingBean getDays(LeaveReportingBean bean);
AjaxResult getUserListCheck(Long id);
}

View File

@ -30,6 +30,8 @@ import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -119,4 +121,69 @@ public class LeaveReportingServiceImpl implements LeaveReportingService {
return AjaxResult.error();
}
}
private static final ThreadLocal<SimpleDateFormat> DATE_FORMAT = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd");
}
};
@Override
public LeaveReportingBean getDays(LeaveReportingBean bean) {
try {
// 查询出所有周末以及节假日的日期
List<LeaveReportingBean> holidays = leaveReportingDao.getFestivalAndHoliday(bean);
// 将节假日转换为 Set<String>提高查找效率
Set<String> holidaySet = new HashSet<>();
for (LeaveReportingBean holiday : holidays) {
holidaySet.add(holiday.getDate());
}
Date startDate = null;
startDate = parseDate(String.valueOf(bean.getLeaveStartDate()));
Date endDate = parseDate(String.valueOf(bean.getLeaveEndDate()));
Calendar calendar = Calendar.getInstance();
calendar.setTime(startDate);
int totalDays = 0;
while (!calendar.getTime().after(endDate)) {
String currentDate = formatDate(calendar.getTime());
if (!holidaySet.contains(currentDate)) {
totalDays++;
}
calendar.add(Calendar.DAY_OF_MONTH, 1);
}
bean.setDate(String.valueOf(totalDays));
return bean;
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
@Override
public AjaxResult getUserListCheck(Long id) {
try {
LeaveReportingBean bean = new LeaveReportingBean();
bean.setId(id);
List<LeaveReportingBean> list = leaveReportingDao.getUserList(bean);
return AjaxResult.success(list);
} catch (Exception e) {
log.error(e.toString(),e);
return AjaxResult.error();
}
}
// 辅助方法将字符串解析为Date对象
private Date parseDate(String dateStr) throws ParseException {
return DATE_FORMAT.get().parse(dateStr);
}
// 辅助方法将Date对象格式化为字符串
private String formatDate(Date date) {
return DATE_FORMAT.get().format(date);
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.system.wechat.dao;
import com.bonus.system.wechat.entity.WechatBean;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@ -19,7 +20,7 @@ public interface WechatDao {
* @param bean
* @return
*/
List<WechatBean> getWechatList(WechatBean bean);
List<WechatBean> getWechatList(@Param("bean") WechatBean bean);
/**
* 小程序打卡数据列表-用户查询

View File

@ -85,4 +85,9 @@ public class WechatBean extends BaseBean {
*/
@Excel(name = "备注", width = 20.0,height = 20.0, orderNum = "5")
private String errorRemake;
/**
* 自己项目部所在分公司下的所有项目部id
*/
private List<String> orgList;
}

View File

@ -3,6 +3,7 @@ package com.bonus.system.wechat.service;
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.evection.dao.EvectionDao;
import com.bonus.system.evection.entity.EvectionBean;
import com.bonus.system.evection.service.EvectionService;
@ -12,10 +13,7 @@ import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
/**
* 出差报备-业务层
@ -31,6 +29,21 @@ public class WechatEvectionServiceImpl implements WechatEvectionService {
@Override
public List<WechatEvectionBean> getEvectionList(WechatEvectionBean bean) {
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()));
}
bean.setOrgList(ids);
}
}
}
return wechatEvectionDao.getEvectionList(bean);
}

View File

@ -3,6 +3,7 @@ package com.bonus.system.wechat.service;
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.leaveReporting.dao.LeaveReportingDao;
import com.bonus.system.leaveReporting.entity.LeaveReportingBean;
import com.bonus.system.leaveReporting.service.LeaveReportingService;
@ -13,6 +14,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
@ -29,6 +31,21 @@ public class WechatLeaveReportingServiceImpl implements WechatLeaveReportingServ
@Override
public List<WechatLeaveReportingBean> getLeaveReportingList(WechatLeaveReportingBean bean) {
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()));
}
bean.setOrgList(ids);
}
}
}
return wechatLeaveReportingDao.getLeaveReportingList(bean);
}

View File

@ -2,6 +2,9 @@ package com.bonus.system.wechat.service;
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.wechat.dao.WechatDao;
import com.bonus.system.wechat.entity.WechatBean;
import org.springframework.stereotype.Service;
@ -22,6 +25,21 @@ public class WechatServiceImpl implements WechatService {
@Override
public List<WechatBean> getWechatList(WechatBean bean) {
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()));
}
bean.setOrgList(ids);
}
}
}
return wechatDao.getWechatList(bean);
}

View File

@ -167,4 +167,11 @@
)
</if>
</select>
<select id="getFestivalAndHoliday" resultType="com.bonus.system.leaveReporting.entity.LeaveReportingBean">
SELECT id, date, `name`, type
FROM
sys_holiday
where type ='1'
</select>
</mapper>

View File

@ -124,6 +124,12 @@
<if test="attStatus != null and attStatus != ''">
AND (v.toWorkAttStatus = #{attStatus} OR v.offWorkAttStatus = #{attStatus})
</if>
<if test="roleType =='2' || roleType == 2 ">
and v.org_id in (#{orgListId})
</if>
<if test="roleType =='3' || roleType == 3 ">
and su.user_id = #{userId}
</if>
ORDER BY att_current_day DESC
</select>

View File

@ -230,6 +230,7 @@
</select>
<select id="getRoleListByUserId" resultType="com.bonus.system.api.domain.SysRole">
SELECT
sr.role_id as roleId,
sr.role_name as roleName
FROM
sys_user_role sur

View File

@ -46,6 +46,13 @@
<if test="bean.params.endTime != null and bean.params.endTime != ''">
and date_format(l.leave_end_date,'%y%m%d') &lt;= date_format(#{bean.params.endTime},'%y%m%d')
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and l.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
GROUP BY
l.id,
l.user_id,

View File

@ -38,6 +38,13 @@
<if test="params.params.endTime != null and params.params.endTime != ''"><!-- 结束时间检索 -->
and date_format(l.leave_end_date,'%y%m%d') &lt;= date_format(#{params.params.endTime},'%y%m%d')
</if>
<if test='bean.orgList != null and bean.orgList.size() > 0'>
and l.org_id in (
<foreach collection="bean.orgList" item="item" separator=",">
#{item}
</foreach>
)
</if>
GROUP BY
l.id,
l.user_id,

View File

@ -22,6 +22,7 @@
ad.att_type
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'
@ -34,6 +35,15 @@
<if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
AND ad.att_current_day BETWEEN #{startDate} AND #{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>
GROUP BY ad.user_id,
ad.org_id,
ad.att_current_day