Ejemplo n.º 1
0
        public List <ReportViewModel> GetUnqualifiedReports(int userId, string stationName = "", string projectName = "", string checkItemCode = "", int days = 1, int pageIndex = 0, int pageSize = 10)
        {
            string dtFormatStr = "yyyy-MM-dd'T'HH:mm:ss";
            string startDtStr  = DateTime.Today.AddDays(-days).ToString(dtFormatStr);
            string endDtStr    = DateTime.Today.AddDays(1).ToString(dtFormatStr);

            Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> qcd = q =>
            {
                var qc = q.Term(t => t.Field(f => f.CONCLUSIONCODE).Value("N")) &&
                         q.DateRange(qdr => qdr.Field(qdrf => qdrf.PRINTDATE).GreaterThanOrEquals(DateMath.FromString(startDtStr))) &&
                         q.DateRange(qddr => qddr.Field(qddrf => qddrf.PRINTDATE).LessThanOrEquals(DateMath.FromString(endDtStr))) &&
                         q.Match(t => t.Field(f => f.SAMPLEDISPOSEPHASE).Query(PkpmConfigService.PrintedSamplePhrase));

                var instFilter = m_svcUser.GetFilterInsts(userId, "");
                if (instFilter.NeedFilter && instFilter.FilterInstIds.Count() > 0)
                {
                    qc = qc && +q.Terms(qtm => qtm.Field(qtmf => qtmf.CUSTOMID).Terms(instFilter.FilterInstIds));
                }

                if (!string.IsNullOrEmpty(checkItemCode))
                {
                    qc = qc && +q.Term(qt => qt.Field(qtf => qtf.ITEMNAME).Value(checkItemCode));
                }

                if (!string.IsNullOrEmpty(stationName))
                {
                    qc = qc && q.Match(t => t.Field(f => f.SUPERUNIT).Query(stationName));
                }

                if (!string.IsNullOrEmpty(projectName))
                {
                    // && + 只过滤,不分词
                    qc = qc && +q.Term(qt => qt.Field(qtf => qtf.PROJECTNAME[0].Suffix("PROJECTNAMERAW")).Value(projectName));
                }

                return(qc);
            };
            ISearchResponse <es_t_bp_item> response = m_repReport.Search(s => s.Sort(cs => cs.Descending(sd => sd.PRINTDATE)).From(pageIndex * pageSize).Size(pageSize).Query(qcd));

            List <ReportViewModel> result = new List <ReportViewModel>();

            foreach (var d in response.Documents)
            {
                var r = ReportViewModel.BuildReportVieModelFromES(d);
                FillInCheckItem(r);
                result.Add(r);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static void SetDateTimeToStr(ReportViewModel reportViewModel, es_t_bp_item report)
        {
            if (report == null)
            {
                return;
            }

            reportViewModel.ENTRUSTDATEStr  = CommonUtils.GetDateTimeStr(report.ENTRUSTDATE);
            reportViewModel.CHECKDATEStr    = CommonUtils.GetDateTimeStr(report.CHECKDATE);
            reportViewModel.AUDITINGDATEStr = CommonUtils.GetDateTimeStr(report.AUDITINGDATE);
            reportViewModel.APPROVEDATEStr  = CommonUtils.GetDateTimeStr(report.APPROVEDATE);
            reportViewModel.PRINTDATEStr    = CommonUtils.GetDateTimeStr(report.PRINTDATE);
            reportViewModel.COLLATEDATEStr  = CommonUtils.GetDateTimeStr(report.COLLATEDATE);
            reportViewModel.VERIFYDATEStr   = CommonUtils.GetDateTimeStr(report.VERIFYDATE);
            reportViewModel.EXTENDDATEStr   = CommonUtils.GetDateTimeStr(report.EXTENDDATE);
            reportViewModel.ACSTIMEStr      = CommonUtils.GetDateTimeStr(report.ACSTIME);
        }
Ejemplo n.º 3
0
        private void FillInCheckItem(ReportViewModel rvm)
        {
            if (rvm == null)
            {
                return;
            }

            // 检测软件那边只要是GE开头的 全部获取SAMPLENAME
            if (!rvm.ITEMNAME.IsNullOrEmpty() && rvm.ITEMNAME.StartsWith("GE"))
            {
                rvm.CheckItemName  = rvm.SAMPLENAME;
                rvm.CheckParamName = "(无)";
                return;
            }

            subitemparm item = null;

            //if (!string.IsNullOrEmpty(rvm.PARMCODE))
            //{
            //    item = m_svcItemName.GetItemByParamCode(rvm.PARMCODE);
            //}
            //else if (!string.IsNullOrEmpty(rvm.SUBITEMCODE))
            //{
            //    item = m_svcItemName.GetItemByItemCode(rvm.SUBITEMCODE);
            //}
            if (item != null)
            {
                rvm.CheckItemName  = item.itemname;
                rvm.CheckParamName = item.parmname;
            }
            else
            {
                // 旧体系
                if (m_oldItemNames == null)
                {
                    m_oldItemNames = m_svcItemName.GetAllItemName();
                }
                var oldItemName = m_svcItemName.GetItemCNNameFromAll(m_oldItemNames, rvm.REPORTJXLB, rvm.ITEMNAME);
                rvm.CheckItemName  = oldItemName;
                rvm.CheckParamName = "(无)";
            }
        }
Ejemplo n.º 4
0
        public ReportViewModel GetByReportNum(string reportNum)
        {
            Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> numQuery = qz =>
            {
                var initquery = qz.Term(qr => qr.Field(qrf => qrf.REPORTNUM).Value(reportNum));
                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.Documents.Count == 0)
            {
                return(null);
            }

            ReportViewModel rvm = ReportViewModel.BuildReportVieModelFromES(response.Documents.First());

            FillInCheckItem(rvm);
            return(rvm);
        }
Ejemplo n.º 5
0
        public ReportViewModel GetByReportNumAndDate(string reportNum, DateTime PrintDate)
        {
            Func <QueryContainerDescriptor <es_t_bp_item>, QueryContainer> numQuery = qz =>
            {
                string dtFormatStr = "yyyy-MM-dd'T'HH:mm:ss";

                var initquery = qz.Term(qr => qr.Field(qrf => qrf.REPORTNUM).Value(reportNum));
                initquery = initquery && qz.DateRange(d => d.Field(f => f.PRINTDATE).GreaterThanOrEquals(DateMath.FromString(PrintDate.ToString(dtFormatStr))));

                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.UPDATETIME)));

            if (response.Documents.Count == 0)
            {
                return(null);
            }

            ReportViewModel rvm = ReportViewModel.BuildReportVieModelFromES(response.Documents.First());

            FillInCheckItem(rvm);
            return(rvm);
        }
Ejemplo n.º 6
0
        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);
        }