Commit b75fb4fa by 胡懿

修改出库报错的问题,升级poi,

parent fc8c3f08
......@@ -12,35 +12,100 @@ public class ExcelStyleUtils {
*/
public static CellStyle topOneCellStyle(XSSFWorkbook workbook) {
// 样式设置
CellStyle topStyle = workbook.createCellStyle();
CellStyle style = workbook.createCellStyle();
// 水平对齐方式
topStyle.setAlignment(HorizontalAlignment.CENTER);
style.setAlignment(HorizontalAlignment.CENTER);
// 垂直居中
topStyle.setVerticalAlignment(VerticalAlignment.CENTER);
Font topFont = workbook.createFont();
topFont.setFontHeight((short) 500);
topFont.setBold(true);
topFont.setUnderline(Font.U_SINGLE); // 下划线
topFont.setFontName("宋体");
topFont.setColor(IndexedColors.BLUE_GREY.getIndex());
topStyle.setFont(topFont);
return topStyle;
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderTop(BorderStyle.THIN);
//设置右边框线条类型
style.setBorderRight(BorderStyle.THIN);
//设置下边框线条类型
style.setBorderBottom(BorderStyle.THIN);
//设置左边框线条类型
style.setBorderLeft(BorderStyle.THIN);
//设置上边框线条颜色
style.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置右边框线条颜色
style.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置下边框线条颜色
style.setBottomBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置左边框线条颜色
style.setLeftBorderColor(IndexedColors.BLUE_GREY.getIndex());
Font font = workbook.createFont();
font.setFontHeight((short) 500);
font.setBold(true);
font.setUnderline(Font.U_SINGLE); // 下划线
font.setFontName("宋体");
font.setColor(IndexedColors.BLUE_GREY.getIndex());
style.setFont(font);
return style;
}
public static CellStyle topTwoCellStyle(XSSFWorkbook workbook) {
// 样式设置
CellStyle topStyle = workbook.createCellStyle();
CellStyle style = workbook.createCellStyle();
// 水平对齐方式
style.setAlignment(HorizontalAlignment.LEFT);
// 垂直居中
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderTop(BorderStyle.THIN);
//设置右边框线条类型
style.setBorderRight(BorderStyle.THIN);
//设置下边框线条类型
style.setBorderBottom(BorderStyle.THIN);
//设置左边框线条类型
style.setBorderLeft(BorderStyle.THIN);
//设置上边框线条颜色
style.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置右边框线条颜色
style.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置下边框线条颜色
style.setBottomBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置左边框线条颜色
style.setLeftBorderColor(IndexedColors.BLUE_GREY.getIndex());
Font font = workbook.createFont();
font.setFontHeight((short) 220);
font.setFontName("宋体");
font.setColor(IndexedColors.BLUE_GREY.getIndex());
style.setFont(font);
return style;
}
public static CellStyle topThreeCellStyle(XSSFWorkbook workbook) {
// 样式设置
CellStyle style = workbook.createCellStyle();
// 水平对齐方式
topStyle.setAlignment(HorizontalAlignment.LEFT);
style.setAlignment(HorizontalAlignment.CENTER);
// 垂直居中
topStyle.setVerticalAlignment(VerticalAlignment.CENTER);
Font topFont = workbook.createFont();
topFont.setFontHeight((short) 220);
topFont.setFontName("宋体");
topFont.setColor(IndexedColors.BLUE_GREY.getIndex());
topStyle.setFont(topFont);
return topStyle;
style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderTop(BorderStyle.THIN);
//设置右边框线条类型
style.setBorderRight(BorderStyle.THIN);
//设置下边框线条类型
style.setBorderBottom(BorderStyle.THIN);
//设置左边框线条类型
style.setBorderLeft(BorderStyle.THIN);
//设置上边框线条颜色
style.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置右边框线条颜色
style.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置下边框线条颜色
style.setBottomBorderColor(IndexedColors.BLUE_GREY.getIndex());
//设置左边框线条颜色
style.setLeftBorderColor(IndexedColors.BLUE_GREY.getIndex());
Font font = workbook.createFont();
font.setFontHeight((short) 220);
font.setFontName("宋体");
font.setColor(IndexedColors.BLUE_GREY.getIndex());
style.setFont(font);
return style;
}
}
package com.jeeplus.modules.warehouse.ledger.dto;
public class ExcelExportInfo {
private String month;
private String day;
private String batch;
private String remarks;
private int taskOrSend; // 0是收入,1是支出
private String task;
private String mask;
private String num;
private String model;
private String userName;
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
public String getBatch() {
return batch;
}
public void setBatch(String batch) {
this.batch = batch;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public int getTaskOrSend() {
return taskOrSend;
}
public void setTaskOrSend(int taskOrSend) {
this.taskOrSend = taskOrSend;
}
public String getTask() {
return task;
}
public void setTask(String task) {
this.task = task;
}
public String getMask() {
return mask;
}
public void setMask(String mask) {
this.mask = mask;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
......@@ -10,8 +10,11 @@ import java.math.BigDecimal;
import java.util.*;
import com.jeeplus.common.utils.DateUtil;
import com.jeeplus.modules.sys.entity.User;
import com.jeeplus.modules.sys.utils.UserUtils;
import com.jeeplus.modules.warehouse.ledger.Utils.ExcelStyleUtils;
import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo;
import com.jeeplus.modules.warehouse.ledger.dto.ExcelExportInfo;
import com.jeeplus.modules.warehouse.materialtype.entity.MaterialType;
import com.jeeplus.modules.warehouse.materialtype.mapper.MaterialTypeMapper;
import com.jeeplus.modules.warehouse.materialtype.service.MaterialTypeService;
......@@ -190,6 +193,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
LedgerInfo temLi = new LedgerInfo();
temLi.setType(materialType);
......@@ -199,6 +203,32 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
outboundInfo.setEndTime(eTime);
List<OutboundInfo> outboundInfoList = outboundInfoMapper.findList(outboundInfo);
Map<String, Integer> modelMap = new HashMap<>();
List<ExcelExportInfo> excelExportInfoList = new ArrayList<>();
for (StorageInfo si : storageInfoList) {
ExcelExportInfo eei = new ExcelExportInfo();
eei.setMonth(DateUtil.getMonth(si.getCreateDate()) + "");
eei.setDay(DateUtil.getDay(si.getCreateDate()) + "");
eei.setBatch(si.getStorage().getBatchNum());
eei.setRemarks(si.getRemarks());
eei.setTaskOrSend(0);
eei.setTask(si.getInfoSum().toString());
eei.setMask("");
eei.setNum(si.getNum() + "");
eei.setModel(si.getModel());
// modelMap
User user = UserUtils.get(si.getCreateBy().getId());
eei.setUserName(user.getLoginName());
excelExportInfoList.add(eei);
}
int sunRowNum = 5 + storageInfoList.size() + outboundInfoList.size();
// 创建工作薄
XSSFWorkbook workbook = new XSSFWorkbook();
......@@ -279,7 +309,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
cell5.setCellStyle(threeStyle);
} else if (21 == i) {
XSSFCell cell6 = sheetRow.createCell(i);
cell6.setCellValue("摘要");
cell6.setCellValue("登记人");
cell6.setCellStyle(threeStyle);
} else {
XSSFCell cell6 = sheetRow.createCell(i);
......@@ -290,15 +320,7 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
if (3 == row) {
sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) {
if (0 == i) {
XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("月");
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (1 == i) {
XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("日");
cell1.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (6 == i) {
if (6 == i) {
XSSFCell cell2 = sheetRow.createCell(i);
cell2.setCellValue("数量");
cell2.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
......@@ -311,13 +333,28 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
cell3.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
}
}
}
if (4 == row) {
sheetRow.setHeightInPoints(15);
for (int i = 0; i < 22; i ++) {
if (0 == i) {
XSSFCell cell = sheetRow.createCell(i);
cell.setCellValue("月");
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else if (1 == i) {
XSSFCell cell1 = sheetRow.createCell(i);
cell1.setCellValue("日");
cell1.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
} else {
XSSFCell cell = sheetRow.createCell(i);
cell.setCellStyle(ExcelStyleUtils.topThreeCellStyle(workbook));
}
}
}
// 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度
}
sheet.addMergedRegion(new CellRangeAddress(0,0,0,21));
sheet.addMergedRegion(new CellRangeAddress(1,1,0,3));
sheet.addMergedRegion(new CellRangeAddress(1,1,4,11));
sheet.addMergedRegion(new CellRangeAddress(1,1,12,21));
......
......@@ -26,6 +26,8 @@
type.amount AS "type.amount",
type.unit AS "type.unit",
s.batch_num AS "storage.batchNum",
qr.code AS "qrCode.code",
qr.state AS "qrCode.state"
</sql>
......@@ -33,6 +35,7 @@
<sql id="storageInfoJoins">
LEFT JOIN t_wh_material_type type ON type.id = a.type_id
LEFT JOIN t_wh_qr qr on qr.id = a.qr_id
LEFT JOIN t_wh_storage s on s.id = a.storage_id
</sql>
......
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