/// <summary> /// 发送制样计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSendMakeCmd_Click(object sender, EventArgs e) { String tempSampleCode = String.Empty; if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.CurrentSampler.Parentid).EquipmentCode == "皮带采样机") { InfBeltSampleUnloadCmd beltSampleUnloadCmd = null; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { if (gridRow.Checked) { beltSampleUnloadCmd = gridRow.DataItem as InfBeltSampleUnloadCmd; } } if (beltSampleUnloadCmd == null) { MessageBoxEx.Show("请选择卸样记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tempSampleCode = beltSampleUnloadCmd.SampleCode; } else if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.CurrentSampler.Parentid).EquipmentCode == "汽车机械采样机") { InfQCJXCYUnLoadCMD qcjxcyUnLoadCMD = null; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { if (gridRow.Checked) { qcjxcyUnLoadCMD = gridRow.DataItem as InfQCJXCYUnLoadCMD; } } if (qcjxcyUnLoadCMD == null) { MessageBoxEx.Show("请选择卸样记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tempSampleCode = qcjxcyUnLoadCMD.SampleCode; } else { rTxtOutputer.Output("无此编码类型,请查证\"皮带采样机\"和\"汽车机械采样机\"类型!", eOutputType.Error); return; } CmcsRCSampleBarrel rCSampleBarrel = commonDAO.SelfDber.Entity <CmcsRCSampleBarrel>(" where BarrelCode='" + tempSampleCode + "' and IsDeleted=0"); if (rCSampleBarrel == null) { MessageBoxEx.Show("未找到采样单明细记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (MessageBoxEx.Show("确定要发送制样命令?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { SendMakePlan(rCSampleBarrel.SamplingId, rCSampleBarrel.InFactoryBatchId); } }
/// <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> /// <param name="machineCode">设备编码</param> /// <param name="sampleCode">采样码</param> /// <param name="sampleUnloadType">卸样方式</param> /// <returns></returns> public bool SendSampleUnloadCmd(string machineCode, string sampleCode, eEquInfSamplerUnloadType sampleUnloadType) { InfQCJXCYUnLoadCMD SampleUnloadCmd = new InfQCJXCYUnLoadCMD { DataFlag = 0, //InterfaceType = CommonDAO.GetInstance().GetMachineInterfaceTypeByCode(machineCode), MachineCode = machineCode, ResultCode = eEquInfCmdResultCode.默认.ToString(), SampleCode = sampleCode, UnLoadType = sampleUnloadType.ToString(), SyncFlag = 0 }; return(Dbers.GetInstance().SelfDber.Insert <InfQCJXCYUnLoadCMD>(SampleUnloadCmd) > 0); }
private void superGridControl3_DataBindingComplete(object sender, DevComponents.DotNetBar.SuperGrid.GridDataBindingCompleteEventArgs e) { foreach (GridRow gridRow in e.GridPanel.Rows) { InfQCJXCYUnLoadCMD entity = gridRow.DataItem as InfQCJXCYUnLoadCMD; if (entity == null) { return; } User user = Dbers.GetInstance().SelfDber.Entity <User>(" where UserAccount= '" + entity.CreateUser + "'"); if (user != null) { gridRow.Cells["CreateUser"].Value = (user.UserName); } } }
/// <summary> /// 发送卸样命令 /// </summary> /// <param name="machineCode">设备编码</param> /// <param name="samplingId">采样单Id</param> /// <param name="sampleCode">采样码</param> /// <param name="sampleUnloadType">卸样方式</param> /// <param name="sampleUnloadCmdId">返回命令Id</param> /// <returns></returns> public bool SendSampleUnloadCmd(string machineCode, string samplingId, string sampleCode, eEquInfSamplerUnloadType sampleUnloadType, out string sampleUnloadCmdId) { InfQCJXCYUnLoadCMD sampleUnloadCmd = new InfQCJXCYUnLoadCMD { Id = Guid.NewGuid().ToString(), DataFlag = 0, //InterfaceType = CommonDAO.GetInstance().GetMachineInterfaceTypeByCode(machineCode), MachineCode = machineCode, ResultCode = eEquInfCmdResultCode.默认.ToString(), SampleCode = sampleCode, UnLoadType = sampleUnloadType.ToString(), SyncFlag = 0, SamplingId = samplingId }; sampleUnloadCmdId = sampleUnloadCmd.Id; return(Dbers.GetInstance().SelfDber.Insert <InfQCJXCYUnLoadCMD>(sampleUnloadCmd) > 0); }
/// <summary> /// 发送卸样命令 /// </summary> /// <param name="machineCode">设备编码</param> /// <param name="samplingId">采样单Id</param> /// <param name="sampleCode">采样码</param> /// <param name="sampleUnloadType">卸样方式</param> /// <param name="sampleUnloadCmdId">返回命令Id</param> /// <returns></returns> public bool SendSampleUnloadCmd(string machineCode, string samplingId, string sampleCode, eEquInfSamplerUnloadType sampleUnloadType, string barrelNumber, out string sampleUnloadCmdId) { InfQCJXCYUnLoadCMD sampleUnloadCmd = new InfQCJXCYUnLoadCMD { Id = Guid.NewGuid().ToString(), DataFlag = 0, MachineCode = machineCode, ResultCode = eEquInfCmdResultCode.默认.ToString(), SampleCode = sampleCode, UnLoadType = sampleUnloadType.ToString(), SyncFlag = 0, SamplingId = samplingId, BarrelNumber = barrelNumber }; sampleUnloadCmdId = sampleUnloadCmd.Id; return(Dbers.GetInstance().SelfDber.Insert <InfQCJXCYUnLoadCMD>(sampleUnloadCmd) > 0); }
/// <summary> /// 获取卸样状态 /// </summary> /// <param name="output"></param> /// <returns></returns> public eEquInfCmdResultCode GetQCJXCYUnloadSamplerState(string UnloadSamplerId) { eEquInfCmdResultCode eResult; InfQCJXCYUnLoadCMD SampleUnloadCmd = Dbers.GetInstance().SelfDber.Get <InfQCJXCYUnLoadCMD>(UnloadSamplerId); if (SampleUnloadCmd != null) { if (Enum.TryParse(SampleUnloadCmd.ResultCode, out eResult)) { return(eResult); } else { return(eEquInfCmdResultCode.默认); } } else { return(eEquInfCmdResultCode.默认); } }
private void superGridControl3_CellClick(object sender, GridCellClickEventArgs e) { if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.CurrentSampler.Parentid).EquipmentCode == "皮带采样机") { InfBeltSampleUnloadCmd sampleUnloadCmd = e.GridCell.GridRow.DataItem as InfBeltSampleUnloadCmd; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { InfBeltSampleUnloadCmd beltSampleUnloadCmd = gridRow.DataItem as InfBeltSampleUnloadCmd; gridRow.Checked = (beltSampleUnloadCmd != null && sampleUnloadCmd.Id == beltSampleUnloadCmd.Id); } } else if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.CurrentSampler.Parentid).EquipmentCode == "汽车机械采样机") { InfQCJXCYUnLoadCMD sampleUnloadCmd = e.GridCell.GridRow.DataItem as InfQCJXCYUnLoadCMD; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { InfQCJXCYUnLoadCMD qcjxcySampleUnloadCmd = gridRow.DataItem as InfQCJXCYUnLoadCMD; gridRow.Checked = (qcjxcySampleUnloadCmd != null && sampleUnloadCmd.Id == qcjxcySampleUnloadCmd.Id); } } }
/// <summary> /// 发送制样计划 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSendMakeCmd_Click(object sender, EventArgs e) { String tempSampleID = String.Empty; if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.currentSampler.Parentid).EquipmentCode == "皮带采样机") { InfBeltSampleUnloadCmd beltSampleUnloadCmd = null; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { if (gridRow.Checked) { beltSampleUnloadCmd = gridRow.DataItem as InfBeltSampleUnloadCmd; } } if (beltSampleUnloadCmd == null) { MessageBoxEx.Show("请选择卸样记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tempSampleID = beltSampleUnloadCmd.SamplingId; } else if (Dbers.GetInstance().SelfDber.Get <CmcsCMEquipment>(this.currentSampler.Parentid).EquipmentCode == "汽车机械采样机") { InfQCJXCYUnLoadCMD qcjxcyUnLoadCMD = null; foreach (GridRow gridRow in superGridControl3.PrimaryGrid.Rows) { if (gridRow.Checked) { qcjxcyUnLoadCMD = gridRow.DataItem as InfQCJXCYUnLoadCMD; } } if (qcjxcyUnLoadCMD == null) { MessageBoxEx.Show("请选择卸样记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } tempSampleID = qcjxcyUnLoadCMD.SamplingId; } CmcsRCSampleBarrel rCSampleBarrel = commonDAO.SelfDber.Entity <CmcsRCSampleBarrel>(" where SamplingId='" + tempSampleID + "' order by CreateDate desc"); if (rCSampleBarrel == null) { MessageBoxEx.Show("未找到采样单明细记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string str = getStr(tempSampleID); //根据采样ID查询该采样ID所在的批次是否还有未卸样的记录 str = str == string.Empty ? "确定要发送制样命令" : str + "还有同批次的煤样未卸载,确定要发送制样命令?"; if (MessageBoxEx.Show(str, "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { string systemStatus = commonDAO.GetSignalDataValue(this.CurrentmakerMachineCode, eSignalDataName.系统.ToString()); if (systemStatus == "就绪待机") { SendMakePlan(tempSampleID); } else { MessageBoxEx.Show("制样机系统未就绪,禁止发送制样命令", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } }
/// <summary> /// 同步卸样命令 /// </summary> /// <param name="output"></param> /// <returns></returns> public void SyncJXCYControlUnloadCMD(Action <string, eOutputType> output) { int res = 0; // 集中管控 > 第三方 foreach (InfQCJXCYUnLoadCMD entity in CarSamplerDAO.GetInstance().GetWaitForSyncJXCYSampleUnloadCmd(MachineCode)) { bool isSuccess = false; EquQCJXCYJUnloadCmd pJXCYCMD = this.EquDber.Get <EquQCJXCYJUnloadCmd>(entity.Id); if (pJXCYCMD == null) { isSuccess = this.EquDber.Insert(new EquQCJXCYJUnloadCmd { // 保持相同的Id Id = entity.Id, DataFlag = 0, CreateDate = entity.CreateDate, SampleCode = entity.SampleCode, ResultCode = eEquInfCmdResultCode.默认.ToString(), UnLoadType = entity.UnLoadType.ToString(), SamplingId = entity.SamplingId }) > 0; } else { isSuccess = true; } if (isSuccess) { entity.SyncFlag = 1; Dbers.GetInstance().SelfDber.Update(entity); res++; } } output(string.Format("同步卸样命令 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal); res = 0; // 第三方 > 集中管控 foreach (EquQCJXCYJUnloadCmd entity in this.EquDber.Entities <EquQCJXCYJUnloadCmd>("where DataFlag=2 and datediff(dd,CreateDate,getdate())=0")) { InfQCJXCYUnLoadCMD JXCYCmd = Dbers.GetInstance().SelfDber.Get <InfQCJXCYUnLoadCMD>(entity.Id); if (JXCYCmd == null) { continue; } // 更新执行结果等 JXCYCmd.ResultCode = entity.ResultCode; if (Dbers.GetInstance().SelfDber.Update(JXCYCmd) > 0) { // 我方已读 entity.DataFlag = 3; this.EquDber.Update(entity); res++; } } output(string.Format("同步卸样命令 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal); }