From 5eddc4d8e027aa65c5f82e88a9b82dd9f09c3f1b Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 30 Nov 2020 17:12:54 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E3=80=8A=E5=AE=9E=E8=AE=AD=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=97=B6=EF=BC=8C=E6=9C=AA=E6=A0=B9=E6=8D=AEprdType?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E3=80=8Bbug=E4=BF=AE=E6=94=B9=EF=BC=88?= =?UTF-8?q?=E8=80=83=E8=AF=95=E5=BC=80=E5=A7=8B=E7=9A=84bug=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E6=B6=88=E9=99=A4=EF=BC=89=EF=BC=9B=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E8=80=83=E8=AF=95=E6=95=88=E7=8E=87=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/services/LessonService.java | 7 +++- .../rtss/services/UserExamService.java | 39 +++++++++---------- .../services/training/ITrainingV1Service.java | 2 +- .../services/training/TrainingV1Service.java | 4 +- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/LessonService.java b/src/main/java/club/joylink/rtss/services/LessonService.java index e68a2f98f..e3d105e4d 100644 --- a/src/main/java/club/joylink/rtss/services/LessonService.java +++ b/src/main/java/club/joylink/rtss/services/LessonService.java @@ -71,6 +71,9 @@ public class LessonService implements ILessonService { @Autowired private StudentRelLessonClassDAO studentRelLessonClassDAO; + @Autowired + private IExamService iExamService; + @Override public LessonTreeVO getLessonTree(Long id, UserVO userVO) { LessonTreeVO lessonTreeVO = new LessonTreeVO(); @@ -616,7 +619,7 @@ public class LessonService implements ILessonService { if (Objects.nonNull(existedDefaultLesson)) { lesson.setId(existedDefaultLesson.getId()); lessonDAO.updateByPrimaryKey(lesson); - //存在默认课程删除旧版本、章节及关联实训数据 + //存在默认课程删除旧版本、章节、考试及关联实训数据 LsLessonVersionExample versionExample = new LsLessonVersionExample(); versionExample.createCriteria().andLessonIdEqualTo(existedDefaultLesson.getId()); lessonVersionDAO.deleteByExample(versionExample); @@ -654,7 +657,7 @@ public class LessonService implements ILessonService { List examTrainings = new ArrayList<>(20); int orderNum = 1; Random random = new Random(); - Map>> trainings = iTrainingV1Service.findEntities(mapVO.getId()) + Map>> trainings = iTrainingV1Service.findEntities(mapVO.getId(), prdType) .stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType))); for (BusinessConsts.Training.Type type : BusinessConsts.Training.Type.values()) { Map> collect = trainings.get(type.name()); diff --git a/src/main/java/club/joylink/rtss/services/UserExamService.java b/src/main/java/club/joylink/rtss/services/UserExamService.java index a9b8e9db2..deda17772 100644 --- a/src/main/java/club/joylink/rtss/services/UserExamService.java +++ b/src/main/java/club/joylink/rtss/services/UserExamService.java @@ -51,9 +51,6 @@ public class UserExamService implements IUserExamService { @Autowired private LsLessonDAO lessonDAO; - @Autowired - private ISysUserService iSysUserService; - @Override @Transactional public UserExamVO generateExamInstance(long examId, UserVO userVO) { @@ -73,7 +70,7 @@ public class UserExamService implements IUserExamService { // 判断是否在考试时间之内 if (examDef.getStartTime() != null) { LocalDateTime now = LocalDateTime.now(); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime())&&now.isBefore(examDef.getEndTime())); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(now.isAfter(examDef.getStartTime()) && now.isBefore(examDef.getEndTime())); } // 保存用户考试信息 UserExam userExam = new UserExam(); @@ -89,28 +86,30 @@ public class UserExamService implements IUserExamService { ruleExample.createCriteria().andExamIdEqualTo(examId); List rules = this.examDefinitionRulesDAO.selectByExample(ruleExample); BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(rules); + //确认课程存在 + LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId()); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(lesson); + //查询实训,生成试卷 + Map>> trainings = iTrainingService.findEntities(lesson.getMapId(), lesson.getPrdType()) + .stream().collect(Collectors.groupingBy(Training::getType, Collectors.groupingBy(Training::getOperateType))); for (ExamDefinitionRules rule : rules) { - // 根据课程所属产品的编码和规则中实训类型查找实训 - LsLesson lesson = this.lessonDAO.selectByPrimaryKey(examDef.getLessonId()); - BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(lesson); - TrainingExample te = new TrainingExample(); - TrainingExample.Criteria criteria = te.createCriteria() - .andMapIdEqualTo(lesson.getMapId()) - .andPrdTypeEqualTo(lesson.getPrdType()) - .andTypeEqualTo(rule.getTrainingType()); + List collect; if (StringUtils.hasText(rule.getOperateType())) { - criteria.andOperateTypeEqualTo(rule.getOperateType()); + collect = trainings.get(rule.getTrainingType()).get(rule.getOperateType()); + } else { + collect = new ArrayList<>(); + for (List value : trainings.get(rule.getTrainingType()).values()) { + collect.addAll(value); + } } - // 符合生成规则的实训 - List trainings = this.trainingDAO.selectByExample(te); - BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(trainings.size() > rule.getNum()); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(collect.size() > rule.getNum()); // 随机生成考试并保存 boolean flag = true; List questionsVOs = new ArrayList<>(); while (flag) { Random random = new Random(); - int i = random.nextInt(trainings.size()); - Long trainId = trainings.get(i).getId(); + int i = random.nextInt(collect.size()); + Long trainId = collect.get(i).getId(); // 保存考试题目 UserExamQuestions questions = new UserExamQuestions(); questions.setPoint(rule.getPoint()); @@ -121,10 +120,10 @@ public class UserExamService implements IUserExamService { this.userExamQuestionsMapper.insert(questions); // 返回考试题目 UserExamQuestionsVO userExamQuestionsVO = new UserExamQuestionsVO(questions); - userExamQuestionsVO.setTrainingName(trainings.get(i).getName()); + userExamQuestionsVO.setTrainingName(collect.get(i).getName()); questionsVOs.add(userExamQuestionsVO); // 从集合中剔除已使用实训 - trainings.remove(i); + collect.remove(i); if (questionsVOs.size() == rule.getNum()) { flag = false; } diff --git a/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java b/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java index 3da45e610..922dbc9e2 100644 --- a/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java +++ b/src/main/java/club/joylink/rtss/services/training/ITrainingV1Service.java @@ -186,5 +186,5 @@ public interface ITrainingV1Service { * 根据地图id查询实训 * @return */ - List findEntities(Long mapId); + List findEntities(Long mapId, String prdType); } diff --git a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java index b50b664c2..4d10c4456 100644 --- a/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java +++ b/src/main/java/club/joylink/rtss/services/training/TrainingV1Service.java @@ -689,9 +689,9 @@ public class TrainingV1Service implements ITrainingV1Service { } @Override - public List findEntities(Long mapId) { + public List findEntities(Long mapId, String prdType) { TrainingExample example = new TrainingExample(); - example.createCriteria().andMapIdEqualTo(mapId); + example.createCriteria().andMapIdEqualTo(mapId).andPrdTypeEqualTo(prdType); return trainingDAO.selectByExample(example); } } From dbfd391799c1a1cf3b14e717696bffd8098d59f6 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 30 Nov 2020 17:51:22 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=B7=BB=E5=8A=A0=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E5=90=8D=E7=A7=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../club/joylink/rtss/dao/SysUserDAO.java | 46 ++++++++++++++++++- .../joylink/rtss/services/SysUserService.java | 12 +++++ .../java/club/joylink/rtss/vo/UserVO.java | 8 ++-- 3 files changed, 62 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/dao/SysUserDAO.java b/src/main/java/club/joylink/rtss/dao/SysUserDAO.java index edb8e68eb..a11be408f 100644 --- a/src/main/java/club/joylink/rtss/dao/SysUserDAO.java +++ b/src/main/java/club/joylink/rtss/dao/SysUserDAO.java @@ -23,7 +23,7 @@ public interface SysUserDAO extends MyBatisBaseDao " + " (#{entity.account,jdbcType=VARCHAR}, #{entity.name,jdbcType=VARCHAR}, #{entity.nickname,jdbcType=VARCHAR}, \n" + @@ -44,4 +44,48 @@ public interface SysUserDAO extends MyBatisBaseDao") List statisticsDailyRegister(@Param("beginDate") LocalDate beginDate, @Param("endDate") LocalDate endDate); + +// @Results(value = { +// @Result(column = "id", property = "id"), +// @Result(column = "account", property = "account"), +// @Result(column = "name", property = "name"), +// @Result(column = "nickname", property = "nickname"), +// @Result(column = "avatar_path", property = "avatarPath"), +// @Result(column = "password", property = "password"), +// @Result(column = "mobile", property = "mobile"), +// @Result(column = "nationcode", property = "nationcode"), +// @Result(column = "email", property = "email"), +// @Result(column = "wx_id", property = "wxId"), +// @Result(column = "wx_union_id", property = "wxUnionId"), +// @Result(column = "wm_open_id", property = "wmOpenId"), +// @Result(column = "status", property = "status"), +// @Result(column = "roles", property = "roles"), //这行有问题 +// @Result(column = "create_time", property = "createTime"), +// @Result(column = "company_id", property = "companyId"), +// @Result(column = "company.name", property = "companyName") +// }) +// @Select("") +// List selectUserWithCompanyName(SysUserExample example); } diff --git a/src/main/java/club/joylink/rtss/services/SysUserService.java b/src/main/java/club/joylink/rtss/services/SysUserService.java index e7c382097..497cb782e 100644 --- a/src/main/java/club/joylink/rtss/services/SysUserService.java +++ b/src/main/java/club/joylink/rtss/services/SysUserService.java @@ -13,6 +13,7 @@ import club.joylink.rtss.vo.SmsResponse; import club.joylink.rtss.vo.UserQueryVO; import club.joylink.rtss.vo.UserVO; import club.joylink.rtss.vo.VdCode; +import club.joylink.rtss.vo.client.CompanyVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.UserConfigVO; import club.joylink.rtss.vo.client.map.MapVO; @@ -33,6 +34,7 @@ import java.time.LocalDateTime; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; +import java.util.function.Function; import java.util.stream.Collectors; @Service @@ -83,6 +85,9 @@ public class SysUserService implements ISysUserService { @Autowired private CompanyDAO companyDAO; + @Autowired + private ICompanyService iCompanyService; + @Override public UserVO findUserByAccountAndPassword(String account, String password) { SysUserExample example = new SysUserExample(); @@ -230,6 +235,13 @@ public class SysUserService implements ISysUserService { } Page page = (Page) this.sysUserDAO.selectByExample(example); List userVOS = UserVO.convert2VO(page.getResult()); + Map companyMap = iCompanyService.queryOrganizations().stream() + .collect(Collectors.toMap(CompanyVO::getId, Function.identity())); + userVOS.forEach(user -> { + if (user.getCompanyId() != null) { + user.setCompanyName(companyMap.get(user.getCompanyId()).getName()); + } + }); return PageVO.convert(page, userVOS); } diff --git a/src/main/java/club/joylink/rtss/vo/UserVO.java b/src/main/java/club/joylink/rtss/vo/UserVO.java index 77ec9bb99..92f9a114e 100644 --- a/src/main/java/club/joylink/rtss/vo/UserVO.java +++ b/src/main/java/club/joylink/rtss/vo/UserVO.java @@ -1,17 +1,17 @@ package club.joylink.rtss.vo; +import club.joylink.rtss.constants.BusinessConsts; +import club.joylink.rtss.entity.SysUser; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import club.joylink.rtss.constants.BusinessConsts; -import club.joylink.rtss.entity.SysUser; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import org.springframework.util.StringUtils; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -102,6 +102,8 @@ public class UserVO implements Serializable { private Integer companyId; + private String companyName; + public UserVO() {} public UserVO(SysUser sysUser) { From 7fe6e84da32b4168fd3b0c70c7ea60b6b061b690 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 1 Dec 2020 14:24:09 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8Fcode=E8=BF=87=E6=9C=9F=E9=94=99=E8=AF=AF=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../joylink/rtss/exception/BusinessExceptionAssertEnum.java | 3 ++- src/main/java/club/joylink/rtss/services/WxApiService.java | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java index aea341136..becbe300f 100644 --- a/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java +++ b/src/main/java/club/joylink/rtss/exception/BusinessExceptionAssertEnum.java @@ -50,9 +50,10 @@ public enum BusinessExceptionAssertEnum implements BusinessExceptionAssert { LOGIN_INFO_ERROR(40003, "login info error"), LOGIN_EXPIRED(40004, "login expired"), NOT_LOGIN(40005, "not login"), + WECHAT_CODE_EXPIRED(40029, "wechat code expired"), INVALID_CLIENT(40031, "invalid client"), INCORRECT_VERIFICATION_CODE(40051, "incorrect verification code"), - THIRD_SERVICE_CALL_EXCEPTION(40071, "the third service call exception"), + THIRD_SERVICE_CALL_EXCEPTION(40071, "the third service call exception") ; int code; diff --git a/src/main/java/club/joylink/rtss/services/WxApiService.java b/src/main/java/club/joylink/rtss/services/WxApiService.java index d350f2346..e59d71ef5 100644 --- a/src/main/java/club/joylink/rtss/services/WxApiService.java +++ b/src/main/java/club/joylink/rtss/services/WxApiService.java @@ -1,13 +1,12 @@ package club.joylink.rtss.services; +import club.joylink.rtss.configuration.configProp.WeChatConfig; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.cache.ICacheService; -import club.joylink.rtss.configuration.configProp.WeChatConfig; import club.joylink.rtss.vo.wx.WmUserSession; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import java.util.Objects; @@ -46,7 +45,7 @@ public class WxApiService implements IWxApiService { WmUserSession wmUserSession = (WmUserSession) this.iCacheService.get(WmUserSession.getCacheKey(wmCode)); if(Objects.isNull(wmUserSession)) { wmUserSession = restTemplate.getForObject(weChatConfig.getCode2SessionUrl(wmCode), WmUserSession.class); - BusinessExceptionAssertEnum.THIRD_SERVICE_CALL_EXCEPTION.assertHasText(wmUserSession.getOpenid(), + BusinessExceptionAssertEnum.WECHAT_CODE_EXPIRED.assertHasText(wmUserSession.getOpenid(), String.format("小程序code为:‘%s’,微信返回的错误消息:errcode:'%s', errmsg:‘%s’", wmCode, wmUserSession.getErrcode(), wmUserSession.getErrmsg())); iCacheService.putExpired(WmUserSession.getCacheKey(wmCode), wmUserSession, 5, TimeUnit.MINUTES); } From f2a137379ba378e3335bee1837dcba1e62fd7f98 Mon Sep 17 00:00:00 2001 From: DU Date: Tue, 1 Dec 2020 18:36:04 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=AF=95=E9=A2=98?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/club/joylink/rtss/exception/BaseException.java | 7 +++++++ .../completition/question/QuestionBankService.java | 8 ++++---- src/main/java/club/joylink/rtss/vo/UserQueryVO.java | 6 ++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/club/joylink/rtss/exception/BaseException.java b/src/main/java/club/joylink/rtss/exception/BaseException.java index cead3a6eb..d53be11d4 100644 --- a/src/main/java/club/joylink/rtss/exception/BaseException.java +++ b/src/main/java/club/joylink/rtss/exception/BaseException.java @@ -1,5 +1,9 @@ package club.joylink.rtss.exception; +import org.springframework.util.StringUtils; + +import java.util.Objects; + public class BaseException extends RuntimeException { private IExceptionMessage exceptionMessage; @@ -29,6 +33,9 @@ public class BaseException extends RuntimeException { } public String getVoMessage() { + if (!StringUtils.isEmpty(super.getMessage())) { + return super.getMessage(); + } return this.exceptionMessage.getMessage(); } } diff --git a/src/main/java/club/joylink/rtss/services/completition/question/QuestionBankService.java b/src/main/java/club/joylink/rtss/services/completition/question/QuestionBankService.java index 167b275dc..fa69935b0 100644 --- a/src/main/java/club/joylink/rtss/services/completition/question/QuestionBankService.java +++ b/src/main/java/club/joylink/rtss/services/completition/question/QuestionBankService.java @@ -180,21 +180,21 @@ public class QuestionBankService implements IQuestionBankService { if (questionVO.isSelect() || questionVO.isJudge()) { long answerCount = questionVO.getOptionList().stream().filter(QuestionOptionVO::getCorrect).count(); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(answerCount == 1, - String.format("单选或判断题[%s]正确答案应当有且只有一个!", topic)); + String.format("题序[%s]:单选或判断题[%s]正确答案应当有且只有一个!", questionVO.getId(),topic)); } if (questionVO.isFill() || questionVO.isAnswer()) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( questionVO.getOptionList().stream().allMatch(QuestionOptionVO::getCorrect), - String.format("填空或问答题[%s]不能有错误选项!", topic)); + String.format("题序[%s]:填空或问答题[%s]不能有错误选项!", questionVO.getId(),topic)); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue( questionVO.getOptionList().stream().noneMatch(op -> Objects.isNull(op.getOrder())), - String.format("填空或问答题[%s]选项缺少序号!", topic)); + String.format("题序[%s]:填空或问答题[%s]选项缺少序号!", questionVO.getId(),topic)); if (questionVO.getOptionList().stream().anyMatch(op -> Objects.isNull(op.getOrder()))) { questionVO.getOptionList().sort(Comparator.comparing(QuestionOptionVO::getOrder)); AtomicInteger i = new AtomicInteger(1); questionVO.getOptionList().forEach(o -> { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertEquals(o.getOrder(), i.getAndIncrement(), - String.format("填空或问答题[%s]选项序号不对!", topic)); + String.format("题序[%s]:填空或问答题[%s]选项序号不对!", questionVO.getId(), topic)); }); } diff --git a/src/main/java/club/joylink/rtss/vo/UserQueryVO.java b/src/main/java/club/joylink/rtss/vo/UserQueryVO.java index 30c8a66f2..75679d661 100644 --- a/src/main/java/club/joylink/rtss/vo/UserQueryVO.java +++ b/src/main/java/club/joylink/rtss/vo/UserQueryVO.java @@ -33,6 +33,12 @@ public class UserQueryVO extends PageQueryVO { @ApiModelProperty(value = "手机号") private String mobile; + /** + * 单位名称 + */ + @ApiModelProperty(value = "单位名称") + private String companyId; + /** * 角色 */