private List <TotalSearchAcsTimeModel> GetAcsTimeDetails(string id, string SampleNum) { ISearchResponse <es_t_bp_acs> acsResponse = null; if (string.IsNullOrEmpty(SampleNum)) { acsResponse = acsESRep.Search(s => s.Index("sh-t-bp-attach").From(0).Size(20).Sort(cs => cs.Ascending(csd => csd.ACSTIME)).Query(q => q. Bool(b => b.Filter(f => f.Term(ft => ft.Field(ftf => ftf.SYSPRIMARYKEY).Value(id)) )))); } else { acsResponse = acsESRep.Search(s => s.Index("sh-t-bp-attach").From(0).Size(20).Sort(cs => cs.Ascending(csd => csd.ACSTIME)).Query(q => q.Term(f => f.Field(ff => ff.SYSPRIMARYKEY).Value(id)) && q.Term(f => f.Field(ff => ff.SAMPLENUM).Value(SampleNum)))); } List <TotalSearchAcsTimeModel> model = new List <TotalSearchAcsTimeModel>(); if (acsResponse.IsValid) { int index = 1; foreach (var item in acsResponse.Documents) { TotalSearchAcsTimeModel oneModel = new TotalSearchAcsTimeModel(); oneModel.SysPrimaryKey = item.PK; oneModel.index = index.ToString(); oneModel.SAMPLENUM = item.SAMPLENUM; oneModel.MAXVALUE = item.MAXVALUE; oneModel.ACSTIME = GetUIDtString(item.ACSTIME, "yyyy-MM-dd HH:mm:ss"); model.Add(oneModel); index++; } } return(model); }
private List <TotalSearchCommonReportModel> GetCommonReportDetails(string customId, string reportNum, string itemCode, string id) { string key = string.Format("{0}{1}{2}", customId, itemCode, reportNum); Func <QueryContainerDescriptor <es_t_pkpm_binaryReport>, QueryContainer> filterQuery = q => (q.Terms(t => t.Field(f => f.REPORTNUM).Terms(key))) && q.Exists(qe => qe.Field(qet => qet.REPORTPATH)); var pkrResponse = pkrESRep.Search(s => s.Index("sh-t-pkpm-pkr").Sort(cs => cs.Descending(csd => csd.UPLOADTIME)).From(0).Size(50).Query(filterQuery)); List <TotalSearchCommonReportModel> model = new List <TotalSearchCommonReportModel>(); if (pkrResponse.IsValid) { int index = 1; foreach (var item in pkrResponse.Documents) { //过滤无附件的报表 if (item.REPORTPATH.IsNullOrEmpty()) { continue; } Dictionary <string, string> dict = new Dictionary <string, string>(); TotalSearchCommonReportModel oneModel = new TotalSearchCommonReportModel(); oneModel.index = index.ToString(); oneModel.UpLoadTime = GetUIDtString(item.UPLOADTIME, "yyyy-MM-dd HH:mm:ss"); oneModel.ReportNum = reportNum; oneModel.ReportPath = SymCryptoUtility.Encrypt(item.REPORTPATH); oneModel.Id = id; index++; model.Add(oneModel); } } return(model); }
public ISearchResponse <es_t_bp_item> GetResult(TotalStatisSearchModel model) { var filterQuery = GetFilterQuery(model); return(tbpitemESRep.Search(s => s.Size(0).Query(filterQuery).Aggregations(af => af.Terms("CUSTOMID", item => item.Field(iif => iif.CUSTOMID) .Aggregations(aaf => aaf.Terms(UnQualiKey, adn => adn.Field(aaa => aaa.CONCLUSIONCODE)) .Terms(ModifyKey, adm => adm.Field(aadm => aadm.HAVELOG)) .Terms(AcsKey, afnm => afnm.Field(aaaa => aaaa.HAVEACS))).Size(1000))))); }
private ISearchResponse <es_t_bp_item> GetStatisData(SysSearchModel model) { if (model.GroupType != "Custom") //不以机构分组则只查不合格,以机构分组则查询所有报告,再聚合一次不合格数量 { model.modelType = SysSearchModelModelType.UnQualified; } var userItems = userItemrep.GetDictByCondition <string, string>(r => r.UserId == GetCurrentUserId() && r.UserItemType == UserItemType.UnQualifiedReport, r => new { r.Id, r.ItemTableName }); var userInstIds = userCustomrep.GetDictByCondition <string, string>(r => r.UserId == GetCurrentUserId() && r.UserCustomType == UserCustomType.UnQualifiedCount, r => new { r.Id, r.CustomId }); var filterQuery = GetFilterQuery(checkUnitService, itemNameService, model, userInstIds, userItems); ISearchResponse <es_t_bp_item> response = null; if (!string.IsNullOrEmpty(model.GroupType)) { switch (model.GroupType) { case "Item": aggeKey = "ItemNum"; //response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) //.Aggregations(af => af.Terms(aggeKey, item => item //.Field(iif => iif.ITEMNAME).Size(1000)))); response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item .Script("doc['REPORTJXLB'].value+'|'+doc['ITEMNAME'].value").Size(1000)))); break; case "Custom": aggeKey = "Custom"; response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item .Field(iif => iif.CUSTOMID).Size(1000) .Aggregations(aaaf => aaaf.Terms("Conclution", aaa => aaa.Field(aac => aac.CONCLUSIONCODE).Aggregations(tt => tt.Terms("ProductFactory", ttt => ttt.Field(tttt => tttt.PRODUCEFACTORY)))) )))); break; case "Project": aggeKey = "Project"; response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item .Field(iif => iif.PROJECTNAME[0].Suffix("PROJECTNAMERAW")).Size(1000)))); break; default: aggeKey = "ItemNum"; response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item .Field(iif => iif.ITEMNAME).Size(1000)))); break; } } return(response); }
private ISearchResponse <es_t_bp_item> GetSearchResult(STSysSearchModel model) { var filterQuery = GetFilterQuerySH(model); int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; var aaaa = rep.Search(s => s.Source(sf => sf.Includes(sfi => sfi.Fields( f => f.SYSPRIMARYKEY, f => f.CUSTOMID, f => f.PROJECTNAME, f => f.STRUCTPART, f => f.ITEMNAME, f => f.ITEMCHNAME, f => f.ACSTIME, f => f.ENTRUSTDATE, f => f.CHECKDATE, f => f.PRINTDATE, f => f.SAMPLENUM, f => f.REPORTNUM, f => f.QRCODEBAR, //f => f.HAVREPORT, f => f.ISCREPORT, f => f.SUBITEMCODE, f => f.SAMPLEDISPOSEPHASE, f => f.SAMPLEDISPOSEPHASEORIGIN, f => f.CHECKCONCLUSION))).Sort(c => c.Descending(cd => cd.PRINTDATE)).From(pos).Size(count).Query(filterQuery).Index("sh-tbpitem")); return(aaaa); }
public ActionResult ModifyRecordDetails(string key) { ModifyRecordDetailsModel viewModel = new ModifyRecordDetailsModel() { ModifyDetailsModel = new List <Models.TotalSearchQuestionModel>() }; var questionResponse = questionESRep.Search(s => s.Index("sh-t-bp-subitem").From(0).Size(50).Query(q => q. Bool(b => b.Filter(f => f.Term(ft => ft.Field(ftf => ftf.QUESTIONPRIMARYKEY).Value(key)))))); List <TotalSearchQuestionModel> model = new List <TotalSearchQuestionModel>(); if (questionResponse.IsValid) { var questionTypes = sysDictService.GetDictsByKey("questionTypes"); int index = 1; foreach (var item in questionResponse.Documents) { TotalSearchQuestionModel oneModel = new TotalSearchQuestionModel(); oneModel.index = index.ToString(); oneModel.RecordTime = GetUIDtString(item.RECORDTIME, "yyyy-MM-dd HH:mm:ss"); oneModel.RecordingPhase = RenderSampleDisposePhase(item.RECORDINGPHASE); oneModel.QuestionType = SysDictUtility.GetKeyFromDic(questionTypes, item.QUESTIONTYPES); oneModel.Context = item.CONTEXT; oneModel.RecordMan = item.RECORDMAN; model.Add(oneModel); index++; } } viewModel.ModifyDetailsModel = model; return(View(viewModel)); }
private ISearchResponse <es_t_bp_item> GetSearchResult(SysSearchModel model) { var filterQuery = GetFilterQuery(checkUnitService, itemNameService, model, new Dictionary <string, string>(), new Dictionary <string, string>()); int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; return(tbpitemESRep.Search(s => s.Source(sf => sf.Includes(sfi => sfi.Fields( f => f.SYSPRIMARYKEY, f => f.APPROVEDATE, f => f.SAMPLENAME, f => f.PROJECTNAME, f => f.STRUCTPART, f => f.CONCLUSIONCODE, f => f.ITEMNAME, f => f.ITEMCHNAME, f => f.REPORTNUM, f => f.CUSTOMID, f => f.ENTRUSTDATE, f => f.CHECKDATE, f => f.SAMPLENUM, f => f.SAMPLEDISPOSEPHASEORIGIN, f => f.PRINTDATE, f => f.ADDTIME, f => f.SAMPLEDISPOSEPHASE, f => f.ACSTIME, f => f.CODEBAR, f => f.QRCODEBAR ))).From(pos).Size(count).Query(filterQuery))); }
private ISearchResponse <es_t_bp_item> GetReportUploadStatis() { var filterQuery = GetFilterQuery(checkUnitService, itemNameService, new Pkpm.Entity.SysSearchModel(), null, null); var response = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item .Field(iif => iif.CUSTOMID).Size(200) .Aggregations(aaf => aaf.TopHits(tBuckKey, tdt => tdt.Size(1).Source(ccs => ccs.Includes(ccsi => ccsi.Field(ccsif => ccsif.UPLOADTIME))) .Sort(cs => cs.Field(csf => csf.UPLOADTIME).Descending())))))); return(response); }
public List <string> GetScheduleCodes(string sysPrimaryKey) { List <string> curlistCodes = new List <string>(); if (string.IsNullOrWhiteSpace(sysPrimaryKey)) { return(curlistCodes); } //sysprimarykey查询covrlist,通过code关联查询WxSchedule,显示现场检测详情、图片、视频 Func <QueryContainerDescriptor <es_covrlist>, QueryContainer> filterQuery = q => q.Term(t => t.Field(f => f.SYSPRIMARYKEY).Value(sysPrimaryKey)); var covrlist = m_covrlistESRep.Search(s => s.Source(sf => sf.Includes(sfi => sfi.Fields( f => f.SYSPRIMARYKEY, f => f.UNITCODE, f => f.CODE ))).Query(filterQuery).Index("cq-t-bp-subitem")); foreach (var item in covrlist.Documents) { curlistCodes.Add(item.CODE); } return(curlistCodes); }
private ISearchResponse <es_t_bp_item> GetSearchResponse(SysSearchModel model) { var filter = GetFilterQuery(checkUnitService, itemNameService, model, new Dictionary <string, string>(), new Dictionary <string, string>()); int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; return(tbpESRep.Search(t => t.Query(filter).From(pos).Size(count) .Source(tt => tt.Includes(tst => tst.Fields( ttt => ttt.SYSPRIMARYKEY, ttt => ttt.ENTRUSTUNIT, ttt => ttt.CONSTRACTUNIT, ttt => ttt.CUSTOMID, ttt => ttt.PROJECTNAME, ttt => ttt.STRUCTPART, ttt => ttt.REPORTJXLB, ttt => ttt.ITEMNAME, ttt => ttt.CHECKTYPE, ttt => ttt.ENTRUSTDATE, ttt => ttt.CHECKDATE, ttt => ttt.PRINTDATE, ttt => ttt.REPORTNUM, ttt => ttt.CHECKCONCLUSION ))))); }
private ISearchResponse <SJKY_CUR> GetResponse(CheckStatisSJKYSearchModel model) { var filter = GetFilterQuery(model); int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; return(sjkyESRep.Search(t => t.Query(filter).From(pos).Size(count).Index("gx-t-bp-sjky").Source(sf => sf.Includes(ss => ss.Fields(tt => tt.SYSPRIMARYKEY, tt => tt.PROJECTNAME, ttt => ttt.STRUCTPART, ttt => ttt.CUSTOMID, ttt => ttt.REPORTNUM, ttt => ttt.SHEJIQIANGDUDENGJI, ttt => ttt.QIANGDUDAIBIAOZHI, ttt => ttt.QIANGDUBAIFENBI))))); }
private List <TotalSearchRawMaterialModel> GetRawMaterials(string id, string ReportNum, string ItemName, string CustomId) { List <TotalSearchRawMaterialModel> models = new List <TotalSearchRawMaterialModel>(); var rmcmRes = rmcrRep.Search(s => s.Query(q => q.Term(qt => qt.Field(qtf => qtf.SYSPRIMARYKEY).Value(id)) && q.Exists(qe => qe.Field(qef => qef.JYPC)) && q.Term(qt => qt.Field(qtf => qtf.REPORTNUM).Value(ReportNum))).Source(ss => ss.Includes(si => si.Fields(sif => sif.JYPC, sif => sif.SAMPLENUM))).Size(10).Index("sh-rmcr")); if (rmcmRes.IsValid && rmcmRes.Documents.Count > 0) { var Jypcs = rmcmRes.Documents.Select(s => s.JYPC).ToList(); if (Jypcs.Count > 0) { int index = 0; Func <QueryContainerDescriptor <es_ut_rpm>, QueryContainer> filterQuery = q => { QueryContainer initQuery = q.Exists(e => e.Field(f => f.JYPC)); initQuery = initQuery && q.Terms(qt => qt.Field(qtf => qtf.JYPC).Terms(Jypcs)); if (!ItemName.IsNullOrEmpty()) { initQuery = initQuery && q.Term(qt => qt.Field(qtf => qtf.ITEMNAME).Value(ItemName)); } var SampleNums = rmcmRes.Documents.Select(s => s.SAMPLENUM).ToList(); if (SampleNums.Count > 0) { initQuery = initQuery && q.Terms(qt => qt.Field(qtf => qtf.SAMPLENUM).Terms(SampleNums)); } if (!CustomId.IsNullOrEmpty()) { initQuery = initQuery && q.Term(qt => qt.Field(qtf => qtf.CUSTOMID).Value(CustomId)); } return(initQuery); }; var response = utrpmRep.Search(s => s.Query(filterQuery).Size(100).Index("sh-ut-rpm")); if (response.IsValid && response.Documents.Count > 0) { foreach (var item in response.Documents) { TotalSearchRawMaterialModel rm = new TotalSearchRawMaterialModel(); rm.index = (++index).ToString(); rm.Name = GetRawMaterialItemName(ItemName); rm.PRODUCEFACTORY = item.PRODUCEFACTORY; rm.ENTRYAMOUNT = item.ENTRYAMOUNT.HasValue ? Math.Round(item.ENTRYAMOUNT.Value, 2).ToString() : ""; rm.ENTRYDATE = GetUIDtString(item.ENTRYDATE); rm.JYPC = item.JYPC; models.Add(rm); } } } } return(models); }
private ISearchResponse <HNKY_CUR> GetResult(CheckStatisHNKYSearchModel model) { var filterQuery = FilterQuery(model); int pos = model.posStart.HasValue ? model.posStart.Value : 0; int count = model.count.HasValue ? model.count.Value : 30; return(Rep.Search(t => t.Query(filterQuery).From(pos).Size(count).Index("gx-t-bp-hnky").Source(sf => sf.Includes(ss => ss.Fields( tt => tt.SYSPRIMARYKEY, tt => tt.PROJECTNAME, tt => tt.STRUCTPART, tt => tt.CUSTOMID, tt => tt.REPORTNUM, tt => tt.SHEJIDENGJI, tt => tt.BAIFENGBI, tt => tt.LINQI, tt => tt.CHECKDATE, tt => tt.QIANGDUDAIBIAOZHI))))); }
private List <TotalSearchModifyModel> GetModifyDetails(string id) { var modifyResponse = modifylogESRep.Search(s => s.Index("sh-t-bp-subitem").From(0).Size(50).Query(q => q. Bool(b => b.Filter(f => f.Term(ft => ft.Field(ftf => ftf.SYSPRIMARYKEY).Value(id)))))); List <TotalSearchModifyModel> model = new List <TotalSearchModifyModel>(); if (modifyResponse.IsValid) { int index = 1; foreach (var item in modifyResponse.Documents) { TotalSearchModifyModel oneModel = new TotalSearchModifyModel(); oneModel.QuestionPrimaryKey = item.QUESTIONPRIMARYKEY; oneModel.index = index.ToString(); oneModel.FieldName = item.FIELDNAME; oneModel.BeforeModifyValues = item.BEFOREMODIFYVALUES; oneModel.AfterModifyValues = item.AFTERMODIFYVALUES; oneModel.ModifyDateTime = GetUIDtString(item.MODIFYDATETIME, "yyyy-MM-dd HH:mm:ss"); index++; model.Add(oneModel); } } return(model); }
public Dictionary <string, int> GetPkrReportNums(IEnumerable <es_t_bp_item> tbpItems) { Dictionary <string, int> pkrReports = new Dictionary <string, int>(); if (tbpItems == null || tbpItems.Count() == 0) { return(pkrReports); } List <string> pkrReportNums = new List <string>(); foreach (var item in tbpItems) { var esPkrReportNum = BuildPkrReportNum(item); pkrReportNums.Add(esPkrReportNum.BSKey); pkrReportNums.Add(esPkrReportNum.NormalKey); } int aggCount = pkrReportNums.Count * 2; string pkrAggkey = "pkrAggKey"; Func <QueryContainerDescriptor <es_t_pkpm_binaryReport>, QueryContainer> filterQuery = q => (q.Terms(t => t.Field(f => f.REPORTNUM).Terms(pkrReportNums))) && q.Exists(qe => qe.Field(qet => qet.REPORTPATH)); var pkrResponse = pkrESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(pkrAggkey, item => item.Field(iif => iif.REPORTNUM).Size(aggCount))).Index("gx-t-pkpm-pkr")); foreach (var item in pkrResponse.Aggs.Terms(pkrAggkey).Buckets) { int count = item.DocCount.HasValue ? (int)item.DocCount.Value : 0; pkrReports[item.Key] = count; } return(pkrReports); }
private ISearchResponse <es_t_bp_item> GetYearSearchResponse(CheckStatisDataSearchModel model) { var filterQuery = GetFilterQuery(model); ISearchResponse <es_t_bp_item> response; if (model.Type == "0") { response = tbpItemESRep.Search(t => t.Size(0).Query(filterQuery) .Aggregations(ttty => ttty.Terms("CustomID", tttty => tttty.Field(tgh => tgh.CUSTOMID) .Aggregations(tt => tt.DateHistogram("year", tst => tst.Field(tss => tss.PRINTDATE).Interval(DateInterval.Year).MinimumDocumentCount(1) .Aggregations(tsst => tsst.DateHistogram("qua", ttt => ttt.Field(tstt => tstt.PRINTDATE).Interval(DateInterval.Quarter).MinimumDocumentCount(0) .Aggregations(ty => ty.DateHistogram("month", tty => tty.Field(ttyy => ttyy.PRINTDATE).Interval(DateInterval.Month).MinimumDocumentCount(0)))))))))); } else if (model.Type == "1") { response = tbpItemESRep.Search(t => t.Size(0).Query(filterQuery) .Aggregations(ttty => ttty.Terms("CustomID", tttty => tttty.Field(tgh => tgh.CUSTOMID) .Aggregations(tt => tt.DateHistogram("year", tst => tst.Field(tss => tss.APPROVEDATE).Interval(DateInterval.Year).MinimumDocumentCount(1) .Aggregations(tsst => tsst.DateHistogram("qua", ttt => ttt.Field(tstt => tstt.APPROVEDATE).Interval(DateInterval.Quarter).MinimumDocumentCount(0) .Aggregations(ty => ty.DateHistogram("month", tty => tty.Field(ttyy => ttyy.APPROVEDATE).Interval(DateInterval.Month).MinimumDocumentCount(0)))))))))); } else if (model.Type == "2") { response = tbpItemESRep.Search(t => t.Size(0).Query(filterQuery) .Aggregations(ttty => ttty.Terms("CustomID", tttty => tttty.Field(tgh => tgh.CUSTOMID) .Aggregations(tt => tt.DateHistogram("year", tst => tst.Field(tss => tss.CHECKDATE).Interval(DateInterval.Year).MinimumDocumentCount(1) .Aggregations(tsst => tsst.DateHistogram("qua", ttt => ttt.Field(tstt => tstt.CHECKDATE).Interval(DateInterval.Quarter).MinimumDocumentCount(0) .Aggregations(ty => ty.DateHistogram("month", tty => tty.Field(ttyy => ttyy.CHECKDATE).Interval(DateInterval.Month).MinimumDocumentCount(0)))))))))); } else if (model.Type == "3") { response = tbpItemESRep.Search(t => t.Size(0).Query(filterQuery) .Aggregations(ttty => ttty.Terms("CustomID", tttty => tttty.Field(tgh => tgh.CUSTOMID) .Aggregations(tt => tt.DateHistogram("year", tst => tst.Field(tss => tss.UPLOADTIME).Interval(DateInterval.Year).MinimumDocumentCount(1) .Aggregations(tsst => tsst.DateHistogram("qua", ttt => ttt.Field(tstt => tstt.UPLOADTIME).Interval(DateInterval.Quarter).MinimumDocumentCount(0) .Aggregations(ty => ty.DateHistogram("month", tty => tty.Field(ttyy => ttyy.UPLOADTIME).Interval(DateInterval.Month).MinimumDocumentCount(0)))))))))); } else { response = null; } return(response); }
// GET: Welcome public ActionResult Index() { var measnumEndDate = new PagingOptions <t_bp_custom>(0, 7, t => t.measnumEndDate); var measnumDate = customRep.GetByConditonPage <MeasnumDateModel>(t => t.measnumEndDate != null, t => new { t.ID, t.NAME, t.measnumEndDate }, measnumEndDate);//检测资质有效期日期 var detectnumEndDate = new PagingOptions <t_bp_custom>(0, 7, t => t.detectnumEndDate); var detectnumDate = customRep.GetByConditonPage <DetectnumDateModel>(t => t.detectnumEndDate != null, t => new { t.ID, t.NAME, t.detectnumEndDate }, detectnumEndDate);//计量认证有效期日期 var checkenddate = new PagingOptions <t_bp_Equipment>(0, 7, t => t.checkenddate); var checkdate = equipmentRep.GetByConditonPage <CheckdateModel>(t => t.checkenddate != null, t => new { t.id, t.EquName, t.checkenddate, t.customid }, checkenddate);//设备有效期 var allUnitByArea = checkUnitService.GetAllCustomInArea(); WelcomeViewMoel viewmodel = new WelcomeViewMoel() { EchartUnqualifyReportsCount = new List <EchartNameValue>(), EchartTotalReportsCount = new List <EchartNameValue>(), EcharModifyReportsCount = new List <EchartNameValue>(), MeasnumDate = new List <DueRemindModel>(), DetectnumDate = new List <DueRemindModel>(), Checkdate = new List <DueRemindModel>() }; int i = 1; foreach (var item in measnumDate) { DueRemindModel dueRemind = new DueRemindModel(); var dateTime = Convert.ToDateTime(DateTime.Now); var time = dateTime - Convert.ToDateTime(item.measnumEndDate); if (time.Days >= 0) { dueRemind.Type = item.Name + "单位检测资质证书已经过期" + time.Days + "天"; } else { dueRemind.Type = item.Name + "单位检测资质证书有效期剩余" + time.Days * (-1) + "天"; } dueRemind.Date = item.measnumEndDate.HasValue ? item.measnumEndDate.Value.ToString("yyyy-MM-dd") : string.Empty; dueRemind.Num = i; i++; dueRemind.Id = item.Id; viewmodel.MeasnumDate.Add(dueRemind); } i = 1; foreach (var item in detectnumDate) { DueRemindModel dueRemind = new DueRemindModel(); var dateTime = Convert.ToDateTime(DateTime.Now); var time = dateTime - Convert.ToDateTime(item.detectnumEndDate); if (time.Days >= 0) { dueRemind.Type = item.Name + "单位计量认证证书已经过期" + time.Days + "天"; } else { dueRemind.Type = item.Name + "单位计量认证证书有效期剩余" + time.Days * (-1) + "天"; } dueRemind.Num = i; i++; dueRemind.Date = item.detectnumEndDate.HasValue ? item.detectnumEndDate.Value.ToString("yyyy-MM-dd") : string.Empty; dueRemind.Id = item.Id; viewmodel.DetectnumDate.Add(dueRemind); } i = 1; foreach (var item in checkdate) { DueRemindModel dueRemind = new DueRemindModel(); var dateTime = Convert.ToDateTime(DateTime.Now); var time = dateTime - Convert.ToDateTime(item.checkenddate); var checkName = checkUnitService.GetCheckUnitById(item.customid); if (time.Days >= 0) { dueRemind.Type = checkName + "单位仪器设备检定已经过期" + time.Days + "天"; } else { dueRemind.Type = checkName + "单位仪器设备检定有效期剩余" + time.Days * (-1) + "天"; } dueRemind.Num = i; i++; dueRemind.Id = item.id; dueRemind.Date = item.checkenddate.HasValue ? item.checkenddate.Value.ToString("yyyy-MM-dd") : string.Empty; viewmodel.Checkdate.Add(dueRemind); } DateTime DtNow = DateTime.Now; string dtFormatStr = "yyyy-MM-dd'T'HH:mm:ss"; string endDtStr = DtNow.AddDays(1).ToString(dtFormatStr); //string endDt = endDtStr DateTime DtStart = DtNow.AddDays(-7); string startDtStr = DtStart.ToString(dtFormatStr); #region 获得首页上部统计信息 var instFilter = GetCurrentInstFilter(); Func <Nest.QueryContainerDescriptor <es_t_bp_item>, QueryContainer> qcd = q => { var qc = q.DateRange(qdr => qdr.Field(qdrf => qdrf.PRINTDATE).GreaterThanOrEquals(DateMath.FromString(startDtStr))) && q.DateRange(qddr => qddr.Field(qddrf => qddrf.PRINTDATE).LessThanOrEquals(DateMath.FromString(endDtStr))); if (instFilter.NeedFilter && instFilter.FilterInstIds.Count() > 0) { qc = qc && +q.Terms(qtm => qtm.Field(qtmf => qtmf.CUSTOMID).Terms(instFilter.FilterInstIds)); } return(qc); }; var response = tbpitemESRep.Search(s => s.Size(0).Query(qcd).Aggregations(af => af.Terms(UnQualiKey, adn => adn.Field(aaa => aaa.CONCLUSIONCODE)) .Terms(ModifyKey, adm => adm.Field(aadm => aadm.HAVELOG)) .Terms(ReportKey, ada => ada.Field(adaa => adaa.HAVREPORT)))); if (response.IsValid) { viewmodel.TotalReports = (int)response.Total; var unQualiBuckets = response.Aggs.Terms(UnQualiKey).Buckets; foreach (var buctet in unQualiBuckets) { if (buctet.Key == "N") { viewmodel.UnqualifyReports = (int)buctet.DocCount; } } var modifyBuckets = response.Aggs.Terms(ModifyKey).Buckets; foreach (var buctet in modifyBuckets) { if (buctet.Key == "1") { viewmodel.ModifyReports = (int)buctet.DocCount; } } var reportBuckets = response.Aggs.Terms(ReportKey).Buckets; foreach (var buctet in reportBuckets) { if (buctet.Key == "1") { viewmodel.PKRReports = (int)buctet.DocCount; } } } if (viewmodel.TotalReports == 0) { viewmodel.UnqualifyPercentage = "0"; viewmodel.ModifyPercentage = "0"; viewmodel.PKRPercentage = "0"; } else { viewmodel.UnqualifyPercentage = (viewmodel.UnqualifyReports * 100 / viewmodel.TotalReports).ToString(); viewmodel.ModifyPercentage = (viewmodel.ModifyReports * 100 / viewmodel.TotalReports).ToString(); viewmodel.PKRPercentage = (viewmodel.PKRReports * 100 / viewmodel.TotalReports).ToString(); } #endregion #region 获得首页中间部分地图信息数据 var countByArea = new Dictionary <string, int>(); var unQualifyCount = new Dictionary <string, int>(); var ModifyCount = new Dictionary <string, int>(); var EchartTotalReportsCount = new Dictionary <string, int>(); var EchartUnqualifyReportsCount = new Dictionary <string, int>(); var EcharModifyReportsCount = new Dictionary <string, int>(); var allArea = areaService.GetAllArea(); var userItems = userItemrep.GetDictByCondition <string, string>(r => r.UserId == GetCurrentUserId() && r.UserItemType == UserItemType.UnQualifiedReport, r => new { r.Id, r.ItemTableName }); var userInstIds = userCustomrep.GetDictByCondition <string, string>(r => r.UserId == GetCurrentUserId() && r.UserCustomType == UserCustomType.UnQualifiedCount, r => new { r.Id, r.CustomId }); SysSearchModel model = new SysSearchModel() { StartDt = DateTime.Today.AddDays(-7), EndDt = DateTime.Today.AddDays(1) }; var filterQuery = GetFilterQuery(checkUnitService, itemNameService, model, userInstIds, userItems); var mapResponse = tbpitemESRep.Search(s => s.Size(0).Query(filterQuery) .Aggregations(af => af.Terms(aggeKey, item => item.Field(iif => iif.CUSTOMID).Size(1000) .Aggregations(aaaf => aaaf.Terms("Conclution", aaa => aaa.Field(aac => aac.CONCLUSIONCODE)).Terms("Havelog", aab => aab.Field(aad => aad.HAVELOG)) )))); if (mapResponse.IsValid) { var bucks = mapResponse.Aggs.Terms(aggeKey).Buckets; foreach (var item in bucks) { var unqualiBucks = item.Terms("Conclution").Buckets; var modifyBucks = item.Terms("Havelog").Buckets; var customId = item.Key; var unitArea = string.Empty; var areaBool = allUnitByArea.TryGetValue(item.Key, out unitArea); if (areaBool) { GetDictResult(countByArea, item, unitArea); } else { unitArea = "其他"; GetDictResult(countByArea, item, unitArea); } foreach (var unqualifyItem in unqualiBucks) { if (unqualifyItem.Key == "N" || unqualifyItem.Key == "n") { GetDictResult(unQualifyCount, unqualifyItem, unitArea); } } foreach (var modifyItem in modifyBucks) { if (modifyItem.Key == "1") { GetDictResult(ModifyCount, modifyItem, unitArea); } } } foreach (var item in countByArea) { GetEchartValue(EchartTotalReportsCount, allArea, item); } foreach (var item in unQualifyCount) { GetEchartValue(EchartUnqualifyReportsCount, allArea, item); } foreach (var item in ModifyCount) { GetEchartValue(EcharModifyReportsCount, allArea, item); } foreach (var item in EchartTotalReportsCount) { EchartNameValue echart = new EchartNameValue() { name = item.Key, value = item.Value }; viewmodel.EchartTotalReportsCount.Add(echart); } foreach (var item in EchartUnqualifyReportsCount) { EchartNameValue echart = new EchartNameValue() { name = item.Key, value = item.Value }; viewmodel.EchartUnqualifyReportsCount.Add(echart); } foreach (var item in EcharModifyReportsCount) { EchartNameValue echart = new EchartNameValue() { name = item.Key, value = item.Value }; viewmodel.EcharModifyReportsCount.Add(echart); } viewmodel.EchartTotalReportsCount = viewmodel.EchartTotalReportsCount.OrderBy(s => s.name).ToList(); viewmodel.EchartUnqualifyReportsCount = viewmodel.EchartUnqualifyReportsCount.OrderBy(s => s.name).ToList(); viewmodel.EcharModifyReportsCount = viewmodel.EcharModifyReportsCount.OrderBy(s => s.name).ToList(); } #endregion #region 获得首页下部到期提醒数据 #endregion return(View(viewmodel)); }
public ReportViewModel GetByReportNum(ReportCheck reportCheck) { Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> numQuery = qz => { var initquery = qz.Term(qr => qr.Field(qrf => qrf.REPORTNUM).Value(reportCheck.reportnum)); if (!reportCheck.customid.IsNullOrEmpty()) { initquery = initquery && qz.Term(tt => tt.Field(ttt => ttt.CUSTOMID).Value(reportCheck.customid)); } return(initquery); }; ISearchResponse <es_t_bp_item> response = m_repReport.Search(s => s.From(0).Size(10).Query(numQuery).Sort(cs => cs.Descending(csd => csd.UPLOADTIME))); if (!response.IsValid || response.Documents == null || response.Documents.Count == 0) { return(null); } es_t_bp_item chooseTBpItem = new es_t_bp_item(); if (response.Documents.Count == 1) { chooseTBpItem = response.Documents.First(); } else { bool hasFound = false; var existDocs = response.Documents.ToList(); //查 工程名称 if (!reportCheck.projectname.IsNullOrEmpty()) { existDocs = existDocs.Where(e => e.PROJECTNAME.Contains(reportCheck.projectname.Trim())).ToList(); if (existDocs.IsNullOrEmpty()) { hasFound = true; chooseTBpItem = response.Documents.First(); } else if (existDocs.Count() == 1) { hasFound = true; chooseTBpItem = existDocs.First(); } } //查 结构部位 if (!hasFound && !reportCheck.structpart.IsNullOrEmpty()) { existDocs = existDocs.Where(e => e.STRUCTPART.Contains(reportCheck.structpart.Trim())).ToList(); if (existDocs.IsNullOrEmpty()) { hasFound = true; chooseTBpItem = response.Documents.First(); } else if (existDocs.Count() == 1) { hasFound = true; chooseTBpItem = existDocs.First(); } } if (!hasFound) { chooseTBpItem = response.Documents.First(); } } ReportViewModel rvm = ReportViewModel.BuildReportVieModelFromES(chooseTBpItem); FillInCheckItem(rvm); return(rvm); }