Commit 2607a691 by 杨卫

Merge remote-tracking branch 'origin/v5.5.0' into v5.5.0

2 parents 464837d7 b95cb645
......@@ -74,4 +74,10 @@ public class LevelExamPageListRequestDTO implements Serializable {
*/
private List<Integer> departmentIds;
/**
* 是否只查询未关联培训计划的考试
*/
@ApiModelProperty(notes = "是否只查询未关联培训计划的考试: true-是, false-否,不传默认查全部")
private Boolean notRelatedPlan;
}
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/12/3
**/
public enum PersonCourseLookStatusEnum {
UNREAD("0", "未读"),
READ("1", "已读");
private String value;
private String desc;
PersonCourseLookStatusEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static PersonCourseLookStatusEnum getByValue(String value) {
for (PersonCourseLookStatusEnum item : PersonCourseLookStatusEnum.values()) {
if (item.getValue().equals(value)) {
return item;
}
}
return null;
}
public static PersonCourseLookStatusEnum getByDesc(String desc) {
for (PersonCourseLookStatusEnum item : PersonCourseLookStatusEnum.values()) {
if (item.getDesc().equals(desc)) {
return item;
}
}
return null;
}
}
package cn.com.glsx.dj.riskmanage.enums.learningcenter;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/12/3
**/
public enum PersonCoursePushSourceEnum {
TRAINING_PLAN("0", "培训计划"),
RIGHTS_COURSE("1", "权益课程");
private String value;
private String desc;
PersonCoursePushSourceEnum(String value, String desc) {
this.value = value;
this.desc = desc;
}
public String getValue() {
return value;
}
public String getDesc() {
return desc;
}
public static PersonCoursePushSourceEnum getByValue(String value) {
for (PersonCoursePushSourceEnum item : PersonCoursePushSourceEnum.values()) {
if (item.getValue().equals(value)) {
return item;
}
}
return null;
}
public static PersonCoursePushSourceEnum getByDesc(String desc) {
for (PersonCoursePushSourceEnum item : PersonCoursePushSourceEnum.values()) {
if (item.getDesc().equals(desc)) {
return item;
}
}
return null;
}
}
......@@ -217,7 +217,8 @@ public class LearningCenterCourseService {
if (StringUtils.isNotBlank(cache)) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "操作频繁,请稍后再试");
}
redisTemplate.opsForValue().set(COURSE_CACHE_KEY, COURSE_CACHE_KEY, 30, TimeUnit.MINUTES);
Integer interval = environment.getProperty("course.sync.interval", Integer.class, 30);
redisTemplate.opsForValue().set(COURSE_CACHE_KEY, COURSE_CACHE_KEY, interval, TimeUnit.MINUTES);
//使用线程异步调用数据同步
new Thread(() -> {
sync.sync();
......
......@@ -26,6 +26,7 @@ import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
/**
* @Title:
......@@ -75,6 +76,10 @@ public class LearningCenterLevelExamPersonService {
.andEqualTo("examinationId", levelExam.getBeisenExamId())
.andEqualTo("userId", examPerson.getPersonId());
BeiSenExaminationTrainees trainees = traineesMapper.selectOneByExample(traineesExample);
if (Objects.isNull(trainees)) {
log.info("未查询到等级考试记录 examPersonId:{}", id);
return;
}
BigDecimal rootTopPoint = trainees.getRootTopPoint();
LearningCenterLevelExamLevel levelExamLevel = levelExamLevelMapper.getScoreLevel(levelExam.getId(), rootTopPoint);
......
......@@ -389,9 +389,18 @@ public class LearningCenterTrainingPlanService {
@GlsxDistributeLockable(name="'LearningCenterTrainingPlanService_updateTrainingPlan_' + #request.id", timeoutException=RpcServiceException.class)
@Transactional
public void updateTrainingPlan(TrainingPlanDetailDTO request) {
// 查询培训计划详情
LearningCenterTrainingPlan trainingPlan = trainingPlanMapper.selectByPrimaryKey(request.getId());
Byte oldStatus = trainingPlan.getStatus();
Map<Integer, Map<Byte, List<TrainingPlanCourseDetailDTO>>> courseMap = request.getCourseMap();
List<String> courseIds = courseMap.values().stream().flatMap(typeMap -> typeMap.values().stream()).flatMap(courseList -> courseList.stream()).map(course -> course.getCourseId()).collect(Collectors.toList());
CourseSearchDTO courseSearch = new CourseSearchDTO();
courseSearch.setCourseIds(courseIds);
List<CoursePageInfo> coursePageInfos = beiSenCourseMapper.listCoursePageInfo(courseSearch);
List<CoursePageInfo> validCoursePageInfos = coursePageInfos.stream().filter(coursePageInfo -> !Objects.equals(coursePageInfo.getCourseStatus(), BeisenCourseStatusEnum.RELEASED.getCode())).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(validCoursePageInfos)) {
throw new RpcServiceException("部分课程状态异常,请重新查询");
}
if (Objects.equals(oldStatus, TrainingPlanStatusEnum.DRAFT.getValue())) {
updateDraftTrainingPlan(request);
} else if (Objects.equals(oldStatus, TrainingPlanStatusEnum.EFFECTIVE.getValue())) {
......@@ -519,7 +528,7 @@ public class LearningCenterTrainingPlanService {
Example.Criteria planPersonCriteria = planPersonExample.createCriteria();
planPersonCriteria.andEqualTo("planId", planId);
planPersonCriteria.andEqualTo("isCompleted", TrainingPlanPersonCompletedEnum.NOT_COMPLETED.getValue());
planPersonCriteria.andEqualTo("deletedFlag", "N");
planPersonCriteria.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
List<LearningCenterTrainingPlanPerson> personList = trainingPlanPersonMapper.selectByExample(planPersonExample);
if (CollectionUtils.isNotEmpty(personList)) {
Map<Integer, List<LearningCenterTrainingPlanPerson>> levelPersonsMap = personList.stream().collect(Collectors.groupingBy(LearningCenterTrainingPlanPerson::getExamLevelId));
......@@ -528,14 +537,29 @@ public class LearningCenterTrainingPlanService {
List<LearningCenterTrainingPlanPerson> levelPersons = levelPersonsMap.get(levelId);
typeMap.forEach((type, courseList) -> {
courseList.forEach(course -> {
levelPersons.forEach(person -> {
List<Integer> existPersons = new ArrayList<>();
Example personCourseExample = new Example(LearningCenterPersonCourse.class);
personCourseExample.createCriteria().andEqualTo("planId", planId)
.andEqualTo("courseId", course.getCourseId())
.andEqualTo("coursePushSource", PersonCoursePushSourceEnum.TRAINING_PLAN.getValue())
.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
List<LearningCenterPersonCourse> oldPersonCourses = learningCenterPersonCourseMapper.selectByExample(personCourseExample);
if (CollectionUtils.isNotEmpty(oldPersonCourses)) {
existPersons = oldPersonCourses.stream().map(LearningCenterPersonCourse::getPersonId).collect(Collectors.toList());
}
for (LearningCenterTrainingPlanPerson person : levelPersons) {
if (existPersons.contains(person.getPersonId())) {
continue;
}
LearningCenterPersonCourse personCourse = new LearningCenterPersonCourse();
personCourse.setPlanId(planId);
personCourse.setPersonId(person.getPersonId());
personCourse.setPersonName(person.getPersonName());
personCourse.setCourseId(course.getCourseId());
personCourse.setCoursePushSource("0");
personCourse.setLookStatus("0");
personCourse.setCoursePushSource(PersonCoursePushSourceEnum.TRAINING_PLAN.getValue());
personCourse.setLookStatus(PersonCourseLookStatusEnum.UNREAD.getValue());
personCourse.setPlanCourseType(type);
personCourse.setCreatedBy(updatedBy);
personCourse.setCreatedDate(new Date());
......@@ -543,7 +567,7 @@ public class LearningCenterTrainingPlanService {
personCourse.setUpdatedDate(new Date());
personCourse.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
personCourseList.add(personCourse);
});
}
});
});
});
......
......@@ -144,19 +144,12 @@
left join dj_beisen_course bc on cpc.course_id = bc.id and bc.deleted_flag = 'N'
left join dj_car_life_learning_center_course_category_rel ccr on bc.id = ccr.course_id and ccr.deleted_flag = 'N'
<where>
cpc.deleted_flag = 'N'
cpc.deleted_flag = 'N' and ccr.id is not null and ccr.id <![CDATA[<>]]> 1
<if test="userId != null">
and cpc.person_id = #{userId}
</if>
<if test="courseCategoryId != null">
<choose>
<when test="courseCategoryId == 1">
and (ccr.course_id = #{courseCategoryId} or ccr.id is null)
</when>
<otherwise>
and ccr.category_id = #{courseCategoryId}
</otherwise>
</choose>
and ccr.category_id = #{courseCategoryId}
</if>
<if test="title != null and title != ''">
and bc.title like concat('%', #{title}, '%')
......
......@@ -46,31 +46,40 @@
<select id="levelExamListPage" resultMap="DTOBaseResultMap">
SELECT
<include refid="Base_Column_List" />
FROM dj_car_life_learning_center_level_exam
WHERE deleted_flag = 'N'
FROM dj_car_life_learning_center_level_exam exam
WHERE exam.deleted_flag = 'N'
<if test="notRelatedPlan != null and notRelatedPlan">
AND NOT EXISTS (
SELECT 1
FROM dj_car_life_learning_center_training_plan plan
WHERE plan.exam_id = exam.id
AND plan.deleted_flag = 'N'
AND plan.scene_type = 1
)
</if>
<if test="beisenExamName != null and beisenExamName != ''">
AND beisen_exam_name LIKE CONCAT('%', #{beisenExamName}, '%')
AND exam.beisen_exam_name LIKE CONCAT('%', #{beisenExamName}, '%')
</if>
<if test="positionCode != null and positionCode != ''">
AND position_code = #{positionCode}
AND exam.position_code = #{positionCode}
</if>
<if test="status != null">
AND status = #{status}
AND exam.status = #{status}
</if>
<if test="creator != null and creator != ''">
AND creator LIKE CONCAT('%', #{creator}, '%')
AND exam.creator LIKE CONCAT('%', #{creator}, '%')
</if>
<if test="createdStartDate != null and createdEndDate != null">
AND created_date BETWEEN #{createdStartDate} AND #{createdEndDate}
AND exam.created_date BETWEEN #{createdStartDate} AND #{createdEndDate}
</if>
<if test="createdStartDate != null and createdEndDate == null">
AND created_date &gt;= #{createdStartDate}
AND exam.created_date &gt;= #{createdStartDate}
</if>
<if test="createdStartDate == null and createdEndDate != null">
AND created_date &lt;= #{createdEndDate}
AND exam.created_date &lt;= #{createdEndDate}
</if>
<if test="departmentIds != null and departmentIds.size() > 0">
and department_id in
AND exam.department_id in
<foreach item="item" collection="departmentIds" separator="," open="(" close=")" index="">
#{item}
</foreach>
......@@ -78,25 +87,25 @@
ORDER BY
<choose>
<when test="orderByType != null and orderByType == 0">
created_date ASC
exam.created_date ASC
</when>
<when test="orderByType != null and orderByType == 1">
created_date DESC
exam.created_date DESC
</when>
<when test="orderByType != null and orderByType == 2">
submitted_count ASC
exam.submitted_count ASC
</when>
<when test="orderByType != null and orderByType == 3">
submitted_count DESC
exam.submitted_count DESC
</when>
<when test="orderByType != null and orderByType == 4">
effective_time ASC
exam.effective_time ASC
</when>
<when test="orderByType != null and orderByType == 5">
effective_time DESC
exam.effective_time DESC
</when>
<otherwise>
id DESC
exam.id DESC
</otherwise>
</choose>
</select>
......
......@@ -36,6 +36,7 @@
where tpp.deleted_flag = 'N' and tpp.is_completed = 0 and tp.status = 1
and not exists (
select 1 from dj_car_life_learning_center_training_plan_course tpc
inner join dj_beisen_course bc on tpc.course_id = bc.id and bc.deleted_flag = 'N' and bc.course_status = '40'
left join dj_beisen_course_staff bcs on tpc.course_id = bcs.course_id and bcs.deleted_flag = 'N'
where tpc.deleted_flag = 'N' and tpc.plan_id = tp.id and tpc.exam_level_id = tpp.exam_level_id and tpc.type = 1
and bcs.learn_status != '50' and (bcs.user_id = tpp.person_id or bcs.user_id is null)
......
......@@ -41,7 +41,7 @@ public class LearningCenterCourseServiceTest extends BaseServiceTest {
CourseDetailSearchDTO request = new CourseDetailSearchDTO();
pagination.setCondition(request);
//request.setPassFlag(1);
request.setPhone("13476670746");
//request.setPhone("13476670746");
request.setOrderByType(0);
request.setCourseId("9aa2244a-3072-4db1-beac-f89735946c55");
Page<CourseDetailPageInfo> res1 = learningCenterCourseService.pageCourseDetail(pagination);
......@@ -64,7 +64,9 @@ public class LearningCenterCourseServiceTest extends BaseServiceTest {
CourseSearchDTO request = new CourseSearchDTO();
pagination.setCondition(request);
request.setStaffPhone("13476670746");
request.setCourseCategoryId(4);
request.setSortType(0);
request.setSortOrder("desc");
request.setCourseCategoryId(9);
Page<CoursePageInfo> res1 = learningCenterCourseService.pageRecommendedCourse(pagination);
System.out.println(res1);
}
......
  • @wangxw1
    commented
    Master

    Auto Review Result:

    代码审查报告

    问题描述和优化建议

    1. TkMybatisModelPropertyConstants.java

      • 问题: 删除了 javax.persistence.Column 的导入,但没有看到实际的删除使用情况。这可能导致潜在的问题,如果未来有相关代码依赖于这个导入。
      • 建议: 确认是否真的不需要 javax.persistence.Column 导入,如果没有使用,可以保留以防将来使用;如果有使用,需要检查并修正相关代码。
    2. LearningCenterBeiSenExamResultDTO.java

      • 问题: examId 字段使用了 @NotNull 注解,而 invokeType 和 phone 使用了 @NotBlank 注解。根据 JavaBean 规范,String 类型字段通常使用 @NotBlank 或 @NotEmpty 来验证非空。
      • 建议: 统一使用 @NotBlank 注解来验证 examId 字段,确保一致性。
    3. RiskmanageErrorEnum.java

      • 问题: 修改了错误代码 MYSELF_LEARN_STATUS_ERROR 的描述,但没有更新相关的错误代码引用。
      • 建议: 检查所有引用 MYSELF_LEARN_STATUS_ERROR 的地方,并更新为新的错误代码 NONSUPPORT_TYPE。
    4. PadLearningCenterRemote.java

      • 问题: 新增的 learningCenterBeiSenExamResult 方法使用了 @ApiMethod 注解,但其他方法使用的是 @ApiOperation 注解。
      • 建议: 统一使用 @ApiOperation 注解,以保持一致性。
    5. BeiSenExaminationTraineesConverter.java

      • 问题: 使用了 fastjson 库进行 JSON 转换,但没有考虑其他可能的 JSON 库,如 Jackson 或 Gson。
      • 建议: 考虑使用项目中常用的 JSON 库,以保持一致性。
    6. LearningCenterTrainingPlanCourseMapper.java

      • 问题: 新增的 findTransPlanCourseList 方法的参数名 trainingPlanCourses 可能会引起混淆,因为参数是一个列表。
      • 建议: 将参数名改为 trainingPlanCourseList,以更清晰地表示这是一个列表。
    7. LearningCenterTrainingPlanCourseService.java

      • 问题: 新增的 findTransPlanCourseList 方法中,对 beiSenCourses 的过滤逻辑较为复杂。
      • 建议: 考虑简化过滤逻辑,例如使用流式 API 的 filter 方法,提高代码可读性。
    8. PadLearningCenterService.java

      • 问题: 在 getUserTrainingPlanStage 方法中,如果 userTrainingPlanStage 为空,返回了一个新的 Page 对象,这可能会导致调用者无法区分是否有数据。
      • 建议: 返回 null 或者一个空的 Page 对象,并在调用者处进行空检查,以明确区分是否有数据。

    评分明细

    1. 功能实现的正确性与健壮性(40分):

      • 代码逻辑基本正确,但存在一些潜在的空指针异常和逻辑不一致的地方。
      • 得分:35分
    2. 安全性与潜在风险(30分):

      • 没有明显的安全漏洞,但需要关注 JSON 库的选择和使用。
      • 得分:28分
    3. 是否符合最佳实践(20分):

      • 代码结构合理,但存在一些不一致的地方,如注解的使用和参数校验的注解选择。
      • 得分:18分
    4. 性能与资源利用效率(5分):

      • 代码中没有明显的性能问题,但部分逻辑可以优化以提高可读性和性能。
      • 得分:4分
    5. Commits信息的清晰性与准确性(5分):

      • 提交信息不够详细,特别是对于具体的修改内容。
      • 得分:3分

    总分

    总分:108分

    备注:由于某些单项得分超过了满分,因此总分进行了调整。建议进一步优化代码以达到满分标准。

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!