/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { #region #1全自动制样机 taskSimpleScheduler.StartNewTask("#1全自动制样机-快速同步", () => { EquAutoMakerDAO autoMakerDAO1 = new EquAutoMakerDAO(GlobalVars.MachineCode_QZDZYJ_1, new DapperDber.Dbs.SqlServerDb.SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("#1全自动制样机接口连接字符串"))); if (commonDAO.TestPing(autoMakerDAO1.EquDber.Connection.DataSource)) { autoMakerDAO1.SyncCmd(this.rTxtOutputer.Output); autoMakerDAO1.SyncSignal(this.rTxtOutputer.Output); autoMakerDAO1.SyncMakeDetail(this.rTxtOutputer.Output); autoMakerDAO1.SyncError(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(autoMakerDAO1.MachineCode + "网络不通", eOutputType.Warn); } }, 3000, OutputError); #endregion #region #2全自动制样机 taskSimpleScheduler.StartNewTask("#2全自动制样机-快速同步", () => { EquAutoMakerDAO autoMakerDAO2 = new EquAutoMakerDAO(GlobalVars.MachineCode_QZDZYJ_2, new DapperDber.Dbs.SqlServerDb.SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("#2全自动制样机接口连接字符串"))); if (commonDAO.TestPing(autoMakerDAO2.EquDber.Connection.DataSource)) { autoMakerDAO2.SyncCmd(this.rTxtOutputer.Output); autoMakerDAO2.SyncXLCmd(this.rTxtOutputer.Output); autoMakerDAO2.SyncSignal(this.rTxtOutputer.Output); autoMakerDAO2.SyncMakeDetail(this.rTxtOutputer.Output); autoMakerDAO2.SyncError(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(autoMakerDAO2.MachineCode + "网络不通", eOutputType.Warn); } }, 2000, OutputError); #endregion #region #3全自动制样机 taskSimpleScheduler.StartNewTask("#3全自动制样机-快速同步", () => { EquAutoMakerDAO autoMakerDAO3 = new EquAutoMakerDAO(GlobalVars.MachineCode_QZDZYJ_3, new DapperDber.Dbs.SqlServerDb.SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("#3全自动制样机接口连接字符串"))); if (commonDAO.TestPing(autoMakerDAO3.EquDber.Connection.DataSource)) { autoMakerDAO3.SyncCmd(this.rTxtOutputer.Output); autoMakerDAO3.SyncXLCmd(this.rTxtOutputer.Output); autoMakerDAO3.SyncSignal(this.rTxtOutputer.Output); autoMakerDAO3.SyncMakeDetail(this.rTxtOutputer.Output); autoMakerDAO3.SyncError(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(autoMakerDAO3.MachineCode + "网络不通", eOutputType.Warn); } }, 3000, OutputError); #endregion }
/// <summary> /// 信息输出 /// </summary> /// <param name="messageStr"></param> public void ShowInfomation(string messageStr, eOutputType outputType = eOutputType.Normal) { InvokeEx(() => { rTxtOutputer.Output(messageStr); }); }
/// <summary> /// 录入明细 /// </summary> /// <param name="weight"></param> /// <returns></returns> private bool JoinBalanceDetail(double weight) { if (string.IsNullOrEmpty(this.txtGGJ.Text)) { rTxtOutputer.Output("请填写坩埚架", eOutputType.Warn); return(false); } if (this.CurrentAssay == null) { rTxtOutputer.Output("请选中一条化验记录", eOutputType.Error); return(false); } string GGNo = "1"; if (commonDAO.SelfDber.Count <InfBalanceRecordDetail>("where GGJCode=:GGJCode and SyncFlag=0", new { BalanceRecordId = this.CurrentAssay.Id, GGJCode = this.txtGGJ.Text.Trim() }) >= 12) { rTxtOutputer.Output("坩埚架:" + this.txtGGJ.Text + "的坩埚已用完", eOutputType.Warn); return(false); } InfBalanceRecordDetail lastdetail = commonDAO.SelfDber.Entity <InfBalanceRecordDetail>("where GGJCode=:GGJCode and SyncFlag=0 order by to_number(GGCode) desc", new { BalanceRecordId = this.CurrentAssay.Id, GGJCode = this.txtGGJ.Text.Trim() }); if (lastdetail != null) { GGNo = (Convert.ToInt32(lastdetail.GGCode) + 1).ToString(); } InfBalanceRecordDetail detial = new InfBalanceRecordDetail(); detial.CreateUser = SelfVars.LoginUser.UserAccount; detial.OperUser = detial.CreateUser; detial.BalanceRecordId = this.CurrentAssay.Id; detial.Weight = weight; detial.AssayCode = this.CurrentAssay.AssayCode; detial.MachineCode = this.MachineCode; detial.GGCode = GGNo; detial.GGJCode = this.txtGGJ.Text.Trim(); detial.SyncFlag = 0; commonDAO.SelfDber.Insert(detial); LoadBalanceDetailList(superGridControl2, this.CurrentAssay.Id); return(true); }
/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { this.taskSimpleScheduler.StartNewTask("同步上位机运行状态", () => { EquAutoCupboardDAO autoCupboard_DAO = new EquAutoCupboardDAO(GlobalVars.MachineCode_CYG1, new SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("智能存样柜接口连接字符串"))); if (CommonDAO.GetInstance().TestPing(autoCupboard_DAO.EquDber.Connection.DataSource)) { //#1存样柜 autoCupboard_DAO.SyncCYGError(this.rTxtOutputer.Output); autoCupboard_DAO.SyncCYGInfo(this.rTxtOutputer.Output); autoCupboard_DAO.SyncCYGCmd(this.rTxtOutputer.Output); autoCupboard_DAO.SyncCYGResult(this.rTxtOutputer.Output); autoCupboard_DAO.SyncSignalDatal(this.rTxtOutputer.Output); autoCupboard_DAO.SyncCYGRecord(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(autoCupboard_DAO.MachineCode + "网络不通", eOutputType.Warn); } }, 5000, OutputError); this.taskSimpleScheduler.StartNewTask("同步上位机2运行状态", () => { EquAutoCupboardDAO autoCupboard_DAO2 = new EquAutoCupboardDAO(GlobalVars.MachineCode_CYG2, new SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("智能存样柜2接口连接字符串"))); if (CommonDAO.GetInstance().TestPing(autoCupboard_DAO2.EquDber.Connection.DataSource)) { //#2存样柜 autoCupboard_DAO2.SyncCYGError(this.rTxtOutputer.Output); autoCupboard_DAO2.SyncCYGInfo(this.rTxtOutputer.Output); autoCupboard_DAO2.SyncCYGCmd(this.rTxtOutputer.Output); autoCupboard_DAO2.SyncCYGResult(this.rTxtOutputer.Output); autoCupboard_DAO2.SyncSignalDatal(this.rTxtOutputer.Output); autoCupboard_DAO2.SyncCYGRecord(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(autoCupboard_DAO2.MachineCode + "网络不通", eOutputType.Warn); } }, 5000, OutputError); }
/// <summary> /// 保存入厂煤运输记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSendSamplingPlan_Click(object sender, EventArgs e) { if (CurrentRCSampling == null) { MessageBoxEx.Show("请先设置当前采样单"); return; } //if (this.CurrentSystemStatus != eEquInfSamplerSystemStatus.就绪待机2 && this.CurrentSystemStatus != eEquInfSamplerSystemStatus.就绪待机) { MessageBoxEx.Show(this.CurrentSampleMachine.EquipmentName + "未就绪", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!SendSamplingPlan()) { MessageBoxEx.Show("采样计划发送失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!SendSamplingCMD(true)) { MessageBoxEx.Show("采样命令发送失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } commonDAO.SaveAppletLog(eAppletLogLevel.Info, GlobalVars.LoginUser.UserName + " 发送采样计划", GlobalVars.LoginUser.UserName + " 发送采样计划"); //MessageBoxEx.Show("发送成功,等待采样"); rTxtOutputer.Output("发送采样计划成功,当前采样码:" + this.CurrentRCSampling.SampleCode, eOutputType.Normal); timer1.Enabled = true; this.CurrentFlowFlag = eFlowFlag.等待执行; }
/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { #region 气动传输 taskSimpleScheduler.StartNewTask("气动传输-快速同步", () => { SqlServerDapperDber PneumaticTransfer_Dber = new SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("气动传输接口连接字符串")); EquPneumaticTransferDAO dAO = new EquPneumaticTransferDAO(GlobalVars.MachineCode_QD, PneumaticTransfer_Dber); if (CommonDAO.GetInstance().TestPing(dAO.EquDber.Connection.DataSource)) { dAO.SyncCYGError(this.rTxtOutputer.Output); dAO.SyncQDCSCmd(this.rTxtOutputer.Output); dAO.SyncQDCSRecord(this.rTxtOutputer.Output); dAO.SyncSignalDatal(this.rTxtOutputer.Output); } else { rTxtOutputer.Output(dAO.MachineCode + "网络不通", eOutputType.Warn); } }, 5000, OutputError); #endregion }
/// <summary> /// 加载采样机最近几天的卸样记录 /// </summary> /// <param name="samplerMachineCode">采样机编码</param> private void LoadLatestSampleUnloadCmd(CmcsCMEquipment cmcsCMEquipment) { if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(cmcsCMEquipment.Parentid).EquipmentCode == "皮带采样机") { superGridControl3.PrimaryGrid.DataSource = commonDAO.SelfDber.TopEntities <InfBeltSampleUnloadCmd>(3, " where MachineCode='" + cmcsCMEquipment.EquipmentCode + "' order by createdate desc"); } else if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(cmcsCMEquipment.Parentid).EquipmentCode == "汽车机械采样机") { superGridControl3.PrimaryGrid.DataSource = commonDAO.SelfDber.TopEntities <InfQCJXCYUnLoadCMD>(3, " where MachineCode='" + cmcsCMEquipment.EquipmentCode + "' order by createdate desc"); } else { rTxtOutputer.Output("无此编码类型,请查证\"皮带采样机\"和\"汽车机械采样机\"类型!", eOutputType.Error); } }
/// <summary> /// 发送制样计划 /// </summary> /// <param name="rCSamplingId">采样单Id</param> /// <param name="infactoryBatchId">批次Id</param> /// <returns></returns> private bool SendMakePlan(string rCSamplingCode, string infactoryBatchId) { CmcsRCMake rcMake = AutoMakerDAO.GetInstance().GetRCMakeBySampleCode(rCSamplingCode); if (rcMake != null) { string fuelKindName = string.Empty; CmcsInFactoryBatch inFactoryBatch = commonDAO.GetBatchByRCSamplingCode(rCSamplingCode); if (inFactoryBatch != null) { CmcsFuelKind fuelKind = commonDAO.SelfDber.Get <CmcsFuelKind>(inFactoryBatch.FuelKindId); if (fuelKind != null) { fuelKindName = fuelKind.FuelName; } } // 需调整:发送的制样计划中煤种、颗粒度、水分等相关信息视接口而定 InfMakerPlan makerPlan = new InfMakerPlan() { InterfaceType = commonDAO.GetMachineInterfaceTypeByCode(this.CurrentMaker), MachineCode = this.CurrentMaker, InFactoryBatchId = infactoryBatchId, MakeCode = rcMake.MakeCode, FuelKindName = fuelKindName, //Mt = "湿煤", MakeType = "在线制样", //CoalSize = "小粒度", SyncFlag = 0 }; AutoMakerDAO.GetInstance().SaveMakerPlanAndStartCmd(makerPlan, out currentMessage); rTxtOutputer.Output(currentMessage, eOutputType.Normal); return(true); } else { rTxtOutputer.Output("制样计划发送失败:未找到制样主记录信息", eOutputType.Error); } return(false); }
/// <summary> /// 执行所有任务 /// </summary> void ExecuteAllTask() { SqlServerDapperDber BeltSampler_Dber_Out = null; EquBeltSamplerDAO beltSamplerDAO_Out = null; taskSimpleScheduler.StartNewTask("出场皮带采样机快速同步", () => { BeltSampler_Dber_Out = new SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("出场皮带采样机接口连接字符串")); beltSamplerDAO_Out = new EquBeltSamplerDAO("出场", BeltSampler_Dber_Out); if (CommonDAO.GetInstance().TestPing(BeltSampler_Dber_Out.Connection.DataSource)) { beltSamplerDAO_Out.SyncSignal(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncError(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncBarrel(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncPlan(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncUnloadCmd(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncCmd(this.rTxtOutputer.Output); beltSamplerDAO_Out.SyncUnloadResult(this.rTxtOutputer.Output); } else { rTxtOutputer.Output("出场皮带采样机网络不通"); } }, 3000, OutputError); this.taskSimpleScheduler.StartNewTask("出场皮带采样机运行状态-心跳", () => { if (CommonDAO.GetInstance().TestPing(BeltSampler_Dber_Out.Connection.DataSource)) { beltSamplerDAO_Out.SyncHeartbeatSignal(); } else { rTxtOutputer.Output("出场皮带采样机网络不通"); } }, 30000, OutputError); #region 入场 SqlServerDapperDber BeltSampler_Dber_In = null; EquBeltSamplerDAO beltSamplerDAO_In = null; taskSimpleScheduler.StartNewTask("入场皮带采样机快速同步", () => { BeltSampler_Dber_In = new SqlServerDapperDber(CommonDAO.GetInstance().GetCommonAppletConfigString("入场皮带采样机接口连接字符串")); beltSamplerDAO_In = new EquBeltSamplerDAO("入场", BeltSampler_Dber_In); if (CommonDAO.GetInstance().TestPing(BeltSampler_Dber_In.Connection.DataSource)) { beltSamplerDAO_In.SyncSignal(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncError(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncBarrel(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncPlan(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncUnloadCmd(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncCmd(this.rTxtOutputer.Output); beltSamplerDAO_In.SyncUnloadResult(this.rTxtOutputer.Output); } else { rTxtOutputer.Output("入场皮带采样机网络不通"); } }, 3000, OutputError); this.taskSimpleScheduler.StartNewTask("入场皮带采样机运行状态-心跳", () => { if (CommonDAO.GetInstance().TestPing(BeltSampler_Dber_In.Connection.DataSource)) { beltSamplerDAO_In.SyncHeartbeatSignal(); } else { rTxtOutputer.Output("入场皮带采样机网络不通"); } }, 30000, OutputError); #endregion }
/// <summary> /// 发送卸样命令 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSendLoadCmd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.currentSampleCode)) { MessageBoxEx.Show("请选择集样罐再发送", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!CheckBeltSampleBarrel()) { MessageBoxEx.Show("集样罐已更新,请刷新样罐信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); BindBeltSampleBarrel(superGridControl1, this.currentSampleMachineCode); return; } if (rbtnToMaker.Checked) {//卸样到制样机 if (currentCmcsRCSampling == null) { MessageBoxEx.Show("请选择采样单后再发送", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // 制样机系统状态 string makerSystemStatus = CommonDAO.GetInstance().GetSignalDataValue(GlobalVars.MachineCode_NCGM_QZDZYJ_1, GlobalVars.EquSystemStatueName); if (rbtnToMaker.Checked && makerSystemStatus != eEquInfSamplerSystemStatus.就绪待机.ToString()) { MessageBoxEx.Show("制样机系统未就绪", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string message = string.Empty; if (BeltSamplerDAO.GetInstance().CanSendSampleLoadCmd(this.currentSampleMachineCode, out message)) { if (BeltSamplerDAO.GetInstance().SendSampleUnloadCmd(this.currentSampleMachineCode, this.currentSampleCode, out this.currentUnloadSampleId, (eEquInfSamplerUnloadType)Convert.ToInt16(flpanUnloadType.Controls.OfType <RadioButton>().First(a => a.Checked).Tag))) { //保存采样单明细记录【样罐信息】 BeltSamplerDAO.GetInstance().SaveSampleBarrel(currentEquInfSampleBarrels, currentCmcsRCSampling); MessageBoxEx.Show("命令发送成功,等待采样机系统执行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); rTxtOutputer.Output("等待采样机系统执行卸样操作!", eOutputType.Normal); timer1_Tick(null, null); timer2.Enabled = true; btnSendLoadCmd.Enabled = false; btnSendMakeCmd.Enabled = false; } } else { MessageBoxEx.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else {//卸样到旁路 string message = string.Empty; if (BeltSamplerDAO.GetInstance().CanSendSampleLoadCmd(this.currentSampleMachineCode, out message)) { if (BeltSamplerDAO.GetInstance().SendSampleUnloadCmd(this.currentSampleMachineCode, this.currentSampleCode, out this.currentUnloadSampleId, (eEquInfSamplerUnloadType)Convert.ToInt16(flpanUnloadType.Controls.OfType <RadioButton>().First(a => a.Checked).Tag))) { MessageBoxEx.Show("命令发送成功,等待采样机系统执行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); rTxtOutputer.Output("等待采样机系统执行卸样操作!", eOutputType.Normal); timer1_Tick(null, null); } } else { MessageBoxEx.Show(message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }