Commit 8f117267 by lijingjing

修改存在检测值为 0 没有格式化的问题;

优化铝成品发送erp数据逻辑;
parent 82c4226f
......@@ -96,7 +96,9 @@ public class SingleSheetMoreItemOperation implements Operation {
// 提取属性对应公式
Map<String, String> formulaMap = this.configList.stream().filter(t -> Objects.nonNull(t.getFormula()))
.collect(Collectors.toMap(OriginalTemplateConfig::getAttributeName, OriginalTemplateConfig::getFormula));
// 此处获取对应的格式
Map<Integer, XSSFCellStyle> cellStyleMap = new HashMap<Integer, XSSFCellStyle>(20);
// ==
int insertCount = voList.size() - templateSampleNum;
for (int m = 0; m < insertCount; m++) {
for (int i = 0; i < sampleMergerNum; i++) {
......@@ -104,9 +106,15 @@ public class SingleSheetMoreItemOperation implements Operation {
XSSFRow row = sheetOne.createRow(insertRow);
row.setHeight(zeroRow.getHeight());
for (int j = 0; j < lastCellNum; j++) {
XSSFCellStyle cellStyle = zeroRow.getCell(j).getCellStyle();
// 从map中取值
XSSFCellStyle cellStyle = cellStyleMap.get(j);
if (Objects.isNull(cellStyle)) {
cellStyle = zeroRow.getCell(j).getCellStyle();
cellStyleMap.put(j, cellStyle);
}
XSSFCell xssfCell = row.createCell(j);
xssfCell.setCellStyle(cellStyle);
// 根据标题行处理公式
// 若标题(Si%等等)为空,那么不进行处理,如若不为空,再根据是否存在公式进行处理
String title = hideRow.getCell(j).getStringCellValue();
......@@ -141,6 +149,10 @@ public class SingleSheetMoreItemOperation implements Operation {
}
for (OriginalTemplateConfig config : configList) {
XSSFCell cell = xssfRow.getCell(config.getColumnPlace());
// 处理样品丢失问题
if (null != cell.getCellStyle() && Objects.equals("General", cell.getCellStyle().getDataFormatString())) {
cell.setCellStyle(cellStyleMap.get(config.getColumnPlace()));
}
XSSFCell cell2 = null;
XSSFCell cell3 = null;
XSSFCell cell4 = null;
......
......@@ -415,7 +415,8 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
List<SoilItemCollectData> soilItemList = new ArrayList<>();
// 声明格式化内容map
Map<String, String> itemFormatMap = new HashMap<>(16);
for (int i = sampleBeginRow; i <= lastRowNum; i += sampleMergerNum) {
XSSFRow xssfRow = sheet.getRow(i);
if (null == xssfRow) {
......@@ -425,6 +426,7 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
String sampleCode = HSSFWorkbookUtil.getJavaValue(sampleCodeCell).toString();
for (ItemCollectEntity collectEntity : collectEntitiesList) {
String itemName = collectEntity.getItemName();
if (null != collectEntity.getSingleElse()) {
XSSFRow row = sheet.getRow(collectEntity.getItemMegerRow());
if (null == row) {
......@@ -450,6 +452,10 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
}
XSSFCell itemCell = xssfRow.getCell(collectEntity.getColumnPlace());
if (null == itemCell) {
continue;
}
String value = "";
try {
value = CellFormat.getInstance(itemCell.getCellStyle().getDataFormatString()).apply(itemCell).text;
......@@ -457,11 +463,10 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
value = HSSFWorkbookUtil.getJavaValue(itemCell).toString();
}
String itemName = collectEntity.getItemName();
if (StringUtils.isBlank(value)) {
continue;
}
SoilItemCollectData soilItemCollectData = new SoilItemCollectData();
soilItemCollectData.setItemName(itemName);
soilItemCollectData.setTestValue(value.trim());
......@@ -574,6 +579,23 @@ public class OriginalTemplateServiceImpl extends BaseServiceImpl<OriginalTemplat
return true;
}
/**
* 获取单元格样式
*
* @param itemFormatMap
* @param itemName
* @param cell
* @return
*/
private String getDataFormatStr(Map<String, String> itemFormatMap, String itemName, XSSFCell cell) {
String cellFormat = itemFormatMap.get(itemName);
if (StringUtils.isBlank(cellFormat)) {
cellFormat = cell.getCellStyle().getDataFormatString();
itemFormatMap.put(itemName, cellFormat);
}
return cellFormat;
}
@Override
public boolean editTemplate(String someParam, OssFileResult obsFileResult) {
......
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