168 lines
5.0 KiB
Java
168 lines
5.0 KiB
Java
package com.tenwa.customer.cache;
|
||
|
||
import com.amarsoft.awe.util.ASResultSet;
|
||
import com.amarsoft.awe.util.SqlObject;
|
||
import com.amarsoft.awe.util.Transaction;
|
||
import com.amarsoft.dict.als.cache.CacheLoaderFactory;
|
||
|
||
public class CustomerInfoCache {
|
||
|
||
public static String getProvince(String customerId) throws Exception{
|
||
String province="";
|
||
Transaction Sqlca =null;
|
||
String companySql = "select provincecode from customer_company where customerid=:customerid ";
|
||
String personSql = "select province from customer_person where customerid=:customerid ";
|
||
try {
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
SqlObject aSql = new SqlObject(companySql);
|
||
aSql.setParameter("customerid", customerId);
|
||
ASResultSet rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
|
||
if(rs.next()){
|
||
province = rs.getStringValue("provincecode");
|
||
}else{
|
||
aSql = new SqlObject(personSql);
|
||
aSql.setParameter("customerid", customerId);
|
||
rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
if(rs.next()){
|
||
province = rs.getStringValue("province");
|
||
}
|
||
}
|
||
String sql="SELECT itemname FROM code_library WHERE codeno='AreaCode' AND itemno=:itemno ";
|
||
aSql = new SqlObject(sql);
|
||
aSql.setParameter("itemno",province);
|
||
rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
if(rs.next()){
|
||
province=rs.getStringValue("itemname");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(Sqlca!=null){
|
||
Sqlca.disConnect();
|
||
Sqlca = null;
|
||
}
|
||
}
|
||
return province;
|
||
}
|
||
public static String getCity(String customerId) throws Exception{
|
||
String city="";
|
||
Transaction Sqlca =null;
|
||
String companySql = "select citycode from customer_company where customerid=:customerid ";
|
||
String personSql = "select city from customer_person where customerid=:customerid ";
|
||
try {
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
SqlObject aSql = new SqlObject(companySql);
|
||
aSql.setParameter("customerid", customerId);
|
||
ASResultSet rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
|
||
if(rs.next()){
|
||
city = rs.getStringValue("citycode");
|
||
}else{
|
||
aSql = new SqlObject(personSql);
|
||
aSql.setParameter("customerid", customerId);
|
||
rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
if(rs.next()){
|
||
city = rs.getStringValue("city");
|
||
}
|
||
}
|
||
String sql="SELECT itemname FROM code_library WHERE codeno='AreaCode' AND itemno=:itemno";
|
||
aSql = new SqlObject(sql);
|
||
aSql.setParameter("itemno",city);
|
||
rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
if(rs.next()){
|
||
city=rs.getStringValue("itemname");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(Sqlca!=null){
|
||
Sqlca.disConnect();
|
||
Sqlca = null;
|
||
}
|
||
}
|
||
return city;
|
||
}
|
||
|
||
/**
|
||
* <20><><EFBFBD>ݿͻ<DDBF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>ͻ<EFBFBD><CDBB>б<EFBFBD><D0B1>Ŀͻ<C4BF><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֶ<EFBFBD>
|
||
* @param customerId
|
||
* @return
|
||
* @throws Exception
|
||
*/
|
||
public static String getCustType(String customerId) throws Exception{
|
||
String custtype="";
|
||
Transaction Sqlca =null;
|
||
String sql = "select * from customer_type where customerid=:customerid and status='valid' ";
|
||
try {
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
SqlObject asql = new SqlObject(sql);
|
||
asql.setParameter("customerid", customerId);
|
||
ASResultSet rs = null;
|
||
rs = Sqlca.getASResultSet(asql);
|
||
while(rs.next()){
|
||
custtype += rs.getStringValue("custtype")+",";
|
||
}
|
||
if(custtype.length()>0)custtype=custtype.substring(0, custtype.length()-1);
|
||
String[] type=custtype.split(",");
|
||
custtype="";
|
||
for(int i=0;i<type.length;i++){
|
||
sql="SELECT itemname FROM code_library WHERE codeno='cust_type' AND itemno=:itemno";
|
||
asql = new SqlObject(sql);
|
||
asql.setParameter("itemno", type[i]);
|
||
rs = Sqlca.getASResultSet(asql);
|
||
if(rs.next()){
|
||
custtype+=rs.getStringValue("itemname")+",";
|
||
}
|
||
}
|
||
if(custtype.length()>0){
|
||
custtype=custtype.substring(0, custtype.length()-1);
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(Sqlca!=null){
|
||
Sqlca.disConnect();
|
||
Sqlca = null;
|
||
}
|
||
}
|
||
return custtype;
|
||
}
|
||
public static String getCustomerName(String lulId,String assid) throws Exception{
|
||
String customername="";
|
||
String customerId="";
|
||
if("".equals(lulId)||null==lulId){
|
||
customerId=assid;
|
||
}else{
|
||
customerId=lulId;
|
||
}
|
||
Transaction Sqlca =null;
|
||
String companySql = "select customername from customer_info where customerid=:customerid ";
|
||
try {
|
||
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
|
||
SqlObject aSql = new SqlObject(companySql);
|
||
aSql.setParameter("customerid", customerId);
|
||
ASResultSet rs = null;
|
||
rs = Sqlca.getASResultSet(aSql);
|
||
|
||
if(rs.next()){
|
||
customername = rs.getStringValue("customername");
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if(Sqlca!=null){
|
||
Sqlca.disConnect();
|
||
Sqlca = null;
|
||
}
|
||
}
|
||
return customername;
|
||
}
|
||
}
|