change - 通知公告关联用户、可上传下载附件

master
yinq 12 months ago
parent 2c9281be86
commit 972b968753

@ -1,89 +1,166 @@
package com.hw.system.domain; package com.hw.system.domain;
import java.util.List;
import com.hw.common.core.xss.Xss;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.hw.common.core.annotation.Excel;
import com.hw.common.core.web.domain.BaseEntity;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.hw.common.core.web.domain.BaseEntity;
import com.hw.common.core.xss.Xss;
/** /**
* sys_notice * sys_notice
* *
* @author ruoyi * @author YinQ
* @date 2024-07-12
*/ */
public class SysNotice extends BaseEntity public class SysNotice extends BaseEntity {
{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 公告ID */ /**
* ID
*/
private Long noticeId; private Long noticeId;
/** 公告标题 */ /**
*
*/
@Excel(name = "公告标题")
private String noticeTitle; private String noticeTitle;
/** 公告类型1通知 2公告 */ /**
* 1 2
*/
@Excel(name = "公告类型", readConverterExp = "1=通知,2=公告")
private String noticeType; private String noticeType;
/** 公告内容 */ /**
*
*/
@Excel(name = "公告内容")
private String noticeContent; private String noticeContent;
/** 公告状态0正常 1关闭 */ /**
* 0 1
*/
@Excel(name = "公告状态", readConverterExp = "0=正常,1=关闭")
private String status; private String status;
public Long getNoticeId() /**
{ * ID
return noticeId; */
@Excel(name = "通知工位ID")
private String stationId;
/**
* ID
*/
@Excel(name = "用户组ID")
private String userGroupId;
/**
*
*/
@Excel(name = "附件路径")
private String attachPath;
/**
*
*/
private List<SysUserNotice> sysUserNoticeList;
/**
*
* List
*/
private List<Long> userNoticeList;
public List<Long> getUserNoticeList() {
return userNoticeList;
} }
public void setNoticeId(Long noticeId) public void setUserNoticeList(List<Long> userNoticeList) {
{ this.userNoticeList = userNoticeList;
}
public void setNoticeId(Long noticeId) {
this.noticeId = noticeId; this.noticeId = noticeId;
} }
public void setNoticeTitle(String noticeTitle) public Long getNoticeId() {
{ return noticeId;
}
public void setNoticeTitle(String noticeTitle) {
this.noticeTitle = noticeTitle; this.noticeTitle = noticeTitle;
} }
@Xss(message = "公告标题不能包含脚本字符") @Xss(message = "公告标题不能包含脚本字符")
@NotBlank(message = "公告标题不能为空") @NotBlank(message = "公告标题不能为空")
@Size(min = 0, max = 50, message = "公告标题不能超过50个字符") @Size(min = 0, max = 50, message = "公告标题不能超过50个字符")
public String getNoticeTitle() public String getNoticeTitle() {
{
return noticeTitle; return noticeTitle;
} }
public void setNoticeType(String noticeType) public void setNoticeType(String noticeType) {
{
this.noticeType = noticeType; this.noticeType = noticeType;
} }
public String getNoticeType() public String getNoticeType() {
{
return noticeType; return noticeType;
} }
public void setNoticeContent(String noticeContent) public void setNoticeContent(String noticeContent) {
{
this.noticeContent = noticeContent; this.noticeContent = noticeContent;
} }
public String getNoticeContent() public String getNoticeContent() {
{
return noticeContent; return noticeContent;
} }
public void setStatus(String status) public void setStatus(String status) {
{
this.status = status; this.status = status;
} }
public String getStatus() public String getStatus() {
{
return status; return status;
} }
public void setStationId(String stationId) {
this.stationId = stationId;
}
public String getStationId() {
return stationId;
}
public void setUserGroupId(String userGroupId) {
this.userGroupId = userGroupId;
}
public String getUserGroupId() {
return userGroupId;
}
public void setAttachPath(String attachPath) {
this.attachPath = attachPath;
}
public String getAttachPath() {
return attachPath;
}
public List<SysUserNotice> getSysUserNoticeList() {
return sysUserNoticeList;
}
public void setSysUserNoticeList(List<SysUserNotice> sysUserNoticeList) {
this.sysUserNoticeList = sysUserNoticeList;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@ -92,11 +169,15 @@ public class SysNotice extends BaseEntity
.append("noticeType", getNoticeType()) .append("noticeType", getNoticeType())
.append("noticeContent", getNoticeContent()) .append("noticeContent", getNoticeContent())
.append("status", getStatus()) .append("status", getStatus())
.append("stationId", getStationId())
.append("userGroupId", getUserGroupId())
.append("attachPath", getAttachPath())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark()) .append("remark", getRemark())
.append("sysUserNoticeList", getSysUserNoticeList())
.toString(); .toString();
} }
} }

@ -0,0 +1,115 @@
package com.hw.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.hw.common.core.annotation.Excel;
import com.hw.common.core.web.domain.BaseEntity;
/**
* sys_user_notice
*
* @author YinQ
* @date 2024-07-12
*/
public class SysUserNotice extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* ID
*/
private Long noticeId;
/**
* ID
*/
private Long userId;
/**
* 0 1
*/
@Excel(name = "查看状态", readConverterExp = "0=未查看,1=已查看")
private String checkStatus;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "查看时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date checkTime;
/**
* 0 1
*/
@Excel(name = "下载状态", readConverterExp = "0=未下载,1=已下载")
private String downloadStatus;
/**
*
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "下载时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date downloadTime;
public void setNoticeId(Long noticeId) {
this.noticeId = noticeId;
}
public Long getNoticeId() {
return noticeId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getUserId() {
return userId;
}
public void setCheckStatus(String checkStatus) {
this.checkStatus = checkStatus;
}
public String getCheckStatus() {
return checkStatus;
}
public void setCheckTime(Date checkTime) {
this.checkTime = checkTime;
}
public Date getCheckTime() {
return checkTime;
}
public void setDownloadStatus(String downloadStatus) {
this.downloadStatus = downloadStatus;
}
public String getDownloadStatus() {
return downloadStatus;
}
public void setDownloadTime(Date downloadTime) {
this.downloadTime = downloadTime;
}
public Date getDownloadTime() {
return downloadTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("noticeId", getNoticeId())
.append("userId", getUserId())
.append("checkStatus", getCheckStatus())
.append("checkTime", getCheckTime())
.append("downloadStatus", getDownloadStatus())
.append("downloadTime", getDownloadTime())
.toString();
}
}

@ -2,6 +2,7 @@ package com.hw.system.mapper;
import java.util.List; import java.util.List;
import com.hw.system.domain.SysNotice; import com.hw.system.domain.SysNotice;
import com.hw.system.domain.SysUserNotice;
/** /**
* *
@ -57,4 +58,28 @@ public interface SysNoticeMapper
* @return * @return
*/ */
public int deleteNoticeByIds(Long[] noticeIds); public int deleteNoticeByIds(Long[] noticeIds);
/**
*
*
* @param noticeIds
* @return
*/
public int deleteSysUserNoticeByNoticeIds(Long[] noticeIds);
/**
*
*
* @param sysUserNoticeList
* @return
*/
public int batchSysUserNotice(List<SysUserNotice> sysUserNoticeList);
/**
*
*
* @param noticeId ID
* @return
*/
public int deleteSysUserNoticeByNoticeId(Long noticeId);
} }

@ -1,11 +1,17 @@
package com.hw.system.service.impl; package com.hw.system.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.hw.common.core.utils.StringUtils;
import com.hw.system.common.mapper.SysPointRouterMapper;
import com.hw.system.domain.SysUserNotice;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hw.system.domain.SysNotice; import com.hw.system.domain.SysNotice;
import com.hw.system.mapper.SysNoticeMapper; import com.hw.system.mapper.SysNoticeMapper;
import com.hw.system.service.ISysNoticeService; import com.hw.system.service.ISysNoticeService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* *
@ -18,6 +24,9 @@ public class SysNoticeServiceImpl implements ISysNoticeService
@Autowired @Autowired
private SysNoticeMapper noticeMapper; private SysNoticeMapper noticeMapper;
@Autowired
private SysPointRouterMapper pointRouterMapper;
/** /**
* *
* *
@ -48,10 +57,13 @@ public class SysNoticeServiceImpl implements ISysNoticeService
* @param notice * @param notice
* @return * @return
*/ */
@Transactional
@Override @Override
public int insertNotice(SysNotice notice) public int insertNotice(SysNotice notice)
{ {
return noticeMapper.insertNotice(notice); int rows = noticeMapper.insertNotice(notice);
insertSysUserNotice(notice);
return rows;
} }
/** /**
@ -60,9 +72,12 @@ public class SysNoticeServiceImpl implements ISysNoticeService
* @param notice * @param notice
* @return * @return
*/ */
@Transactional
@Override @Override
public int updateNotice(SysNotice notice) public int updateNotice(SysNotice notice)
{ {
noticeMapper.deleteSysUserNoticeByNoticeId(notice.getNoticeId());
insertSysUserNotice(notice);
return noticeMapper.updateNotice(notice); return noticeMapper.updateNotice(notice);
} }
@ -72,9 +87,11 @@ public class SysNoticeServiceImpl implements ISysNoticeService
* @param noticeId ID * @param noticeId ID
* @return * @return
*/ */
@Transactional
@Override @Override
public int deleteNoticeById(Long noticeId) public int deleteNoticeById(Long noticeId)
{ {
noticeMapper.deleteSysUserNoticeByNoticeId(noticeId);
return noticeMapper.deleteNoticeById(noticeId); return noticeMapper.deleteNoticeById(noticeId);
} }
@ -84,9 +101,36 @@ public class SysNoticeServiceImpl implements ISysNoticeService
* @param noticeIds ID * @param noticeIds ID
* @return * @return
*/ */
@Transactional
@Override @Override
public int deleteNoticeByIds(Long[] noticeIds) public int deleteNoticeByIds(Long[] noticeIds)
{ {
noticeMapper.deleteSysUserNoticeByNoticeIds(noticeIds);
return noticeMapper.deleteNoticeByIds(noticeIds); return noticeMapper.deleteNoticeByIds(noticeIds);
} }
/**
*
*
* @param sysNotice
*/
public void insertSysUserNotice(SysNotice sysNotice)
{
List<SysUserNotice> sysUserNoticeList = sysNotice.getSysUserNoticeList();
Long noticeId = sysNotice.getNoticeId();
if (StringUtils.isNotNull(sysUserNoticeList))
{
List<SysUserNotice> list = new ArrayList<>();
for (SysUserNotice sysUserNotice : sysUserNoticeList)
{
sysUserNotice.setNoticeId(noticeId);
list.add(sysUserNotice);
}
if (list.size() > 0)
{
noticeMapper.batchSysUserNotice(list);
}
}
}
} }

@ -10,6 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="noticeType" column="notice_type" /> <result property="noticeType" column="notice_type" />
<result property="noticeContent" column="notice_content" /> <result property="noticeContent" column="notice_content" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="stationId" column="station_id" />
<result property="userGroupId" column="user_group_id" />
<result property="attachPath" column="attach_path" />
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
@ -17,14 +20,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="remark" column="remark" /> <result property="remark" column="remark" />
</resultMap> </resultMap>
<resultMap id="SysNoticeSysUserNoticeResult" type="SysNotice" extends="SysNoticeResult">
<collection property="sysUserNoticeList" notNullColumn="sub_notice_id" javaType="java.util.List" resultMap="SysUserNoticeResult" />
<collection property="userNoticeList" ofType="java.lang.Long">
<id column="sub_user_id" property="userNoticeList" />
</collection>
</resultMap>
<resultMap type="SysUserNotice" id="SysUserNoticeResult">
<result property="noticeId" column="sub_notice_id" />
<result property="userId" column="sub_user_id" />
<result property="checkStatus" column="sub_check_status" />
<result property="checkTime" column="sub_check_time" />
<result property="downloadStatus" column="sub_download_status" />
<result property="downloadTime" column="sub_download_time" />
</resultMap>
<sql id="selectNoticeVo"> <sql id="selectNoticeVo">
select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, create_by, create_time, update_by, update_time, remark select notice_id, notice_title, notice_type, cast(notice_content as char) as notice_content, status, station_id, user_group_id, attach_path, create_by, create_time, update_by, update_time, remark
from sys_notice from sys_notice
</sql> </sql>
<select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeResult"> <select id="selectNoticeById" parameterType="Long" resultMap="SysNoticeSysUserNoticeResult">
<include refid="selectNoticeVo"/> select a.notice_id, a.notice_title, a.notice_type, a.notice_content, a.status, a.station_id, a.user_group_id, a.attach_path, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,
where notice_id = #{noticeId} b.notice_id as sub_notice_id, b.user_id as sub_user_id, b.check_status as sub_check_status, b.check_time as sub_check_time, b.download_status as sub_download_status, b.download_time as sub_download_time
from sys_notice a
left join sys_user_notice b on b.notice_id = a.notice_id
where a.notice_id = #{noticeId}
</select> </select>
<select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult"> <select id="selectNoticeList" parameterType="SysNotice" resultMap="SysNoticeResult">
@ -42,12 +64,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<insert id="insertNotice" parameterType="SysNotice"> <insert id="insertNotice" parameterType="SysNotice" useGeneratedKeys="true" keyProperty="noticeId">
insert into sys_notice ( insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if> <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
<if test="noticeType != null and noticeType != '' ">notice_type, </if> <if test="noticeType != null and noticeType != '' ">notice_type, </if>
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if> <if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
<if test="status != null and status != '' ">status, </if> <if test="status != null and status != '' ">status, </if>
<if test="stationId != null">station_id,</if>
<if test="userGroupId != null">user_group_id,</if>
<if test="attachPath != null">attach_path,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
create_time create_time
@ -56,6 +81,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if> <if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if> <if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
<if test="status != null and status != ''">#{status}, </if> <if test="status != null and status != ''">#{status}, </if>
<if test="stationId != null">#{stationId},</if>
<if test="userGroupId != null">#{userGroupId},</if>
<if test="attachPath != null and attachPath != ''">#{attachPath},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() sysdate()
@ -69,6 +97,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if> <if test="noticeType != null and noticeType != ''">notice_type = #{noticeType}, </if>
<if test="noticeContent != null">notice_content = #{noticeContent}, </if> <if test="noticeContent != null">notice_content = #{noticeContent}, </if>
<if test="status != null and status != ''">status = #{status}, </if> <if test="status != null and status != ''">status = #{status}, </if>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="userGroupId != null">user_group_id = #{userGroupId},</if>
<if test="attachPath != null">attach_path = #{attachPath},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()
</set> </set>
@ -86,4 +117,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<delete id="deleteSysUserNoticeByNoticeIds" parameterType="String">
delete from sys_user_notice where notice_id in
<foreach item="noticeId" collection="array" open="(" separator="," close=")">
#{noticeId}
</foreach>
</delete>
<delete id="deleteSysUserNoticeByNoticeId" parameterType="Long">
delete from sys_user_notice where notice_id = #{noticeId}
</delete>
<insert id="batchSysUserNotice">
insert into sys_user_notice( notice_id, user_id) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.noticeId}, #{item.userId})
</foreach>
</insert>
</mapper> </mapper>

@ -143,7 +143,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="12">
<el-form-item label="状态"> <el-form-item label="状态">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
<el-radio <el-radio
@ -154,9 +154,22 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="通知用户" >
<el-select v-model="form.userNoticeList" placeholder="请选择通知用户" multiple>
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.nickName"
:value="item.userId"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="内容"> <el-form-item label="内容">
<editor v-model="form.noticeContent" :min-height="192"/> <editor v-model="form.noticeContent" :min-height="192"/>
<fileUpload v-model="form.attachPath"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -171,6 +184,7 @@
<script> <script>
import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice"; import { listNotice, getNotice, delNotice, addNotice, updateNotice } from "@/api/system/notice";
import {findUserList} from "@/api/system/user";
export default { export default {
name: "Notice", name: "Notice",
@ -213,7 +227,9 @@ export default {
noticeType: [ noticeType: [
{ required: true, message: "公告类型不能为空", trigger: "change" } { required: true, message: "公告类型不能为空", trigger: "change" }
] ]
} },
//List
userList: []
}; };
}, },
created() { created() {
@ -241,6 +257,8 @@ export default {
noticeTitle: undefined, noticeTitle: undefined,
noticeType: undefined, noticeType: undefined,
noticeContent: undefined, noticeContent: undefined,
sysUserNoticeList: [],
userNoticeList: [],
status: "0" status: "0"
}; };
this.resetForm("form"); this.resetForm("form");
@ -264,12 +282,18 @@ export default {
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
findUserList({}).then(response => {
this.userList = response.data;
});
this.open = true; this.open = true;
this.title = "添加公告"; this.title = "添加公告";
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
findUserList({}).then(response => {
this.userList = response.data;
});
const noticeId = row.noticeId || this.ids const noticeId = row.noticeId || this.ids
getNotice(noticeId).then(response => { getNotice(noticeId).then(response => {
this.form = response.data; this.form = response.data;
@ -279,6 +303,9 @@ export default {
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
if (this.form.userNoticeList.length > 0){
this.form.sysUserNoticeList = this.form.userNoticeList.map(userId => ({ userId }));
}
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
if (this.form.noticeId != undefined) { if (this.form.noticeId != undefined) {

Loading…
Cancel
Save