Commit d22c38d4 by 王璐琦

refactor(service): 移除无用的 notDeliveryCount 字段设置

- 删除 DailyReportRecordService 中对 notDeliveryCount 字段的硬编码赋值
feat(scene): 按商户ID和场景类型查询场景列表

- 新增 MerchantIdAndSceneRequest 请求类,支持按商户ID和场景类型查询
- 创建 MerchantActivateBaseSceneCodesResponse 响应类,封装基础场景码信息
- 添加 NewMerchantSceneDTOConvert 转换器,将 DTO 转为响应类
- rpc-dj-smartcarlife-api 增加 findByMerchantIdAndSceneType 接口声明
- rpc-dj-smartcarlife 实现 findByMerchantIdAndSceneType 方法,增加异常处理
- SceneMerchantRefService 新增按商户ID和场景类型筛选场景逻辑
- SceneMerchantRefCarBoutiqueController 增加新接口 dj.api.scenemerchantref.findByMerchantIdAndSceneType
- 调整相关pom依赖版本号,确保接口依赖一致性
1 parent b68c6d94
......@@ -30,6 +30,7 @@ import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.scrm.equity.enums.DeleteFlagEnum;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
......@@ -309,7 +310,20 @@ public class DailyReportRecordService {
continue;
}
try {
Integer deliveryCount = getIntField(fieldDataList, deliveryFieldKey);
Integer deliveryCount = getDeliveryCountField(fieldDataList, deliveryFieldKey);
// 同步更新员工日报华为品牌-交付数
StaffDailyReportHuawei deliveryUpdate = new StaffDailyReportHuawei();
deliveryUpdate.setMerchantId(merchantId);
deliveryUpdate.setYqMerchantId(yqMerchantId);
deliveryUpdate.setReportDate(dailyReportRecordDTO.getReportDate());
deliveryUpdate.setFirstBrandId(carBrand.getFirstBrandId());
deliveryUpdate.setBrandId(carBrand.getBrandId());
deliveryUpdate.setSceneType(sceneType);
deliveryUpdate.setDeliveryCount(deliveryCount);
deliveryUpdate.setUpdatedBy(dailyReportRecordDTO.getUpdatedBy());
deliveryUpdate.setUpdatedDate(new Date());
staffDailyReportRemote.updateStaffDailyReportHuaweiDeliveryCount(deliveryUpdate);
MerchantDailyReportHuawei report = new MerchantDailyReportHuawei();
report.setMerchantId(merchantId);
......@@ -554,6 +568,8 @@ public class DailyReportRecordService {
boolean isScene1 = Objects.equals(SceneTypeEnum.SCENE1_1.getValue(), sceneType);
boolean isScene0 = Objects.equals(SceneTypeEnum.SCENE1_0.getValue(), sceneType);
Map<String, Integer> brandDeliveryCountMap = isScene1 ? calcDeliveryCount(merchantId, sceneType, dto.getReportDate()) : null;
List<DailyReportCarBrandDTO> carBrandList = dto.getCarBrandList();
if (CollectionUtils.isEmpty(carBrandList)) {
return;
......@@ -575,6 +591,14 @@ public class DailyReportRecordService {
huaweiBrandMap.put(shangjieId, new HuaweiBrandKeys(DailyReportFieldEnum.F1_8_1, DailyReportFieldEnum.F1_8_2, DailyReportFieldEnum.F1_8_3, DailyReportFieldEnum.F1_8_4, DailyReportFieldEnum.F1_8_5, DailyReportFieldEnum.F1_8_6));
huaweiBrandMap.put(zunjieId, new HuaweiBrandKeys(DailyReportFieldEnum.F1_9_1, DailyReportFieldEnum.F1_9_2, DailyReportFieldEnum.F1_9_3, DailyReportFieldEnum.F1_9_4, DailyReportFieldEnum.F1_9_5, DailyReportFieldEnum.F1_9_6));
// brandId → deliveryFieldKey 映射
Map<Integer, String> brandDeliveryFieldMap = new HashMap<>();
brandDeliveryFieldMap.put(aitoId, DailyReportFieldEnum.F2_18.getValue());
brandDeliveryFieldMap.put(xiangjieId, DailyReportFieldEnum.F2_19.getValue());
brandDeliveryFieldMap.put(zhijieId, DailyReportFieldEnum.F2_20.getValue());
brandDeliveryFieldMap.put(shangjieId, DailyReportFieldEnum.F2_21.getValue());
brandDeliveryFieldMap.put(zunjieId, DailyReportFieldEnum.F2_22.getValue());
// 其他品牌+岚图 同步标识
boolean otherBrandSynced = false;
......@@ -600,6 +624,7 @@ public class DailyReportRecordService {
Integer afterSaleExtendedWarrantyToShopCount = null;
Integer afterSaleRealEquityToShopCount = null;
Integer notDeliveryReturnCount = null;
Integer deliveryCount = null;
if (isHuaweiBrand) {
HuaweiBrandKeys keys = huaweiBrandMap.get(carBrand.getBrandId());
......@@ -607,6 +632,8 @@ public class DailyReportRecordService {
equityToShopCount = getIntField(fieldDataList, keys.lightVisitCount.getValue())
+ getIntField(fieldDataList, keys.lightDeliveryReferralCount.getValue());
afterSaleEquityToShopCount = getIntField(fieldDataList, keys.lightAfterSaleVisitCount.getValue());
String deliveryFieldKey = brandDeliveryFieldMap.get(carBrand.getBrandId());
deliveryCount = brandDeliveryCountMap != null && deliveryFieldKey != null ? brandDeliveryCountMap.get(deliveryFieldKey) : null;
}
if (isScene0) {
extendedWarrantyToShopCount = getIntField(fieldDataList, keys.extWarrantyPreSaleVisitCount.getValue());
......@@ -658,6 +685,7 @@ public class DailyReportRecordService {
report.setAfterSaleExtendedWarrantyToShopCount(afterSaleExtendedWarrantyToShopCount);
report.setAfterSaleRealEquityToShopCount(afterSaleRealEquityToShopCount);
report.setNotDeliveryReturnCount(notDeliveryReturnCount);
report.setDeliveryCount(deliveryCount);
staffDailyReportRemote.saveStaffDailyReportHuawei(report);
log.info("syncStaffDailyReportHuawei success, merchantId={}, brand={}, staffUuid={}",
......@@ -687,6 +715,77 @@ public class DailyReportRecordService {
}
/**
* 从 fieldDataList 中获取指定 key 的 int 值,未找到返回 null
*/
private Integer getDeliveryCountField(List<DailyReportFieldDataDTO> fieldDataList, String key) {
if (CollectionUtils.isEmpty(fieldDataList)) {
return null;
}
return fieldDataList.stream()
.filter(f -> Objects.equals(f.getFieldKey(), key))
.findFirst()
.map(f -> {
try {
return Integer.parseInt(f.getFieldValue());
} catch (NumberFormatException e) {
return null;
}
})
.orElse(null);
}
/**
* 查询门店日报门店端实际交车数(仅轻改场景)
*/
private Map<String, Integer> calcDeliveryCount(Integer merchantId, Byte sceneType, String reportDate) {
// 查询日报记录
Example recordExample = new Example(DailyReportRecord.class);
recordExample.createCriteria()
.andEqualTo("merchantId", merchantId)
.andEqualTo("sceneType", sceneType)
.andEqualTo("templateType", DailyReportTemplateTypeEnum.MERCHANT_DAILY_REPORT.getValue())
.andEqualTo("reportDate", reportDate)
.andEqualTo("reportStatus", DailyReportReportStatusEnum.SUBMITTED.getValue())
.andEqualTo("deletedFlag", DeleteFlagEnum.N.getValue());
List<DailyReportRecord> records = dailyReportRecordMapper.selectByExample(recordExample);
if (CollectionUtils.isEmpty(records)) {
return Maps.newHashMap();
}
Integer reportRecordId = records.get(0).getId();
// 查询品牌交车字段数据
List<String> deliveryFieldKeys = Arrays.asList(
DailyReportFieldEnum.F2_18.getValue(),
DailyReportFieldEnum.F2_19.getValue(),
DailyReportFieldEnum.F2_20.getValue(),
DailyReportFieldEnum.F2_21.getValue(),
DailyReportFieldEnum.F2_22.getValue()
);
Example fieldExample = new Example(DailyReportFieldData.class);
fieldExample.createCriteria()
.andEqualTo("reportRecordId", reportRecordId)
.andIn("fieldKey", deliveryFieldKeys)
.andEqualTo("deletedFlag", DeleteFlagEnum.N.getValue());
List<DailyReportFieldData> fieldDataList = dailyReportFieldDataMapper.selectByExample(fieldExample);
if (CollectionUtils.isEmpty(fieldDataList)) {
return Maps.newHashMap();
}
return fieldDataList.stream()
.filter(f -> f.getFieldValue() != null)
.collect(Collectors.toMap(
DailyReportFieldData::getFieldKey,
f -> {
try {
return Integer.parseInt(f.getFieldValue());
} catch (NumberFormatException e) {
return 0;
}
},
(a, b) -> a
));
}
/**
* @description: 草稿日报数据保存
* @param: [dailyReportRecordDTO]
* @return: java.lang.Boolean
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!