提交 f0a1fe9a authored 作者: xc's avatar xc

xc

上级 a227d90f
......@@ -16,6 +16,7 @@ public interface NoticeDao extends JpaRepository<Notice , Integer> {
Page<Notice> findOutByAddresseeLikeAndType(String addressee, int type, Pageable pageable);
List<Notice> findOutByStatusAndTypeAndLabel(int status, int type, int label);
Page<Notice> findOutByAddresseeLikeAndTypeAndStatus(String addressee, int type, int status, Pageable pageable);
Page<Notice> findOutByReceiverAndType(String addressee, int type, Pageable pageable);
Page<Notice> findOutByReceiverAndTypeAndStatus(String addressee, int type, int status, Pageable pageable);
}
......@@ -25,7 +25,6 @@ public class NoticeController {
@Autowired
private NoticeService noticeService;
/**
* 新增通知
* @param notice
......@@ -55,11 +54,13 @@ public class NoticeController {
@ApiOperation(value = "查看通知接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "通知id", paramType = "query",
required = true, example = "1", dataType = "int")
required = true, example = "1", dataType = "int"),
@ApiImplicitParam(name = "userId", value = "当前用户", paramType = "query",
required = true, dataType = "String")
})
@GetMapping("/getNotice")
public ResponseEntity<Notice> getNotice(@RequestParam int id){
return ResponseEntity.ok(noticeService.getNotice(id));
public ResponseEntity<Notice> getNotice(@RequestParam int id,String userId){
return ResponseEntity.ok(noticeService.getNotice(id, userId));
}
@GetMapping("/getNoticeList")
......
......@@ -128,6 +128,13 @@ public class Notice {
@Column(name = "label")
private int label;
/**
* 发收件人姓名
*/
@ApiModelProperty(value = "receiver", example = "", dataType = "String", name = "发件人名称")
@Column(name = "receiver")
private String receiver;
}
......@@ -24,10 +24,10 @@ public interface NoticeService {
/**
* 查看通知
* @param id 通知id
*
* @param userId 当前用户
* @return
*/
Notice getNotice(int id);
Notice getNotice(int id, String userId);
/**
* 获取通知列表
......
......@@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.Dao.NoticeDao;
import com.zjty.efs.bus.entity.Addressee;
import com.zjty.efs.bus.entity.Attention;
import com.zjty.efs.bus.entity.Notice;
import com.zjty.efs.bus.entity.Paging;
import com.zjty.efs.bus.service.AttentionService;
import com.zjty.efs.bus.service.NoticeService;
import com.zjty.efs.log.subject.entity.EfsLog;
import com.zjty.efs.log.tool.EfsLogUtil;
......@@ -33,6 +35,8 @@ public class NoticeServiceImpl implements NoticeService {
EfsLogUtil efsLogUtil;
@Autowired
UserService userService;
@Autowired
AttentionService attentionService;
@Override
@Transactional
......@@ -70,6 +74,7 @@ public class NoticeServiceImpl implements NoticeService {
List<Addressee> addresseeList2 = new ArrayList<>(); //接受者显示的接收列表
Notice notice1 = transform(notice); //发送通知
String dataList = "";
List<String> stringList = new ArrayList<>();
for(String addressee:strings){
UserDo userDo1 = userService.findById(addressee); //收件人用户
......@@ -82,20 +87,36 @@ public class NoticeServiceImpl implements NoticeService {
String data2 = "[" +userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
+ "]收到了来自[" + userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]关于[" + notice.getTitle() + "的通知";
stringList.add(addressee);
dataList = dataList + "[" + userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
+ "] ";
efsLogUtil.addLog(new EfsLog(null, userDo1.getId(), data2, new Date()));
}
String add2 = JSONObject.toJSONString(addresseeList2);
for (String addressee:strings){
for (String add:stringList){
Notice notice2 = transform(notice); // 接收通知
notice2.setAddressee(add2);
notice2.setType(0);
notice2.setReceiver(add);
noticeDao.save(notice2);
UserDo userDo1 = userService.findById(add); //收件人用户
String data2 = "[" +userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
+ "]收到了来自[" + userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]关于[" + notice.getTitle() + "的通知";
Attention attention = new Attention();
attention.setStatus(0);
attention.setUpdateTime(new Date());
attention.setData(data2);
attention.setUserId(add);
attentionService.addAttention(attention);
}
notice1.setAddressee(add2);
......@@ -103,9 +124,15 @@ public class NoticeServiceImpl implements NoticeService {
String data1 = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]给" + dataList
+ "发送了关于[" + notice.getTitle() + "]的通知";
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data1, new Date()));
Attention attention = new Attention();
attention.setStatus(0);
attention.setNoticeId(notice1.getId());
attention.setUpdateTime(new Date());
attention.setData(data1);
attention.setUserId(userDo.getId());
attentionService.addAttention(attention);
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data1, new Date()));
}
return true;
......@@ -151,31 +178,16 @@ public class NoticeServiceImpl implements NoticeService {
@Override
@Transactional
public Notice getNotice(int id) {
public Notice getNotice(int id, String userId) {
try {
Notice notice = noticeDao.findById(id);
notice.setStatus(1);
noticeDao.save(notice);
String userId = "";
if (notice.getType() == 0){
//已接收
userId = notice.getAddressee();
}else {
userId = notice.getSender();
}
UserDo userDo = userService.findById(userId); // 发送人
UserDo userDo = userService.findById(userId); // 当前用户
String data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "查看了关于[" + notice.getTitle() + "的通知";
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data, new Date()));
UserDo addressee = userService.findById(notice.getAddressee());
Addressee addressee1 = new Addressee();
addressee1.setId(addressee.getId());
addressee1.setName(addressee.getName());
String json = JSONObject.toJSONString(addressee1);
notice.setAddressee(json);
return notice;
}catch (Exception e){
e.printStackTrace();
......@@ -192,7 +204,8 @@ public class NoticeServiceImpl implements NoticeService {
if (type == 0){
//已接收
p = noticeDao.findOutByAddresseeLikeAndType("%"+user+"%", type, pageable);
// p = noticeDao.findOutByAddresseeLikeAndType("%"+user+"%", type, pageable);
p = noticeDao.findOutByReceiverAndType(user, type,pageable);
}else {
//已发送,草稿
p = noticeDao.findOutBySenderAndType(user, type, pageable);
......@@ -290,7 +303,8 @@ public class NoticeServiceImpl implements NoticeService {
public Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize,int type) {
try{
Pageable pageable = PageRequest.of(pageNum - 1, pageSize, Sort.Direction.DESC,"updateTime");
Page<Notice> p = noticeDao.findOutByAddresseeLikeAndTypeAndStatus("%"+user+"%",type, status, pageable);
Page<Notice> p = noticeDao.findOutByReceiverAndTypeAndStatus(user,type, status, pageable);
// Page<Notice> p = noticeDao.findOutByAddresseeLikeAndTypeAndStatus("%"+user+"%",type, status, pageable);
Paging<Notice> paging = new Paging<>();
paging.setData(p.getContent());
paging.setPageSize(pageSize);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论