|
|
@@ -8,10 +8,12 @@ import com.usoftchina.smartschool.school.wxschool.mapper.*;
|
|
|
import com.usoftchina.smartschool.school.wxschool.support.RemindTaskVote;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.DateFormatUtil;
|
|
|
import com.usoftchina.smartschool.school.wxschool.utils.ObjectUtils;
|
|
|
+import com.usoftchina.smartschool.wechat.service.WxPushService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@@ -32,6 +34,18 @@ public class WxVoteServiceImpl implements WxVoteService {
|
|
|
@Autowired
|
|
|
private WxTeacherMapper teacherMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WxPushService wxPushService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxSchoolMapper wxSchoolMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxParentsStuMapper wxParentsStuMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WxParentsMapper wxParentsMapper;
|
|
|
+
|
|
|
|
|
|
/** 创建投票单 */
|
|
|
public String voteCreate(String voteString) throws Exception {
|
|
|
@@ -79,24 +93,29 @@ public class WxVoteServiceImpl implements WxVoteService {
|
|
|
timer.schedule(new RemindTaskVote(voteMapper,vote.getVoteId()),DateFormatUtil.string2Date(voteEndDate));
|
|
|
}
|
|
|
List<Long> teacherId = JSON.parseArray(teacherIds, Long.class);
|
|
|
- List<Long> list = removeDuplicate(teacherId);
|
|
|
+ if (ObjectUtils.isNotEmpty(teacherId)){
|
|
|
+ List<Long> list = removeDuplicate(teacherId);
|
|
|
+ for (Long ll:list) {
|
|
|
+ TeacherDO teacherDO = teacherMapper.get(ll);
|
|
|
+ SchoolDO schoolDO = wxSchoolMapper.get(teacherDO.getSchoolId());
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ this.wxPushService.wxPush(schoolDO.getSchoolAppid(),schoolDO.getSchoolSecret(),teacherDO.getOpenid(),"h0BkcnTo24b2jsficMeVO0B17GvE-VzlPvF0fVXea4w","有一个投票单需要您的支持",schoolDO.getSchoolName(),teacherMapper.get(creator).getTeacherName(),format.format(new Date()),vote.getVoteName(),"点击查看详情","");
|
|
|
+ }
|
|
|
+ }
|
|
|
List<Long> stuId = JSON.parseArray(stuIds, Long.class);
|
|
|
List<Long> list1 = removeDuplicate(stuId);
|
|
|
- /*for (int j = 0; j <list.size() ; j++) {
|
|
|
- Long teacherId = list.get(j);
|
|
|
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- if (ObjectUtils.isNotEmpty(user)){
|
|
|
- String userOpenid = user.getUserOpenid();
|
|
|
- if (ObjectUtils.isNotEmpty(userOpenid)){
|
|
|
- userService.wxPush(userOpenid,"h0BkcnTo24b2jsficMeVO0B17GvE-VzlPvF0fVXea4w","有一个投票单需要您的支持",schoolMapper.selectSchoolById(userMapper.selectUserById(votes.getLong("creator")).getSchoolId()).getSchName(),userMapper.selectUserById(votes.getLong("creator")).getUserName(),format.format(new Date()),vote.getVoteName(),"点击查看详情","https://www.akuiguoshu.com/smart-school/classRechargeDetail/"+userId+"/"+vote.getVoteId());
|
|
|
- }*//*else {
|
|
|
- throw new Exception("请关注智慧校园公众号");
|
|
|
- }*//*
|
|
|
- }else {
|
|
|
- throw new Exception("用户不存在");
|
|
|
+ new ArrayList<Long>();
|
|
|
+ for (Long l:list1) {
|
|
|
+ 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());
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ this.wxPushService.wxPush(schoolDO.getSchoolAppid(), schoolDO.getSchoolSecret(), parentsDO.getOpenid(), "h0BkcnTo24b2jsficMeVO0B17GvE-VzlPvF0fVXea4w", "有一个投票单需要您的支持", schoolDO.getSchoolName(), teacherMapper.get(creator).getTeacherName(), format.format(new Date()), vote.getVoteName(), "点击查看详情", "");
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- }*/
|
|
|
+ }
|
|
|
return "创建成功";
|
|
|
}else {
|
|
|
throw new Exception("创建失败");
|