Commit 9781e83e by ghxdhr

原始记录修改

parent c79981d7
...@@ -29,11 +29,11 @@ public class OriginalFactory { ...@@ -29,11 +29,11 @@ public class OriginalFactory {
if (null == template.getSampleBeginRow()|| null==template.getSampleMergerNum()||null==template.getTemplateSampleNum()){ if (null == template.getSampleBeginRow()|| null==template.getSampleMergerNum()||null==template.getTemplateSampleNum()){
return null; return null;
} }
if (voList.size()<template.getTemplateSampleNum()){ // if (voList.size()<template.getTemplateSampleNum()){
return new SingleSheetLittleOperation(template,voList,entrust,configList,xssfWorkbook); // return new SingleSheetLittleOperation(template,voList,entrust,configList,xssfWorkbook);
}else{ // }else{
return new SingleSheetMoreOperation(template,voList,entrust,configList,xssfWorkbook); return new SingleSheetMoreOperation(template,voList,entrust,configList,xssfWorkbook);
} // }
}else{ }else{
Integer templateSampleNum = template.getTemplateSampleNum(); Integer templateSampleNum = template.getTemplateSampleNum();
......
...@@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils; ...@@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -21,6 +22,7 @@ public class SingleSheetMoreOperation implements Operation { ...@@ -21,6 +22,7 @@ public class SingleSheetMoreOperation implements Operation {
private Entrust entrust ; private Entrust entrust ;
private List<OriginalTemplateConfig> configList; private List<OriginalTemplateConfig> configList;
private XSSFWorkbook xssfWorkbook; private XSSFWorkbook xssfWorkbook;
private String collectionDataPrefix = "clc.";
public SingleSheetMoreOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) { public SingleSheetMoreOperation(OriginalTemplate template, List<EntrustSampleItemVO> voList, Entrust entrust, List<OriginalTemplateConfig> configList, XSSFWorkbook xssfWorkbook) {
this.template = template; this.template = template;
this.voList = voList; this.voList = voList;
...@@ -173,5 +175,52 @@ public class SingleSheetMoreOperation implements Operation { ...@@ -173,5 +175,52 @@ public class SingleSheetMoreOperation implements Operation {
} }
} }
} }
// 处理曲线和空白
dealCurveAndBlank(configList,voList,template,xssfWorkbook);
}
private void dealCurveAndBlank(List<OriginalTemplateConfig> configList, List<EntrustSampleItemVO> voList, OriginalTemplate template, XSSFWorkbook xssfWorkbook) {
Integer curveBeginNum = template.getCurveBeginNum();
Integer blankBeginNum = template.getBlankBeginNum();
List<Map<String,String>> curveDataList = null;
Map<String,String> blankDataMap = null;
XSSFSheet sheet = xssfWorkbook.getSheetAt(0);
if (CollectionUtils.isNotEmpty(voList)) {
curveDataList = voList.get(0).getCurveDataList();
blankDataMap = voList.get(0).getBlankDataMap();
}
// 填充曲线数据
if (curveBeginNum != null && CollectionUtils.isNotEmpty(curveDataList)) {
int index = 0;
for (int i = curveBeginNum; i < curveBeginNum + curveDataList.size(); i++) {
XSSFRow row = sheet.getRow(i);
for (OriginalTemplateConfig config : configList) {
if (null == config.getColumnPlace()) {
continue;
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(curveDataList.get(index).get(config.getDataAttribute().substring(collectionDataPrefix.length())));
}
}
}
index++;
}
// 填充空白
if (blankBeginNum != null && blankDataMap != null && blankDataMap.size() > 0) {
XSSFRow row = sheet.getRow(blankBeginNum);
// 只插固定一行
for (OriginalTemplateConfig config : configList) {
if (null == config.getColumnPlace()) {
continue;
}
if (null != config.getDataAttribute() && config.getDataAttribute().startsWith(collectionDataPrefix)) {
XSSFCell cell = row.getCell(config.getColumnPlace());
cell.setCellValue(blankDataMap.get(config.getDataAttribute().substring(collectionDataPrefix.length())));
}
}
}
} }
} }
...@@ -1282,7 +1282,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust> ...@@ -1282,7 +1282,7 @@ public class EntrustServiceImpl extends BaseServiceImpl<EntrustMapper, Entrust>
private ByteArrayOutputStream getEntrustBaos() { private ByteArrayOutputStream getEntrustBaos() {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("\\templates.\\word.\\entrust.\\EntrustExportTemplate.docx"); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("\\templates\\word\\entrust\\EntrustExportTemplate.docx");
RestAssert.fail(null == inputStream, "委托检测书模板获取失败"); RestAssert.fail(null == inputStream, "委托检测书模板获取失败");
byte[] buffer = new byte[1024]; byte[] buffer = new byte[1024];
int len; int len;
......
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