Beispiel #1
0
        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);
        }
Beispiel #2
0
        public ActionResult Search(STSysSearchModel model)
        {
            int pos = model.posStart.HasValue ? model.posStart.Value : 0;
            ISearchResponse <es_t_bp_item> response = GetSearchResult(model);

            int        totalCount = (int)response.Total;
            DhtmlxGrid grid       = new DhtmlxGrid();

            grid.AddPaging(totalCount, pos);
            int index             = pos;
            var allCheckItems     = sHItemNameService.GetAllSHItemName();
            var reportConclusions = sysDictService.GetDictsByKey("ReportConclusionCode");

            foreach (var item in response.Documents)
            {
                DhtmlxGridRow row = new DhtmlxGridRow(item.SYSPRIMARYKEY);
                row.AddCell(index + 1);
                row.AddCell(item.PROJECTNAME);
                row.AddCell(SysDictUtility.GetKeyFromDic(reportConclusions, item.CONCLUSIONCODE, "/"));
                row.AddCell(checkUnitService.GetSTCheckUnitById(item.CUSTOMID));
                row.AddCell(item.STRUCTPART);
                row.AddCell(sHItemNameService.GetItemSHNameFromAll(allCheckItems, item.ITEMNAME));

                row.AddCell(item.REPORTNUM);
                row.AddCell(item.QRCODEBAR);
                row.AddCell(GetUIDtString(item.CHECKDATE, "yyyy-MM-dd"));
                row.AddCell(GetUIDtString(item.APPROVEDATE, "yyyy-MM-dd"));
                row.AddCell(reportService.GetReportDataStatus(item.SAMPLEDISPOSEPHASEORIGIN));
                row.AddCell(new DhtmlxGridCell("查看", false).AddCellAttribute("title", "查看"));
                index++;
                grid.AddGridRow(row);
            }
            string str = grid.BuildRowXml().ToString(System.Xml.Linq.SaveOptions.DisableFormatting);

            return(Content(str, "text/xml"));
        }
Beispiel #3
0
        protected Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> GetFilterQuerySH(
            STSysSearchModel model)
        {
            Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> filterQuery = q =>
            {
                string         dtFormatStr = "yyyy-MM-dd'T'HH:mm:ss";
                string         startDtStr  = model.StartDt.HasValue ? model.StartDt.Value.ToString(dtFormatStr) : string.Empty;
                string         endDtStr    = model.EndDt.HasValue ? model.EndDt.Value.AddDays(1).ToString(dtFormatStr) : string.Empty;
                QueryContainer initQuery   = null;
                var            date        = DateTime.Today;
                if (model.StartDt.HasValue || model.EndDt.HasValue)
                {
                    if (model.DtType == "CheckDt")
                    {
                        if (!startDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.CHECKDATE).GreaterThanOrEquals(DateMath.FromString(startDtStr)));
                        }
                        if (!endDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.CHECKDATE).LessThan(DateMath.FromString(endDtStr)));
                        }
                    }
                    else if (model.DtType == "ReportDt")
                    {
                        if (!startDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.PRINTDATE).GreaterThanOrEquals(DateMath.FromString(startDtStr)));
                        }
                        if (!endDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.PRINTDATE).LessThan(DateMath.FromString(endDtStr)));
                        }
                    }
                    else if (model.DtType == "UploadDt")
                    {
                        if (!startDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.UPLOADTIME).GreaterThanOrEquals(DateMath.FromString(startDtStr)));
                        }
                        if (!endDtStr.IsNullOrEmpty())
                        {
                            initQuery = initQuery && +q.DateRange(d => d.Field(f => f.UPLOADTIME).LessThan(DateMath.FromString(endDtStr)));
                        }
                    }
                }


                ////页面显示已打印的报告
                //if ("1" == System.Configuration.ConfigurationManager.AppSettings["ShowPrinted"])
                //{
                //    initQuery = initQuery && q.Match(m => m.Field(f => f.SAMPLEDISPOSEPHASE).Query(printedPhrase));
                //}


                var instFilter = GetCurrentInstFilter();
                if (instFilter.NeedFilter && instFilter.FilterInstIds.Count() > 0)
                {
                    initQuery = initQuery && +q.Terms(qtm => qtm.Field(qtmf => qtmf.CUSTOMID).Terms(instFilter.FilterInstIds));
                }

                if (!string.IsNullOrWhiteSpace(model.ProjectName))
                {
                    //initQuery = initQuery && q.QueryString(m => m.DefaultField(f => f.PROJECTNAME[0].Suffix("PROJECTNAMERAW")).Query("{0}{1}{0}".Fmt("*", model.ProjectName)));
                    initQuery = initQuery && q.Wildcard(qw => qw.Field(qwf => qwf.PROJECTNAME).Value("{0}{1}{0}".Fmt("*", model.ProjectName)));
                }

                if (!string.IsNullOrWhiteSpace(model.EntrustUnit))
                {
                    initQuery = initQuery && q.Match(m => m.Field(f => f.ENTRUSTUNIT).Query(model.EntrustUnit));
                }
                if (!string.IsNullOrWhiteSpace(model.EntrustUnit))
                {
                    initQuery = initQuery && q.Match(m => m.Field(f => f.ENTRUSTUNIT).Query(model.EntrustUnit));
                }
                if (!string.IsNullOrWhiteSpace(model.ReportNum))
                {
                    initQuery = initQuery && q.Match(m => m.Field(f => f.REPORTNUM).Query(model.ReportNum));
                }
                if (!string.IsNullOrWhiteSpace(model.EntrustNum))
                {
                    initQuery = initQuery && q.Match(m => m.Field(f => f.ENTRUSTNUM).Query(model.EntrustNum));
                }


                if (!string.IsNullOrWhiteSpace(model.CheckItem))   //.CheckItemCodes))
                {
                    var allItemcodes = model.CheckItem.Split(','); //.CheckItemCodes.Split(',');
                    if (allItemcodes.Length > 0)
                    {
                        initQuery = initQuery && q.Terms(qt => qt.Field(qtf => qtf.ITEMNAME).Terms(allItemcodes));
                    }
                }

                if (model.IsChanged.HasValue && model.IsChanged.Value != -1)
                {
                    if (model.IsChanged.Value == 1)
                    {
                        initQuery = initQuery && +q.Range(r => r.Field(f => f.HAVELOG).GreaterThanOrEquals(1));
                    }
                    else if (model.IsChanged.Value == 0)
                    {
                        initQuery = initQuery && (!q.Exists(e => e.Field(f => f.HAVELOG)) || q.Term(t => t.Field(f => f.HAVELOG).Value(0)));
                    }
                }

                if (model.HasArc.HasValue && model.HasArc.Value != -1)
                {
                    if (model.HasArc.Value == 1)
                    {
                        initQuery = initQuery && +q.Range(r => r.Field(f => f.HAVEACS).GreaterThanOrEquals(1)) && q.Exists(r => r.Field(f => f.ACSTIME));
                    }
                    else if (model.HasArc.Value == 0)
                    {
                        initQuery = initQuery && (!q.Exists(e => e.Field(f => f.HAVEACS)) || q.Term(t => t.Field(f => f.HAVEACS).Value(0)));
                    }
                }

                if (!string.IsNullOrWhiteSpace(model.CheckStatus) && model.CheckStatus != "A")
                {
                    initQuery = initQuery && +q.Term(t => t.Field(f => f.CONCLUSIONCODE).Value(model.CheckStatus));
                }
                if (!string.IsNullOrEmpty(model.SampleNum))
                {
                    initQuery = initQuery && q.QueryString(qrm => qrm.DefaultField(qrmf => qrmf.SAMPLENUM).Query("{0}{1}{0}".Fmt("*", model.SampleNum)));
                    //+ q.Term(t => t.Field(f => f.SAMPLENUM).Value(model.SampleNum));
                }


                if (!model.ItemName.IsNullOrEmpty())
                {
                    initQuery = initQuery && +q.Term(t => t.Field(f => f.ITEMNAME).Value(model.ItemName));
                }
                return(initQuery);
            };



            return(filterQuery);
        }