/// <summary> /// 发送制样计划,并发送开始制样命令 /// </summary> public bool SaveMakerPlanAndStartCmd(InfMakerPlan entity, out string message) { try { message = "制样计划发送成功"; if (Dbers.GetInstance().SelfDber.Insert <InfMakerPlan>(entity) > 0) { InfMakerControlCmd makerControlCmd = new InfMakerControlCmd(); makerControlCmd.InterfaceType = CommonDAO.GetInstance().GetMachineInterfaceTypeByCode(entity.MachineCode); makerControlCmd.MachineCode = entity.MachineCode; makerControlCmd.MakeCode = entity.MakeCode; makerControlCmd.ResultCode = eEquInfCmdResultCode.默认.ToString(); makerControlCmd.CmdCode = eEquInfMakerCmd.开始制样.ToString(); makerControlCmd.SyncFlag = 0; Dbers.GetInstance().SelfDber.Insert <InfMakerControlCmd>(makerControlCmd); // 修改入厂煤制样记录的开始制样时间 //Dbers.GetInstance().SelfDber.Execute("update " + EntityReflectionUtil.GetTableName<CmcsRCMake>() + " set GetPle='自动接样',GetDate=:DtNow,MakeDate=:DtNow where MakeCode=:MakeCode", new { DtNow = DateTime.Now, MakeCode = entity.MakeCode }); return(true); } message = "制样计划发送失败"; return(false); } catch (Exception ex) { message = "制样计划发送失败" + ex.Message; return(false); } }
/// <summary> /// 从卸样记录中获取最新的采样编码,判断是否能卸样 /// </summary> /// <param name="cmcsCMEquipment"></param> /// <returns></returns> private bool HandleWhetherSampleUnloadCmd(CmcsCMEquipment cmcsCMEquipment) { string tempSamplingId = string.Empty; if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(cmcsCMEquipment.Parentid).EquipmentCode == "皮带采样机") { InfBeltSampleUnloadCmd entity = commonDAO.SelfDber.Entity <InfBeltSampleUnloadCmd>(" where MachineCode='" + cmcsCMEquipment.EquipmentCode + "' order by createdate desc"); if (entity != null) { tempSamplingId = entity.SamplingId; } } else if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(cmcsCMEquipment.Parentid).EquipmentCode == "汽车机械采样机") { InfQCJXCYUnLoadCMD entity = commonDAO.SelfDber.Entity <InfQCJXCYUnLoadCMD>(" where MachineCode='" + cmcsCMEquipment.EquipmentCode + "' order by createdate desc"); if (entity != null) { tempSamplingId = entity.SamplingId; } } else { rTxtOutputer.Output("无此编码类型,请查证\"皮带采样机\"和\"汽车机械采样机\"类型!", eOutputType.Error); return(false); } if (!string.IsNullOrEmpty(tempSamplingId)) { //同一批次可以继续卸样 if (this.CurrentRCSampling.Id == tempSamplingId) { return(true); } CmcsRCMake rcMake = AutoMakerDAO.GetInstance().GetRCMakeBySampleId(tempSamplingId); if (rcMake != null) { //未找到制样记录需要提示是否继续操作 InfMakerPlan infMakerPlan = Dbers.GetInstance().SelfDber.Entity <InfMakerPlan>("where MakeCode=:MakeCode", new { MakeCode = rcMake.MakeCode }); if (infMakerPlan == null) { if (MessageBoxEx.Show("该卸样记录与上一次未制样的记录不是同一批次,为防止混样,确定是否继续", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.OK) { if (new FrmConfirmOperationLog("确定人为操作继续卸样").ShowDialog() == DialogResult.OK) { return(true); } } } } } return(false); }
/// <summary> /// 发送制样计划和制样命令给制样机 /// </summary> private void SendMakePlanAndStart() { if (this.brotherRCSampleBarrels.Count == 0) { ShowMessage("请先完成采样桶校验", eOutputType.Error); return; } if (this.RCMake == null) { ShowMessage("未找到制样单记录", eOutputType.Error); return; } if (this.AutoMaker == null) { ShowMessage("未找到制样机设备", eOutputType.Error); return; } if (commonDAO.GetSignalDataValue(this.AutoMaker.EquipmentCode, eSignalDataName.系统.ToString()) != eEquInfSamplerSystemStatus.就绪待机.ToString()) { MessageBoxEx.Show("制样机未就绪,禁止发送制样命令!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBoxEx.Show("准备启动制样机,请确定煤样已全部倒入制样机料斗!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { // 需调整:根据接口规定写入煤种、水分等参数 InfMakerPlan makerPlan = new InfMakerPlan() { InterfaceType = commonDAO.GetMachineInterfaceTypeByCode(this.AutoMaker.EquipmentCode), MachineCode = this.AutoMaker.EquipmentCode, InFactoryBatchId = this.brotherRCSampleBarrels[0].InFactoryBatchId, MakeCode = this.RCMake.MakeCode, FuelKindName = "褐煤", Mt = "湿煤", MakeType = "在线制样", CoalSize = "小粒度" }; if (AutoMakerDAO.GetInstance().SaveMakerPlanAndStartCmd(makerPlan, out resMessage)) { this.CurrentFlowFlag = eFlowFlag.等待制样结果; ShowMessage(resMessage, eOutputType.Normal); } else { ShowMessage(resMessage, eOutputType.Error); } } }
/// <summary> /// 发送制样计划 /// </summary> /// <param name="rCSamplingId">采样单Id</param> /// <param name="infactoryBatchId">批次Id</param> /// <returns></returns> private bool SendMakePlan(string rCSamplingId) { CmcsRCSampling rCSampling = commonDAO.SelfDber.Get <CmcsRCSampling>(rCSamplingId); CmcsRCMake rcMake = AutoMakerDAO.GetInstance().GetRCMakeBySampleId(rCSamplingId); if (rcMake != null) { string fuelKindName = string.Empty; CmcsInFactoryBatch inFactoryBatch = commonDAO.GetBatchByRCSamplingId(rCSamplingId); 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.CurrentmakerMachineCode), MachineCode = this.CurrentmakerMachineCode, InFactoryBatchId = rCSampling != null ? rCSampling.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); }
private void SendMakePlanAndStart() { if (this.brotherRCSampleBarrels.Count == 0) { this.ShowMessage("请先完成采样桶校验", FrmMakeTake.eOutputType.Error); return; } if (this.RCMake == null) { this.ShowMessage("未找到制样单记录", FrmMakeTake.eOutputType.Error); return; } if (this.commonDAO.GetSignalDataValue(this.AutoMaker.EquipmentCode, eSignalDataName.设备状态.ToString()) != eEquInfSamplerSystemStatus.就绪待机.ToString()) { MessageBoxEx.Show("制样机未就绪,禁止发送制样命令!", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } if (MessageBoxEx.Show("准备启动制样机,请确定煤样已全部倒入制样机料斗!", "提示", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Asterisk) == System.Windows.Forms.DialogResult.OK) { InfMakerPlan entity = new InfMakerPlan { InterfaceType = this.commonDAO.GetMachineInterfaceTypeByCode(this.AutoMaker.EquipmentCode), MachineCode = this.AutoMaker.EquipmentCode, InFactoryBatchId = this.brotherRCSampleBarrels[0].InFactoryBatchId, MakeCode = this.RCMake.MakeCode, FuelKindName = "褐煤", Mt = "湿煤", MakeType = "在线制样", CoalSize = "小粒度" }; if (AutoMakerDAO.GetInstance().SaveMakerPlanAndStartCmd(entity, out this.resMessage)) { this.CurrentFlowFlag = eFlowFlag.等待制样结果; this.ShowMessage(this.resMessage, FrmMakeTake.eOutputType.Normal); return; } this.ShowMessage(this.resMessage, FrmMakeTake.eOutputType.Error); } }