parent
e7a4871b18
commit
870381457b
|
|
@ -7,14 +7,18 @@ 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.SysRole;
|
||||
import com.bonus.system.api.domain.SysUser;
|
||||
import com.bonus.system.basic.dao.SysUserMapper;
|
||||
import com.bonus.system.basic.domain.SysNotice;
|
||||
import com.bonus.system.basic.service.SysNoticeService;
|
||||
import com.bonus.system.holiday.dao.WorkReportDao;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -29,11 +33,44 @@ public class SysNoticeController extends BaseController {
|
|||
@Autowired
|
||||
private SysNoticeService noticeService;
|
||||
|
||||
@Resource(name = "WorkReportDao")
|
||||
private WorkReportDao dao;
|
||||
|
||||
@Resource
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@RequiresPermissions("system:notice:list")
|
||||
@GetMapping("/list")
|
||||
@Log(title = "系统管理->我的消息->查询消息列表", businessType = BusinessType.QUERY)
|
||||
public TableDataInfo list(SysNotice bean) {
|
||||
try{
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
List<SysRole> sysRoleList = dao.getRoleListByUserId(userId);
|
||||
int roleCount = 0;
|
||||
if(!sysRoleList.isEmpty()){
|
||||
for (SysRole sysRole : sysRoleList) {
|
||||
if(sysRole.getRoleName().contains("管理员")){
|
||||
roleCount = 1;
|
||||
break;
|
||||
}else if(sysRole.getRoleName().contains("部门负责人")){
|
||||
roleCount = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(roleCount==2){
|
||||
String ids = userMapper.getOrg(userId);
|
||||
String userIdList = userMapper.getUserIdList(ids);
|
||||
bean.setRoleType("2");
|
||||
String[] split = userIdList.split(",");
|
||||
bean.setUserIdList(split);
|
||||
}else if(roleCount==1){
|
||||
bean.setRoleType("1");
|
||||
} else{
|
||||
bean.setRoleType("3");
|
||||
bean.setUserId(userId);
|
||||
}
|
||||
|
||||
List<SysNotice> list = noticeService.selectNoticeList(bean);
|
||||
return endPage(list);
|
||||
}catch (Exception e){
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.bonus.system.basic.domain.SysUserPost;
|
|||
import com.bonus.system.basic.domain.SysUserRole;
|
||||
import com.bonus.system.holiday.entity.HolidayKeyBean;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ public interface SysNoticeMapper
|
|||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<SysNotice> selectNoticeList(SysNotice bean);
|
||||
List<SysNotice> selectNoticeList(@Param("bean") SysNotice bean);
|
||||
|
||||
/**
|
||||
* 新增我的消息
|
||||
|
|
@ -62,4 +63,6 @@ public interface SysNoticeMapper
|
|||
List<Long> getUserIdByOrgId(Long orgId);
|
||||
|
||||
List<Long> getAttUserIdByOrgId(List<Long> orgList);
|
||||
|
||||
int delNotice(SysNotice bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -230,4 +230,6 @@ public interface SysUserMapper
|
|||
List<String> getRoleListById(SysUser user);
|
||||
|
||||
String getOrg(Long userId);
|
||||
|
||||
String getUserIdList(String userIdList);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,16 @@ public class SysNotice
|
|||
* 参数
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* 请假申请id
|
||||
*/
|
||||
private long leaveApplyId;
|
||||
|
||||
/**
|
||||
* 角色类型 1:人资专员和管理员;2:考勤员
|
||||
*/
|
||||
private String roleType;
|
||||
|
||||
private String[] userIdList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.system.basic.service;
|
|||
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.basic.domain.SysNotice;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -54,4 +55,10 @@ public interface SysNoticeService {
|
|||
* @return
|
||||
*/
|
||||
List<Long> getAttUserIdByOrgId(List<Long> orgList);
|
||||
|
||||
/**
|
||||
* 先删除之前的推送消息
|
||||
* @param bean
|
||||
*/
|
||||
AjaxResult delNotice(SysNotice bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ public class SysNoticeServiceImpl implements SysNoticeService
|
|||
SysNotice notice = new SysNotice();
|
||||
notice.setUserId(userId1);
|
||||
notice.setNoticeId(bean.getNoticeId());
|
||||
notice.setLeaveApplyId(bean.getLeaveApplyId());
|
||||
list.add(notice);
|
||||
}
|
||||
result = noticeMapper.insertUserNotice(list);
|
||||
|
|
@ -89,4 +90,16 @@ public class SysNoticeServiceImpl implements SysNoticeService
|
|||
public List<Long> getAttUserIdByOrgId(List<Long> orgList) {
|
||||
return noticeMapper.getAttUserIdByOrgId(orgList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult delNotice(SysNotice bean) {
|
||||
try {
|
||||
int re = noticeMapper.delNotice(bean);
|
||||
return re > 0 ? AjaxResult.success() : AjaxResult.error();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.toString(),e);
|
||||
return AjaxResult.error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,12 +86,18 @@ public class HolidayServiceImpl implements HolidayService {
|
|||
List<Long> userList = noticeService.getUserIdByOrgId(o.getOrgId());
|
||||
// 将 List 转换为数组
|
||||
if(!userList.isEmpty()){
|
||||
if (userList.size() > 1) { // 检查是否有多个元素
|
||||
// 如果有多个元素,检查并移除值为1的元素
|
||||
while (userList.contains(userId)) {
|
||||
userList.remove(Long.valueOf(userId));
|
||||
}
|
||||
}
|
||||
Long[] userIds = userList.toArray(new Long[0]);
|
||||
//发送审批消息
|
||||
SysNotice bean = new SysNotice();
|
||||
bean.setUserIds(userIds);
|
||||
bean.setUserId(userId);
|
||||
if("轮休".equals(o.getLeaveType())){
|
||||
/*if("轮休".equals(o.getLeaveType())){
|
||||
bean.setTitle("轮休申请");
|
||||
bean.setContent("轮休申请");
|
||||
bean.setType("65");
|
||||
|
|
@ -99,8 +105,19 @@ public class HolidayServiceImpl implements HolidayService {
|
|||
bean.setTitle("临时外出申请");
|
||||
bean.setContent("临时外出申请");
|
||||
bean.setType("66");
|
||||
}*/
|
||||
if("轮休".equals(o.getLeaveType())){
|
||||
bean.setTitle("轮休审批提醒");
|
||||
bean.setContent("轮休审批提醒");
|
||||
bean.setType("67");
|
||||
}else{
|
||||
bean.setTitle("临时外出审批提醒");
|
||||
bean.setContent("临时外出审批提醒");
|
||||
bean.setType("68");
|
||||
}
|
||||
|
||||
bean.setValue("");
|
||||
bean.setLeaveApplyId(o.getId());
|
||||
//推送消息
|
||||
noticeService.insertNotice(bean);
|
||||
}
|
||||
|
|
@ -117,12 +134,54 @@ public class HolidayServiceImpl implements HolidayService {
|
|||
public int updateHoliday(HolidayBean o) {
|
||||
o.setUpdateUserId(SecurityUtils.getLoginUser().getSysUser().getUserId());
|
||||
o.setExamineStatus("0");
|
||||
return holidayDao.updateHoliday(o);
|
||||
int i = holidayDao.updateHoliday(o);
|
||||
Long userId = SecurityUtils.getLoginUser().getSysUser().getUserId();
|
||||
if (i > 0) {
|
||||
//获取部门负责人
|
||||
List<Long> userList = noticeService.getUserIdByOrgId(o.getOrgId());
|
||||
// 将 List 转换为数组
|
||||
if(!userList.isEmpty()){
|
||||
if (userList.size() > 1) { // 检查是否有多个元素
|
||||
// 如果有多个元素,检查并移除值为1的元素
|
||||
while (userList.contains(userId)) {
|
||||
userList.remove(Long.valueOf(userId));
|
||||
}
|
||||
}
|
||||
Long[] userIds = userList.toArray(new Long[0]);
|
||||
//发送审批消息
|
||||
SysNotice bean = new SysNotice();
|
||||
bean.setUserIds(userIds);
|
||||
bean.setUserId(userId);
|
||||
if("轮休".equals(o.getLeaveType())){
|
||||
bean.setTitle("轮休审批提醒");
|
||||
bean.setContent("轮休审批提醒");
|
||||
bean.setType("67");
|
||||
}else{
|
||||
bean.setTitle("临时外出审批提醒");
|
||||
bean.setContent("临时外出审批提醒");
|
||||
bean.setType("68");
|
||||
}
|
||||
bean.setValue("");
|
||||
bean.setLeaveApplyId(o.getId());
|
||||
//先删除之前的推送消息
|
||||
noticeService.delNotice(bean);
|
||||
//推送消息
|
||||
noticeService.insertNotice(bean);
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteHolidayById(Long id) {
|
||||
return holidayDao.deleteHolidayById(id);
|
||||
int i = holidayDao.deleteHolidayById(id);
|
||||
if(i>0){
|
||||
SysNotice bean = new SysNotice();
|
||||
bean.setLeaveApplyId(id);
|
||||
//先删除之前的推送消息
|
||||
noticeService.delNotice(bean);
|
||||
}
|
||||
return i ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -160,6 +219,12 @@ public class HolidayServiceImpl implements HolidayService {
|
|||
List<Long> userList =holidayDao.getUserIdById(o.getId());
|
||||
// 将 List 转换为数组
|
||||
if(!userList.isEmpty()){
|
||||
if (userList.size() > 1) { // 检查是否有多个元素
|
||||
// 如果有多个元素,检查并移除值为1的元素
|
||||
while (userList.contains(updateUserId)) {
|
||||
userList.remove(Long.valueOf(updateUserId));
|
||||
}
|
||||
}
|
||||
Long[] userIds = userList.toArray(new Long[0]);
|
||||
//发送审批消息
|
||||
SysNotice bean = new SysNotice();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.system.basic.dao.SysNoticeMapper">
|
||||
<insert id="insertNotice" keyProperty="noticeId" useGeneratedKeys="true" keyColumn="id">
|
||||
insert into sys_notice(
|
||||
|
|
@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="content != null and content != ''">content,</if>
|
||||
<if test="type != null and type != ''">type,</if>
|
||||
<if test="value != null and value != ''">value,</if>
|
||||
<if test="leaveApplyId != null and leaveApplyId != ''">leave_apply_id,</if>
|
||||
create_time
|
||||
) values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
|
|
@ -17,21 +18,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="content != null and content != ''">#{content},</if>
|
||||
<if test="type != null and type != ''">#{type},</if>
|
||||
<if test="value != null and value != ''">#{value},</if>
|
||||
<if test="leaveApplyId != null and leaveApplyId != ''">#{leaveApplyId},</if>
|
||||
sysdate()
|
||||
)
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertUserNotice">
|
||||
insert into sys_notice_user(notice_id, user_id) values
|
||||
insert into sys_notice_user(notice_id, user_id,leave_apply_id) values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(#{item.noticeId},#{item.userId})
|
||||
(#{item.noticeId},#{item.userId},#{item.leaveApplyId})
|
||||
</foreach>
|
||||
</insert>
|
||||
<update id="updateStatus">
|
||||
update sys_notice_user set is_read='1' where notice_id = #{noticeId} and user_id = #{userId} and is_active = 1
|
||||
update sys_notice_user
|
||||
set is_read='1'
|
||||
where notice_id = #{noticeId}
|
||||
and user_id = #{userId}
|
||||
and is_active = 1
|
||||
</update>
|
||||
|
||||
<select id="selectNoticeList" resultType="com.bonus.system.basic.domain.SysNotice">
|
||||
SELECT
|
||||
<delete id="delNotice">
|
||||
DELETE FROM sys_notice WHERE `leave_apply_id` = #{leaveApplyId};
|
||||
DELETE FROM sys_notice_user WHERE `leave_apply_id` = #{leaveApplyId}
|
||||
</delete>
|
||||
|
||||
<select id="selectNoticeList" resultType="com.bonus.system.basic.domain.SysNotice" parameterType="com.bonus.system.basic.domain.SysNotice">
|
||||
SELECT DISTINCT
|
||||
snu.notice_id as noticeId,
|
||||
sn.title,
|
||||
sn.content,
|
||||
|
|
@ -45,49 +56,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN sys_notice sn on sn.id=snu.notice_id and sn.is_active=1
|
||||
LEFT JOIN sys_user su on su.user_id=sn.user_id and su.is_active=1
|
||||
LEFT JOIN sys_dict_data sdd on sdd.dict_code=sn.type and sdd.`status`=0
|
||||
WHERE
|
||||
snu.user_id=#{userId}
|
||||
and snu.is_active=1
|
||||
<if test="isRead != null and isRead != ''">
|
||||
and snu.is_read=#{isRead}
|
||||
WHERE snu.is_active=1
|
||||
<if test="bean.roleType =='3' || bean.roleType == 3 ">
|
||||
and sn.user_id=#{bean.userId}
|
||||
</if>
|
||||
<if test="bean.isRead != null and bean.isRead != ''">
|
||||
and snu.is_read=#{bean.isRead}
|
||||
</if>
|
||||
<if test="bean.roleType =='2' || bean.roleType == 2 ">
|
||||
<if test="bean.userIdList != null and bean.userIdList.length > 0">
|
||||
and sn.user_id in
|
||||
<foreach item="userId" collection="bean.userIdList" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</if>
|
||||
</if>
|
||||
order by sn.create_time desc
|
||||
</select>
|
||||
<select id="getDictData" resultType="java.lang.Long">
|
||||
SELECT
|
||||
dict_code as noticeId
|
||||
FROM
|
||||
sys_dict_data
|
||||
WHERE
|
||||
dict_label = '轮休申请'
|
||||
SELECT dict_code as noticeId
|
||||
FROM sys_dict_data
|
||||
WHERE dict_label = '轮休申请'
|
||||
AND dict_type = 'sys_notice'
|
||||
and `status`=0
|
||||
limit 1
|
||||
and `status` = 0 limit 1
|
||||
</select>
|
||||
<select id="getUserIdByModelName" resultType="java.lang.Long">
|
||||
SELECT DISTINCT
|
||||
sur.user_id
|
||||
FROM
|
||||
sys_menu sm
|
||||
LEFT JOIN sys_role_menu srm ON srm.menu_id = sm.menu_id
|
||||
AND srm.is_active = '1'
|
||||
LEFT JOIN sys_user_role sur ON sur.role_id = srm.role_id
|
||||
AND sur.is_active = '1'
|
||||
WHERE
|
||||
sm.menu_name = #{modelName}
|
||||
SELECT DISTINCT sur.user_id
|
||||
FROM sys_menu sm
|
||||
LEFT JOIN sys_role_menu srm ON srm.menu_id = sm.menu_id
|
||||
AND srm.is_active = '1'
|
||||
LEFT JOIN sys_user_role sur ON sur.role_id = srm.role_id
|
||||
AND sur.is_active = '1'
|
||||
WHERE sm.menu_name = #{modelName}
|
||||
</select>
|
||||
<select id="getUserIdByOrgId" resultType="java.lang.Long">
|
||||
SELECT DISTINCT
|
||||
user_id
|
||||
FROM
|
||||
sys_organization_head
|
||||
SELECT DISTINCT user_id
|
||||
FROM sys_organization_head
|
||||
WHERE org_id = #{orgId}
|
||||
</select>
|
||||
<select id="getAttUserIdByOrgId" resultType="java.lang.Long">
|
||||
SELECT DISTINCT
|
||||
attendance_user_id
|
||||
attendance_user_id
|
||||
FROM
|
||||
sys_organization
|
||||
sys_organization
|
||||
WHERE id IN
|
||||
<foreach collection="list" item="item" separator="," open="(" close=")">
|
||||
#{item}
|
||||
|
|
|
|||
|
|
@ -313,4 +313,12 @@
|
|||
WHERE su.is_active = 1
|
||||
AND su.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="getUserIdList" resultType="java.lang.String">
|
||||
SELECT GROUP_CONCAT(su.user_id SEPARATOR ',') AS orgName
|
||||
FROM `sys_user` su
|
||||
LEFT JOIN sys_user_org suo on suo.user_id = su.user_id and suo.is_active = 1
|
||||
WHERE su.is_active = 1
|
||||
AND suo.org_id in (#{userIdList})
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.system.holiday.dao.HolidayDao">
|
||||
<insert id="insertHoliday">
|
||||
<insert id="insertHoliday" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
|
||||
INSERT INTO leave_apply(user_id,user_name,org_id,org_name,leave_type,leave_reason,
|
||||
leave_start_date,leave_start_interval,leave_end_date,leave_end_interval,
|
||||
leave_duration,examine_status,source,create_user_id,is_agree, location, host_user_id, remark,type)
|
||||
|
|
|
|||
Loading…
Reference in New Issue