89 lines
3.4 KiB
Java
89 lines
3.4 KiB
Java
package com.tenwa.apzl.comm;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.HashMap;
|
||
import java.util.HashSet;
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
import java.util.Set;
|
||
|
||
import com.amarsoft.are.jbo.BizObject;
|
||
import com.amarsoft.are.jbo.JBOTransaction;
|
||
import com.amarsoft.awe.util.SqlObject;
|
||
import com.amarsoft.awe.util.Transaction;
|
||
import com.amarsoft.context.ASUser;
|
||
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
|
||
import com.tenwa.comm.exception.BusinessException;
|
||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||
import com.tenwa.officetempalte.importcallback.impl.BaseImportExcelCallBack;
|
||
|
||
public class MailingContainerNumberImport extends BaseImportExcelCallBack{
|
||
@Override
|
||
public void run(ASUser CurUser, BizObject importObject,Map<String, String> model, Integer rowIndex, JBOTransaction tx,Transaction Sqlca) throws Exception {
|
||
}
|
||
@Override
|
||
public void runBefore(ASUser CurUser, Map<String, String> model, List<BizObject> importObjects, JBOTransaction tx,Transaction Sqlca) throws Exception {
|
||
Transaction Sqlca1 = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
/**
|
||
* 定义全局变量
|
||
*/
|
||
String error=""; // 错误描述
|
||
boolean flag=false; // 错误描述
|
||
String CONTRACT_NUMBER=null;
|
||
String sql1=""; // 原有的数据
|
||
/**
|
||
* 校验本次导入数据在导入表是否已有
|
||
*/
|
||
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> exclarrayExist = new ArrayList<String>(); //申请编号在系统中已存在
|
||
boolean flagExist=false;
|
||
List<String> exclarrayRepeat = new ArrayList<String>(); //excl中的数据重复
|
||
boolean flagRepeat=false;
|
||
for(BizObject bo:importObjects){
|
||
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(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)+"在系统中不存在,请检查!!!");
|
||
}
|
||
if(flagExist) {
|
||
throw new BusinessException(",excl中的合同号:"+String.join(", ", exclarrayExist)+"在系统中已存在,请检查!!!");
|
||
}
|
||
|
||
}
|
||
}
|