/// <summary> /// Get start-end time list /// </summary> /// <param name="DBline"></param> /// <param name="rangeDate"></param> /// <param name="assy"></param> /// <param name="unit"></param> /// <returns></returns> private List <DtData> GetDtData(string DBline, List <DateTime> rangeDate, string assy, string unit) { List <DtData> dtDataRet = new List <DtData>(); try { XDocument XMLdoc = XDocument.Load(Application.StartupPath + @"\Parameter\Display.xml"); //string url = XMLdoc.Descendants("url").FirstOrDefault().Value; string url = ""; switch (DBHelper.DBremark) { case "kk09": url = XMLdoc.Descendants("urlkk09").FirstOrDefault().Value; break; case "kk08": url = XMLdoc.Descendants("urlkk08").FirstOrDefault().Value; break; //case "kk07": // url = XMLdoc.Descendants("url").FirstOrDefault().Value; // break; } string start_time = rangeDate[0].ToString("yyyy-MM-dd HH:mm:ss"); string end_time = rangeDate[1].ToString("yyyy-MM-dd HH:mm:ss"); //// 测试用start //string start_time = "2019-07-19 08:00:00"; //string end_time = "2019-07-19 16:00:00"; //DBline = "L03"; //assy = "Final"; SummaryDataModel summaryDataModel = new SummaryDataModel() { line_cd = DBline, assy_cd = assy, unit_cd = unit, start = start_time, end = end_time }; string summaryDataModelStr = SerializeObject <SummaryDataModel>(summaryDataModel); string res = PostHttp(url, summaryDataModelStr); ResObjModel <List <DtData> > resObj = DeserializeJsonToObject <ResObjModel <List <DtData> > >(res); foreach (DtData item in resObj.data) { dtDataRet.Add(new DtData { start = item.start, end = item.end }); } return(dtDataRet); } catch (Exception ex) { string str = LogHelper.GetExceptionMsg(ex, "獲取API數據失敗!"); LogHelper.WriteErrorLog(str); return(dtDataRet); } }
/// <summary> /// 数据库查询出数据 /// </summary> /// <param name="inputName"></param> /// <param name="outputName"></param> /// <param name="process_cd"></param> /// <param name="DBline"></param> /// <param name="dayOrNight"></param> /// <param name="nowShifList"></param> /// <returns></returns> //private DataTable QueryDT(string inputName, string outputName, string[] process_cd, string DBline, List<DateTime> rangeDate) //{ // string process_cd_in = string.Format("'{0}', '{1}', '{2}'", inputName, outputName, String.Join("','", process_cd)); // // 查询数据 // //测试用 // string sql = string.Format(@" // SELECT AA.proc_uuid, process_at, judge_text, // ROW_NUMBER() OVER (PARTITION BY AA.proc_uuid ORDER BY process_at) AS rid // FROM( // SELECT proc_uuid,process_cd // FROM m_process // WHERE process_cd in('AE-1') // AND line_cd='L03' // )PP // LEFT JOIN t_insp_kk07 AA ON AA.proc_uuid = pp.proc_uuid // WHERE process_at >= '2018-06-30 20:00' and process_at < '2018-07-01 05:00' // "); // //string sql = string.Format(@" // // SELECT AA.proc_uuid, process_at, judge_text, // // ROW_NUMBER() OVER (PARTITION BY AA.proc_uuid ORDER BY process_at) AS rid // // FROM( // // SELECT proc_uuid,process_cd // // FROM m_process // // WHERE process_cd in({0}) // // AND line_cd='{1}' // // )PP // // LEFT JOIN t_insp_{2} AA ON AA.proc_uuid = pp.proc_uuid // // WHERE process_at >= '{3}' and process_at < '{4}' // //", process_cd_in, DBline, DBHelper.DBremark, rangeDate[0].ToString("yyyy-MM-dd HH:mm"), rangeDate[1].ToString("yyyy-MM-dd HH:mm")); // DataTable dt = new DataTable(); // Console.WriteLine(sql); // new DBHelper().ExecuteDataTable(1, sql, ref dt); // return dt; //} private DataTable QueryDT(string inputName, string outputName, string[] process_cd, string DBline, List <DateTime> rangeDate, string assy) { //string start_time = rangeDate[0].ToString("yyyy-MM-dd HH:mm:ss"); //string end_time = rangeDate[1].ToString("yyyy-MM-dd HH:mm:ss"); string start_time = "http://10.107.171.57:8000"; string end_time = "2019-07-17 17:00:00"; assy = "TUB"; SummaryDataModel summaryDataModel = new SummaryDataModel() { line_cd = DBline, assy_cd = assy, start = start_time, end = end_time }; string summaryDataModelStr = SerializeObject <SummaryDataModel>(summaryDataModel); string url = "http://10.107.171.57:8000/get_status_data_api"; string res = PostHttp(url, summaryDataModelStr); ResObjModel <List <SummaryDataModel> > resObj = DeserializeJsonToObject <ResObjModel <List <SummaryDataModel> > >(res); DataTable dt = new DataTable(); if (resObj.state) { dt.Columns.Add("proc_uuid"); dt.Columns.Add("process_at"); dt.Columns.Add("judge_text"); dt.Columns.Add("rid"); foreach (SummaryDataModel item in resObj.data) { DataRow dr = dt.NewRow(); dr["line_cd"] = item.line_cd.ToString(); dr["assy_cd"] = item.assy_cd.ToString(); dr["start"] = item.start.ToString(); dr["end"] = item.end.ToString(); dt.Rows.Add(dr); } return(dt); } return(dt); }