/// <summary> /// 更新历史安灯记录 /// </summary> /// <param name="openSftwTime">首次打开软件的时间</param> /// <param name="playerIndex">播放器序列号</param> /// <returns>受影响记录条数</returns> public int UpdateHistroyAdn(DateTime openSftwTime, int playerIndex) { string where = string.Format(" call_time<='{0}' and SUBSTRING(play_record,{1},1)='1' order by call_time desc", openSftwTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), playerIndex); DAO.SqlServerHelper dbEngine = DAO.SqlServerHelper.CreateInstance(SqlConStr); List <Model.TableModel.Adn> listAnd = dbEngine.QueryList <Model.TableModel.Adn>(where); foreach (Model.TableModel.Adn item in listAnd) { string newPlayRecord = CaclNewPlayRecord(item.play_record, playerIndex); item.play_record = newPlayRecord; } return(dbEngine.QueryInt <Model.TableModel.Adn>("Update", listAnd)); }
/// <summary> /// 获取看板数据 /// </summary> /// <returns>返回序列化后的看板信息</returns> public string GetKanpanData() { //数据库构建 DAO.SqlServerHelper dbEngine = DAO.SqlServerHelper.CreateInstance(Common.ConfigHelper.GetConfigValueFromXml("connectionStr", "dfsDb", AppDomain.CurrentDomain.BaseDirectory + @"Config\mesWebSiteConfig.xml")); //中间变量 string res = string.Empty; object objTmp = null; int intTmp = 0; //获取计划数量 string sql = "select sum(plan_qty) from mpo_plan where plan_date=@plan_date;"; Dictionary <string, object> pms = new Dictionary <string, object>(); pms.Add("@plan_date", DateTime.Now.Date.ToString("yyyy-MM-dd")); objTmp = dbEngine.QueryObj(sql, pms); res = (objTmp ?? "0").ToString(); decimal dTmp = 0.0M; dTmp = decimal.TryParse(res, out dTmp) ? dTmp : 0.0M; intTmp = decimal.ToInt32(dTmp); string planQty = intTmp.ToString(); //获取当日产量 sql = "select distinct count(serial_no) from mes_fb_item where quality_no='QA01' and eqm_no=(select eqm_no from pdm_eqm where eqm_index=(select max(eqm_index) from pdm_eqm)) and fb_datetime >=@start_time and fb_datetime<=@end_time"; pms.Clear(); pms.Add("@start_time", DateTime.Now.Date); pms.Add("@end_time", DateTime.Now.Date + new TimeSpan(0, 23, 59, 59, 999)); objTmp = dbEngine.QueryObj(sql, pms); res = (objTmp ?? "0").ToString(); intTmp = int.TryParse(res, out intTmp) ? intTmp : 0; string productQty = intTmp.ToString(); //获取产线停机时间 sql = "select sum(datediff(MINUTE,case when submit_time<=@start_time then @start_time else submit_time end,case when reply_time>=@end_time then @end_time else reply_time end))from eqm_jam_record where ((submit_time between @start_time and @end_time) or (reply_time between @start_time and @end_time) or ( submit_time <= @start_time and reply_time>=@end_time ));"; objTmp = dbEngine.QueryObj(sql, pms); res = (objTmp ?? "0").ToString(); intTmp = int.TryParse(res, out intTmp) ? intTmp : 0; string stopTime = intTmp.ToString(); //获取看板具体信息 sql = @"select pdm_eqm.eqm_no,pdm_eqm.eqm_status,adn.andon_type_name,adn.status_no from adn inner join (select pdm_eqm.eqm_no,max(adn.call_time) as call_time from adn right join pdm_eqm on adn.eqm_no=pdm_eqm.eqm_no group by pdm_eqm.eqm_no) as c on adn.call_time=c.call_time and adn.eqm_no=c.eqm_no right join pdm_eqm on adn.eqm_no=pdm_eqm.eqm_no order by pdm_eqm.eqm_index asc; "; DataTable adnList = dbEngine.QueryTable(sql); var data = new { planQty = planQty, productQty = productQty, stopTime = stopTime, adnList = adnList }; return(Common.JsonHelper.SerializeObject(data)); }
/// <summary> /// 播放安灯呼叫 /// </summary> /// <param name="dtOpenSftwDateTime">初次打开软件的事件</param> /// <param name="andonEqmIndex">安灯播放器编号</param> internal void Play(DateTime dtOpenSftwDateTime, int andonEqmIndex) { AndonPlayerIsRun = false; DAO.SqlServerHelper dbEngine = DAO.SqlServerHelper.CreateInstance(SqlConStr); string where = string.Format(" call_time>'{0}' and SUBSTRING(play_record,{1},1)='1' and is_finished='false' and andon_type_no in ({2}) order by call_time desc", dtOpenSftwDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff"), andonEqmIndex, AndonType); List <Model.TableModel.Adn> listAdn = dbEngine.QueryList <Model.TableModel.Adn>(where); if (listAdn.Count <= 0) { return; } string musicName = listAdn[0].andon_music_no; _mp3.Play(AndonFilePath + "\\" + musicName, 5); int tim = _mp3.GetTimeLong(); List <Model.TableModel.Adn> newListAdn = new List <Model.TableModel.Adn>(); string newPlayRecord = CaclNewPlayRecord(listAdn[0].play_record, andonEqmIndex); listAdn[0].play_record = newPlayRecord; newListAdn.Add(listAdn[0]); dbEngine.QueryInt <Model.TableModel.Adn>("Update", newListAdn); }