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

xc

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