学生端课程实操列表

beetlsql3-dev
xuliangtong 2 years ago
parent cecad09037
commit 324e48cf64

@ -20,20 +20,26 @@ public class WxMpConfig {
@Value("${we_chat.aesKey}")
private String aesKey;
@Value("${we_chat.codeBackUrl}")
private String codeBackUrl;
public String getToken() {
return this.token;
return token;
}
public String getAppid() {
return this.appid;
return appid;
}
public String getAppSecret() {
return this.appSecret;
return appSecret;
}
public String getAesKey() {
return this.aesKey;
return aesKey;
}
public String getCodeBackUrl() {
return codeBackUrl;
}
}

@ -77,11 +77,13 @@ public class InterceptorConfig implements WebMvcConfigurer, InitializingBean {
registry.addResourceHandler("/filesystem/temp/**").addResourceLocations(p+"/filesystem/temp/");
registry.addResourceHandler("/filesystem/zip/**").addResourceLocations(p+"/filesystem/zip/");
registry.addResourceHandler("/images/**").addResourceLocations(p+"/filesystem/product/images/");
registry.addResourceHandler("/**/MP*.txt").addResourceLocations(p+"/filesystem/temp/");
}else {
registry.addResourceHandler("/filesystem/courseInfo/**").addResourceLocations("file:/"+p+"/filesystem/courseInfo/");
registry.addResourceHandler("/filesystem/temp/**").addResourceLocations("file:/"+p+"/filesystem/temp/");
registry.addResourceHandler("/filesystem/zip/**").addResourceLocations("file:/"+p+"/filesystem/zip/");
registry.addResourceHandler("/images/**").addResourceLocations("file:/"+p+"/filesystem/product/images/");
registry.addResourceHandler("/**/MP*.txt").addResourceLocations("file:/"+p+"/filesystem/temp/");
}
}

@ -1,13 +1,14 @@
package cn.jlw.webSocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* WebSocket
* @author zhengkai.blog.csdn.net
*/
//@Configuration
@Configuration
public class WebSocketConfig {
@Bean

@ -0,0 +1,48 @@
package com.ibeetl.jlw.entity.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
*
*
* @Version 0.0.1
* @Author
* @Date 2022/11/27 11:55
*/
@Data
public class StudentHandsOnVO {
/**
* id
*/
private Long handsOnId;
/**
* id
*/
private Long teacherOpenCourseId;
/**
*
*/
private String handsOnName;
/**
*
*/
private Integer handsOnTaskNum;
/**
*
*/
private BigDecimal studentScore;
/**
*
*/
private Integer schedule;
}

@ -1,8 +1,10 @@
package com.ibeetl.jlw.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.jlw.token.TokenService;
import cn.jlw.webSocket.WebSocketServer;
import com.ibeetl.admin.core.conf.CacheConfig;
import com.ibeetl.admin.core.conf.WxMpConfig;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.jlw.entity.CoreUserWx;
@ -18,6 +20,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
/**
@ -34,6 +37,8 @@ public class MsgHandler extends AbstractHandler {
private StudentService studentService;
@Autowired
private TokenService tokenService;
@Autowired
private WxMpConfig wxConfig;
@Override
@ -45,19 +50,20 @@ public class MsgHandler extends AbstractHandler {
String fromUser = wxMessage.getFromUser();
String userId = wxMessage.getEventKey();
if (StringUtils.isEmpty(userId)) {
return WxMpXmlOutMessage.TEXT().content("欢迎关注").toUser(fromUser)
return WxMpXmlOutMessage.TEXT().content("欢迎关注天泽教育").toUser(fromUser)
.fromUser(wxMessage.getToUser())
.build();
}
userId = userId.replace("qrscene_", "");
//登录
if (userId.contains("login")) {
//登录所包含userId为雪花算法ID
userId = userId.replace("login", "");
CoreUserWxQuery coreUserWxQuery = new CoreUserWxQuery();
coreUserWxQuery.setOpenid(fromUser);
coreUserWxQuery.setUserId(Long.parseLong(userId));
CoreUserWx info = coreUserWxService.getInfo(coreUserWxQuery);
if (info != null) {
Student student = studentService.getByUserId(info.getUserId());
List<CoreUserWx> info = coreUserWxService.getValuesByQueryNotWithPermission(coreUserWxQuery);
if (CollectionUtil.isNotEmpty(info)) {
Student student = studentService.getByUserId(info.get(0).getUserId());
String token = tokenService.getToken(student);
WebSocketServer.sendToUser("token="+token, userId);
return WxMpXmlOutMessage.TEXT().content("登录成功").toUser(fromUser)
@ -81,6 +87,8 @@ public class MsgHandler extends AbstractHandler {
}
coreUserWxQuery2.setOpenid(fromUser);
coreUserWxService.add(coreUserWxQuery2);
// String redirectURI = wxConfig.getCodeBackUrl();
// String s = weixinService.oauth2buildAuthorizationUrl(redirectURI, "snsapi_userinfo", "STATE");
return WxMpXmlOutMessage.TEXT().content("绑定成功").toUser(fromUser)
.fromUser(wxMessage.getToUser())
.build();

@ -1,15 +1,19 @@
package com.ibeetl.jlw.service;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.NumberUtil;
import cn.jlw.util.ToolUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
import com.ibeetl.jlw.dao.TeacherOpenCourseHandsOnDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.vo.StudentHandsOnVO;
import com.ibeetl.jlw.web.query.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
@ -22,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -44,6 +49,15 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService<TeacherOpen
@Autowired private TeacherOpenCourseHandsOnSimulationTasksService teacherOpenCourseHandsOnSimulationTasksService;
@Autowired private HandsOnSimulationTasksService handsOnSimulationTasksService;
@Autowired private HandsOnAchievementService handsOnAchievementService;
@Autowired private StudentService studentService;
@Autowired private StudentHandsOnTaskVideoService videoService;
@Autowired private StudentHandsOnTaskPptService pptService;
@Autowired private StudentHandsOnTaskStepService stepService;
@Autowired private StudentHandsOnTaskTheoryService theoryService;
@Autowired private StudentHandsOnTaskReportService reportService;
public PageQuery<TeacherOpenCourseHandsOn>queryByCondition(PageQuery query){
PageQuery ret = teacherOpenCourseHandsOnDao.queryByCondition(query);
@ -289,4 +303,107 @@ public class TeacherOpenCourseHandsOnService extends CoreBaseService<TeacherOpen
public void deleteTeacherOpenCourseAllRelatedByTeacherOpenCourseId(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId) {
log.info("需要实现删除操作!");
}
/**
*
* @param teacherOpenCourseId
* @param coreUser
* @return
*/
public JsonResult<List<StudentHandsOnVO>> getHandsListByOpenCourseIdAndStudent(Long teacherOpenCourseId, CoreUser coreUser) {
Long userId = coreUser.getId();
Student student = studentService.getByUserId(userId);
Long studentId = student == null ? 0 :student.getStudentId();
TeacherOpenCourseHandsOnQuery handsOnQuery = new TeacherOpenCourseHandsOnQuery();
handsOnQuery.setTeacherOpenCourseId(teacherOpenCourseId);
List<TeacherOpenCourseHandsOn> handsOnList = this.getValuesByQueryNotWithPermission(handsOnQuery);
List<TeacherOpenCourseHandsOnSimulationTasks> tasksList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(handsOnList)) {
List<Long> handIds = handsOnList.stream().map(TeacherOpenCourseHandsOn::getHandsOnId).collect(Collectors.toList());
TeacherOpenCourseHandsOnSimulationTasksQuery tasksQuery = new TeacherOpenCourseHandsOnSimulationTasksQuery();
tasksQuery.setHandsOnIdPlural(CollectionUtil.join(handIds, ","));
tasksList = teacherOpenCourseHandsOnSimulationTasksService.getValuesByQueryNotWithPermission(tasksQuery);
}
List<StudentHandsOnVO> studentHandsOnVOS = new ArrayList<>();
for (TeacherOpenCourseHandsOn handsOn : handsOnList) {
StudentHandsOnVO studentHandsOnVO = new StudentHandsOnVO();
Long handsOnId = handsOn.getHandsOnId();
studentHandsOnVO.setTeacherOpenCourseId(handsOn.getTeacherOpenCourseId());
List<TeacherOpenCourseHandsOnSimulationTasks> tasks = tasksList.stream().filter(v -> v.getHandsOnId().equals(handsOnId)).collect(Collectors.toList());
studentHandsOnVO.setHandsOnId(handsOnId);
studentHandsOnVO.setHandsOnName(handsOn.getHandsOnName());
studentHandsOnVO.setHandsOnTaskNum(tasks.size());
BigDecimal bigDecimal = BigDecimal.ZERO;
if (CollectionUtils.isNotEmpty(tasks)) {
BigDecimal decimal = BigDecimal.ZERO;
for (TeacherOpenCourseHandsOnSimulationTasks task : tasks) {
Long taskId = task.getTaskId();
if ("1".equals(task.getTaskType())) {
StudentHandsOnTaskVideoQuery videoQuery = new StudentHandsOnTaskVideoQuery();
videoQuery.setHandsOnTaskId(taskId);
videoQuery.setStudentId(studentId);
List<StudentHandsOnTaskVideo> videoList = videoService.getValuesByQueryNotWithPermission(videoQuery);
if (CollectionUtils.isNotEmpty(videoList)) {
StudentHandsOnTaskVideo studentHandsOnTaskVideo = videoList.get(0);
BigDecimal videoScore = studentHandsOnTaskVideo.getVideoScore();
bigDecimal = bigDecimal.add(videoScore);
decimal = bigDecimal.add(BigDecimal.ONE);
}
}else if("2".equals(task.getTaskType())) {
StudentHandsOnTaskPptQuery pptQuery = new StudentHandsOnTaskPptQuery();
pptQuery.setHandsOnTaskId(taskId);
pptQuery.setStudentId(studentId);
List<StudentHandsOnTaskPpt> pptList = pptService.getValuesByQueryNotWithPermission(pptQuery);
if (CollectionUtils.isNotEmpty(pptList)) {
StudentHandsOnTaskPpt studentHandsOnTaskPpt = pptList.get(0);
BigDecimal videoScore = studentHandsOnTaskPpt.getPptScore();
bigDecimal = bigDecimal.add(videoScore);
decimal = bigDecimal.add(BigDecimal.ONE);
}
}else if("3".equals(task.getTaskType())) {
StudentHandsOnTaskTheoryQuery theoryQuery = new StudentHandsOnTaskTheoryQuery();
theoryQuery.setHandsOnTaskId(taskId);
theoryQuery.setStudentId(studentId);
List<StudentHandsOnTaskTheory> taskTheoryList = theoryService.getValuesByQueryNotWithPermission(theoryQuery);
if (CollectionUtils.isNotEmpty(taskTheoryList)) {
StudentHandsOnTaskTheory taskTheory = taskTheoryList.get(0);
BigDecimal videoScore = taskTheory.getTheoryScore();
bigDecimal = bigDecimal.add(videoScore);
decimal = bigDecimal.add(BigDecimal.ONE);
}
}else if("4".equals(task.getTaskType())) {
StudentHandsOnTaskStepQuery stepQuery = new StudentHandsOnTaskStepQuery();
stepQuery.setHandsOnTaskId(taskId);
stepQuery.setStudentId(studentId);
List<StudentHandsOnTaskStep> stepList = stepService.getValuesByQueryNotWithPermission(stepQuery);
if (CollectionUtils.isNotEmpty(stepList)) {
StudentHandsOnTaskStep taskTheory = stepList.get(0);
BigDecimal videoScore = taskTheory.getTheoryScore();
bigDecimal = bigDecimal.add(videoScore);
decimal = bigDecimal.add(BigDecimal.ONE);
}
}else if("5".equals(task.getTaskType())) {
StudentHandsOnTaskReportQuery reportQuery = new StudentHandsOnTaskReportQuery();
reportQuery.setHandsOnTaskId(taskId);
reportQuery.setStudentId(studentId);
List<StudentHandsOnTaskReport> reportList =reportService.getValuesByQueryNotWithPermission(reportQuery);
if (CollectionUtils.isNotEmpty(reportList)) {
StudentHandsOnTaskReport taskTheory = reportList.get(0);
BigDecimal videoScore = taskTheory.getReportScore();
bigDecimal = bigDecimal.add(videoScore);
decimal = bigDecimal.add(BigDecimal.ONE);
}
}
}
int schedule = NumberUtil.div(decimal, BigDecimal.valueOf(tasksList.size()),2).multiply(BigDecimal.valueOf(100)).intValue();
studentHandsOnVO.setSchedule(schedule);
}else {
studentHandsOnVO.setSchedule(0);
}
studentHandsOnVO.setStudentScore(bigDecimal);
studentHandsOnVOS.add(studentHandsOnVO);
}
return JsonResult.success(studentHandsOnVOS);
}
}

@ -11,6 +11,7 @@ import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.jlw.entity.TaskTypeParam;
import com.ibeetl.jlw.entity.TeacherOpenCourseHandsOn;
import com.ibeetl.jlw.entity.TeacherOpenCourseHandsOnList;
import com.ibeetl.jlw.entity.vo.StudentHandsOnVO;
import com.ibeetl.jlw.service.TeacherOpenCourseHandsOnService;
import com.ibeetl.jlw.web.query.GetHandsOnListParam;
import com.ibeetl.jlw.web.query.TeacherOpenCourseHandsOnQuery;
@ -533,4 +534,15 @@ public class TeacherOpenCourseHandsOnController{
}
}
/**
*
* @param teacherOpenCourseId id
* @return
*/
@GetMapping(API + "/getHandsListByOpenCourseIdAndStudent.do")
public JsonResult<List<StudentHandsOnVO>> getHandsListByOpenCourseIdAndStudent(Long teacherOpenCourseId, @SCoreUser CoreUser coreUser) {
return teacherOpenCourseHandsOnService.getHandsListByOpenCourseIdAndStudent(teacherOpenCourseId, coreUser);
}
}

@ -1,25 +1,45 @@
package com.ibeetl.jlw.web;
import cn.hutool.core.util.IdUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.jlw.Interceptor.SCoreUser;
import cn.jlw.token.TokenService;
import cn.jlw.webSocket.WebSocketServer;
import com.github.binarywang.utils.qrcode.MatrixToImageWriter;
import com.ibeetl.admin.core.conf.WxMpConfig;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.jlw.entity.CoreUserWx;
import com.ibeetl.jlw.entity.Student;
import com.ibeetl.jlw.service.CoreUserWxService;
import com.ibeetl.jlw.service.StudentService;
import com.ibeetl.jlw.service.WeixinService;
import com.ibeetl.jlw.web.query.CoreUserWxQuery;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpMessageRouter;
import me.chanjar.weixin.mp.api.WxMpQrcodeService;
import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
import me.chanjar.weixin.mp.bean.message.WxMpXmlOutMessage;
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
import me.chanjar.weixin.mp.bean.result.WxMpUser;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
*
* @Version 0.0.1
* @Author
@ -30,10 +50,21 @@ import java.util.Map;
@Slf4j
public class WeiXinController {
@Autowired
private WeixinService weixinService;
@Autowired
private WxMpConfig wxMpConfig;
@Autowired
private WeixinService weixinService;
private CoreUserWxService coreUserWxService;
@Autowired
private StudentService studentService;
@Autowired
private TokenService tokenService;
//region 公众号
@GetMapping(produces = "text/plain;charset=utf-8")
public String authGet(
@ -85,7 +116,7 @@ public class WeiXinController {
@GetMapping("/api/getQrCode")
public JsonResult<?> getQrCode(@SCoreUser CoreUser coreUser) throws WxErrorException {
WxMpQrcodeService qrcodeService = weixinService.getQrcodeService();
WxMpQrCodeTicket wxMpQrCodeTicket = qrcodeService.qrCodeCreateTmpTicket(coreUser.getId().toString(), 2592000);
WxMpQrCodeTicket wxMpQrCodeTicket = qrcodeService.qrCodeCreateTmpTicket(coreUser.getId() + "", 2592000);
String imgUrl = qrcodeService.qrCodePictureUrl(wxMpQrCodeTicket.getTicket());
Map<String, Object> map = new HashMap<>();
map.put("imgUrl", imgUrl);
@ -144,5 +175,57 @@ public class WeiXinController {
log.debug("\n组装回复信息"+out);
return out;
}
//endregion 公众号
//region 网页授权
@GetMapping("/getQrCode")
public void getQrCode(HttpServletResponse response) throws IOException {
response.setHeader("Content-Type","application/octet-stream");
response.setHeader("Content-Disposition", "attachment;filename=" + "二维码.png");
String redirectURI = wxMpConfig.getCodeBackUrl();
String snowflakeNextIdStr = IdUtil.getSnowflakeNextIdStr();
String s = weixinService.oauth2buildAuthorizationUrl(redirectURI, "snsapi_userinfo", snowflakeNextIdStr);
OutputStream outputStream = response.getOutputStream();
QrCodeUtil.generate(s, 80, 80, "png", outputStream);
}
/**
*
* @param code
* @param state
* @return
* @throws URIException
*/
@GetMapping("/getCode")
public String getCode(@RequestParam("code") String code, @RequestParam("state") String state) throws URIException {
try {
WxMpOAuth2AccessToken accessToken = weixinService.oauth2getAccessToken(code);
WxMpUser wxMpUser = weixinService.oauth2getUserInfo(accessToken, null);
CoreUserWx coreUserWx = new CoreUserWx();
String openId = wxMpUser.getOpenId();
coreUserWx.setOpenid(openId);
coreUserWx.setNickname(wxMpUser.getNickname());
coreUserWx.setSex(wxMpUser.getSex());
coreUserWx.setPrivilege(wxMpUser.getProvince());
coreUserWx.setCity(wxMpUser.getCity());
coreUserWx.setCountry(wxMpUser.getCountry());
coreUserWx.setHeadimgurl(wxMpUser.getHeadImgUrl());
coreUserWx.setPrivilege(Arrays.toString(wxMpUser.getPrivileges()));
coreUserWx.setUnionid(wxMpUser.getUnionId());
coreUserWxService.update(coreUserWx);
CoreUserWxQuery coreUserWxQuery = new CoreUserWxQuery();
coreUserWxQuery.setOpenid(openId);
List<CoreUserWx> info = coreUserWxService.getValuesByQueryNotWithPermission(coreUserWxQuery);
Student student = studentService.getByUserId(info.get(0).getUserId());
String token = tokenService.getToken(student);
WebSocketServer.sendToUser("token="+token, state);
} catch (WxErrorException e) {
return e.getMessage();
}
return "登录成功";
}
//endregion 网页授权
}

@ -96,8 +96,9 @@ contract_url=
we_chat.appId=wx511d1fc5f859c040
we_chat.appSecret=ef17c7734c3d82451bb3d6a8ebb5341e
we_chat.token=weixin
we_chat.aesKey=
we_chat.aesKey=rHcC0bFnAGmDHow9N4XpIxFWeRVgi3EJ4vP3rMJe92E
we_chat.baseUrl=http://localhost:9090/server
we_chat.codeBackUrl=http://rednoob.free.idcfengye.com/server/wx/getCode
#we_chat.appId=wxd09c1cac6a02cab8
#we_chat.appSecret=96e19a99cb89bd98cea050e4b30cb9f4

Loading…
Cancel
Save