/// <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 this.EquDber.Entities <EquQCJXCYJUnloadResult>("where DataFlag=0")) { InfQCJXCYJUnloadResult oldUnloadResult = commonDAO.SelfDber.Get <InfQCJXCYJUnloadResult>(entity.Id); if (oldUnloadResult == null) { // 查找采样命令 EquQCJXCYJSampleCmd qCJXCYJSampleCmd = this.EquDber.Entity <EquQCJXCYJSampleCmd>("where SampleCode=@SampleCode", new { SampleCode = entity.SampleCode }); if (qCJXCYJSampleCmd != null) { CmcsRCSampling sampling = commonDAO.SelfDber.Entity <CmcsRCSampling>("where SampleCode=:SampleCode", new { SampleCode = entity.SampleCode }); //生成采样桶记录 CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel() { BarrelCode = entity.BarrelCode, BarrellingTime = entity.UnloadTime, BarrelNumber = entity.BarrelCode, InFactoryBatchId = qCJXCYJSampleCmd.InFactoryBatchId, SamplerName = this.MachineCode, SampleType = eSamplingType.机械采样.ToString(), SamplingId = sampling != null ? sampling.Id : entity.SamplingId, SampleWeight = entity.SampleWeigh }; 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) { CmcsCYJCodeInfo codeInfo = commonDAO.SelfDber.Entity <CmcsCYJCodeInfo>("where SampleCode=:SampleCode and BarrelCode=:BarrelCode and SamplerName=:SamplerName and IsClear=0", new { SampleCode = entity.SampleCode, BarrelCode = entity.BarrelCode, SamplerName = this.MachineCode }); if (codeInfo != null) { codeInfo.ClearTime = entity.UnloadTime; codeInfo.IsClear = 1; commonDAO.SelfDber.Update(codeInfo); } entity.DataFlag = 1; this.EquDber.Update(entity); res++; } } } } } output(string.Format("{0}-同步卸样结果 {0} 条(第三方 > 集中管控)", this.MachineCode, res), eOutputType.Normal); }
/// <summary> /// 同步集样罐信息到集中管控 /// </summary> /// <param name="output"></param> /// <returns></returns> public void SyncBarrel(Action <string, eOutputType> output) { int res = 0; List <EquQCJXCYJBarrel> infpdcybarrels = this.EquDber.Entities <EquQCJXCYJBarrel>("where DataFlag=0"); foreach (EquQCJXCYJBarrel entity in infpdcybarrels) { if (commonDAO.SaveEquInfSampleBarrel(new InfEquInfSampleBarrel { BarrelNumber = entity.BarrelNumber, BarrelStatus = entity.BarrelStatus.ToString(), MachineCode = this.MachineCode, InFactoryBatchId = entity.InFactoryBatchId, InterfaceType = "西马智深汽车采样机接口", IsCurrent = entity.IsCurrent, SampleCode = entity.SampleCode, SampleCount = entity.SampleCount, UpdateTime = entity.UpdateTime, BarrelType = "密码罐", SampleWeight = entity.SampleWeigh })) { if (!string.IsNullOrEmpty(entity.BarrelNumber) && !string.IsNullOrEmpty(entity.SampleCode)) { //写入采样码记录 CmcsRCSampling sampling = commonDAO.SelfDber.Entity <CmcsRCSampling>("where SampleCode=:SampleCode", new { SampleCode = entity.SampleCode }); CmcsCYJCodeInfo codeInfo = commonDAO.SelfDber.Entity <CmcsCYJCodeInfo>("where SampleCode=:SampleCode and BarrelCode=:BarrelCode and SamplerName=:SamplerName and IsClear=0", new { SampleCode = entity.SampleCode, BarrelCode = entity.BarrelNumber, SamplerName = this.MachineCode }); int carCount = 0; if (sampling != null) { carCount = commonDAO.SelfDber.Count <CmcsBuyFuelTransport>("where SamplingId=:SamplingId and SamplePlace=:SamplePlace", new { SamplingId = sampling.Id, SamplePlace = this.MachineCode }); } if (codeInfo == null) { codeInfo = new CmcsCYJCodeInfo(); codeInfo.SampleCode = entity.SampleCode; codeInfo.BarrelCode = Convert.ToInt32(entity.BarrelNumber); codeInfo.SampleCount = entity.SampleCount; codeInfo.CarCount = entity.SampleCount; codeInfo.SampleWeight = entity.SampleWeigh; codeInfo.SamplerName = this.MachineCode; codeInfo.SamplingId = sampling != null ? sampling.Id : ""; codeInfo.StartTime = entity.UpdateTime; codeInfo.IsClear = 0; commonDAO.SelfDber.Insert(codeInfo); } else { codeInfo.SampleCount = entity.SampleCount; codeInfo.CarCount = entity.SampleCount; codeInfo.SampleWeight = entity.SampleWeigh; codeInfo.EndTime = DateTime.Now; commonDAO.SelfDber.Update(codeInfo); } } entity.DataFlag = 1; this.EquDber.Update(entity); res++; } } output(string.Format("{0}-同步集样罐记录 {1} 条", this.MachineCode, res), eOutputType.Normal); }