apzl_leasing/src_tenwa/com/tenwa/customer/cache/GetContractNumber.java
2018-06-03 22:26:41 +08:00

65 lines
1.8 KiB
Java

package com.tenwa.customer.cache;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.amarsoft.are.jbo.JBOException;
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 GetContractNumber {
public static String getContractNumber(String id) throws JBOException
{
String contNum="";
Transaction Sqlca =null;
try {
Sqlca = Transaction.createTransaction(CacheLoaderFactory.getDataSource());
String sql="SELECT contract_number FROM LB_CONTRACT_INFO WHERE id =:contract_id ";
SqlObject asql = new SqlObject(sql);
asql.setParameter("contract_id", id);
ASResultSet rs = null;
rs = Sqlca.getASResultSet(asql);
if(rs.next()){
contNum=rs.getStringValue("contract_number");
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
if(Sqlca!=null){
Sqlca.disConnect();
Sqlca = null;
}
}
return contNum;
}
public static String getDutyDays(String strStartDate,String strEndDate) {
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
Date startDate=null;
Date endDate = null;
try {
startDate=df.parse(strStartDate);
endDate = df.parse(strEndDate);
} catch (ParseException e) {
System.out.println("非法的日期格式,无法进行转换");
e.printStackTrace();
}
int result = 0;
while (startDate.compareTo(endDate) <= 0) {
if (startDate.getDay() != 6 && startDate.getDay() != 0)
result++;
startDate.setDate(startDate.getDate() + 1);
}
return String.valueOf(result);
}
}