Exemple #1
0
        /// <summary>
        /// 保存入厂煤运输记录
        /// </summary>
        /// <returns></returns>
        bool SendSamplingPlan()
        {
            InfBeltSamplePlan oldBeltSamplePlan = Dbers.GetInstance().SelfDber.Entity <InfBeltSamplePlan>("where InFactoryBatchId=:InFactoryBatchId and SampleCode=:SampleCode", new { InFactoryBatchId = this.CurrentRCSampling.InCoalPotId, SampleCode = this.CurrentRCSampling.SampleCode });

            if (oldBeltSamplePlan == null)
            {
                return(Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlan>(new InfBeltSamplePlan
                {
                    DataFlag = 0,
                    InterfaceType = this.CurrentSampleMachine.InterfaceType,
                    InFactoryBatchId = this.CurrentRCSampling.InCoalPotId,
                    SampleCode = this.CurrentRCSampling.SampleCode,
                    //FuelKindName = this.CurrentRCSampling.FuelName,
                    CarCount = 0,
                    Mt = 0,
                    TicketWeight = 0,
                    GatherType = CurrentGatherType.ToString(),
                    SampleType = "皮带采样"
                }) > 0);
            }
            else
            {
                oldBeltSamplePlan.DataFlag = 0;
                //oldBeltSamplePlan.FuelKindName = this.CurrentRCSampling.FuelName;
                oldBeltSamplePlan.CarCount     = 0;
                oldBeltSamplePlan.Mt           = 0;
                oldBeltSamplePlan.TicketWeight = 0;
                oldBeltSamplePlan.GatherType   = CurrentGatherType.ToString();

                return(Dbers.GetInstance().SelfDber.Update(oldBeltSamplePlan) > 0);
            }
        }
        /// <summary>
        /// 发送采样计划,若存在则更新
        /// </summary>
        /// <param name="view_TrainTipperQueue"></param>
        /// <returns></returns>
        public bool SendSamplePlan(View_TrainTipperQueue view_TrainTipperQueue)
        {
            CmcsInFactoryBatch inFactoryBatch = Dbers.GetInstance().SelfDber.Get <CmcsInFactoryBatch>(view_TrainTipperQueue.InFactoryBatchId);

            if (inFactoryBatch == null)
            {
                throw new ArgumentNullException("inFactoryBatchId", "未找到Id=" + view_TrainTipperQueue.InFactoryBatchId + "的批次");
            }

            CmcsFuelKind fuelKind             = Dbers.GetInstance().SelfDber.Get <CmcsFuelKind>(inFactoryBatch.FuelKindId);
            List <View_TrainTipperQueue> list = trainTipperDAO.GetView_TrainTipperQueueBy(view_TrainTipperQueue.TrainSampleSchemeId);

            InfBeltSamplePlan oldBeltSamplePlan = Dbers.GetInstance().SelfDber.Entity <InfBeltSamplePlan>("where InFactoryBatchId=:InFactoryBatchId and SampleCode=:SampleCode", new { InFactoryBatchId = view_TrainTipperQueue.InFactoryBatchId, SampleCode = view_TrainTipperQueue.YuSampleCode });

            if (oldBeltSamplePlan == null)
            {
                Log4Neter.Info(this.trainTipper.EquipmentName + " - 向[" + this.trainBeltSampler.EquipmentCode + "]发送采样计划,采样码:" + view_TrainTipperQueue.YuSampleCode);

                return(Dbers.GetInstance().SelfDber.Insert <InfBeltSamplePlan>(new InfBeltSamplePlan
                {
                    DataFlag = 0,
                    InterfaceType = this.trainBeltSampler.InterfaceType,
                    InFactoryBatchId = view_TrainTipperQueue.InFactoryBatchId,
                    SampleCode = view_TrainTipperQueue.YuSampleCode,
                    FuelKindName = fuelKind != null ? fuelKind.Name : string.Empty,
                    CarCount = list.Count,
                    Mt = 0,
                    TicketWeight = list.Sum(a => a.TicketQty),
                    SampleType = eEquInfSampleType.到集样罐.ToString(),
                    GatherType = commonDAO.GetCommonAppletConfigString(this.trainBeltSampler.EquipmentCode + "集样方式")
                }) > 0);
            }
            else
            {
                Log4Neter.Info(this.trainTipper.EquipmentName + " - 向[" + this.trainBeltSampler.EquipmentCode + "]更新采样计划,采样码:" + view_TrainTipperQueue.YuSampleCode);

                oldBeltSamplePlan.DataFlag     = 0;
                oldBeltSamplePlan.FuelKindName = fuelKind != null ? fuelKind.Name : string.Empty;
                oldBeltSamplePlan.CarCount     = list.Count;
                oldBeltSamplePlan.Mt           = 0;
                oldBeltSamplePlan.TicketWeight = list.Sum(a => a.TicketQty);
                oldBeltSamplePlan.SampleType   = eEquInfSampleType.到集样罐.ToString();
                oldBeltSamplePlan.GatherType   = commonDAO.GetCommonAppletConfigString(this.trainBeltSampler.EquipmentCode + "集样方式");

                return(Dbers.GetInstance().SelfDber.Update(oldBeltSamplePlan) > 0);
            }
        }
Exemple #3
0
        /// <summary>
        /// 同步采样计划
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSamplePlan(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSamplePlan entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlan(this.MachineCode))
            {
                bool isSuccess = false;
                // 需调整:命令中的水分等信息视接口而定
                EquHCQSCYJPlan samplecmdEqu = this.EquDber.Get <EquHCQSCYJPlan>(entity.Id);
                if (samplecmdEqu == null)
                {
                    isSuccess = this.EquDber.Insert(new EquHCQSCYJPlan
                    {
                        // 保持相同的Id
                        Id               = entity.Id,
                        SampleCode       = entity.SampleCode,
                        MachineCode      = this.MachineCode,
                        TrainCode        = entity.TrainCode,
                        InFactoryBatchId = entity.InFactoryBatchId,
                        TicketWeight     = entity.TicketWeight,
                        CarCount         = entity.CarCount,
                        Mt               = entity.Mt,
                        DataFlag         = 0
                    }) > 0;
                }
                else
                {
                    samplecmdEqu.SampleCode       = entity.SampleCode;
                    samplecmdEqu.MachineCode      = this.MachineCode;
                    samplecmdEqu.TrainCode        = entity.TrainCode;
                    samplecmdEqu.InFactoryBatchId = entity.InFactoryBatchId;
                    samplecmdEqu.TicketWeight     = entity.TicketWeight;
                    samplecmdEqu.CarCount         = entity.CarCount;
                    samplecmdEqu.Mt       = entity.Mt;
                    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 (EquHCQSCYJPlan entity in this.EquDber.Entities <EquHCQSCYJPlan>("where DataFlag=2 and datediff(dd,CreateDate,getdate())=0"))
            {
                InfBeltSamplePlan samplecmdInf = Dbers.GetInstance().SelfDber.Get <InfBeltSamplePlan>(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);
        }
        /// <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);
            }
        }
        /// <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);
            }
        }
Exemple #6
0
        /// <summary>
        /// 同步采样计划
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncPlan(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSamplePlan entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlan(Type == "入场" ? GlobalVars.InterfaceType_PDCYJ_In : GlobalVars.InterfaceType_PDCYJ_Out))
            {
                bool isSuccess = false;

                EquPDCYJPlan pDCYPlan = this.EquDber.Get <EquPDCYJPlan>(entity.Id);
                if (pDCYPlan == null)
                {
                    isSuccess = this.EquDber.Insert(new EquPDCYJPlan
                    {
                        // 保持相同的Id
                        Id               = entity.Id,
                        CarCount         = entity.CarCount,
                        DataFlag         = 0,
                        CreateDate       = entity.CreateDate,
                        InFactoryBatchId = entity.InFactoryBatchId,
                        Mt               = ConvertToInfMt(entity.Mt),
                        SampleCode       = entity.SampleCode,
                        GatherType       = entity.GatherType,
                        TicketWeight     = entity.TicketWeight
                    }) > 0;
                }
                else
                {
                    pDCYPlan.CarCount         = entity.CarCount;
                    pDCYPlan.DataFlag         = 0;
                    pDCYPlan.CreateDate       = entity.CreateDate;
                    pDCYPlan.InFactoryBatchId = entity.InFactoryBatchId;
                    pDCYPlan.Mt           = ConvertToInfMt(entity.Mt);
                    pDCYPlan.SampleCode   = entity.SampleCode;
                    pDCYPlan.GatherType   = entity.GatherType;
                    pDCYPlan.TicketWeight = entity.TicketWeight;

                    isSuccess = this.EquDber.Update(pDCYPlan) > 0;
                }

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

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

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

                // 更新采样开始、结束时间、采样员等
                beltSamplePlan.StartTime  = entity.StartTime;
                beltSamplePlan.EndTime    = entity.EndTime;
                beltSamplePlan.SampleUser = entity.SampleUser;

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

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