Commit e2c1b315 authored by hongguangwu's avatar hongguangwu

MVP1.6.2-工资原表识别-优化

parent 67e44669
...@@ -57,6 +57,8 @@ public class EkpQiwiChuchai { ...@@ -57,6 +57,8 @@ public class EkpQiwiChuchai {
private String fdPerson; private String fdPerson;
@Schema(description = "出差地点") @Schema(description = "出差地点")
private String fdAddress; private String fdAddress;
@Schema(description = "出发地点")
private String fdOldAddress;
@Schema(description = "出行工具") @Schema(description = "出行工具")
private String fdTools; private String fdTools;
@Schema(description = "出差地点级别") @Schema(description = "出差地点级别")
......
...@@ -338,6 +338,8 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -338,6 +338,8 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
String person = null; String person = null;
// 出差地点 // 出差地点
String address = null; String address = null;
// 出发地点
String oldAddress = null;
// 出行工具 // 出行工具
String tools = ""; String tools = "";
for (HashMap content : contentList) { for (HashMap content : contentList) {
...@@ -378,6 +380,11 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -378,6 +380,11 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
if (Common.isNotNull(value)) { if (Common.isNotNull(value)) {
address = value.getString("text"); address = value.getString("text");
} }
} else if ("出发地点".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) {
oldAddress = value.getString("text");
}
} else if ("出差地点级别".equals(((JSONObject) title.get(0)).get("text"))) { } else if ("出差地点级别".equals(((JSONObject) title.get(0)).get("text"))) {
value = (JSONObject) content.get(VALUESTR); value = (JSONObject) content.get(VALUESTR);
if (Common.isNotNull(value)) { if (Common.isNotNull(value)) {
...@@ -442,6 +449,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi ...@@ -442,6 +449,7 @@ public class QiWeiServiceImpl extends ServiceImpl<EkpQiweiChuchaiMapper, EkpQiwi
reimburse.setFdRenShu(renShu); reimburse.setFdRenShu(renShu);
reimburse.setFdPerson(person); reimburse.setFdPerson(person);
reimburse.setFdAddress(address); reimburse.setFdAddress(address);
reimburse.setFdOldAddress(oldAddress);
reimburse.setFdTools(tools); reimburse.setFdTools(tools);
reimburse.setFdAddressLevel(addressLevel); reimburse.setFdAddressLevel(addressLevel);
reimburse.setFdJiaoTong(jiaoTong); reimburse.setFdJiaoTong(jiaoTong);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result property="fdReason" column="FD_REASON"/> <result property="fdReason" column="FD_REASON"/>
<result property="fdPerson" column="FD_PERSON"/> <result property="fdPerson" column="FD_PERSON"/>
<result property="fdAddress" column="FD_ADDRESS"/> <result property="fdAddress" column="FD_ADDRESS"/>
<result property="fdOldAddress" column="FD_OLD_ADDRESS"/>
<result property="fdTools" column="FD_TOOLS"/> <result property="fdTools" column="FD_TOOLS"/>
<result property="fdAddressLevel" column="FD_ADDRESS_LEVEL"/> <result property="fdAddressLevel" column="FD_ADDRESS_LEVEL"/>
<result property="fdJiaoTong" column="FD_JIAO_TONG"/> <result property="fdJiaoTong" column="FD_JIAO_TONG"/>
...@@ -36,6 +37,7 @@ ...@@ -36,6 +37,7 @@
a.FD_REASON, a.FD_REASON,
a.FD_PERSON, a.FD_PERSON,
a.FD_ADDRESS, a.FD_ADDRESS,
a.FD_OLD_ADDRESS,
a.FD_TOOLS, a.FD_TOOLS,
a.FD_ADDRESS_LEVEL, a.FD_ADDRESS_LEVEL,
a.FD_JIAO_TONG, a.FD_JIAO_TONG,
......
...@@ -181,6 +181,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -181,6 +181,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
String cellValue; String cellValue;
// 内容行 // 内容行
int dataRow; int dataRow;
// 身份证所在列
int idCardColumn = -1;
// 空白列起始号
int nullColumn = -1;
// 上一个空白行
int preNullColumn = -1;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int nullColumnNum = 0;
// 极限空白列,超过阈值,将不继续循环列
int maxNullColumNum = 10;
String idCardValue = null;
// 数据行是否被确认,true否 // 数据行是否被确认,true否
boolean dataRowFlag; boolean dataRowFlag;
HSSFCell cell; HSSFCell cell;
...@@ -198,6 +209,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -198,6 +209,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
dataRowFlag = true; dataRowFlag = true;
// 循环当前sheet的每行内容 // 循环当前sheet的每行内容
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) { for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
idCardValue = null;
contentMap = new HashMap<>(); contentMap = new HashMap<>();
columnList = new ArrayList<>(); columnList = new ArrayList<>();
row = sheetAt.getRow(rowNum); row = sheetAt.getRow(rowNum);
...@@ -229,18 +246,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -229,18 +246,20 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} else if (CellType.BOOLEAN == cell.getCellType()) { } else if (CellType.BOOLEAN == cell.getCellType()) {
cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue()); cellValue = String.valueOf(row.getCell(cellNum).getBooleanCellValue());
} else { } else {
cell.setCellType(CellType.STRING);
cellValue = row.getCell(cellNum).getStringCellValue(); cellValue = row.getCell(cellNum).getStringCellValue();
} }
} }
} catch (Exception e) { } catch (Exception e) {
cellValue = ""; cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo
} }
if (Common.isNotNull(cellValue) && dataRowFlag if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue)) && (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别 // 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) { || regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum; dataRow = rowNum;
idCardColumn = cellNum;
dataRowFlag = false; dataRowFlag = false;
} }
columnVo.setLineNum(cellNum); columnVo.setLineNum(cellNum);
...@@ -250,10 +269,51 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -250,10 +269,51 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
contentMap.put(String.valueOf(cellNum), cellValue); contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) { if (dataRowFlag) {
if (Common.isEmpty(cellValue) && titleMap.get(String.valueOf(cellNum)) != null) { if (Common.isEmpty(cellValue)) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum))); if (titleMap.get(String.valueOf(cellNum)) != null) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum)));
} else {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
columnVo.setContent("空白列" + cellNum);
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
} }
columnList.add(columnVo); columnList.add(columnVo);
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
}
if (nullColumnNum >= maxNullColumNum) {
for (int num = maxNullColumNum-1; num >= 0; num--) {
if (dataRowFlag) {
columnList.remove(nullColumn + num);
}
contentMap.remove(String.valueOf(nullColumn + num));
}
break;
}
if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue;
} }
} }
if (!dataRowFlag) { if (!dataRowFlag) {
...@@ -268,6 +328,13 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -268,6 +328,13 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (titleFlag && !dataRowFlag) { if (titleFlag && !dataRowFlag) {
break; break;
} }
// 阻断空白行
if (idCardColumn != -1 && Common.isEmpty(idCardValue)) {
if (!contentList.isEmpty() && contentList.size() > 1) {
contentList.remove(contentList.size() - 1);
}
break;
}
} }
if (dataRowFlag) { if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!"); return R.failed("未找到身份证所在的数据行,请检查表数据!!");
...@@ -324,6 +391,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -324,6 +391,17 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
String cellValue; String cellValue;
// 内容行 // 内容行
int dataRow; int dataRow;
// 身份证所在列
int idCardColumn = -1;
// 空白列起始号
int nullColumn = -1;
// 上一个空白行
int preNullColumn = -1;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int nullColumnNum = 0;
// 极限空白列,超过阈值,将不继续循环列
int maxNullColumNum = 10;
String idCardValue = null;
// 数据行是否被确认,true否 // 数据行是否被确认,true否
boolean dataRowFlag; boolean dataRowFlag;
XSSFCell cell; XSSFCell cell;
...@@ -341,6 +419,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -341,6 +419,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
dataRowFlag = true; dataRowFlag = true;
// 循环当前sheet的每行内容 // 循环当前sheet的每行内容
for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) { for (int rowNum = 0; rowNum <= sheetAt.getLastRowNum(); rowNum++) {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
idCardValue = null;
contentMap = new HashMap<>(); contentMap = new HashMap<>();
columnList = new ArrayList<>(); columnList = new ArrayList<>();
row = sheetAt.getRow(rowNum); row = sheetAt.getRow(rowNum);
...@@ -377,14 +461,15 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -377,14 +461,15 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
} catch (Exception e) { } catch (Exception e) {
cellValue = ""; cellValue = "";
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage()); //sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo; //return sheetVo
} }
if (Common.isNotNull(cellValue) && dataRowFlag if (Common.isNotNull(cellValue) && dataRowFlag
&& (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue)) && (((cellValue.length() == 15 || cellValue.length() == 18) && regIdCard(cellValue))
// 特殊身份证允许识别 // 特殊身份证允许识别
|| regSpecialIdCard(cellValue, specialIdCardList))) { || regSpecialIdCard(cellValue, specialIdCardList))) {
dataRow = rowNum; dataRow = rowNum;
idCardColumn = cellNum;
dataRowFlag = false; dataRowFlag = false;
} }
columnVo.setLineNum(cellNum); columnVo.setLineNum(cellNum);
...@@ -394,10 +479,51 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -394,10 +479,51 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} }
contentMap.put(String.valueOf(cellNum), cellValue); contentMap.put(String.valueOf(cellNum), cellValue);
if (dataRowFlag) { if (dataRowFlag) {
if (Common.isEmpty(cellValue) && titleMap.get(String.valueOf(cellNum)) != null) { if (Common.isEmpty(cellValue)) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum))); if (titleMap.get(String.valueOf(cellNum)) != null) {
columnVo.setContent(titleMap.get(String.valueOf(cellNum)));
} else {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
columnVo.setContent("空白列" + cellNum);
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
} }
columnList.add(columnVo); columnList.add(columnVo);
} else {
if (Common.isEmpty(cellValue)) {
if (preNullColumn == -1 || preNullColumn + 1 == cellNum) {
if (nullColumn == -1) {
nullColumn = cellNum;
}
preNullColumn = cellNum;
nullColumnNum++;
}
} else {
nullColumn = -1;
preNullColumn = -1;
nullColumnNum = 0;
}
}
if (nullColumnNum >= maxNullColumNum) {
for (int num = maxNullColumNum-1; num >= 0; num--) {
if (dataRowFlag) {
columnList.remove(nullColumn + num);
}
contentMap.remove(String.valueOf(nullColumn + num));
}
break;
}
if (idCardColumn != -1 && cellNum == idCardColumn) {
idCardValue = cellValue;
} }
} }
if (!dataRowFlag) { if (!dataRowFlag) {
...@@ -412,6 +538,13 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand ...@@ -412,6 +538,13 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (titleFlag && !dataRowFlag) { if (titleFlag && !dataRowFlag) {
break; break;
} }
// 阻断空白行
if (idCardColumn != -1 && Common.isEmpty(idCardValue)) {
if (!contentList.isEmpty() && contentList.size() > 1) {
contentList.remove(contentList.size() - 1);
}
break;
}
} }
if (dataRowFlag) { if (dataRowFlag) {
return R.failed("未找到身份证所在的数据行,请检查表数据!!"); return R.failed("未找到身份证所在的数据行,请检查表数据!!");
......
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