|
|
@@ -14,6 +14,10 @@ import com.usoftchina.smartschool.school.exception.BizExceptionCode;
|
|
|
import com.usoftchina.smartschool.school.mapper.*;
|
|
|
import com.usoftchina.smartschool.school.po.*;
|
|
|
import com.usoftchina.smartschool.utils.CollectionUtils;
|
|
|
+import com.usoftchina.smartschool.utils.DateUtils;
|
|
|
+import com.usoftchina.smartschool.wechat.api.WechatApi;
|
|
|
+import com.usoftchina.smartschool.wechat.dto.MessageInfoDTO;
|
|
|
+import com.usoftchina.smartschool.wechat.dto.TransferDTO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -47,6 +51,15 @@ public class ScoreServiceImpl implements ScoreService{
|
|
|
@Autowired
|
|
|
private SysStudentMapper sysStudentMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysSchoolMapper sysSchoolMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WechatApi wechatApi;
|
|
|
+
|
|
|
+
|
|
|
+ final static String TEMPLATEID = "GwR7hZ9ya7ghAiH3PR-ws1l24P_ETE3phYJBjKTcpKY";
|
|
|
+
|
|
|
@Override
|
|
|
public PageInfo<ScoreImportList> getListData(PageRequest page, ListReqDTO listReqDTO) {
|
|
|
PageHelper.startPage(page.getNumber(), page.getSize());
|
|
|
@@ -202,8 +215,13 @@ public class ScoreServiceImpl implements ScoreService{
|
|
|
List<StuScore> appScores = new ArrayList<StuScore>();
|
|
|
StuScore appScore = null;
|
|
|
Long school_id = BaseContextHolder.getSchoolId();
|
|
|
+ //学校信息
|
|
|
+ SysSchool school = sysSchoolMapper.selectByPrimaryKey(BaseContextHolder.getSchoolId());
|
|
|
+ //表单数据
|
|
|
ScoreImport main = scoreMapper.selectByPrimaryKey(id);
|
|
|
List<ScoreImportdetail> details = scoreMapper.selectDetail(id);
|
|
|
+ //消息内容
|
|
|
+ List<MessageInfoDTO> msgs = new ArrayList<>();
|
|
|
for (ScoreImportdetail detail : details) {
|
|
|
appScore = new StuScore();
|
|
|
appScore.setSchool_id(school_id);
|
|
|
@@ -221,6 +239,29 @@ public class ScoreServiceImpl implements ScoreService{
|
|
|
appScores.add(appScore);
|
|
|
}
|
|
|
scoreMapper.batchInsert(appScores);
|
|
|
+ //微信推送
|
|
|
+ List<ScoreNoticer> noticers = scoreMapper.selectWechatMsg(id);
|
|
|
+ noticers.forEach(noticer -> {
|
|
|
+ MessageInfoDTO msg = new MessageInfoDTO();
|
|
|
+ msg.setTitle("您好,请查收您小孩" + noticer.getStuName() + "的成绩单");
|
|
|
+ msg.setKeyword1(noticer.getStuName());
|
|
|
+ msg.setKeyword2(noticer.getStuNo());
|
|
|
+ msg.setKeyword3(main.getSi_examtitle());
|
|
|
+ msg.setKeyword4(DateUtils.format(main.getSi_examdate(),"yyyy-MM-dd"));
|
|
|
+ msg.setKeyword5(school.getSchool_name());
|
|
|
+ msg.setRemark("成绩为:" + noticer.getScore());
|
|
|
+ msg.setTemplateId(TEMPLATEID);
|
|
|
+ msg.setTouser(noticer.getOpenid());
|
|
|
+ msg.setAppId(school.getSchool_appid());
|
|
|
+ msg.setSecret(school.getSchool_secret());
|
|
|
+ msgs.add(msg);
|
|
|
+ });
|
|
|
+ if (msgs.size() > 0) {
|
|
|
+ TransferDTO transferDTO = new TransferDTO();
|
|
|
+ transferDTO.setData(msgs);
|
|
|
+ //调用推送接口
|
|
|
+ wechatApi.largeMessages(transferDTO);
|
|
|
+ }
|
|
|
//更新已转标志
|
|
|
scoreMapper.updateTurnPublish(id);
|
|
|
}
|