档案归档导入校验

This commit is contained in:
tangfutang 2020-04-17 16:24:01 +08:00
parent 004586ecb4
commit 27b3d64c90

View File

@ -29,7 +29,6 @@ public class MailingContainerNumberImport extends BaseImportExcelCallBack{
*/
String error=""; // 错误描述
boolean flag=false; // 错误描述
String ARCHIVING_CABINET_NO=null; // 导入的邮寄柜号
String CONTRACT_NUMBER=null;
String sql1=""; // 原有的数据
/**
@ -37,38 +36,53 @@ public class MailingContainerNumberImport extends BaseImportExcelCallBack{
*/
List<Map<String, String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = new HashMap<String, String>();
List<String> arrayList = new ArrayList<String>();
List<String> exclarrayList = new ArrayList<String>();
List<String> arrayList = new ArrayList<String>(); //所有申请合同
List<String> exclarrayList = new ArrayList<String>(); //申请编号不在系统中的集合
List<String> exclarrayExist = new ArrayList<String>(); //申请编号在系统中已存在
boolean flagExist=false;
List<String> exclarrayRepeat = new ArrayList<String>(); //excl中的数据重复
boolean flagRepeat=false;
for(BizObject bo:importObjects){
ARCHIVING_CABINET_NO=bo.getAttribute("ARCHIVING_CABINET_NO").getString();
arrayList.add(ARCHIVING_CABINET_NO);
// 通过本次excel中的数据查询导入的表, 判断是否重复
sql1="SELECT ARCHIVING_CABINET_NO,CONTRACT_NUMBER FROM LB_FILE_ARCHIVING_INFO WHERE ARCHIVING_CABINET_NO='"+ARCHIVING_CABINET_NO+"'";
CONTRACT_NUMBER=bo.getAttribute("CONTRACT_NUMBER").getString();
if(arrayList.contains(CONTRACT_NUMBER)){
if(! exclarrayRepeat.contains(CONTRACT_NUMBER)){
exclarrayRepeat.add(CONTRACT_NUMBER);
}
flagRepeat=true;
}
arrayList.add(CONTRACT_NUMBER);
// 通过本次excel中的数据是否在系统中
//sql1="SELECT ARCHIVING_CABINET_NO,CONTRACT_NUMBER FROM LB_FILE_ARCHIVING_INFO WHERE ARCHIVING_CABINET_NO='"+CONTRACT_NUMBER+"'";
sql1="select id from lb_contract_info where contract_no='"+CONTRACT_NUMBER+"'";
List<Map<String, String>> dataList = DataOperatorUtil.getDataBySql(Sqlca, sql1, null);
// 有结果集, 说明重复
if(dataList.size()>0){
if(! exclarrayList.contains(ARCHIVING_CABINET_NO) ){
exclarrayList.add(ARCHIVING_CABINET_NO);
}
// 无结果说明不在系统中
if(dataList.size()<=0){
if(! exclarrayList.contains(CONTRACT_NUMBER) ){
exclarrayList.add(CONTRACT_NUMBER);
}
flag=true;
}
sql1="select id from LB_FILE_ARCHIVING_INFO where CONTRACT_NUMBER='"+CONTRACT_NUMBER+"'";
dataList = DataOperatorUtil.getDataBySql(Sqlca, sql1, null);
// 无结果说明不在系统中
if(dataList.size()>0){
if(! exclarrayExist.contains(CONTRACT_NUMBER) ){
exclarrayExist.add(CONTRACT_NUMBER);
}
flagExist=true;
}
}
if(flagRepeat) {
throw new BusinessException("excl中的合同号:"+String.join(", ", exclarrayRepeat)+"重复,请检查!!!");
}
if(flag) {
throw new BusinessException("excl中的邮寄柜号:"+String.join(", ", exclarrayList)+"已存在 ");
throw new BusinessException("excl中的合同号:"+String.join(", ", exclarrayList)+"在系统中不存在,请检查!!");
}
long count = arrayList.stream().distinct().count();
boolean isRepeat = count < arrayList.size();
if(isRepeat){
Set<String> set = new HashSet<>();
Set<String> exist = new HashSet<>();
for (String s : arrayList) {
if (set.contains(s)) {
exist.add(s);
} else {
set.add(s);
}
}
throw new BusinessException("excl中的邮寄柜号:"+String.join(", ", exist)+"重复。");
if(flagExist) {
throw new BusinessException("excl中的合同号:"+String.join(", ", exclarrayExist)+"在系统中已存在,请检查!!!");
}
}
}