|
@@ -1,21 +1,11 @@
|
|
|
-import cn.hutool.core.collection.ListUtil;
|
|
|
-import cn.hutool.core.io.FileUtil;
|
|
|
-import com.alibaba.excel.EasyExcel;
|
|
|
-import com.alibaba.excel.ExcelWriter;
|
|
|
-import com.alibaba.excel.metadata.Head;
|
|
|
-import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
|
|
-import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
-import com.alibaba.excel.write.metadata.fill.FillConfig;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.sd.SdApplication;
|
|
|
import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.production.dto.StockPreparationDto;
|
|
|
import com.sd.business.entity.production.vo.UncompletedVo;
|
|
|
-import com.sd.business.entity.statement.bo.ExportDocumentByOrderBo;
|
|
|
import com.sd.business.entity.statement.dto.GetDocumentDto;
|
|
|
import com.sd.business.entity.statement.vo.DocumentByOrderVo;
|
|
|
import com.sd.business.service.order.OrderService;
|
|
@@ -23,23 +13,17 @@ import com.sd.business.service.production.StockPreparationService;
|
|
|
import com.sd.business.service.statement.StatementOfAccountMergeService;
|
|
|
import com.sd.wln.service.WlnStatementOfAccount;
|
|
|
import com.sd.wln.util.WlnUtil;
|
|
|
-import lombok.SneakyThrows;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.InputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.nio.charset.Charset;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@RunWith(SpringRunner.class)
|
|
@@ -155,137 +139,140 @@ public class TestList {
|
|
|
System.out.println(JSON.toJSONString(collect));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- @SneakyThrows
|
|
|
public static void main(String[] args) {
|
|
|
-
|
|
|
- String str2 = FileUtil.readString("E:\\新建文本文档2.txt", Charset.defaultCharset());
|
|
|
- List<DocumentByOrderVo> list = JSON.parseArray(str2).toJavaList(DocumentByOrderVo.class);
|
|
|
-
|
|
|
- String str = FileUtil.readString("E:\\新建文本文档.txt", Charset.defaultCharset());
|
|
|
-
|
|
|
- JSONObject json = JSON.parseObject(str);
|
|
|
- List<ExportDocumentByOrderBo> exportDocumentByOrderBos = (List<ExportDocumentByOrderBo>) json.remove("exportDocumentByOrderBos");
|
|
|
-
|
|
|
- String filePath = "tempExcel" + File.separator + IdWorker.getId() + ".xlsx";
|
|
|
- File tempExcel = new File("tempExcel");
|
|
|
- if (!tempExcel.exists()) {
|
|
|
- tempExcel.mkdir();
|
|
|
- }
|
|
|
- FileOutputStream os = new FileOutputStream(filePath);
|
|
|
-
|
|
|
- ClassPathResource classPathResource = new ClassPathResource("template" + File.separator + "orderDocument.xlsx");
|
|
|
- InputStream is = classPathResource.getInputStream();
|
|
|
- ExcelWriter excelWriter = EasyExcel.write(os).withTemplate(is).build();
|
|
|
- try {
|
|
|
- A strategy = new A(list);
|
|
|
- WriteSheet writeSheet = EasyExcel.writerSheet().registerWriteHandler(strategy).build();
|
|
|
- FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
|
|
-
|
|
|
- System.out.println("写入1");
|
|
|
- excelWriter.fill(json, fillConfig, writeSheet);
|
|
|
- System.out.println("写入2");
|
|
|
- List<ExportDocumentByOrderBo> ssss = ListUtil.partition(exportDocumentByOrderBos, 100).get(0);
|
|
|
- excelWriter.fill(exportDocumentByOrderBos, fillConfig, writeSheet);
|
|
|
- System.out.println("写入完成");
|
|
|
- } finally {
|
|
|
- if (excelWriter != null) {
|
|
|
- excelWriter.finish();
|
|
|
- excelWriter.close();
|
|
|
- }
|
|
|
- os.close();
|
|
|
- is.close();
|
|
|
- }
|
|
|
-
|
|
|
+ String a = "{\n" +
|
|
|
+ " \"idGroupConcat\": \"1699739286011727873,1702638389020454914,1700101673936044034,1700464061822562305,1702276001603575809,1700826449696530434,1701928713001660417,1701551225520091137,1701106726288019458,1701106725822451713,1701106725755342850,1701106725625319426,1701106725558210565,1701106725558210564,1699376899223990273\"\n" +
|
|
|
+ "}";
|
|
|
+ System.out.println(a);
|
|
|
}
|
|
|
|
|
|
- private static class A extends AbstractMergeStrategy {
|
|
|
-
|
|
|
-
|
|
|
- private final int mergeRowIndex = 2;
|
|
|
-
|
|
|
-
|
|
|
- private final List<Integer> skuColIndex = Arrays.asList(3, 4, 5, 16, 17, 18, 19);
|
|
|
-
|
|
|
- private final List<Integer> skuRowIndex = new ArrayList<>();
|
|
|
-
|
|
|
-
|
|
|
- private final List<Integer> orderRowIndex = new ArrayList<>();
|
|
|
-
|
|
|
- private final List<Integer> orderColIndex = Arrays.asList(0, 1, 2, 20, 21);
|
|
|
|
|
|
- public A(List<DocumentByOrderVo> documentByOrderVoList) {
|
|
|
-
|
|
|
- for (DocumentByOrderVo documentByOrderVo : documentByOrderVoList) {
|
|
|
- List<DocumentByOrderVo.SkuSpec> skuSpecList = documentByOrderVo.getSkuSpecList();
|
|
|
-
|
|
|
-
|
|
|
- Integer size = skuSpecList.stream().map(item -> item.getBomSpecList().size()).reduce(0, Integer::sum);
|
|
|
- int orderRowIndexNumber = orderRowIndex.size() == 0 ? mergeRowIndex : orderRowIndex.get(orderRowIndex.size() - 1);
|
|
|
- orderRowIndex.add(size + orderRowIndexNumber);
|
|
|
-
|
|
|
-
|
|
|
- for (DocumentByOrderVo.SkuSpec skuSpec : skuSpecList) {
|
|
|
- int bomSpecListSize = skuSpec.getBomSpecList().size();
|
|
|
- int skuRowIndexSize = skuRowIndex.size();
|
|
|
- int skuRowIndexNumber = skuRowIndexSize == 0 ? mergeRowIndex : skuRowIndex.get(skuRowIndexSize - 1);
|
|
|
- skuRowIndex.add(bomSpecListSize + skuRowIndexNumber);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void merge(Sheet sheet, Cell cell, Head head, Integer relativeRowIndex) {
|
|
|
-
|
|
|
-
|
|
|
- int curRowIndex = cell.getRowIndex(), curColIndex = cell.getColumnIndex();
|
|
|
-
|
|
|
-
|
|
|
- if (curRowIndex <= mergeRowIndex) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (orderColIndex.contains(curColIndex) && orderRowIndex.contains(curRowIndex)) {
|
|
|
- int i = orderRowIndex.indexOf(curRowIndex);
|
|
|
- if (i == 0) {
|
|
|
- mergeWithPrevRow(sheet, mergeRowIndex, curRowIndex, curColIndex);
|
|
|
- } else {
|
|
|
- Integer row = orderRowIndex.get(i - 1);
|
|
|
- mergeWithPrevRow(sheet, row, curRowIndex, curColIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- else if (skuColIndex.contains(curColIndex) && skuRowIndex.contains(curRowIndex)) {
|
|
|
- int i = skuRowIndex.indexOf(curRowIndex);
|
|
|
- if (i == 0) {
|
|
|
- mergeWithPrevRow(sheet, mergeRowIndex, curRowIndex, curColIndex);
|
|
|
- } else {
|
|
|
- Integer row = skuRowIndex.get(i - 1);
|
|
|
- mergeWithPrevRow(sheet, row, curRowIndex, curColIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- * 合并单元格
|
|
|
- */
|
|
|
- private void mergeWithPrevRow(Sheet sheet, int beginRow, int endRow, int col) {
|
|
|
- CellRangeAddress cellRangeAddress = new CellRangeAddress(beginRow + 1, endRow, col, col);
|
|
|
- sheet.addMergedRegionUnsafe(cellRangeAddress);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|