修改自动发布作业的逻辑
This commit is contained in:
parent
fae2fc8673
commit
4cb7757ed5
|
@ -778,18 +778,19 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
|
||||||
|
|
||||||
//微信通知点击后跳转的页面
|
//微信通知点击后跳转的页面
|
||||||
private static final String domainTo = "https://zxkccx.webvpn.nenu.edu.cn";
|
private static final String domainTo = "https://zxkccx.webvpn.nenu.edu.cn";
|
||||||
|
|
||||||
public void sendWxmessage(KcWechatSendLog kcWechatSendLog) {
|
public void sendWxmessage(KcWechatSendLog kcWechatSendLog) {
|
||||||
String openId = kcWechatSendLog.getOpenid();//曹老师账号
|
String openId = kcWechatSendLog.getOpenid();//曹老师账号
|
||||||
System.out.println("openId:"+openId+"");
|
System.out.println("openId:" + openId + "");
|
||||||
if(org.apache.commons.lang3.StringUtils.isNotEmpty(openId)){
|
if (org.apache.commons.lang3.StringUtils.isNotEmpty(openId)) {
|
||||||
try {
|
try {
|
||||||
String urlToken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+ appId +"&corpsecret=" + appIdSecret;
|
String urlToken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + appId + "&corpsecret=" + appIdSecret;
|
||||||
System.out.println("urlToken: "+ urlToken);
|
System.out.println("urlToken: " + urlToken);
|
||||||
String res = HttpUtil.get(urlToken);
|
String res = HttpUtil.get(urlToken);
|
||||||
JSONObject jsonObjectToken = JSONObject.parseObject(res);
|
JSONObject jsonObjectToken = JSONObject.parseObject(res);
|
||||||
System.out.println("jsonObjectToken:{}"+ jsonObjectToken);
|
System.out.println("jsonObjectToken:{}" + jsonObjectToken);
|
||||||
String accessToken = jsonObjectToken.getString("access_token");
|
String accessToken = jsonObjectToken.getString("access_token");
|
||||||
System.out.println("accessToken:{}"+ accessToken);
|
System.out.println("accessToken:{}" + accessToken);
|
||||||
|
|
||||||
// 微信的基础accessToken
|
// 微信的基础accessToken
|
||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + accessToken;
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + accessToken;
|
||||||
|
@ -797,7 +798,7 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
|
||||||
|
|
||||||
// 1、xx老师,你好,您本学期(2023秋)听课要求为:5次,当前实际听课次数:3次,请尽快完成本学期的听课任务。
|
// 1、xx老师,你好,您本学期(2023秋)听课要求为:5次,当前实际听课次数:3次,请尽快完成本学期的听课任务。
|
||||||
String html = kcWechatSendLog.getYtkcs();
|
String html = kcWechatSendLog.getYtkcs();
|
||||||
html = html + "\n<a href=\""+domainTo+"\">查看</a>";
|
html = html + "\n<a href=\"" + domainTo + "\">查看</a>";
|
||||||
sendMag.put("content", html);//授课老师推送内容
|
sendMag.put("content", html);//授课老师推送内容
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
//拼接base参数
|
//拼接base参数
|
||||||
|
@ -805,17 +806,17 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
|
||||||
sendBody.put("touser", openId); // openId
|
sendBody.put("touser", openId); // openId
|
||||||
sendBody.put("msgtype", "text"); // 消息类型,此时固定为:text
|
sendBody.put("msgtype", "text"); // 消息类型,此时固定为:text
|
||||||
sendBody.put("agentid", agentid); // 企业id
|
sendBody.put("agentid", agentid); // 企业id
|
||||||
sendBody.put("text",sendMag); //发送内容
|
sendBody.put("text", sendMag); //发送内容
|
||||||
ResponseEntity<String> forEntity = restTemplate.postForEntity(url, sendBody, String.class);
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(url, sendBody, String.class);
|
||||||
JSONObject jsonObject2 = JSONObject.parseObject(forEntity.getBody());
|
JSONObject jsonObject2 = JSONObject.parseObject(forEntity.getBody());
|
||||||
System.out.println("jsonObject2 : " + jsonObject2);
|
System.out.println("jsonObject2 : " + jsonObject2);
|
||||||
String messageCode = jsonObject2.getString("errcode");
|
String messageCode = jsonObject2.getString("errcode");
|
||||||
String msgId = jsonObject2.getString("msgid");
|
String msgId = jsonObject2.getString("msgid");
|
||||||
System.out.println("messageCode : " + messageCode + ", msgId: " +msgId);
|
System.out.println("messageCode : " + messageCode + ", msgId: " + msgId);
|
||||||
}catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,14 +881,13 @@ public class ZyInfoController extends JeecgController<ZyInfo, IZyInfoService> {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
KcWechatSendLog kcWechatSendLog = new KcWechatSendLog();
|
KcWechatSendLog kcWechatSendLog = new KcWechatSendLog();
|
||||||
kcWechatSendLog.setOpenid("2016900057");//指定曹老师账号
|
// kcWechatSendLog.setOpenid("2016900057");//指定曹老师账号
|
||||||
// kcWechatSendLog.setOpenid(xxhbbks.getXh());
|
kcWechatSendLog.setOpenid(xxhbbks.getXh());
|
||||||
kcWechatSendLog.setYtkcs(zyDbtx.getContent());
|
kcWechatSendLog.setYtkcs(zyDbtx.getContent());
|
||||||
sendWxmessage(kcWechatSendLog);
|
sendWxmessage(kcWechatSendLog);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,36 @@
|
||||||
package org.jeecg.modules.kc.zyInfo.service.impl;
|
package org.jeecg.modules.kc.zyInfo.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.xkcoding.http.HttpUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.jeecg.modules.kc.grab.imports.entity.Xxhbbks;
|
||||||
|
import org.jeecg.modules.kc.grab.imports.service.IXxhbbksService;
|
||||||
|
import org.jeecg.modules.kc.kcWechatSendLog.entity.KcWechatSendLog;
|
||||||
|
import org.jeecg.modules.kc.ktgl.entity.KcKechengbiao;
|
||||||
|
import org.jeecg.modules.kc.ktgl.service.IKcKechengbiaoService;
|
||||||
|
import org.jeecg.modules.kc.zyDbtx.entity.ZyDbtx;
|
||||||
|
import org.jeecg.modules.kc.zyDbtx.service.IZyDbtxService;
|
||||||
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
|
import org.jeecg.modules.kc.zyInfo.entity.ZyInfo;
|
||||||
import org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys;
|
import org.jeecg.modules.kc.zyInfo.entity.ZyInfoSys;
|
||||||
import org.jeecg.modules.kc.zyInfo.mapper.ZyInfoMapper;
|
import org.jeecg.modules.kc.zyInfo.mapper.ZyInfoMapper;
|
||||||
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
|
import org.jeecg.modules.kc.zyInfo.service.IZyInfoService;
|
||||||
import org.jeecg.modules.tools.DateUtils;
|
import org.jeecg.modules.tools.DateUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 作业发布
|
* @Description: 作业发布
|
||||||
|
@ -24,6 +41,13 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> implements IZyInfoService {
|
public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> implements IZyInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IKcKechengbiaoService kcKechengbiaoService;
|
||||||
|
@Autowired
|
||||||
|
private IZyDbtxService zyDbtxService;
|
||||||
|
@Autowired
|
||||||
|
private IXxhbbksService xxhbbksService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<ZyInfo> stuList(Page<ZyInfo> page, QueryWrapper<ZyInfo> queryWrapper) {
|
public IPage<ZyInfo> stuList(Page<ZyInfo> page, QueryWrapper<ZyInfo> queryWrapper) {
|
||||||
return baseMapper.stuList(page, queryWrapper);
|
return baseMapper.stuList(page, queryWrapper);
|
||||||
|
@ -54,11 +78,133 @@ public class ZyInfoServiceImpl extends ServiceImpl<ZyInfoMapper, ZyInfo> impleme
|
||||||
QueryWrapper<ZyInfo> zyInfoQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ZyInfo> zyInfoQueryWrapper = new QueryWrapper<>();
|
||||||
zyInfoQueryWrapper.le("start_time", DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
zyInfoQueryWrapper.le("start_time", DateUtils.format(new Date(),"yyyy-MM-dd HH:mm:ss"));
|
||||||
zyInfoQueryWrapper.eq("zy_status","0");
|
zyInfoQueryWrapper.eq("zy_status","0");
|
||||||
List<ZyInfo> list = baseMapper.selectList(zyInfoQueryWrapper);
|
List<ZyInfo> list2 = baseMapper.selectList(zyInfoQueryWrapper);
|
||||||
for(ZyInfo par : list){
|
if(list2.size()>0){
|
||||||
par.setZyStatus("1");
|
|
||||||
baseMapper.updateById(par);
|
|
||||||
|
for(ZyInfo zyInfo : list2){
|
||||||
|
zyInfo.setZyStatus("1");
|
||||||
|
baseMapper.updateById(zyInfo);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
QueryWrapper<KcKechengbiao> kcKechengbiaoQueryWrapper = new QueryWrapper<>();
|
||||||
|
kcKechengbiaoQueryWrapper.eq("rwbh",zyInfo.getRwbh());
|
||||||
|
kcKechengbiaoQueryWrapper.eq("jgh",zyInfo.getCreateBy());
|
||||||
|
kcKechengbiaoQueryWrapper.eq("xqxn",zyInfo.getXnxq());
|
||||||
|
kcKechengbiaoQueryWrapper.last("limit 1");
|
||||||
|
KcKechengbiao kcKechengbiao = kcKechengbiaoService.getOne(kcKechengbiaoQueryWrapper);
|
||||||
|
|
||||||
|
QueryWrapper<ZyDbtx> zyDbtxQueryWrapper = new QueryWrapper<>();
|
||||||
|
zyDbtxQueryWrapper.eq("type",zyInfo.getZyLeixing());//发送作业
|
||||||
|
zyDbtxQueryWrapper.eq("rwbh",zyInfo.getRwbh());
|
||||||
|
List<ZyDbtx> dbtxlist = zyDbtxService.list(zyDbtxQueryWrapper);
|
||||||
|
String xharrs[] = new String[dbtxlist.size()];
|
||||||
|
for(int i=0;i<dbtxlist.size();i++){
|
||||||
|
xharrs[i] = dbtxlist.get(i).getCreateBy();
|
||||||
|
}
|
||||||
|
|
||||||
|
ZyInfo zyInfo2 = baseMapper.getKechengById(zyInfo.getId());
|
||||||
|
QueryWrapper<Xxhbbks> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.apply("a.xh = b.xh");
|
||||||
|
queryWrapper.eq("b.KCAPZBBH",zyInfo2.getRwbh());
|
||||||
|
if(xharrs.length>0){
|
||||||
|
queryWrapper.notIn("a.xh",xharrs);
|
||||||
|
}
|
||||||
|
List<Xxhbbks> list = xxhbbksService.getXsxkbAllList(queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(Xxhbbks xxhbbks:list) {
|
||||||
|
|
||||||
|
//作业代办提醒
|
||||||
|
ZyDbtx zyDbtx = new ZyDbtx();
|
||||||
|
zyDbtx.setCreateBy(xxhbbks.getXh());
|
||||||
|
zyDbtx.setMainId(zyInfo.getId());
|
||||||
|
zyDbtx.setRwbh(zyInfo.getRwbh());
|
||||||
|
String hpts = "";
|
||||||
|
if(StringUtils.equals(zyInfo.getXshpkg(),"1")){
|
||||||
|
hpts = "互评时间:"+ org.jeecg.common.util.DateUtils.formatDate(zyInfo.getXshpkssj(),"yyyy-MM-dd HH:mm")+" ~ "+ org.jeecg.common.util.DateUtils.formatDate(zyInfo.getXshpjssj(),"yyyy-MM-dd HH:mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(StringUtils.equals(zyInfo.getZyLeixing(),"0")) {
|
||||||
|
zyDbtx.setType("0");//0发布作业 1评分 2测验 3问卷 4讨论
|
||||||
|
zyDbtx.setContent(kcKechengbiao.getSkjs() + "老师主讲的[" + kcKechengbiao.getKcmc() + "]课程于" + org.jeecg.common.util.DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss") + "发布了一篇题目为“" + zyInfo.getTitle() + "”的作业,该作业提交时间为:" + org.jeecg.common.util.DateUtils.formatDate(zyInfo.getStartTime(), "yyyy-MM-dd HH:mm") + " ~ " + org.jeecg.common.util.DateUtils.formatDate(zyInfo.getEndTime(), "yyyy-MM-dd HH:mm") + ",请按时完成! " + hpts);
|
||||||
|
}else if (StringUtils.equals(zyInfo.getZyLeixing(),"1")){
|
||||||
|
zyDbtx.setType("10");//0发布作业 1评分 2测验 3问卷 4讨论
|
||||||
|
zyDbtx.setContent(kcKechengbiao.getSkjs() + "老师主讲的[" + kcKechengbiao.getKcmc() + "]课程于" + org.jeecg.common.util.DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss") + "发布了一篇题目为“" + zyInfo.getTitle() + "”的期末考试,该期末考试提交时间为:" + org.jeecg.common.util.DateUtils.formatDate(zyInfo.getStartTime(), "yyyy-MM-dd HH:mm") + " ~ " + org.jeecg.common.util.DateUtils.formatDate(zyInfo.getEndTime(), "yyyy-MM-dd HH:mm") + ",请按时完成! " + hpts);
|
||||||
|
}
|
||||||
|
zyDbtx.setFlag("0");
|
||||||
|
zyDbtx.setFbr(kcKechengbiao.getSkjs());
|
||||||
|
zyDbtxService.save(zyDbtx);
|
||||||
|
|
||||||
|
try {
|
||||||
|
KcWechatSendLog kcWechatSendLog = new KcWechatSendLog();
|
||||||
|
kcWechatSendLog.setOpenid(xxhbbks.getXh());
|
||||||
|
kcWechatSendLog.setYtkcs(zyDbtx.getContent());
|
||||||
|
sendWxmessage(kcWechatSendLog);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// appId
|
||||||
|
private static final String appId = "wx031697a8ca09a5ce";//东师
|
||||||
|
|
||||||
|
private static final String agentid = "1000065";//
|
||||||
|
// appIdSecret
|
||||||
|
private static final String appIdSecret = "6Qhnge3xfzAQMDX2TcjEyE0vUGP96hP9OTYUsYBze2Y";//东师
|
||||||
|
|
||||||
|
//微信通知点击后跳转的页面
|
||||||
|
private static final String domainTo = "https://zxkccx.webvpn.nenu.edu.cn";
|
||||||
|
|
||||||
|
public void sendWxmessage(KcWechatSendLog kcWechatSendLog) {
|
||||||
|
String openId = kcWechatSendLog.getOpenid();//曹老师账号
|
||||||
|
System.out.println("openId:" + openId + "");
|
||||||
|
if (org.apache.commons.lang3.StringUtils.isNotEmpty(openId)) {
|
||||||
|
try {
|
||||||
|
String urlToken = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=" + appId + "&corpsecret=" + appIdSecret;
|
||||||
|
System.out.println("urlToken: " + urlToken);
|
||||||
|
String res = HttpUtil.get(urlToken);
|
||||||
|
JSONObject jsonObjectToken = JSONObject.parseObject(res);
|
||||||
|
System.out.println("jsonObjectToken:{}" + jsonObjectToken);
|
||||||
|
String accessToken = jsonObjectToken.getString("access_token");
|
||||||
|
System.out.println("accessToken:{}" + accessToken);
|
||||||
|
|
||||||
|
// 微信的基础accessToken
|
||||||
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=" + accessToken;
|
||||||
|
Map<String, Object> sendMag = new HashMap<>();
|
||||||
|
|
||||||
|
// 1、xx老师,你好,您本学期(2023秋)听课要求为:5次,当前实际听课次数:3次,请尽快完成本学期的听课任务。
|
||||||
|
String html = kcWechatSendLog.getYtkcs();
|
||||||
|
html = html + "\n<a href=\"" + domainTo + "\">查看</a>";
|
||||||
|
sendMag.put("content", html);//授课老师推送内容
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
//拼接base参数
|
||||||
|
Map<String, Object> sendBody = new HashMap<>();
|
||||||
|
sendBody.put("touser", openId); // openId
|
||||||
|
sendBody.put("msgtype", "text"); // 消息类型,此时固定为:text
|
||||||
|
sendBody.put("agentid", agentid); // 企业id
|
||||||
|
sendBody.put("text", sendMag); //发送内容
|
||||||
|
ResponseEntity<String> forEntity = restTemplate.postForEntity(url, sendBody, String.class);
|
||||||
|
JSONObject jsonObject2 = JSONObject.parseObject(forEntity.getBody());
|
||||||
|
System.out.println("jsonObject2 : " + jsonObject2);
|
||||||
|
String messageCode = jsonObject2.getString("errcode");
|
||||||
|
String msgId = jsonObject2.getString("msgid");
|
||||||
|
System.out.println("messageCode : " + messageCode + ", msgId: " + msgId);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue