Commit e88c9986 by 胡懿

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

parent d0f3c15b
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<!-- tools version setting --> <!-- tools version setting -->
<slf4j.version>1.7.25</slf4j.version> <slf4j.version>1.7.25</slf4j.version>
<commons-io.version>2.4</commons-io.version> <commons-io.version>2.11.0</commons-io.version>
<commons-codec.version>1.9</commons-codec.version> <commons-codec.version>1.9</commons-codec.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version> <commons-fileupload.version>1.3.1</commons-fileupload.version>
<commons-beanutils.version>1.9.1</commons-beanutils.version> <commons-beanutils.version>1.9.1</commons-beanutils.version>
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
<build> <build>
<finalName>jeeplus</finalName> <finalName>warehouse</finalName>
<resources> <resources>
<resource> <resource>
<directory>src/main/java</directory> <directory>src/main/java</directory>
...@@ -655,6 +655,21 @@ ...@@ -655,6 +655,21 @@
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<!--<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>${poi.version}</version> <version>${poi.version}</version>
</dependency> </dependency>
<dependency> <dependency>
...@@ -666,7 +681,7 @@ ...@@ -666,7 +681,7 @@
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId> <artifactId>poi-ooxml-schemas</artifactId>
<version>${poi.version}</version> <version>${poi.version}</version>
</dependency> </dependency>-->
<!-- image util --> <!-- image util -->
<dependency> <dependency>
...@@ -811,6 +826,12 @@ ...@@ -811,6 +826,12 @@
<version>42.1.1</version> <version>42.1.1</version>
</dependency> </dependency>
<!-- Ikanalyzer分词器 -->
<dependency>
<groupId>com.janeluo</groupId>
<artifactId>ikanalyzer</artifactId>
<version>2012_u6</version>
</dependency>
<!-- UTILS end --> <!-- UTILS end -->
</dependencies> </dependencies>
......
...@@ -19,15 +19,7 @@ import java.util.Map; ...@@ -19,15 +19,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor; import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
...@@ -40,6 +32,7 @@ import com.jeeplus.common.utils.Encodes; ...@@ -40,6 +32,7 @@ import com.jeeplus.common.utils.Encodes;
import com.jeeplus.common.utils.Reflections; import com.jeeplus.common.utils.Reflections;
import com.jeeplus.common.utils.excel.annotation.ExcelField; import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.sys.utils.DictUtils; import com.jeeplus.modules.sys.utils.DictUtils;
import org.apache.poi.hssf.record.cf.BorderFormatting;
/** /**
* 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion) * 导出Excel文件(导出“XLSX”格式,支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion)
...@@ -237,24 +230,24 @@ public class ExportExcel { ...@@ -237,24 +230,24 @@ public class ExportExcel {
Map<String, CellStyle> styles = new HashMap<String, CellStyle>(); Map<String, CellStyle> styles = new HashMap<String, CellStyle>();
CellStyle style = wb.createCellStyle(); CellStyle style = wb.createCellStyle();
style.setAlignment(CellStyle.ALIGN_CENTER); style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
Font titleFont = wb.createFont(); Font titleFont = wb.createFont();
titleFont.setFontName("Arial"); titleFont.setFontName("Arial");
titleFont.setFontHeightInPoints((short) 16); titleFont.setFontHeightInPoints((short) 16);
titleFont.setBoldweight(Font.BOLDWEIGHT_BOLD); titleFont.setBold(true);
style.setFont(titleFont); style.setFont(titleFont);
styles.put("title", style); styles.put("title", style);
style = wb.createCellStyle(); style = wb.createCellStyle();
style.setVerticalAlignment(CellStyle.VERTICAL_CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setBorderRight(CellStyle.BORDER_THIN); style.setBorderRight(BorderStyle.THIN);
style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderLeft(CellStyle.BORDER_THIN); style.setBorderLeft(BorderStyle.THIN);
style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderTop(CellStyle.BORDER_THIN); style.setBorderTop(BorderStyle.THIN);
style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setBorderBottom(CellStyle.BORDER_THIN); style.setBorderBottom(BorderStyle.THIN);
style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
Font dataFont = wb.createFont(); Font dataFont = wb.createFont();
dataFont.setFontName("Arial"); dataFont.setFontName("Arial");
...@@ -264,29 +257,29 @@ public class ExportExcel { ...@@ -264,29 +257,29 @@ public class ExportExcel {
style = wb.createCellStyle(); style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data")); style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_LEFT); style.setAlignment(HorizontalAlignment.CENTER);
styles.put("data1", style); styles.put("data1", style);
style = wb.createCellStyle(); style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data")); style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_CENTER); style.setAlignment(HorizontalAlignment.CENTER);
styles.put("data2", style); styles.put("data2", style);
style = wb.createCellStyle(); style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data")); style.cloneStyleFrom(styles.get("data"));
style.setAlignment(CellStyle.ALIGN_RIGHT); style.setAlignment(HorizontalAlignment.RIGHT);
styles.put("data3", style); styles.put("data3", style);
style = wb.createCellStyle(); style = wb.createCellStyle();
style.cloneStyleFrom(styles.get("data")); style.cloneStyleFrom(styles.get("data"));
// style.setWrapText(true); // style.setWrapText(true);
style.setAlignment(CellStyle.ALIGN_CENTER); style.setAlignment(HorizontalAlignment.CENTER);
style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
style.setFillPattern(CellStyle.SOLID_FOREGROUND); style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
Font headerFont = wb.createFont(); Font headerFont = wb.createFont();
headerFont.setFontName("Arial"); headerFont.setFontName("Arial");
headerFont.setFontHeightInPoints((short) 10); headerFont.setFontHeightInPoints((short) 10);
headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerFont.setBold(true);
headerFont.setColor(IndexedColors.WHITE.getIndex()); headerFont.setColor(IndexedColors.WHITE.getIndex());
style.setFont(headerFont); style.setFont(headerFont);
styles.put("header", style); styles.put("header", style);
......
...@@ -17,14 +17,9 @@ import java.util.Date; ...@@ -17,14 +17,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -65,7 +60,6 @@ public class ImportExcel { ...@@ -65,7 +60,6 @@ public class ImportExcel {
/** /**
* 构造函数 * 构造函数
* @param path 导入文件,读取第一个工作表
* @param headerNum 标题行号,数据行号=标题行号+1 * @param headerNum 标题行号,数据行号=标题行号+1
* @throws InvalidFormatException * @throws InvalidFormatException
* @throws IOException * @throws IOException
...@@ -77,7 +71,6 @@ public class ImportExcel { ...@@ -77,7 +71,6 @@ public class ImportExcel {
/** /**
* 构造函数 * 构造函数
* @param path 导入文件对象,读取第一个工作表
* @param headerNum 标题行号,数据行号=标题行号+1 * @param headerNum 标题行号,数据行号=标题行号+1
* @throws InvalidFormatException * @throws InvalidFormatException
* @throws IOException * @throws IOException
...@@ -89,7 +82,6 @@ public class ImportExcel { ...@@ -89,7 +82,6 @@ public class ImportExcel {
/** /**
* 构造函数 * 构造函数
* @param path 导入文件
* @param headerNum 标题行号,数据行号=标题行号+1 * @param headerNum 标题行号,数据行号=标题行号+1
* @param sheetIndex 工作表编号 * @param sheetIndex 工作表编号
* @throws InvalidFormatException * @throws InvalidFormatException
...@@ -102,7 +94,6 @@ public class ImportExcel { ...@@ -102,7 +94,6 @@ public class ImportExcel {
/** /**
* 构造函数 * 构造函数
* @param path 导入文件对象
* @param headerNum 标题行号,数据行号=标题行号+1 * @param headerNum 标题行号,数据行号=标题行号+1
* @param sheetIndex 工作表编号 * @param sheetIndex 工作表编号
* @throws InvalidFormatException * @throws InvalidFormatException
...@@ -128,7 +119,6 @@ public class ImportExcel { ...@@ -128,7 +119,6 @@ public class ImportExcel {
/** /**
* 构造函数 * 构造函数
* @param path 导入文件对象
* @param headerNum 标题行号,数据行号=标题行号+1 * @param headerNum 标题行号,数据行号=标题行号+1
* @param sheetIndex 工作表编号 * @param sheetIndex 工作表编号
* @throws InvalidFormatException * @throws InvalidFormatException
...@@ -197,12 +187,12 @@ public class ImportExcel { ...@@ -197,12 +187,12 @@ public class ImportExcel {
try { try {
Cell cell = row.getCell(column); Cell cell = row.getCell(column);
if (cell != null) { if (cell != null) {
if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) { if (cell.getCellType() == CellType.NUMERIC) {
// val = cell.getNumericCellValue(); // val = cell.getNumericCellValue();
// 当excel 中的数据为数值或日期是需要特殊处理 // 当excel 中的数据为数值或日期是需要特殊处理
if (HSSFDateUtil.isCellDateFormatted(cell)) { if (DateUtil.isCellDateFormatted(cell)) {
double d = cell.getNumericCellValue(); double d = cell.getNumericCellValue();
Date date = HSSFDateUtil.getJavaDate(d); Date date = DateUtil.getJavaDate(d);
SimpleDateFormat dformat = new SimpleDateFormat( SimpleDateFormat dformat = new SimpleDateFormat(
"yyyy-MM-dd"); "yyyy-MM-dd");
val = dformat.format(date); val = dformat.format(date);
...@@ -211,13 +201,13 @@ public class ImportExcel { ...@@ -211,13 +201,13 @@ public class ImportExcel {
nf.setGroupingUsed(false);// true时的格式:1,234,567,890 nf.setGroupingUsed(false);// true时的格式:1,234,567,890
val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下 val = nf.format(cell.getNumericCellValue());// 数值类型的数据为double,所以需要转换一下
} }
} else if (cell.getCellType() == Cell.CELL_TYPE_STRING) { } else if (cell.getCellType() == CellType.STRING) {
val = cell.getStringCellValue(); val = cell.getStringCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { } else if (cell.getCellType() == CellType.FORMULA) {
val = cell.getCellFormula(); val = cell.getCellFormula();
} else if (cell.getCellType() == Cell.CELL_TYPE_BOOLEAN) { } else if (cell.getCellType() == CellType.BOOLEAN) {
val = cell.getBooleanCellValue(); val = cell.getBooleanCellValue();
} else if (cell.getCellType() == Cell.CELL_TYPE_ERROR) { } else if (cell.getCellType() == CellType.ERROR) {
val = cell.getErrorCellValue(); val = cell.getErrorCellValue();
} }
} }
......
package com.jeeplus.modules.warehouse.ledger.Utils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelStyleUtils {
/**
* 第一行样式
* @return
*/
public static CellStyle topOneCellStyle(XSSFWorkbook workbook) {
// 样式设置
CellStyle topStyle = workbook.createCellStyle();
// 水平对齐方式
topStyle.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;
}
public static CellStyle topTwoCellStyle(XSSFWorkbook workbook) {
// 样式设置
CellStyle topStyle = workbook.createCellStyle();
// 水平对齐方式
topStyle.setAlignment(HorizontalAlignment.LEFT);
// 垂直居中
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;
}
}
...@@ -13,6 +13,7 @@ import com.jeeplus.common.utils.excel.annotation.ExcelField; ...@@ -13,6 +13,7 @@ import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse; import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -43,6 +44,7 @@ public class LedgerInfo extends DataEntity<LedgerInfo> { ...@@ -43,6 +44,7 @@ public class LedgerInfo extends DataEntity<LedgerInfo> {
private Shelves shelves; private Shelves shelves;
public LedgerInfo() { public LedgerInfo() {
super(); super();
} }
...@@ -182,4 +184,5 @@ public class LedgerInfo extends DataEntity<LedgerInfo> { ...@@ -182,4 +184,5 @@ public class LedgerInfo extends DataEntity<LedgerInfo> {
public void setShelves(Shelves shelves) { public void setShelves(Shelves shelves) {
this.shelves = shelves; this.shelves = shelves;
} }
} }
\ No newline at end of file
...@@ -19,7 +19,6 @@ import java.util.List; ...@@ -19,7 +19,6 @@ import java.util.List;
@MyBatisMapper @MyBatisMapper
public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> { public interface LedgerInfoMapper extends BaseMapper<LedgerInfo> {
public List<CountLedgerInfo> findCliList(LedgerInfo ledgerInfo);
void deleteByLedgerInfo(@Param("id") String id); void deleteByLedgerInfo(@Param("id") String id);
public List<LedgerInfo> findListByQrIdAndCode(LedgerInfo ledgerInfo); public List<LedgerInfo> findListByQrIdAndCode(LedgerInfo ledgerInfo);
void updateByLedgerInfo(@Param("id") String id); void updateByLedgerInfo(@Param("id") String id);
......
...@@ -237,52 +237,4 @@ ...@@ -237,52 +237,4 @@
select * FROM t_wh_ledger_info where ${propertyName} = '${value}' select * FROM t_wh_ledger_info where ${propertyName} = '${value}'
</select> </select>
<select id="findCliList" resultType="com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo" >
SELECT
a.ledger_id AS "ledger.id",
count(a.id) AS "num",
a.type_id AS "type.id",
a.model AS "model",
a.batch_num AS "batchNum",
a.shelves_id AS "shelves.id",
sum(a.amount) AS "sum",
type.name AS "type.name",
s.name AS "shelves.name",
w.id AS "shelves.warehouse.id",
w.name AS "shelves.warehouse.name"
FROM t_wh_ledger_info a
LEFT JOIN t_wh_material_type type on type.id = a.type_id
LEFT JOIN t_wh_shelves s on s.id = a.shelves_id
LEFT JOIN t_wh_warehouse w on w.id = s.warehouse_id
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
AND a.ledger_id = #{ledger.id}
</where>
GROUP BY a.ledger_id,a.batch_num,a.shelves_id
</select>
<select id="findListByQrIdAndCode" resultType="LedgerInfo" >
SELECT
<include refid="ledgerInfoColumns"/>
FROM t_wh_ledger_info a
<include refid="ledgerInfoJoins"/>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
${dataScope}
<if test="code != null and code != ''">
AND a.code = #{code}
</if>
<if test="qr != null and qr.id != null and qr.id != ''">
AND a.qr_id = #{qr.id}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.create_date ASC
</otherwise>
</choose>
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -3,16 +3,33 @@ ...@@ -3,16 +3,33 @@
*/ */
package com.jeeplus.modules.warehouse.ledger.service; package com.jeeplus.modules.warehouse.ledger.service;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.*;
import com.jeeplus.common.utils.DateUtil;
import com.jeeplus.modules.warehouse.ledger.Utils.ExcelStyleUtils;
import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo; import com.jeeplus.modules.warehouse.ledger.dto.CountLedgerInfo;
import com.jeeplus.modules.warehouse.materialtype.entity.MaterialType;
import com.jeeplus.modules.warehouse.materialtype.mapper.MaterialTypeMapper;
import com.jeeplus.modules.warehouse.materialtype.service.MaterialTypeService;
import com.jeeplus.modules.warehouse.outbound.entity.OutboundInfo;
import com.jeeplus.modules.warehouse.outbound.mapper.OutboundInfoMapper;
import com.jeeplus.modules.warehouse.qrcode.entity.QrCode; import com.jeeplus.modules.warehouse.qrcode.entity.QrCode;
import com.jeeplus.modules.warehouse.qrcode.mapper.QrCodeMapper; import com.jeeplus.modules.warehouse.qrcode.mapper.QrCodeMapper;
import com.jeeplus.modules.warehouse.shelves.entity.Shelves; import com.jeeplus.modules.warehouse.shelves.entity.Shelves;
import com.jeeplus.modules.warehouse.shelves.utils.ShelvesUtil; import com.jeeplus.modules.warehouse.shelves.utils.ShelvesUtil;
import com.jeeplus.modules.warehouse.storage.dto.CountStorageInfo; import com.jeeplus.modules.warehouse.storage.dto.CountStorageInfo;
import com.jeeplus.modules.warehouse.storage.entity.StorageInfo;
import com.jeeplus.modules.warehouse.storage.mapper.StorageInfoMapper;
import com.jeeplus.modules.warehouse.storage.mapper.StorageMapper;
import com.jeeplus.modules.warehouse.storage.service.StorageService;
import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse; import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -25,6 +42,8 @@ import com.jeeplus.modules.warehouse.ledger.mapper.LedgerMapper; ...@@ -25,6 +42,8 @@ import com.jeeplus.modules.warehouse.ledger.mapper.LedgerMapper;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo; import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
import com.jeeplus.modules.warehouse.ledger.mapper.LedgerInfoMapper; import com.jeeplus.modules.warehouse.ledger.mapper.LedgerInfoMapper;
import javax.servlet.http.HttpServletResponse;
/** /**
* 台账信息Service * 台账信息Service
* @author huyi * @author huyi
...@@ -38,6 +57,15 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -38,6 +57,15 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
private LedgerInfoMapper ledgerInfoMapper; private LedgerInfoMapper ledgerInfoMapper;
@Autowired @Autowired
private QrCodeMapper qrCodeMapper; private QrCodeMapper qrCodeMapper;
@Autowired
private MaterialTypeMapper materialTypeMapper;
@Autowired
private StorageInfoMapper storageInfoMapper;
@Autowired
private OutboundInfoMapper outboundInfoMapper;
public Ledger get(String id) { public Ledger get(String id) {
Ledger ledger = super.get(id); Ledger ledger = super.get(id);
...@@ -144,5 +172,86 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> { ...@@ -144,5 +172,86 @@ public class LedgerService extends CrudService<LedgerMapper, Ledger> {
return null; return null;
} }
} }
public void ledgerStreamWater(String typeId, String beginTime, String endTime, HttpServletResponse respons) {
typeId = "4657ffc36fcf4feb922eb571231234b0";
beginTime = "2023-01-01 00:00:00";
endTime = "2023-12-01 00:00:00";
MaterialType materialType = materialTypeMapper.get(typeId);
StorageInfo temSi = new StorageInfo();
temSi.setType(materialType);
temSi.setBeginTime(DateUtil.parseStrToDate(beginTime, "yyyy-MM-dd HH:mm:ss"));
temSi.setEndTime(DateUtil.parseStrToDate(endTime, "yyyy-MM-dd HH:mm:ss"));
List<StorageInfo> storageInfoList = storageInfoMapper.findList(temSi);
LedgerInfo temLi = new LedgerInfo();
temLi.setType(materialType);
OutboundInfo outboundInfo = new OutboundInfo();
outboundInfo.setLedgerInfo(temLi);
outboundInfo.setBeginTime(DateUtil.parseStrToDate(beginTime, "yyyy-MM-dd HH:mm:ss"));
outboundInfo.setEndTime(DateUtil.parseStrToDate(endTime, "yyyy-MM-dd HH:mm:ss"));
List<OutboundInfo> outboundInfoList = outboundInfoMapper.findList(outboundInfo);
int sunRowNum = 5 + storageInfoList.size() + outboundInfoList.size();
// 创建工作薄
XSSFWorkbook workbook = new XSSFWorkbook();
// 创建工作表
XSSFSheet sheet = workbook.createSheet("被装物资库房帐");
//设置数据
for (int row = 0; row < sunRowNum; row++) {
XSSFRow sheetRow = sheet.createRow(row);
if (0 == row) {
sheetRow.setHeightInPoints(30);
XSSFCell cell = sheetRow.createCell(0);
cell.setCellValue("被 装 物 资 库 房 帐");
cell.setCellStyle(ExcelStyleUtils.topOneCellStyle(workbook));
}
if (1 == row) {
sheetRow.setHeightInPoints(20);
XSSFCell cell = sheetRow.createCell(0);
cell.setCellValue("品名代码:" + materialType.getCode());
cell.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
XSSFCell cell1 = sheetRow.createCell(1);
cell1.setCellValue("品名:" + materialType.getName());
cell1.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
XSSFCell cell2 = sheetRow.createCell(2);
cell2.setCellValue("计量单位:" + materialType.getUnit());
cell2.setCellStyle(ExcelStyleUtils.topTwoCellStyle(workbook));
}
// 设置列宽 sheet.setColumnWidth(0, 16 * 256); 第一个参数为第几个单元格,第二个为16个字符宽度
}
sheet.addMergedRegion(new CellRangeAddress(0,0,0,22));
sheet.addMergedRegion(new CellRangeAddress(1,1,0,4));
sheet.addMergedRegion(new CellRangeAddress(1,1,5,12));
sheet.addMergedRegion(new CellRangeAddress(1,1,13,22));
FileOutputStream out = null;
try {
out = new FileOutputStream(new File("D:/excel.xlsx"));
workbook.write(out);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (null != out) {
out.flush();
out.close();
}
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
\ No newline at end of file
...@@ -252,7 +252,7 @@ public class LedgerController extends BaseController { ...@@ -252,7 +252,7 @@ public class LedgerController extends BaseController {
*/ */
@ResponseBody @ResponseBody
@RequestMapping(value = "findByQrOrCode") @RequestMapping(value = "findByQrOrCode")
public Map<String, Object>findByQrOrCode(String qrId, String code) { public Map<String, Object> findByQrOrCode(String qrId, String code) {
boolean b = false; boolean b = false;
if (StringUtils.isNotBlank(qrId)) { if (StringUtils.isNotBlank(qrId)) {
b = true; b = true;
...@@ -275,4 +275,13 @@ public class LedgerController extends BaseController { ...@@ -275,4 +275,13 @@ public class LedgerController extends BaseController {
} }
return map; return map;
} }
@ResponseBody
@RequestMapping(value = "ledgerStreamWater")
public AjaxJson ledgerStreamWater(String typeId, String beginTime, String endTime, HttpServletResponse response) {
AjaxJson j = new AjaxJson();
ledgerService.ledgerStreamWater(typeId, beginTime, endTime, response);
return j;
}
} }
\ No newline at end of file
...@@ -5,8 +5,7 @@ import java.text.DecimalFormat; ...@@ -5,8 +5,7 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.FormulaEvaluator;
...@@ -23,9 +22,9 @@ public class POIUtil { ...@@ -23,9 +22,9 @@ public class POIUtil {
if (null != cell) { if (null != cell) {
// 以下是判断数据的类型 // 以下是判断数据的类型
switch (cell.getCellType()) { switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC: // 数字 case NUMERIC: // 数字
if (0 == cell.getCellType()) {// 判断单元格的类型是否则NUMERIC类型 if (0 == cell.getCellType().getCode()) {// 判断单元格的类型是否则NUMERIC类型
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 判断是否为日期类型 if (DateUtil.isCellDateFormatted(cell)) {// 判断是否为日期类型
Date date = cell.getDateCellValue(); Date date = cell.getDateCellValue();
// DateFormat formater = new SimpleDateFormat("yyyy/MM/dd HH:mm"); // DateFormat formater = new SimpleDateFormat("yyyy/MM/dd HH:mm");
DateFormat formater = new SimpleDateFormat("yyyy/MM/dd"); DateFormat formater = new SimpleDateFormat("yyyy/MM/dd");
...@@ -38,18 +37,18 @@ public class POIUtil { ...@@ -38,18 +37,18 @@ public class POIUtil {
} }
} }
break; break;
case HSSFCell.CELL_TYPE_STRING: // 字符串 case STRING: // 字符串
cellValue = cell.getStringCellValue(); cellValue = cell.getStringCellValue();
break; break;
case HSSFCell.CELL_TYPE_BOOLEAN: // Boolean case BOOLEAN: // Boolean
cellValue = cell.getBooleanCellValue() + ""; cellValue = cell.getBooleanCellValue() + "";
break; break;
case HSSFCell.CELL_TYPE_FORMULA: // 公式 case FORMULA: // 公式
try { try {
// 如果公式结果为字符串 // 如果公式结果为字符串
cellValue = String.valueOf(cell.getStringCellValue()); cellValue = String.valueOf(cell.getStringCellValue());
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
if (HSSFDateUtil.isCellDateFormatted(cell)) {// 判断是否为日期类型 if (DateUtil.isCellDateFormatted(cell)) {// 判断是否为日期类型
Date date = cell.getDateCellValue(); Date date = cell.getDateCellValue();
// DateFormat formater = new SimpleDateFormat("yyyy/MM/dd HH:mm"); // DateFormat formater = new SimpleDateFormat("yyyy/MM/dd HH:mm");
DateFormat formater = new SimpleDateFormat("yyyy/MM/dd"); DateFormat formater = new SimpleDateFormat("yyyy/MM/dd");
...@@ -67,10 +66,10 @@ public class POIUtil { ...@@ -67,10 +66,10 @@ public class POIUtil {
// //直接获取公式 // //直接获取公式
// cellValue = cell.getCellFormula() + ""; // cellValue = cell.getCellFormula() + "";
break; break;
case HSSFCell.CELL_TYPE_BLANK: // 空值 case BLANK: // 空值
cellValue = ""; cellValue = "";
break; break;
case HSSFCell.CELL_TYPE_ERROR: // 故障 case ERROR: // 故障
cellValue = "非法字符"; cellValue = "非法字符";
break; break;
default: default:
......
...@@ -8,6 +8,8 @@ import com.jeeplus.core.persistence.DataEntity; ...@@ -8,6 +8,8 @@ import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField; import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo; import com.jeeplus.modules.warehouse.ledger.entity.LedgerInfo;
import java.util.Date;
/** /**
* 出库单明细表Entity * 出库单明细表Entity
* @author zhanglt * @author zhanglt
...@@ -18,7 +20,19 @@ public class OutboundInfo extends DataEntity<OutboundInfo> { ...@@ -18,7 +20,19 @@ public class OutboundInfo extends DataEntity<OutboundInfo> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Outbound outbound; // 出库单主表id private Outbound outbound; // 出库单主表id
private LedgerInfo ledgerInfo; // 台账明细表id private LedgerInfo ledgerInfo; // 台账明细表id
/**
* 查询使用--------------------
*/
private Date beginTime;
private Date endTime;
/**
* -----------------
*/
public OutboundInfo() { public OutboundInfo() {
super(); super();
} }
...@@ -59,5 +73,20 @@ public class OutboundInfo extends DataEntity<OutboundInfo> { ...@@ -59,5 +73,20 @@ public class OutboundInfo extends DataEntity<OutboundInfo> {
public void setLedgerInfo(LedgerInfo ledgerInfo) { public void setLedgerInfo(LedgerInfo ledgerInfo) {
this.ledgerInfo = ledgerInfo; this.ledgerInfo = ledgerInfo;
} }
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
} }
\ No newline at end of file
...@@ -52,6 +52,12 @@ ...@@ -52,6 +52,12 @@
<if test="ledgerInfo != null and ledgerInfo.id != null and ledgerInfo.id != ''"> <if test="ledgerInfo != null and ledgerInfo.id != null and ledgerInfo.id != ''">
AND a.ledger_info_id = #{ledgerInfo.id} AND a.ledger_info_id = #{ledgerInfo.id}
</if> </if>
<if test="ledgerInfo != null and ledgerInfo.type != null and ledgerInfo.type.id != null and ledgerInfo.type.id != ''">
AND tpye.id = #{ledgerInfo.type.id}
</if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
AND a.create_date &gt;= #{beginTime} AND a.create_date &lt;= #{endTime}
</if>
</where> </where>
<choose> <choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''"> <when test="page !=null and page.orderBy != null and page.orderBy != ''">
......
...@@ -13,6 +13,7 @@ import com.jeeplus.common.utils.excel.annotation.ExcelField; ...@@ -13,6 +13,7 @@ import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse; import com.jeeplus.modules.warehouse.warehouse.entity.Warehouse;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -38,6 +39,17 @@ public class StorageInfo extends DataEntity<StorageInfo> { ...@@ -38,6 +39,17 @@ public class StorageInfo extends DataEntity<StorageInfo> {
private List<Warehouse> warehouseList; // 仓库外键 private List<Warehouse> warehouseList; // 仓库外键
private QrCode qrCode; // 前端保存入库单时使用的临时二维码对象 private QrCode qrCode; // 前端保存入库单时使用的临时二维码对象
/**
* 查询使用的属性-------
*/
private Date beginTime;
private Date endTime;
/**
* ------------
*/
public StorageInfo() { public StorageInfo() {
super(); super();
} }
...@@ -159,4 +171,20 @@ public class StorageInfo extends DataEntity<StorageInfo> { ...@@ -159,4 +171,20 @@ public class StorageInfo extends DataEntity<StorageInfo> {
public void setInfoSum(BigDecimal infoSum) { public void setInfoSum(BigDecimal infoSum) {
this.infoSum = infoSum; this.infoSum = infoSum;
} }
public Date getBeginTime() {
return beginTime;
}
public void setBeginTime(Date beginTime) {
this.beginTime = beginTime;
}
public Date getEndTime() {
return endTime;
}
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
} }
\ No newline at end of file
...@@ -17,4 +17,5 @@ import java.util.List; ...@@ -17,4 +17,5 @@ import java.util.List;
*/ */
@MyBatisMapper @MyBatisMapper
public interface StorageInfoMapper extends BaseMapper<StorageInfo> { public interface StorageInfoMapper extends BaseMapper<StorageInfo> {
} }
\ No newline at end of file
...@@ -82,6 +82,9 @@ ...@@ -82,6 +82,9 @@
<if test="dbName == 'mssql'">'%'+#{model}+'%'</if> <if test="dbName == 'mssql'">'%'+#{model}+'%'</if>
<if test="dbName == 'mysql'">concat('%',#{model},'%')</if> <if test="dbName == 'mysql'">concat('%',#{model},'%')</if>
</if> </if>
<if test="beginTime != null and beginTime != '' and endTime != null and endTime != ''">
AND a.create_date &gt;= #{beginTime} AND a.create_date &lt;= #{endTime} AND qr.state &lt;&gt; '1'
</if>
</where> </where>
<choose> <choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''"> <when test="page !=null and page.orderBy != null and page.orderBy != ''">
......
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