招行新模版

This commit is contained in:
cwchen 2025-02-27 18:28:24 +08:00
parent 516b83f1dd
commit f8c35ba173
4 changed files with 164 additions and 53 deletions

View File

@ -23,6 +23,7 @@ import java.net.URLConnection;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Objects;
@Api(tags = "下载") @Api(tags = "下载")
@RestController @RestController
@ -53,6 +54,9 @@ public class DownloadController {
response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate"); response.addHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.addHeader("charset", "utf-8"); response.addHeader("charset", "utf-8");
response.addHeader("Pragma", "no-cache"); response.addHeader("Pragma", "no-cache");
if(Objects.equals(filename,"zh_model.xlsx")){ // 招行新模版
filename = "招商银行工资导入模板(新).xlsx";
}
String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString()); String encodeName = URLEncoder.encode(filename, StandardCharsets.UTF_8.toString());
response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName); response.setHeader("Content-Disposition", "attachment; filename=\"" + encodeName + "\"; filename*=utf-8''" + encodeName);

View File

@ -104,12 +104,25 @@ public class ImportNoPhotoExcelHelper {
private static boolean checkModal(Sheet sheet, String className) { private static boolean checkModal(Sheet sheet, String className) {
int colNum = 0; int colNum = 0;
// 是否是招行新模板
boolean isNewModel = false;
if (className.equals("UploadPayrollBean")){ if (className.equals("UploadPayrollBean")){
colNum = sheet.getRow(1).getLastCellNum(); colNum = sheet.getRow(1).getLastCellNum();
}else if (className.equals("CareerBean")){ }else if (className.equals("CareerBean")){
colNum = sheet.getRow(1).getLastCellNum(); colNum = sheet.getRow(1).getLastCellNum();
}else if (className.equals("WagesDetailsBean")){ }else if (className.equals("WagesDetailsBean")){
colNum = sheet.getRow(5).getLastCellNum(); String applyDateTitle = sheet.getRow(4).getCell(0).getStringCellValue();
if(Objects.equals(applyDateTitle,"申请时间")){
isNewModel = true;
colNum = sheet.getRow(12).getLastCellNum();
System.err.println(sheet.getRow(11).getLastCellNum());
System.err.println(sheet.getRow(12).getLastCellNum());
System.err.println(sheet.getRow(13).getLastCellNum());
}else{
colNum = sheet.getRow(5).getLastCellNum();
}
}else{ }else{
colNum = sheet.getRow(0).getLastCellNum(); colNum = sheet.getRow(0).getLastCellNum();
} }
@ -123,7 +136,11 @@ public class ImportNoPhotoExcelHelper {
case "CareerBean": case "CareerBean":
return colNum == 12; return colNum == 12;
case "WagesDetailsBean": case "WagesDetailsBean":
return colNum >= 18; if(isNewModel){
return colNum >= 7;
}else{
return colNum >= 18;
}
case "VoucherDetailsBean": case "VoucherDetailsBean":
return colNum == 28; return colNum == 28;
case "CCBWagesDetailsBean": case "CCBWagesDetailsBean":
@ -140,8 +157,17 @@ public class ImportNoPhotoExcelHelper {
} }
List<JSONObject> list = new ArrayList<>(); List<JSONObject> list = new ArrayList<>();
int last = 0; int last = 0;
// 是否是招行新模板
boolean isNewModel = false;
Map<String, String> zhDataMap = new HashMap<>(); // 存放招行新模板通用数据
if (className.equals("WagesDetailsBean")){ if (className.equals("WagesDetailsBean")){
last = sheet.getRow(5).getLastCellNum(); String applyDateTitle = sheet.getRow(4).getCell(0).getStringCellValue();
if(Objects.equals(applyDateTitle,"申请时间")){
isNewModel = true;
last = sheet.getRow(12).getLastCellNum();
}else{
last = sheet.getRow(5).getLastCellNum();
}
}else{ }else{
last = sheet.getRow(0).getLastCellNum(); last = sheet.getRow(0).getLastCellNum();
} }
@ -193,7 +219,54 @@ public class ImportNoPhotoExcelHelper {
if (row.getRowNum() < 2) continue; if (row.getRowNum() < 2) continue;
break; break;
case "WagesDetailsBean": case "WagesDetailsBean":
if (row.getRowNum() < 5) continue; if(isNewModel){
if (row.getRowNum() < 3) {
continue;
}else if(row.getRowNum() == 4){
// 申请时间主账号
row.getCell(1).setCellType(CellType.STRING);
row.getCell(3).setCellType(CellType.STRING);
String applyDate = row.getCell(1).getStringCellValue();
String mainNumber = row.getCell(3).getStringCellValue();
if(StringUtils.isEmpty(applyDate)){
return R.fail("申请时间不能为空");
}
if(StringUtils.isEmpty(mainNumber)){
return R.fail("主账号不能为空");
}
zhDataMap.put("applyDate",applyDate);
zhDataMap.put("mainNumber",mainNumber);
continue;
}else if(row.getRowNum() == 7){
// 业务参考号批次摘要/备注
row.getCell(1).setCellType(CellType.STRING);
row.getCell(3).setCellType(CellType.STRING);
String serviceReferenceNumber = row.getCell(1).getStringCellValue();
String batchSummary = row.getCell(3).getStringCellValue();
if(StringUtils.isEmpty(serviceReferenceNumber)){
return R.fail("业务参考号不能为空");
}
if(StringUtils.isEmpty(batchSummary)){
return R.fail("批次摘要/备注不能为空");
}
zhDataMap.put("serviceReferenceNumber",serviceReferenceNumber);
zhDataMap.put("batchSummary",batchSummary);
continue;
}else if(row.getRowNum() == 8){
row.getCell(1).setCellType(CellType.STRING);
// 主账户名称
String masterAccountName = row.getCell(1).getStringCellValue();
if(StringUtils.isEmpty(masterAccountName)){
return R.fail("主账户名称不能为空");
}
zhDataMap.put("masterAccountName",masterAccountName);
continue;
}else if(row.getRowNum() == 3 || row.getRowNum() == 5 || row.getRowNum() == 6 || (row.getRowNum() > 8 && row.getRowNum() <= 12)){
continue;
}
}else{
if (row.getRowNum() < 5) continue;
}
break; break;
case "CCBWagesDetailsBean": case "CCBWagesDetailsBean":
if (row.getRowNum() < 1) continue; if (row.getRowNum() < 1) continue;
@ -353,59 +426,85 @@ public class ImportNoPhotoExcelHelper {
case "WagesDetailsBean": case "WagesDetailsBean":
int dynamicColumnCount = row.getLastCellNum(); int dynamicColumnCount = row.getLastCellNum();
setExcleTString(dynamicColumnCount, row, 0); setExcleTString(dynamicColumnCount, row, 0);
if (row.getCell(0) != null) if(!isNewModel){
obj.put("zh", row.getCell(0).getStringCellValue()); if (row.getCell(0) != null)
if (row.getCell(1) != null) obj.put("zh", row.getCell(0).getStringCellValue());
obj.put("hm", row.getCell(1).getStringCellValue()); if (row.getCell(1) != null)
if (row.getCell(2) != null) obj.put("hm", row.getCell(1).getStringCellValue());
obj.put("je", row.getCell(2).getStringCellValue()); if (row.getCell(2) != null)
if (row.getCell(3) != null) obj.put("je", row.getCell(2).getStringCellValue());
obj.put("sjdkje", row.getCell(3).getStringCellValue()); if (row.getCell(3) != null)
if (row.getCell(4) != null) obj.put("sjdkje", row.getCell(3).getStringCellValue());
obj.put("zt", row.getCell(4).getStringCellValue()); if (row.getCell(4) != null)
if (row.getCell(5) != null) obj.put("zt", row.getCell(4).getStringCellValue());
obj.put("zs", row.getCell(5).getStringCellValue()); if (row.getCell(5) != null)
if (row.getCell(6) != null) obj.put("zs", row.getCell(5).getStringCellValue());
obj.put("ckh", row.getCell(6).getStringCellValue()); if (row.getCell(6) != null)
if (row.getCell(7) != null) obj.put("ckh", row.getCell(6).getStringCellValue());
obj.put("ts", row.getCell(7).getStringCellValue()); if (row.getCell(7) != null)
if (row.getCell(8) != null) obj.put("ts", row.getCell(7).getStringCellValue());
obj.put("khh", row.getCell(8).getStringCellValue()); if (row.getCell(8) != null)
if (row.getCell(9) != null) obj.put("khh", row.getCell(8).getStringCellValue());
obj.put("khd", row.getCell(9).getStringCellValue()); if (row.getCell(9) != null)
if (row.getCell(10) != null) obj.put("khd", row.getCell(9).getStringCellValue());
obj.put("jbr", row.getCell(10).getStringCellValue()); if (row.getCell(10) != null)
if (row.getCell(11) != null) obj.put("jbr", row.getCell(10).getStringCellValue());
obj.put("qwr", row.getCell(11).getStringCellValue()); if (row.getCell(11) != null)
if (row.getCell(12) != null) obj.put("qwr", row.getCell(11).getStringCellValue());
obj.put("sfkzhm", row.getCell(12).getStringCellValue()); if (row.getCell(12) != null)
if (row.getCell(13) != null) obj.put("sfkzhm", row.getCell(12).getStringCellValue());
obj.put("sfkzh", row.getCell(13).getStringCellValue()); if (row.getCell(13) != null)
if (row.getCell(14) != null) obj.put("sfkzh", row.getCell(13).getStringCellValue());
obj.put("yt", row.getCell(14).getStringCellValue()); if (row.getCell(14) != null)
if (row.getCell(15) != null) obj.put("yt", row.getCell(14).getStringCellValue());
obj.put("ywckh", row.getCell(15).getStringCellValue()); if (row.getCell(15) != null)
if (row.getCell(16) != null) obj.put("ywckh", row.getCell(15).getStringCellValue());
obj.put("lx", row.getCell(16).getStringCellValue()); if (row.getCell(16) != null)
if (row.getCell(17) != null) obj.put("lx", row.getCell(16).getStringCellValue());
obj.put("qdbz", row.getCell(17).getStringCellValue()); if (row.getCell(17) != null)
obj.put("qdbz", row.getCell(17).getStringCellValue());
// if (row.getCell(18) != null) // if (row.getCell(18) != null)
// obj.put("hnbz", row.getCell(18).getStringCellValue()); // obj.put("hnbz", row.getCell(18).getStringCellValue());
// 处理第18列之后的所有列 // 处理第18列之后的所有列
StringBuilder additionalData = new StringBuilder(); StringBuilder additionalData = new StringBuilder();
for (int i = 18; i < dynamicColumnCount; i++) { for (int i = 18; i < dynamicColumnCount; i++) {
Cell cell = row.getCell(i); Cell cell = row.getCell(i);
if (cell != null) { if (cell != null) {
String columnName = sheet.getRow(5).getCell(i).getStringCellValue(); String columnName = sheet.getRow(5).getCell(i).getStringCellValue();
String cellValue = cell.getStringCellValue(); String cellValue = cell.getStringCellValue();
if (additionalData.length() > 0) { if (additionalData.length() > 0) {
additionalData.append("; "); additionalData.append("; ");
}
additionalData.append(columnName).append(": ").append(cellValue);
} }
additionalData.append(columnName).append(": ").append(cellValue);
} }
} if (additionalData.length() > 0) {
if (additionalData.length() > 0) { obj.put("additionalData", additionalData.toString());
obj.put("additionalData", additionalData.toString()); }
}else{
if (row.getCell(0) != null) // 员工姓名
obj.put("hm", row.getCell(0).getStringCellValue());
if (row.getCell(1) != null) // 个人账号
obj.put("zh", row.getCell(1).getStringCellValue());
if (row.getCell(2) != null) // 开户行
obj.put("khh", row.getCell(2).getStringCellValue());
if (row.getCell(3) != null) // 代发金额
obj.put("je", row.getCell(3).getStringCellValue());
if (row.getCell(4) != null) // 代发状态
obj.put("zt", row.getCell(4).getStringCellValue());
if (row.getCell(5) != null) // 失败原因
obj.put("ts", row.getCell(5).getStringCellValue());
if (row.getCell(6) != null) // 备注
obj.put("additionalData", row.getCell(6).getStringCellValue());
obj.put("zs", "网上代发代扣");
obj.put("jbr", zhDataMap.get("applyDate"));
obj.put("qwr", zhDataMap.get("applyDate"));
obj.put("sfkzhm", zhDataMap.get("masterAccountName"));
obj.put("sfkzh", zhDataMap.get("mainNumber"));
obj.put("yt", zhDataMap.get("batchSummary"));
obj.put("ywckh", zhDataMap.get("serviceReferenceNumber"));
obj.put("lx", "代发其他");
obj.put("qdbz", "超网代发");
} }
break; break;
case "CCBWagesDetailsBean": case "CCBWagesDetailsBean":

Binary file not shown.

View File

@ -48,6 +48,7 @@
<div class="layui-inline" style="float: right;"> <div class="layui-inline" style="float: right;">
<button type="button" class="layui-btn" onclick="downloadVoucher()">下载凭证模板</button> <button type="button" class="layui-btn" onclick="downloadVoucher()">下载凭证模板</button>
<button type="button" class="layui-btn" onclick="downloadWages()">下载工资册模板</button> <button type="button" class="layui-btn" onclick="downloadWages()">下载工资册模板</button>
<button type="button" class="layui-btn" onclick="downloadNewWages()">下载工资册模板(新)</button>
</div> </div>
</div> </div>
</form> </form>
@ -190,6 +191,13 @@
function downloadWages() { function downloadWages() {
window.open(ctxPath + "/download/download?filename=招商银行工资导入模板.xlsx") window.open(ctxPath + "/download/download?filename=招商银行工资导入模板.xlsx")
} }
/**
* 下载工资册模板(新)
* */
function downloadNewWages() {
window.open(ctxPath + "/download/download?filename=zh_model.xlsx")
}
</script> </script>
</body> </body>
</html> </html>