예제 #1
0
        /// <summary>
        /// 发送采样计划
        /// </summary>
        /// <returns></returns>
        bool SendSamplingPlan()
        {
            InfBeltSamplePlan oldBeltSamplePlan = Dbers.GetInstance().SelfDber.Entity <InfBeltSamplePlan>("where InFactoryBatchId=:InFactoryBatchId and SampleCode=:SampleCode and MachineCode=:MachineCode", new { InFactoryBatchId = this.CurrentRCSampling.BatchId, SampleCode = this.CurrentRCSampling.SampleCode, MachineCode = this.CurrentSampleMachine.EquipmentName });

            if (oldBeltSamplePlan == null)
            {
                oldBeltSamplePlan                  = new InfBeltSamplePlan();
                oldBeltSamplePlan.DataFlag         = 0;
                oldBeltSamplePlan.InterfaceType    = this.CurrentSampleMachine.InterfaceType;
                oldBeltSamplePlan.InFactoryBatchId = this.CurrentRCSampling.BatchId;
                oldBeltSamplePlan.SampleCode       = this.CurrentRCSampling.SampleCode;
                oldBeltSamplePlan.FuelKindName     = this.CurrentRCSampling.FuelKindName;
                oldBeltSamplePlan.Mt               = 0;
                oldBeltSamplePlan.TicketWeight     = 0;
                oldBeltSamplePlan.GatherType       = "样桶";
                oldBeltSamplePlan.TrainCode        = ((ComboItem)cmbTrainCode.SelectedItem) != null ? ((ComboItem)cmbTrainCode.SelectedItem).Text : "";
                oldBeltSamplePlan.SampleType       = CurrentRCSampling.SamplingType;
                oldBeltSamplePlan.MachineCode      = CurrentSampleMachine.EquipmentCode;
                oldBeltSamplePlan.CarCount         = this.CurrentRCSampling.TransportNumber;
                //oldBeltSamplePlan.TrainCode = "#2";
                if (oldBeltSamplePlan.SampleType == eSamplingType.机械采样.ToString() || oldBeltSamplePlan.SampleType == eSamplingType.皮带采样.ToString())
                {
                    IList <CmcsTransport> transports = commonDAO.SelfDber.Entities <CmcsTransport>("where InFactoryBatchId=:InFactoryBatchId order by OrderNumber", new { InFactoryBatchId = CurrentRCSampling.BatchId });
                    foreach (CmcsTransport item in transports)
                    {
                        InfBeltSamplePlanDetail samplePlanDetail = new InfBeltSamplePlanDetail();
                        samplePlanDetail.PlanId      = oldBeltSamplePlan.Id;
                        samplePlanDetail.MchineCode  = this.CurrentSampleMachine.EquipmentCode;
                        samplePlanDetail.CarNumber   = item.TransportNo;
                        samplePlanDetail.OrderNumber = item.OrderNumber;
                        samplePlanDetail.SyncFlag    = 0;
                        samplePlanDetail.CarModel    = item.TrainType;
                        samplePlanDetail.CyCount     = Convert.ToInt32(this.cmbCYCount.Text);                    //(int)dbi_CyCount.Value;
                        //samplePlanDetail.TrainCode = "#2";
                        Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlanDetail>(samplePlanDetail);
                    }
                    commonDAO.SetSignalDataValue(this.CurrentSampleMachine.EquipmentName, eSignalDataName.矿发量.ToString(), transports.Sum(a => a.TicketQty).ToString());
                }
                commonDAO.SetSignalDataValue(this.CurrentSampleMachine.EquipmentName, eSignalDataName.采样编码.ToString(), this.CurrentRCSampling.SampleCode);

                return(Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlan>(oldBeltSamplePlan) > 0);
            }
            else
            {
                oldBeltSamplePlan.DataFlag     = 0;
                oldBeltSamplePlan.FuelKindName = this.CurrentRCSampling.FuelKindName;
                oldBeltSamplePlan.Mt           = 0;
                oldBeltSamplePlan.TicketWeight = 0;
                oldBeltSamplePlan.SampleType   = CurrentRCSampling.SamplingType;
                oldBeltSamplePlan.MachineCode  = CurrentSampleMachine.EquipmentCode;
                oldBeltSamplePlan.CarCount     = this.CurrentRCSampling.TransportNumber;
                oldBeltSamplePlan.TrainCode    = ((ComboItem)cmbTrainCode.SelectedItem) != null ? ((ComboItem)cmbTrainCode.SelectedItem).Text : "";
                oldBeltSamplePlan.SyncFlag     = 0;
                if (oldBeltSamplePlan.SampleType == eSamplingType.机械采样.ToString() || oldBeltSamplePlan.SampleType == eSamplingType.皮带采样.ToString())
                {
                    IList <CmcsTransport> transports = commonDAO.SelfDber.Entities <CmcsTransport>("where InFactoryBatchId=:InFactoryBatchId order by OrderNumber", new { InFactoryBatchId = CurrentRCSampling.BatchId });
                    foreach (CmcsTransport item in transports)
                    {
                        InfBeltSamplePlanDetail samplePlanDetail = commonDAO.SelfDber.Entity <InfBeltSamplePlanDetail>("where PlanId=:PlanId and CarNumber=:CarNumber order by OrderNumber", new { PlanId = oldBeltSamplePlan.Id, CarNumber = item.TransportNo });
                        if (samplePlanDetail == null)
                        {
                            samplePlanDetail             = new InfBeltSamplePlanDetail();
                            samplePlanDetail.PlanId      = oldBeltSamplePlan.Id;
                            samplePlanDetail.MchineCode  = this.CurrentSampleMachine.EquipmentCode;
                            samplePlanDetail.CarNumber   = item.TransportNo;
                            samplePlanDetail.OrderNumber = item.OrderNumber;
                            samplePlanDetail.SyncFlag    = 0;
                            samplePlanDetail.CarModel    = item.TrainType;
                            samplePlanDetail.CyCount     = Convert.ToInt32(this.cmbCYCount.Text);                        // (int)dbi_CyCount.Value;
                            //samplePlanDetail.TrainCode = "#2";
                            Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlanDetail>(samplePlanDetail);
                        }
                    }
                }
                return(Dbers.GetInstance().SelfDber.Update(oldBeltSamplePlan) > 0);
            }
        }
예제 #2
0
        /// <summary>
        /// 同步采样计划明细
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSamplePlanDetail(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSamplePlanDetail entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlanDetail(this.MachineCode))
            {
                bool isSuccess = false;
                EquHCQSCYJPlanDetail samplecmdEqu = this.EquDber.Get <EquHCQSCYJPlanDetail>(entity.Id);
                if (samplecmdEqu == null)
                {
                    isSuccess = this.EquDber.Insert(new EquHCQSCYJPlanDetail
                    {
                        // 保持相同的Id
                        Id          = entity.Id,
                        PlanId      = entity.PlanId,
                        MachineCode = this.MachineCode,
                        CarNumber   = entity.CarNumber,
                        CarModel    = entity.CarModel.Substring(0, 3),
                        CyCount     = entity.CyCount,
                        OrderNumber = entity.OrderNumber,
                        DataFlag    = 0
                    }) > 0;
                }
                else
                {
                    samplecmdEqu.PlanId      = entity.PlanId;
                    samplecmdEqu.MachineCode = this.MachineCode;
                    samplecmdEqu.CarNumber   = entity.CarNumber;
                    samplecmdEqu.CarModel    = entity.CarModel.Substring(0, 3);
                    samplecmdEqu.CyCount     = entity.CyCount;
                    samplecmdEqu.OrderNumber = entity.OrderNumber;
                    //samplecmdEqu.DataFlag = 0;
                    isSuccess = this.EquDber.Update(samplecmdEqu) > 0;
                }

                if (isSuccess)
                {
                    entity.SyncFlag = 1;
                    Dbers.GetInstance().SelfDber.Update(entity);

                    res++;
                }
            }
            output(string.Format("同步采样计划明细 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);


            res = 0;
            // 第三方 > 集中管控
            foreach (EquHCQSCYJPlanDetail entity in this.EquDber.Entities <EquHCQSCYJPlanDetail>("where DataFlag=2 and datediff(dd,CreateDate,getdate())=0"))
            {
                InfBeltSamplePlanDetail samplecmdInf = Dbers.GetInstance().SelfDber.Get <InfBeltSamplePlanDetail>(entity.Id);
                if (samplecmdInf == null)
                {
                    continue;
                }

                //samplecmdInf.Point1 = entity.Point1;
                //samplecmdInf.Point2 = entity.Point2;
                //samplecmdInf.Point3 = entity.Point3;
                //samplecmdInf.Point4 = entity.Point4;
                //samplecmdInf.Point5 = entity.Point5;
                //samplecmdInf.Point6 = entity.Point6;
                samplecmdInf.StartTime  = entity.StartTime;
                samplecmdInf.EndTime    = entity.EndTime;
                samplecmdInf.SampleUser = entity.SampleUser;

                if (Dbers.GetInstance().SelfDber.Update(samplecmdInf) > 0)
                {
                    // 我方已读
                    entity.DataFlag = 3;
                    this.EquDber.Update(entity);

                    res++;
                }
            }
            output(string.Format("同步采样计划明细 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
        }
예제 #3
0
        /// <summary>
        /// 发送采样计划
        /// </summary>
        /// <returns></returns>
        bool SendSamplingPlan()
        {
            InfBeltSamplePlan oldBeltSamplePlan = Dbers.GetInstance().SelfDber.Entity <InfBeltSamplePlan>("where InFactoryBatchId=:InFactoryBatchId and SampleCode=:SampleCode", new { InFactoryBatchId = this.CurrentRCSampling.BatchId, SampleCode = this.CurrentRCSampling.SampleCode });

            if (oldBeltSamplePlan == null)
            {
                oldBeltSamplePlan                  = new InfBeltSamplePlan();
                oldBeltSamplePlan.DataFlag         = 0;
                oldBeltSamplePlan.InterfaceType    = this.CurrentSampleMachine.InterfaceType;
                oldBeltSamplePlan.InFactoryBatchId = this.CurrentRCSampling.BatchId;
                oldBeltSamplePlan.SampleCode       = this.CurrentRCSampling.SampleCode;
                oldBeltSamplePlan.FuelKindName     = this.CurrentRCSampling.FuelKindName;
                oldBeltSamplePlan.Mt               = 0;
                oldBeltSamplePlan.TicketWeight     = 0;
                oldBeltSamplePlan.GatherType       = "样桶";
                oldBeltSamplePlan.SampleType       = CurrentRCSampling.SamplingType;
                oldBeltSamplePlan.MachineCode      = CurrentSampleMachine.EquipmentCode;
                oldBeltSamplePlan.CarCount         = this.CurrentRCSampling.TransportNumber;
                //oldBeltSamplePlan.TrainCode = "#2";
                if (oldBeltSamplePlan.SampleType == eSamplingType.机械采样.ToString())
                {
                    IList <CmcsTransport> transports = commonDAO.SelfDber.Entities <CmcsTransport>("where InFactoryBatchId=:InFactoryBatchId order by OrderNumber", new { InFactoryBatchId = CurrentRCSampling.BatchId });
                    foreach (CmcsTransport item in transports)
                    {
                        InfBeltSamplePlanDetail samplePlanDetail = new InfBeltSamplePlanDetail();
                        samplePlanDetail.PlanId      = oldBeltSamplePlan.Id;
                        samplePlanDetail.MchineCode  = this.CurrentSampleMachine.EquipmentCode;
                        samplePlanDetail.CarNumber   = item.TransportNo;
                        samplePlanDetail.OrderNumber = item.OrderNumber;
                        samplePlanDetail.SyncFlag    = 0;
                        samplePlanDetail.CarModel    = item.TrainType;
                        samplePlanDetail.CyCount     = 2;
                        //samplePlanDetail.TrainCode = "#2";
                        Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlanDetail>(samplePlanDetail);
                    }
                }
                return(Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlan>(oldBeltSamplePlan) > 0);
            }
            else
            {
                oldBeltSamplePlan.DataFlag     = 0;
                oldBeltSamplePlan.FuelKindName = this.CurrentRCSampling.FuelKindName;
                oldBeltSamplePlan.Mt           = 0;
                oldBeltSamplePlan.TicketWeight = 0;
                oldBeltSamplePlan.SampleType   = CurrentRCSampling.SamplingType;
                oldBeltSamplePlan.MachineCode  = CurrentSampleMachine.EquipmentCode;
                oldBeltSamplePlan.CarCount     = this.CurrentRCSampling.TransportNumber;
                oldBeltSamplePlan.TrainCode    = "#2";
                oldBeltSamplePlan.SyncFlag     = 0;
                if (oldBeltSamplePlan.SampleType == eSamplingType.机械采样.ToString())
                {
                    IList <CmcsTransport> transports = commonDAO.SelfDber.Entities <CmcsTransport>("where InFactoryBatchId=:InFactoryBatchId order by OrderNumber", new { InFactoryBatchId = CurrentRCSampling.BatchId });
                    foreach (CmcsTransport item in transports)
                    {
                        InfBeltSamplePlanDetail samplePlanDetail = commonDAO.SelfDber.Entity <InfBeltSamplePlanDetail>("where PlanId=:PlanId and CarNumber=:CarNumber order by OrderNumber", new { PlanId = oldBeltSamplePlan.Id, CarNumber = item.TransportNo });
                        if (samplePlanDetail == null)
                        {
                            samplePlanDetail             = new InfBeltSamplePlanDetail();
                            samplePlanDetail.PlanId      = oldBeltSamplePlan.Id;
                            samplePlanDetail.MchineCode  = this.CurrentSampleMachine.EquipmentCode;
                            samplePlanDetail.CarNumber   = item.TransportNo;
                            samplePlanDetail.OrderNumber = item.OrderNumber;
                            samplePlanDetail.SyncFlag    = 0;
                            samplePlanDetail.CarModel    = item.TrainType;
                            samplePlanDetail.CyCount     = 2;
                            //samplePlanDetail.TrainCode = "#2";
                            Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlanDetail>(samplePlanDetail);
                        }
                    }
                }
                return(Dbers.GetInstance().SelfDber.Update(oldBeltSamplePlan) > 0);
            }
        }