Commit 4f898dd5 authored by tianbo's avatar tianbo

refactor(amos-boot-module-jg): 重构设备质量评分更新逻辑

- 引入 EquipmentCategoryService 以替代直接使用 equipmentCategoryDao - 使用 saveWithImmediateRefresh 方法替代原有的 save 方法,以确保数据实时更新
parent bf012fb0
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity; import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto; import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.biz.service.impl.EquipmentCategoryService;
import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto; import com.yeejoin.amos.boot.module.jg.api.dto.ReminderItemDto;
import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory; import com.yeejoin.amos.boot.module.jg.biz.reminder.biz.factory.GradeStrategyFactory;
import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent; import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEditEvent;
...@@ -18,6 +19,7 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo; ...@@ -18,6 +19,7 @@ import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -44,6 +46,9 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate { ...@@ -44,6 +46,9 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate {
private final GradeStrategyFactory gradeStrategyFactory; private final GradeStrategyFactory gradeStrategyFactory;
@Autowired
EquipmentCategoryService equipmentCategoryService;
@Override @Override
public Boolean support(EquipCreateOrEditEvent.EquipType equipType) { public Boolean support(EquipCreateOrEditEvent.EquipType equipType) {
return EquipCreateOrEditEvent.EquipType.equip.equals(equipType); return EquipCreateOrEditEvent.EquipType.equip.equals(equipType);
...@@ -61,7 +66,7 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate { ...@@ -61,7 +66,7 @@ public class EquipQualityScoreUpdateService implements IQualityScoreUpdate {
Integer level = this.getReminderLevel(bizType, record); Integer level = this.getReminderLevel(bizType, record);
op.ifPresent(equipmentCategory -> { op.ifPresent(equipmentCategory -> {
equipmentCategory.setDataQualityScore(level); equipmentCategory.setDataQualityScore(level);
equipmentCategoryDao.save(equipmentCategory); equipmentCategoryService.saveWithImmediateRefresh(equipmentCategory);
}); });
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>(); LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, record); updateWrapper.eq(IdxBizJgUseInfo::getRecord, record);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment