Commit 8c7fb381 by lijingjing

Merge remote-tracking branch 'origin/master'

parents 1542bba8 66455bdc
......@@ -961,8 +961,10 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
mapReplace.put("#{sampleFrom}", list.size() > 0 ? list.get(0).getSampleFrom() : " - ");
list = sampleList.stream().filter(s -> StringUtils.isNotEmpty(s.getName())).collect(Collectors.toList());
mapReplace.put("#{sampleName}", list.size() > 0 ? list.get(0).getName() : " - ");
HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, 0);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(0);
int numberOfSheets = xssfWorkbook.getNumberOfSheets();
for (int k = 0; k < numberOfSheets; k++) {
HSSFWorkbookUtil.replaceModel(mapReplace, xssfWorkbook, k);
XSSFSheet sheetOne = xssfWorkbook.getSheetAt(k);
String sheetName = sheetOne.getSheetName();
System.out.println(sheetName);
sheetOne.setForceFormulaRecalculation(true);
......@@ -971,12 +973,24 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
int templateSampleNum = sysFileTemplate.getTemplateSampleNum();
if (templateSampleNum >= sampleVOList.size()) {
Integer beginRow = sysFileTemplate.getSampleBeginRow();
HashMap<Long, List<EntrustSampleItemIndex>> indexMap = new HashMap<>();
for (EntrustSampleVO vo : sampleVOList) {
// List<EntrustSampleItemIndex> indexList = entrustSampleItemIndexService.listBySampleId(vo.getId());
List<EntrustSampleItemIndex> indexList = entrustSampleItemIndexService.getInReportItemIndex(vo.getId());
List<EntrustSampleItemIndex> indexList = new ArrayList<>();
if (indexMap.containsKey(vo.getId())) {
indexList = indexMap.get(vo.getId());
} else {
indexList = entrustSampleItemIndexService.getInReportItemIndex(vo.getId());
}
vo.setIndexList(indexList);
XSSFRow xssfRow = sheetOne.getRow(beginRow);
for (EntrustReportTemplateConfig config : configList) {
if (null != config.getSheetNum() && config.getSheetNum() != k) {
continue;
}
if (null == config.getColumnPlace()) {
continue;
}
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
if ("sn".equals(config.getDataAttribute())) {
continue;
......@@ -989,35 +1003,6 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
beginRow += sampleMergerNum;
}
String generated = entrust.getCode();
FileOutputStream os = null;
File file = null;
try {
file = File.createTempFile(generated, ".xlsx");
os = new FileOutputStream(file);
xssfWorkbook.write(os);
os.flush();
entrustReportService.uploadReportGenerateDocx(entrust, ids, account, StringHandleUtils.join(sampleNameSet), "报告生成", file);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
xssfWorkbook.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
io.close();
} catch (IOException e) {
e.printStackTrace();
}
FileUtils.deleteFiles(file);
}
} else {
......@@ -1028,7 +1013,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
for (int i = 1; i < totalSheetSize; i++) {
xssfWorkbook.cloneSheet(0, sheetOne.getSheetName() + (i + 1));
}
for (int k = 0; k < listList.size(); k++) {
for (int m = 0; m < listList.size(); m++) {
Integer beginRow = sysFileTemplate.getSampleBeginRow();
List<EntrustSampleVO> sampleVOListIndex = listList.get(k);
......@@ -1053,8 +1038,6 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
beginRow += sampleMergerNum;
}
}
} else {
Integer beginRow = sysFileTemplate.getSampleBeginRow();
int insertRow = beginRow + sampleMergerNum * templateSampleNum;
......@@ -1081,6 +1064,9 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
List<EntrustSampleItemIndex> indexList = entrustSampleItemIndexService.listBySampleId(vo.getId());
vo.setIndexList(indexList);
for (EntrustReportTemplateConfig config : configList) {
if (null != config.getSheetNum() && config.getSheetNum() != k) {
continue;
}
if (null == config.getColumnPlace()) {
continue;
}
......@@ -1122,6 +1108,7 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
}
}
String generated = entrust.getCode();
FileOutputStream os = null;
File file = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment