提交 77559e40 authored 作者: zhangshuang's avatar zhangshuang

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

...@@ -14,5 +14,6 @@ public interface NoticeDao extends JpaRepository<Notice , Integer> { ...@@ -14,5 +14,6 @@ public interface NoticeDao extends JpaRepository<Notice , Integer> {
Notice findById(int id); Notice findById(int id);
Page<Notice> findOutBySenderAndType(String sender, int type, Pageable pageable); Page<Notice> findOutBySenderAndType(String sender, int type, Pageable pageable);
Page<Notice> findOutByAddresseeLikeAndType(String addressee, int type, Pageable pageable); Page<Notice> findOutByAddresseeLikeAndType(String addressee, int type, Pageable pageable);
List<Notice> findOutByStatusAndType(int status, int type); List<Notice> findOutByStatusAndTypeAndLabel(int status, int type, int label);
Page<Notice> findOutByAddresseeLikeAndTypeAndStatus(String addressee, int type, Pageable pageable, int status);
} }
...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
...@@ -22,6 +23,7 @@ import java.util.List; ...@@ -22,6 +23,7 @@ import java.util.List;
@Api(tags = "提醒接口") @Api(tags = "提醒接口")
@RestController @RestController
@RequestMapping("/attention") @RequestMapping("/attention")
@Slf4j
public class AttentionController { public class AttentionController {
@Autowired @Autowired
AttentionService attentionService; AttentionService attentionService;
...@@ -33,6 +35,7 @@ public class AttentionController { ...@@ -33,6 +35,7 @@ public class AttentionController {
}) })
@GetMapping("/getAttention") @GetMapping("/getAttention")
public ResponseEntity<Paging<Attention>> getAttentionList(@RequestParam String userId, int pageNum, int pageSize){ public ResponseEntity<Paging<Attention>> getAttentionList(@RequestParam String userId, int pageNum, int pageSize){
log.info("获取提醒列表:{}", userId);
return ResponseEntity.ok(attentionService.getAttentionList(userId, pageNum, pageSize)); return ResponseEntity.ok(attentionService.getAttentionList(userId, pageNum, pageSize));
} }
...@@ -43,6 +46,7 @@ public class AttentionController { ...@@ -43,6 +46,7 @@ public class AttentionController {
}) })
@PutMapping("/updateStatus") @PutMapping("/updateStatus")
public ResponseEntity updateStatus(@RequestBody @Valid List<Attention> attentions){ public ResponseEntity updateStatus(@RequestBody @Valid List<Attention> attentions){
log.info("修改提醒为已读");
return ResponseEntity.ok(attentionService.updateStatus(attentions)); return ResponseEntity.ok(attentionService.updateStatus(attentions));
} }
...@@ -52,6 +56,7 @@ public class AttentionController { ...@@ -52,6 +56,7 @@ public class AttentionController {
}) })
@GetMapping("/redDot") @GetMapping("/redDot")
public ResponseEntity getRedDot(@RequestParam String userId){ public ResponseEntity getRedDot(@RequestParam String userId){
log.info("消息提醒小红点");
return ResponseEntity.ok(attentionService.getRedDot(userId)); return ResponseEntity.ok(attentionService.getRedDot(userId));
} }
......
...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -19,6 +20,7 @@ import java.util.List; ...@@ -19,6 +20,7 @@ import java.util.List;
@Api(tags = "通知接口") @Api(tags = "通知接口")
@RestController @RestController
@RequestMapping("/notice") @RequestMapping("/notice")
@Slf4j
public class NoticeController { public class NoticeController {
@Autowired @Autowired
private NoticeService noticeService; private NoticeService noticeService;
...@@ -33,6 +35,7 @@ public class NoticeController { ...@@ -33,6 +35,7 @@ public class NoticeController {
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true) @ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PostMapping("/addNotice") @PostMapping("/addNotice")
public ResponseEntity addNotice(@RequestBody @Valid Notice notice){ public ResponseEntity addNotice(@RequestBody @Valid Notice notice){
log.info("新增通知:{}", notice);
return ResponseEntity.ok(noticeService.addNotice(notice)); return ResponseEntity.ok(noticeService.addNotice(notice));
} }
...@@ -45,7 +48,7 @@ public class NoticeController { ...@@ -45,7 +48,7 @@ public class NoticeController {
@ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true) @ApiImplicitParam(name = "notice", value = "通知实体", dataType = "Notice", paramType = "body", required = true)
@PutMapping("/updateNotice") @PutMapping("/updateNotice")
public ResponseEntity updateNotice(@RequestBody @Valid Notice notice){ public ResponseEntity updateNotice(@RequestBody @Valid Notice notice){
log.info("修改通知接口:{}", notice);
return ResponseEntity.ok(noticeService.updateNotice(notice)); return ResponseEntity.ok(noticeService.updateNotice(notice));
} }
...@@ -60,13 +63,23 @@ public class NoticeController { ...@@ -60,13 +63,23 @@ public class NoticeController {
} }
@GetMapping("/getNoticeList") @GetMapping("/getNoticeList")
@ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2") @ApiOperation(value = "获取通知列表接口", notes = "获取列表,type为通知类型,接收 0,发送 1,草稿 2,status为状态,0 未读,1已读,2 全部")
@ApiImplicitParams({@ApiImplicitParam(name = "user", value = "当前用户名称", paramType = "query", required = true, example = "account", dataType = "String"), @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"),
public ResponseEntity<Paging<Notice>> getNoticeList(@RequestParam String user, int type, int pageNum, int pageSize){ @ApiImplicitParam(name = "status", value = "状态", paramType = "query", required = true, dataType = "int")})
Paging<Notice> data = noticeService.getReceiveList(user, type, pageNum, pageSize); public ResponseEntity<Paging<Notice>> getNoticeList(@RequestParam String user, int type,
int pageNum, int pageSize, int status){
log.info("获取通知列表接口:{},{}", user,type);
Paging<Notice> data = new Paging<>();
if (status == 2){
//全部
data = noticeService.getReceiveList(user, type, pageNum, pageSize);
}else {
data = noticeService.getListByStatus(user, status, pageNum, pageSize);
}
return ResponseEntity.ok(data); return ResponseEntity.ok(data);
} }
...@@ -76,6 +89,7 @@ public class NoticeController { ...@@ -76,6 +89,7 @@ public class NoticeController {
allowMultiple = true, dataType = "Notice"), allowMultiple = true, dataType = "Notice"),
@ApiImplicitParam(name = "userId", value = "当前登录用户", paramType = "query", required = true,dataType = "String")}) @ApiImplicitParam(name = "userId", value = "当前登录用户", paramType = "query", required = true,dataType = "String")})
public ResponseEntity updateStatus(@RequestBody List<Notice> notices, @RequestParam String userId){ public ResponseEntity updateStatus(@RequestBody List<Notice> notices, @RequestParam String userId){
log.info("修改通知为已读:{}", userId);
return ResponseEntity.ok(noticeService.updateStatus(notices, userId)); return ResponseEntity.ok(noticeService.updateStatus(notices, userId));
} }
......
...@@ -59,7 +59,8 @@ public class Attention { ...@@ -59,7 +59,8 @@ public class Attention {
@ApiModelProperty(value = "updateTime", name = "更新时间", example = "2019-01-01 00:00:00.000") @ApiModelProperty(value = "updateTime", name = "更新时间", example = "2019-01-01 00:00:00.000")
@Column(name = "update_time") @Column(name = "update_time")
@JsonFormat(pattern = "yyyy-HH-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime; private Date updateTime;
} }
...@@ -68,7 +68,7 @@ public class Notice { ...@@ -68,7 +68,7 @@ public class Notice {
@ApiModelProperty(value = "status", example = "0", dataType = "int" ,name = "通知状态", @ApiModelProperty(value = "status", example = "0", dataType = "int" ,name = "通知状态",
notes = "未查看 0,已查看 1,已下载 2,默认 0") notes = "未查看 0,已查看 1,已下载 2,默认 0")
@Column(name = "status") @Column(name = "status")
private int status; private Integer status;
/** /**
* 通知类型 接受 0,发送 1,草稿 2 * 通知类型 接受 0,发送 1,草稿 2
...@@ -83,7 +83,7 @@ public class Notice { ...@@ -83,7 +83,7 @@ public class Notice {
*/ */
@ApiModelProperty(value = "deadline", name = "通知失效时间", example = "2019-01-01 00:00:00.000") @ApiModelProperty(value = "deadline", name = "通知失效时间", example = "2019-01-01 00:00:00.000")
@Column(name = "deadline") @Column(name = "deadline")
@JsonFormat(pattern = "yyyy-HH-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date deadline; private Date deadline;
/** /**
...@@ -92,7 +92,7 @@ public class Notice { ...@@ -92,7 +92,7 @@ public class Notice {
@ApiModelProperty(value = "updateTime", name = "通知更新时间", example = "2019-01-01 00:00:00.000") @ApiModelProperty(value = "updateTime", name = "通知更新时间", example = "2019-01-01 00:00:00.000")
@Column(name = "update_time") @Column(name = "update_time")
@JsonFormat(pattern = "yyyy-HH-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime; private Date updateTime;
/** /**
...@@ -121,6 +121,13 @@ public class Notice { ...@@ -121,6 +121,13 @@ public class Notice {
@ApiModelProperty(value = "name", example = "", dataType = "String", name = "发件人名称") @ApiModelProperty(value = "name", example = "", dataType = "String", name = "发件人名称")
@Column(name = "name") @Column(name = "name")
private String name; private String name;
/**
* 是否提醒 没提醒 0,提醒 1
*/
@ApiModelProperty(value = "label", example = "1", dataType = "int", name = "是否提醒")
@Column(name = "label")
private int label;
} }
...@@ -54,6 +54,19 @@ public interface NoticeService { ...@@ -54,6 +54,19 @@ public interface NoticeService {
* @return * @return
*/ */
List<Notice> findBySender(String userId, int status, int type); List<Notice> findBySender(String userId, int status, int type);
void saveNotice(Notice notice);
/**
* 获取已查看/未查看
* @param user 当前用户id
* @param status 通知状态
* @param pageNum
* @param pageSize
* @return
*/
Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize);
} }
...@@ -11,6 +11,7 @@ import com.zjty.efs.log.subject.entity.EfsLog; ...@@ -11,6 +11,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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; 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;
...@@ -24,6 +25,7 @@ import java.lang.reflect.Array; ...@@ -24,6 +25,7 @@ import java.lang.reflect.Array;
import java.util.*; import java.util.*;
@Service @Service
@Slf4j
public class NoticeServiceImpl implements NoticeService { public class NoticeServiceImpl implements NoticeService {
@Autowired @Autowired
NoticeDao noticeDao; NoticeDao noticeDao;
...@@ -45,6 +47,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -45,6 +47,7 @@ public class NoticeServiceImpl implements NoticeService {
notice.setUnit(userDo.getUnit()); notice.setUnit(userDo.getUnit());
notice.setStatus(0); notice.setStatus(0);
notice.setName(userDo.getName()); notice.setName(userDo.getName());
notice.setLabel(0);
...@@ -65,40 +68,43 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -65,40 +68,43 @@ public class NoticeServiceImpl implements NoticeService {
}else { }else {
List<Addressee> addresseeList2 = new ArrayList<>(); //接受者显示的接收列表 List<Addressee> addresseeList2 = new ArrayList<>(); //接受者显示的接收列表
Notice notice1 = transform(notice); //发送通知
String dataList = "";
for(String addressee:strings){ for(String addressee:strings){
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()); addressee1.setUnit(userDo1.getUnit());
addresseeList.add(addressee1);
addresseeList2.add(addressee1); addresseeList2.add(addressee1);
Notice notice1 = transform(notice); //发送通知
Notice notice2 = transform(notice); // 接收通知
String add = JSONObject.toJSONString(addresseeList);
String add2 = JSONObject.toJSONString(addresseeList2);
notice1.setAddressee(add);
notice2.setAddressee(add2);
notice2.setUnit(userDo1.getUnit());
notice2.setType(0);
noticeDao.save(notice1);
noticeDao.save(notice2);
String data1 = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]给[" + userDo1.getUnit() + "][" + userDo1.getDepartment() + "]的[" + userDo1.getName()
+ "发送了关于[" + notice.getTitle() + "]的通知";
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() + "的通知";
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data1, new Date())); 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);
for (String addressee:strings){
Notice notice2 = transform(notice); // 接收通知
notice2.setAddressee(add2);
notice2.setType(0);
noticeDao.save(notice2);
}
notice1.setAddressee(add2);
noticeDao.save(notice1);
String data1 = "[" +userDo.getUnit() + "][" + userDo.getDepartment() + "]的[" + userDo.getName()
+ "]给" + dataList
+ "发送了关于[" + notice.getTitle() + "]的通知";
efsLogUtil.addLog(new EfsLog(null, userDo.getId(), data1, new Date()));
} }
...@@ -123,6 +129,8 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -123,6 +129,8 @@ public class NoticeServiceImpl implements NoticeService {
notice1.setUpdateTime(notice.getUpdateTime()); notice1.setUpdateTime(notice.getUpdateTime());
notice1.setType(notice.getType()); notice1.setType(notice.getType());
notice1.setUnit(notice.getUnit()); notice1.setUnit(notice.getUnit());
notice1.setName(notice.getName());
notice1.setLabel(notice.getLabel());
return notice1; return notice1;
} }
...@@ -265,12 +273,35 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -265,12 +273,35 @@ public class NoticeServiceImpl implements NoticeService {
@Override @Override
public List<Notice> findBySender(String userId, int status, int type) { public List<Notice> findBySender(String userId, int status, int type) {
try{ try{
return noticeDao.findOutByStatusAndType(status, type); return noticeDao.findOutByStatusAndTypeAndLabel(status, type, 0);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
@Override
public void saveNotice(Notice notice) {
noticeDao.save(notice);
}
@Override
public Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize) {
try{
Pageable pageable = PageRequest.of(pageNum - 1, pageSize, Sort.Direction.DESC,"updateTime");
Page<Notice> p = noticeDao.findOutByAddresseeLikeAndTypeAndStatus(user, 0, pageable, status);
Paging<Notice> paging = new Paging<>();
paging.setData(p.getContent());
paging.setPageSize(pageSize);
paging.setPageNum(pageNum);
paging.setTotal((int)p.getTotalElements());
return paging;
}catch (Exception e){
e.printStackTrace();
return null;
}
}
} }
...@@ -10,6 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,9 @@ 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.time.LocalDateTime;
import java.time.Period;
import java.time.ZoneId;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -23,33 +26,40 @@ public class Job { ...@@ -23,33 +26,40 @@ public class Job {
@Scheduled(cron = "0 */1 * * * ?") @Scheduled(cron = "0 */1 * * * ?")
public void cronJob() { public void cronJob() {
Date now = new Date(); try {
Calendar calendar = Calendar.getInstance(); Date now = new Date();
calendar.add(Calendar.DATE, 7);
Date time = calendar.getTime(); List<Notice> noticeList = noticeService.findBySender("",0,0);
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(); Date endTime = notice.getDeadline();
Date endTime = notice.getDeadline();
double days = (endTime.getTime()-now.getTime())/(1000*3600*24.0);
long days = (endTime.getTime()-now.getTime())/(1000*3600*24); // System.out.println(days);
System.out.println(days); if (days <= 3.001 || days <= 1.001){
if (days == 3 || days == 1){ int d = (int)days;
data = "您收到来自[" + notice.getName() +"]的[" + notice.getTitle() + "],还有" + days +"天失效。"; data = "您收到来自[" + notice.getName() +"]的[" + notice.getTitle() + "],还有" + d +"天失效。";
attention.setData(data); attention.setData(data);
attention.setNoticeId(notice.getId()); attention.setNoticeId(notice.getId());
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.setUpdateTime(new Date());
attentionService.addAttention(attention);
}
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.setUpdateTime(new Date());
attentionService.addAttention(attention);
notice.setLabel(1);
noticeService.saveNotice(notice);
}
}
}catch (Exception e){
e.printStackTrace();
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论