apzl_leasing/src_tenwa/com/tenwa/apzl/discount/ModelLibraryImport.java
2019-06-06 10:35:55 +08:00

75 lines
2.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.tenwa.apzl.discount;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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 ModelLibraryImport 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 cars=null; // 导入的车系
String brand=null; // 导入的品牌
String models=null; // 导入的车辆类型
String series_name=null; // 原有的车系
String brand_name=null; // 原有的品牌
String car_type=null; // 原有的车辆类型
String sql1=""; // 原有的车辆类型
/**
* 校验本次Excel是否有重复的
*/
/**
* 校验本次导入数据在导入表是否已有
*/
List<Map<String, String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = new HashMap<String, String>();
for(BizObject bo:importObjects){
cars=bo.getAttribute("cars").getString();
brand=bo.getAttribute("brand").getString();
models=bo.getAttribute("models").getString();
// 通过本次excel中的数据查询导入的表, 判断是否重复
sql1="SELECT brand FROM li_cardata_commercial WHERE cars='"+cars+"' AND brand='"+brand+"' AND models='"+models+"'";
List<Map<String, String>> dataList = DataOperatorUtil.getDataBySql(Sqlca, sql1, null);
// 有结果集, 说明重复
if(dataList !=null || !dataList.isEmpty()){
error="【品牌: "+brand+", 车系: "+cars+", 车型 : "+models+"";
flag=true;
}
}
if(flag) {
error = error.substring(1);
throw new BusinessException(error+"已存在 ");
}
}
@SuppressWarnings("unchecked")
@Override
public void runAfter(ASUser CurUser, Map<String, String> model, List<BizObject> importObjects, JBOTransaction tx,
Transaction Sqlca) throws Exception {
// 商用车车型导入配置
Sqlca.executeSQL(new SqlObject("{call proc_insert_shangyongche()}"));
}
}