<%@ page import="weaver.conn.RecordSet" %>


<%@ page import="java.util.ArrayList" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="com.icbc.api.internal.apache.http.impl.cookie.S" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>


<%
    String id = request.getParameter("id");
    // out.print(id);
    ArrayList<Map<String, String>> sourceidsList = new ArrayList<Map<String, String>>();
    RecordSet recordSet = new RecordSet();
    BaseBean baseBean = new BaseBean();
    recordSet.executeQuery("select lcbt from uf_CCSPDTZ where id = ?",id);
    int lc = 0;
    if (recordSet.next()){
        lc = Util.getIntValue(recordSet.getString("lcbt"));
    }
    // out.print(lc+"\n");

    String sqlWhere = " where JouneryID ";
    String FlightsqlWhere = " where JourneyID ";
    String HotelsqlWhere = " where HotelRelatedJourneyNo ";

    // uf_CCBGJLB
    recordSet.executeQuery("select mainid from uf_CCBGJLB_dt1 where ccbgjllc = ?",lc);
    if(recordSet.getCounts() == 0){
        // recordSet.executeQuery("select lc from uf_CCBGJLB ccqqlc = ?",lc);
        // recordSet.next();
        sqlWhere =sqlWhere + "LIKE '"+lc+"%'";
        FlightsqlWhere =FlightsqlWhere + "LIKE '"+lc+"%'";
        HotelsqlWhere =HotelsqlWhere + "LIKE '"+lc+"%'";
    }else {
        recordSet.next();
        String mainid = recordSet.getString("mainid");
        recordSet.executeQuery("select  ccqqlc from uf_CCBGJLB where id = ?",mainid);
        recordSet.next();
        String ccqqlc = recordSet.getString("ccqqlc");
        sqlWhere = sqlWhere + "LIKE '"+ccqqlc+"%'";
        FlightsqlWhere = FlightsqlWhere + "LIKE '"+ccqqlc+"%'";
        HotelsqlWhere = HotelsqlWhere + "LIKE '"+ccqqlc+"%'";
        recordSet.executeQuery("select ccbgjllc from uf_CCBGJLB_dt1 where mainid = ?",mainid);
        while (recordSet.next()){
            String ccbgjllc = recordSet.getString("ccbgjllc");
            sqlWhere =sqlWhere + " or JouneryID LIKE '"+ccbgjllc+"%'";
            FlightsqlWhere =FlightsqlWhere + " or JourneyID LIKE '"+ccbgjllc+"%'";
            HotelsqlWhere =HotelsqlWhere + " or HotelRelatedJourneyNo LIKE '"+ccbgjllc+"%'";
        }
    }
    // out.print(sqlWhere+"\n");
    // sqlWhere = sqlWhere + "or JouneryID LIKE '"+332337+"%'";
    baseBean.writeLog("sqlWhere===>"+sqlWhere);
    recordSet.execute("select * from ctrip_SettlemenTrainOrdert" + sqlWhere);

    while (recordSet.next()) {
        HashMap<String, String> map = new HashMap<>();
        map.put("JouneryID", Util.null2String(recordSet.getString("JouneryID")));
        map.put("OrderId", Util.null2String(recordSet.getString("OrderId")));
        map.put("DetailType", getTypeName(Util.null2String(recordSet.getString("DetailType"))));
        map.put("Type", "火车");
        map.put("PassengerName", Util.null2String(recordSet.getString("PassengerName")));
        map.put("DepartureCityName", Util.null2String(recordSet.getString("DepartureCityName")));
        map.put("DepartureDateTime", Util.null2String(recordSet.getString("DepartureDateTime")));
        map.put("ArrivalDateTime", Util.null2String(recordSet.getString("ArrivalDateTime")));
        map.put("DepartureStationName", Util.null2String(recordSet.getString("DepartureStationName")));
        map.put("ArrivalStationName", Util.null2String(recordSet.getString("ArrivalStationName")));
        sourceidsList.add(map);
    }
    recordSet.execute("select * from ctrip_SettlemenFlightOrdert" + FlightsqlWhere);
    while (recordSet.next()) {
        HashMap<String, String> map = new HashMap<>();
        map.put("JouneryID", Util.null2String(recordSet.getString("JourneyID")));
        map.put("OrderId", Util.null2String(recordSet.getString("OrderId")));
        map.put("DetailType", getTypeName(Util.null2String(recordSet.getString("DetailType"))));
        map.put("Type", "飞机");
        map.put("PassengerName", Util.null2String(recordSet.getString("PassengerName")));
        map.put("DepartureCityName", Util.null2String(recordSet.getString("DCityName")));
        map.put("DepartureDateTime", Util.null2String(recordSet.getString("TakeOffTime2")));
        map.put("ArrivalDateTime", Util.null2String(recordSet.getString("ArrivalTime2")));
        map.put("DepartureStationName", Util.null2String(recordSet.getString("DPortName")));
        map.put("ArrivalStationName", Util.null2String(recordSet.getString("APortName")));
        sourceidsList.add(map);
    }
    recordSet.execute("select * from ctrip_SettlemenHotelOrdert" + HotelsqlWhere);
    while (recordSet.next()) {
        HashMap<String, String> map = new HashMap<>();
        map.put("JouneryID", Util.null2String(recordSet.getString("HotelRelatedJourneyNo")));
        map.put("OrderId", Util.null2String(recordSet.getString("OrderId")));
        map.put("DetailType", getTypeName(Util.null2String(recordSet.getString("DetailType"))));
        map.put("Type", "酒店");
        map.put("PassengerName", Util.null2String(recordSet.getString("CityName")));
        map.put("DepartureCityName", Util.null2String(recordSet.getString("DepartureCityName")));
        map.put("DepartureDateTime", Util.null2String(recordSet.getString("StartTime")));
        map.put("ArrivalDateTime", Util.null2String(recordSet.getString("EndTime")));
        map.put("DepartureStationName", Util.null2String(recordSet.getString("HotelName")));
        map.put("ArrivalStationName", Util.null2String(recordSet.getString("HotelName")));
        sourceidsList.add(map);
    }
    out.println(JSONObject.toJSONString(sourceidsList));

%>
<%!
    private String getTypeName(String type) {
        String s = "";
        if ("O".equals(type)) {
            s = "出票";
        } else if ("A".equals(type)) {
            s = "改签";
        } else if ("R".equals(type)) {
            s = "退票";
        }
        return s;
    }
%>