提交 f3fc5312 authored 作者: zhangshuang's avatar zhangshuang

Merge branch 'develop' of git.yfzx.zjtys.com.cn:zhuangshuang/EncryptedFileSystem into develop

...@@ -73,9 +73,10 @@ public class NoticeController { ...@@ -73,9 +73,10 @@ public class NoticeController {
@PutMapping("/updateStatus") @PutMapping("/updateStatus")
@ApiOperation(value = "修改通知为已读",notes = "status 未查看 0,已查看 1") @ApiOperation(value = "修改通知为已读",notes = "status 未查看 0,已查看 1")
@ApiImplicitParams({@ApiImplicitParam(name = "notices", value = "通知列表", paramType = "body", required = true, @ApiImplicitParams({@ApiImplicitParam(name = "notices", value = "通知列表", paramType = "body", required = true,
allowMultiple = true, dataType = "Notice")}) allowMultiple = true, dataType = "Notice"),
public ResponseEntity updateStatus(@RequestBody List<Notice> notices){ @ApiImplicitParam(name = "userId", value = "当前登录用户", paramType = "query", required = true,dataType = "String")})
return ResponseEntity.ok(noticeService.updateStatus(notices)); public ResponseEntity updateStatus(@RequestBody List<Notice> notices, @RequestParam String userId){
return ResponseEntity.ok(noticeService.updateStatus(notices, userId));
} }
} }
...@@ -13,5 +13,6 @@ import java.lang.annotation.Documented; ...@@ -13,5 +13,6 @@ import java.lang.annotation.Documented;
public class Addressee { public class Addressee {
private String id; private String id;
private String name; private String name;
private String unit;
} }
...@@ -115,6 +115,12 @@ public class Notice { ...@@ -115,6 +115,12 @@ public class Notice {
@ApiModelProperty(value = "unit", example = "", dataType = "String", name = "单位名称") @ApiModelProperty(value = "unit", example = "", dataType = "String", name = "单位名称")
@Column(name = "unit") @Column(name = "unit")
private String unit; private String unit;
/**
* 发件人姓名
*/
@ApiModelProperty(value = "name", example = "", dataType = "String", name = "发件人名称")
@Column(name = "name")
private String name;
} }
...@@ -43,7 +43,7 @@ public interface NoticeService { ...@@ -43,7 +43,7 @@ public interface NoticeService {
* 修改通知为已读 * 修改通知为已读
* @param notices 需要修改的通知实体列表 * @param notices 需要修改的通知实体列表
*/ */
boolean updateStatus(List<Notice> notices); boolean updateStatus(List<Notice> notices, String userId);
/** /**
......
...@@ -36,7 +36,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -36,7 +36,7 @@ public class NoticeServiceImpl implements NoticeService {
@Transactional @Transactional
public boolean addNotice(Notice notice){ public boolean addNotice(Notice notice){
try{ try{
UserDo userDo = userService.findById(notice.getSender()); // 发送人 UserDo userDo = userService.findById(notice.getSender()); // 发送人用户
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 7); calendar.add(Calendar.DATE, 7);
String[] strings = notice.getAddressee().split(","); String[] strings = notice.getAddressee().split(",");
...@@ -44,34 +44,43 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -44,34 +44,43 @@ public class NoticeServiceImpl implements NoticeService {
notice.setDeadline(calendar.getTime()); notice.setDeadline(calendar.getTime());
notice.setUnit(userDo.getUnit()); notice.setUnit(userDo.getUnit());
notice.setStatus(0); notice.setStatus(0);
notice.setName(userDo.getName());
if (notice.getType() == 2){ if (notice.getType() == 2){
//保存为草稿 //保存为草稿
List<Addressee> addresseeList = new ArrayList<>(); List<Addressee> addresseeList = new ArrayList<>();
for(String addressee:strings){ for(String addressee:strings){
UserDo userDo1 = userService.findById(addressee); UserDo userDo1 = userService.findById(addressee);
Addressee addressee1 = new Addressee(); Addressee addressee1 = new Addressee();//收件人
addressee1.setId(userDo1.getId()); addressee1.setId(userDo1.getId());
addressee1.setName(userDo1.getName()); addressee1.setName(userDo1.getName());
addresseeList.add(addressee1); addresseeList.add(addressee1);
} }
notice.setAddressee(JSONObject.toJSONString(addresseeList)); notice.setAddressee(JSONObject.toJSONString(addresseeList));
noticeDao.save(notice); noticeDao.save(notice);
}else { }else {
List<Addressee> addresseeList2 = new ArrayList<>(); //接受者显示的接收列表
for(String addressee:strings){ for(String addressee:strings){
List<Addressee> addresseeList = new ArrayList<>(); List<Addressee> addresseeList = new ArrayList<>();
UserDo userDo1 = userService.findById(addressee); UserDo userDo1 = userService.findById(addressee); //收件人用户
Addressee addressee1 = new Addressee(); Addressee addressee1 = new Addressee();
addressee1.setId(userDo1.getId()); addressee1.setId(userDo1.getId());
addressee1.setName(userDo1.getName()); addressee1.setName(userDo1.getName());
addressee1.setUnit(userDo1.getUnit());
addresseeList.add(addressee1); addresseeList.add(addressee1);
addresseeList2.add(addressee1);
Notice notice1 = transform(notice); //发送通知 Notice notice1 = transform(notice); //发送通知
Notice notice2 = transform(notice); // 接收通知 Notice notice2 = transform(notice); // 接收通知
String add = JSONObject.toJSONString(addresseeList); String add = JSONObject.toJSONString(addresseeList);
String add2 = JSONObject.toJSONString(addresseeList2);
notice1.setAddressee(add); notice1.setAddressee(add);
notice2.setAddressee(add); notice2.setAddressee(add2);
notice2.setUnit(userDo1.getUnit()); notice2.setUnit(userDo1.getUnit());
notice2.setType(0); notice2.setType(0);
noticeDao.save(notice1); noticeDao.save(notice1);
...@@ -101,69 +110,6 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -101,69 +110,6 @@ public class NoticeServiceImpl implements NoticeService {
} }
// @Override
// @Transactional
// public boolean addNotice(Notice notice) {
// try{
//
// Calendar calendar = Calendar.getInstance();
// calendar.add(Calendar.DATE, 7);
// UserDo userDo = userService.findById(notice.getSender()); // 发送人
//
// notice.setUpdateTime(new Date());
// notice.setDeadline(calendar.getTime());
// notice.setUnit(userDo.getUnit());
// notice.setStatus(0);
//
//
// String data = "";
//
// if(notice.getType() == 2){
// //如果是草稿
// data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
// + "]新增关于[" + notice.getTitle() + "草稿";
// noticeDao.save(notice);
// }else {
// //如果是发送,就新增接收
//
// String[] addressees = notice.getAddressee().split(",");
// List<Notice> noticeList = new ArrayList<>();
// for (String addressee:addressees){
// Notice notice2 = transform(notice);
// notice2.setAddressee(addressee);
// noticeList.add(notice2); //已发送保存
//
// UserDo userDo1 = userService.findById(addressee); //接收人
//
// data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
// + "]给[" + userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
// + "发送了关于[" + notice.getTitle() + "]的通知";
//// Notice notice1 = new Notice();
// Notice notice1 = transform(notice);//已接收
// notice1.setType(0);
// notice1.setTitle(notice.getTitle());
// notice1.setAddressee(addressee);
// notice1.setUnit(userDo1.getUnit());
// noticeDao.save(notice1);
// String data1 = "[" +userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
// + "]收到了来自[" + userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
// + "]关于[" + notice.getTitle() + "的通知";
// 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()));
// return true;
//
// }catch (Exception e){
// e.printStackTrace();
// return false;
// }
//
// }
private Notice transform(Notice notice){ private Notice transform(Notice notice){
Notice notice1 = new Notice(); Notice notice1 = new Notice();
notice1.setTitle(notice.getTitle()); notice1.setTitle(notice.getTitle());
...@@ -285,16 +231,18 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -285,16 +231,18 @@ public class NoticeServiceImpl implements NoticeService {
@Override @Override
@Transactional @Transactional
public boolean updateStatus(List<Notice> notices) { public boolean updateStatus(List<Notice> notices, String userId) {
try { try {
String userId = ""; // String userId = "";
if (notices.get(0).getType() == 0){ // if (notices.get(0).getType() == 0){
String str = notices.get(0).getAddressee(); // String str = notices.get(0).getAddressee();
List<Addressee> addresseeList = JSONArray.parseArray(str,Addressee.class); // List<Addressee> addresseeList = JSONArray.parseArray(str,Addressee.class);
userId = addresseeList.get(0).getId(); // userId = addresseeList.get(0).getId();
}else { // }else {
userId = notices.get(0).getSender(); // String str = notices.get(0).getSender();
} // Addressee addressee = JSONObject.parseObject(str,Addressee.class);
// userId = addressee.getName();
// }
UserDo userDo = userService.findById(userId); // 当前登录人 UserDo userDo = userService.findById(userId); // 当前登录人
String data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName() String data = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "修改"; + "修改";
......
package com.zjty.efs.bus.util; package com.zjty.efs.bus.util;
import com.alibaba.fastjson.JSONArray;
import com.zjty.efs.bus.entity.Addressee;
import com.zjty.efs.bus.entity.Attention; 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.service.AttentionService; import com.zjty.efs.bus.service.AttentionService;
...@@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -8,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -17,10 +20,15 @@ public class Job { ...@@ -17,10 +20,15 @@ public class Job {
NoticeService noticeService; NoticeService noticeService;
@Autowired @Autowired
AttentionService attentionService; AttentionService attentionService;
@Scheduled(cron = "0 0 10 * * ? ") @Scheduled(cron = "0 */1 * * * ?")
public void cronJob() { public void cronJob() {
List<Notice> noticeList = noticeService.findBySender("",0,0);
Date now = new Date(); Date now = new Date();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, 7);
Date time = calendar.getTime();
List<Notice> noticeList = noticeService.findBySender("",0,0);
String data = ""; String data = "";
for(Notice notice:noticeList){ for(Notice notice:noticeList){
Attention attention = new Attention(); Attention attention = new Attention();
...@@ -29,10 +37,14 @@ public class Job { ...@@ -29,10 +37,14 @@ public class Job {
long days = (endTime.getTime()-now.getTime())/(1000*3600*24); long days = (endTime.getTime()-now.getTime())/(1000*3600*24);
System.out.println(days); System.out.println(days);
if (days == 3 || days == 1){ if (days == 3 || days == 1){
data = "您收到来自[" + notice.getSender() +"]的[" + notice.getTitle() + "],还有" + days +"天失效。"; data = "您收到来自[" + notice.getName() +"]的[" + notice.getTitle() + "],还有" + days +"天失效。";
attention.setData(data); attention.setData(data);
attention.setNoticeId(notice.getId()); attention.setNoticeId(notice.getId());
attention.setUserId(notice.getAddressee());
String str = notice.getAddressee();
List<Addressee> addresseeList = JSONArray.parseArray(str,Addressee.class);
String userId = addresseeList.get(0).getId();
attention.setUserId(userId);
attention.setStatus(0); attention.setStatus(0);
attention.setUpdateTime(new Date()); attention.setUpdateTime(new Date());
attentionService.addAttention(attention); attentionService.addAttention(attention);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论