ServiceTest.java 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. package com.qmth.distributed.print;
  2. import com.alibaba.fastjson.JSON;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import com.qmth.distributed.print.business.bean.dto.examObject.ExamObjectDto;
  6. import com.qmth.distributed.print.business.bean.marking.CardJpgResult;
  7. import com.qmth.distributed.print.business.entity.ExamCardDetail;
  8. import com.qmth.distributed.print.business.entity.ExamPrintPlan;
  9. import com.qmth.distributed.print.business.entity.ExamStudent;
  10. import com.qmth.teachcloud.common.enums.MessageEnum;
  11. import com.qmth.distributed.print.business.mapper.ExamStudentMapper;
  12. import com.qmth.distributed.print.business.service.*;
  13. import com.qmth.teachcloud.common.contant.SystemConstant;
  14. import com.qmth.teachcloud.common.entity.BasicAttachment;
  15. import com.qmth.teachcloud.common.entity.BasicCourse;
  16. import com.qmth.teachcloud.common.entity.BasicPrintConfig;
  17. import com.qmth.teachcloud.common.service.BasicCourseService;
  18. import com.qmth.teachcloud.common.service.BasicVerifyCodeService;
  19. import com.qmth.teachcloud.common.util.ConvertUtil;
  20. import org.junit.Test;
  21. import org.junit.runner.RunWith;
  22. import org.springframework.boot.test.context.SpringBootTest;
  23. import org.springframework.test.context.junit4.SpringRunner;
  24. import javax.annotation.Resource;
  25. import java.io.IOException;
  26. import java.util.HashMap;
  27. import java.util.List;
  28. import java.util.Map;
  29. /**
  30. * @Description: service层测试
  31. * @Author: CaoZixuan
  32. * @Date: 2021-04-05
  33. */
  34. @SpringBootTest
  35. @RunWith(SpringRunner.class)
  36. public class ServiceTest {
  37. @Resource
  38. private ExamPrintPlanService examPrintPlanService;
  39. @Resource
  40. private ExamDetailService examDetailService;
  41. @Resource
  42. private BasicVerifyCodeService basicVerifyCodeService;
  43. @Resource
  44. private BasicCourseService basicCourseService;
  45. @Resource
  46. private ExamTaskService examTaskService;
  47. @Resource
  48. private PrintCommonService printCommonService;
  49. @Resource
  50. private ExamCardDetailService examCardDetailService;
  51. @Resource
  52. private BasicPrintConfigService basicPrintConfigService;
  53. @Resource
  54. private ExamStudentMapper examStudentMapper;
  55. @Resource
  56. private ExamPaperStructureService examPaperStructureService;
  57. @Resource
  58. private ExamStudentService examStudentService;
  59. @Resource
  60. private ExamDetailCourseService examDetailCourseService;
  61. @Test
  62. public void printPlanTemplateDatasource() {
  63. examPrintPlanService.printPlanTemplateDatasource(1L, 2L);
  64. }
  65. @Test
  66. public void mapper() {
  67. }
  68. @Test
  69. public void readExcelTest() {
  70. examDetailService.findExaminationFields(101L);
  71. }
  72. @Test
  73. public void date() {
  74. Long startTime = 1618308000000L;
  75. Long endTime = 1618315200000L;
  76. Map<String, Object> map = ConvertUtil.analyzeDateAndTime(startTime, endTime);
  77. String date = String.valueOf(map.get("date"));
  78. String time = String.valueOf(map.get("time"));
  79. System.out.println("date = " + date);
  80. System.out.println("time = " + time);
  81. }
  82. @Test
  83. public void sendMessage() {
  84. Long userId = 1L;
  85. String mobileNumber = "18903719928";
  86. Long businessId = 1L;
  87. Map<String, String> jsonMap = new HashMap<>();
  88. jsonMap.put("userName", "李四");
  89. jsonMap.put("courseName", "数学");
  90. jsonMap.put("paperNumber", "SX001");
  91. String variableParams = JSON.toJSONString(jsonMap);
  92. // String variableParams = "{\"code\":\"" + "123456" + "\"}";
  93. Long createId = 1L;
  94. MessageEnum messageType = MessageEnum.NOTICE_OF_AUDIT_PASS;
  95. // basicMessageService.saveMessageSendLog(userId, "李四", mobileNumber, businessId, variableParams, createId, messageType, null);
  96. }
  97. @Test
  98. public void sendVerifyCode() {
  99. basicVerifyCodeService.sendVeirfyCode("18903719928", null);
  100. }
  101. @Test
  102. public void like() {
  103. QueryWrapper<BasicCourse> queryWrapper = new QueryWrapper<>();
  104. String name = "_";
  105. queryWrapper.lambda().like(BasicCourse::getName, SystemConstant.translateSpecificSign(name));
  106. List<BasicCourse> basicCourseList = basicCourseService.list(queryWrapper);
  107. System.out.println(JSON.toJSONString(basicCourseList));
  108. }
  109. @Test
  110. public void findByExamDetailId() {
  111. Long examDetailId = 1L;
  112. ExamPrintPlan examPrintPlan = examPrintPlanService.findByExamDetailId(examDetailId);
  113. System.out.println(JSON.toJSONString(examPrintPlan));
  114. }
  115. @Test
  116. public void approveForm() {
  117. Long examTask = 167675409079468032L;
  118. System.out.println(JSON.toJSONString(examTaskService.findExamTaskApprovalForm(examTask)));
  119. }
  120. @Test
  121. public void saveHtmlAndPdf() throws IOException {
  122. Long id = 165147096339447808L;
  123. ExamCardDetail examCardDetail = examCardDetailService.getById(id);
  124. String htmlContent = examCardDetail.getHtmlContent();
  125. BasicAttachment basicAttachment = printCommonService.saveAttachmentHtmlAndPdf("那不勒斯", htmlContent, 1L);
  126. System.out.println(JSON.toJSONString(basicAttachment));
  127. }
  128. @Test
  129. public void findExamObject() {
  130. String paperNumber = "cn004-0906-001";
  131. ExamObjectDto examObjectDto = examTaskService.findExamObjectDtoByPaperNumber(null, paperNumber);
  132. System.out.println(JSON.toJSONString(examObjectDto));
  133. }
  134. @Test
  135. public void findBasicPrintConfig() {
  136. Long examId = 228554176387354624L;
  137. String courseCode = "gd-gdsx";
  138. // BasicPrintConfig basicPrintConfig = basicPrintConfigService.getByExamIdAndCourseCode(examId,courseCode);
  139. BasicPrintConfig basicPrintConfig = basicPrintConfigService.getById(228554329928241152L);
  140. List<String> tempList = JSONObject.parseArray(basicPrintConfig.getPrintContent(), String.class);
  141. for (String s : tempList) {
  142. System.out.println(s);
  143. }
  144. String var = basicPrintConfig.getVariableContent();
  145. System.out.println(var);
  146. }
  147. @Test
  148. public void findExamStudent() {
  149. Long schoolId = 2L;
  150. String clazzId = "225944699725156352";
  151. List<ExamStudent> examStudentList = examStudentMapper.listExamStudentBySchoolIdAndClazzId(schoolId, clazzId);
  152. System.out.println(JSON.toJSONString(examStudentList));
  153. }
  154. @Test
  155. public void findCardJpgFileByPaperNumber() {
  156. List<CardJpgResult> resultList = examPaperStructureService.findCardJpgFileByPaperNumber(237292182900310016L, "yznwl", "yznwl-0415-001", "A");
  157. System.out.println(JSON.toJSONString(resultList));
  158. }
  159. @Test
  160. public void testFindExamObject() throws Exception {
  161. }
  162. @Test
  163. public void upExamStudent(){
  164. List<ExamStudent> examStudentList = examStudentService.list();
  165. for (ExamStudent examStudent : examStudentList) {
  166. Long examDetailCourseId = examStudent.getExamDetailCourseId();
  167. examStudent.setPaperNumber(examDetailCourseService.getById(examDetailCourseId).getPaperNumber());
  168. }
  169. examStudentService.updateBatchById(examStudentList);
  170. }
  171. }