|
@@ -16,10 +16,10 @@ import cn.com.qmth.examcloud.core.examwork.dao.entity.*;
|
|
import cn.com.qmth.examcloud.core.examwork.service.NoticeService;
|
|
import cn.com.qmth.examcloud.core.examwork.service.NoticeService;
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.*;
|
|
import cn.com.qmth.examcloud.core.examwork.service.bean.*;
|
|
import cn.com.qmth.examcloud.marking.api.MarkWorkCloudService;
|
|
import cn.com.qmth.examcloud.marking.api.MarkWorkCloudService;
|
|
-import cn.com.qmth.examcloud.marking.api.bean.MarkWorkBean;
|
|
|
|
-import cn.com.qmth.examcloud.marking.api.request.GetMarkWorkReq;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.marking.api.bean.MarkWorkMainBean;
|
|
|
|
+import cn.com.qmth.examcloud.marking.api.request.GetMarkWorkMainByIdsReq;
|
|
import cn.com.qmth.examcloud.marking.api.request.GetMarkersByWorkIdsReq;
|
|
import cn.com.qmth.examcloud.marking.api.request.GetMarkersByWorkIdsReq;
|
|
-import cn.com.qmth.examcloud.marking.api.response.GetMarkWorkResp;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.marking.api.response.GetMarkWorkMainByIdsResp;
|
|
import cn.com.qmth.examcloud.marking.api.response.GetMarkersByWorkIdsResp;
|
|
import cn.com.qmth.examcloud.marking.api.response.GetMarkersByWorkIdsResp;
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
|
|
@@ -98,17 +98,18 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public int updateNoticeReadStatus(String noticeId, UserType userType, Long userId) {
|
|
public int updateNoticeReadStatus(String noticeId, UserType userType, Long userId) {
|
|
- List<Long> noticeIdList = new ArrayList<>();
|
|
|
|
- if (noticeId.indexOf(",")>-1){
|
|
|
|
- noticeIdList=Arrays.asList(noticeId.split(",")).stream().map(p->Long.parseLong(p)).collect(Collectors.toList());
|
|
|
|
- }else {
|
|
|
|
- noticeIdList=Arrays.asList(noticeId).stream().map(p->Long.parseLong(p)).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Long> noticeIdList;
|
|
|
|
+ if (noticeId.contains(",")) {
|
|
|
|
+ noticeIdList = Arrays.asList(noticeId.split(",")).stream().map(p -> Long.parseLong(p)).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ noticeIdList = Arrays.asList(noticeId).stream().map(p -> Long.parseLong(p)).collect(Collectors.toList());
|
|
}
|
|
}
|
|
return userNoticeRepo.updateNoticeReadStatus(noticeIdList, userType.toString(), userId);
|
|
return userNoticeRepo.updateNoticeReadStatus(noticeIdList, userType.toString(), userId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageInfo<NoticeInfo> getPagedNoticeList(Integer curPage, Integer pageSize, NoticeInfoQuery infoQuery) {
|
|
public PageInfo<NoticeInfo> getPagedNoticeList(Integer curPage, Integer pageSize, NoticeInfoQuery infoQuery) {
|
|
|
|
+ List<NoticeInfo> resultList = new ArrayList<>();
|
|
Long rootOrgId = infoQuery.getRootOrgId();
|
|
Long rootOrgId = infoQuery.getRootOrgId();
|
|
Specification<NoticeEntity> specification = (root, query, cb) -> {
|
|
Specification<NoticeEntity> specification = (root, query, cb) -> {
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
List<Predicate> predicates = new ArrayList<>();
|
|
@@ -135,15 +136,20 @@ public class NoticeServiceImpl implements NoticeService {
|
|
PageRequest pageRequest = PageRequest.of(curPage, pageSize,
|
|
PageRequest pageRequest = PageRequest.of(curPage, pageSize,
|
|
new Sort(Sort.Direction.DESC, "creationTime"));
|
|
new Sort(Sort.Direction.DESC, "creationTime"));
|
|
Page<NoticeEntity> pagedNoticeEntityList = noticeRepo.findAll(specification, pageRequest);
|
|
Page<NoticeEntity> pagedNoticeEntityList = noticeRepo.findAll(specification, pageRequest);
|
|
- List<NoticeInfo> resultList = new ArrayList<>();
|
|
|
|
|
|
+ List<Long> noticeIdList = pagedNoticeEntityList.stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
|
|
+ List<NoticeReceiverRuleEntity> ruleList = getReceiverRuleList(rootOrgId, noticeIdList.toArray(new Long[noticeIdList.size()]));
|
|
|
|
+
|
|
for (NoticeEntity ne : pagedNoticeEntityList) {
|
|
for (NoticeEntity ne : pagedNoticeEntityList) {
|
|
|
|
+ NoticeReceiverRuleType ruleType = getNoticeReceiverRuleType(ne.getId(), ruleList);
|
|
NoticeInfo ni = new NoticeInfo();
|
|
NoticeInfo ni = new NoticeInfo();
|
|
ni.setId(ne.getId());
|
|
ni.setId(ne.getId());
|
|
ni.setPublisher(ne.getPublisher());
|
|
ni.setPublisher(ne.getPublisher());
|
|
ni.setPublishTime(ne.getPublishTime());
|
|
ni.setPublishTime(ne.getPublishTime());
|
|
ni.setTitle(ne.getTitle());
|
|
ni.setTitle(ne.getTitle());
|
|
- ni.setPublishObject(getPublishObject(rootOrgId, ne.getId()));
|
|
|
|
|
|
+ ni.setContent(ne.getContent());
|
|
|
|
+ ni.setPublishObject(getPublishObject(rootOrgId,ruleType,ruleList));
|
|
ni.setPublishStatus(getNoticePublishStatus(rootOrgId, ne));
|
|
ni.setPublishStatus(getNoticePublishStatus(rootOrgId, ne));
|
|
|
|
+ ni.setRuleType(ruleType);
|
|
resultList.add(ni);
|
|
resultList.add(ni);
|
|
}
|
|
}
|
|
return new PageInfo<>(pagedNoticeEntityList, resultList);
|
|
return new PageInfo<>(pagedNoticeEntityList, resultList);
|
|
@@ -188,7 +194,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
@Override
|
|
@Override
|
|
public int updateNotice(UpdateNoticeInfo info) {
|
|
public int updateNotice(UpdateNoticeInfo info) {
|
|
Long rootOrgId = info.getRootOrgId();
|
|
Long rootOrgId = info.getRootOrgId();
|
|
- List<Long> noticeIdList = Arrays.asList(info.getId());
|
|
|
|
|
|
+ List<Long> noticeIdList = Collections.singletonList(info.getId());
|
|
//校验通知状态,正在发送的通知不允许修改
|
|
//校验通知状态,正在发送的通知不允许修改
|
|
NoticePublishScheduleEntity publishSchedule = noticePublishScheduleRepo.findByRootOrgIdAndNoticeId(info.getRootOrgId(), info.getId());
|
|
NoticePublishScheduleEntity publishSchedule = noticePublishScheduleRepo.findByRootOrgIdAndNoticeId(info.getRootOrgId(), info.getId());
|
|
if (publishSchedule == null) {
|
|
if (publishSchedule == null) {
|
|
@@ -224,7 +230,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
NoticePublishScheduleEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(info);
|
|
NoticePublishScheduleEntity publishScheduleEntity = getNoticePublishScheduleEntityFrom(info);
|
|
NoticePublishScheduleEntity savedSchedule = noticePublishScheduleRepo.save(publishScheduleEntity);
|
|
NoticePublishScheduleEntity savedSchedule = noticePublishScheduleRepo.save(publishScheduleEntity);
|
|
|
|
|
|
- return savedSchedule == null ? 0 : 1;
|
|
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -239,10 +245,8 @@ public class NoticeServiceImpl implements NoticeService {
|
|
for (NoticePublishScheduleEntity publishSchedule : publishingScheduleList) {
|
|
for (NoticePublishScheduleEntity publishSchedule : publishingScheduleList) {
|
|
Long rootOrgId = publishSchedule.getRootOrgId();
|
|
Long rootOrgId = publishSchedule.getRootOrgId();
|
|
Long noticeId = publishSchedule.getNoticeId();
|
|
Long noticeId = publishSchedule.getNoticeId();
|
|
- List<NoticeReceiverRuleEntity> ruleList = noticeReceiverRuleRepo.findByRootOrgIdAndNoticeId(rootOrgId, noticeId);
|
|
|
|
- if (ruleList == null) {
|
|
|
|
- throw new StatusException("501009", "找不到通知id为:" + noticeId + "的通知对象信息");
|
|
|
|
- }
|
|
|
|
|
|
+ List<NoticeReceiverRuleEntity> ruleList = getReceiverRuleList(rootOrgId,noticeId);
|
|
|
|
+
|
|
//按通知对象的类型进行分组
|
|
//按通知对象的类型进行分组
|
|
Map<NoticeReceiverRuleType, List<NoticeReceiverRuleEntity>> groupedRuleMap = ruleList.stream().collect(Collectors.groupingBy(p -> p.getRuleType()));
|
|
Map<NoticeReceiverRuleType, List<NoticeReceiverRuleEntity>> groupedRuleMap = ruleList.stream().collect(Collectors.groupingBy(p -> p.getRuleType()));
|
|
Set<NoticeReceiverRuleType> groupRuleMapKeySet = groupedRuleMap.keySet();
|
|
Set<NoticeReceiverRuleType> groupRuleMapKeySet = groupedRuleMap.keySet();
|
|
@@ -353,7 +357,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
* @param publishSchedule
|
|
* @param publishSchedule
|
|
* @param limitStudentIdList
|
|
* @param limitStudentIdList
|
|
*/
|
|
*/
|
|
- private void finishNoticePublishSchedule( NoticePublishScheduleEntity publishSchedule) {
|
|
|
|
|
|
+ private void finishNoticePublishSchedule(NoticePublishScheduleEntity publishSchedule) {
|
|
publishSchedule.setPublishStatus(NoticePublishStatus.PUBLISHED);
|
|
publishSchedule.setPublishStatus(NoticePublishStatus.PUBLISHED);
|
|
noticePublishScheduleRepo.save(publishSchedule);
|
|
noticePublishScheduleRepo.save(publishSchedule);
|
|
}
|
|
}
|
|
@@ -400,12 +404,12 @@ public class NoticeServiceImpl implements NoticeService {
|
|
markWorkerReq.setSize(rowNumber);
|
|
markWorkerReq.setSize(rowNumber);
|
|
// FIXME: 2019/7/11
|
|
// FIXME: 2019/7/11
|
|
GetMarkersByWorkIdsResp markWorkerResp = markWorkCloudService.getMarkersByWorkIds(markWorkerReq);
|
|
GetMarkersByWorkIdsResp markWorkerResp = markWorkCloudService.getMarkersByWorkIds(markWorkerReq);
|
|
-// GetMarkersByWorkIdsResp markWorkerResp = new GetMarkersByWorkIdsResp();
|
|
|
|
List<Long> limitUserIdList = markWorkerResp.getMarkers();
|
|
List<Long> limitUserIdList = markWorkerResp.getMarkers();
|
|
if (markWorkerResp.getMarkers() != null && !markWorkerResp.getMarkers().isEmpty()) {
|
|
if (markWorkerResp.getMarkers() != null && !markWorkerResp.getMarkers().isEmpty()) {
|
|
resultResp.setMaxId(Collections.max(limitUserIdList));
|
|
resultResp.setMaxId(Collections.max(limitUserIdList));
|
|
}
|
|
}
|
|
resultResp.setNextId(markWorkerResp.getNextId());
|
|
resultResp.setNextId(markWorkerResp.getNextId());
|
|
|
|
+ resultResp.setIdList(markWorkerResp.getMarkers());
|
|
return resultResp;
|
|
return resultResp;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -414,7 +418,7 @@ public class NoticeServiceImpl implements NoticeService {
|
|
List<Long> limitUserIdList = new ArrayList<>();
|
|
List<Long> limitUserIdList = new ArrayList<>();
|
|
long nextUserId;//当前需求只有考试中心
|
|
long nextUserId;//当前需求只有考试中心
|
|
GetAllUsersByRoleReq getLcUserReq = new GetAllUsersByRoleReq();
|
|
GetAllUsersByRoleReq getLcUserReq = new GetAllUsersByRoleReq();
|
|
- getLcUserReq.setRoleId(rootOrgId);
|
|
|
|
|
|
+ getLcUserReq.setRootOrgId(rootOrgId);
|
|
getLcUserReq.setRoleCode(RoleMeta.LC_USER.toString());
|
|
getLcUserReq.setRoleCode(RoleMeta.LC_USER.toString());
|
|
getLcUserReq.setStart(startUserId);
|
|
getLcUserReq.setStart(startUserId);
|
|
GetAllUsersByRoleResp getLcUserResp = userCloudService.getAllUsersByRole(getLcUserReq);
|
|
GetAllUsersByRoleResp getLcUserResp = userCloudService.getAllUsersByRole(getLcUserReq);
|
|
@@ -517,27 +521,33 @@ public class NoticeServiceImpl implements NoticeService {
|
|
* @param noticeId
|
|
* @param noticeId
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getPublishObject(Long rootOrgId, Long noticeId) {
|
|
|
|
- List<NoticeReceiverRuleEntity> ruleList =
|
|
|
|
- noticeReceiverRuleRepo.findByRootOrgIdAndNoticeId(rootOrgId, noticeId);
|
|
|
|
- if (ruleList == null || ruleList.isEmpty()) {
|
|
|
|
- throw new StatusException("501002", "未找到公告接收人相关信息");
|
|
|
|
- }
|
|
|
|
- //公告接收人类型
|
|
|
|
- NoticeReceiverRuleType ruleType = ruleList.stream().map(NoticeReceiverRuleEntity::getRuleType).findFirst().get();
|
|
|
|
-
|
|
|
|
|
|
+ private List<Map<String, Object>> getPublishObject(Long rootOrgId, NoticeReceiverRuleType ruleType,List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
|
|
+ Map<String, Object> objectMap;
|
|
|
|
+ List<NoticeReceiverRuleEntity> currentRuleList;
|
|
switch (ruleType) {
|
|
switch (ruleType) {
|
|
case STUDENTS_OF_EXAM:
|
|
case STUDENTS_OF_EXAM:
|
|
- return getExamStudentObject(ruleList);
|
|
|
|
|
|
+ currentRuleList = ruleList.stream().filter(p -> p.getRuleType() == ruleType).collect(Collectors.toList());
|
|
|
|
+ return getExamStudentObject(currentRuleList);
|
|
case ALL_STUDENTS_OF_ROOT_ORG:
|
|
case ALL_STUDENTS_OF_ROOT_ORG:
|
|
- return "所有学生";
|
|
|
|
|
|
+ objectMap = new HashMap<>();
|
|
|
|
+ objectMap.put("id", 0);
|
|
|
|
+ objectMap.put("name", "所有学生");
|
|
|
|
+ objectMap.put("ruleType", "ALL_STUDENTS_OF_ROOT_ORG");
|
|
|
|
+ resultList.add(objectMap);
|
|
|
|
+ return resultList;
|
|
case COMMON_USERS_OF_ROLE:
|
|
case COMMON_USERS_OF_ROLE:
|
|
- return "所有学习中心用户";
|
|
|
|
|
|
+ objectMap = new HashMap<>();
|
|
|
|
+ objectMap.put("id", 0);
|
|
|
|
+ objectMap.put("name", "所有学习中心用户");
|
|
|
|
+ objectMap.put("ruleType", "COMMON_USERS_OF_ROLE");
|
|
|
|
+ resultList.add(objectMap);
|
|
|
|
+ return resultList;
|
|
case TEACHER_OF_MARK_WORK:
|
|
case TEACHER_OF_MARK_WORK:
|
|
- return getMarkTeacherObject(rootOrgId, ruleList);
|
|
|
|
- default:
|
|
|
|
- return "";
|
|
|
|
|
|
+ currentRuleList = ruleList.stream().filter(p -> p.getRuleType() == ruleType).collect(Collectors.toList());
|
|
|
|
+ return getMarkTeacherObject(rootOrgId, currentRuleList);
|
|
}
|
|
}
|
|
|
|
+ return resultList;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -546,15 +556,19 @@ public class NoticeServiceImpl implements NoticeService {
|
|
* @param ruleList
|
|
* @param ruleList
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getExamStudentObject(List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
- String publishObject = "";
|
|
|
|
|
|
+ private List<Map<String, Object>> getExamStudentObject(List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
//考试批次id
|
|
//考试批次id
|
|
List<Long> examIdList = ruleList.stream().map(p -> Long.parseLong(p.getRuleValue())).collect(Collectors.toList());
|
|
List<Long> examIdList = ruleList.stream().map(p -> Long.parseLong(p.getRuleValue())).collect(Collectors.toList());
|
|
List<ExamEntity> examList = examRepo.findByIdIn(examIdList);
|
|
List<ExamEntity> examList = examRepo.findByIdIn(examIdList);
|
|
for (ExamEntity e : examList) {
|
|
for (ExamEntity e : examList) {
|
|
- publishObject += "学生-" + e.getName() + ";";
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("id", e.getId());
|
|
|
|
+ map.put("name", "学生-" + e.getName());
|
|
|
|
+ map.put("ruleType", "STUDENTS_OF_EXAM");
|
|
|
|
+ resultList.add(map);
|
|
}
|
|
}
|
|
- return publishObject;
|
|
|
|
|
|
+ return resultList;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -564,26 +578,23 @@ public class NoticeServiceImpl implements NoticeService {
|
|
* @param ruleList
|
|
* @param ruleList
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- private String getMarkTeacherObject(Long rootOrgId, List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
- String publishObject = "";
|
|
|
|
|
|
+ private List<Map<String, Object>> getMarkTeacherObject(Long rootOrgId, List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
+ List<Map<String, Object>> resultList = new ArrayList<>();
|
|
List<Long> markWorkIdList = ruleList.stream().map(p -> Long.parseLong(p.getRuleValue())).collect(Collectors.toList());
|
|
List<Long> markWorkIdList = ruleList.stream().map(p -> Long.parseLong(p.getRuleValue())).collect(Collectors.toList());
|
|
- GetMarkWorkReq req = new GetMarkWorkReq();
|
|
|
|
- MarkWorkBean bean = new MarkWorkBean();
|
|
|
|
- bean.setRootOrgId(rootOrgId);
|
|
|
|
- bean.setStatus(1);
|
|
|
|
- req.setMarkWorkBean(bean);
|
|
|
|
- // FIXME: 2019/7/11
|
|
|
|
- GetMarkWorkResp markWorkResp = markWorkCloudService.getMarkWork(req);
|
|
|
|
- List<MarkWorkBean> markWorkList = markWorkResp.getMarkWorkBeanList();
|
|
|
|
- for (Long mwId : markWorkIdList) {
|
|
|
|
- Optional<MarkWorkBean> workBeanOptional = markWorkList.stream().filter(p -> p.getId().equals(mwId)).findFirst();
|
|
|
|
- if (!workBeanOptional.isPresent()) {
|
|
|
|
- throw new StatusException("501004", "找不到id为:" + mwId + "的教务工作信息");
|
|
|
|
- }
|
|
|
|
- MarkWorkBean mw = workBeanOptional.get();
|
|
|
|
- publishObject += "老师-" + mw.getName() + ";";
|
|
|
|
|
|
+ GetMarkWorkMainByIdsReq req = new GetMarkWorkMainByIdsReq();
|
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
|
+ req.setWorkIds(markWorkIdList);
|
|
|
|
+
|
|
|
|
+ GetMarkWorkMainByIdsResp markWorkResp = markWorkCloudService.getMarkWorkMainByIds(req);
|
|
|
|
+ List<MarkWorkMainBean> markWorkList = markWorkResp.getList();
|
|
|
|
+ for (MarkWorkMainBean mw : markWorkList) {
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("id", mw.getId());
|
|
|
|
+ map.put("name", "老师-" + mw.getName());
|
|
|
|
+ map.put("ruleType", "TEACHER_OF_MARK_WORK");
|
|
|
|
+ resultList.add(map);
|
|
}
|
|
}
|
|
- return publishObject;
|
|
|
|
|
|
+ return resultList;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -710,4 +721,24 @@ public class NoticeServiceImpl implements NoticeService {
|
|
|
|
|
|
return ruleList;
|
|
return ruleList;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private List<NoticeReceiverRuleEntity> getReceiverRuleList(Long rootOrgId, Long... noticeId) {
|
|
|
|
+ List<NoticeReceiverRuleEntity> ruleList =
|
|
|
|
+ noticeReceiverRuleRepo.findByRootOrgIdAndNoticeIdIn(rootOrgId, Arrays.asList(noticeId));
|
|
|
|
+ if (ruleList == null) {
|
|
|
|
+ throw new StatusException("501009", "找不到通知id为:" + noticeId + "的通知对象信息");
|
|
|
|
+ }
|
|
|
|
+ return ruleList;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private NoticeReceiverRuleType getNoticeReceiverRuleType(Long noticeId, List<NoticeReceiverRuleEntity> ruleList) {
|
|
|
|
+ Optional<NoticeReceiverRuleType> first = ruleList.stream().
|
|
|
|
+ filter(p -> p.getNoticeId().equals(noticeId)).map(p->p.getRuleType()).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ return first.get();
|
|
|
|
+ } else {
|
|
|
|
+ throw new StatusException("501012","找不到通知id为:"+noticeId+"的通知规则类型");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|