diff --git a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java index 52a1685..996f62f 100644 --- a/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java +++ b/blockchain-common/blockchain-common-base/src/main/java/com/blockchain/common/base/dto/YyyfUserDto.java @@ -15,7 +15,7 @@ import java.io.Serializable; public class YyyfUserDto implements Serializable { private static final long serialVersionUID = -6752296227958588252L; /**传过来的用户id*/ - private String id; + private Integer id; /**用户名称*/ private String name; /**用户类型:0学生,1老师,2管理员*/ diff --git a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml index d983557..ef11b67 100644 --- a/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml +++ b/blockchain-server/blockchain-server-user/src/main/resources/bootstrap.yml @@ -13,6 +13,7 @@ spring: cloud: #配置中心 config: + uri: http://10.10.17.84:8002 discovery: service-id: dapp-config-server enabled: true diff --git a/blockchain-server/blockchain-server-yyyf/pom.xml b/blockchain-server/blockchain-server-yyyf/pom.xml index b3f206c..0753e77 100644 --- a/blockchain-server/blockchain-server-yyyf/pom.xml +++ b/blockchain-server/blockchain-server-yyyf/pom.xml @@ -47,6 +47,28 @@ gexin-rp-sdk-http 4.1.0.3 + + + org.springframework.cloud + spring-cloud-commons + + + + org.apache.poi + poi + 3.10-FINAL + + + org.apache.poi + poi-ooxml + 3.10-FINAL + + + org.apache.poi + poi-ooxml-schemas + 3.10-FINAL + + diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java index 66f2545..e4c963f 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/LoginController.java @@ -7,6 +7,7 @@ import com.blockchain.common.base.dto.YyyfUserDto; import com.blockchain.common.base.util.RSACoderUtils; import com.blockchain.server.yyyf.controller.api.LoginApi; import com.blockchain.server.yyyf.dto.*; +import com.blockchain.server.yyyf.service.AssessUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; @@ -17,7 +18,6 @@ import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import sun.misc.BASE64Decoder; @@ -39,6 +39,8 @@ public class LoginController { private static final Logger LOG = LoggerFactory.getLogger(LoginController.class); + @Autowired + private AssessUserService assessUserService; @Autowired private RedisTemplate redisTemplate; @@ -46,7 +48,7 @@ public class LoginController { @PostMapping("/login") @ApiOperation(value = LoginApi.YyyfLogin.METHOD_NAME, notes = LoginApi.YyyfLogin.METHOD_NOTE) - public ResultDTO loginyyyf(@ApiParam(LoginApi.YyyfLogin.METHOD_API_YYYFLOGINREQUESTVO) @Valid @RequestBody YyyfLoginRequestVo yyyfLoginRequestVo) { + public ResultDTO loginyyyf(@ApiParam(LoginApi.YyyfLogin.METHOD_API_YYYFLOGINREQUESTVO) @Valid YyyfLoginRequestVo yyyfLoginRequestVo) { //存到redis中用于以渔有方用户与智信链用户进行绑定 YyyfUserDto yyyfUserDto=new YyyfUserDto(); @@ -63,7 +65,7 @@ public class LoginController { int reqType = yyyfLoginRequestVo.getReqType().intValue(); int userType = yyyfLoginRequestVo.getUserType().intValue(); Integer classId =yyyfLoginRequestVo.getClassId(); - String userId = yyyfLoginRequestVo.getUserId(); + Integer userId = yyyfLoginRequestVo.getUserId(); Integer schoolId = yyyfLoginRequestVo.getSchoolId(); yyyfUserDto.setClassId(classId); @@ -81,9 +83,9 @@ public class LoginController { HashOperations examDtoOpsForHash = redisTemplate.opsForHash(); //将参加考试的人员缓存 - HashOperations> studentOpsForHash = redisTemplate.opsForHash(); + HashOperations> studentOpsForHash = redisTemplate.opsForHash(); //参加考试的人员id - List joinStuIds =null; + List joinStuIds =null; //考试id和案列id缓存 String caseKey = YyyfConstant.CASE_KEY + userId; @@ -91,7 +93,7 @@ public class LoginController { //判断考试缓存中是否存在这张卷子 if (0 == reqType) { //如果他提交了,库里有信息了,不允许他再次进入了。 - if (/**this.assessUserService.getAssessUserByIssueIdAndUserIdForExam(examId, userId) != null*/1==1) { + if (this.assessUserService.selectScore(examId, userId) != null) { yyyfLoginDto.setStatus(2); yyyfLoginDto.setMsg(YyyfConstant.SUBMITTED); return handleAfterLogin(yyyfLoginDto,yyyfUserDto); @@ -110,7 +112,7 @@ public class LoginController { joinStuIds=studentOpsForHash.get(YyyfConstant.JOIN_EXAM_STU_IDS_KEY, examId); if (joinStuIds == null) { - joinStuIds = new ArrayList(); + joinStuIds = new ArrayList(); } //如果等于0 if (joinStuIds.stream() @@ -209,7 +211,7 @@ public class LoginController { */ private ResultDTO handleAfterLogin(YyyfLoginDto yyyfLoginDto, YyyfUserDto yyyfUserDto) { int status = yyyfLoginDto.getStatus(); - String token = generateToken(yyyfUserDto.getId(), System.currentTimeMillis(), YyyfConstant.YYYF_ZHIXINLIAN_USER_KEY); + String token = generateToken(String.valueOf(yyyfUserDto.getId()), System.currentTimeMillis(), YyyfConstant.YYYF_ZHIXINLIAN_USER_KEY); yyyfLoginDto.setYyyfUserToken(token); if(status==1){ //到时看要不要设定时长 diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java new file mode 100644 index 0000000..6a14574 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/controller/TeachingGradeController.java @@ -0,0 +1,619 @@ +package com.blockchain.server.yyyf.controller; + +import com.alibaba.fastjson.JSONObject; +import com.blockchain.server.yyyf.dto.PractiseProDto; +import com.blockchain.server.yyyf.dto.PractiseTaskDto; +import com.blockchain.server.yyyf.entity.AssessUser; +import com.blockchain.server.yyyf.service.AssessUserService; +import com.blockchain.server.yyyf.service.AssessUserTaskService; +import com.blockchain.server.yyyf.utils.MSExcelUtil; +import com.blockchain.server.yyyf.utils.ResponseUtils; + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.util.CellRangeAddress; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import sun.misc.BASE64Decoder; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @author huan.xu + * @version 1.0 + * @className TeachingGradeController + * @description 练习、考核成绩Controller + * @date 2019-11-05 16:23 + */ +@Controller +@RequestMapping("/teachingGrade") +public class TeachingGradeController { + protected Logger logger = LoggerFactory.getLogger(TeachingGradeController.class); + + private static final String SYS_CODE = "102"; + + @Autowired + private AssessUserService assessUserService; + @Autowired + private AssessUserTaskService assessUserTaskService; + // @Autowired + // private ScoreSynchroService scoreSynchroService; + + + /** + * http://10.10.17.93:8080/BankTrain/teachingGrade/getGradeData?issueId=7e027a96764b4749b2a2d65cdc4a5c92&totalNum=10&caseId=38 + * + * @param [request, response] + * @return void + * @description 教师端获取错误率 (issueId:考核id【即reqId】;totalNum:班级总人数;caseId:项目id) + * @author huan.xu + * @date 2019-11-08 18:03:39 + **/ + @RequestMapping(value = "/getGradeData"/*,produces = {"application/text;charset=UTF-8"}*/) + @ResponseBody + @SuppressWarnings("all") + public void getGradeData(HttpServletRequest request, HttpServletResponse response) { + + String issueId = request.getParameter("issueId"); + String totalNumStr = request.getParameter("totalNum"); + String projectId = request.getParameter("caseId");//项目id + Integer totalNum = Integer.valueOf(totalNumStr); + + JSONObject json = new JSONObject(); + try {/* + //根据考核id 查询所有的有成绩的学生考核概览信息 + List assessUserList = this.assessUserService.selectAssessUserListByIssueId(issueId); + Map wrongStatistics = null;//错误信息 + //无人考试 时封装错误率 + if (assessUserList == null || (assessUserList != null && assessUserList.size() == 0)) { + + //String projectName = JedisUtil.getMapValue(JedisUtil.bulidKey(Const.TIFPRO_KEY), projectId, TifPro.class).getProjectName(); + //获取所有交易关联信息 + List tiftrnDtoList = JedisUtil.getMapValueForList(JedisUtil.bulidKey(Const.TIFTRN_KEY), projectId, TiftrnDto.class); + + wrongStatistics = new HashMap<>(); + + Map maxErrorRateInfo = new HashMap<>();//最大错误率信息记录 + Map minErrorRateInfo = new HashMap<>();//最小错误率信息记录 + List taskNames = new ArrayList<>(); + List errorRates = new ArrayList<>(); + for (TiftrnDto tifDtotrn : tiftrnDtoList) { + List testPoints = tifDtotrn.getTestPoints(); + if (testPoints != null && testPoints.size() != 0) { + for (TestPointDto testPointDto : testPoints) { + taskNames.add(testPointDto.getPointName()); + errorRates.add(Double.valueOf(100)); + if (maxErrorRateInfo.size() == 0) { + maxErrorRateInfo.put("headCount", totalNum); + maxErrorRateInfo.put("taskName", testPointDto.getPointName()); + maxErrorRateInfo.put("errorRate", Double.valueOf(100)); + maxErrorRateInfo.put("projectName", tifDtotrn.getTrxName()); + maxErrorRateInfo.put("errorCount", totalNum); + continue; + } + if (minErrorRateInfo.size() == 0) { + minErrorRateInfo.put("headCount", totalNum); + minErrorRateInfo.put("taskName", testPointDto.getPointName()); + minErrorRateInfo.put("errorRate", Double.valueOf(100)); + minErrorRateInfo.put("projectName", tifDtotrn.getTrxName()); + minErrorRateInfo.put("errorCount", totalNum); + continue; + } + } + + } else { + taskNames.add(tifDtotrn.getTrxName()); + errorRates.add(Double.valueOf(100)); + if (maxErrorRateInfo.size() == 0) { + maxErrorRateInfo.put("headCount", totalNum); + maxErrorRateInfo.put("taskName", tifDtotrn.getTrxName()); + maxErrorRateInfo.put("errorRate", Double.valueOf(100)); + maxErrorRateInfo.put("projectName", tifDtotrn.getTrxName()); + maxErrorRateInfo.put("errorCount", totalNum); + continue; + } + if (minErrorRateInfo.size() == 0) { + minErrorRateInfo.put("headCount", totalNum); + minErrorRateInfo.put("taskName", tifDtotrn.getTrxName()); + minErrorRateInfo.put("errorRate", Double.valueOf(100)); + minErrorRateInfo.put("projectName", tifDtotrn.getTrxName()); + minErrorRateInfo.put("errorCount", totalNum); + continue; + } + } + } + wrongStatistics.put("maxErrorRateInfo", maxErrorRateInfo); + wrongStatistics.put("minErrorRateInfo", minErrorRateInfo); + wrongStatistics.put("taskNames", taskNames); + wrongStatistics.put("errorRates", errorRates); + + } else { + wrongStatistics = getWrongStatistics(issueId, totalNum - assessUserList.size()); + } + + + json.put("result", true); + json.put("wrongStatistics", wrongStatistics);*/ + } catch (Exception e) { + json.put("result", false); + json.put("msg", "获取成绩报表数据失败"); + logger.error("获取成绩报表数据失败: " + e.getMessage(), e); + } + + ResponseUtils.renderJson(response, json.toString()); + } + + /** + * @param [issueId, notExamNum] + * @return java.util.Map + * @description 封装错误率 + * @author huan.xu + * @date 2019-11-08 18:27:22 + **/ + public Map getWrongStatistics(String issueId, Integer notExamNum) { + Map wrongStatistics = new HashMap(); + //根据考核发布id,获取考核点信息 + List> taskListDb = assessUserTaskService.selectYHTaskInfoByIssueId(issueId); + List> taskList = new ArrayList<>(); + String appTaskIdStrs = ","; + + //key 考核点id(无考核点则是交易的id),value为答题情况集合 + Map>> userTasksMap = new HashMap<>(); + + for (Map map : taskListDb) { + String appTaskId = (String) map.get("appTaskId"); + List> mapList = userTasksMap.get(appTaskId); + if (mapList == null) { + mapList = new ArrayList<>(); + } + mapList.add(map); + userTasksMap.put(appTaskId, mapList); + String s = appTaskId + ","; + if (!appTaskIdStrs.contains("," + s)) { + taskList.add(map); + appTaskIdStrs += s; + } + } + + + Map maxErrorRateInfo = null;//最大错误率信息记录 + Map minErrorRateInfo = null;//最小错误率信息记录 + //记录考核点名称 + String[] taskNames = new String[taskList.size()]; + //记录错误率 + double[] errorRates = new double[taskList.size()]; + for (int i = 0; i < taskList.size(); i++) { + Map task = taskList.get(i); + taskNames[i] = task.get("taskName").toString(); + /*Map con = new HashMap(); + con.put("issueId", issueId); + con.put("classId", classId); + con.put("appTaskId", task.get("appTaskId"));*/ + //获取该考核点用户的答题情况 + List> userTasks = new ArrayList>(); + userTasks = userTasksMap.get(task.get("appTaskId")); + int errorCount = notExamNum;//错误人数 + for (Map userTask : userTasks) { + //答题错误记录人数 + if (Integer.valueOf(userTask.get("answer").toString()) == 1) { + errorCount++; + } + } + int totalNum = userTasks.size() + notExamNum; + double errorRate = (double) (errorCount) / (double) (totalNum) * 100;//计算错误率 + errorRate = Double.valueOf(String.format("%.2f", errorRate));//四舍五入保留两位小数 + errorRates[i] = errorRate; + //处理最大和最小错误率信息 + if (maxErrorRateInfo == null) { + maxErrorRateInfo = new HashMap(); + maxErrorRateInfo.put("projectName", task.get("projectName").toString()); + maxErrorRateInfo.put("taskName", task.get("taskName").toString()); + maxErrorRateInfo.put("headCount", totalNum); + maxErrorRateInfo.put("errorCount", errorCount); + maxErrorRateInfo.put("errorRate", errorRate); + } else { + //上一次最大错误率 + double prevMaxErrorRate = Double.valueOf(maxErrorRateInfo.get("errorRate").toString()); + if (errorRate > prevMaxErrorRate) { + //本次错误率大于上次,则记录本次信息 + maxErrorRateInfo.put("projectName", task.get("projectName").toString()); + maxErrorRateInfo.put("taskName", task.get("taskName").toString()); + maxErrorRateInfo.put("headCount", totalNum); + maxErrorRateInfo.put("errorCount", errorCount); + maxErrorRateInfo.put("errorRate", errorRate); + } + } + if (minErrorRateInfo == null) { + minErrorRateInfo = new HashMap(); + minErrorRateInfo.put("projectName", task.get("projectName").toString()); + minErrorRateInfo.put("taskName", task.get("taskName").toString()); + minErrorRateInfo.put("headCount", totalNum); + minErrorRateInfo.put("errorCount", errorCount); + minErrorRateInfo.put("errorRate", errorRate); + } else { + //上一次最小错误率 + double prevMinErrorRate = Double.valueOf(minErrorRateInfo.get("errorRate").toString()); + if (prevMinErrorRate > errorRate) { + //本次错误率小于上次最小错误率,则记录本次信息 + minErrorRateInfo.put("projectName", task.get("projectName").toString()); + minErrorRateInfo.put("taskName", task.get("taskName").toString()); + minErrorRateInfo.put("headCount", totalNum); + minErrorRateInfo.put("errorCount", errorCount); + minErrorRateInfo.put("errorRate", errorRate); + } + } + } + wrongStatistics.put("maxErrorRateInfo", maxErrorRateInfo); + wrongStatistics.put("minErrorRateInfo", minErrorRateInfo); + wrongStatistics.put("taskNames", taskNames); + wrongStatistics.put("errorRates", errorRates); + return wrongStatistics; + } + + /** + * @param [reqType, issueId, userId, stuNo, userName, className, caseId, model] + * @return java.lang.String + * @description 获取考核详情 + * @author huan.xu + * @date 2019-11-08 18:27:50 + **/ + + @RequestMapping("/studyGrade/mygrade") + public String selectPractiseProList(String reqType, String issueId, String examName, Integer userId, String stuNo, String userName, String className, String caseId, Model model) { + try {/* + AssessUser assessUser = null; + List assessUserIds = new ArrayList(); + model.addAttribute("assessUserIds", assessUserIds); + model.addAttribute("reqType", reqType); + model.addAttribute("caseId", caseId); + if ("1".equals(reqType)) { //考核 + assessUser = this.assessUserService.selectScore(SYS_CODE, issueId, userId); + } else {//练习 + List assessUserList = this.assessUserService.selectAssessUserListByIssuerIdAndUserId(issueId, userId); + for (AssessUser assessUserInner : assessUserList) { + if (assessUser == null) { + //取第一个,最新的 + assessUser = assessUserInner; + } + assessUserIds.add(assessUserInner.getId()); + } + } + if (assessUser != null) { //不为空,说明其做过 + cratePractiseProDtosForNotNull(assessUser, model); + } else { //为空,则生成一个,这个可不要,因为考核无答题的话,不会进入详情的页面 + List practiseProDtos = new ArrayList(); + //交易码 + List tiftrnDtoList = JedisUtil.getMapValueForList(JedisUtil.bulidKey(Const.TIFTRN_KEY), caseId, TiftrnDto.class); //获取所有交易关联信息 + for (TiftrnDto tiftrnDto : tiftrnDtoList) { + PractiseProDto practiseProDto = new PractiseProDto(); + practiseProDto.setId(tiftrnDto.getTrxCode()); + practiseProDto.setProjectCaseDesc(String.valueOf(tiftrnDto.getSerNum())); + practiseProDto.setProjectScore(BigDecimal.ZERO); + practiseProDto.setProName(tiftrnDto.getTrxName()); + List testPoints = tiftrnDto.getTestPoints(); + if (testPoints != null && testPoints.size() > 0) { + List taskList = new ArrayList(); + for (TestPointDto testPointDto : testPoints) { + PractiseTaskDto practiseTaskDto = new PractiseTaskDto(); + practiseTaskDto.setId(String.valueOf(testPointDto.getPointId())); + practiseTaskDto.setAnswer(1); + practiseTaskDto.setProjectName(tiftrnDto.getTrxName()); + practiseTaskDto.setRightAnswer(testPointDto.getTestPointAnswer()); + practiseTaskDto.setStuAnswer("-"); + practiseTaskDto.setTaskName(testPointDto.getPointName()); + practiseTaskDto.setTaskScore(BigDecimal.valueOf(testPointDto.getTestPointScore())); + taskList.add(practiseTaskDto); + } + practiseProDto.setTaskList(taskList); + } + practiseProDtos.add(practiseProDto); + } + model.addAttribute("examDate", "-"); + model.addAttribute("useTime", "00:00:00"); + model.addAttribute("totalScore", BigDecimal.ZERO); + model.addAttribute("practiseProDtos", practiseProDtos); + } + + model.addAttribute("stuNo", stuNo); + model.addAttribute("userName", new String(new BASE64Decoder().decodeBuffer(userName.replaceAll(" ", "+")), "UTF-8")); + model.addAttribute("className", new String(new BASE64Decoder().decodeBuffer(className.replaceAll(" ", "+")), "UTF-8")); + model.addAttribute("examName", new String(new BASE64Decoder().decodeBuffer(examName.replaceAll(" ", "+")), "UTF-8")); + model.addAttribute("caseInfo", JedisUtil.getMapValue(JedisUtil.bulidKey(Const.TIFPRO_KEY), caseId, TifPro.class).getCaseInfo()); + */} catch (Exception e) { + logger.error("获取成绩失败: " + e.getMessage(), e); + } + return "/yyyf/exam_mesaage"; + } + + /** + * @param [assessUserId, model] + * @return java.lang.String + * @description 练习用于上一次、下一次的页面切换 + * @author huan.xu + * @date 2019-11-08 18:46:05 + **/ + @RequestMapping("/studyGrade/examMesaageDetails") + public String examMesaageDetails(String assessUserId, Model model) { + AssessUser assessUser = this.assessUserService.selectAssessUserById(assessUserId.trim()); + cratePractiseProDtosForNotNull(assessUser, model); + return "/yyyf/exam_mesaage_details"; + } + + + /** + * @param [assessUser, model] + * @return void + * @description 封装有成绩的答题详情 + * @author huan.xu + * @date 2019-11-08 18:38:41 + **/ + public void cratePractiseProDtosForNotNull(AssessUser assessUser, Model model) { + List practiseProDtos = this.assessUserService.selectPractiseProList(assessUser.getId()); + double duration = assessUser.getEndTime().getTime() - assessUser.getStartTime().getTime(); + String h = String.format("%02d", (int) Math.floor(duration / 1000 / 60 / 60)); + String m = String.format("%02d", (int) Math.floor(duration / 1000 / 60 % 60)); + String s = String.format("%02d", (int) Math.floor(duration / 1000 % 60)); + model.addAttribute("useTime", h + ":" + m + ":" + s); + model.addAttribute("totalScore", assessUser.getTotalScore()); + model.addAttribute("examDate", new SimpleDateFormat("yyyy/MM/dd").format(assessUser.getStartTime())); + model.addAttribute("practiseProDtos", practiseProDtos); + model.addAttribute("assessUserId", assessUser.getId()); + } + + + /** + * @param [issueId, authorization] + * @return java.util.Map + * @description 重新成绩同步 + * @author huan.xu + * @date 2019-11-08 18:39:55 + **/ + @RequestMapping("/studyGrade/reSynchroze") + @ResponseBody + @SuppressWarnings("all") + public Map reSynchroze(String issueId, String authorization) { + Map result = new HashMap<>(); + /* result.put("status", 0); + result.put("msg", "系统错误"); + try { + if ("87DIVy348Oxzj3ha".equals(authorization)) { + + result = this.scoreSynchroService.synchrozeScoreList(issueId); + + } else { + result.put("msg", "验证错误"); + } + } catch (Exception e) { + result.put("msg", "同步失败,请进行后台检查"); + logger.error(e.getMessage(), e); + }*/ + return result; + } + + + @RequestMapping("/export") + @ResponseBody + public void yhExport(HttpServletRequest request, HttpServletResponse response) {/* + String examName = request.getParameter("examName"); + String className = request.getParameter("className"); + String stuNo = request.getParameter("stuNo"); + String totalScore = request.getParameter("totalScore"); + String useTime = request.getParameter("useTime"); + String examDate = request.getParameter("examDate"); + String assessUserId = request.getParameter("assessUserId"); + String userName = request.getParameter("userName"); + String caseInfo = request.getParameter("caseInfo"); + String caseId = request.getParameter("caseId"); + // TifPro tifPro = JedisUtil.getMapValue(JedisUtil.bulidKey(Const.TIFPRO_KEY), caseId, TifPro.class); + + //设置导出文件名称 + String fileName = ((new SimpleDateFormat("yyyyMMdd")).format(new Date()))+"-"+userName+ "-考核详情.xls"; + response.setContentType("application/x-download");//不同类型的文件对应不同的MIME类型 + try { + if (request.getHeader("USER-AGENT").toLowerCase().indexOf("firefox") > 0) { + fileName = new String(fileName.getBytes("GB2312"), "ISO-8859-1"); + } else { + fileName = URLEncoder.encode(fileName, "UTF-8"); + } + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + response.setHeader("Content-Disposition", "attachment; filename=" + fileName); + HSSFWorkbook wb = new HSSFWorkbook(); + HSSFSheet sheet = wb.createSheet("成绩详情"); //创建table工作薄 + Object[][] datas = { + {"学生姓名:" + userName, + "班级:" + className, + "学号:" + stuNo, + "成绩:" + totalScore+" 分", + "日期:" + examDate, "用时:" + useTime}, + {"考核名称:" + examName,"","","","",""}, + {"项目名称:" + tifPro.getProjectName(),"","","","",""}, + {"项目背景:" + caseInfo,"","","","",""}, + {"成绩解析:","","","","",""}}; + + List cellDate = new ArrayList(); + for (Object[] data : datas) { + cellDate.add(data); + } + + List practiseProDtos = this.assessUserService.selectPractiseProList(assessUserId); + + //合并单元格参数 + List regionList = new ArrayList(); + regionList.add(new int[]{1, 1, 0, 5}); + regionList.add(new int[]{2, 2, 0, 5}); + regionList.add(new int[]{3, 3, 0, 5}); + regionList.add(new int[]{4, 4, 0, 5}); + + + int reginonIndex = 4; + + HSSFRow row; + HSSFCell cell; + + + //regionList.add(new int[]{5,5,1,2}); + + + //靠左的行索引 + HashSet leftRowIndexSet=new HashSet(); + leftRowIndexSet.add(reginonIndex); + for (PractiseProDto practiseProDto : practiseProDtos) { + reginonIndex++; + leftRowIndexSet.add(reginonIndex); + + regionList.add(new int[]{reginonIndex, reginonIndex, 0, 5}); + Object[] trx = {practiseProDto.getProName()+("(得分:")+(practiseProDto.getProjectScore())+(")").toString()}; + cellDate.add(trx);//交易层次 + + // + Object[] trxTitle = {"序号", "考核点", "正确答案", "学生答案", "考核点分值", "得分"}; + cellDate.add(trxTitle); + reginonIndex++; + + + *//*Object[] assess = {"",taskVo.getTaskName(),"",(taskVo.getAnswer()==0?"对":"错"),""}; + cellDate.add(assess);*//* + List taskList = practiseProDto.getTaskList(); + + if (taskList != null && taskList.size() > 0) { + int i = 1; + for (PractiseTaskDto taskDto : taskList) { + String rightAnswer = taskDto.getRightAnswer(); + if (rightAnswer == null) { + rightAnswer = "-"; + } + String stuAnswer = taskDto.getStuAnswer(); + if (stuAnswer == null) { + stuAnswer = "-"; + } + + BigDecimal studentScore = BigDecimal.ZERO; + + if (taskDto.getAnswer().intValue() == 0) { + studentScore = taskDto.getTaskScore(); + } + Object[] assess = {i, taskDto.getTaskName(), rightAnswer, stuAnswer, taskDto.getTaskScore(), studentScore}; + cellDate.add(assess); + reginonIndex++; + i++; + } + } else { + Object[] assess = {"-", "-", "-", "-", "-", "-"}; + cellDate.add(assess); + reginonIndex++; + } + + *//*regionList.add(new int[]{maxRow,maxRow,1,2}); + maxRow ++;*//* + } + + int size = cellDate.size(); + for (int i = 0; i < size; i++) { + //居中标识 + short alignment=2; + if(leftRowIndexSet.contains(i)){ + //居左 + alignment=1; + } + row = sheet.createRow(i);//创建表格行 + int length = cellDate.get(i).length; + for (int j = 0; j 4 ){ + setFontColor(wb,cell,str,str.indexOf(":")+1,str.length()-1); + }else{ + cell.setCellValue(str); + } + + + + HSSFCellStyle cellStyle = wb.createCellStyle(); + cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN); + cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); + cellStyle.setAlignment(alignment); + cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER); + if(i==3) + cellStyle.setWrapText(true); + cell.setCellStyle(cellStyle); + } + row = sheet.getRow(i); + if (i ==3) + row.setHeightInPoints(320); + else + row.setHeightInPoints(30); + } + + + int cellDate1Len = cellDate.get(0).length; + + for (int j = 0; j < cellDate1Len; j++) { + sheet.setColumnWidth(j, MSExcelUtil.pixel2WidthUnits(180)); + } + + for (int[] regions : regionList) { + //合并单元格 + CellRangeAddress region = new CellRangeAddress(regions[0], // first row + regions[1], // last row + regions[2], // first column + regions[3] // last column + ); + sheet.addMergedRegion(region); + } + + ServletOutputStream sos = null; + + try { + sos = response.getOutputStream(); + wb.write(sos); + sos.close(); + } catch (Exception e) { + logger.error(e.getMessage(), e); + } finally { + if (sos != null) { + try { + sos.close(); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + + } + }*/ + } + + /** + * @description poi实现单元格中部分字体颜色设定 + * @author huan.xu + * @date 2019-12-10 16:19:48 + * @param [cell, wb, str, startIndex, endIndex] + * @return void + **/ + private void setFontColor(HSSFWorkbook wb, HSSFCell cell, String str, int startIndex, int endIndex ){ + HSSFFont font=wb.createFont(); + font.setColor(HSSFColor.RED.index); + HSSFRichTextString richString = new HSSFRichTextString(str); + richString.applyFont(startIndex, endIndex,font); + cell.setCellValue(richString); + } +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDto.java index d370ae0..93260cc 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/ExamDto.java @@ -4,13 +4,6 @@ import lombok.Data; import java.util.Date; -/** - * @author huan.xu - * @version 1.0 - * @className ExamDto - * @description 考试的dto - * @date 2019-08-19 10:50 - */ @Data public class ExamDto { /**考试id,即reqId*/ diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseProDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseProDto.java new file mode 100644 index 0000000..fe706dd --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseProDto.java @@ -0,0 +1,26 @@ +package com.blockchain.server.yyyf.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.List; + +@Data +public class PractiseProDto implements Serializable { + private static final long serialVersionUID = -6726051902592416723L; + + + //id + private String id; + //项目名称 + private String proName; + //考核项目得分 + private BigDecimal projectScore; + //项目案例内容 + private String projectCaseDesc; + //案例集合 + private List taskList; + + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTaskDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTaskDto.java new file mode 100644 index 0000000..1b6825a --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTaskDto.java @@ -0,0 +1,26 @@ +package com.blockchain.server.yyyf.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class PractiseTaskDto implements Serializable { + private static final long serialVersionUID = 6752155834635874301L; + + //id + private String id; + private String projectName; + //考核点名称 + private String taskName; + //考核点得分 + private BigDecimal taskScore; + //是否正确 0对 1错 + private Integer answer; + //考核点正确答案 + private String rightAnswer; + //学生答案 + private String stuAnswer; + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTipDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTipDto.java index 8265413..57d2aaa 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTipDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/PractiseTipDto.java @@ -6,13 +6,6 @@ import lombok.Data; import lombok.Getter; import lombok.Setter; -/** - * @author huan.xu - * @version 1.0 - * @className PractiseTipDto - * @description - * @date 2019-12-18 15:50 - */ @ApiModel("练习重新开始参数封装") @Data public class PractiseTipDto { @@ -24,6 +17,6 @@ public class PractiseTipDto { private String examPaperId; @ApiModelProperty("以渔有方用户id") - private String yyyfUserId; + private Integer yyyfUserId; } \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentAnswerDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentAnswerDto.java index 8f9aefd..dcc62a3 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentAnswerDto.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentAnswerDto.java @@ -1,23 +1,17 @@ package com.blockchain.server.yyyf.dto; +import io.swagger.models.auth.In; import lombok.Data; import java.math.BigDecimal; import java.util.Map; -/** - * @author huan.xu - * @version 1.0 - * @className StudentAnswerDto - * @description 学生答题Dto - * @date 2019-08-20 9:04 - */ @Data public class StudentAnswerDto extends ExamDto { /** * 用户id */ - private String userId; + private Integer userId; /** * 用户姓名 */ diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentScoreDto.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentScoreDto.java new file mode 100644 index 0000000..d042bf1 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/StudentScoreDto.java @@ -0,0 +1,23 @@ +package com.blockchain.server.yyyf.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; +@Data +public class StudentScoreDto implements Serializable { + + private static final long serialVersionUID = 1L; + + private String authorization = "87DIVy348Oxzj3ha"; + private String sysType = "102";// + private String userId; + private Float totalScore;//分数 + private Date startTime;//开始时间 + private Date endTime;//结束时间 + private String achievementType;//0 练习 1考核 + private String assessmentId;//考核id + private String classId;//班级ID + private String courseId;//课程ID + private String caseId; +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginRequestVo.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginRequestVo.java index 9d4efab..4b72272 100644 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginRequestVo.java +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/dto/YyyfLoginRequestVo.java @@ -3,6 +3,7 @@ package com.blockchain.server.yyyf.dto; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import io.swagger.models.auth.In; import lombok.Data; import org.springframework.format.annotation.DateTimeFormat; @@ -16,7 +17,7 @@ public class YyyfLoginRequestVo implements Serializable { private static final long serialVersionUID = 6595694408632033196L; @NotNull @ApiModelProperty("登录用户的id") - private String userId; + private Integer userId; @NotNull @ApiModelProperty("登录用户的姓名") private String userName; diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java new file mode 100644 index 0000000..081a0e8 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUser.java @@ -0,0 +1,97 @@ +package com.blockchain.server.yyyf.entity; + + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Table(name = "yyyf_server_assess_user") +@Data +public class AssessUser implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "id") + private String id; + + /** + * 子系统id + */ + @Column(name = "train_id") + private String trainId; + + /** + * 已发布id + */ + @Column(name = "issue_id") + private String issueId; + + /** + * 子系统练习id(练习才会用到) + */ + @Column(name = "ss_practise_id") + private String ssPractiseId; + + + /** + * 用户id + */ + @Column(name = "user_id") + private Integer userId; + /** + * 得分 + */ + @Column(name = "total_score") + private BigDecimal totalScore; + /** + * 时长 + */ + @Column(name = "duration") + private Integer duration; + /** + * 时长单位 + */ + @Column(name = "duration_unit") + private String durationUnit; + /** + * 开始时间 + */ + @Column(name = "start_time") + private Date startTime; + /** + * 结束时间 + */ + @Column(name = "end_time") + private Date endTime; + /** + * 案例id + */ + @Column(name = "case_id") + private String caseId; + + /** + * 0 练习 1考核 + */ + @Column(name = "achieve_ment_type") + private Integer achieveMentType; + + /** + * 绑定班级 + */ + @Column(name = "class_id") + private String classId; + + /** + * 绑定的课程id + */ + @Column(name = "course_id") + private String courseId; + + +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java new file mode 100644 index 0000000..f3e4230 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserProject.java @@ -0,0 +1,46 @@ +package com.blockchain.server.yyyf.entity; + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; +@Table(name = "yyyf_server_assess_user_project") +@Data +public class AssessUserProject implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * uuid + */ + @Id + @Column(name = "id") + private String id; + /** + * 用户考核主表id + */ + @Column(name = "assess_user_id") + private String assessUserId; + /** + * 子系统项目id + */ + @Column(name = "project_id") + private String projectId; + /** + * 子系统项目名称 + */ + @Column(name = "project_name") + private String projectName; + /** + * 项目得分 + */ + @Column(name = "project_score") + private BigDecimal projectScore; + + @Column(name = "project_case_desc") + private BigDecimal projectCaseDesc; + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTask.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTask.java new file mode 100644 index 0000000..7165a27 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/entity/AssessUserTask.java @@ -0,0 +1,69 @@ +package com.blockchain.server.yyyf.entity; + + +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Id; +import javax.persistence.Table; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; + +@Table(name = "yyyf_server_assess_user_task") +@Data +public class AssessUserTask implements Serializable { + + private static final long serialVersionUID = 1L; + + @Id + @Column(name = "id") + private String id; + /** + * 用户考核项目id + */ + @Column(name = "assessProjectId") + private String assessProjectId; + /** + * 任务id + */ + @Column(name = "taskId") + private String taskId; + /** + * 任务名 + */ + @Column(name = "taskName") + private String taskName; + /** + * 答题对错0对 1错 + */ + @Column(name = "answer") + private Integer answer; + /** + * 任务得分 + */ + @Column(name = "taskScore") + private BigDecimal taskScore; + + + /** + * 排序字段 + */ + @Column(name = "serialNumber") + private int serialNumber; + + /** + * 正确答案 + */ + @Column(name = "rightAnswer") + private String rightAnswer; + + /** + * 学生答案 + */ + @Column(name = "stuAnswer") + private String stuAnswer; + + + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/BtcFeign.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/BtcFeign.java deleted file mode 100644 index 58f444d..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/BtcFeign.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.blockchain.server.yyyf.feign; - -import com.blockchain.common.base.dto.ResultDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * @author huangxl - * @create 2019-02-28 17:40 - */ -@FeignClient("dapp-btc-server") -public interface BtcFeign { - @GetMapping("/inner/wallet/createWallet") - ResultDTO createWallet(@RequestParam("userOpenId") String userOpenId); -} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EosFeign.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EosFeign.java deleted file mode 100644 index 19d5104..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EosFeign.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.blockchain.server.yyyf.feign; - -import com.blockchain.common.base.dto.ResultDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * @author huangxl - * @create 2019-02-28 17:39 - */ -@FeignClient("dapp-eos-server") -public interface EosFeign { - @GetMapping("/inner/walletTx/initEosWallet") - ResultDTO initEosWallet(@RequestParam("userOpenId") String userOpenId); -} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EthFeign.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EthFeign.java deleted file mode 100644 index c6ff066..0000000 --- a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/feign/EthFeign.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.blockchain.server.yyyf.feign; - -import com.blockchain.common.base.dto.ResultDTO; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * @author huangxl - * @create 2019-02-28 17:39 - */ -@FeignClient("dapp-eth-server") -public interface EthFeign { - @GetMapping("/inner/wallet/initWallets") - ResultDTO initWallets(@RequestParam("userOpenId") String userOpenId); -} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java new file mode 100644 index 0000000..9e0a1a9 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserMapper.java @@ -0,0 +1,43 @@ +package com.blockchain.server.yyyf.mapper; + + +import com.blockchain.server.yyyf.dto.PractiseProDto; +import com.blockchain.server.yyyf.entity.AssessUser; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + + +@Repository +public interface AssessUserMapper { + + void insert(AssessUser assessUser); + + void batchInsert(List assessUserList); + + + AssessUser selectScore( @Param("assessmentId") String assessmentId, @Param("userId") Integer userId); + + + Map selectUserGradeCase(Map con); + + + List> selectUserGradeListByClassIdAndIssueId(Map con); + + + List selectPractiseProList (@Param("assessUserId") String assessUserId); + + + List selectAssessUserListByIssuerIdAndUserId(@Param("issueId") String issueId, @Param("userId") Integer userId); + + + AssessUser selectAssessUserById(@Param("assessUserId") String assessUserId); + + + List selectAssessUserListByIssueId(@Param("issueId") String issueId); + + void delAssessUserByIssueId(@Param("issueId") String issueId); + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java new file mode 100644 index 0000000..85fabba --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserProjectMapper.java @@ -0,0 +1,15 @@ +package com.blockchain.server.yyyf.mapper; + +import com.blockchain.server.yyyf.entity.AssessUserProject; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface AssessUserProjectMapper { + + void insert(AssessUserProject assessUserProject); + + void batchInsert(List assessUserProjectList); + +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTaskMapper.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTaskMapper.java new file mode 100644 index 0000000..2d39bf9 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/mapper/AssessUserTaskMapper.java @@ -0,0 +1,19 @@ +package com.blockchain.server.yyyf.mapper; + +import com.blockchain.server.yyyf.entity.AssessUserTask; +import org.apache.ibatis.annotations.Param; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +public interface AssessUserTaskMapper { + + void insert(AssessUserTask assessUserTask); + + void batchInsert(List assessUserTaskList); + + + List> selectYHTaskInfoByIssueId(@Param("issueId") String issueId); +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java new file mode 100644 index 0000000..d9ddd17 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserProjectService.java @@ -0,0 +1,4 @@ +package com.blockchain.server.yyyf.service; + +public interface AssessUserProjectService{ +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java new file mode 100644 index 0000000..996d7e0 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserService.java @@ -0,0 +1,74 @@ +package com.blockchain.server.yyyf.service; + + + +import com.blockchain.server.yyyf.dto.PractiseProDto; +import com.blockchain.server.yyyf.entity.AssessUser; + +import java.util.List; +import java.util.Map; + +/** + * @param + * @author huan.xu + * @description 学生用户考核信息表 服务接口类 + * @date 2019-10-31 14:36:49 + * @return + **/ +public interface AssessUserService { + + + + + + /** + * @description 根据 学生成绩id,查询答题详情 + * @author huan.xu + * @date 2019-11-08 18:39:11 + * @param [assessUserId] + * @return java.util.List + **/ + public List selectPractiseProList(String assessUserId); + + + /** + * @param [sysType, issueId, userId] + * @return com.gtafeyyyf.model.AssessUser + * @description 考核id,以及用户id 查询学生答题概览(考核) + * @author huan.xu + * @date 2019-11-08 18:28:30 + **/ + AssessUser selectScore( String issueId, Integer userId); + + /** + * @description 根据发布id,用户id 获取学生该练习的所有答题情况 + * @author huan.xu + * @date 2019-11-08 18:31:38 + * @param [issueId, userId] + * @return java.util.List + **/ + List selectAssessUserListByIssuerIdAndUserId(String issueId, Integer userId); + + + /** + * @description 根据 assessUser 表的id查询assessUser + * @param [assessUserId] + * @return com.gtafeyyyf.model.AssessUser + **/ + AssessUser selectAssessUserById(String assessUserId); + + /** + * @param [issueId] + * @return java.util.List + * @description 根据考核id 查询所有的有成绩的学生考核概览信息,这一块可做优化,将其封装成成绩同步的DTO, + * 在TeachingGradeController的406 行就无需遍历封装。由于时间原因暂不优化 + **/ + List selectAssessUserListByIssueId(String issueId); + + /*** + * @description 通过考试id删除该考试的所有学生成绩 + * @param [examId] + * @return void + **/ + void delAssessUserByIssueId(String examId); +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTaskService.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTaskService.java new file mode 100644 index 0000000..91f74e8 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/AssessUserTaskService.java @@ -0,0 +1,18 @@ +package com.blockchain.server.yyyf.service; + +import java.util.List; +import java.util.Map; + +/** + * @version 1.0 + * @className AssessUserTaskService + * @description + */ +public interface AssessUserTaskService { + /** + * @description 根据考核发布id,获取考核点信息 + * @param [issueId] + * @return java.util.List> + **/ + List> selectYHTaskInfoByIssueId(String issueId); +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java new file mode 100644 index 0000000..63631ff --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserProjectServiceImpl.java @@ -0,0 +1,15 @@ +package com.blockchain.server.yyyf.service.impl; + +import com.blockchain.server.yyyf.service.AssessUserProjectService; +import org.springframework.stereotype.Service; + +/** + * @author huan.xu + * @version 1.0 + * @className AssessUserProjectServiceImpl + * @description + * @date 2019-10-31 17:40 + */ +@Service +public class AssessUserProjectServiceImpl implements AssessUserProjectService { +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java new file mode 100644 index 0000000..97459df --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserServiceImpl.java @@ -0,0 +1,74 @@ +package com.blockchain.server.yyyf.service.impl; + +import com.blockchain.server.yyyf.dto.PractiseProDto; +import com.blockchain.server.yyyf.entity.AssessUser; +import com.blockchain.server.yyyf.mapper.AssessUserMapper; +import com.blockchain.server.yyyf.mapper.AssessUserProjectMapper; +import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper; +import com.blockchain.server.yyyf.service.AssessUserService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * @author huan.xu + * @version 1.0 + * @className AssessUserServiceImpl + * @description 学生用户考核信息表 服务实现类 + * @date 2019-10-31 14:34 + */ +@Service +public class AssessUserServiceImpl implements AssessUserService { + private static Logger LOG = LoggerFactory.getLogger(AssessUserServiceImpl.class); + + + @Autowired + private AssessUserMapper assessUserMapper; + @Autowired + private AssessUserProjectMapper assessUserProjectMapper; + @Autowired + private AssessUserTaskMapper assessUserTaskMapper; + + private static final String durationUnit = "m";//时长单位 + + + + + + @Override + public List selectPractiseProList (String assessUserId){ + return this.assessUserMapper.selectPractiseProList(assessUserId); + } + + @Override + public AssessUser selectScore(String issueId, Integer userId) { + return this.assessUserMapper.selectScore(issueId,userId); + } + + @Override + public List selectAssessUserListByIssuerIdAndUserId(String issueId, Integer userId) { + return this.assessUserMapper.selectAssessUserListByIssuerIdAndUserId(issueId,userId); + } + + @Override + public AssessUser selectAssessUserById(String assessUserId) { + return this.assessUserMapper.selectAssessUserById(assessUserId); + } + + @Override + public List selectAssessUserListByIssueId(String issueId) { + return this.assessUserMapper.selectAssessUserListByIssueId(issueId); + } + + @Transactional + @Override + public void delAssessUserByIssueId(String examId) { + this.assessUserMapper.delAssessUserByIssueId(examId); + } + + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTaskServiceImpl.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTaskServiceImpl.java new file mode 100644 index 0000000..c0ec653 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/service/impl/AssessUserTaskServiceImpl.java @@ -0,0 +1,28 @@ +package com.blockchain.server.yyyf.service.impl; + +import com.blockchain.server.yyyf.mapper.AssessUserTaskMapper; +import com.blockchain.server.yyyf.service.AssessUserTaskService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author huan.xu + * @version 1.0 + * @className AssessUserTaskServiceImpl + * @description + * @date 2019-10-31 17:40 + */ +@Service +public class AssessUserTaskServiceImpl implements AssessUserTaskService { + @Autowired + private AssessUserTaskMapper assessUserTaskMapper; + @Override + public List> selectYHTaskInfoByIssueId(String issueId) { + return this.assessUserTaskMapper.selectYHTaskInfoByIssueId(issueId); + } + + +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/MSExcelUtil.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/MSExcelUtil.java new file mode 100644 index 0000000..9d94a3a --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/MSExcelUtil.java @@ -0,0 +1,27 @@ +package com.blockchain.server.yyyf.utils; + +/** + * @version 1.0 + * @className MSExcelUtil + * @description + */ +public class MSExcelUtil { + public static final short EXCEL_COLUMN_WIDTH_FACTOR = 256; + public static final int UNIT_OFFSET_LENGTH = 7; + public static final int[] UNIT_OFFSET_MAP = new int[] { 0, 36, 73, 109, 146, 182, 219 }; + + public static short pixel2WidthUnits(int pxs) { + short widthUnits = (short) (EXCEL_COLUMN_WIDTH_FACTOR * (pxs / UNIT_OFFSET_LENGTH)); + widthUnits += UNIT_OFFSET_MAP[(pxs % UNIT_OFFSET_LENGTH)]; + return widthUnits; + } + + public static int widthUnits2Pixel(int widthUnits) { + int pixels = (widthUnits / EXCEL_COLUMN_WIDTH_FACTOR) * UNIT_OFFSET_LENGTH; + int offsetWidthUnits = widthUnits % EXCEL_COLUMN_WIDTH_FACTOR; + pixels += Math.round(offsetWidthUnits + / ((float) EXCEL_COLUMN_WIDTH_FACTOR / UNIT_OFFSET_LENGTH)); + + return pixels; + } +} \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/ResponseUtils.java b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/ResponseUtils.java new file mode 100644 index 0000000..2628c7a --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/java/com/blockchain/server/yyyf/utils/ResponseUtils.java @@ -0,0 +1,77 @@ +package com.blockchain.server.yyyf.utils; + + +import java.io.IOException; + +import javax.servlet.http.HttpServletResponse; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * HttpServletResponse帮助 + * + * @author + * + */ +public final class ResponseUtils { + public static final Logger logger = LoggerFactory + .getLogger(ResponseUtils.class); + + /** + * 发送文本。使用UTF-8编码。 + * + * @param response + * HttpServletResponse + * @param text + * 发送的字符串 + */ + public static void renderText(HttpServletResponse response, String text) { + render(response, "text/plain;charset=UTF-8", text); + } + + /** + * 发送json。使用UTF-8编码。 + * + * @param response + * HttpServletResponse + * @param text + * 发送的字符串 + */ + public static void renderJson(HttpServletResponse response, String text) { + render(response, "application/json;charset=UTF-8", text); + } + + /** + * 发送xml。使用UTF-8编码。 + * + * @param response + * HttpServletResponse + * @param text + * 发送的字符串 + */ + public static void renderXml(HttpServletResponse response, String text) { + render(response, "text/xml;charset=UTF-8", text); + } + + /** + * 发送内容。使用UTF-8编码。 + * + * @param response + * @param contentType + * @param text + */ + public static void render(HttpServletResponse response, String contentType, + String text) { + response.setContentType(contentType); + response.setHeader("Pragma", "No-cache"); + response.setHeader("Cache-Control", "no-cache"); + response.setDateHeader("Expires", 0); + try { + response.getWriter().write(text); + response.getWriter().flush(); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + } +} diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml new file mode 100644 index 0000000..7faf516 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserMapper.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + and t.id=#{id,jdbcType=VARCHAR} + + + and t.train_id=#{trainId,jdbcType=VARCHAR} + + + and t.issue_id=#{issueId,jdbcType=VARCHAR} + + + and t.ss_practise_id=#{ssPractiseId,jdbcType=VARCHAR} + + + and t.user_id=#{userId,jdbcType=INTEGER} + + + and t.total_score=#{totalScore,jdbcType=NUMERIC} + + + and t.customer_story=#{customerStory,jdbcType=VARCHAR} + + + and t.duration=#{duration,jdbcType=INTEGER} + + + and t.duration_unit=#{durationUnit,jdbcType=VARCHAR} + + + and t.start_time=#{startTime,jdbcType=TIMESTAMP} + + + and t.end_time=#{endTime,jdbcType=TIMESTAMP} + + + and t.case_id=#{caseId,jdbcType=VARCHAR} + + + and t.achieve_ment_type=#{achieveMentType,jdbcType=INTEGER} + + + and t.class_id=#{classId,jdbcType=VARCHAR} + + + and t.course_id=#{courseId,jdbcType=VARCHAR} + + + and t.group_id=#{groupId,jdbcType=INTEGER} + + + + + t.id, + t.train_id, + t.issue_id, + t.ss_practise_id, + t.user_id, + t.total_score, + t.duration, + t.duration_unit, + t.start_time, + t.end_time, + t.case_id, + t.achieve_ment_type, + t.class_id, + t.course_id, + + + + insert into yyyf_server_assess_user ( id, train_id, issue_id, ss_practise_id, user_id, total_score, duration, duration_unit, start_time, end_time, case_id, achieve_ment_type, class_id, course_id) + values( + #{id}, + #{trainId}, + #{issueId}, + #{ssPractiseId}, + #{userId}, + #{totalScore}, + #{duration}, + #{durationUnit}, + #{startTime}, + #{endTime}, + #{caseId}, + #{achieveMentType}, + #{classId}, + #{courseId} + ) + + + + insert into yyyf_server_assess_user + values + + + ( + #{item.id}, + #{item.trainId}, + #{item.issueId}, + #{item.ssPractiseId}, + #{item.userId}, + #{item.totalScore}, + #{item.duration}, + #{item.durationUnit}, + #{item.startTime}, + #{item.endTime}, + #{item.caseId}, + #{item.achieveMentType}, + #{item.classId}, + #{item.courseId}, + ) + + + + + delete from yyyf_server_assess_user where issue_id=#{issueId} + + + + + + + + + + + + + + + diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml new file mode 100644 index 0000000..c556eb4 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserProject.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + and t.id=#{id,jdbcType=VARCHAR} + + + and t.assess_user_id=#{assessUserId,jdbcType=VARCHAR} + + + and t.project_name=#{projectName,jdbcType=VARCHAR} + + + and t.project_id=#{projectId,jdbcType=VARCHAR} + + + and t.project_score=#{projectScore,jdbcType=NUMERIC} + + + and t.duration=#{duration,jdbcType=INTEGER} + + + and t.duration_unit=#{durationUnit,jdbcType=VARCHAR} + + + and t.project_case_desc=#{projectCaseDesc,jdbcType=VARCHAR} + + + + + t.id, + t.assess_user_id, + t.project_name, + t.project_id, + t.project_score, + t.duration, + t.duration_unit, + t.project_case_desc, + + + + insert into yyyf_server_assess_user_project (id, assess_user_id, project_name, project_id, project_score, duration, duration_unit, project_case_desc) + values( + #{id}, + #{assessUserId}, + #{projectName}, + #{projectId}, + #{projectScore}, + #{duration}, + #{durationUnit}, + #{projectCaseDesc} + ) + + + + insert into yyyf_server_assess_user_project ( id, assess_user_id, project_name, project_id, project_score, project_case_desc) + values + + ( + #{item.id}, + #{item.assessUserId}, + #{item.projectName}, + #{item.projectId}, + #{item.projectScore}, + #{item.projectCaseDesc} + ) + + + + + + \ No newline at end of file diff --git a/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTask.xml b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTask.xml new file mode 100644 index 0000000..a57b760 --- /dev/null +++ b/blockchain-server/blockchain-server-yyyf/src/main/resources/mapper/AssessUserTask.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + and t.id=#{id,jdbcType=VARCHAR} + + + and t.assess_project_id=#{assessProjectId,jdbcType=VARCHAR} + + + and t.task_id=#{taskId,jdbcType=VARCHAR} + + + and t.task_name=#{taskName,jdbcType=VARCHAR} + + + and t.task_score=#{taskScore,jdbcType=NUMERIC} + + + and t.answer=#{answer,jdbcType=INTEGER} + + + + and t.serial_number=#{serialNumber,jdbcType=INTEGER} + + + and t.right_answer=#{rightAnswer,jdbcType=VARCHAR} + + + and t.stu_answer=#{stuAnswer,jdbcType=VARCHAR} + + + + + t.id, + t.assess_project_id, + t.task_id, + t.task_name, + t.task_score, + t.answer, + t.serial_number, + t.right_answer, + t.stu_answer, + + + + insert into yyyf_server_assess_user_task ( id, assess_project_id, task_id, task_name, task_score, answer, serial_number, right_answer, stu_answer) + values( + #{id}, + #{assessProjectId}, + #{taskId}, + #{taskName}, + #{taskScore}, + #{answer}, + #{serialNumber}, + #{rightAnswer}, + #{stuAnswer} + ) + + + + insert into yyyf_server_assess_user_task + values + + ( + #{item.id}, + #{item.assessProjectId}, + #{item.taskId}, + #{item.taskName}, + #{item.taskScore}, + #{item.answer}, + #{item.serialNumber}, + #{item.rightAnswer}, + #{item.stuAnswer} + ) + + + + + + diff --git a/pom.xml b/pom.xml index edf54a7..d0fc253 100644 --- a/pom.xml +++ b/pom.xml @@ -33,8 +33,8 @@ latest - zhixinlian:zhi123xin678lian@127.0.0.1 - 127.0.0.1 + zhixinlian:zhi123xin678lian@10.10.17.84 + 10.10.17.84