/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { DataHandlerDAO dataHandlerDAO = DataHandlerDAO.GetInstance(); SqlServerDapperDber qgcDapperDber = new SqlServerDapperDber(commonDAO.GetCommonAppletConfigString("全过程接口连接字符串")); taskSimpleScheduler.StartNewTask("同步全过程基础信息", () => { dataHandlerDAO.SyncBaseInfoForCHLGL(this.rTxtOutputer.Output, qgcDapperDber); //dataHandlerDAO.SyncBaseInfoForDYJH(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForGYS(this.rTxtOutputer.Output, qgcDapperDber); //dataHandlerDAO.SyncBaseInfoForCHYSH(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForKB(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForMZ(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForDYJHK(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForYAPFK(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForQCLMYGP(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForWZJHCL(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForJLMZ(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForJLPZ(this.rTxtOutputer.Output, qgcDapperDber); dataHandlerDAO.SyncBaseInfoForcCLGLLSPZ(this.rTxtOutputer.Output, qgcDapperDber); }, 10000, OutputError); taskSimpleScheduler.StartNewTask("处理集控首页数据", () => { dataHandlerDAO.HandleHomePageData(this.rTxtOutputer.Output); }, 10000, OutputError); //初始化Api string ip = commonDAO.GetCommonAppletConfigString("海康平台地址"); int port = commonDAO.GetCommonAppletConfigInt32("海康协议端口号"); string Appkey = commonDAO.GetCommonAppletConfigString("海康Appkey"); string Secret = commonDAO.GetCommonAppletConfigString("海康Secret"); HttpUtillib.SetPlatformInfo(Appkey, Secret, ip, port, false); taskSimpleScheduler.StartNewTask("同步门禁数据", () => { dataHandlerDAO.SyncDoorEventData(this.rTxtOutputer.Output); }, 60000, OutputError); }
/// <summary> /// 根据入场运输记录判断批次是否已生成,并返回。 /// 根据入场时间(实际到厂时间)、供煤单位、煤种判断 /// </summary> /// <param name="buyFuelTransport"></param> /// <returns></returns> public CmcsInFactoryBatch HasInFactoryBatch(CmcsBuyFuelTransport buyFuelTransport) { DateTime dt = buyFuelTransport.GrossTime.Year < 2000 ? buyFuelTransport.InFactoryTime.AddHours(-commonDAO.GetCommonAppletConfigInt32("汽车分批时间点")) : buyFuelTransport.GrossTime.AddHours(-commonDAO.GetCommonAppletConfigInt32("汽车分批时间点")); return(SelfDber.Entity <CmcsInFactoryBatch>("where Batch like '%-'|| to_char(:CreateDate,'YYYYMMDD') ||'-%' and SupplierId=:SupplierId and MineId=:MineId and FuelKindId=:FuelKindId and InFactoryType=:InFactoryType", new { CreateDate = dt, SupplierId = buyFuelTransport.SupplierId, MineId = buyFuelTransport.MineId, FuelKindId = buyFuelTransport.FuelKindId, InFactoryType = buyFuelTransport.InFactoryType })); }
/// <summary> /// 加载配置 /// </summary> void LoadAppConfig() { #region 绑定语音类型 List <string> arrVoices = voiceSpeaker.GetVoices(); for (int i = 0; i < arrVoices.Count; i++) { DataItem comboitem = new DataItem(arrVoices[i]); cmbVoiceName.Items.Add(comboitem); } cmbVoiceName.SelectedIndex = 0; #endregion txtAppIdentifier.Text = commonAppConfig.AppIdentifier; txtSelfConnStr.Text = commonAppConfig.SelfConnStr; chbStartup.Checked = (commonDAO.GetAppletConfigString("开机启动") == "1"); chkUseRwer.Checked = (commonDAO.GetAppletConfigString("启用读卡器") == "1"); chkUseCamera.Checked = (commonDAO.GetAppletConfigString("启用识别相机") == "1"); //公共配置 chkAutoPrint.Checked = (commonDAO.GetCommonAppletConfigString("自动打印磅单") == "1"); chkOnWayMonitor.Checked = (commonDAO.GetCommonAppletConfigString("启用在途监控") == "1"); dbiSampleWayCount.Value = commonDAO.GetCommonAppletConfigInt32("采样通道车数"); chkSampleWayCount.Checked = (commonDAO.GetCommonAppletConfigString("启用采样通道车数") == "1"); txtTicketDiff.Value = commonDAO.GetCommonAppletConfigDouble("净重超差限值"); chkTicketDiff.Checked = (commonDAO.GetCommonAppletConfigString("启用净重超差限值") == "1"); txtSamplerCodes.Text = commonDAO.GetCommonAppletConfigString("采样机编号"); txtWeighterCodes.Text = commonDAO.GetCommonAppletConfigString("汽车衡编号"); // IO控制器 SelectedComboBoxItem(cmbIocerCom, commonDAO.GetAppletConfigInt32("IO控制器_串口").ToString()); SelectedComboBoxItem(cmbIocerBandrate, commonDAO.GetAppletConfigInt32("IO控制器_波特率").ToString()); SelectedComboBoxItem(cmbIocerDataBits, commonDAO.GetAppletConfigInt32("IO控制器_数据位").ToString()); SelectedComboBoxItem(cmbIocerStopBits, commonDAO.GetAppletConfigInt32("IO控制器_停止位").ToString()); SelectedComboBoxItem(cmbIocerParity, commonDAO.GetAppletConfigInt32("IO控制器_校验位").ToString()); SelectedComboBoxItem(cmbInductorCoil1Port, commonDAO.GetAppletConfigInt32("IO控制器_地感1端口").ToString()); SelectedComboBoxItem(cmbInductorCoil2Port, commonDAO.GetAppletConfigInt32("IO控制器_地感2端口").ToString()); SelectedComboBoxItem(cmbInductorCoil3Port, commonDAO.GetAppletConfigInt32("IO控制器_地感3端口").ToString()); SelectedComboBoxItem(cmbInductorCoil4Port, commonDAO.GetAppletConfigInt32("IO控制器_地感4端口").ToString()); SelectedComboBoxItem(cmbGate1UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1升杆端口").ToString()); SelectedComboBoxItem(cmbGate1DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1降杆端口").ToString()); SelectedComboBoxItem(cmbGate2UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2升杆端口").ToString()); SelectedComboBoxItem(cmbGate2DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2降杆端口").ToString()); SelectedComboBoxItem(cmbSignalLight1Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯1端口").ToString()); SelectedComboBoxItem(cmbSignalLight2Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯2端口").ToString()); // 读卡器 ip_Rwer1.Value = commonDAO.GetAppletConfigString("读卡器1_IP地址"); SelectedComboBoxItem(cmbip_Rwer1Port, commonDAO.GetAppletConfigInt32("读卡器1_功率").ToString()); SelectedComboBoxItem(cmbRwer2, commonDAO.GetAppletConfigInt32("读卡器2_串口").ToString()); SelectedComboBoxItem(cmbip_Rwer2Port, commonDAO.GetAppletConfigInt32("读卡器2_功率").ToString()); txtRwerTagStartWith.Text = commonDAO.GetAppletConfigString("读卡器_标签过滤"); // LED显示屏 iptxtLED1IP.Value = commonDAO.GetAppletConfigString("LED显示屏1_IP地址"); // 语音 SelectedComboBoxItem(cmbVoiceName, commonDAO.GetAppletConfigString("语音包").ToString()); sldVoiceRate.Value = commonDAO.GetAppletConfigInt32("语速"); sldVoiceVolume.Value = commonDAO.GetAppletConfigInt32("音量"); lblVoiceRate.Text = sldVoiceRate.Value.ToString(); lblVoiceVolume.Text = sldVoiceVolume.Value.ToString(); }
/// <summary> /// 加载配置 /// </summary> void LoadAppConfig() { #region 绑定语音类型 List <string> arrVoices = voiceSpeaker.GetVoices(); for (int i = 0; i < arrVoices.Count; i++) { DataItem comboitem = new DataItem(arrVoices[i]); cmbVoiceName.Items.Add(comboitem); } cmbVoiceName.SelectedIndex = 0; #endregion txtAppIdentifier.Text = commonAppConfig.AppIdentifier; txtSelfConnStr.Text = commonAppConfig.SelfConnStr; chbStartup.Checked = (commonDAO.GetAppletConfigString("开机启动") == "1"); intPoundIndex.Value = commonDAO.GetAppletConfigInt32("磅编号"); //公共配置 chkAutoPrint.Checked = (commonDAO.GetCommonAppletConfigString("自动打印磅单") == "1"); chkITMS.Checked = (commonDAO.GetCommonAppletConfigString("启用智能调运") == "1"); chkPaperWorkPass.Checked = (commonDAO.GetCommonAppletConfigString("启用证件到期") == "1"); chkOutFactoryITMS.Checked = (commonDAO.GetCommonAppletConfigString("启用出厂天线") == "1"); dbiSampleWayCount.Value = commonDAO.GetCommonAppletConfigInt32("采样通道车数"); chkSampleWayCount.Checked = (commonDAO.GetCommonAppletConfigString("启用采样通道车数") == "1"); dbiFactoryCount.Value = commonDAO.GetCommonAppletConfigInt32("厂内总车数"); chkFactoryCount.Checked = (commonDAO.GetCommonAppletConfigString("启用厂内总车数") == "1"); txtTicketDiff.Value = commonDAO.GetCommonAppletConfigDouble("净重超差限值"); chkTicketDiff.Checked = (commonDAO.GetCommonAppletConfigString("启用净重超差限值") == "1"); txtTareCoefficient.Value = commonDAO.GetCommonAppletConfigDouble("皮重排查系数"); chkTareCoefficient.Checked = (commonDAO.GetCommonAppletConfigString("启用皮重排查系数") == "1"); // IO控制器 SelectedComboBoxItem(cmbIocerCom, commonDAO.GetAppletConfigInt32("IO控制器_串口").ToString()); SelectedComboBoxItem(cmbIocerBandrate, commonDAO.GetAppletConfigInt32("IO控制器_波特率").ToString()); SelectedComboBoxItem(cmbIocerDataBits, commonDAO.GetAppletConfigInt32("IO控制器_数据位").ToString()); SelectedComboBoxItem(cmbIocerStopBits, commonDAO.GetAppletConfigInt32("IO控制器_停止位").ToString()); SelectedComboBoxItem(cmbIocerParity, commonDAO.GetAppletConfigInt32("IO控制器_校验位").ToString()); SelectedComboBoxItem(cmbInductorCoil1Port, commonDAO.GetAppletConfigInt32("IO控制器_地感1端口").ToString()); SelectedComboBoxItem(cmbInductorCoil2Port, commonDAO.GetAppletConfigInt32("IO控制器_地感2端口").ToString()); SelectedComboBoxItem(cmbInductorCoil3Port, commonDAO.GetAppletConfigInt32("IO控制器_地感3端口").ToString()); SelectedComboBoxItem(cmbInductorCoil4Port, commonDAO.GetAppletConfigInt32("IO控制器_地感4端口").ToString()); SelectedComboBoxItem(cmbGate1UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1升杆端口").ToString()); SelectedComboBoxItem(cmbGate1DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸1降杆端口").ToString()); SelectedComboBoxItem(cmbGate2UpPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2升杆端口").ToString()); SelectedComboBoxItem(cmbGate2DownPort, commonDAO.GetAppletConfigInt32("IO控制器_道闸2降杆端口").ToString()); SelectedComboBoxItem(cmbSignalLight1Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯1端口").ToString()); SelectedComboBoxItem(cmbSignalLight2Port, commonDAO.GetAppletConfigInt32("IO控制器_信号灯2端口").ToString()); // 入厂读卡器 cmbRwer1Ip.Value = commonDAO.GetAppletConfigString("读卡器1_Ip"); cmbRwer1Port.Value = commonDAO.GetAppletConfigInt32("读卡器1_端口"); // 出厂读卡器 cmbRwer2Ip.Value = commonDAO.GetAppletConfigString("读卡器2_Ip"); cmbRwer2Port.Value = commonDAO.GetAppletConfigInt32("读卡器2_端口"); //室内发卡器 SelectedComboBoxItem(cmbRwer2Com, commonDAO.GetAppletConfigInt32("读卡器2_串口").ToString()); txtRwerTagStartWith.Text = commonDAO.GetAppletConfigString("读卡器_标签过滤"); // LED显示屏 iptxtLED1IP.Value = commonDAO.GetAppletConfigString("LED显示屏1_IP地址"); iptxtLED2IP.Value = commonDAO.GetAppletConfigString("LED显示屏2_IP地址"); // 语音 SelectedComboBoxItem(cmbVoiceName, commonDAO.GetAppletConfigString("语音包").ToString()); sldVoiceRate.Value = commonDAO.GetAppletConfigInt32("语速"); sldVoiceVolume.Value = commonDAO.GetAppletConfigInt32("音量"); lblVoiceRate.Text = sldVoiceRate.Value.ToString(); lblVoiceVolume.Text = sldVoiceVolume.Value.ToString(); }
/// <summary> /// 根据运输记录判断批次是否已生成,并返回。 /// 根据入厂时间(实际到厂时间)、供煤单位、煤种判断 /// </summary> /// <param name="buyFuelTransport"></param> /// <returns></returns> public CmcsInFactoryBatch HasInFactoryBatch(CmcsBuyFuelTransport buyFuelTransport) { DateTime dt = buyFuelTransport.CreationTime.AddHours(-commonDAO.GetCommonAppletConfigInt32("汽车分批时间点")); return(SelfDber.Entity <CmcsInFactoryBatch>("where Batch like '%-'|| to_char(:CreationTime,'YYYYMMDD') ||'-%' and SupplierId=:SupplierId and BatchCreateType=1 and IsDeleted=0", new { CreationTime = dt, SupplierId = buyFuelTransport.SupplierId, FuelKindId = buyFuelTransport.FuelKindId })); }
/// <summary> /// 请求数据 /// </summary> void RequestData() { string cell = SelfVars.CurrentSelectedCell; List <HtmlDataItem> datas = new List <HtmlDataItem>(); datas.Clear(); int overday = commonDAO.GetCommonAppletConfigInt32("存样柜超期天数"); IList <InfAutoCupBoard> cellList = commonDAO.SelfDber.Entities <InfAutoCupBoard>("where CupBoardType=:CupBoardType and ParentPKID is not null", new { CupBoardType = cell }); decimal useCount = cellList.Count(a => a.State == 1); decimal emptyCount = cellList.Count - useCount; decimal usePercent = cellList.Count > 0 ? Math.Round(useCount / cellList.Count, 2, MidpointRounding.AwayFromZero) : 0; decimal overCount = cellList.Count(a => a.State == 1 && a.SaveTime < DateTime.Now.AddDays(-overday)); decimal overPercent = useCount > 0 ? Math.Round(overCount / useCount, 2, MidpointRounding.AwayFromZero) : 0; datas.Add(new HtmlDataItem("总仓位", cellList.Count.ToString(), eHtmlDataItemType.svg_text)); datas.Add(new HtmlDataItem("已存仓位", useCount.ToString(), eHtmlDataItemType.svg_text)); datas.Add(new HtmlDataItem("未存仓位", emptyCount.ToString(), eHtmlDataItemType.svg_text)); datas.Add(new HtmlDataItem("超期仓位", overCount.ToString(), eHtmlDataItemType.svg_text)); datas.Add(new HtmlDataItem("存样率", (usePercent * 100).ToString("F2") + "%", eHtmlDataItemType.svg_text)); datas.Add(new HtmlDataItem("超期率", (overPercent * 100).ToString("F2") + "%", eHtmlDataItemType.svg_text)); IList <RowResult> rowResult = new List <RowResult>(); if (cellList.Count > 0) { if (cell == "原煤样样柜") { int maxRow = cellList.OrderByDescending(a => a.RowNumber).First().RowNumber; int maxCell = cellList.OrderByDescending(a => a.CellNumber).First().CellNumber; for (int i = 1; i <= maxRow; i++) { RowResult rowEntity = new RowResult(); rowEntity.RowName = String.Format("第 {0} 层", i); rowEntity.CellList = new List <CellResult>(); for (int j = 1; j <= maxCell; j++) { CellResult cellEntity = new CellResult(); InfAutoCupBoard sampleCell = cellList.Where(a => a.RowNumber == i && a.CellNumber == j).FirstOrDefault(); if (sampleCell == null) { cellEntity.CellFlag = -1; } else { cellEntity.CellNumber = sampleCell.CupBoardDes.Replace("层", "").Replace("格", "").Remove(0, 2); //柜门标识:-1没这一格,0空柜,1已存放,2超期样,3停用 if (sampleCell.IsValid == "0") { cellEntity.CellFlag = 3; } else if (sampleCell.State == 1 && sampleCell.SaveTime < DateTime.Now.AddDays(-overday)) { cellEntity.CellFlag = 2; } else if (sampleCell.State == 1) { cellEntity.CellFlag = 1; } else { cellEntity.CellFlag = 0; } } rowEntity.CellList.Add(cellEntity); } rowResult.Add(rowEntity); } } else { int maxRow = 5; int maxCell = 4; for (int i = 1; i <= maxRow; i++) { RowResult rowEntity = new RowResult(); rowEntity.RowName = String.Format("第 {0} 排", i); rowEntity.CellList = new List <CellResult>(); for (int j = 1; j <= maxCell; j++) { CellResult cellEntity = new CellResult(); cellEntity.CellNumber = string.Format("{0}排{1}号", i, j); string cellCode = i.ToString().PadLeft(2, '0') + "G" + j.ToString().PadLeft(2, '0'); cellEntity.CellCode = cellCode; IList <InfAutoCupBoard> sampleCell = cellList.Where(a => a.CupBoardCode.Contains(cellCode)).ToList(); //柜门标识:-1没这一格,0空柜,1已存放,2超期样,3停用 if (cellList.Count(a => a.IsValid == "0" && a.CupBoardCode.Contains(cellCode)) == 60) { cellEntity.CellFlag = 3; } else if (cellList.Count(a => a.State == 1 && a.SaveTime < DateTime.Now.AddDays(-overday) && a.CupBoardCode.Contains(cellCode)) > 0) { cellEntity.CellFlag = 2; } else if (cellList.Count(a => a.State == 1 && a.CupBoardCode.Contains(cellCode)) > 0) { cellEntity.CellFlag = 1; } else if (cellList.Count(a => a.State == 0 && a.CupBoardCode.Contains(cellCode)) == 60) { cellEntity.CellFlag = 0; } rowEntity.CellList.Add(cellEntity); } rowResult.Add(rowEntity); } } } datas.Add(new HtmlDataItem("样柜信息", Newtonsoft.Json.JsonConvert.SerializeObject(rowResult), eHtmlDataItemType.json_data)); // 添加更多... // 发送到页面 cefWebBrowser.Browser.GetMainFrame().ExecuteJavaScript("requestData(" + Newtonsoft.Json.JsonConvert.SerializeObject(datas) + ");", "", 0); }