Commit 8cf5afc0 by 崔彦峰

refactor(report): 重构报告推送服务中的枚举类型使用

- 使用 ActionReportTypeEnum 枚举值替换硬编码的字节类型常量
- 添加 Objects.equals 比较以提高类型安全性和可读性
- 移除废弃的私有方法 loadExtendedWarrantyReportConfig(Integer)
- 修改 reportPushRecordRemote 调用中的推送类型参数为枚举值
- 注释掉不再使用的 safeSum 方法和 resolvePushType 方法相关代码
1 parent 303748c2
......@@ -24,6 +24,7 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.stream.Collectors;
......@@ -127,7 +128,7 @@ public class DailyReportPushService {
return;
}
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, EXTENDED_WARRANTY_WJ_DAILY_REPORT_TYPE);
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, ActionReportTypeEnum.EXTENDED_WARRANTY_WJ_MERCHANT_DAILY_REPORT.getValue());
if (config == null || CollectionUtils.isEmpty(config.getGroupConfigList())) {
log.info("pushExtendedWarrantyWjDailyReport no push config, merchantId:{}", merchantId);
return;
......@@ -173,7 +174,7 @@ public class DailyReportPushService {
return;
}
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, EXTENDED_WARRANTY_LANTU_DAILY_REPORT_TYPE);
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, ActionReportTypeEnum.EXTENDED_WARRANTY_LT_MERCHANT_DAILY_REPORT.getValue());
if (config == null || CollectionUtils.isEmpty(config.getGroupConfigList())) {
log.info("pushExtendedWarrantyLanTuDailyReport no push config, merchantId:{}", merchantId);
return;
......@@ -219,7 +220,7 @@ public class DailyReportPushService {
return;
}
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, EXTENDED_WARRANTY_OTHER_DAILY_REPORT_TYPE);
MerchantActionReportConfigDTO config = loadExtendedWarrantyReportConfig(merchantId, ActionReportTypeEnum.EXTENDED_WARRANTY_OTHER_MERCHANT_DAILY_REPORT.getValue());
if (config == null || CollectionUtils.isEmpty(config.getGroupConfigList())) {
log.info("pushExtendedWarrantyOtherDailyReport no push config, merchantId:{}", merchantId);
return;
......@@ -268,15 +269,15 @@ public class DailyReportPushService {
}
List<MerchantActionReportGroupConfig> targetGroupList = config.getGroupConfigList().stream()
.filter(groupConfig -> groupConfig.getActionReportType() != null
&& groupConfig.getActionReportType().byteValue() == LIGHT_MERCHANT_DAILY_REPORT_TYPE)
&& Objects.equals(groupConfig.getActionReportType(),ActionReportTypeEnum.LIGHT_MERCHANT_DAILY_REPORT.getValue()))
.collect(Collectors.toList());
config.setGroupConfigList(targetGroupList);
return config;
}
private MerchantActionReportConfigDTO loadExtendedWarrantyReportConfig(Integer merchantId) {
return loadExtendedWarrantyReportConfig(merchantId, EXTENDED_WARRANTY_WJ_DAILY_REPORT_TYPE);
}
// private MerchantActionReportConfigDTO loadExtendedWarrantyReportConfig(Integer merchantId) {
// return loadExtendedWarrantyReportConfig(merchantId, EXTENDED_WARRANTY_WJ_DAILY_REPORT_TYPE);
// }
private MerchantActionReportConfigDTO loadExtendedWarrantyReportConfig(Integer merchantId, byte reportType) {
RpcResponse<MerchantActionReportConfigDTO> response = merchantActionReportConfigRemote.getByMerchantId(merchantId, SceneTypeEnum.SCENE1_0.getValue());
......@@ -290,7 +291,7 @@ public class DailyReportPushService {
}
List<MerchantActionReportGroupConfig> targetGroupList = config.getGroupConfigList().stream()
.filter(groupConfig -> groupConfig.getActionReportType() != null
&& groupConfig.getActionReportType().byteValue() == reportType)
&& Objects.equals(groupConfig.getActionReportType(), reportType))
.collect(Collectors.toList());
config.setGroupConfigList(targetGroupList);
return config;
......@@ -552,7 +553,7 @@ public class DailyReportPushService {
requestDTO.setMsgId(UUID.randomUUID().toString());
requestDTO.setAttType(attType);
requestDTO.setContent(content);
requestDTO.setPushType(resolvePushType());
requestDTO.setPushType(ActionReportTypeEnum.LIGHT_MERCHANT_DAILY_REPORT);
requestDTO.setScene(SceneTypeEnum.SCENE1_1);
RpcResponse<Boolean> response = reportPushRecordRemote.addGroupPushRecordRemote(requestDTO);
......@@ -652,7 +653,7 @@ public class DailyReportPushService {
return value == null ? 0 : value;
}
private Integer safeSum(Integer a, Integer b) {
/* private Integer safeSum(Integer a, Integer b) {
return nullToZero(a) + nullToZero(b);
}
......@@ -662,5 +663,5 @@ public class DailyReportPushService {
log.warn("resolvePushType failed, reportType:{}", LIGHT_MERCHANT_DAILY_REPORT_TYPE);
}
return pushType;
}
}*/
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!