Commit 7f8d678b authored by hongguangwu's avatar hongguangwu

MVP1.6.10工资相关

parent a3f4b018
......@@ -71,7 +71,6 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
implements TSalaryStandardOriginalService {
private final SalaryUploadService salaryUploadService;
private final TSalaryStandardOriginalService tSalaryStandardOriginalService;
private final TSalaryStandardOriginalDetailService tSalaryStandardOriginalDetailService;
/**
......@@ -801,7 +800,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (Common.isEmpty(originalId)) {
return R.failed("识别配置为空,请选择识别配置!");
}
TSalaryStandardOriginal original = tSalaryStandardOriginalService.getById(originalId);
TSalaryStandardOriginal original = this.getById(originalId);
if (original == null || Common.isEmpty(original.getId())) {
return R.failed("请检查表头配置!");
}
......@@ -811,22 +810,49 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if (detailList == null || detailList.isEmpty() || detailList.size() < 4) {
return R.failed("请检查表头配置!!");
}
int maxColumn = detailList.size() + 10;
// 忽略配置的表头,额外的表头
Map<String, Integer> ignoreMap = new HashMap<>();
ignoreMap.put("是否新员工(默认否)", 1);
ignoreMap.put("开户行总行", 1);
ignoreMap.put("开户行省", 1);
ignoreMap.put("开户行市", 1);
ignoreMap.put("开户行支行", 1);
ignoreMap.put("银行卡号", 1);
ignoreMap.put("手机号码", 1);
ignoreMap.put("计税月份", 1);
ignoreMap.put("工资发放时间(立即发、暂停发)", 1);
Integer maxColumn = detailList.size() + 10;
// 是否固定列,true是,原逻辑,false否,忽略没配置的表头
boolean isFixedColumn = true;
if (Common.isNotNull(original.getIsFixedColumn()) && CommonConstants.ZERO_INT == original.getIsFixedColumn()) {
isFixedColumn = false;
maxColumn = null;
}
// 不固定表头配置
Map<String, TSalaryStandardOriginalDetail> notFixedTitleMap = new HashMap<>();
// 判断是否已重复存在
Map<String, Integer> curMap = new HashMap<>();
for (TSalaryStandardOriginalDetail detail : detailList) {
if (Common.isEmpty(detail.getModelName())
&& ("是否新员工(默认否)".equals(detail.getExcelName())
|| "开户行总行".equals(detail.getExcelName())
|| "开户行省".equals(detail.getExcelName())
|| "开户行市".equals(detail.getExcelName())
|| "开户行支行".equals(detail.getExcelName())
|| "银行卡号".equals(detail.getExcelName())
|| "手机号码".equals(detail.getExcelName())
|| "计税月份".equals(detail.getExcelName()))) {
&& (ignoreMap.get(detail.getExcelName()) != null)) {
detail.setModelName(detail.getExcelName());
} else if (SalaryConstants.ID_NUMBER.equals(detail.getModelName())) {
idCardNum = detail.getColumnNo();
}
if (isFixedColumn) {
detailMap.put(String.valueOf(detail.getColumnNo()), detail);
} else {
if (Common.isNotNull(detail.getModelName()) || ignoreMap.get(detail.getExcelName()) != null) {
if (Common.isNotNull(detail.getExcelKey())) {
notFixedTitleMap.put(detail.getExcelKey(), detail);
} else {
notFixedTitleMap.put(detail.getExcelName(), detail);
}
}
}
}
//对前端传递的文件进行校验
if (Common.isEmpty(sheetName)) {
......@@ -859,50 +885,91 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} else {
return R.failed(voR == null ? "识别表格异常!" : voR.getMsg());
}
// 验证表头:
if (vo.getTitleList() != null && !vo.getTitleList().isEmpty()) {
ExcelColumnVo title;
TSalaryStandardOriginalDetail detail;
// 标题行的内容
String titleStr;
TSalaryStandardOriginalDetail detailSet;
// 匹配的表头关键字
String key;
// 匹配规则
String rule;
boolean isFixError;
boolean isError;
boolean isOther;
// 重复存在的表头值
Integer curValue;
for (int i = 0; i < vo.getTitleList().size(); i++) {
isError = true;
rule = "等于";
title = vo.getTitleList().get(i);
if (Common.isNotNull(title.getContent())) {
if (detailMap.get(String.valueOf(title.getLineNum())) == null) {
if (!"是否新员工(默认否)".equals(title.getContent())
&& !"开户行总行".equals(title.getContent())
&& !"开户行省".equals(title.getContent())
&& !"开户行市".equals(title.getContent())
&& !"开户行支行".equals(title.getContent())
&& !"银行卡号".equals(title.getContent())
&& !"手机号码".equals(title.getContent())
&& !"计税月份".equals(title.getContent()) && title.getLineNum() <detailList.size()) {
titleStr = title.getContent();
isOther = ignoreMap.get(titleStr) == null;
if (Common.isNotNull(titleStr)) {
// 固定表头
if (isFixedColumn) {
detailSet = detailMap.get(String.valueOf(title.getLineNum()));
if (detailSet == null) {
if (ignoreMap.get(titleStr) == null && title.getLineNum() < detailList.size()) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!");
//return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
} else if ("是否新员工(默认否)".equals(title.getContent())
|| "开户行总行".equals(title.getContent())
|| "开户行省".equals(title.getContent())
|| "开户行市".equals(title.getContent())
|| "开户行支行".equals(title.getContent())
|| "银行卡号".equals(title.getContent())
|| "手机号码".equals(title.getContent())
|| "计税月份".equals(title.getContent())) {
} else if (ignoreMap.get(titleStr) != null) {
detail = new TSalaryStandardOriginalDetail();
detail.setModelName(title.getContent());
detail.setModelName(titleStr);
detailMap.put(String.valueOf(title.getLineNum()), detail);
}
} else if (!title.getContent().equals(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())
&& (!"是否新员工(默认否)".equals(title.getContent())
|| !"开户行总行".equals(title.getContent())
|| !"开户行省".equals(title.getContent())
|| !"开户行市".equals(title.getContent())
|| !"开户行支行".equals(title.getContent())
|| !"银行卡号".equals(title.getContent())
|| !"手机号码".equals(title.getContent())
|| !"计税月份".equals(title.getContent()))
) {
} else {
if (Common.isNotNull(detailSet.getExcelKey())) {
key = detailSet.getExcelKey();
} else {
key = detailSet.getExcelName();
}
if (Common.isNotNull(detailSet.getExcelRule())) {
rule = detailSet.getExcelRule();
}
switch (rule) {
case "等于" : isError = !titleStr.equals(key); break;
case "包含" : isError = !titleStr.contains(key); break;
default: isError = !titleStr.equals(key); break;
}
if (isError && isOther) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!");
}
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为【" + title.getContent() + "】")
}
} else if (detailMap.get(String.valueOf(title.getLineNum())) != null && Common.isNotNull(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())) {
} else {
// 循环匹配不固定表头
for (Map.Entry<String, TSalaryStandardOriginalDetail> entry : notFixedTitleMap.entrySet()) {
key = entry.getKey();
rule = entry.getValue().getExcelRule();
switch (rule) {
case "等于" : isFixError = !titleStr.equals(key); break;
case "包含" : isFixError = !titleStr.contains(key); break;
default: isFixError = !titleStr.equals(key); break;
}
// 表示匹配到了
if (!isFixError) {
isError = false;
curValue = curMap.get(key);
if (Common.isNotNull(curValue)) {
return R.failed("监测到多个“关键字"+ key +"”,请检查调整后再次提交");
} else {
curMap.put(key, 1);
}
// 存储适配map,以做识别内容
detailMap.put(String.valueOf(title.getLineNum()), entry.getValue());
break;
}
}
if (isError && isOther) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!");
}
}
} else if (isFixedColumn && detailMap.get(String.valueOf(title.getLineNum())) != null && Common.isNotNull(detailMap.get(String.valueOf(title.getLineNum())).getExcelName())) {
return R.failed("未找到对应配置的表头,请核实导入的原表信息后,重新尝试!!!");
//return R.failed("表头与导入的不一致,第" + (i + 1) + "列应为【" + detailMap.get(String.valueOf(title.getLineNum())).getExcelName() + "】,实际为空!")
}
......@@ -910,6 +977,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
} else {
return R.failed("表格没有表头,请检查表格数据!");
}
if (vo.getContentList() != null && !vo.getContentList().isEmpty()) {
// 智能识别表头
TSalaryStandardOriginalDetail detail;
......
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