📄 ordertrackutil.java
字号:
/**
*
*/
package com.air.backend.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.air.exceptions.AirException;
import com.air.form.DestineForm;
import com.air.model.Destine;
import com.air.model.Fight;
import com.air.persistence.DataSrcUtil;
import com.air.persistence.IsqlDataSource;
import com.air.util.ValHelper;
/**
* @author jelly_yang
*
*/
public class OrderTrackUtil {
private static Log log = LogFactory.getLog(ShowOrdersUtil.class);
private OrderTrackUtil() {
// TODO Auto-generated constructor stub
}
public static class OrderTrackUtilHolder{
static OrderTrackUtil orderTrackUtil = new OrderTrackUtil();
}
public static OrderTrackUtil getInstance(){
return OrderTrackUtilHolder.orderTrackUtil;
}
public Destine getOrdersByNameAndPhone(DestineForm destineForm)throws AirException{
Destine destine = new Destine();
Map<String,String> result = new HashMap<String,String>();
String sSql = "select * from destine where contact_person='"+destineForm.getContactPerson()+
"' and contact_phone='"+destineForm.getContactPhone()+"'";
IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
Connection conn = null;
log.debug("retrieveFight() -- sSql["+ sSql+ "]");
try
{
conn = src.getConnection();
result = src.retrieveSingleRow(conn, sSql);
}
catch(SQLException se)
{
log.error("getUsers() caught SQLException: " + se);
}
catch(Exception ex)
{
log.error("getUsers() caught Exception: " + ex);
}
finally
{
src.closeConn(conn);
}
if(!result.isEmpty())
{
String destineId = ValHelper.getInstance().getValue(result, "did");
String fightId = ValHelper.getInstance().getValue(result, "fid");
String status = ValHelper.getInstance().getValue(result, "status");
destine.setDestineId(destineId);
destine.setFightId(fightId);
destine.setStatus(status);
}
return destine;
}
public Fight getFightsById(String fid)throws AirException{
Fight fight = new Fight();
Map<String, String> result = new HashMap<String, String>();
String sSql = "select * from fights where fid="+fid;
IsqlDataSource src = DataSrcUtil.getInstance().getDataSource();
Connection conn = null;
log.debug("retrieveFight() -- sSql["+ sSql+ "]");
try
{
conn = src.getConnection();
result = src.retrieveSingleRow(conn, sSql);
}
catch(SQLException se)
{
log.error("getUsers() caught SQLException: " + se);
}
catch(Exception ex)
{
log.error("getUsers() caught Exception: " + ex);
}
finally
{
src.closeConn(conn);
}
if(!result.isEmpty())
{
Integer fightId = ValHelper.getInstance().getIntValue(result, "fid");
String fightName = ValHelper.getInstance().getValue(result, "fight_name");
String fightNo = ValHelper.getInstance().getValue(result, "fight_no");
String leaveCity = ValHelper.getInstance().getValue(result, "leave_city");
String arriveCity = ValHelper.getInstance().getValue(result, "arrive_city");
String leaveTime = ValHelper.getInstance().getValue(result, "leave_time");
String arriveTime = ValHelper.getInstance().getValue(result, "arrive_time");
double price = ValHelper.getInstance().getDoubleValue(result, "price");
double fuelRate = Double.parseDouble(ValHelper.getInstance().getValue(result, "fuel_rate"));
double buildRate = Double.parseDouble(ValHelper.getInstance().getValue(result, "build_rate"));
String leaveDate = ValHelper.getInstance().getValue(result, "leave_date");
Integer specialNum = ValHelper.getInstance().getIntValue(result, "special_num");
Integer economicNum = ValHelper.getInstance().getIntValue(result, "economic_num");
Integer businessNum = ValHelper.getInstance().getIntValue(result, "business_num");
Integer headNum = ValHelper.getInstance().getIntValue(result, "head_num");
fight.setFightId(fightId);
fight.setLeaveDate(leaveDate.substring(0,10));
fight.setFightName(fightName);
fight.setFightNo(fightNo);
fight.setLeaveCity(leaveCity);
fight.setArriveCity(arriveCity);
fight.setLeaveTime(leaveTime);
fight.setArriveTime(arriveTime);
fight.setPrice(price);
fight.setFuelRate(fuelRate);
fight.setBuildRate(buildRate);
fight.setSpecialNum(specialNum);
fight.setEconomicNum(economicNum);
fight.setBusinessNum(businessNum);
fight.setHeadNum(headNum);
}
return fight;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -