Commit 049d8353 by 杨卫

feat:1047852:导入代码优化

1 parent 2a11f9c0
......@@ -85,12 +85,17 @@ public class MerchantProfitRecordListener extends AnalysisEventListener<Merchant
data.getErrors().addAll(errors);
}
String uniqueKey = StrUtil.join(SymbolConstants.DASH, data.getStoreId(), data.getBusinessType(), data.getMonthYear());
if (parsedUniqueKeys.contains(uniqueKey)) {
data.getErrors().add("重复数据");
Long storeId = data.getStoreId();
String businessType = data.getBusinessType();
String monthYear = data.getMonthYear();
if (ObjectUtil.isNotNull(storeId) && StrUtil.isNotBlank(businessType) && StrUtil.isNotBlank(monthYear)) {
String uniqueKey = StrUtil.join(SymbolConstants.DASH, storeId, businessType, monthYear);
if (parsedUniqueKeys.contains(uniqueKey)) {
data.getErrors().add("重复数据");
}
parsedUniqueKeys.add(uniqueKey);
}
parsedUniqueKeys.add(uniqueKey);
exportDataMap.put(context.readRowHolder().getRowIndex(), data);
}
......
......@@ -213,10 +213,10 @@ public class BiAnalyseBackgroundService {
Map<Integer, MerchantProfitRecordExcelImportDTO> importError = MapUtil.<Integer, MerchantProfitRecordExcelImportDTO>builder().build();
// 计算进度条,批量远程调用
List<Integer> indexList = Lists.newArrayList(readDataMap.keySet());
List<Integer> indexList = readDataMap.keySet().stream().sorted(Integer::compareTo).collect(Collectors.toList());
List<List<Integer>> partition = ListUtil.partition(indexList, 200);
for (List<Integer> indexes : partition) {
Map<Integer, MerchantProfitRecordImportDataDTO> batch = MapUtil.<Integer, MerchantProfitRecordImportDataDTO>builder().build();
LinkedHashMap<Integer, MerchantProfitRecordImportDataDTO> batch = new LinkedHashMap<>(indexes.size());
for (Integer index : indexes) {
batch.put(index, merchantProfitRecordConvert.merchantProfitRecordExcelDto2Dto(readDataMap.get(index)));
}
......@@ -328,6 +328,7 @@ public class BiAnalyseBackgroundService {
*/
public Map<Integer, MerchantProfitRecordExcelImportDTO> readExcelHandler(SingleUploadRequest request) {
Map<Integer, MerchantProfitRecordExcelImportDTO> exportDataMap = MapUtil.newHashMap(true);
try (InputStream inputstream = new BufferedInputStream(new ByteArrayInputStream(request.getFile().getContent()))) {
EasyExcel.read(inputstream, MerchantProfitRecordExcelImportDTO.class, new MerchantProfitRecordListener(exportDataMap))
.sheet()
......
......@@ -64,9 +64,21 @@ public class BiAnalyseBackgroundControllerTest extends BaseControllerTest {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
params.add("v", "1.0.0");
params.add("method", "dj.api.script.merchant.bi.matter.handle");
params.add("id", "2");
params.add("handlingStrategy", "giaogiaogiaogiao,hahahaha,nika lufu");
params.add("sessionId", "6daef60d-58aa-4503-a4b8-d7d55785f452");
params.add("id", "12");
params.add("handlingStrategy", "i know, come off it!");
params.add("sessionId", "174765eb-b6fc-4ad4-ac1b-71d2022cd182");
System.out.println(post(params));
}
@Test
public void testMerchantBiMatterHandle2() throws Exception {
MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
params.add("v", "1.0.0");
params.add("method", "dj.api.script.merchant.bi.matter.handle");
params.add("id", "12");
params.add("handlingStrategy", "i know, come off it!");
params.add("sessionId", "174765eb-b6fc-4ad4-ac1b-71d2022cd182");
System.out.println(post(params));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!