修改bug#40674

This commit is contained in:
梁琦涛
2021-10-14 16:57:16 +08:00
parent 0eddd9727b
commit e5795a5a19
5 changed files with 57 additions and 36 deletions
@@ -647,8 +647,14 @@ public class PayCompanyManagementController extends JeroController<PayCompanyMan
//导入Excel格式校验,看匹配的字段文本概率 //导入Excel格式校验,看匹配的字段文本概率
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayCompanyManagement.class, params); Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayCompanyManagement.class, params);
if(!t){ if(!t){
throw new JeroBootException("导入Excel校验失败 !"); throw new JeroBootException("文件格式有误,请下载模板后上传 !");
} }
}catch (Exception e){
e.printStackTrace();
throw new JeroBootException("文件格式有误,请下载模板后上传 !");
}
StringBuilder msg = new StringBuilder();
try {
List<PayCompanyManagement> list = ExcelImportUtil.importExcel(file.getInputStream(), PayCompanyManagement.class, params); List<PayCompanyManagement> list = ExcelImportUtil.importExcel(file.getInputStream(), PayCompanyManagement.class, params);
if(!CollectionUtils.isEmpty(list)){ if(!CollectionUtils.isEmpty(list)){
List<PayCompanyManagement> listSigning = new ArrayList<>(); List<PayCompanyManagement> listSigning = new ArrayList<>();
@@ -661,7 +667,6 @@ public class PayCompanyManagementController extends JeroController<PayCompanyMan
List<PayCompanyManagement> listDutyCodeAll = payCompanyManagementService.list(queryPayCompanyManagement); List<PayCompanyManagement> listDutyCodeAll = payCompanyManagementService.list(queryPayCompanyManagement);
List<String> listCompany = new ArrayList<>(); List<String> listCompany = new ArrayList<>();
List<String> listDutyCode = new ArrayList<>(); List<String> listDutyCode = new ArrayList<>();
StringBuilder msg = new StringBuilder();
int finalDataSource = dataSource; int finalDataSource = dataSource;
int finalStatus = status; int finalStatus = status;
list.forEach(p->{ list.forEach(p->{
@@ -709,6 +714,8 @@ public class PayCompanyManagementController extends JeroController<PayCompanyMan
} }
// 更新数据 // 更新数据
payCompanyManagementService.updateCompanyData(listSigning,list); payCompanyManagementService.updateCompanyData(listSigning,list);
}else{
msg.append("没有数据可导入!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
@@ -720,6 +727,9 @@ public class PayCompanyManagementController extends JeroController<PayCompanyMan
e.printStackTrace(); e.printStackTrace();
} }
} }
if(!StringUtils.isEmpty(msg)){
return Result.error(msg.toString());
}
} }
return Result.OK("文件导入成功!"); return Result.OK("文件导入成功!");
} }
@@ -688,8 +688,14 @@ public class PayContactsManagementController extends JeroController<PayContactsM
//导入Excel格式校验,看匹配的字段文本概率 //导入Excel格式校验,看匹配的字段文本概率
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayContactsManagement.class, params); Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayContactsManagement.class, params);
if(!t){ if(!t){
throw new RuntimeException("导入Excel校验失败 !"); throw new JeroBootException("文件格式有误,请下载模板后上传 !");
} }
}catch (Exception e){
e.printStackTrace();
throw new JeroBootException("文件格式有误,请下载模板后上传 !");
}
StringBuilder msg = new StringBuilder();
try {
List<PayContactsManagement> list = ExcelImportUtil.importExcel(file.getInputStream(), PayContactsManagement.class, params); List<PayContactsManagement> list = ExcelImportUtil.importExcel(file.getInputStream(), PayContactsManagement.class, params);
if(!CollectionUtils.isEmpty(list)){ if(!CollectionUtils.isEmpty(list)){
List<PayContactsManagement> listSigning = new ArrayList<>(); List<PayContactsManagement> listSigning = new ArrayList<>();
@@ -713,7 +719,6 @@ public class PayContactsManagementController extends JeroController<PayContactsM
listCompanyAll = payCompanyManagementService.listPayCompanyManagement(companyList); listCompanyAll = payCompanyManagementService.listPayCompanyManagement(companyList);
} }
List<PayContactsManagement> listContacts = new ArrayList<>(); List<PayContactsManagement> listContacts = new ArrayList<>();
StringBuilder msg = new StringBuilder();
List<PayCompanyManagement> finalListCompanyAll = listCompanyAll; List<PayCompanyManagement> finalListCompanyAll = listCompanyAll;
List<PayContactsManagement> finalListContactsAll = listContactsAll; List<PayContactsManagement> finalListContactsAll = listContactsAll;
list.forEach(p->{ list.forEach(p->{
@@ -779,6 +784,8 @@ public class PayContactsManagementController extends JeroController<PayContactsM
} }
// 更新数据 // 更新数据
payContactsManagementService.updateContactsData(listSigning,list); payContactsManagementService.updateContactsData(listSigning,list);
}else{
msg.append("没有数据可导入!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(),e);
@@ -790,6 +797,9 @@ public class PayContactsManagementController extends JeroController<PayContactsM
e.printStackTrace(); e.printStackTrace();
} }
} }
if(!StringUtils.isEmpty(msg)){
return Result.error(msg.toString());
}
} }
return Result.OK("文件导入成功!"); return Result.OK("文件导入成功!");
} }
@@ -260,11 +260,11 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
int count = map.size(); int count = map.size();
// 合同信息字段为20个,分期信息为5个 // 合同信息字段为20个,分期信息为5个
if(count < listSpendingContract.size()){ if(count < listSpendingContract.size()){
throw new JeroBootException("excel表头错误!"); throw new JeroBootException("文件格式有误,请下载模板后上传!");
}else { }else {
listSpendingContract.forEach(p->{ listSpendingContract.forEach(p->{
if(!Objects.equals(map.get(listSpendingContract.indexOf(p)),p)){ if(!Objects.equals(map.get(listSpendingContract.indexOf(p)),p)){
throw new JeroBootException("excel表头错误!"); throw new JeroBootException("文件格式有误,请下载模板后上传!");
} }
}); });
int count1 = count - listSpendingContract.size(); int count1 = count - listSpendingContract.size();
@@ -272,7 +272,7 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
Pattern p = Pattern.compile("[0-9]*"); Pattern p = Pattern.compile("[0-9]*");
Matcher m = p.matcher(String.valueOf(count1 / 5)); Matcher m = p.matcher(String.valueOf(count1 / 5));
if (!m.matches()){ if (!m.matches()){
throw new JeroBootException("excel表头错误!"); throw new JeroBootException("文件格式有误,请下载模板后上传!");
} }
int count2 = count1 / listSpendingContractInstallment.size(); int count2 = count1 / listSpendingContractInstallment.size();
for (int i = 1; i <= count2; i++) { for (int i = 1; i <= count2; i++) {
@@ -139,7 +139,6 @@ public class PayWorkingGroupSubItem implements Serializable {
private java.lang.String chargeNoticeNo; private java.lang.String chargeNoticeNo;
/**收费通知文件id*/ /**收费通知文件id*/
@ApiModelProperty(value = "收费通知文件id") @ApiModelProperty(value = "收费通知文件id")
@Size(max = 32,message = "收费通知文件id长度不能大于32个字符")
private java.lang.String chargeNoticeId; private java.lang.String chargeNoticeId;
/**打包(1:是,0:否)*/ /**打包(1:是,0:否)*/
@ApiModelProperty(value = "打包(1:是,0:否)") @ApiModelProperty(value = "打包(1:是,0:否)")
@@ -298,11 +298,11 @@ public class PayWorkingGroupSubItemServiceImpl extends ServiceImpl<PayWorkingGro
try { try {
Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayWorkingGroupSubItem.class, params); Boolean t = ExcelImportCheckUtil.check(file.getInputStream(), PayWorkingGroupSubItem.class, params);
if(!t){ if(!t){
throw new JeroBootException("导入Excel校验失败 !"); throw new JeroBootException("文件格式有误,请下载模板后上传 !");
} }
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new JeroBootException("导入Excel校验失败 !"); throw new JeroBootException("文件格式有误,请下载模板后上传 !");
} }
try { try {
List<PayWorkingGroupSubItem> list = ExcelImportUtil.importExcel(file.getInputStream(), PayWorkingGroupSubItem.class, params); List<PayWorkingGroupSubItem> list = ExcelImportUtil.importExcel(file.getInputStream(), PayWorkingGroupSubItem.class, params);
@@ -506,6 +506,8 @@ public class PayWorkingGroupSubItemServiceImpl extends ServiceImpl<PayWorkingGro
payWorkingGroupSubItemService.saveBatch(list); payWorkingGroupSubItemService.saveBatch(list);
} }
} }
}else{
throw new JeroBootException("没有数据可导入!");
} }
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(),e); log.error(e.getMessage(),e);