|
|
@ -3,10 +3,7 @@ package com.example.demo.serviceImpl.coin; |
|
|
import cn.hutool.log.AbstractLog; |
|
|
import cn.hutool.log.AbstractLog; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.write.handler.SheetWriteHandler; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; |
|
|
|
|
|
import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; |
|
|
|
|
|
import com.example.demo.Util.ExcelHeaderTranslator; |
|
|
import com.example.demo.Util.ExcelHeaderTranslator; |
|
|
import com.example.demo.Util.ExcelUploadUtil; |
|
|
import com.example.demo.Util.ExcelUploadUtil; |
|
|
import com.example.demo.Util.JWTUtil; |
|
|
import com.example.demo.Util.JWTUtil; |
|
|
@ -22,18 +19,15 @@ import com.example.demo.controller.coin.RefundController; |
|
|
import com.example.demo.domain.entity.Admin; |
|
|
import com.example.demo.domain.entity.Admin; |
|
|
import com.example.demo.domain.entity.Export; |
|
|
import com.example.demo.domain.entity.Export; |
|
|
import com.example.demo.domain.entity.User; |
|
|
import com.example.demo.domain.entity.User; |
|
|
import com.example.demo.domain.export.Goldmingxi; |
|
|
|
|
|
import com.example.demo.domain.vo.bean.*; |
|
|
import com.example.demo.domain.vo.bean.*; |
|
|
|
|
|
|
|
|
import com.example.demo.domain.vo.cash.CashCollection; |
|
|
import com.example.demo.domain.vo.cash.CashCollection; |
|
|
import com.example.demo.domain.vo.cash.CashRecordDTO; |
|
|
import com.example.demo.domain.vo.cash.CashRecordDTO; |
|
|
|
|
|
import com.example.demo.domain.vo.cash.PerformanceVO; |
|
|
import com.example.demo.domain.vo.coin.*; |
|
|
import com.example.demo.domain.vo.coin.*; |
|
|
|
|
|
|
|
|
import com.example.demo.mapper.cash.CashRefundMapper; |
|
|
|
|
|
import com.example.demo.mapper.coin.ExportMapper; |
|
|
import com.example.demo.mapper.coin.ExportMapper; |
|
|
import com.example.demo.service.cash.RefundService; |
|
|
|
|
|
import com.example.demo.service.coin.ExportExcelService; |
|
|
import com.example.demo.service.coin.ExportExcelService; |
|
|
import com.example.demo.serviceImpl.cash.CashRefundServiceImpl; |
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.JsonNode; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
import com.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
|
|
|
|
|
@ -42,19 +36,13 @@ import com.example.demo.service.coin.AiEmotionService; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.poi.ss.formula.functions.Finance; |
|
|
|
|
|
import org.apache.xmlbeans.impl.xb.xsdschema.Attribute; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
import org.springframework.security.authentication.AuthenticationManager; |
|
|
import org.springframework.security.core.Authentication; |
|
|
|
|
|
import org.springframework.security.core.context.SecurityContextHolder; |
|
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
import java.io.*; |
|
|
import java.text.ParseException; |
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.function.Function; |
|
|
import java.util.function.Function; |
|
|
|
|
|
|
|
|
@ -239,6 +227,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception LiveExcel(String message) throws Exception { |
|
|
public Exception LiveExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "liveUser", page -> { |
|
|
return exportExcelGeneric(message, "liveUser", page -> { |
|
|
@ -261,6 +250,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception FanExcel(String message) throws Exception { |
|
|
public Exception FanExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "fanUser", page -> { |
|
|
return exportExcelGeneric(message, "fanUser", page -> { |
|
|
@ -283,6 +273,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception ArticleExcel(String message) throws Exception { |
|
|
public Exception ArticleExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "articleUser", page -> { |
|
|
return exportExcelGeneric(message, "articleUser", page -> { |
|
|
@ -305,6 +296,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception BeanExcel(String message) throws Exception { |
|
|
public Exception BeanExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "beanUser", page -> { |
|
|
return exportExcelGeneric(message, "beanUser", page -> { |
|
|
@ -327,6 +319,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception OnlineExcel(String message) throws Exception { |
|
|
public Exception OnlineExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "onlineUser", page -> { |
|
|
return exportExcelGeneric(message, "onlineUser", page -> { |
|
|
@ -349,6 +342,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception FinanceExcel(String message) throws Exception { |
|
|
public Exception FinanceExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "financeUser", page -> { |
|
|
return exportExcelGeneric(message, "financeUser", page -> { |
|
|
@ -371,6 +365,7 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
@Override |
|
|
@Override |
|
|
public Exception CashExcel(String message) throws Exception { |
|
|
public Exception CashExcel(String message) throws Exception { |
|
|
return exportExcelGeneric(message, "cashUser", page -> { |
|
|
return exportExcelGeneric(message, "cashUser", page -> { |
|
|
@ -393,6 +388,29 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Transactional |
|
|
|
|
|
@Override |
|
|
|
|
|
public Exception PerformanceExcel(String message) throws Exception { |
|
|
|
|
|
return exportExcelGeneric(message, "performanceUser", page -> { |
|
|
|
|
|
try { |
|
|
|
|
|
JsonNode rootNode = objectMapper.readTree(message); |
|
|
|
|
|
JsonNode requestDataNode = rootNode.path("requestData"); |
|
|
|
|
|
JsonNode beanRechargeNode = requestDataNode.path("performanceVO"); |
|
|
|
|
|
PerformanceVO performanceVO = objectMapper.treeToValue(beanRechargeNode, PerformanceVO.class); |
|
|
|
|
|
page.setPerformanceVO(performanceVO); |
|
|
|
|
|
// 从请求数据中获取语言设置,如果没有则使用默认值 |
|
|
|
|
|
String lang = "zh_CN"; |
|
|
|
|
|
JsonNode langNode = requestDataNode.path("lang"); |
|
|
|
|
|
if (langNode != null && !langNode.asText().isEmpty()) { |
|
|
|
|
|
lang = langNode.asText(); |
|
|
|
|
|
} |
|
|
|
|
|
return cashCollectionController.performanceSelect(page, lang); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public List<Export> getExcel(Export export) { |
|
|
public List<Export> getExcel(Export export) { |
|
|
List<Export> list = exportMapper.getExportRecord(export.getAccount(),export.getType()); |
|
|
List<Export> list = exportMapper.getExportRecord(export.getAccount(),export.getType()); |
|
|
@ -702,6 +720,26 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1") |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1") |
|
|
.head(head) |
|
|
.head(head) |
|
|
.build(); |
|
|
.build(); |
|
|
|
|
|
} |
|
|
|
|
|
// 如果是业绩归属表,添加动态表头处理器 |
|
|
|
|
|
else if ("performanceUser".equals(exportType)) { |
|
|
|
|
|
Map<String, String> headers = excelHeaderTranslator.getPerformanceHeaders(lang); |
|
|
|
|
|
List<String> columnOrder = excelHeaderTranslator.getPerformanceColumnOrder(); |
|
|
|
|
|
|
|
|
|
|
|
// 构建自定义表头 |
|
|
|
|
|
List<List<String>> head = new ArrayList<>(); |
|
|
|
|
|
for (String fieldName : columnOrder) { |
|
|
|
|
|
String headerText = headers.get(fieldName); |
|
|
|
|
|
if (headerText != null) { |
|
|
|
|
|
List<String> headItems = new ArrayList<>(); |
|
|
|
|
|
headItems.add(headerText); |
|
|
|
|
|
head.add(headItems); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
writeSheet = EasyExcel.writerSheet("Sheet1") |
|
|
|
|
|
.head(head) |
|
|
|
|
|
.build(); |
|
|
} else { |
|
|
} else { |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|
|
writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|
|
} |
|
|
} |
|
|
@ -804,6 +842,11 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
translateUserList((List<User>) list, lang); |
|
|
translateUserList((List<User>) list, lang); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 添加业绩归属翻译支持 |
|
|
|
|
|
if ("performanceUser".equals(exportType) && list.get(0) instanceof PerformanceVO) { |
|
|
|
|
|
translatePerformanceList((List<PerformanceVO>) list, lang); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
excelWriter.write(list, writeSheet); |
|
|
excelWriter.write(list, writeSheet); |
|
|
page.setPageNum(page.getPageNum() + 1); |
|
|
page.setPageNum(page.getPageNum() + 1); |
|
|
totalCount += list.size(); |
|
|
totalCount += list.size(); |
|
|
@ -952,6 +995,8 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
return CashRecordDTO.class; |
|
|
return CashRecordDTO.class; |
|
|
case "cashUser": |
|
|
case "cashUser": |
|
|
return CashCollection.class; |
|
|
return CashCollection.class; |
|
|
|
|
|
case "performanceUser": |
|
|
|
|
|
return PerformanceVO.class; |
|
|
default: |
|
|
default: |
|
|
throw new IllegalArgumentException("不支持的导出类型: " + exportType); |
|
|
throw new IllegalArgumentException("不支持的导出类型: " + exportType); |
|
|
} |
|
|
} |
|
|
@ -1516,4 +1561,29 @@ public class ExportExcelServiceImpl implements ExportExcelService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 翻译业绩归属列表 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void translatePerformanceList(List<PerformanceVO> list, String lang) { |
|
|
|
|
|
if (list == null || list.isEmpty() || "zh_CN".equalsIgnoreCase(lang) || "zh".equalsIgnoreCase(lang)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
for (PerformanceVO item : list) { |
|
|
|
|
|
// 翻译所属地区名称 |
|
|
|
|
|
if (item.getMarketName() != null && !item.getMarketName().isEmpty()) { |
|
|
|
|
|
item.setMarketName(languageTranslationUtil.translate(item.getMarketName(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译付款币种 |
|
|
|
|
|
if (item.getPaymentCurrency() != null && !item.getPaymentCurrency().isEmpty()) { |
|
|
|
|
|
item.setPaymentCurrency(languageTranslationUtil.translate(item.getPaymentCurrency(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 翻译到账币种 |
|
|
|
|
|
if (item.getReceivedCurrency() != null && !item.getReceivedCurrency().isEmpty()) { |
|
|
|
|
|
item.setReceivedCurrency(languageTranslationUtil.translate(item.getReceivedCurrency(), lang)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |