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

xc

上级 1545166d
...@@ -57,6 +57,28 @@ ...@@ -57,6 +57,28 @@
<artifactId>efs-user</artifactId> <artifactId>efs-user</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.4.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>2.2.5.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.zjty</groupId>
<artifactId>efs-ftp</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
......
...@@ -12,7 +12,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; ...@@ -12,7 +12,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
"com.zjty.efs.misc", "com.zjty.efs.misc",
"com.zjty.efs.bus", "com.zjty.efs.bus",
"com.zjty.efs.log", "com.zjty.efs.log",
"com.zjty.efs.user" "com.zjty.efs.user",
"com.zjty.efs.ftp"
}) })
@EnableSwagger2 @EnableSwagger2
@EnableScheduling @EnableScheduling
......
...@@ -11,5 +11,6 @@ import java.util.List; ...@@ -11,5 +11,6 @@ import java.util.List;
@Repository @Repository
public interface AttentionDao extends JpaRepository<Attention, Integer> { public interface AttentionDao extends JpaRepository<Attention, Integer> {
Page<Attention> findOutByUserId(String sender, Pageable pageable); Page<Attention> findOutByUserId(String sender, Pageable pageable);
Page<Attention> findOutByUserIdAndStatus(String sender, Pageable pageable, int status);
List<Attention> findOutByUserIdAndStatus(String userId, int status); List<Attention> findOutByUserIdAndStatus(String userId, int status);
} }
...@@ -14,9 +14,10 @@ public interface NoticeDao extends JpaRepository<Notice , Integer> { ...@@ -14,9 +14,10 @@ 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> findOutByStatusAndTypeAndLabel(int status, int type, int label); List<Notice> findOutByTypeAndLabelNot(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> findOutByReceiverAndType(String addressee, int type, Pageable pageable);
Page<Notice> findOutByReceiverAndTypeAndStatus(String addressee, int type, int status, Pageable pageable); Page<Notice> findOutByReceiverAndTypeAndStatus(String addressee, int type, int status, Pageable pageable);
List<Notice> findOutByReceiverAndStatus(String receiver, int status);
} }
...@@ -27,16 +27,17 @@ import java.util.List; ...@@ -27,16 +27,17 @@ import java.util.List;
public class AttentionController { public class AttentionController {
@Autowired @Autowired
AttentionService attentionService; AttentionService attentionService;
@ApiOperation(value = "获取提醒列表") @ApiOperation(value = "获取提醒列表", notes = "status为状态,全部 2,未读 0, 已读 1")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "当前登录用户", dataType = "String", paramType = "query", required = true), @ApiImplicitParam(name = "userId", value = "当前登录用户", dataType = "String", paramType = "query", required = true),
@ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", paramType = "query", required = true), @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "pageSize", value = "条数", dataType = "int", paramType = "query", required = true) @ApiImplicitParam(name = "pageSize", value = "条数", dataType = "int", paramType = "query", required = true),
@ApiImplicitParam(name = "status", value = "状态", dataType = "int", paramType = "query", required = true)
}) })
@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, int status){
log.info("获取提醒列表:{}", userId); log.info("获取提醒列表:{}", userId);
return ResponseEntity.ok(attentionService.getAttentionList(userId, pageNum, pageSize)); return ResponseEntity.ok(attentionService.getAttentionList(userId, pageNum, pageSize, status));
} }
@ApiOperation(value = "修改提醒为已读") @ApiOperation(value = "修改提醒为已读")
......
...@@ -94,4 +94,10 @@ public class NoticeController { ...@@ -94,4 +94,10 @@ public class NoticeController {
return ResponseEntity.ok(noticeService.updateStatus(notices, userId)); return ResponseEntity.ok(noticeService.updateStatus(notices, userId));
} }
@GetMapping("/unreadNum")
public ResponseEntity unreadNum(String userId){
log.info("已接收未读数量");
return ResponseEntity.ok(noticeService.unreadNum(userId));
}
} }
...@@ -4,15 +4,26 @@ import lombok.AllArgsConstructor; ...@@ -4,15 +4,26 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import javax.persistence.Table;
import java.lang.annotation.Documented;
/**
* 接收人信息
*/
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public class Addressee { public class Addressee {
/**
* 接收人ID
*/
private String id; private String id;
/**
* 接收人名字
*/
private String name; private String name;
/**
* 接收人单位
*/
private String unit; private String unit;
} }
...@@ -13,7 +13,7 @@ public interface AttentionService { ...@@ -13,7 +13,7 @@ public interface AttentionService {
* @param pageSize  每页条数 * @param pageSize  每页条数
* @return List<Paging></> * @return List<Paging></>
*/ */
Paging<Attention> getAttentionList(String userId, int pageNum, int pageSize); Paging<Attention> getAttentionList(String userId, int pageNum, int pageSize, int status);
/** /**
* 添加消息提醒 * 添加消息提醒
...@@ -34,5 +34,5 @@ public interface AttentionService { ...@@ -34,5 +34,5 @@ public interface AttentionService {
* @param userId 当前登录用户编号 * @param userId 当前登录用户编号
* @return * @return
*/ */
boolean getRedDot(String userId); int getRedDot(String userId);
} }
...@@ -10,14 +10,14 @@ public interface NoticeService { ...@@ -10,14 +10,14 @@ public interface NoticeService {
/** /**
* 新增通知 * 新增通知
* @param jsonObject 通知对象 * @param jsonObject 通知对象
* @return * @return true/false
*/ */
boolean addNotice(Notice jsonObject); boolean addNotice(Notice jsonObject);
/** /**
* 修改通知 * 修改通知
* @param jsonObject 通知对象 * @param jsonObject 通知对象
* @return * @return true/false
*/ */
boolean updateNotice(Notice jsonObject); boolean updateNotice(Notice jsonObject);
...@@ -25,7 +25,7 @@ public interface NoticeService { ...@@ -25,7 +25,7 @@ public interface NoticeService {
* 查看通知 * 查看通知
* @param id 通知id * @param id 通知id
* @param userId 当前用户 * @param userId 当前用户
* @return * @return 通知实体notice
*/ */
Notice getNotice(int id, String userId); Notice getNotice(int id, String userId);
...@@ -51,22 +51,30 @@ public interface NoticeService { ...@@ -51,22 +51,30 @@ public interface NoticeService {
* @param userId 当前用户 * @param userId 当前用户
* @param status 0 未读 * @param status 0 未读
* @param type 0 接收通知 * @param type 0 接收通知
* @return * @return 通知实体列表
*/ */
List<Notice> findBySender(String userId, int status, int type); List<Notice> findBySender(String userId, int status, int type);
/**
* 保存通知
* @param notice 通知实体
*/
void saveNotice(Notice notice); void saveNotice(Notice notice);
/** /**
* 获取已查看/未查看 * 获取已查看/未查看
* @param user 当前用户id * @param user 当前用户id
* @param status 通知状态 * @param status 通知状态
* @param pageNum * @param pageNum 页码
* @param pageSize * @param pageSize 页数
* @return * @return Paging实体
*/ */
Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize,int type); Paging<Notice> getListByStatus(String user, int status, int pageNum, int pageSize,int type);
/**
* 已接收未读数量
* @param userId 当前用户id
* @return 已接收未读数量
*/
int unreadNum(String userId);
} }
...@@ -19,10 +19,16 @@ public class AttentionServiceImpl implements AttentionService { ...@@ -19,10 +19,16 @@ public class AttentionServiceImpl implements AttentionService {
@Autowired @Autowired
AttentionDao attentionDao; AttentionDao attentionDao;
@Override @Override
public Paging<Attention> getAttentionList(String userId, int pageNum, int pageSize) { public Paging<Attention> getAttentionList(String userId, int pageNum, int pageSize, int staus) {
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<Attention> p = attentionDao.findOutByUserId(userId, pageable); Page<Attention> p;
if (staus ==2 ){
p = attentionDao.findOutByUserId(userId, pageable);
}else {
p = attentionDao.findOutByUserIdAndStatus(userId, pageable, staus);
}
Paging<Attention> paging= new Paging<>(); Paging<Attention> paging= new Paging<>();
paging.setTotal((int)p.getTotalElements()); paging.setTotal((int)p.getTotalElements());
...@@ -66,13 +72,9 @@ public class AttentionServiceImpl implements AttentionService { ...@@ -66,13 +72,9 @@ public class AttentionServiceImpl implements AttentionService {
} }
@Override @Override
public boolean getRedDot(String userId) { public int getRedDot(String userId) {
List<Attention> attentions = attentionDao.findOutByUserIdAndStatus(userId, 0); List<Attention> attentions = attentionDao.findOutByUserIdAndStatus(userId, 0);
if(attentions.size() > 0){ return attentions.size();
return true;
}else {
return false;
}
} }
} }
...@@ -14,9 +14,7 @@ import com.zjty.efs.log.tool.EfsLogUtil; ...@@ -14,9 +14,7 @@ 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 lombok.extern.slf4j.Slf4j;
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.domain.*; import org.springframework.data.domain.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -63,6 +61,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -63,6 +61,7 @@ public class NoticeServiceImpl implements NoticeService {
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);
...@@ -74,10 +73,13 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -74,10 +73,13 @@ 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<>(); List<UserDo> stringList = new ArrayList<>();//收件人列表
for(String addressee:strings){ for(String addressee:strings){
UserDo userDo1 = userService.findById(addressee); //收件人用户 UserDo userDo1 = userService.findById(addressee); //收件人用户
stringList.add(userDo1);
Addressee addressee1 = new Addressee(); Addressee addressee1 = new Addressee();
addressee1.setId(userDo1.getId()); addressee1.setId(userDo1.getId());
addressee1.setName(userDo1.getName()); addressee1.setName(userDo1.getName());
...@@ -87,7 +89,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -87,7 +89,7 @@ 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()
+ "] "; + "] ";
...@@ -97,16 +99,14 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -97,16 +99,14 @@ public class NoticeServiceImpl implements NoticeService {
} }
String add2 = JSONObject.toJSONString(addresseeList2); String add2 = JSONObject.toJSONString(addresseeList2);
for (String add:stringList){ for (UserDo 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); notice2.setReceiver(add.getId());
noticeDao.save(notice2); noticeDao.save(notice2);
UserDo userDo1 = userService.findById(add); //收件人用户 String data2 = "[" +add.getUnit() + "][" + add.getDepartment() + "]的[" + add.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() + "的通知";
...@@ -114,7 +114,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -114,7 +114,7 @@ public class NoticeServiceImpl implements NoticeService {
attention.setStatus(0); attention.setStatus(0);
attention.setUpdateTime(new Date()); attention.setUpdateTime(new Date());
attention.setData(data2); attention.setData(data2);
attention.setUserId(add); attention.setUserId(add.getId());
attentionService.addAttention(attention); attentionService.addAttention(attention);
} }
...@@ -159,6 +159,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -159,6 +159,7 @@ public class NoticeServiceImpl implements NoticeService {
notice1.setUnit(notice.getUnit()); notice1.setUnit(notice.getUnit());
notice1.setName(notice.getName()); notice1.setName(notice.getName());
notice1.setLabel(notice.getLabel()); notice1.setLabel(notice.getLabel());
return notice1; return notice1;
} }
...@@ -211,32 +212,6 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -211,32 +212,6 @@ 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().split(",")[0];
// addressee = userService.findById(addresseeId);
// }else {
// String addresseeId1 = notice.getAddressee().split(",")[0];
// if (!addresseeId.equals(addresseeId1)){
// //如果两个收件人不一样,重新获取user
// addressee = userService.findById(addresseeId1);
// }
// }
//
// 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);
...@@ -255,16 +230,6 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -255,16 +230,6 @@ public class NoticeServiceImpl implements NoticeService {
@Transactional @Transactional
public boolean updateStatus(List<Notice> notices, String userId) { public boolean updateStatus(List<Notice> notices, String userId) {
try { try {
// String userId = "";
// if (notices.get(0).getType() == 0){
// String str = notices.get(0).getAddressee();
// List<Addressee> addresseeList = JSONArray.parseArray(str,Addressee.class);
// userId = addresseeList.get(0).getId();
// }else {
// 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()
+ "修改"; + "修改";
...@@ -287,7 +252,7 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -287,7 +252,7 @@ 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.findOutByStatusAndTypeAndLabel(status, type, 0); return noticeDao.findOutByTypeAndLabelNot(type, 2);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
return null; return null;
...@@ -318,5 +283,11 @@ public class NoticeServiceImpl implements NoticeService { ...@@ -318,5 +283,11 @@ public class NoticeServiceImpl implements NoticeService {
} }
@Override
public int unreadNum(String userId) {
List<Notice> noticeList = noticeDao.findOutByReceiverAndStatus(userId, 0);
return noticeList.size();
}
} }
package com.zjty.efs.bus.util; package com.zjty.efs.bus.util;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
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.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;
import com.zjty.efs.bus.service.NoticeService; import com.zjty.efs.bus.service.NoticeService;
import com.zjty.efs.ftp.base.response.ServerResponse;
import com.zjty.efs.ftp.entity.DownLoadCount;
import com.zjty.efs.ftp.entity.DownLoadRequest;
import com.zjty.efs.ftp.service.DownLoadService;
import org.springframework.beans.factory.annotation.Autowired; 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;
...@@ -13,6 +19,7 @@ import org.springframework.stereotype.Component; ...@@ -13,6 +19,7 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.Period; import java.time.Period;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.ArrayList;
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,6 +30,8 @@ public class Job { ...@@ -23,6 +30,8 @@ public class Job {
NoticeService noticeService; NoticeService noticeService;
@Autowired @Autowired
AttentionService attentionService; AttentionService attentionService;
@Autowired
DownLoadService downLoadService;
@Scheduled(cron = "0 */1 * * * ?") @Scheduled(cron = "0 */1 * * * ?")
public void cronJob() { public void cronJob() {
...@@ -30,31 +39,19 @@ public class Job { ...@@ -30,31 +39,19 @@ public class Job {
Date now = new Date(); Date now = new Date();
List<Notice> noticeList = noticeService.findBySender("",0,0); List<Notice> noticeList = noticeService.findBySender("",0,0);
String data = "";
for(Notice notice:noticeList){ for(Notice notice:noticeList){
Attention attention = new Attention();
Date endTime = notice.getDeadline(); Date endTime = notice.getDeadline();
double days = (endTime.getTime()-now.getTime())/(1000*3600*24.0); double days = (endTime.getTime()-now.getTime())/(1000*3600*24.0);
// System.out.println(days); // System.out.println(days);
if (days <= 3.001 || days <= 1.001){
int d = (int)days;
data = "您收到来自[" + notice.getName() +"]的[" + notice.getTitle() + "],还有" + d +"天失效。";
attention.setData(data);
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);
notice.setLabel(1);
noticeService.saveNotice(notice);
// updateAtt(notice, days, 1);
if (days <= 3.001 && days > 2.998 && notice.getLabel() != 1){
updateAtt(notice, days, 1);
}
if(days <= 1.001 && days > 0.998 && notice.getLabel() != 2){
updateAtt(notice, days, 2);
} }
} }
...@@ -63,4 +60,69 @@ public class Job { ...@@ -63,4 +60,69 @@ public class Job {
} }
} }
/**
* 判断是否有已读未下载的文件
* @param notice 通知
* @param days 失效天数
* @param label 修改通知label 1为提醒过一次,2为提醒过两次
*/
private void updateAtt(Notice notice, double days, int label){
// System.out.println("--------------------定时------------------");
String data = "";
Attention attention = new Attention();
data = "您收到来自["+ notice.getUnit() + "][" + notice.getName() +"]标题为[" + notice.getTitle() + "]的通知,没有查看";
if (notice.getStatus() == 1 && !"".equals(notice.getFileList())){
//通知为已读,且文件列表不为空
String file = notice.getFileList();
String[] files = file.split(",");
List<Integer> fileList = new ArrayList<>();
DownLoadRequest downLoadRequest = new DownLoadRequest();
for(int i = 0; i < files.length; i++){
String s = files[i];
fileList.add(Integer.parseInt(s));
}
downLoadRequest.setFileIds(fileList);
downLoadRequest.setUserId(notice.getReceiver());
List<DownLoadCount> downLoadCounts = downLoadService.findCount(downLoadRequest);
// System.out.println(downLoadCounts);
for(DownLoadCount downLoadCount:downLoadCounts){
if(downLoadCount.getCount() == 0){
data = "您收到来自["+ notice.getUnit() + "][" + notice.getName() +"]标题为[" + notice.getTitle() + "]的通知,有文件没有下载";
add(days, attention, data, notice, label);
}
}
}else {
add(days, attention, data, notice, label);
}
}
/**
* 新增提醒,并修改通知label
* @param days 失效天数
* @param attention 提醒实体
* @param data 提醒内容
* @param notice 通知实体
* @param label 该通知提醒过几次
*/
private void add(double days, Attention attention, String data, Notice notice, int label){
int d = (int)Math.ceil(days);
data = data + ",还有" + d + "天失效。";
attention.setData(data);
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);
notice.setLabel(label);
noticeService.saveNotice(notice);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论