|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.dsideal.QingLong.Util;
|
|
|
|
|
|
|
|
|
|
import UnitTest.ImportExcel.Bean.CellBean;
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import com.jfinal.kit.Kv;
|
|
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
@ -99,19 +100,45 @@ public class GenericTemplateUtil {
|
|
|
|
|
return Db.findFirst(sql, tableName).getInt("c") == 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定模板+指定Sheet的全部配置信息
|
|
|
|
|
*
|
|
|
|
|
* @param upload_excel_filename
|
|
|
|
|
* @param sheet_index
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static Record getExcelSheetInfo(String upload_excel_filename, int sheet_index) {
|
|
|
|
|
String sql = "select * from t_importexcel_config where upload_excel_filename=? and sheet_index=?";
|
|
|
|
|
return Db.findFirst(sql, upload_excel_filename, sheet_index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定模板+指定Sheet的个数
|
|
|
|
|
*
|
|
|
|
|
* @param upload_excel_filename
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static int getExcelSheetCount(String upload_excel_filename) {
|
|
|
|
|
String sql = "select * from t_importexcel_config where upload_excel_filename=?";
|
|
|
|
|
List<Record> list = Db.find(sql, upload_excel_filename);
|
|
|
|
|
return list.size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:检查两个EXCEL文件的指定行+指定列是不是内容一致,返回值是不一致的位置集合,位置用数对 Map.Entry<Integer, Integer>描述
|
|
|
|
|
*
|
|
|
|
|
* @param f1 模板文件
|
|
|
|
|
* @param f2 上传文件
|
|
|
|
|
* @param startRow 开始行
|
|
|
|
|
* @param endRow 结束行
|
|
|
|
|
* @param startCol 开始列
|
|
|
|
|
* @param endCol 结束列
|
|
|
|
|
* @param f1 模板文件
|
|
|
|
|
* @param f2 上传文件
|
|
|
|
|
* @return 不一样的位置集合
|
|
|
|
|
* @throws IOException
|
|
|
|
|
*/
|
|
|
|
|
public static List<Map.Entry<Integer, Integer>> checkYiZhi(String f1, String f2, int sheetIdx, int startRow, int endRow, int startCol, int endCol) throws IOException {
|
|
|
|
|
public static List<Map.Entry<Integer, Integer>> checkYiZhi(String f1, String f2, int sheetIdx) throws IOException {
|
|
|
|
|
Record record = getExcelSheetInfo(FileUtil.getName(f1), sheetIdx);
|
|
|
|
|
int start_row = record.getInt("start_row");
|
|
|
|
|
int end_row = record.getInt("end_row");
|
|
|
|
|
int start_column = record.getInt("start_column");
|
|
|
|
|
int end_column = record.getInt("end_column");
|
|
|
|
|
|
|
|
|
|
FileInputStream file1 = new FileInputStream(f1);
|
|
|
|
|
FileInputStream file2 = new FileInputStream(f2);
|
|
|
|
|
List<Map.Entry<Integer, Integer>> errList = new ArrayList<>();
|
|
|
|
@ -121,10 +148,10 @@ public class GenericTemplateUtil {
|
|
|
|
|
Sheet sheet1 = wb1.getSheetAt(sheetIdx);
|
|
|
|
|
Sheet sheet2 = wb2.getSheetAt(sheetIdx);
|
|
|
|
|
|
|
|
|
|
for (int i = startRow; i <= endRow; i++) {
|
|
|
|
|
for (int i = start_row; i <= end_row; i++) {
|
|
|
|
|
Row row1 = sheet1.getRow(i);
|
|
|
|
|
Row row2 = sheet2.getRow(i);
|
|
|
|
|
for (int j = startCol; j <= endCol; j++) {
|
|
|
|
|
for (int j = start_column; j <= end_column; j++) {
|
|
|
|
|
Cell cell1 = row1.getCell(j);
|
|
|
|
|
Cell cell2 = row2.getCell(j);
|
|
|
|
|
if (cell1 != null && cell2 != null) {
|
|
|
|
@ -190,7 +217,7 @@ public class GenericTemplateUtil {
|
|
|
|
|
kv.set("start_row", st.getRowNum());//表头开始行
|
|
|
|
|
kv.set("end_row", ed.getRowNum());//表头结束行
|
|
|
|
|
kv.set("start_column", 0);//表头开始列
|
|
|
|
|
kv.set("end_column", ed.getLastCellNum());//表头结束列
|
|
|
|
|
kv.set("end_column", ed.getLastCellNum() - 1);//表头结束列
|
|
|
|
|
|
|
|
|
|
kv.set("data_start_row", ed.getRowNum() + 1);//真实数据的起始行索引
|
|
|
|
|
kv.set("column_num", ed.getLastCellNum());//一共多少列
|
|
|
|
|