Exemplo n.º 1
0
        /// <summary>
        /// 同步卸样结果,根据卸样信息生成集控采样桶记录
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public void SyncUnloadResult(Action <string, eOutputType> output)
        {
            int res = 0;

            foreach (EquPDCYJUnloadResult pDCYJUnloadResult in this.EquDber.Entities <EquPDCYJUnloadResult>("where DataFlag=0"))
            {
                InfBeltSamplerUnloadResult oldUnloadResult = commonDAO.SelfDber.Get <InfBeltSamplerUnloadResult>(pDCYJUnloadResult.Id);
                if (oldUnloadResult == null)
                {
                    // 查找采样计划
                    EquPDCYJPlan pDCYJPlan = this.EquDber.Entity <EquPDCYJPlan>("where SampleCode=@SampleCode", new { SampleCode = pDCYJUnloadResult.SampleCode });
                    if (pDCYJPlan != null)
                    {
                        // 生成采样桶记录
                        CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel()
                        {
                            SampleCode       = pDCYJUnloadResult.SampleCode,
                            BarrelCode       = pDCYJUnloadResult.BarrelCode,
                            BarrellingTime   = pDCYJUnloadResult.UnloadTime,
                            InFactoryBatchId = pDCYJPlan.InFactoryBatchId,
                            SampleMachine    = commonDAO.GetMachineNameByCode(ConvertToCmcsMachineCode(pDCYJUnloadResult.MachineCode)),
                            SampleType       = eSamplingType.皮带采样.ToString(),
                            SamplingId       = pDCYJUnloadResult.SamplingId
                        };

                        if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0)
                        {
                            // 同步卸样结果
                            if (commonDAO.SelfDber.Insert(new InfBeltSamplerUnloadResult
                            {
                                MachineCode = ConvertToCmcsMachineCode(pDCYJUnloadResult.MachineCode),
                                SampleCode = pDCYJUnloadResult.SampleCode,
                                DataFlag = pDCYJUnloadResult.DataFlag,
                                BarrelCode = pDCYJUnloadResult.BarrelCode,
                                UnloadTime = pDCYJUnloadResult.UnloadTime,
                                SamplingId = pDCYJUnloadResult.SamplingId
                            }) > 0)
                            {
                                pDCYJUnloadResult.DataFlag = 1;
                                this.EquDber.Update(pDCYJUnloadResult);

                                res++;
                            }
                        }
                    }
                }
            }

            output(string.Format("同步卸样结果 {0} 条", res), eOutputType.Normal);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
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);
        }