提交 76f8a95b authored 作者: xc's avatar xc

xc

上级 ce68cb6f
...@@ -61,7 +61,7 @@ public class NoticeController { ...@@ -61,7 +61,7 @@ public class NoticeController {
@GetMapping("/getNoticeList") @GetMapping("/getNoticeList")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2") @ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2")
@ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "account", dataType = "int"), @ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "account", dataType = "String"),
@ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int"), @ApiImplicitParam(name = "type", value = "通知类型", paramType = "query", required = true, example = "0", dataType = "int"),
@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "int"), @ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int")}) @ApiImplicitParam(name = "pageSize", value = "条数", paramType = "query", required = true, dataType = "int")})
......
...@@ -10,8 +10,8 @@ import java.lang.annotation.Documented; ...@@ -10,8 +10,8 @@ import java.lang.annotation.Documented;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public class FileList { public class Addressee {
private String id; private String id;
private String address; private String name;
} }
package com.zjty.efs.bus.service.impl; package com.zjty.efs.bus.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.zjty.efs.bus.Dao.NoticeDao; import com.zjty.efs.bus.Dao.NoticeDao;
import com.zjty.efs.bus.entity.Addressee;
import com.zjty.efs.bus.entity.Notice; import com.zjty.efs.bus.entity.Notice;
import com.zjty.efs.bus.entity.Paging; import com.zjty.efs.bus.entity.Paging;
import com.zjty.efs.bus.service.NoticeService; import com.zjty.efs.bus.service.NoticeService;
...@@ -8,6 +10,7 @@ import com.zjty.efs.log.subject.entity.EfsLog; ...@@ -8,6 +10,7 @@ import com.zjty.efs.log.subject.entity.EfsLog;
import com.zjty.efs.log.tool.EfsLogUtil; import com.zjty.efs.log.tool.EfsLogUtil;
import com.zjty.efs.user.subject.entity.UserDo; import com.zjty.efs.user.subject.entity.UserDo;
import com.zjty.efs.user.subject.service.UserService; import com.zjty.efs.user.subject.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.domain.*; import org.springframework.data.domain.*;
...@@ -54,27 +57,22 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -54,27 +57,22 @@ public class NoticeServiceImpl implements NoticeService {
//如果是发送,就新增接收 //如果是发送,就新增接收
String[] addressees = notice.getAddressee().split(","); String[] addressees = notice.getAddressee().split(",");
List<Notice> noticeList = new ArrayList<>();
for (String addressee:addressees){ for (String addressee:addressees){
Notice notice2 = notice; Notice notice2 = transform(notice);
notice2.setAddressee(addressee); notice2.setAddressee(addressee);
noticeDao.save(notice2); noticeList.add(notice2); //已发送保存
UserDo userDo1 = userService.findById(addressee); //接收人 UserDo userDo1 = userService.findById(addressee); //接收人
data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName() data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]给[" + userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName() + "]给[" + userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
+ "发送了关于[" + notice.getTitle() + "]的通知"; + "发送了关于[" + notice.getTitle() + "]的通知";
Notice notice1 = new Notice(); // Notice notice1 = new Notice();
Notice notice1 = transform(notice);//已接收
notice1.setType(0); notice1.setType(0);
notice1.setTitle(notice.getTitle()); notice1.setTitle(notice.getTitle());
notice1.setAddressee(addressee); notice1.setAddressee(addressee);
notice1.setDeadline(notice.getDeadline());
notice1.setFileList(notice.getFileList());
notice1.setMessage(notice.getMessage());
notice1.setNote(notice.getNote());
notice1.setSender(notice.getSender());
notice1.setStatus(notice.getStatus());
notice1.setUpdateTime(notice.getUpdateTime());
notice1.setUnit(userDo1.getUnit()); notice1.setUnit(userDo1.getUnit());
noticeDao.save(notice1); noticeDao.save(notice1);
String data1 = "[" +userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName() String data1 = "[" +userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
...@@ -82,6 +80,8 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -82,6 +80,8 @@ public class NoticeServiceImpl implements NoticeService {
+ "]关于[" + notice.getTitle() + "的通知"; + "]关于[" + notice.getTitle() + "的通知";
efsLogUtil.addLog(new EfsLog(null, userDo1.getId(), data1, new Date())); efsLogUtil.addLog(new EfsLog(null, userDo1.getId(), data1, new Date()));
} }
System.out.println(noticeList);
noticeDao.saveAll(noticeList);
} }
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data, new Date())); efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data, new Date()));
...@@ -93,6 +93,21 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -93,6 +93,21 @@ public class NoticeServiceImpl implements NoticeService {
} }
} }
private Notice transform(Notice notice){
Notice notice1 = new Notice();
notice1.setTitle(notice.getTitle());
notice1.setAddressee(notice.getAddressee());
notice1.setDeadline(notice.getDeadline());
notice1.setFileList(notice.getFileList());
notice1.setMessage(notice.getMessage());
notice1.setNote(notice.getNote());
notice1.setSender(notice.getSender());
notice1.setStatus(notice.getStatus());
notice1.setUpdateTime(notice.getUpdateTime());
notice1.setType(notice.getType());
notice1.setUnit(notice.getUnit());
return notice1;
}
@Override @Override
@Transactional @Transactional
...@@ -127,6 +142,14 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -127,6 +142,14 @@ public class NoticeServiceImpl implements NoticeService {
String data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName() String data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "查看了关于[" + notice.getTitle() + "的通知"; + "查看了关于[" + notice.getTitle() + "的通知";
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data, new Date())); 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; return notice;
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
...@@ -149,6 +172,31 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -149,6 +172,31 @@ public class NoticeServiceImpl implements NoticeService {
p = noticeDao.findOutBySenderAndType(user, type, pageable); p = noticeDao.findOutBySenderAndType(user, type, pageable);
} }
// for (Notice notice:p.getContent()){
String addresseeId = "";//收件人编号
UserDo addressee = new UserDo();//收件人实体
for (int i = 0; i < p.getContent().size(); i++){
List<Addressee> addressees = new ArrayList<>();
Notice notice = p.getContent().get(i);
if (i == 0) {
addresseeId = notice.getAddressee();
addressee = userService.findById(notice.getAddressee());
}else {
if (!addresseeId.equals(notice.getAddressee())){
//如果两个收件人不一样,重新获取user
addressee = userService.findById(notice.getAddressee());
}
}
Addressee addressee1 = new Addressee();
addressee1.setId(addressee.getId());
addressee1.setName(addressee.getName());
addressees.add(addressee1);
String json = JSONObject.toJSONString(addressees);
notice.setAddressee(json);
}
Paging<Notice> paging = new Paging<>(); Paging<Notice> paging = new Paging<>();
paging.setData(p.getContent()); paging.setData(p.getContent());
paging.setPageSize(pageSize); paging.setPageSize(pageSize);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论