Commit c5a0d90b by 284718418@qq.com

OA 讯息添加文件传阅 模板排序

parent b1a5b3fe
......@@ -146,4 +146,7 @@ public class CmsContent extends Model<CmsContent>{
@ApiModelProperty(value = "定时发布时间", example = "101")
private Long fixedTime;// 定时发布时间
@ApiModelProperty(value = "是否公开:0否,1是", example = "1")
private Integer openStatus;
}
......@@ -54,4 +54,7 @@ public class CmsContentModular extends Model<CmsContentModular> {
@ApiModelProperty(value = "0- 开启 1-关闭", example = "0")
private Integer isOpen;
@ApiModelProperty(value = "排序:升序", example = "0")
private Integer sort;
}
package cn.timer.api.bean.qyxx;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 文件传阅表
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-06-23
*/
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "cms_content_read")
@ApiModel("文件传阅表")
public class CmsContentRead extends Model<CmsContentRead>{
private static final long serialVersionUID = -5904257321968702198L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号", example = "1")
private Integer id;
@ApiModelProperty(value = "企业讯息主表ID", example = "101")
private Integer cmsContentId;
@ApiModelProperty(value = "留言/意见反馈", example = "")
private String reviewContent;
@ApiModelProperty(value = "留言/意见反馈时间", example = "")
private Date reviewTime;
@ApiModelProperty(value = "组织机构代码", example = "1")
private Integer orgCode;
@ApiModelProperty(value = "用户ID", example = "1")
private Integer userId;
@ApiModelProperty(value = "用户姓名", example = "张三")
private String userName;
@ApiModelProperty(value = "阅读标记0.未读 1.已读", example = "0")
private Integer readStatus;
@ApiModelProperty(value = "逻辑删除标记0.未删除 1.删除", example = "0")
private Integer deleteFlag;
@ApiModelProperty(value = "创建时间", example = "")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "")
private Date updateTime;
}
......@@ -2,12 +2,15 @@ package cn.timer.api.controller.qyxx;
import java.util.*;
import cn.timer.api.utils.redis.RedisUtil;
import cn.timer.api.bean.qyxx.*;
import cn.timer.api.dto.qyxx.CmsContentReadDto;
import com.github.yulichang.query.MPJQueryWrapper;
import com.google.common.collect.Maps;
import org.apache.commons.lang3.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
......@@ -26,10 +29,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.timer.api.bean.qyxx.CmsAnnouncement;
import cn.timer.api.bean.qyxx.CmsContent;
import cn.timer.api.bean.qyxx.CmsContentModular;
import cn.timer.api.bean.qyxx.CmsIsRead;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
......@@ -49,6 +48,7 @@ import javax.annotation.Resource;
@Api(tags = "5.0企业讯息")
@Transactional
@RequestMapping(value = "/qyxx", produces = { "application/json" })
@Slf4j
public class CmsController {
@Autowired
......@@ -88,9 +88,16 @@ public class CmsController {
public Result<Object> groupbyTime(@CurrentUser UserBean userBean) {
Map map = Maps.newHashMap();
Integer orgCode = userBean.getOrgCode();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id", "title", "author", "releasetime", "fmtpath").eq("releasestate", 0)
.eq("organization_id", orgCode).orderByDesc("releasetime").last("limit 6");
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.eq("t.releasestate", 0)
.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1)
.or(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum()))
.or(true,q -> q.eq("t.open_status", 0).eq("t.userid",userBean.getEmpNum())))
.eq("t.organization_id", orgCode)
.groupBy("t.id")
.orderByDesc("t.releasetime").last("limit 6");
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
/*应需求一定要展示前四张图片*/
QueryWrapper<CmsContent> qw = new QueryWrapper<>();
......@@ -152,9 +159,16 @@ public class CmsController {
for (CmsContentModular cmsContentModular : list) {
// 分类模块id
Integer id = cmsContentModular.getId();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id", "modularid", "title", "author", "releasetime").eq("releasestate", 0)
.eq("organization_id", userBean.getOrgCode()).orderByDesc("releasetime").eq("modularid", id)
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.modularid", "t.title", "t.author", "t.releasetime")
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.eq("t.releasestate", 0)
.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1)
.or(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum()))
.or(true,q -> q.eq("t.open_status", 0).eq("t.userid",userBean.getEmpNum())))
.eq("t.organization_id", userBean.getOrgCode()).eq("t.modularid", id)
.groupBy("t.id")
.orderByDesc("t.releasetime")
.last("limit 5");
List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper);
o.add(qynrs);
......@@ -171,7 +185,8 @@ public class CmsController {
public Result<Object> getxxfl(@CurrentUser UserBean userBean) {
return ResultUtil.data(CmsContentModular.builder().build().selectList(new QueryWrapper<CmsContentModular>()
// .eq("organization_id", userBean.getOrgCode())
.eq("is_open", 0)), "查询分类成功!");
.eq("is_open", 0)
.orderByAsc("sort")), "查询分类成功!");
}
/**
......@@ -193,6 +208,9 @@ public class CmsController {
// qynr.setXxbh("XX" + i++);
Boolean a = qynr.getId() == null;
if(a){
qynr.setUserid(empNum);
}
if (a && qynr.getPublisher() == null)
qynr.setPublisher(empNum);
qynr.setOrganizationId(orgCode);
......@@ -200,7 +218,7 @@ public class CmsController {
// 录入时间
qynr.setAddeddate(now);
// 发布方式:1,审核通过后立即发布,2定时发布,3手动发布
// 发布方式:1,审核通过后立即发布,2定时发布,3手动发布,4立即发布
Integer fbfs = qynr.getReleasetype();
// 定时
if (fbfs != null && fbfs == 2) {
......@@ -211,13 +229,32 @@ public class CmsController {
.eq(YgglMainEmp::getOrgCode, orgCode).eq(YgglMainEmp::getEmpNum, empNum)).getName());
qynr.setReleasetype(fbfs);
qynr.setStatus(0);
if(fbfs != null && fbfs == 4){
qynr.setReleasestate(0);
qynr.setStatus(1);
qynr.setReleasetime(now.toString());
}
qynr.insertOrUpdate();
// 新增 文件传阅 人员数据
if(a){
if(!CollectionUtils.isEmpty(cmsContentDto.getCmsContentReads())){
for (CmsContentRead entity :cmsContentDto.getCmsContentReads() ) {
entity.setCmsContentId(qynr.getId());
entity.setOrgCode(orgCode);
entity.setReadStatus(0);
entity.setDeleteFlag(0);
entity.insert();
}
}
}
if (a)
return ResultUtil.data(qynr, "提交成功、等待管理员审核");
else
if (a){
String msg = fbfs==4?"提交成功":"提交成功、等待管理员审核";
return ResultUtil.data(qynr, msg);
} else {
return ResultUtil.data(qynr, "修改成功");
}
}
/**
* 删除企业OA讯息
......@@ -311,14 +348,18 @@ public class CmsController {
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode()).eq("status", 1).eq("releasestate", 0)
.eq(t != null && t > -1, "modularid", t).eq(r != null && r > -1, "releasestate", r)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "releasetime",
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or(true,sq -> sq.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum())));
queryWrapper.eq("t.organization_id", userBean.getOrgCode()).eq("t.status", 1).eq("t.releasestate", 0)
.eq(t != null && t > -1, "t.modularid", t).eq(r != null && r > -1, "t.releasestate", r)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "t.releasetime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
.and(!StrUtil.hasBlank(q), wq -> wq.like("t.userid", q).or().like("t.author", q).or().like("title", q))
.groupBy("t.id")
.orderByDesc("t.addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
......@@ -401,7 +442,7 @@ public class CmsController {
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode())
.select("id", "publisher_name", "auditopinion", "modularid", "status", "title", "releasetime",
"addeddate", "author", "summary", "releasetype", "fmtpath","filepath")
"addeddate", "author", "summary", "releasetype", "fmtpath","filepath","open_status")
.ne("status", 1).eq(t != null && t > -1, "modularid", t)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "releasetime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
......@@ -580,4 +621,95 @@ public class CmsController {
return ResultUtil.success("设置失败");
}
/**
* 查询传阅列表
* @return
*/
@PostMapping(value = "/getCmsContentReads")
@ApiOperation(value = "查询传阅列表", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> getCmsContentReads(@CurrentUser UserBean userBean, @RequestBody CmsContentReadDto cmsContentReadDto) {
Page<CmsContentRead> page = new Page<CmsContentRead>(cmsContentReadDto.getCurrentPage(), cmsContentReadDto.getTotalPage());
//查询传阅列表
IPage<CmsContentRead> cmsContentReads = CmsContentRead.builder().build()
.selectPage(page, new QueryWrapper<CmsContentRead>()
.lambda().eq(CmsContentRead::getCmsContentId, cmsContentReadDto.getCmsContentId()).orderByDesc(CmsContentRead::getReviewTime));
return ResultUtil.data(cmsContentReads);
}
/**
* 标记已阅
*/
@GetMapping(value = "/haveRead/{id}")
@ApiOperation(value = "标记已阅", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> haveRead(@CurrentUser UserBean userBean, @PathVariable("id") Integer id) {
//用户id查询传阅消息
CmsContentRead cmsContentRead = CmsContentRead.builder().build()
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,id));
if(cmsContentRead == null){
cmsContentRead = new CmsContentRead();
cmsContentRead.setUserId(userBean.getEmpNum());
cmsContentRead.setUserName(userBean.getUserInfo().getName());
cmsContentRead.setOrgCode(userBean.getOrgCode());
cmsContentRead.setCmsContentId(id);
}else {
//已阅 直接返回
if(cmsContentRead.getReadStatus() == 1){
return ResultUtil.data(1);
}
}
try {
cmsContentRead.setReadStatus(1);
cmsContentRead.setReviewTime(new Date());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
log.error("=============已阅操作失败, " + e);
return ResultUtil.error(e);
}
return ResultUtil.success();
}
/**
* 根据讯息id查传阅列表
* @return
*/
@PostMapping(value = "/comment")
@ApiOperation(value = "评论意见反馈", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> comment(@CurrentUser UserBean userBean, @RequestBody CmsContentReadDto cmsContentReadDto) {
//用户id查询传阅消息
CmsContentRead cmsContentRead = CmsContentRead.builder().build()
.selectOne(new QueryWrapper<CmsContentRead>().lambda()
.eq(CmsContentRead::getUserId, userBean.getEmpNum())
.eq(CmsContentRead::getOrgCode, userBean.getOrgCode())
.eq(CmsContentRead::getCmsContentId,cmsContentReadDto.getCmsContentId()));
try {
cmsContentRead.setReviewContent(cmsContentReadDto.getReviewContent());
cmsContentRead.insertOrUpdate();
}catch (Exception e){
log.error("=============评论失败, " + e);
return ResultUtil.error(e);
}
return ResultUtil.success();
}
/**
* 添加传阅人员
* @return
*/
@PostMapping(value = "/addReadPersonnel")
@ApiOperation(value = "添加传阅人员", httpMethod = "POST", notes = "接口发布说明")
public Result<Object> addReadPersonnel(@CurrentUser UserBean userBean, @RequestBody List<CmsContentRead> cmsContentReads) {
for (CmsContentRead ccr:cmsContentReads
) {
ccr.insert();
}
return ResultUtil.success();
}
}
package cn.timer.api.dao.qyxx;
import com.github.yulichang.base.MPJBaseMapper;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.qyxx.CmsContent;
......@@ -12,6 +12,6 @@ import cn.timer.api.bean.qyxx.CmsContent;
* @author dsc 2019-12-10
*/
@Repository
public interface CmsContentMapper extends BaseMapper<CmsContent> {
public interface CmsContentMapper extends MPJBaseMapper<CmsContent> {
}
package cn.timer.api.dao.qyxx;
import cn.timer.api.bean.qyxx.CmsContentRead;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* 文件传阅表
*
* @author wuqingjun
* @email 284718418@qq.com
* @date 2022-06-23
*/
@Repository
public interface CmsContentReadMapper extends BaseMapper<CmsContentRead> {
}
package cn.timer.api.dto.qyxx;
import java.io.Serializable;
import java.util.List;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import cn.timer.api.bean.qyxx.CmsContentRead;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
......@@ -137,4 +139,12 @@ public class CmsContentDto extends Page implements Serializable{
@ApiModelProperty(value = "定时发布时间", example = "101")
private Long fixedTime;// 定时发布时间
@ApiModelProperty(value = "是否公开:0否,1是", example = "1")
private Integer openStatus;
/**
* 文件传阅人员
*/
@ApiModelProperty(value = "文件传阅人员")
private List<CmsContentRead> cmsContentReads;
}
\ No newline at end of file
package cn.timer.api.dto.qyxx;
import cn.timer.api.utils.Page;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CmsContentReadDto extends Page implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "编号", example = "1")
private Integer id;
@ApiModelProperty(value = "企业讯息主表ID", example = "101")
private Integer cmsContentId;
@ApiModelProperty(value = "留言/意见反馈", example = "")
private String reviewContent;
@ApiModelProperty(value = "留言/意见反馈时间", example = "")
private Date reviewTime;
@ApiModelProperty(value = "组织机构代码", example = "1")
private Integer orgCode;
@ApiModelProperty(value = "用户ID", example = "1")
private Integer userId;
@ApiModelProperty(value = "用户姓名", example = "张三")
private String userName;
@ApiModelProperty(value = "阅读标记0.未读 1.已读", example = "0")
private Integer readStatus;
@ApiModelProperty(value = "逻辑删除标记0.未删除 1.删除", example = "0")
private Integer deleteFlag;
@ApiModelProperty(value = "创建时间", example = "")
private Date createTime;
@ApiModelProperty(value = "更新时间", example = "")
private Date updateTime;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment