Commit 8e0f89a0 by 林永健

fix(sync): 修复BeiSen课程同步中的数值属性处理

- 将课程相关数值字段转换为BigDecimal类型以保证精度
- 同步新增totalCredit、totalDuration、totalDurationSecond、totalStar字段
- 优化更新判断逻辑,增加对数值字段变更的检测
- 修改复制属性时手动设置数值字段以避免拷贝失败影响主流程
1 parent a22b21bd
package cn.com.glsx.dj.riskmanage.service.beisen.sync.impl; package cn.com.glsx.dj.riskmanage.service.beisen.sync.impl;
import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -121,10 +122,19 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons ...@@ -121,10 +122,19 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons
List<BeiSenCourse> toInsert = new ArrayList<>(); List<BeiSenCourse> toInsert = new ArrayList<>();
for (GetCourseListDataItemResponseDTO item : items) { for (GetCourseListDataItemResponseDTO item : items) {
BeiSenCourse existItem = existMap.get(item.getId()); BeiSenCourse existItem = existMap.get(item.getId());
BigDecimal itemTotalDuration = item.getTotalDuration() == null ? null : BigDecimal.valueOf(item.getTotalDuration());
BigDecimal itemTotalStar = item.getTotalStar() == null ? null : BigDecimal.valueOf(item.getTotalStar());
BigDecimal itemTotalDurationSecond = item.getTotalDurationSecond() == null ? null : BigDecimal.valueOf(item.getTotalDurationSecond());
BigDecimal itemTotalCredit = item.getTotalCredit() == null ? null : BigDecimal.valueOf(item.getTotalCredit());
if (existItem == null) { if (existItem == null) {
BeiSenCourse course = new BeiSenCourse(); BeiSenCourse course = new BeiSenCourse();
try { try {
BeanUtils.copyProperties(course, item); BeanUtils.copyProperties(course, item);
course.setTotalCredit(itemTotalCredit);
course.setTotalDuration(itemTotalDuration);
course.setTotalDurationSecond(itemTotalDurationSecond);
course.setTotalStar(itemTotalStar);
} catch (Exception e) { } catch (Exception e) {
// Bean 属性拷贝失败时不影响主流程,仅保留必要字段 // Bean 属性拷贝失败时不影响主流程,仅保留必要字段
} }
...@@ -141,6 +151,8 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons ...@@ -141,6 +151,8 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons
} else { } else {
boolean changed = !Objects.equals(item.getModifiedTime(), existItem.getModifiedTime()) boolean changed = !Objects.equals(item.getModifiedTime(), existItem.getModifiedTime())
|| !Objects.equals(item.getLearnTotal(), existItem.getLearnTotal()) || !Objects.equals(item.getLearnTotal(), existItem.getLearnTotal())
|| !Objects.equals(itemTotalStar, existItem.getTotalStar())
|| !Objects.equals(itemTotalDuration, existItem.getTotalDuration())
|| !Objects.equals(item.getLearnCount(), existItem.getLearnCount()) || !Objects.equals(item.getLearnCount(), existItem.getLearnCount())
|| !Objects.equals(item.getOrganizationV2(), existItem.getOrganization()) || !Objects.equals(item.getOrganizationV2(), existItem.getOrganization())
|| !Objects.equals(item.getPageView(), existItem.getPageView()) || !Objects.equals(item.getPageView(), existItem.getPageView())
...@@ -152,6 +164,10 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons ...@@ -152,6 +164,10 @@ public class CourseSync extends AbstractPageSync<PageQueryRequestDTO, RpcRespons
existItem.getLearnTotal(), item.getLearnTotal(), existItem.getLearnCount(), item.getLearnCount(), existItem.getLearnTotal(), item.getLearnTotal(), existItem.getLearnCount(), item.getLearnCount(),
existItem.getPageView(), item.getPageView()); existItem.getPageView(), item.getPageView());
CopyUtils.copyIgnoreNullProperties(item, existItem); CopyUtils.copyIgnoreNullProperties(item, existItem);
existItem.setTotalCredit(itemTotalCredit);
existItem.setTotalDuration(itemTotalDuration);
existItem.setTotalDurationSecond(itemTotalDurationSecond);
existItem.setTotalStar(itemTotalStar);
existItem.setOrganization(item.getOrganizationV2()); existItem.setOrganization(item.getOrganizationV2());
existItem.setUpdatedBy("system"); existItem.setUpdatedBy("system");
existItem.setUpdatedTime(new Date()); existItem.setUpdatedTime(new Date());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!