Commit 2fcd9912 authored by 竹天卫's avatar 竹天卫

导出优化

parent 04ee0430
......@@ -480,7 +480,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
}
}
}
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托单进展统计" : fileName, wb, response);
}
......
......@@ -5723,7 +5723,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
Map<String, Object> map = list.get(0);
String[] headers = new String[map.size() + 1];
headers[0] = "序号";
headers[1] = "委托号";
headers[1] = "委托号";
headers[2] = "是否加急";
headers[3] = "项目名称";
headers[4] = "项目编号";
......@@ -5934,7 +5934,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
}
}
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托单进展" : fileName, wb, response);
}
......@@ -6130,7 +6130,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
coloum = coloum + 1;
}
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "样品标签" : fileName, wb, response);
}
......@@ -6254,7 +6254,7 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
}
}
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托列表" : fileName, wb, response);
ExcelUtil.excelExportNew(fileName == null || fileName.trim().length() <= 0 ? "委托单校核" : fileName, wb, response);
}
......
......@@ -123,9 +123,7 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
if(normProduction.getType() == null){
return BaseResponse.errorMsg("类型不允许为空!");
}
if(normProduction.getAssessId() == null){
return BaseResponse.errorMsg("对象id不允许为空!");
}
//如果是处理项 只能添加一次
if(normProduction.getType() == 0){
normProduction.setAssessId(null);
......@@ -137,6 +135,9 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
return BaseResponse.errorMsg("当前处理项标准产值已存在!");
}
}else{
if(normProduction.getAssessId() == null){
return BaseResponse.errorMsg("对象id不允许为空!");
}
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("type", normProduction.getType());
......@@ -216,9 +217,6 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
if(normProduction.getType() == null){
return BaseResponse.errorMsg("类型不允许为空!");
}
if(normProduction.getAssessId() == null){
return BaseResponse.errorMsg("对象id不允许为空!");
}
NormProduction normProductionOld = this.getById(normProduction.getId());
if(normProductionOld == null){
return BaseResponse.errorMsg("信息错误!");
......@@ -236,6 +234,9 @@ public class NormProductionServiceImpl extends ServiceImpl<NormProductionMapper,
return BaseResponse.errorMsg("当前处理项标准产值已存在!");
}
}else{
if(normProduction.getAssessId() == null){
return BaseResponse.errorMsg("对象id不允许为空!");
}
//判断配置项目是否已存在
QueryWrapper<NormProduction> qw = new QueryWrapper<>();
qw.eq("assess_id", normProduction.getAssessId());
......
......@@ -472,7 +472,7 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
headers[3] = "数量";
headers[4] = "合计";
headers[5] = "产值设置:";
headers[5] = "产值设置参数:";
headers[6] = "额定工日";
headers[7] = "报出对应分析结果";
......@@ -497,13 +497,15 @@ public class PrecipriceServiceImpl extends ServiceImpl<PrecipriceMapper, Precipr
NormProductionVo vo = null;
if(target.getType() == 0){
vo =normProductions.stream()
.filter(arg -> (arg.getType().equals("处理项") && arg.getAssessId()==null)).findFirst().get();
.filter(arg -> (arg.getType().equals("处理项") && arg.getAssessId()==null)).findFirst().orElse(null);
}else if(target.getType() == 1){
vo =normProductions.stream()
.filter(arg -> (arg.getType().equals("检测组") && arg.getAssessId().equals(target.getObjId()))).findFirst().get();
vo = normProductions.stream()
.filter(arg -> (arg.getType().equals("检测组") && arg.getAssessId().equals(target.getObjId())))
.findFirst().orElse(null);
}else if(target.getType() == 2){
vo =normProductions.stream()
.filter(arg -> (arg.getType().equals("检测项") && arg.getAssessId().equals(target.getObjId()))).findFirst().get();
.filter(arg -> (arg.getType().equals("检测项") && arg.getAssessId().equals(target.getObjId()))).findFirst().orElse(null);
}
if(vo != null){
......
......@@ -34,51 +34,6 @@ import java.util.List;
* @author zhutianwei
*/
public class ExcelUtil {
public static void excelLocal(String path, String fileName, String[] headers, List<Object[]> datas) {
Workbook workbook = getWorkbook(headers, datas);
if (workbook != null) {
ByteArrayOutputStream byteArrayOutputStream = null;
FileOutputStream fileOutputStream = null;
try {
byteArrayOutputStream = new ByteArrayOutputStream();
workbook.write(byteArrayOutputStream);
String suffix = ".xls";
File file = new File(path + File.separator + fileName + suffix);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fileOutputStream = new FileOutputStream(file);
fileOutputStream.write(byteArrayOutputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (fileOutputStream != null) {
fileOutputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
if (byteArrayOutputStream != null) {
byteArrayOutputStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
try {
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
/**
* 导出excel
*
......@@ -217,11 +172,11 @@ public class ExcelUtil {
font.setBold(true);
font.setFontHeightInPoints((short) 13);
style.setFont(font);
style.setWrapText(true);
maxColumn = headers.length;
for (int i = 0; i < maxColumn; i++) {
cell = row.createCell(i);
sheet.setColumnWidth(i, Math.min(255*256, sheet.getColumnWidth(i) * 12 / 10));
XSSFFont xxsfFont = workbook.createFont();
//表头处理上下标
......@@ -252,6 +207,7 @@ public class ExcelUtil {
if (datas != null && datas.size() > 0) {// 渲染数据
CellStyle style = workbook.createCellStyle();
style.setWrapText(true);
XSSFFont xxsfFont = workbook.createFont();
for (int index = 0, size = datas.size(); index < size; index++) {
......@@ -305,6 +261,8 @@ public class ExcelUtil {
for (int i = 0; i < maxColumn; i++) {
sheet.autoSizeColumn(i);
//单元格自适应宽度
sheet.setColumnWidth(i, Math.max(15 * 256, Math.min(255 * 256, sheet.getColumnWidth(i) * 12 / 10)));
}
return workbook;
......@@ -411,6 +369,8 @@ public class ExcelUtil {
for (int i = 0; i < maxColumn; i++) {
sheet.autoSizeColumn(i);
//单元格自适应宽度
sheet.setColumnWidth(i, Math.max(15 * 256, Math.min(255 * 256, sheet.getColumnWidth(i) * 12 / 10)));
}
return workbook;
......
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