コード例 #1
0
        /// <summary>
        /// 同步集样罐信息到集中管控
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncBarrel(Action <string, eOutputType> output)
        {
            int res = 0;

            List <KY_CYJ_P_BARREL> infpdcybarrels = DcDbers.GetInstance().BeltSampler_Dber.Entities <KY_CYJ_P_BARREL>();

            foreach (KY_CYJ_P_BARREL entity in infpdcybarrels)
            {
                if (commonDAO.SaveEquInfSampleBarrel(new InfEquInfSampleBarrel
                {
                    BarrelNumber = entity.Barrel_Code,
                    BarrelStatus = entity.Down_Full == 1 ? "已满" : "未满".ToString(),
                    MachineCode = this.MachineCode,
                    InterfaceType = GlobalVars.InterfaceType_PDCYJ,
                    SampleCode = entity.Batch_Number,
                    InFactoryBatchId = commonDAO.GetBatchIdBySampleCode(entity.Barrel_Code),
                    SampleCount = entity.Down_Count,
                    UpdateTime = entity.End_Time,
                    BarrelType = "底卸式",
                }))
                {
                    res++;
                }
            }

            output(string.Format("同步集样罐记录 {0} 条", res), eOutputType.Normal);
        }
コード例 #2
0
        /// <summary>
        /// 是否处于空闲状态
        /// </summary>
        public bool CheckFree()
        {
            bool returnCheckFree = true;

            if (returnCheckFree)
            {
                if (DcDbers.GetInstance().PneumaticTransfer_Dber.Entities <EquQDBill>(" where DataStatus=0 or DataStatus=3").Count != 0)
                {
                    returnCheckFree = false;
                }
            }
            if (returnCheckFree)
            {
                List <EquQDStatus> infqdstatuses = DcDbers.GetInstance().PneumaticTransfer_Dber.Entities <EquQDStatus>("");
                if (infqdstatuses.Count != 0)
                {
                    if (infqdstatuses[0].SamReady != 3)
                    {
                        returnCheckFree = false;
                    }
                }
                else
                {
                    returnCheckFree = false;
                }
            }
            return(returnCheckFree);
        }
コード例 #3
0
        private void button7_Click(object sender, EventArgs e)
        {
            List <EquQDStatus> infcygdataflags = DcDbers.GetInstance().PneumaticTransfer_Dber.Entities <EquQDStatus>("");

            if (infcygdataflags.Count > 0)
            {
                if (((Button)sender).Text == "气动传输正常")
                {
                    infcygdataflags[0].SamReady = 3;
                    DcDbers.GetInstance().AutoCupboard_Dber.Execute("UPDATE QD_STATUS_TB SET SAMREADY=3");
                    ((Button)sender).Text = "气动传输异常";
                }
                else
                {
                    infcygdataflags[0].SamReady = 1;
                    DcDbers.GetInstance().AutoCupboard_Dber.Execute("UPDATE QD_STATUS_TB SET SAMREADY=1");
                    ((Button)sender).Text = "气动传输正常";
                }
            }
            else
            {
                if (((Button)sender).Text == "气动传输正常")
                {
                    EquQDStatus infcygdataflag = new EquQDStatus();
                    infcygdataflag.SamReady = 3;
                    DcDbers.GetInstance().AutoCupboard_Dber.Insert(infcygdataflag);
                }
            }
        }
コード例 #4
0
        private void button6_Click(object sender, EventArgs e)
        {
            List <EquCYGSignal> infcygdataflags = DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYGSignal>(" where TagName='系统'");

            if (infcygdataflags.Count > 0)
            {
                if (((Button)sender).Text == "智能存样柜系统正常")
                {
                    infcygdataflags[0].TagValue = 3;
                    DcDbers.GetInstance().AutoCupboard_Dber.Update(infcygdataflags[0]);
                    ((Button)sender).Text = "智能存样柜系统异常";
                }
                else
                {
                    infcygdataflags[0].TagValue = 2;
                    DcDbers.GetInstance().AutoCupboard_Dber.Update(infcygdataflags[0]);
                    ((Button)sender).Text = "智能存样柜系统正常";
                }
            }
            else
            {
                if (((Button)sender).Text == "智能存样柜系统正常")
                {
                    EquCYGSignal infcygdataflag = new EquCYGSignal();
                    infcygdataflag.TagName  = "系统";
                    infcygdataflag.TagValue = 3;
                    DcDbers.GetInstance().AutoCupboard_Dber.Insert(infcygdataflag);
                }
            }
        }
コード例 #5
0
        private void button5_Click(object sender, EventArgs e)
        {
            List <EquCYGSignal> infcygdataflags = DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYGSignal>(" where TagName='托盘到位'");

            if (infcygdataflags.Count > 0)
            {
                if (((Button)sender).Text == "托盘到位")
                {
                    infcygdataflags[0].TagValue   = 1;
                    infcygdataflags[0].UpdateTime = DateTime.Now;
                    DcDbers.GetInstance().AutoCupboard_Dber.Update(infcygdataflags[0]);
                    ((Button)sender).Text = "托盘未到位";
                }
                else
                {
                    infcygdataflags[0].TagValue = 0;
                    DcDbers.GetInstance().AutoCupboard_Dber.Update(infcygdataflags[0]);
                    ((Button)sender).Text = "托盘到位";
                }
            }
            else
            {
                if (((Button)sender).Text == "托盘到位")
                {
                    EquCYGSignal infcygdataflag = new EquCYGSignal();
                    infcygdataflag.TagName  = "托盘到位";
                    infcygdataflag.TagValue = 1;
                    DcDbers.GetInstance().AutoCupboard_Dber.Insert(infcygdataflag);
                }
            }
        }
コード例 #6
0
        private void btn_cyg(object sender, EventArgs e)
        {
            List <EquCYGBill> infcygbill = DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYGBill>(" order by CZPFSSJ desc");

            List <EquCYGBillRecord> infcygbillrecords = DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYGBillRecord>(" where billid='" + infcygbill[0].Id + "'");

            if (infcygbillrecords.Count == 0)
            {
                EquCYGBillRecord infcygbillrecord = new EquCYGBillRecord();
                infcygbillrecord.BillId = infcygbill[0].Id;
                if (((Button)sender).Text.Contains("成功"))
                {
                    infcygbillrecord.CZPJG = 1;
                }
                else
                {
                    infcygbillrecord.CZPJG = 2;
                }
                DcDbers.GetInstance().AutoCupboard_Dber.Insert(infcygbillrecord);
            }
            else
            {
                if (((Button)sender).Text.Contains("成功"))
                {
                    infcygbillrecords[0].CZPJG = 1;
                }
                else
                {
                    infcygbillrecords[0].CZPJG = 2;
                }
                DcDbers.GetInstance().AutoCupboard_Dber.Update(infcygbillrecords[0]);
            }
        }
コード例 #7
0
        /// <summary>
        /// 插入车辆信息至翻车衡交互数据库
        /// </summary>
        /// <param name="trunNumber"></param>
        /// <param name="transport"></param>
        public static bool InsertCarToTurnCarWeighter(string trunNumber, CmcsTransport transport)
        {
            if (transport != null && !string.IsNullOrEmpty(transport.InFactoryBatchId))
            {
                CmcsRCSampling sampling = Dbers.GetInstance().SelfDber.Entity <CmcsRCSampling>("where InFactoryBatchId=:InFactoryBatchId and SamplingType not like '%抽查%' order by SamplingDate desc", new { InFactoryBatchId = transport.InFactoryBatchId });
                if (sampling != null)
                {
                    if (DcDbers.GetInstance().TurnCarWeighterMutualDber.Entity <CarInfoMutual>(" where  TurnCarNumber='" + trunNumber + "' and  CarNumber='" + transport.TransportNo + "' and DataFlag=0 ") == null)
                    {
                        DcDbers.GetInstance().TurnCarWeighterMutualDber.Execute(" update CarInfoMutual set DataFlag=1 where TurnCarNumber='" + trunNumber + "'");

                        return(DcDbers.GetInstance().TurnCarWeighterMutualDber.Insert(new CarInfoMutual()
                        {
                            TurnCarNumber = trunNumber,
                            CarNumber = transport.TransportNo,
                            SampleBillNumber = sampling.SampleCode,
                            InFactoryDate = transport.InfactoryTime,
                            TicketWeight = (double)transport.TicketQty,
                            CreateDate = System.DateTime.Now,
                            WeightDate = DateTime.Now,
                            DataFlag = 0,
                            CancelSign = 0
                        }) > 0);
                    }
                }
            }
            return(false);
        }
コード例 #8
0
        /// <summary>
        /// 获取上位机运行状态表 - 心跳值
        /// 每隔30s读取该值,如果数值不变化则表示设备上位机出现故障
        /// </summary>
        /// <param name="MachineCode">设备编码</param>
        public void SyncHeartbeatSignal()
        {
            EquQCJXCYJSignal pDCYSignal = DcDbers.GetInstance().CarJXSampler_Dber.Entity <EquQCJXCYJSignal>("where TagName=:TagName", new { TagName = GlobalVars.EquHeartbeatName });

            ChangeSystemHitchStatus((pDCYSignal != null && pDCYSignal.TagValue == this.PrevHeartbeat));

            this.PrevHeartbeat = pDCYSignal != null ? pDCYSignal.TagValue : string.Empty;
        }
コード例 #9
0
        public void setheart(Action <string, eOutputType> output)
        {
            int res = DcDbers.GetInstance().AutoCupboard_Dber.Execute("UPDATE DATAFLAG SET DATAFLAG=DATAFLAG+1");

            if (res > 0)
            {
                output("心跳传输成功", eOutputType.Normal);
            }
        }
コード例 #10
0
        /// <summary>
        /// 5号车号识别
        /// </summary>
        /// <param name="carNumber">车号</param>
        /// <param name="carDate">时间</param>
        /// <param name="direction">方向</param>
        /// <param name="carmodel">车型</param>
        /// <returns></returns>
        public static bool CarSpot5Data(Action <string, eOutputType> output, CmcsTrainRecognition trainPass)
        {
            CmcsTransport transport = Dbers.GetInstance().SelfDber.Entity <CmcsTransport>("where TransportNo='" + trainPass.CarNumber + "' and InfactoryTime>=to_date('" + DateTime.Now.Date.AddDays(-1) + "','yyyy/mm/dd HH24:MI:SS') order by InfactoryTime desc");

            if (transport == null)
            {
                return(false);
            }

            if (trainPass.Direction == "进厂" && transport.InfactoryTime > DateTime.MinValue)
            {
                if (trainPass.OrderNum == 2)                //处理牵车太靠近 两节车都识别到车号 后面一节车顶掉前一节车
                {
                    try
                    {
                        CmcsTrainRecognition lastentity = Dbers.GetInstance().SelfDber.Entity <CmcsTrainRecognition>("where CrossTime=:CrossTime and OrderNum=1 and DataFlag=1 order by CrossTime", new { CrossTime = trainPass.CrossTime });
                        if (lastentity != null)
                        {
                            CarInfoMutual mutual = DcDbers.GetInstance().TurnCarWeighterMutualDber.Entity <CarInfoMutual>("where CarNumber=:CarNumber and CreateDate>=:CreateDate", new { CarNumber = lastentity.CarNumber, CreateDate = DateTime.Now.AddDays(-1) });
                            if (mutual == null || mutual.SuttleWeight == 0)
                            {
                                return(false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        output("处理连续车号:" + ex.Message, eOutputType.Error);
                    }
                }
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_2, eSignalDataName.当前车号.ToString(), trainPass.CarNumber);

                //插入车辆信息至翻车衡交互数据库
                if (InsertCarToTurnCarWeighter("#2", transport))
                {
                    output(string.Format("向{0}插入一条数据", GlobalVars.MachineCode_TrunOver_2), eOutputType.Normal);
                }

                //更改翻车状态
                if (TurnTransportPosition(trainPass.CarNumber))
                {
                    output(string.Format("{0}更改为已翻车", trainPass.CarNumber), eOutputType.Normal);
                }
                return(true);
            }
            else if (trainPass.Direction == "出厂")
            {
                CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_2, eSignalDataName.当前车号.ToString(), string.Empty);
                //更改翻车状态
                if (UnTurnTransportPosition(trainPass.CarNumber))
                {
                    output(string.Format("{0}更改为未翻车", trainPass.CarNumber), eOutputType.Normal);
                }
                return(true);
            }
            return(false);
        }
コード例 #11
0
        public int SyncTransport(Action <string, eOutputType> output)
        {
            int res = 0;
            IList <TransportOld> list = DcDbers.GetInstance().TruckWeight_Dber.Entities <TransportOld>("where IsToServer=0 and SuttleWeight>0");

            foreach (TransportOld item in list)
            {
                CmcsBuyFuelTransport entity = CommonDAO.GetInstance().SelfDber.Get <CmcsBuyFuelTransport>(item.Id);
                if (entity == null)
                {
                    entity                     = new CmcsBuyFuelTransport();
                    entity.Id                  = item.Id;
                    entity.CreateDate          = item.CreateDate;
                    entity.OperDate            = item.OperDate;
                    entity.OperUser            = item.OperUser;
                    entity.CreateUser          = item.CreateUser;
                    entity.InFactoryTime       = item.InFactoryTime;
                    entity.GrossPlace          = item.GrossPlace;
                    entity.GrossTime           = item.GrossTime;
                    entity.GrossWeight         = item.GrossWeight;
                    entity.TarePlace           = item.TarePlace;
                    entity.TareTime            = item.TareTime;
                    entity.TareWeight          = item.TareWeight;
                    entity.SuttleWeight        = item.SuttleWeight;
                    entity.KsWeight            = item.KsWeight;
                    entity.KgWeight            = item.KgWeight;
                    entity.AutoKsWeight        = item.AutoKsWeight;
                    entity.CheckWeight         = item.CheckWeight;
                    entity.ProfitAndLossWeight = item.ProfitAndLossWeight;
                    entity.OutFactoryTime      = item.OutFactoryTime;
                    entity.MineName            = item.MineName;
                    entity.AutotruckId         = item.AutotruckId;
                    entity.CarNumber           = item.CarNumber;
                    entity.TicketWeight        = item.TicketWeight;
                    entity.FuelKindId          = item.FuelKindId;
                    entity.FuelKindName        = item.FuelKindName;
                    entity.IsUse               = item.IsUse;
                    entity.IsFinish            = item.IsFinish;
                    entity.StepName            = item.StepName;
                    entity.InFactoryBatchId    = item.InFactoryBatchId;
                    entity.SerialNumber        = item.SerialNumber;
                    res            += CommonDAO.GetInstance().SelfDber.Insert(entity);
                    item.IsToServer = 1;
                    DcDbers.GetInstance().TruckWeight_Dber.Update(item);
                }
            }
            output(string.Format("同步运输记录 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
            return(res);
        }
コード例 #12
0
        /// <summary>
        /// 同步历史卸样结果
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode"></param>
        public void SyncUnloadResult(Action <string, eOutputType> output)
        {
            int res = 0;

            res = 0;
            // 第三方 > 集中管控
            foreach (EquQCJXCYJUnloadResult entity in DcDbers.GetInstance().CarJXSampler_Dber.Entities <EquQCJXCYJUnloadResult>("where DataFlag=0"))
            {
                InfQCJXCYJUnloadResult oldUnloadResult = commonDAO.SelfDber.Get <InfQCJXCYJUnloadResult>(entity.Id);
                if (oldUnloadResult == null)
                {
                    // 查找采样命令
                    EquQCJXCYJSampleCmd qCJXCYJSampleCmd = DcDbers.GetInstance().CarJXSampler_Dber.Entity <EquQCJXCYJSampleCmd>("where SampleCode=:SampleCode", new { SampleCode = entity.SampleCode });
                    if (qCJXCYJSampleCmd != null)
                    {
                        // 生成采样桶记录
                        CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel()
                        {
                            BarrelCode       = entity.BarrelCode,
                            BarrellingTime   = entity.UnloadTime,
                            BarrelNumber     = entity.BarrelNumber,
                            InFactoryBatchId = qCJXCYJSampleCmd.InFactoryBatchId,
                            SamplerName      = commonDAO.GetMachineNameByCode(this.MachineCode),
                            SampleType       = eSamplingType.机械采样.ToString(),
                            SamplingId       = entity.SamplingId
                        };

                        if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0)
                        {
                            if (commonDAO.SelfDber.Insert(new InfQCJXCYJUnloadResult
                            {
                                SampleCode = entity.SampleCode,
                                BarrelCode = entity.BarrelCode,
                                UnloadTime = entity.UnloadTime,
                                DataFlag = entity.DataFlag
                            }) > 0)
                            {
                                entity.DataFlag = 1;
                                DcDbers.GetInstance().CarJXSampler_Dber.Update(entity);

                                res++;
                            }
                        }
                    }
                }
            }
            output(string.Format("同步卸样结果 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
        }
コード例 #13
0
        /// <summary>
        /// 默认为智能存样柜取到
        /// </summary>
        /// <param name="opstart"></param>
        /// <param name="opend"></param>
        /// <returns></returns>
        bool SendSample(eOp opstart = eOp.自动存查样管理系统, eOp opend = eOp.化验室)
        {
            EquQDBill infqdbill = new EquQDBill();

            infqdbill.OpStart       = (int)opstart;
            infqdbill.OpEnd         = (int)opend;
            infqdbill.Operator_Code = 501;
            infqdbill.Send_Time     = DateTime.Now;
            infqdbill.DataStatus    = 0;
            infqdbill.readState     = 1;
            if (DcDbers.GetInstance().PneumaticTransfer_Dber.Insert(infqdbill) > 0)
            {
                return(true);
            }
            return(false);
        }
コード例 #14
0
        private void btn_qdcs(object sender, EventArgs e)
        {
            List <EquQDBill> infqdbill = DcDbers.GetInstance().PneumaticTransfer_Dber.Entities <EquQDBill>(" order by Send_Time desc");

            if (((Button)sender).Text.Contains("成功"))
            {
                infqdbill[0].DataStatus = 1;
            }
            else
            {
                infqdbill[0].DataStatus = 2;
            }
            if (DcDbers.GetInstance().PneumaticTransfer_Dber.Execute("UPDATE QD_INTERFACE_TB SET DATASTATUS=" + infqdbill[0].DataStatus + " WHERE DATASTATUS=0") > 0)
            {
                tbQDCS.Text = ((Button)sender).Text;
            }
        }
コード例 #15
0
        /// <summary>
        /// 同步故障信息到集中管控
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncQCJXCYJError(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (EquQCJXCYJError entity in DcDbers.GetInstance().CarJXSampler_Dber.Entities <EquQCJXCYJError>("where DataFlag=0"))
            {
                if (commonDAO.SaveEquInfHitch(this.MachineCode, entity.ErrorTime, "故障代码 " + entity.ErrorCode + "," + entity.ErrorDescribe))
                {
                    entity.DataFlag = 1;
                    DcDbers.GetInstance().CarJXSampler_Dber.Update(entity);

                    res++;
                }
            }

            output(string.Format("同步故障信息记录 {0} 条", res), eOutputType.Normal);
        }
コード例 #16
0
        /// <summary>
        /// 同步制样 故障信息到集中管控
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncCYGError(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (EquQDError entity in DcDbers.GetInstance().PneumaticTransfer_Dber.Entities <EquQDError>("where DataStatus=0"))
            {
                if (CommonDAO.GetInstance().SaveEquInfHitch(MachineCode, entity.ErrorTime, entity.ErrorDec))
                {
                    entity.DataStatus = 1;
                    DcDbers.GetInstance().PneumaticTransfer_Dber.Insert(entity);

                    res++;
                }
            }

            output(string.Format("气动传输-同步故障信息记录 {0} 条", res), eOutputType.Normal);
        }
コード例 #17
0
        /// <summary>
        /// 同步采样计划_KY
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSamplePlan_KY(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSamplePlan_KY entity in Dbers.GetInstance().SelfDber.Entities <InfBeltSamplePlan_KY>("where SyncFlag=0"))
            {
                bool isSuccess = false;

                KY_CYJ_P_TurnOver turn = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_TurnOver>("where CY_Code=@CY_Code and TurnCode=@TurnCode", new { CY_Code = entity.SampleCode, TurnCode = entity.MachineCode });
                if (turn == null)
                {
                    turn             = new KY_CYJ_P_TurnOver();
                    turn.Send_Time   = DateTime.Now;
                    turn.CY_Code     = entity.SampleCode;
                    turn.DataFlag    = 0;
                    turn.Car_Count   = entity.CarCount;
                    turn.Ready_Count = 0;
                    turn.IsDone      = 0;
                    turn.TurnCode    = entity.MachineCode;
                    isSuccess        = DcDbers.GetInstance().BeltSampler_Dber.Insert(turn) > 0;
                }
                else
                {
                    turn.Send_Time   = DateTime.Now;
                    turn.CY_Code     = entity.SampleCode;
                    turn.DataFlag    = 0;
                    turn.Car_Count   = entity.CarCount;
                    turn.Ready_Count = 0;
                    turn.IsDone      = 0;
                    turn.TurnCode    = entity.MachineCode;
                    isSuccess        = DcDbers.GetInstance().BeltSampler_Dber.Update(turn) > 0;
                }


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

                    res++;
                }
            }
            output(string.Format("同步采样计划 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);
        }
コード例 #18
0
        /// <summary>
        /// 同步翻车信息
        /// </summary>
        /// <param name="output"></param>
        public void SyncTurn(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (KY_CYJ_P_TurnOver entity in DcDbers.GetInstance().BeltSampler_Dber.Entities <KY_CYJ_P_TurnOver>("where IsDone=0 order by Send_Time"))
            {
                entity.Ready_Count = commonDAO.GetRealyCarCountBySampleCode(entity.CY_Code);
                if (entity.Ready_Count == entity.Car_Count)
                {
                    entity.IsDone = 1;
                }
                entity.DataFlag  = 0;
                entity.Send_Time = DateTime.Now;
                res += DcDbers.GetInstance().BeltSampler_Dber.Update(entity);
                commonDAO.SetSignalDataValue(this.MachineCode, entity.TurnCode == "#1" ? "#1翻车机已翻车数" : "#2翻车机已翻车数", entity.Ready_Count.ToString());
            }
            output(string.Format("同步翻车信息{0}条", res), eOutputType.Normal);
        }
コード例 #19
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);
        //}

        ///// <summary>
        ///// 同步采样命令
        ///// </summary>
        ///// <param name="output"></param>
        ///// <param name="MachineCode">设备编码</param>
        //public void SyncSampleCmd(Action<string, eOutputType> output)
        //{
        //	int res = 0;

        //	// 集中管控 > 第三方
        //	foreach (InfBeltSampleCmd entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSampleCmd(this.MachineCode))
        //	{
        //		bool isSuccess = false;
        //		// 需调整:命令中的水分等信息视接口而定
        //		EquHCQSCYJSampleCmd samplecmdEqu = this.EquDber.Get<EquHCQSCYJSampleCmd>(entity.Id);
        //		if (samplecmdEqu == null)
        //		{
        //			isSuccess = this.EquDber.Insert(new EquHCQSCYJSampleCmd
        //			{
        //				// 保持相同的Id
        //				Id = entity.Id,
        //				SampleCode = entity.SampleCode,
        //				CmdCode = entity.CmdCode,
        //				ResultCode = entity.ResultCode,
        //				MachineCode = this.MachineCode,
        //				DataFlag = 0
        //			}) > 0;
        //		}
        //		else
        //		{
        //			samplecmdEqu.SampleCode = entity.SampleCode;
        //			samplecmdEqu.CmdCode = entity.CmdCode;
        //			samplecmdEqu.ResultCode = entity.ResultCode;
        //			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 (EquHCQSCYJSampleCmd entity in this.EquDber.Entities<EquHCQSCYJSampleCmd>("where DataFlag=2 and datediff(dd,CreateDate,getdate())=0"))
        //	{
        //		InfBeltSampleCmd samplecmdInf = Dbers.GetInstance().SelfDber.Get<InfBeltSampleCmd>(entity.Id);
        //		if (samplecmdInf == null) continue;

        //		if (entity.ResultCode.Contains("失败"))
        //		{
        //			samplecmdInf.ResultCode = eEquInfCmdResultCode.失败.ToString();
        //			commonDAO.SaveEquInfHitch(this.MachineCode, DateTime.Now, entity.ResultCode);
        //		}
        //		else
        //			samplecmdInf.ResultCode = entity.ResultCode;

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

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

        ///// <summary>
        ///// 同步历史卸样结果
        ///// </summary>
        ///// <param name="output"></param>
        ///// <param name="MachineCode"></param>
        //public void SyncUnloadResult(Action<string, eOutputType> output)
        //{
        //	int res = 0;

        //	res = 0;
        //	// 第三方 > 集中管控
        //	foreach (EquHCQSCYJUnloadResult entity in this.EquDber.Entities<EquHCQSCYJUnloadResult>("where DataFlag=0"))
        //	{
        //		InfBeltSamplerUnloadResult oldUnloadResult = commonDAO.SelfDber.Get<InfBeltSamplerUnloadResult>(entity.Id);
        //		if (oldUnloadResult == null)
        //		{
        //			// 查找采样命令
        //			EquHCQSCYJPlan qCJXCYJSampleCmd = this.EquDber.Entity<EquHCQSCYJPlan>("where SampleCode=@SampleCode", new { SampleCode = entity.SampleCode });
        //			if (qCJXCYJSampleCmd != null)
        //			{
        //				// 生成采样桶记录
        //				CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel()
        //				{
        //					BarrelCode = entity.BarrelCode,
        //					BarrellingTime = entity.UnloadTime,
        //					BarrelNumber = entity.BarrelNumber,
        //					InFactoryBatchId = qCJXCYJSampleCmd.InFactoryBatchId,
        //					SamplerName = this.MachineCode,
        //					SampleType = eSamplingType.机械采样.ToString(),
        //					SamplingId = entity.SamplingId
        //				};

        //				if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0)
        //				{
        //					if (commonDAO.SelfDber.Insert(new InfQCJXCYJUnloadResult
        //					{
        //						MachineCode = this.MachineCode,
        //						SampleCode = entity.SampleCode,
        //						BarrelCode = entity.BarrelCode,
        //						UnloadTime = entity.UnloadTime,
        //						DataFlag = entity.DataFlag
        //					}) > 0)
        //					{
        //						entity.DataFlag = 1;
        //						this.EquDber.Update(entity);

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

        /// <summary>
        /// 同步采样机其他命令
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSampleCmd(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfBeltSampleCmd_KY entity in commonDAO.SelfDber.Entities <InfBeltSampleCmd_KY>(" Where SyncFlag='0'"))
            {
                bool isSuccess = false;

                KY_CYJ_P_CMD samplecmdEqu = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_CMD>("where CMDId=@CMDId", new { CMDId = entity.Id });
                if (samplecmdEqu == null)
                {
                    isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(new KY_CYJ_P_CMD
                    {
                        CMDId        = entity.Id,
                        MachineCode  = MachineCodeToKY(entity.MachineCode),
                        CmdCode      = int.Parse(entity.CmdCode),
                        ResultCode   = 0,
                        OperatorName = entity.OperatorName,
                        SendDateTime = entity.SendDateTime,
                        DataFlag     = 0,
                    }) > 0;
                }
                else
                {
                    samplecmdEqu.MachineCode  = MachineCodeToKY(entity.MachineCode);
                    samplecmdEqu.CmdCode      = int.Parse(entity.CmdCode);
                    samplecmdEqu.ResultCode   = 0;
                    samplecmdEqu.OperatorName = entity.OperatorName;
                    samplecmdEqu.SendDateTime = entity.SendDateTime;
                    samplecmdEqu.DataFlag     = 0;
                    isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Update(samplecmdEqu) > 0;
                }

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

                    res++;
                }
            }
            output(string.Format("同步其他采样命令 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);
        }
コード例 #20
0
        /// <summary>
        /// 同步故障信息到集中管控
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncError(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (KY_CYJ_P_Alarm entity in DcDbers.GetInstance().BeltSampler_Dber.Entities <KY_CYJ_P_Alarm>("where DateDiff(dd,AlarmDateTime,getdate())<=7"))
            {
                InfEquInfHitch infEquInfHitch = Dbers.GetInstance().SelfDber.Entity <InfEquInfHitch>("where HitchTime=:HitchTime and HitchDescribe=:HitchDescribe", new { HitchTime = entity.AlarmDateTime, HitchDescribe = entity.VarComment });
                if (infEquInfHitch == null)
                {
                    if (commonDAO.SaveEquInfHitch(entity.VarName.Contains("A侧") ? GlobalVars.MachineCode_PDCYJ_1 : GlobalVars.MachineCode_PDCYJ_2, entity.AlarmDateTime, entity.VarComment))
                    {
                        //entity.DataFlag = 1;
                        //this.EquDber.Update(entity);

                        res++;
                    }
                }
            }

            output(string.Format("同步故障信息记录 {0} 条", res), eOutputType.Normal);
        }
コード例 #21
0
        /// <summary>
        /// 同步实时信号到集中管控
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        /// <returns></returns>
        public int SyncSignal(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (KY_CYJ_P_STATE state in DcDbers.GetInstance().BeltSampler_Dber.Entities <KY_CYJ_P_STATE>())
            {
                eEquInfBeltSamplerSystemStatus system = eEquInfBeltSamplerSystemStatus.等待采样;
                Enum.TryParse <eEquInfBeltSamplerSystemStatus>(state.CY_State, out system);
                res += commonDAO.SetSignalDataValue(KYToMachineCode(state.CYJ_Machine), eSignalDataName.设备状态.ToString(), system.ToString()) ? 1 : 0;

                eEquInfBeltSamplerUnloadStatus systemXL = eEquInfBeltSamplerUnloadStatus.默认;
                Enum.TryParse <eEquInfBeltSamplerSystemStatus>(state.XL_State, out system);
                res += commonDAO.SetSignalDataValue(KYToMachineCode(state.CYJ_Machine), eSignalDataName.卸料机状态.ToString(), systemXL.ToString()) ? 1 : 0;
            }

            //foreach (EquSignalData item in DcDbers.GetInstance().BeltSampler_Dber.Entities<EquSignalData>())
            //{

            //}
            output(string.Format("同步实时信号 {0} 条", res), eOutputType.Normal);

            return(res);
        }
コード例 #22
0
        /// <summary>
        /// 从汽车衡同步运输记录信息 并生成批次 采制化
        /// </summary>
        /// <param name="output"></param>
        public void SyncBuyFulTransportFromQCH(Action <string, eOutputType> output)
        {
            int res = 0;
            List <CmcsBuyFuelTransport> list = DcDbers.GetInstance().TruckWeight_Dber.Entities <CmcsBuyFuelTransport>("where IsSynch=0 order by CreateDate desc");

            foreach (CmcsBuyFuelTransport transport in list)
            {
                if (transport.InFactoryTime.Date < transport.GrossTime.Date)
                {
                    transport.InFactoryTime = transport.GrossTime;
                }
                // 生成批次以及采制化三级编码数据
                CmcsInFactoryBatch inFactoryBatch = CarTransportDAO.GetInstance().GCQCInFactoryBatchByBuyFuelTransport(transport);

                CmcsBuyFuelTransport old = commonDAO.SelfDber.Get <CmcsBuyFuelTransport>(transport.Id);
                if (old == null)
                {
                    res += commonDAO.SelfDber.Insert(transport);
                }
                else
                {
                    transport.SamplePlace  = old.SamplePlace;
                    transport.SamplingId   = old.SamplingId;
                    transport.SamplingTime = old.SamplingTime;
                    transport.SamplingType = old.SamplingType;
                    transport.UnLoadArea   = old.UnLoadArea;
                    transport.UploadTime   = old.UploadTime;
                    transport.IsSynch      = 1;
                    res += commonDAO.SelfDber.Update(transport);
                }
                transport.IsSynch = 1;
                DcDbers.GetInstance().TruckWeight_Dber.Update(transport);
            }

            output(string.Format("同步汽车衡运输记录 {0} 条", res), eOutputType.Normal);
        }
コード例 #23
0
        /// <summary>
        /// 同步采样命令
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode">设备编码</param>
        public void SyncSampleCmd(Action <string, eOutputType> output)
        {
            int res = 0;

            // 集中管控 > 第三方
            foreach (InfQCJXCYSampleCMD entity in CarSamplerDAO.GetInstance().GetWaitForSyncSampleCMD(this.MachineCode))
            {
                bool isSuccess = false;

                List <Interface_Data> list = DcDbers.GetInstance().CarJXSampler_Dber.Entities <Interface_Data>("where Sampler_No=:Sampler_No", new { Sampler_No = this.MachineCode == GlobalVars.MachineCode_QCJXCYJ_1 ? "CY01" : "CY02" });
                if (list.Count > 0)
                {
                    foreach (var item in list)
                    {
                        DcDbers.GetInstance().CarJXSampler_Dber.Delete <Interface_Data>(item.Interface_Id);
                    }
                }

                Interface_Data samplecmdEqu = DcDbers.GetInstance().CarJXSampler_Dber.Get <Interface_Data>(entity.Id);
                if (samplecmdEqu == null)
                {
                    isSuccess = DcDbers.GetInstance().CarJXSampler_Dber.Insert(new Interface_Data
                    {
                        // 保持相同的Id
                        Interface_Id   = entity.Id,
                        Sampler_No     = this.MachineCode == GlobalVars.MachineCode_QCJXCYJ_1 ? "CY01" : "CY02",
                        Weighing_Id    = entity.SerialNumber,
                        Car_Mark       = entity.CarNumber,
                        Mine_Name      = entity.SampleCode,
                        Point_Count    = entity.PointCount,
                        Car_Length     = entity.CarriageLength,
                        Car_Width      = entity.CarriageWidth,
                        Car_Height     = entity.CarriageHeight,
                        Chassis_Height = entity.CarriageBottomToFloor,
                        Tie_Rod_Place1 = entity.Obstacle1,
                        Tie_Rod_Place2 = entity.Obstacle2,
                        Tie_Rod_Place3 = entity.Obstacle3,
                        Tie_Rod_Place4 = entity.Obstacle4,
                        Tie_Rod_Place5 = entity.Obstacle5,
                        Tie_Rod_Place6 = entity.Obstacle6,
                        Sample_Time    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        Data_Status    = 1
                    }) > 0;
                }
                else
                {
                    samplecmdEqu.Car_Mark       = entity.CarNumber;
                    samplecmdEqu.Weighing_Id    = entity.SerialNumber;
                    samplecmdEqu.Mine_Name      = entity.SampleCode;
                    samplecmdEqu.Point_Count    = entity.PointCount;
                    samplecmdEqu.Car_Length     = entity.CarriageLength;
                    samplecmdEqu.Car_Width      = entity.CarriageWidth;
                    samplecmdEqu.Car_Height     = entity.CarriageHeight;
                    samplecmdEqu.Chassis_Height = entity.CarriageBottomToFloor;
                    samplecmdEqu.Tie_Rod_Place1 = entity.Obstacle1;
                    samplecmdEqu.Tie_Rod_Place2 = entity.Obstacle2;
                    samplecmdEqu.Tie_Rod_Place3 = entity.Obstacle3;
                    samplecmdEqu.Tie_Rod_Place4 = entity.Obstacle4;
                    samplecmdEqu.Tie_Rod_Place5 = entity.Obstacle5;
                    samplecmdEqu.Tie_Rod_Place6 = entity.Obstacle6;
                    samplecmdEqu.Sample_Time    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    samplecmdEqu.Data_Status    = 1;
                    isSuccess = DcDbers.GetInstance().CarJXSampler_Dber.Update(samplecmdEqu) > 0;
                }

                if (isSuccess)
                {
                    commonDAO.SetSignalDataValue(this.MachineCode, eSignalDataName.采样编码.ToString(), entity.SampleCode);
                    entity.SyncFlag = 1;
                    Dbers.GetInstance().SelfDber.Update(entity);

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


            res = 0;
            // 第三方 > 集中管控
            foreach (InfQCJXCYSampleCMD item in commonDAO.SelfDber.Entities <InfQCJXCYSampleCMD>("where ResultCode='默认' and MachineCode=:MachineCode order by CreationTime ", new { MachineCode = this.MachineCode }))
            {
                Interface_Data entity = DcDbers.GetInstance().CarJXSampler_Dber.Entity <Interface_Data>("where Interface_Id=:Interface_Id", new { Interface_Id = item.Id });
                if (entity != null)
                {
                    if (entity.Data_Status == 2)
                    {
                        item.StartTime  = Convert.ToDateTime(entity.Sample_Time);
                        item.ResultCode = eEquInfCmdResultCode.成功.ToString();
                    }
                    else if (entity.Data_Status == 4)
                    {
                        item.ResultCode = "定位错误";
                    }
                    else if (entity.Data_Status == 5)
                    {
                        item.ResultCode = "系统故障";
                    }

                    if (Dbers.GetInstance().SelfDber.Update(item) > 0)
                    {
                        commonDAO.SetSignalDataValue(this.MachineCode, eSignalDataName.采样编码.ToString(), string.Empty);
                        res++;
                    }
                    output(string.Format("同步采样计划 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
                }
            }

            //foreach (Interface_Data entity in DcDbers.GetInstance().CarJXSampler_Dber.Entities<Interface_Data>("where Data_Status=2 order by Sample_Time desc"))
            //{
            //	InfQCJXCYSampleCMD samplecmdInf = Dbers.GetInstance().SelfDber.Get<InfQCJXCYSampleCMD>(entity.Interface_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.Sample_Time;
            //	//samplecmdInf.EndTime = entity.EndTime;
            //	//samplecmdInf.SampleUser = entity.SampleUser;
            //	samplecmdInf.ResultCode = eEquInfCmdResultCode.成功.ToString();

            //	if (Dbers.GetInstance().SelfDber.Update(samplecmdInf) > 0)
            //	{
            //		// 我方已读
            //		//entity.DataFlag = 3;
            //		//this.EquDber.Update(entity);
            //		res++;
            //	}
            //}
            //output(string.Format("同步采样计划 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
        }
コード例 #24
0
        /// <summary>
        /// 同步存样柜信息
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public int SyncCYGInfo(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (EquCYG item in DcDbers.GetInstance().AutoCupboard_Dber.Entities <EquCYG>())
            {
                string pkid         = item.YGId.ToString();
                string CupBoardType = item.YGLX;
                if (item.YGLX == "432")
                {
                    CupBoardType = "制样室样柜";
                }
                else if (item.YGLX == "433")
                {
                    CupBoardType = "化验室样柜";
                }
                else if (item.YGLX == "646")
                {
                    CupBoardType = "原煤样样柜";
                }

                int State = 0;
                if (item.ZT == 435)
                {
                    State = 1;
                }
                else if (item.ZT == 436)
                {
                    State = 0;
                }

                int row = 0, cell = 0;
                if (item.YGBM.Length == 9)
                {
                    string ms     = item.WZMS.Replace("层", "").Replace("格", "");
                    int    number = int.Parse(ms.Remove(0, 2));
                    if (CupBoardType == "原煤样样柜")
                    {
                        row  = number % 4;
                        cell = number / 4 + 1;
                        if (row == 0)
                        {
                            row  = 4;
                            cell = number / 4;
                        }
                    }
                    else
                    {
                        row  = number % 10;
                        cell = number / 10 + 1;
                        if (row == 0)
                        {
                            row  = 10;
                            cell = number / 10;
                        }
                    }
                }
                InfAutoCupBoard entity = commonDAO.SelfDber.Entity <InfAutoCupBoard>(" where PKID=:PKID", new { PKID = pkid });
                EquCYGDetail    detail = DcDbers.GetInstance().AutoCupboard_Dber.Entity <EquCYGDetail>("where YGID=@YGID and ZT=438 order by CYSJ desc", new { YGID = item.YGId });
                if (entity == null)
                {
                    entity = new InfAutoCupBoard();
                    entity.CupBoardCode = item.YGBM;
                    entity.CupBoardType = CupBoardType;
                    entity.CupBoardDes  = item.WZMS;
                    entity.State        = State;
                    entity.IsValid      = item.Is_Valid;
                    entity.PKID         = pkid;
                    entity.ParentPKID   = item.Parent_YGID;
                    entity.RowNumber    = row;
                    entity.CellNumber   = cell;
                    entity.CupNumber    = item.Num_Url;
                    if (detail != null)
                    {
                        entity.SaveTime = detail.CYSJ;
                    }
                    res += commonDAO.SelfDber.Insert(entity);
                }
                else
                {
                    entity.CupBoardCode = item.YGBM;
                    entity.CupBoardType = CupBoardType;
                    entity.CupBoardDes  = item.WZMS;
                    entity.State        = State;
                    entity.IsValid      = item.Is_Valid;
                    entity.RowNumber    = row;
                    entity.CellNumber   = cell;
                    entity.CupNumber    = item.Num_Url;
                    entity.ParentPKID   = item.Parent_YGID;
                    if (detail != null)
                    {
                        entity.SaveTime = detail.CYSJ;
                    }
                    res += commonDAO.SelfDber.Update(entity);
                }
            }
            output(string.Format("同步存样柜数据 {0} 条", res), eOutputType.Normal);

            return(res);
        }
コード例 #25
0
        /// <summary>
        /// 同步翻车衡过衡数据
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public int SyncLwCarsInfo(Action <string, eOutputType> output)
        {
            int res = 0;

            IList <CarInfoMutual> carInfos = DcDbers.GetInstance().TurnCarWeighterMutualDber.Entities <CarInfoMutual>(" where DataFlag=1 and SuttleWeight>0 and CreateDate>=to_date('" + DateTime.Now.Date.AddDays(-2) + "','yyyy/mm/dd HH24:MI:SS')");

            foreach (var item in carInfos)
            {
                //同步到批次明细
                CmcsTransport transport = Dbers.GetInstance().SelfDber.Entity <CmcsTransport>(" where TransportNo=:TransportNo and InfactoryTime>=:InfactoryTime ", new { TransportNo = item.CarNumber, InfactoryTime = DateTime.Now.Date.AddDays(-2) });
                if (transport != null && !string.IsNullOrEmpty(transport.InFactoryBatchId))
                {
                    if (item.GrossWeight != 0 && transport.GrossQty == 0)
                    {
                        transport.GrossQty = (decimal)item.GrossWeight;
                    }

                    if (item.TareWeight != 0 && transport.SkinQty == 0)
                    {
                        transport.SkinQty = (decimal)item.TareWeight;
                    }

                    if (item.SuttleWeight != 0 && transport.SuttleQty == 0)
                    {
                        transport.SuttleQty = (decimal)item.SuttleWeight;
                        transport.MarginQty = (decimal)(item.SuttleWeight - item.TicketWeight);
                    }
                    transport.MeasureMan = "自动";
                    transport.IsDeleted  = item.CancelSign;
                    transport.ArriveDate = item.WeightDate;
                    transport.TareDate   = item.WeightDate.AddMinutes(3).AddSeconds(1.2);
                    transport.TrackCode  = item.TurnCarNumber == "#1" ? "#4" : "#2";
                    if (item.TurnCarNumber == "#1")
                    {
                        CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_1, eSignalDataName.当前车号.ToString(), string.Empty);
                    }
                    else
                    {
                        CommonDAO.GetInstance().SetSignalDataValue(GlobalVars.MachineCode_TrunOver_2, eSignalDataName.当前车号.ToString(), string.Empty);
                    }

                    res += Dbers.GetInstance().SelfDber.Update(transport);

                    //同步到轨道衡数据表
                    CmcsTrainWeightRecord trainRecord = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>("where TrainNumber=:TrainNumber and ArriveTime>=:ArriveTime", new { TrainNumber = item.CarNumber, ArriveTime = DateTime.Now.Date.AddDays(-2) });
                    CmcsRCSampling        sampling    = Dbers.GetInstance().SelfDber.Entity <CmcsRCSampling>("where InFactoryBatchId=:InFactoryBatchId order by SamplingDate", new { InFactoryBatchId = transport.InFactoryBatchId });
                    if (trainRecord != null)
                    {
                        trainRecord.TrainTipperMachineCode = item.TurnCarNumber;
                        trainRecord.FuelKind     = transport.TheBatch.FuelKindName;
                        trainRecord.MineName     = sampling != null ? sampling.SampleCode : "";
                        trainRecord.SupplierName = "";
                        trainRecord.StationName  = transport.TheBatch.TheStation.Name;

                        trainRecord.SerialNumber           = item.RecordId;
                        trainRecord.TicketWeight           = (decimal)item.TicketWeight;
                        trainRecord.GrossTime              = item.WeightDate;
                        trainRecord.GrossWeight            = (decimal)item.GrossWeight;
                        trainRecord.SkinTime               = item.WeightDate.AddMinutes(3).AddSeconds(1.2);
                        trainRecord.SkinWeight             = (decimal)item.TareWeight;
                        trainRecord.StandardWeight         = (decimal)item.SuttleWeight;
                        trainRecord.MarginWeight           = trainRecord.StandardWeight - trainRecord.TicketWeight - trainRecord.DeductWeight;
                        trainRecord.MesureMan              = "自动";
                        trainRecord.TrainTipperMachineCode = item.TurnCarNumber;
                        trainRecord.MachineCode            = item.TurnCarNumber == "#1" ? "#4" : "#2";
                        trainRecord.IsTurnover             = "已翻";
                        trainRecord.UnloadTime             = item.WeightDate;

                        Dbers.GetInstance().SelfDber.Update(trainRecord);
                    }
                }

                item.DataFlag = 2;
                DcDbers.GetInstance().TurnCarWeighterMutualDber.Update(item);
            }
            output(string.Format("同步翻车衡数据 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
            return(res);
        }
コード例 #26
0
        /// <summary>
        /// 同步轨道衡过衡数据,并在火车出厂后将皮重回写
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public int SyncLwCarsInfo(Action <string, eOutputType> output)
        {
            int       res    = 0;
            DataTable result = getData(DcDbers.GetInstance().WeightBridger_Dber1);

            foreach (DataRow row in result.Rows)
            {
                string pKId = getDateTime(row["时间"].ToString()) + "-" + row["车号"].ToString(); //时间+车号组装成唯一标识
                CmcsTrainWeightRecord trainWeightRecord = Dbers.GetInstance().SelfDber.Entity <CmcsTrainWeightRecord>("where PKID=:PKID", new { PKID = pKId });
                if (trainWeightRecord == null)
                {
                    res += Dbers.GetInstance().SelfDber.Insert <CmcsTrainWeightRecord>(
                        new CmcsTrainWeightRecord
                    {
                        PKID                   = pKId,
                        OrderNumber            = Convert.ToInt32(row["序号"].ToString()),
                        SupplierName           = row["供煤单位"].ToString(),
                        MineName               = row["矿点"].ToString(),
                        FuelKind               = row["煤种"].ToString(),
                        StationName            = row["发站"].ToString(),
                        MachineCode            = row["设备编号"].ToString(),
                        TrainNumber            = row["车号"].ToString(),
                        TrainType              = row["车型"].ToString(),
                        TicketWeight           = Convert.ToDecimal(row["票重"]),
                        GrossWeight            = Convert.ToDecimal(row["毛重"]),
                        SkinWeight             = Convert.ToDecimal(row["皮重"]),
                        StandardWeight         = Convert.ToDecimal(row["净重"]),
                        Speed                  = Convert.ToDecimal(row["车速"]),
                        MesureMan              = row["过衡人"].ToString(),
                        ArriveTime             = Convert.ToDateTime(getDateTime(row["入厂时间"].ToString())),
                        GrossTime              = Convert.ToDateTime(getDateTime(row["毛重时间"].ToString())),
                        SkinTime               = Convert.ToDateTime(getDateTime(row["皮重时间"].ToString())),
                        LeaveTime              = Convert.ToDateTime(getDateTime(row["出厂时间"].ToString())),
                        UnloadTime             = Convert.ToDateTime(getDateTime(row["卸车时间"].ToString())),
                        TrainTipperMachineCode = row["翻车机编号"].ToString(),
                        IsTurnover             = row["翻车标识"].ToString(),
                        DataFlag               = 0
                    }
                        );
                }
                else
                {
                    trainWeightRecord.OrderNumber = Convert.ToInt32(row["序号"].ToString());
                    if (!String.IsNullOrEmpty(row["车号"].ToString()))
                    {
                        trainWeightRecord.TrainNumber = row["车号"].ToString();
                    }

                    trainWeightRecord.SupplierName           = row["供煤单位"].ToString();
                    trainWeightRecord.MineName               = row["矿点"].ToString();
                    trainWeightRecord.FuelKind               = row["煤种"].ToString();
                    trainWeightRecord.StationName            = row["发站"].ToString();
                    trainWeightRecord.MachineCode            = row["设备编号"].ToString();
                    trainWeightRecord.TrainType              = row["车型"].ToString();
                    trainWeightRecord.TicketWeight           = Convert.ToDecimal(row["票重"]);
                    trainWeightRecord.GrossWeight            = Convert.ToDecimal(row["毛重"]);
                    trainWeightRecord.SkinWeight             = Convert.ToDecimal(row["皮重"]);
                    trainWeightRecord.StandardWeight         = Convert.ToDecimal(row["净重"]);
                    trainWeightRecord.Speed                  = Convert.ToDecimal(row["车速"]);
                    trainWeightRecord.MesureMan              = row["过衡人"].ToString();
                    trainWeightRecord.ArriveTime             = Convert.ToDateTime(getDateTime(row["入厂时间"].ToString()));
                    trainWeightRecord.GrossTime              = Convert.ToDateTime(getDateTime(row["毛重时间"].ToString()));
                    trainWeightRecord.SkinTime               = Convert.ToDateTime(getDateTime(row["皮重时间"].ToString()));
                    trainWeightRecord.LeaveTime              = Convert.ToDateTime(getDateTime(row["出厂时间"].ToString()));
                    trainWeightRecord.UnloadTime             = Convert.ToDateTime(getDateTime(row["卸车时间"].ToString()));
                    trainWeightRecord.TrainTipperMachineCode = row["翻车机编号"].ToString();
                    trainWeightRecord.IsTurnover             = row["翻车标识"].ToString();
                    trainWeightRecord.DataFlag               = 0;
                    res += Dbers.GetInstance().SelfDber.Update <CmcsTrainWeightRecord>(trainWeightRecord);
                }
                if (res > 0 && String.IsNullOrEmpty(row["车号"].ToString()))
                {
                    CommonDAO.GetInstance().SaveSysMessage(eMessageType.轨道衡.ToString(), "车号为空请补录!", eMessageType.轨道衡.ToString());
                }
            }
            output(string.Format("同步轨道衡数据 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal);
            return(res);
        }
コード例 #27
0
        ///// <summary>
        ///// 同步故障信息到集中管控
        ///// </summary>
        ///// <param name="output"></param>
        ///// <returns></returns>
        //public void SyncQCJXCYJError(Action<string, eOutputType> output)
        //{
        //	int res = 0;

        //	foreach (EquHCQSCYJError entity in this.EquDber.Entities<EquHCQSCYJError>("where DataFlag=0"))
        //	{
        //		if (commonDAO.SaveEquInfHitch(this.MachineCode, entity.ErrorTime, "故障代码 " + entity.ErrorCode + "," + entity.ErrorDescribe))
        //		{
        //			entity.DataFlag = 1;
        //			this.EquDber.Update(entity);

        //			res++;
        //		}
        //	}

        //	output(string.Format("同步故障信息记录 {0} 条", res), eOutputType.Normal);
        //}

        /// <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;
                // 需调整:命令中的水分等信息视接口而定
                KY_CYJ_P_OUTRUN samplecmdEqu = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_OUTRUN>("where CY_Code=@CY_Code and CYJ_Machine=@CYJ_Machine", new { CYJ_Machine = MachineCodeToKY(this.MachineCode), CY_Code = entity.SampleCode });
                if (samplecmdEqu == null)
                {
                    //	isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(new KY_CYJ_P_OUTRUN
                    //	{
                    //		CYJ_Machine = MachineCodeToKY(this.MachineCode),
                    //		CY_Code = entity.SampleCode,
                    //		Send_Time = DateTime.Now,
                    //		CY_Flag = 0,
                    //		Stop_Flag = 0,
                    //		TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2",
                    //		Car_Count= commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode)

                    //}) > 0;


                    KY_CYJ_P_OUTRUN outrun = new KY_CYJ_P_OUTRUN();
                    outrun.CYJ_Machine = MachineCodeToKY(this.MachineCode);
                    outrun.CY_Code     = entity.SampleCode;
                    outrun.Send_Time   = DateTime.Now;
                    outrun.CY_Flag     = 0;
                    outrun.Stop_Flag   = 0;
                    outrun.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                    outrun.Car_Count   = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
                    isSuccess          = DcDbers.GetInstance().BeltSampler_Dber.Insert(outrun) > 0;
                    commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", outrun.Car_Count.ToString());

                    KY_CYJ_P_TurnOver turn = DcDbers.GetInstance().BeltSampler_Dber.Entity <KY_CYJ_P_TurnOver>("where CY_Code=@CY_Code", new { CY_Code = entity.SampleCode });
                    if (turn == null)
                    {
                        turn             = new KY_CYJ_P_TurnOver();
                        turn.Send_Time   = DateTime.Now;
                        turn.CY_Code     = entity.SampleCode;
                        turn.DataFlag    = 0;
                        turn.Car_Count   = commonDAO.GetCarCountBySampleCode(entity.SampleCode);
                        turn.Ready_Count = commonDAO.GetRealyCarCountBySampleCode(entity.SampleCode);
                        turn.IsDone      = 0;
                        turn.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                        DcDbers.GetInstance().BeltSampler_Dber.Insert(turn);
                        commonDAO.SetSignalDataValue(this.MachineCode, turn.TurnCode == "#1" ? "#1翻车机车数" : "#2翻车机车数", turn.Car_Count.ToString());
                    }
                }
                else
                {
                    samplecmdEqu.CYJ_Machine = MachineCodeToKY(this.MachineCode);
                    samplecmdEqu.CY_Code     = entity.SampleCode;
                    samplecmdEqu.Send_Time   = DateTime.Now;
                    samplecmdEqu.CY_Flag     = 0;
                    samplecmdEqu.Stop_Flag   = 0;
                    samplecmdEqu.TurnCode    = this.MachineCode.Contains("A") ? "#1" : "#2";
                    samplecmdEqu.Car_Count   = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
                    isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Update(samplecmdEqu) > 0;
                    commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", samplecmdEqu.Car_Count.ToString());
                }

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

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

            //// 集中管控 > 第三方
            //foreach (InfBeltSamplePlan entity in BeltSamplerDAO.GetInstance().GetWaitForSyncBeltSamplePlan(this.MachineCode))
            //{
            //	bool isSuccess = false;
            //	// 需调整:命令中的水分等信息视接口而定
            //	KY_CYJ_P_OUTRUN samplecmdEqu = DcDbers.GetInstance().BeltSampler_Dber.Entity<KY_CYJ_P_OUTRUN>("where CY_Code=@CY_Code and CYJ_Machine=@CYJ_Machine", new { CYJ_Machine = MachineCodeToKY(this.MachineCode), CY_Code = entity.SampleCode });
            //	if (samplecmdEqu == null)
            //	{
            //	//	isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(new KY_CYJ_P_OUTRUN
            //	//	{
            //	//		CYJ_Machine = MachineCodeToKY(this.MachineCode),
            //	//		CY_Code = entity.SampleCode,
            //	//		Send_Time = DateTime.Now,
            //	//		CY_Flag = 0,
            //	//		Stop_Flag = 0,
            //	//		TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2",
            //	//		Car_Count= commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode)

            //	//}) > 0;


            //		KY_CYJ_P_OUTRUN outrun = new KY_CYJ_P_OUTRUN();
            //		outrun.CYJ_Machine = MachineCodeToKY(this.MachineCode);
            //		outrun.CY_Code = entity.SampleCode;
            //		outrun.Send_Time = DateTime.Now;
            //		outrun.CY_Flag = 0;
            //		outrun.Stop_Flag = 0;
            //		outrun.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //		outrun.Car_Count = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
            //		isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Insert(outrun)>0;
            //		commonDAO.SetSignalDataValue(this.MachineCode,"轨道车数", outrun.Car_Count.ToString());

            //		KY_CYJ_P_TurnOver turn = DcDbers.GetInstance().BeltSampler_Dber.Entity<KY_CYJ_P_TurnOver>("where CY_Code=@CY_Code", new { CY_Code = entity.SampleCode });
            //		if (turn == null)
            //		{
            //			turn = new KY_CYJ_P_TurnOver();
            //			turn.Send_Time = DateTime.Now;
            //			turn.CY_Code = entity.SampleCode;
            //			turn.DataFlag = 0;
            //			turn.Car_Count = commonDAO.GetCarCountBySampleCode(entity.SampleCode);
            //			turn.Ready_Count = commonDAO.GetRealyCarCountBySampleCode(entity.SampleCode);
            //			turn.IsDone = 0;
            //			turn.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //			DcDbers.GetInstance().BeltSampler_Dber.Insert(turn);
            //			commonDAO.SetSignalDataValue(this.MachineCode, turn.TurnCode == "#1" ? "#1翻车机车数" : "#2翻车机车数", turn.Car_Count.ToString());
            //		}
            //	}
            //	else
            //	{
            //		samplecmdEqu.CYJ_Machine = MachineCodeToKY(this.MachineCode);
            //		samplecmdEqu.CY_Code = entity.SampleCode;
            //		samplecmdEqu.Send_Time = DateTime.Now;
            //		samplecmdEqu.CY_Flag = 0;
            //		samplecmdEqu.Stop_Flag = 0;
            //		samplecmdEqu.TurnCode = this.MachineCode.Contains("A") ? "#1" : "#2";
            //		samplecmdEqu.Car_Count = commonDAO.GetGDHCarCountBySampleCode(this.MachineCode.Contains("A") ? "#1" : "#2", entity.SampleCode);
            //		isSuccess = DcDbers.GetInstance().BeltSampler_Dber.Update(samplecmdEqu) > 0;
            //		commonDAO.SetSignalDataValue(this.MachineCode, "轨道车数", samplecmdEqu.Car_Count.ToString());
            //	}

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

            //		res++;
            //	}
            //}
            //output(string.Format("同步采样计划 {0} 条(集中管控 > 第三方)", res), eOutputType.Normal);
        }
コード例 #28
0
        /// <summary>
        /// 同步历史卸样结果
        /// </summary>
        /// <param name="output"></param>
        /// <param name="MachineCode"></param>
        public void SyncUnloadResult(Action <string, eOutputType> output)
        {
            int res = 0;

            res = 0;
            // 第三方 > 集中管控
            foreach (KY_CYJ_P_BARREL entity in DcDbers.GetInstance().BeltSampler_Dber.Entities <KY_CYJ_P_BARREL>("where DateDiff(dd,EditDate,getdate())<=7"))
            {
                // 查找采样命令
                CmcsRCSampling sampling = commonDAO.SelfDber.Entity <CmcsRCSampling>("where SampleCode=:SampleCode", new { SampleCode = entity.Barrel_Name });
                if (sampling != null)
                {
                    CmcsRCSampleBarrel cmcsRCSampleBarrel = commonDAO.SelfDber.Entity <CmcsRCSampleBarrel>("where BarrelNumber='" + entity.Barrel_Name + "' and to_char(BarrellingTime,'yyyy-mm-dd hh24:mi:ss')= '" + entity.EditDate.ToString("yyyy-MM-dd HH:mm:ss") + "' and SamplerName = '" + KYToMachineCode(entity.CYJ_Machine) + "'");
                    if (cmcsRCSampleBarrel == null)
                    {
                        // 生成采样桶记录
                        CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel()
                        {
                            SamplingId     = sampling.Id,
                            BarrellingTime = entity.EditDate,
                            BarrelNumber   = entity.Barrel_Name,
                            SamplerName    = KYToMachineCode(entity.CYJ_Machine),
                            SampleType     = eSamplingType.机械采样.ToString(),
                            //SampleCount = barrel.SampleCount,
                            SampleWeight = entity.Barrel_Weight,
                            BarrelCode   = entity.Barrel_Code
                        };
                        commonDAO.SelfDber.Insert(rCSampleBarrel);
                    }
                    else
                    {
                        cmcsRCSampleBarrel.SampleWeight = entity.Barrel_Weight;
                        commonDAO.SelfDber.Update(cmcsRCSampleBarrel);
                    }
                }


                InfBeltSamplerUnloadResult oldUnloadResult = commonDAO.SelfDber.Entity <InfBeltSamplerUnloadResult>("where samplecode='" + entity.Barrel_Name + "' and to_char(UnloadTime,'yyyy-mm-dd hh24:mi:ss')= '" + entity.EditDate.ToString("yyyy-MM-dd HH:mm:ss") + "'");
                if (oldUnloadResult == null)
                {
                    if (commonDAO.SelfDber.Insert(new InfBeltSamplerUnloadResult
                    {
                        MachineCode = KYToMachineCode(entity.CYJ_Machine),
                        SampleCode = entity.Barrel_Name,
                        BarrelCode = entity.Barrel_Code,
                        UnloadTime = entity.EditDate
                    }) > 0)
                    {
                        //entity.DataFlag = 1;
                        //this.EquDber.Update(entity);

                        res++;
                    }
                }
                else
                {
                    oldUnloadResult.MachineCode = KYToMachineCode(entity.CYJ_Machine);
                    oldUnloadResult.SampleCode  = entity.Barrel_Name;
                    oldUnloadResult.BarrelCode  = entity.Barrel_Code;
                    oldUnloadResult.UnloadTime  = entity.EditDate;

                    if (commonDAO.SelfDber.Update(oldUnloadResult) > 0)
                    {
                        //entity.DataFlag = 1;
                        //this.EquDber.Update(entity);

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