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

            foreach (KY_CYJ_BarrelStatus item in this.EquDber.Entities <KY_CYJ_BarrelStatus>(" where CYJ_Machine=@CYJ_Machine and DataFlag=0 order by Barrel_Code", new { CYJ_Machine = DataToKYMachine(this.MachineCode) }))
            {
                if (item.Barrel_Code != "9")
                {
                    InfEquInfSampleBarrel infSampleBarrel = new InfEquInfSampleBarrel();
                    infSampleBarrel.BarrelNumber  = item.Barrel_Code;
                    infSampleBarrel.BarrelStatus  = item.Down_Full == 0 ? "未满" : "已满";
                    infSampleBarrel.MachineCode   = this.MachineCode;
                    infSampleBarrel.InterfaceType = commonDAO.GetMachineInterfaceTypeByCode(this.MachineCode);
                    infSampleBarrel.SampleCode    = !string.IsNullOrEmpty(item.CY_Code) ? item.CY_Code.Trim() : "";
                    if (string.IsNullOrEmpty(item.CY_Code))
                    {
                        infSampleBarrel.BarrelStatus = "";
                    }
                    infSampleBarrel.InFactoryBatchId = !string.IsNullOrEmpty(item.CY_Code) ? commonDAO.GetBatchIdByRCSamplingCode(item.CY_Code) : "";
                    infSampleBarrel.SampleCount      = item.Down_Cont;
                    infSampleBarrel.UpdateTime       = item.EditDate;
                    infSampleBarrel.BarrelType       = "底卸式";
                    if (commonDAO.SaveEquInfSampleBarrel(infSampleBarrel))
                    {
                        item.DataFlag = 1;
                        this.EquDber.Update(item);
                        res++;
                    }
                }
                else
                {
                    //当前进料桶
                    InfEquInfSampleBarrel JLBarrel = commonDAO.SelfDber.Entity <InfEquInfSampleBarrel>("where MachineCode=:MachineCode and BarrelNumber=:BarrelNumber order by BarrelNumber", new { MachineCode = KYMachineToData(item.CYJ_Machine), BarrelNumber = item.JL_Code });
                    if (JLBarrel != null)
                    {
                        JLBarrel.IsCurrent = 1;
                        commonDAO.SelfDber.Update(JLBarrel);
                    }
                    //当前卸料桶
                }
            }

            output(string.Format("同步集样罐记录 {0} 条-{1}", res, this.MachineCode), eOutputType.Normal);
        }