|
|
@@ -7,6 +7,7 @@ import com.usoftchina.smartschool.school.wxschool.basic.service.WxNotifyService;
|
|
|
import com.usoftchina.smartschool.school.wxschool.mapper.*;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
|
|
|
import com.usoftchina.smartschool.wechat.api.WxPushApi;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -69,88 +70,89 @@ public class WxNotifyServiceImpl implements WxNotifyService {
|
|
|
JSONObject json = JSONObject.parseObject(jsonNotify);
|
|
|
NotifyDO notifyDO = new NotifyDO();
|
|
|
notifyDO.setCreateDate(new Date());
|
|
|
+ notifyDO.setPublishDate(new Date());
|
|
|
String notifyTitle = json.getString("notifyTitle");
|
|
|
notifyDO.setNotifyTitle(notifyTitle);
|
|
|
String notifyDetails = json.getString("notifyDetails");
|
|
|
notifyDO.setNotifyDetails(notifyDetails);
|
|
|
Long notifyCreator = json.getLong("notifyCreator");
|
|
|
notifyDO.setNotifyCreator(notifyCreator);
|
|
|
- notifyDO.setSchoolId(teacherMapper.get(notifyCreator).getSchoolId());
|
|
|
+ TeacherDO teacherDO1 = teacherMapper.get(notifyCreator);
|
|
|
+ Long schoolId = null;
|
|
|
+ if (ObjectUtils.isNotEmpty(teacherDO1)){
|
|
|
+ schoolId = teacherDO1.getSchoolId();
|
|
|
+ notifyDO.setSchoolId(schoolId);
|
|
|
+ notifyDO.setCreator(teacherDO1.getTeacherName());
|
|
|
+ }
|
|
|
notifyDO.setNotifyType(json.getInteger("notifyType"));
|
|
|
notifyDO.setNotifyFiles(json.getString("notifyFiles"));
|
|
|
notifyDO.setNotifyStatus(json.getInteger("notifyStatus"));
|
|
|
notifyDO.setNotifyRemarks(json.getString("notifyRemarks"));
|
|
|
- String notifyTeacher = json.getString("notifyTeacher");
|
|
|
- String notifyStu = json.getString("notifyStu");
|
|
|
- notifyDO.setNotifyTeacher(notifyTeacher);
|
|
|
- notifyDO.setNotifyStu(notifyStu);
|
|
|
int save = notifyMapper.save(notifyDO);
|
|
|
if (save>0){
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
- List<Long> longs = JSON.parseArray(notifyTeacher, Long.class);
|
|
|
- if (ObjectUtils.isNotEmpty(longs)){
|
|
|
- List<Long> list = removeDuplicate(longs);
|
|
|
- NotifyrecordsDO notifyrecordsDO = new NotifyrecordsDO();
|
|
|
- for (Long l:list) {
|
|
|
- if (notifyCreator.compareTo(l)==0){
|
|
|
- notifyrecordsDO.setIsRead(2);
|
|
|
- }else {
|
|
|
- notifyrecordsDO.setIsRead(1);
|
|
|
- }
|
|
|
- notifyrecordsDO.setNotifyId(notifyDO.getNotifyId());
|
|
|
- notifyrecordsDO.setTeacherId(l);
|
|
|
- notifyrecordsMapper.save(notifyrecordsDO);
|
|
|
- TeacherDO teacherDO = teacherMapper.get(l);
|
|
|
- SchoolDO schoolDO = wxSchoolMapper.get(teacherDO.getSchoolId());
|
|
|
- String schoolName = schoolDO.getSchoolName();
|
|
|
- String teacherName = teacherMapper.get(notifyCreator).getTeacherName();
|
|
|
- if (ObjectUtils.isNotEmpty(schoolDO)){
|
|
|
- String schoolAppid = schoolDO.getSchoolAppid();
|
|
|
- if (ObjectUtils.isNotEmpty(schoolAppid)){
|
|
|
- TemplateDO templateDO = wxTemplateMapper.getByAppid(schoolAppid);
|
|
|
- if (ObjectUtils.isNotEmpty(templateDO)){
|
|
|
- String temNotify = templateDO.getTemNotify();
|
|
|
- try {
|
|
|
- wxPushApi.wxPush(schoolDO.getSchoolAppid(),schoolDO.getSchoolSecret(),teacherDO.getOpenid(), temNotify, "您好,您有一条通知",schoolName ,teacherName,format.format(new Date()),notifyDetails, "点击查看详情", wechatUrl + "/notifyDetail/teacher/"+notifyDO.getNotifyId()+"?teacherId="+l);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ if (ObjectUtils.isNotEmpty(schoolId)){
|
|
|
+ List<Long> idBySchoolId = teacherMapper.getIdBySchoolId(schoolId,1);
|
|
|
+ if (ObjectUtils.isNotEmpty(idBySchoolId)){
|
|
|
+ List<Long> list = removeDuplicate(idBySchoolId);
|
|
|
+ NotifyrecordsDO notifyrecordsDO = new NotifyrecordsDO();
|
|
|
+ for (Long l:list) {
|
|
|
+ if (notifyCreator.compareTo(l)==0){
|
|
|
+ notifyrecordsDO.setIsRead(2);
|
|
|
+ }else {
|
|
|
+ notifyrecordsDO.setIsRead(1);
|
|
|
+ }
|
|
|
+ notifyrecordsDO.setNotifyId(notifyDO.getNotifyId());
|
|
|
+ notifyrecordsDO.setTeacherId(l);
|
|
|
+ notifyrecordsMapper.save(notifyrecordsDO);
|
|
|
+ TeacherDO teacherDO = teacherMapper.get(l);
|
|
|
+ if (ObjectUtils.isNotEmpty(teacherDO)){
|
|
|
+ Long schoolId1 = teacherDO.getSchoolId();
|
|
|
+ if (ObjectUtils.isNotEmpty(schoolId1)){
|
|
|
+ SchoolDO schoolDO = wxSchoolMapper.get(schoolId1);
|
|
|
+ String school = wxTemplateMapper.getByStCode(schoolId1, "school");
|
|
|
+ if (ObjectUtils.isNotEmpty(schoolDO)){
|
|
|
+ String schoolName = schoolDO.getSchoolName();
|
|
|
+ String teacherName = teacherMapper.get(notifyCreator).getTeacherName();
|
|
|
+ try {
|
|
|
+ wxPushApi.wxPush(schoolDO.getSchoolAppid(),schoolDO.getSchoolSecret(),teacherDO.getOpenid(), school, "您好,您有一条通知",schoolName ,teacherName,format.format(new Date()),notifyDetails, "点击查看详情", wechatUrl + "/notifyDetail/teacher/"+notifyDO.getNotifyId()+"?teacherId="+l);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- }
|
|
|
- List<Long> stuIds = JSON.parseArray(notifyStu, Long.class);
|
|
|
- if (ObjectUtils.isNotEmpty(stuIds)){
|
|
|
- List<Long> list = removeDuplicate(stuIds);
|
|
|
- NotifyrecordsDO notifyrecordsDO = new NotifyrecordsDO();
|
|
|
- for (Long l:list) {
|
|
|
- notifyrecordsDO.setIsRead(1);
|
|
|
- notifyrecordsDO.setNotifyId(notifyDO.getNotifyId());
|
|
|
- notifyrecordsDO.setStuId(l);
|
|
|
- notifyrecordsMapper.save(notifyrecordsDO);
|
|
|
- List<ParentsStuDO> parentsStuDOS = wxParentsStuMapper.listByStuId(l);
|
|
|
- if (parentsStuDOS.size()>0){
|
|
|
- for (ParentsStuDO ps:parentsStuDOS) {
|
|
|
- ParentsDO parentsDO = wxParentsMapper.get(ps.getParentId());
|
|
|
- SchoolDO schoolDO = wxSchoolMapper.get(parentsDO.getSchoolId());
|
|
|
- String teacherName = teacherMapper.get(notifyCreator).getTeacherName();
|
|
|
- if (ObjectUtils.isNotEmpty(schoolDO)){
|
|
|
- String schoolAppid = schoolDO.getSchoolAppid();
|
|
|
- if (ObjectUtils.isNotEmpty(schoolAppid)){
|
|
|
- TemplateDO templateDO = wxTemplateMapper.getByAppid(schoolAppid);
|
|
|
- if (ObjectUtils.isNotEmpty(templateDO)){
|
|
|
- String temNotify = templateDO.getTemNotify();
|
|
|
- try {
|
|
|
- wxPushApi.wxPush(schoolDO.getSchoolAppid(),schoolDO.getSchoolSecret(),parentsDO.getOpenid(), temNotify, "您好,您有一条通知", schoolDO.getSchoolName(),teacherName,format.format(new Date()),notifyDetails, "点击查看详情", wechatUrl + "/notifyDetail/parent/"+notifyDO.getNotifyId()+"?stuId="+l);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ List<Long> list = studentMapper.selectStuIdsBySchoolId(schoolId);
|
|
|
+ if (ObjectUtils.isNotEmpty(list)){
|
|
|
+ List<Long> stuIds = removeDuplicate(list);
|
|
|
+ NotifyrecordsDO notifyrecordsDO = new NotifyrecordsDO();
|
|
|
+ for (Long l:stuIds) {
|
|
|
+ notifyrecordsDO.setIsRead(1);
|
|
|
+ notifyrecordsDO.setNotifyId(notifyDO.getNotifyId());
|
|
|
+ notifyrecordsDO.setStuId(l);
|
|
|
+ notifyrecordsMapper.save(notifyrecordsDO);
|
|
|
+ List<ParentsStuDO> parentsStuDOS = wxParentsStuMapper.listByStuId(l);
|
|
|
+ if (parentsStuDOS.size()>0){
|
|
|
+ for (ParentsStuDO ps:parentsStuDOS) {
|
|
|
+ ParentsDO parentsDO = wxParentsMapper.get(ps.getParentId());
|
|
|
+ if (ObjectUtils.isNotEmpty(parentsDO)){
|
|
|
+ Long schoolId1 = parentsDO.getSchoolId();
|
|
|
+ if (ObjectUtils.isNotEmpty(schoolId1)){
|
|
|
+ SchoolDO schoolDO = wxSchoolMapper.get(schoolId1);
|
|
|
+ String school = wxTemplateMapper.getByStCode(schoolId1, "school");
|
|
|
+ if (ObjectUtils.isNotEmpty(schoolDO)){
|
|
|
+ String teacherName = teacherMapper.get(notifyCreator).getTeacherName();
|
|
|
+ try {
|
|
|
+ wxPushApi.wxPush(schoolDO.getSchoolAppid(),schoolDO.getSchoolSecret(),parentsDO.getOpenid(), school, "您好,您有一条通知", schoolDO.getSchoolName(),teacherName,format.format(new Date()),notifyDetails, "点击查看详情", wechatUrl + "/notifyDetail/parent/"+notifyDO.getNotifyId()+"?stuId="+l);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -183,11 +185,15 @@ public class WxNotifyServiceImpl implements WxNotifyService {
|
|
|
}
|
|
|
hashMap.put("create",createList);
|
|
|
|
|
|
- List<NotifyDO> notifys = notifyMapper.selectNotifyListLikeTeacher("%" + teacherId + "%", notifyStatus, pageStart, pageSize);
|
|
|
List<NotifyDO> notifyList = new ArrayList<>();
|
|
|
- for (NotifyDO mt:notifys) {
|
|
|
- NotifyDO notifyDO = getNotifyDetail(0L,teacherId, mt);
|
|
|
- notifyList.add(notifyDO);
|
|
|
+ TeacherDO teacherDO = teacherMapper.get(teacherId);
|
|
|
+ if (ObjectUtils.isNotEmpty(teacherDO)){
|
|
|
+ List<NotifyDO> notifyDOS1 = notifyMapper.selectNotifyListSchoolId(teacherDO.getSchoolId(), notifyStatus,
|
|
|
+ pageStart, pageSize);
|
|
|
+ for (NotifyDO mt:notifyDOS1) {
|
|
|
+ NotifyDO notifyDO = getNotifyDetail(0L,teacherId, mt);
|
|
|
+ notifyList.add(notifyDO);
|
|
|
+ }
|
|
|
}
|
|
|
hashMap.put("notify",notifyList);
|
|
|
return hashMap;
|
|
|
@@ -200,15 +206,22 @@ public class WxNotifyServiceImpl implements WxNotifyService {
|
|
|
* @param pageIndex
|
|
|
* @param pageSize
|
|
|
*/
|
|
|
- public List<NotifyDO> notifyListByStu(Long stuId, Integer notifyStatus, Integer pageIndex, Integer pageSize){
|
|
|
+ public List<NotifyDO> notifyListByStu(Long stuId, Integer notifyStatus, Integer pageIndex, Integer pageSize) throws Exception {
|
|
|
Integer pageStart = (pageIndex-1)*pageSize;
|
|
|
- List<NotifyDO> notifys = notifyMapper.selectNotifyListLikeStu("%" + stuId + "%", notifyStatus, pageStart, pageSize);
|
|
|
- List<NotifyDO> notifyList = new ArrayList<>();
|
|
|
- for (NotifyDO nt:notifys) {
|
|
|
- NotifyDO notifyDetail = getNotifyDetail(stuId, 0L, nt);
|
|
|
- notifyList.add(notifyDetail);
|
|
|
+ StudentDO studentDO = studentMapper.get(stuId);
|
|
|
+ if (ObjectUtils.isNotEmpty(studentDO)){
|
|
|
+ List<NotifyDO> notifyList = new ArrayList<>();
|
|
|
+ List<NotifyDO> notifyDOS = notifyMapper.selectNotifyListSchoolId(studentDO.getSchoolId(), notifyStatus,
|
|
|
+ pageStart, pageSize);
|
|
|
+ for (NotifyDO nt:notifyDOS) {
|
|
|
+ NotifyDO notifyDetail = getNotifyDetail(stuId, 0L, nt);
|
|
|
+ notifyList.add(notifyDetail);
|
|
|
+ }
|
|
|
+ return notifyList;
|
|
|
+ }else {
|
|
|
+ throw new Exception("该学生暂时不存在");
|
|
|
}
|
|
|
- return notifyList;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -219,10 +232,11 @@ public class WxNotifyServiceImpl implements WxNotifyService {
|
|
|
*/
|
|
|
public NotifyDO getNotifyDetails(Long stuId,Long notifyId) throws Exception {
|
|
|
NotifyDO notifyDO = notifyMapper.get(notifyId);
|
|
|
- NotifyrecordsDO byStu = notifyrecordsMapper.getByStu(stuId, notifyId);
|
|
|
- if (ObjectUtils.isNotEmpty(byStu)){
|
|
|
- byStu.setIsRead(2);
|
|
|
- int update = notifyrecordsMapper.update(byStu);
|
|
|
+ List<NotifyrecordsDO> byStu = notifyrecordsMapper.getByStu(stuId, notifyId);
|
|
|
+ if (CollectionUtils.isNotEmpty(byStu)){
|
|
|
+ NotifyrecordsDO notifyrecordsDO = byStu.get(0);
|
|
|
+ notifyrecordsDO.setIsRead(2);
|
|
|
+ int update = notifyrecordsMapper.update(notifyrecordsDO);
|
|
|
if (update>0){
|
|
|
return getNotifyDetail(stuId,0L,notifyDO);
|
|
|
}else {
|
|
|
@@ -240,10 +254,11 @@ public class WxNotifyServiceImpl implements WxNotifyService {
|
|
|
*/
|
|
|
public NotifyDO getNotifyDetailsByTeacher(Long notifyId, Long teacherId) throws Exception {
|
|
|
NotifyDO notifyDO = notifyMapper.get(notifyId);
|
|
|
- NotifyrecordsDO byTeacher = notifyrecordsMapper.getByTeacher(notifyId, teacherId);
|
|
|
- if (ObjectUtils.isNotEmpty(byTeacher)){
|
|
|
- byTeacher.setIsRead(2);
|
|
|
- int update = notifyrecordsMapper.update(byTeacher);
|
|
|
+ List<NotifyrecordsDO> byTeacher = notifyrecordsMapper.getByTeacher(notifyId, teacherId);
|
|
|
+ if (CollectionUtils.isNotEmpty(byTeacher)){
|
|
|
+ NotifyrecordsDO notifyrecordsDO = byTeacher.get(0);
|
|
|
+ notifyrecordsDO.setIsRead(2);
|
|
|
+ int update = notifyrecordsMapper.update(notifyrecordsDO);
|
|
|
if (update>0){
|
|
|
return getNotifyDetail(0L,teacherId,notifyDO);
|
|
|
}else {
|