Commit f272d2f1 authored by qinhu's avatar qinhu

质量管理报告--下标去掉null

parent cdd1a981
...@@ -84,5 +84,4 @@ public class QualityController { ...@@ -84,5 +84,4 @@ public class QualityController {
public BaseResponse<QualityDetailVo> getReportDetail(@PathVariable("entrustId") Integer entrustId) { public BaseResponse<QualityDetailVo> getReportDetail(@PathVariable("entrustId") Integer entrustId) {
return BaseResponse.okData(iEntrustService.getQualityDetail(entrustId)); return BaseResponse.okData(iEntrustService.getQualityDetail(entrustId));
} }
} }
...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON; ...@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -154,22 +155,22 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua ...@@ -154,22 +155,22 @@ public class QualityApplyServiceImpl extends ServiceImpl<QualityApplyMapper, Qua
List<String> inputValus = JSON.parseArray(arg.getInputResult(), String.class); List<String> inputValus = JSON.parseArray(arg.getInputResult(), String.class);
Object[] objs = new Object[inputValus.size() + 8]; Object[] objs = new Object[inputValus.size() + 8];
if (!"误差".equals(arg.getUserName())) { if (!"误差".equals(arg.getUserName())) {
objs[0] = arg.getProjectName(); objs[0] = arg.getProjectName() == null ? "" : arg.getProjectName();
objs[1] = arg.getProjectId(); objs[1] = arg.getProjectId() == null ? "" : arg.getProjectId();
objs[2] = arg.getSampleName(); objs[2] = arg.getSampleName() == null ? "" : arg.getSampleName();
objs[3] = arg.getSampleForm(); objs[3] = arg.getSampleForm() == null ? "" : arg.getSampleForm();
objs[4] = arg.getSampleCode(); objs[4] = arg.getSampleCode() == null ? "" : arg.getSampleCode();
objs[5] = arg.getCementCode(); objs[5] = arg.getCementCode() == null ? "" : arg.getCementCode();
objs[6] = userGroupMap.get(arg.getUserId()); objs[6] = userGroupMap.get(arg.getUserId());
} }
//添加名字 //添加名字
objs[7] = arg.getUserName(); objs[7] = arg.getUserName();
for (int i = 0; i < inputValus.size(); i++) { for (int i = 0; i < inputValus.size(); i++) {
String value = inputValus.get(i); String value = inputValus.get(i);
if (value == null){ if (value == null) {
value = "0"; value = "0";
} }
if ( value.contains("\"")) { if (value.contains("\"")) {
value = value.replace("\"", ""); value = value.replace("\"", "");
} }
objs[8 + i] = value; objs[8 + i] = value;
......
...@@ -116,6 +116,7 @@ public class ExcelUtil { ...@@ -116,6 +116,7 @@ public class ExcelUtil {
} }
} }
} }
public static void excelExportNew(String fileName, String[] headers, List<Object[]> datas, public static void excelExportNew(String fileName, String[] headers, List<Object[]> datas,
HttpServletResponse response) { HttpServletResponse response) {
Workbook workbook = getWorkbookNew(headers, datas); Workbook workbook = getWorkbookNew(headers, datas);
...@@ -152,6 +153,7 @@ public class ExcelUtil { ...@@ -152,6 +153,7 @@ public class ExcelUtil {
} }
} }
} }
/** /**
* @param headers 列头 * @param headers 列头
* @param datas 数据 * @param datas 数据
...@@ -201,27 +203,28 @@ public class ExcelUtil { ...@@ -201,27 +203,28 @@ public class ExcelUtil {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
String value = data[i] == null ? null : data[i].toString(); String value = data[i] == null ? null : data[i].toString();
cell = row.createCell(i); cell = row.createCell(i);
if (value != null) {
//处理下标 //处理下标
if(value.contains("<sub>") || value.contains("</sub>") ){ if (value.contains("<sub>") || value.contains("</sub>")) {
xxsfFont.setTypeOffset(FontFormatting.SS_SUB); xxsfFont.setTypeOffset(FontFormatting.SS_SUB);
cell.setCellStyle(style); cell.setCellStyle(style);
XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sub>","<sub>").replaceAll("<sub>","")); XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sub>", "<sub>").replaceAll("<sub>", ""));
//提取下标位置 //提取下标位置
applyRichStringFontsub(value, richString, xxsfFont); applyRichStringFontsub(value, richString, xxsfFont);
cell.setCellValue(richString); cell.setCellValue(richString);
}else if(value.contains("<sup>") || value.contains("</sup>")){ } else if (value.contains("<sup>") || value.contains("</sup>")) {
xxsfFont.setTypeOffset(FontFormatting.SS_SUPER); xxsfFont.setTypeOffset(FontFormatting.SS_SUPER);
cell.setCellStyle(style); cell.setCellStyle(style);
XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sup>","<sup>").replaceAll("<sup>","")); XSSFRichTextString richString = new XSSFRichTextString(value.replaceAll("</sup>", "<sup>").replaceAll("<sup>", ""));
//提取下标位置 //提取下标位置
applyRichStringFontsup(value, richString, xxsfFont); applyRichStringFontsup(value, richString, xxsfFont);
cell.setCellValue(richString); cell.setCellValue(richString);
}else{ } else {
cell.setCellValue(value); cell.setCellValue(value);
cell.setCellStyle(style); cell.setCellStyle(style);
} }
}
} }
} }
} }
...@@ -234,28 +237,28 @@ public class ExcelUtil { ...@@ -234,28 +237,28 @@ public class ExcelUtil {
return workbook; return workbook;
} }
private static void applyRichStringFontsub(String sub, XSSFRichTextString richString,XSSFFont xxsfFont) { private static void applyRichStringFontsub(String sub, XSSFRichTextString richString, XSSFFont xxsfFont) {
String[] split = sub.replaceAll("</sub>", "<sub>").split("<sub>"); String[] split = sub.replaceAll("</sub>", "<sub>").split("<sub>");
String it_str = ""; String it_str = "";
for (int i = 1; i < split.length + 1; i++) { for (int i = 1; i < split.length + 1; i++) {
if (i % 2 != 0) { if (i % 2 != 0) {
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} else { } else {
richString.applyFont(it_str.length(),(it_str+split[i-1]).length(),xxsfFont); richString.applyFont(it_str.length(), (it_str + split[i - 1]).length(), xxsfFont);
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} }
} }
} }
private static void applyRichStringFontsup(String sup, XSSFRichTextString richString,XSSFFont xxsfFont) { private static void applyRichStringFontsup(String sup, XSSFRichTextString richString, XSSFFont xxsfFont) {
String[] split = sup.replaceAll("</sup>", "<sup>").split("<sup>"); String[] split = sup.replaceAll("</sup>", "<sup>").split("<sup>");
String it_str = ""; String it_str = "";
for (int i = 1; i < split.length + 1; i++) { for (int i = 1; i < split.length + 1; i++) {
if (i % 2 != 0) { if (i % 2 != 0) {
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} else { } else {
richString.applyFont(it_str.length(),(it_str+split[i-1]).length(),xxsfFont); richString.applyFont(it_str.length(), (it_str + split[i - 1]).length(), xxsfFont);
it_str = it_str + split[i - 1]; it_str = it_str + split[i - 1];
} }
...@@ -263,11 +266,10 @@ public class ExcelUtil { ...@@ -263,11 +266,10 @@ public class ExcelUtil {
} }
public static Workbook getWorkbookNew(String[] headers, List<Object[]> datas) { public static Workbook getWorkbookNew(String[] headers, List<Object[]> datas) {
Workbook workbook = new HSSFWorkbook(); Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
workbook.setSheetName(0,"样品处置记录"); workbook.setSheetName(0, "样品处置记录");
Row row = null; Row row = null;
Cell cell = null; Cell cell = 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