Browse Source

feat: [试验方法] 新增试验方法发消息

master
memorylkf 3 months ago
parent
commit
cb8bf7a218
11 changed files with 336 additions and 13 deletions
  1. +17
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/HomeController.java
  2. +97
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Notice.java
  3. +14
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/NoticeMapper.java
  4. +46
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/INoticeService.java
  5. +97
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/NoticeServiceImpl.java
  6. +6
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java
  7. +1
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java
  8. +8
    -0
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java
  9. +1
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java
  10. +6
    -0
      hxhq-modules/hxhq-system/src/main/resources/mapper/business/NoticeMapper.xml
  11. +43
    -11
      hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml

+ 17
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/HomeController.java View File

@ -1,8 +1,10 @@
package com.hxhq.business.controller; package com.hxhq.business.controller;
import com.hxhq.business.domain.Notice;
import com.hxhq.business.dto.study.StudyListDto; import com.hxhq.business.dto.study.StudyListDto;
import com.hxhq.business.enums.study.StudyTypeEnum; import com.hxhq.business.enums.study.StudyTypeEnum;
import com.hxhq.business.form.study.StudySearchForm; import com.hxhq.business.form.study.StudySearchForm;
import com.hxhq.business.service.INoticeService;
import com.hxhq.business.service.IStudyService; import com.hxhq.business.service.IStudyService;
import com.hxhq.common.core.web.controller.BaseController; import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult; import com.hxhq.common.core.web.domain.AjaxResult;
@ -26,6 +28,8 @@ public class HomeController extends BaseController
{ {
@Autowired @Autowired
private IStudyService studyService; private IStudyService studyService;
@Autowired
private INoticeService noticeService;
/** /**
* 查询首页数量 * 查询首页数量
@ -36,4 +40,17 @@ public class HomeController extends BaseController
{ {
return AjaxResult.success(studyService.queryHomeCount()); return AjaxResult.success(studyService.queryHomeCount());
} }
/**
* 查询试验列表
*/
@GetMapping("/noticeList")
@RequiresPermissions("business:study:list")
public TableDataInfo noticeService()
{
startPage();
List<Notice> list = noticeService.queryList();
TableDataInfo table = getDataTable(list);
return table;
}
} }

+ 97
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/domain/Notice.java View File

@ -0,0 +1,97 @@
package com.hxhq.business.domain;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hxhq.common.core.domain.MpBaseEntity;
/**
* 系统通知对象 t_notice
*
* @author hxhq
* @date 2026-01-16
*/
@TableName("t_notice")
public class Notice extends MpBaseEntity
{
private static final long serialVersionUID = 1L;
/** 通知人id */
private Long userId;
/** 通知人姓名 */
private String userName;
/** 标题 */
private String title;
/** 内容 */
private String content;
/** 状态1已发送,10已阅读 */
private Integer status;
/** 跳转地址 */
private String url;
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
{
return userName;
}
public void setTitle(String title)
{
this.title = title;
}
public String getTitle()
{
return title;
}
public void setContent(String content)
{
this.content = content;
}
public String getContent()
{
return content;
}
public void setStatus(Integer status)
{
this.status = status;
}
public Integer getStatus()
{
return status;
}
public void setUrl(String url)
{
this.url = url;
}
public String getUrl()
{
return url;
}
}

+ 14
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/mapper/NoticeMapper.java View File

@ -0,0 +1,14 @@
package com.hxhq.business.mapper;
import com.hxhq.business.domain.Notice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 系统通知Mapper接口
*
* @author hxhq
* @date 2026-01-16
*/
public interface NoticeMapper extends BaseMapper<Notice>
{
}

+ 46
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/INoticeService.java View File

@ -0,0 +1,46 @@
package com.hxhq.business.service;
import java.util.List;
import com.hxhq.business.domain.Notice;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 系统通知Service接口
*
* @author hxhq
* @date 2026-01-16
*/
public interface INoticeService extends IService<Notice>
{
/**
* 查询系统通知列表
*
* @return 系统通知集合
*/
List<Notice> queryList();
/**
* 保存
* @param title
* @param userId
* @param url
*/
void save(String title,Long userId,String url);
/**
* 批量保存试验方法
* @param title
* @param userIdList
* @param url
*/
void saveBatch(String title,List<Long> userIdList, String url);
/**
* 新增试验方便保存
* @param studyId
* @param studySubjectId
* @param createUserId
*/
void saveStudyMethod(Long studyId,Long studySubjectId,Long createUserId);
}

+ 97
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/NoticeServiceImpl.java View File

@ -0,0 +1,97 @@
package com.hxhq.business.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.Study;
import com.hxhq.business.domain.StudySubject;
import com.hxhq.business.dto.select.DeptUserTreeDto;
import com.hxhq.business.enums.study.StudyTypeEnum;
import com.hxhq.business.service.IStudyService;
import com.hxhq.business.service.IStudySubjectService;
import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.security.utils.SecurityUtils;
import com.hxhq.system.mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.NoticeMapper;
import com.hxhq.business.domain.Notice;
import com.hxhq.business.service.INoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* 系统通知Service业务层处理
*
* @author hxhq
* @date 2026-01-16
*/
@Service
public class NoticeServiceImpl extends ServiceImpl<NoticeMapper, Notice> implements INoticeService
{
@Autowired
private SysUserMapper userMapper;
@Autowired
private IStudyService studyService;
@Autowired
private IStudySubjectService studySubjectService;
/**
* 查询系统通知列表
*
* @return 系统通知
*/
@Override
public List<Notice> queryList()
{
QueryWrapper<Notice> queryWrapper = Wrappers.query();
queryWrapper.eq("user_id", SecurityUtils.getUserId());
queryWrapper.orderByDesc("id");
return this.list(queryWrapper);
}
@Override
public void save(String title, Long userId, String url) {
Notice notice = new Notice();
notice.setTitle(title);
notice.setUserId(userId);
notice.setUrl(url);
save(notice);
}
@Override
public void saveBatch(String title, List<Long> userIdList, String url) {
List<Notice> list = new ArrayList<>();
for(Long userId : userIdList){
Notice notice = new Notice();
notice.setTitle(title);
notice.setUserId(userId);
notice.setUrl(url);
list.add(notice);
}
saveBatch(list);
}
@Override
public void saveStudyMethod(Long studyId, Long studySubjectId, Long createUserId) {
Study study = studyService.getById(studyId);
if(study==null){
throw new ServiceException("信息不存在");
}
StudySubject studySubject = null;
if(study.getType().equals(StudyTypeEnum.sy.getValue())){
studySubject = studySubjectService.getById(studySubjectId);
if(studySubject==null){
throw new ServiceException("学科不存在");
}
}
String title = "您参与的【"+study.getName()+"("+study.getSn()+")】【"+(study.getType().equals(StudyTypeEnum.sy.getValue())?studySubject.getDeptName():study.getDeptName())+"】有新试验方法,请进入试验的对应学科进行阅读";
//试验学科内部的人+非试验部门内的人+麻精药不用判断只需要判断有审核按钮
List<Long> userIdList = userMapper.selectStudyMethodUserIdExcludeCreate(studyId, study.getType().equals(StudyTypeEnum.sy.getValue())?studySubjectId:null,study.getType().equals(StudyTypeEnum.fsy.getValue())?study.getDeptId():null,createUserId);
if(userIdList.size()>0){
saveBatch(title,userIdList,null);
}
}
}

+ 6
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/service/impl/StudyMethodServiceImpl.java View File

@ -9,6 +9,7 @@ import com.hxhq.business.enums.study.StudyMethodStatusEnum;
import com.hxhq.business.form.study.StudyMethodForm; import com.hxhq.business.form.study.StudyMethodForm;
import com.hxhq.business.form.study.StudyMethodReadForm; import com.hxhq.business.form.study.StudyMethodReadForm;
import com.hxhq.business.form.study.StudyMethodSearchForm; import com.hxhq.business.form.study.StudyMethodSearchForm;
import com.hxhq.business.service.INoticeService;
import com.hxhq.business.service.IStudyMethodReadService; import com.hxhq.business.service.IStudyMethodReadService;
import com.hxhq.common.core.exception.ServiceException; import com.hxhq.common.core.exception.ServiceException;
import com.hxhq.common.security.utils.SecurityUtils; import com.hxhq.common.security.utils.SecurityUtils;
@ -38,6 +39,8 @@ public class StudyMethodServiceImpl extends ServiceImpl
@Autowired @Autowired
private IStudyMethodReadService studyMethodReadService; private IStudyMethodReadService studyMethodReadService;
@Autowired
private INoticeService noticeService;
/** /**
* 查询试验-试验方法列表 * 查询试验-试验方法列表
@ -97,6 +100,9 @@ public class StudyMethodServiceImpl extends ServiceImpl
studyMethodRead.setRemark(form.getRemark()); studyMethodRead.setRemark(form.getRemark());
studyMethodRead.setQmyy("阅读"); studyMethodRead.setQmyy("阅读");
studyMethodReadService.save(studyMethodRead); studyMethodReadService.save(studyMethodRead);
//发送消息通知
noticeService.saveStudyMethod(studyMethod.getStudyId(),studyMethod.getStudySubjectId(),studyMethod.getUserId());
} }
@Override @Override

+ 1
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/controller/SysUserController.java View File

@ -463,7 +463,7 @@ public class SysUserController extends BaseController
return AjaxResult.error("信息不存在"); return AjaxResult.error("信息不存在");
} }
//试验学科内部的人+非试验部门内的人+麻精药不用判断只需要判断有审核按钮 //试验学科内部的人+非试验部门内的人+麻精药不用判断只需要判断有审核按钮
List<DeptUserTreeDto> depts = userService.selectStudyUser(study.getType().equals(StudyTypeEnum.sy.getValue())?studyId:null,study.getType().equals(StudyTypeEnum.sy.getValue())?studySubjectId:null,study.getDeptId(),permit);
List<DeptUserTreeDto> depts = userService.selectStudyUser(study.getType().equals(StudyTypeEnum.sy.getValue())?studyId:null,study.getType().equals(StudyTypeEnum.sy.getValue())?studySubjectId:null,study.getType().equals(StudyTypeEnum.fsy.getValue())?study.getDeptId():null,permit);
return success(depts); return success(depts);
} }
} }

+ 8
- 0
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/mapper/SysUserMapper.java View File

@ -171,4 +171,12 @@ public interface SysUserMapper
* @return * @return
*/ */
List<DeptUserTreeDto> selectStudyUser(@Param("studyId") Long studyId, @Param("studySubjectId") Long studySubjectId,@Param("deptId") Long deptId, @Param("permit") String permit); List<DeptUserTreeDto> selectStudyUser(@Param("studyId") Long studyId, @Param("studySubjectId") Long studySubjectId,@Param("deptId") Long deptId, @Param("permit") String permit);
/**
* 获取新增试验方法需要通知的用户ID
* @param studyId
* @param studySubjectId
* @return
*/
List<Long> selectStudyMethodUserIdExcludeCreate(@Param("studyId") Long studyId, @Param("studySubjectId") Long studySubjectId,@Param("deptId") Long deptId,@Param("createUserId") Long createUserId);
} }

+ 1
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/system/service/ISysUserService.java View File

@ -235,7 +235,7 @@ public interface ISysUserService
List<DeptUserTreeDto> selectDeptAndUser(); List<DeptUserTreeDto> selectDeptAndUser();
/** /**
* 试验人员列表
* 试验人员列表(选审核人用)
* @param studyId * @param studyId
* @param studySubjectId * @param studySubjectId
* @param permit * @param permit

+ 6
- 0
hxhq-modules/hxhq-system/src/main/resources/mapper/business/NoticeMapper.xml View File

@ -0,0 +1,6 @@
<?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">
<mapper namespace="com.hxhq.business.mapper.NoticeMapper">
</mapper>

+ 43
- 11
hxhq-modules/hxhq-system/src/main/resources/mapper/system/SysUserMapper.xml View File

@ -261,17 +261,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT u.`user_id` AS id,u.`user_name` AS nameEn,u.`nick_name` AS `name` SELECT u.`user_id` AS id,u.`user_name` AS nameEn,u.`nick_name` AS `name`
FROM `sys_user` u FROM `sys_user` u
WHERE del_flag='0' AND u.`user_id`&lt;>1 WHERE del_flag='0' AND u.`user_id`&lt;>1
-- 试验下
<if test="studyId != null and studyId != 0">
AND
(
u.`user_id` IN(SELECT leader FROM `t_study` WHERE del_flag='0' AND id=#{studyId})
OR
u.`user_id` IN(SELECT leader FROM `t_study_subject` WHERE del_flag='0' AND study_id=#{studyId})
OR
u.`user_id` IN(SELECT user_id FROM `t_study_subject_user` WHERE del_flag='0' AND study_id=#{studyId})
)
</if>
-- 试验下-有studySubjectId就不需要
<!-- <if test="studyId != null and studyId != 0">-->
<!-- AND-->
<!-- (-->
<!-- u.`user_id` IN(SELECT leader FROM `t_study` WHERE del_flag='0' AND id=#{studyId})-->
<!-- OR-->
<!-- u.`user_id` IN(SELECT leader FROM `t_study_subject` WHERE del_flag='0' AND study_id=#{studyId})-->
<!-- OR-->
<!-- u.`user_id` IN(SELECT user_id FROM `t_study_subject_user` WHERE del_flag='0' AND study_id=#{studyId})-->
<!-- )-->
<!-- </if>-->
-- 学科下 -- 学科下
<if test="studySubjectId != null and studySubjectId != 0"> <if test="studySubjectId != null and studySubjectId != 0">
@ -300,4 +300,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</select> </select>
<select id="selectStudyMethodUserIdExcludeCreate" resultType="java.lang.Long">
SELECT u.`user_id`
FROM `sys_user` u
WHERE del_flag='0' AND u.`user_id`&lt;>#{createUserId}
-- 试验下-有studySubjectId就不需要
<!-- <if test="studyId != null and studyId != 0">-->
<!-- AND-->
<!-- (-->
<!-- u.`user_id` IN(SELECT leader FROM `t_study` WHERE del_flag='0' AND id=#{studyId})-->
<!-- OR-->
<!-- u.`user_id` IN(SELECT leader FROM `t_study_subject` WHERE del_flag='0' AND study_id=#{studyId})-->
<!-- OR-->
<!-- u.`user_id` IN(SELECT user_id FROM `t_study_subject_user` WHERE del_flag='0' AND study_id=#{studyId})-->
<!-- )-->
<!-- </if>-->
-- 学科下
<if test="studySubjectId != null and studySubjectId != 0">
AND
(
u.`user_id` IN(SELECT leader FROM `t_study_subject` WHERE del_flag='0' AND id=#{studySubjectId})
OR
u.`user_id` IN(SELECT user_id FROM `t_study_subject_user` WHERE del_flag='0' AND study_subject_id=#{studySubjectId})
)
</if>
-- 部门
<if test="deptId != null and deptId != 0">
AND u.dept_id=#{deptId}
</if>
</select>
</mapper> </mapper>

Loading…
Cancel
Save