public bool CreateAssay(CmcsRCMake rCMake) { // 入厂煤化验 CmcsRCAssay rCAssay = CommonDAO.GetInstance().SelfDber.Entity <CmcsRCAssay>("where MakeId=:MakeId and AssayWay='监督样化验'", new { MakeId = rCMake.Id }); if (rCAssay == null) { // 入厂煤煤质 CmcsFuelQuality fuelQuality = new CmcsFuelQuality() { Id = Guid.NewGuid().ToString(), Mt = Convert.ToDecimal(dbiMt.Value) }; if (CommonDAO.GetInstance().SelfDber.Insert(fuelQuality) > 0) { rCAssay = new CmcsRCAssay() { MakeId = rCMake.Id, AssayType = eAssayType.级编码化验.ToString(), AssayWay = eAssayType.监督样化验.ToString(), AssayCode = CommonDAO.GetInstance().CreateNewAssayCode(rCMake.CreateDate), FuelQualityId = fuelQuality.Id, AssayPle = "", WfStatus = 0, BackBatchDate = rCMake.UseTime, AssayPoint = this.assayTarget.TrimEnd(',') }; return(CommonDAO.GetInstance().SelfDber.Insert(rCAssay) > 0); } } else { rCAssay.AssayPoint = this.assayTarget.TrimEnd(','); CmcsFuelQuality fuelQuality = rCAssay.TheFuelQuality; if (fuelQuality != null) { fuelQuality.Mt = Convert.ToDecimal(dbiMt.Value); CommonDAO.GetInstance().SelfDber.Update(fuelQuality); } return(CommonDAO.GetInstance().SelfDber.Update(rCAssay) > 0); } return(false); }
/// <summary> /// 创建采制化三级数据 /// </summary> /// <param name="inFactoryBatch">批次</param> /// <param name="samplingType">采样方式</param> /// <param name="remark">备注</param> /// <param name="assayType">化验方式</param> /// <returns></returns> public CmcsRCSampling GCSamplingMakeAssay(CmcsInFactoryBatch inFactoryBatch, string samplingType, string remark) { bool isSuccess = false; // 入厂煤采样 CmcsRCSampling rCSampling = SelfDber.Entity <CmcsRCSampling>("where InFactoryBatchId=:InFactoryBatchId and SamplingType=:SamplingType and IsDeleted=0", new { InFactoryBatchId = inFactoryBatch.Id, SamplingType = samplingType }); if (rCSampling == null) { rCSampling = new CmcsRCSampling() { InFactoryBatchId = inFactoryBatch.Id, SamplingType = samplingType, SamplingDate = DateTime.Now, SamplingPle = "自动", SampleCode = CreateNewSampleCode(inFactoryBatch.FactArriveDate), Remark = remark }; isSuccess = SelfDber.Insert(rCSampling) > 0; } // 入厂煤制样 CmcsRCMake rCMake = SelfDber.Entity <CmcsRCMake>("where SamplingId=:SamplingId and IsDeleted=0", new { SamplingId = rCSampling.Id }); if (rCMake == null) { rCMake = new CmcsRCMake() { SamplingId = rCSampling.Id, MakeType = "机器制样", MakeDate = rCSampling.CreateDate, MakeCode = CreateNewMakeCode(rCSampling.CreateDate), MakePle = "自动", Remark = remark }; isSuccess = SelfDber.Insert(rCMake) > 0; } // 入厂煤化验 CmcsRCAssay rCAssay = SelfDber.Entity <CmcsRCAssay>("where MakeId=:MakeId and IsDeleted=0", new { MakeId = rCMake.Id }); if (rCAssay == null) { // 入厂煤煤质 CmcsFuelQuality fuelQuality = new CmcsFuelQuality() { Id = Guid.NewGuid().ToString() }; if (SelfDber.Insert(fuelQuality) > 0) { rCAssay = new CmcsRCAssay() { MakeId = rCMake.Id, AssayCode = CreateNewAssayCode(rCMake.CreateDate), InFactoryBatchId = inFactoryBatch.Id, FuelQualityId = fuelQuality.Id, AssayDate = rCMake.CreateDate, Remark = remark, IsAssay = 0 }; isSuccess = SelfDber.Insert(rCAssay) > 0; } } return(rCSampling); }
/// <summary> /// 生成制样及化验 /// </summary> /// <param name="makeCode"></param> /// <param name="assayType"></param> /// <param name="user"></param> /// <param name="assayTarget"></param> /// <returns></returns> public bool CreateMakeAndAssay(ref string makeCode, string assayType, string user, string assayTarget) { bool isSuccess = false; CmcsRCMake make = Dbers.GetInstance().SelfDber.Entity <CmcsRCMake>("where MakeCode=:MakeCode order by CreateDate desc ", new { MakeCode = makeCode }); if (make != null) { CmcsRCSampling rCSampling = Dbers.GetInstance().SelfDber.Get <CmcsRCSampling>(make.SamplingId); if (rCSampling != null) { // 入厂煤制样 CmcsRCMake rCMake = new CmcsRCMake() { SamplingId = rCSampling.Id, MakeStyle = eMakeType.机器制样.ToString(), MakeType = assayType, MakeStartTime = DateTime.Now, MakeEndTime = DateTime.Now, MakeCode = CommonDAO.GetInstance().CreateNewMakeCode(DateTime.Now), MakePle = user, ParentMakeId = make.Id }; isSuccess = Dbers.GetInstance().SelfDber.Insert(rCMake) > 0; makeCode = rCMake.MakeCode; //入厂煤制样明细 foreach (CodeContent item in CommonDAO.GetInstance().GetCodeContentByKind("制样类型")) { CmcsRCMakeDetail rCMakeDetail = Dbers.GetInstance().SelfDber.Entity <CmcsRCMakeDetail>("where MakeId=:MakeId and SampleType=:SampleType", new { MakeId = rCMake.Id, SampleType = item.Content }); if (rCMakeDetail == null) { rCMakeDetail = new CmcsRCMakeDetail(); rCMakeDetail.MakeId = rCMake.Id; rCMakeDetail.BarrelCode = CommonDAO.GetInstance().CreateNewMakeBarrelCodeByMakeCode(rCMake.MakeCode, item.Content); rCMakeDetail.SampleType = item.Content; isSuccess = Dbers.GetInstance().SelfDber.Insert(rCMakeDetail) > 0; } } // 入厂煤化验 CmcsRCAssay rCAssay = Dbers.GetInstance().SelfDber.Entity <CmcsRCAssay>("where MakeId=:MakeId", new { MakeId = rCMake.Id }); if (rCAssay == null) { // 入厂煤煤质 CmcsFuelQuality fuelQuality = new CmcsFuelQuality() { Id = Guid.NewGuid().ToString() }; if (Dbers.GetInstance().SelfDber.Insert(fuelQuality) > 0) { rCAssay = new CmcsRCAssay() { MakeId = rCMake.Id, AssayType = assayType, AssayWay = assayType, AssayCode = CommonDAO.GetInstance().CreateNewAssayCode(rCMake.CreateDate), InFactoryBatchId = rCSampling.InFactoryBatchId, FuelQualityId = fuelQuality.Id, AssayDate = rCMake.CreateDate, WfStatus = 0, AssayPoint = assayTarget }; isSuccess = Dbers.GetInstance().SelfDber.Insert(rCAssay) > 0; } } } } return(isSuccess); }
/// <summary> /// 生成抽查样 /// </summary> /// <param name="assay">原化验记录</param> /// <param name="UserName">操作人</param> /// <param name="assayPoint">化验指标</param> /// <param name="PreFix">化验类型</param> /// <returns></returns> public bool CreateSpotAssay(CmcsRCAssay entity, string userName, string userAccount, string assayPoint, string PreFix, ref CmcsRCAssay assay) { try { assay = new CmcsRCAssay(); assay.AssayPoint = assayPoint; assay.AssayType = "三级编码化验"; assay.SendDate = GlobalVars.ServerNowDateTime; //assay.AssayDate = GlobalVars.ServerNowDateTime; CmcsRCMake make = entity.TheRcMake; if (make.TheRcSampling != null && make.TheRcSampling.TheInFactoryBatch != null) { assay.InFactoryBatchId = make.TheRcSampling.TheInFactoryBatch.Id; } assay.MakeId = make.Id; assay.IsRelieve = 1; assay.AssayPle = userName; assay.AssayCode = CommonDAO.GetInstance().CreateNewAssayCode(DateTime.Now); assay.AssayWay = PreFix; assay.Remark = "由化验室接样程序手动生成"; assay.ParentId = entity.Id; assay.BackBatchDate = entity.BackBatchDate; CmcsFuelQuality quality_new = new CmcsFuelQuality(); CmcsRCAssay assay_new = CommonDAO.GetInstance().SelfDber.Entity <CmcsRCAssay>("where MakeId=:MakeId order by CreateDate desc", new { MakeId = make.Id }); if (assay_new != null) { quality_new = (CmcsFuelQuality)Clone(assay_new.TheFuelQuality); } quality_new.CreateDate = quality_new.OperDate = DateTime.Now; if (assayPoint.Contains("全水分") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Mar = 0; } if (assayPoint.Contains("空干基水分") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Mad = 0; quality_new.FCad = 0; } if (assayPoint.Contains("灰分") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Aad = 0; quality_new.Ad = 0; quality_new.Aar = 0; quality_new.FCad = 0; } if (assayPoint.Contains("挥发分") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Vad = 0; quality_new.Vdaf = 0; quality_new.Vd = 0; quality_new.Var = 0; quality_new.FCad = 0; } if (assayPoint.Contains("全硫") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Stad = 0; quality_new.Star = 0; quality_new.Std = 0; quality_new.Sd = 0; } if (assayPoint.Contains("热值") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.QbAd = 0; quality_new.Qgrad = 0; quality_new.Qgrar = 0; quality_new.Qgrd = 0; quality_new.QCal = 0; quality_new.QJ = 0; } if (assayPoint.Contains("氢值") || assayPoint.Contains("全指标") || assayPoint.Contains("日常分析")) { quality_new.Hd = 0; quality_new.Had = 0; quality_new.Har = 0; } if (assayPoint.Contains("灰熔融") || assayPoint.Contains("全指标")) { quality_new.DT = 0; quality_new.HT = 0; quality_new.FT = 0; quality_new.ST = 0; } quality_new.Id = Guid.NewGuid().ToString(); quality_new.CreateUser = userAccount; quality_new.OperUser = userAccount; assay.FuelQualityId = quality_new.Id; Dbers.GetInstance().SelfDber.Insert(quality_new); Dbers.GetInstance().SelfDber.Insert(assay); return(true); } catch (Exception) { return(false); } }
/// <summary> /// 创建采制化三级数据 /// </summary> /// <param name="inFactoryBatch">批次</param> /// <param name="samplingType">采样方式</param> /// <param name="remark">备注</param> /// <param name="assayType">化验方式</param> /// <returns></returns> public CmcsRCSampling GCSamplingMakeAssay(CmcsInFactoryBatch inFactoryBatch, string samplingType, string remark) { bool isSuccess = false; // 入厂煤采样 CmcsRCSampling rCSampling = SelfDber.Entity <CmcsRCSampling>("where InFactoryBatchId=:InFactoryBatchId and SamplingType=:SamplingType and IsDeleted=0", new { InFactoryBatchId = inFactoryBatch.Id, SamplingType = samplingType }); if (rCSampling == null) { rCSampling = new CmcsRCSampling() { InFactoryBatchId = inFactoryBatch.Id, SamplingType = samplingType, SamplingDate = inFactoryBatch.FactArriveDate, SamplingPle = "自动", SampleCode = CreateNewSampleCode(inFactoryBatch.FactArriveDate), Remark = remark }; isSuccess = SelfDber.Insert(rCSampling) > 0; } // 入厂煤制样 CmcsRCMake rCMake = SelfDber.Entity <CmcsRCMake>("where SamplingId=:SamplingId and IsDeleted=0", new { SamplingId = rCSampling.Id }); if (rCMake == null) { rCMake = new CmcsRCMake() { SamplingId = rCSampling.Id, MakeType = "三级编码制样", MakeStyle = "机器制样", MakeDate = rCSampling.SamplingDate, MakeCode = CreateNewMakeCode(rCSampling.SamplingDate), MakePle = "自动", Remark = remark }; isSuccess = SelfDber.Insert(rCMake) > 0; } //入厂煤制样明细 foreach (CodeContent item in CommonDAO.GetInstance().GetCodeContentByKind("样品类型")) { CmcsRCMakeDetail rCMakeDetail = SelfDber.Entity <CmcsRCMakeDetail>("where MakeId=:MakeId and SampleType=:SampleType", new { MakeId = rCMake.Id, SampleType = item.Content }); if (rCMakeDetail == null) { rCMakeDetail = new CmcsRCMakeDetail(); rCMakeDetail.MakeId = rCMake.Id; rCMakeDetail.SampleCode = CreateNewMakeBarrelCodeByMakeCode(rCMake.MakeCode, item.Content); rCMakeDetail.SampleType = item.Content; isSuccess = SelfDber.Insert(rCMakeDetail) > 0; } } // 入厂煤化验 CmcsRCAssay rCAssay = SelfDber.Entity <CmcsRCAssay>("where MakeId=:MakeId and IsDeleted=0", new { MakeId = rCMake.Id }); if (rCAssay == null) { // 入厂煤煤质 CmcsFuelQuality fuelQuality = new CmcsFuelQuality() { Id = Guid.NewGuid().ToString() }; if (SelfDber.Insert(fuelQuality) > 0) { rCAssay = new CmcsRCAssay() { MakeId = rCMake.Id, AssayCode = CreateNewAssayCode(rCMake.CreateDate), InFactoryBatchId = inFactoryBatch.Id, FuelQualityId = fuelQuality.Id, AssayDate = rCMake.MakeDate, Remark = remark, IsAssay = 0, BackBatchDate = inFactoryBatch.BackBatchDate, }; isSuccess = SelfDber.Insert(rCAssay) > 0; } } return(rCSampling); }