Browse Source

1月21日.Excel导出翻译优化

huangqizheng/feature-20260113143035-现金管理0109
wangguorui 1 month ago
parent
commit
bfc2d63f2c
  1. 4
      src/main/java/com/example/demo/Util/ExcelHeaderTranslator.java
  2. 6
      src/main/java/com/example/demo/controller/coin/ExportController.java
  3. 7
      src/main/java/com/example/demo/domain/vo/bean/BeanConsumeFan.java
  4. 36
      src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java

4
src/main/java/com/example/demo/Util/ExcelHeaderTranslator.java

@ -411,7 +411,7 @@ public class ExcelHeaderTranslator {
headers.put("freeBean", "免费金豆数"); headers.put("freeBean", "免费金豆数");
headers.put("buyBean", "付费金豆数"); headers.put("buyBean", "付费金豆数");
headers.put("channel", "频道"); headers.put("channel", "频道");
headers.put("type", "会员类型");
headers.put("typeDesc", "会员类型");
headers.put("consumeTime", "加入时间"); headers.put("consumeTime", "加入时间");
// 如果需要翻译则翻译表头 // 如果需要翻译则翻译表头
@ -428,7 +428,7 @@ public class ExcelHeaderTranslator {
public List<String> getBeanConsumeFanColumnOrder() { public List<String> getBeanConsumeFanColumnOrder() {
return Arrays.asList( return Arrays.asList(
"id", "name", "jwcode", "dept", "beanNum", "freeBean", "buyBean", "id", "name", "jwcode", "dept", "beanNum", "freeBean", "buyBean",
"channel", "type", "consumeTime"
"channel", "typeDesc", "consumeTime"
); );
} }

6
src/main/java/com/example/demo/controller/coin/ExportController.java

@ -597,10 +597,10 @@ public class ExportController {
} }
// 转换会员类型 // 转换会员类型
if (beanConsumeFan.getType() != null && !beanConsumeFan.getType().isEmpty()) {
if (beanConsumeFan.getTypeDesc() != null && !beanConsumeFan.getTypeDesc().isEmpty()) {
String chineseType = translationService.findChineseSimplifiedByTranslation( String chineseType = translationService.findChineseSimplifiedByTranslation(
beanConsumeFan.getType(), languageCode);
beanConsumeFan.setType(chineseType);
beanConsumeFan.getTypeDesc(), languageCode);
beanConsumeFan.setTypeDesc(chineseType);
} }
} }
} }

7
src/main/java/com/example/demo/domain/vo/bean/BeanConsumeFan.java

@ -1,8 +1,6 @@
package com.example.demo.domain.vo.bean; package com.example.demo.domain.vo.bean;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.example.demo.config.MemberTypeStringConverter;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
@ -36,8 +34,9 @@ public class BeanConsumeFan implements Serializable {
private String freeBean; //免费金豆 private String freeBean; //免费金豆
private String buyBean; //付费金豆 private String buyBean; //付费金豆
private String channel; //频道名称source_name private String channel; //频道名称source_name
@ExcelProperty(value = "", converter = MemberTypeStringConverter.class)
private String type; //类型source_type 7单月8连续包月
@ExcelIgnore
private Integer type; //类型source_type 7单月8连续包月
private String typeDesc;
//@ExcelProperty("支付方式") //@ExcelProperty("支付方式")
@ExcelIgnore @ExcelIgnore
private Integer payType; //支付方式直播12345铁粉7文章8 private Integer payType; //支付方式直播12345铁粉7文章8

36
src/main/java/com/example/demo/serviceImpl/coin/ExportExcelServiceImpl.java

@ -852,6 +852,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
// 添加铁粉用户翻译支持 // 添加铁粉用户翻译支持
if ("fanUser".equals(exportType) && list.get(0) instanceof BeanConsumeFan) { if ("fanUser".equals(exportType) && list.get(0) instanceof BeanConsumeFan) {
fillUserMemberStatusDescriptions((List<BeanConsumeFan>) list);
translateBeanConsumeFanList((List<BeanConsumeFan>) list, lang); translateBeanConsumeFanList((List<BeanConsumeFan>) list, lang);
} }
@ -1056,6 +1057,31 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
/** /**
* 填充用户会员的状态描述
*/
private void fillUserMemberStatusDescriptions(List<BeanConsumeFan> fans) {
if (fans != null && !fans.isEmpty()) {
for (BeanConsumeFan fan : fans) {
if (fan.getType() != null) {
fan.setTypeDesc(fanTypeToString(fan.getType()));
}
}
}
}
/**
* 将会员类型数字转换为中文描述
*/
private String fanTypeToString(Integer type) {
if (type == null) return "";
switch (type) {
case 7: return "单次付费";
case 8: return "连续包月";
default: return "其他";
}
}
/**
* 填充用户数据的状态描述 * 填充用户数据的状态描述
*/ */
private void fillUserStatusDescriptions(List<FundsDTO> funds) { private void fillUserStatusDescriptions(List<FundsDTO> funds) {
@ -1067,6 +1093,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
} }
} }
/** /**
* 将类型数字转换为中文描述 * 将类型数字转换为中文描述
*/ */
@ -1205,8 +1232,8 @@ public class ExportExcelServiceImpl implements ExportExcelService {
private String convertIsBackpackGiftToString(Integer isBackpackGift) { private String convertIsBackpackGiftToString(Integer isBackpackGift) {
if (isBackpackGift == null) return ""; if (isBackpackGift == null) return "";
switch (isBackpackGift) { switch (isBackpackGift) {
case 0: return "";
case 1: return "";
case 0: return "";
case 1: return "";
default: return "未知"; default: return "未知";
} }
} }
@ -1224,6 +1251,7 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
} }
} }
/** /**
* 将充值平台数字转换为中文描述 * 将充值平台数字转换为中文描述
*/ */
@ -1448,8 +1476,8 @@ public class ExportExcelServiceImpl implements ExportExcelService {
} }
// 翻译会员类型 // 翻译会员类型
if (item.getType() != null && !item.getType().isEmpty()) {
item.setType(languageTranslationUtil.translate(item.getType(), lang));
if (item.getTypeDesc() != null && !item.getTypeDesc().isEmpty()) {
item.setTypeDesc(languageTranslationUtil.translate(item.getTypeDesc(), lang));
} }
} }
} }

Loading…
Cancel
Save