/// <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> /// <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 sample = commonDAO.SelfDber.Entity <CmcsRCSampling>("where SamplingType='机械采样' and InFactoryBatchId=:InFactoryBatchId order by CreateDate desc", new { InFactoryBatchId = qCJXCYJSampleCmd.InFactoryBatchId }); // 生成采样桶记录 CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel() { BarrelCode = entity.BarrelCode, BarrellingTime = entity.UnloadTime, BarrelNumber = entity.BarrelNumber, InFactoryBatchId = qCJXCYJSampleCmd.InFactoryBatchId, SamplerName = this.MachineCode, SampleType = eSamplingType.机械采样.ToString(), SamplingId = sample != null ? sample.Id : "", SampSecondCode = entity.BarrelCode }; if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0) { if (commonDAO.SelfDber.Insert(new InfQCJXCYJUnloadResult { SampleCode = entity.SampleCode, BarrelCode = entity.BarrelCode, UnloadTime = entity.UnloadTime, SamplingId = sample != null ? sample.Id : "", DataFlag = entity.DataFlag }) > 0) { entity.DataFlag = 1; this.EquDber.Update(entity); res++; } } } } } output(string.Format("{0}同步卸样结果 {1} 条(第三方 > 集中管控)", this.MachineCode, 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 (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); }
/// <summary> /// 同步卸样操作结果 /// </summary> /// <param name="output"></param> public void SyncResult(Action <string, eOutputType> output) { int res = 0, res2 = 0; // 第三方 > 集中管控 卸样结果 foreach (InfQCJXCYUnLoadCMD item in Dbers.GetInstance().SelfDber.Entities <InfQCJXCYUnLoadCMD>("where MachineCode=:MachineCode and DataFlag=0", new { MachineCode = this.MachineCode })) { if (item.UnLoadType == "到制样机") { IList <KY_CYJ_BarrelStatus> barrelstatus = this.EquDber.Entities <KY_CYJ_BarrelStatus>("where CY_Code=@CY_Code order by Barrel_Code", new { CY_Code = item.SampleCode }); IList <KY_CYJ_Down> downlist = new List <KY_CYJ_Down>(); foreach (KY_CYJ_BarrelStatus barrel in barrelstatus) { KY_CYJ_Down down = this.EquDber.Entity <KY_CYJ_Down>("where Barrel_Code=@Barrel_Code and XL_Finish=1", new { Barrel_Code = barrel.Barrel_Code }); if (down != null) { downlist.Add(down); } } if (downlist.Count == barrelstatus.Count) { foreach (KY_CYJ_Down entity in downlist) { //历史卸样结果 InfQCJXCYJUnloadResult oldUnloadResult = commonDAO.SelfDber.Entity <InfQCJXCYJUnloadResult>("where SampleCode=:SampleCode and BarrelCode=:BarrelCode and UnLoadType=:UnLoadType and DataFlag=0", new { SampleCode = item.SampleCode, UnLoadType = item.UnLoadType, BarrelCode = entity.Barrel_Code }); if (oldUnloadResult == null) { // 生成采样桶记录 CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel(); rCSampleBarrel.BarrelCode = item.SampleCode; rCSampleBarrel.BarrellingTime = entity.LastDateTime; rCSampleBarrel.SampleCode = item.SampleCode; rCSampleBarrel.SampleMachine = this.MachineCode.Contains("#1") ? "#1汽车机械采样机" : "#2汽车机械采样机"; rCSampleBarrel.SampleType = eSamplingType.机械采样.ToString(); rCSampleBarrel.SampSecondCode = commonDAO.CreateSampleDetailCode(rCSampleBarrel.SampleCode); rCSampleBarrel.SamplingId = commonDAO.GetSamplingIdBySamplingCode(item.SampleCode); rCSampleBarrel.InFactoryBatchId = commonDAO.GetBatchIdByRCSamplingId(rCSampleBarrel.SamplingId); if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0) { if (commonDAO.SelfDber.Insert(new InfQCJXCYJUnloadResult { SampleCode = item.SampleCode, BarrelCode = entity.Barrel_Code, UnloadTime = entity.LastDateTime, UnLoadType = item.UnLoadType, DataFlag = 0 }) > 0) { res++; } } } } item.ResultCode = eEquInfCmdResultCode.成功.ToString(); item.DataFlag = 1; if (Dbers.GetInstance().SelfDber.Update(item) > 0) { // 我方已读 this.EquDber.Execute(string.Format("update {0} set XL_Start = 0,XL_Finish = 0,Read_Flag = 0 where XL_Finish=1", CMCS.DapperDber.Util.EntityReflectionUtil.GetTableName <KY_CYJ_Down>())); res2++; } } } else if (item.UnLoadType == "到归批机") { KY_CYJ_Down down = this.EquDber.Entity <KY_CYJ_Down>("where Barrel_Code=@Barrel_Code and XL_Finish=1", new { Barrel_Code = item.BarrelNumber }); if (down != null) { //历史卸样结果 InfQCJXCYJUnloadResult oldUnloadResult = commonDAO.SelfDber.Entity <InfQCJXCYJUnloadResult>("where SampleCode=:SampleCode and BarrelCode=:BarrelCode and UnLoadType=:UnLoadType and DataFlag=0", new { SampleCode = item.SampleCode, UnLoadType = item.UnLoadType, BarrelCode = item.BarrelNumber }); if (oldUnloadResult == null) { // 生成采样桶记录 CmcsRCSampleBarrel rCSampleBarrel = new CmcsRCSampleBarrel(); rCSampleBarrel.BarrelCode = item.SampleCode; rCSampleBarrel.SampSecondCode = commonDAO.CreateSampleDetailCode(item.SampleCode);; rCSampleBarrel.BarrellingTime = down.LastDateTime; rCSampleBarrel.SampleCode = item.SampleCode; rCSampleBarrel.SampSecondCode = commonDAO.CreateSampleDetailCode(rCSampleBarrel.SampleCode); rCSampleBarrel.SampleMachine = this.MachineCode.Contains("#1") ? "#1汽车机械采样机" : "#2汽车机械采样机"; rCSampleBarrel.SampleType = eSamplingType.机械采样.ToString(); rCSampleBarrel.SamplingId = commonDAO.GetSamplingIdBySamplingCode(item.SampleCode); rCSampleBarrel.InFactoryBatchId = commonDAO.GetBatchIdByRCSamplingId(rCSampleBarrel.SamplingId); if (commonDAO.SelfDber.Insert(rCSampleBarrel) > 0) { InfQCJXCYJUnloadResult unload = new InfQCJXCYJUnloadResult { SampleCode = item.SampleCode, BarrelCode = down.Barrel_Code, UnloadTime = down.LastDateTime, DataFlag = 0 }; if (commonDAO.SelfDber.Insert(unload) > 0) { res++; } } } item.ResultCode = eEquInfCmdResultCode.成功.ToString(); item.DataFlag = 1; if (Dbers.GetInstance().SelfDber.Update(item) > 0) { // 我方已读 this.EquDber.Execute(string.Format("update {0} set XL_Start = 0,XL_Finish = 0,Read_Flag = 0 where XL_Finish=1 and Barrel_Code='{1}'", CMCS.DapperDber.Util.EntityReflectionUtil.GetTableName <KY_CYJ_Down>(), item.BarrelNumber)); res2++; } } } } output(string.Format("同步历史卸样结果 {0} 条(第三方 > 集中管控)", res), eOutputType.Normal); output(string.Format("同步卸样结果 {0} 条(第三方 > 集中管控)", res2), eOutputType.Normal); }