Пример #1
0
        public async Task <ScoreRecordDetailDto> GetScoreRecordDetail(string recordId)
        {
            var auditRateMModel         = _auditRateMRepository.FindSingle(x => x.Record_ID.Trim() == recordId);
            ScoreRecordDetailDto result = new ScoreRecordDetailDto();

            if (auditRateMModel != null)
            {
                var listAuditRateDModel = _auditRateDRepository.FindAll(x => x.Record_ID == auditRateMModel.Record_ID);
                var listAuditTypeD      = _auditTypeDRepository.FindAll(x => x.Audit_Type_ID == auditRateMModel.Audit_Type_ID);
                var listAuditRateD      = await(from a in listAuditRateDModel
                                                join b in listAuditTypeD
                                                on a.Audit_Item_ID equals b.Audit_Item_ID
                                                select new AuditRateDDetailDto
                {
                    RecordId       = a.Record_ID,
                    AuditItemId    = a.Audit_Item_ID,
                    Rating0        = a.Rating_0,
                    Rating1        = a.Rating_1,
                    Rating2        = a.Rating_2,
                    RatingNA       = a.Rate_NA,
                    Remark         = a.Remark,
                    UplloadPicture = a.Upload_Picture,
                    AuditItemLL    = _auditTypeDRepository.GetAuditItemLL(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    AuditItemEN    = _auditTypeDRepository.GetAuditItemEN(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    AuditItemZW    = _auditTypeDRepository.GetAuditItemZW(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    TypeDrating0   = _auditTypeDRepository.GetTypeDrating0(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    TypeDrating1   = _auditTypeDRepository.GetTypeDrating1(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    TypeDrating2   = _auditTypeDRepository.GetTypeDrating2(auditRateMModel.Audit_Type_ID, a.Audit_Item_ID),
                    oderby         = 0,
                    RatingDetail   = a.Rating_0 == 1?b.Rating_0.ToString():a.Rating_1 == 1?b.Rating_1.ToString():"NA",
                    //  RatingDetail =b.Rating_1
                }).ToListAsync();
                listAuditRateD = listAuditRateD.Select(x => {
                    x.oderby = (x.AuditItemId.Split(".")).Count() == 1?0:x.AuditItemId.Split(".")[1].ToInt();
                    return(x);
                }).ToList();
                listAuditRateD = listAuditRateD.OrderBy(x => x.AuditItemId.Split(".")[0].ToInt())
                                 .ThenBy(x => x.oderby).ToList();

                var dataRateMmodel = _mapper.Map <AuditRateMDto>(auditRateMModel);

                var dataUser = _mesUserRepository.FindAll().Where(x => x.User_ID.Trim() == dataRateMmodel.Updated_By.Trim()).Select(x => new {
                    user = x.User_ID + "_" + x.User_Name
                }).FirstOrDefault();
                dataRateMmodel.Line_ID_2_Name = _mesAuditOrgRepository.FindAll().Where(x => x.Line_ID_2.Trim() == dataRateMmodel.Line.Trim()).FirstOrDefault().Line_ID_2_Name;
                dataRateMmodel.PDC_Name       = _mesAuditOrgRepository.FindAll().Where(x => x.PDC_ID.Trim() == dataRateMmodel.PDC.Trim()).FirstOrDefault().PDC_Name;
                dataRateMmodel.Updated_By     = dataUser == null?dataRateMmodel.Updated_By:dataUser.user;
                result.auditRateM             = dataRateMmodel;
                result.listAuditRateD         = listAuditRateD;
            }
            return(result);
        }
Пример #2
0
        public async Task <PagedList <AuditRecDto> > GetAllAuditRecViewModel(PaginationParams param)
        {
            var listAuditRecM   = _repoM.FindAll();
            var listAuditRecD   = _repoD.FindAll();
            var listAuditMes    = _repoMes.FindAll(x => x.Status == 1);
            var listAuditRecDto = listAuditRecD.Join(listAuditRecM, x => x.Record_ID, y => y.Record_ID, (x, y) => new { x, y })
                                  .Join(listAuditMes, z => z.y.Line, t => t.Line_ID_2, (z, t)
                                        => new AuditRecDto
            {
                Record_ID      = z.x.Record_ID,
                Record_Time    = z.y.Record_Time,
                After_Picture  = z.x.After_Picture,
                Audit_Item     = z.x.Audit_Item,
                Audit_Type_ID  = z.x.Audit_Type_ID,
                Audit_Type     = (z.x == null || z.x.Audit_Type_ID == "") ? "" : _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type1 + "-" + _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type2,
                Before_Picture = z.x.Before_Picture,
                Finished_Date  = z.x.Finished_Date,
                ERCS           = z.x.ERCS,
                Implement_Time = z.x.Implement_Time,
                Implement_User = z.x.Implement_User,
                Issue_EN       = z.x.Issue_EN,
                Issue_LL       = z.x.Issue_LL,
                Issue_ZW       = z.x.Issue_ZW,
                Building       = z.y.Building,
                PDC            = z.y.PDC,
                Line           = z.y.Line,
                Line_Name      = t.Line_ID_2_Name,
                ME_PIC         = z.x.ME_PIC,
                Model_Name     = z.y.Model_Name,
                Model_No       = z.y.Model_No,
                Chief          = z.y.Chief,
                Recorder       = z.y.Recorder,
                Attendees      = z.y.Attendees,
                PD_PIC         = z.x.PD_PIC,
                PD_Department  = z.x.PD_Department,
                PD_Building    = z.x.PD_Building,
                Remark         = z.x.Remark,
                Status         = z.x.Status,
                Item_no        = z.x.Item_no,
                Updated_By     = z.x.Updated_By,
                Updated_Time   = z.x.Updated_Time,
            }).OrderBy(x => x.Audit_Type_ID);

            return(await PagedList <AuditRecDto> .CreateAsync(listAuditRecDto, param.PageNumber, param.PageSize));
        }
Пример #3
0
        public async Task <PagedList <SMEScoreRecordDto> > GetListSMEScoreRecord(PaginationParams paginationParams, ScoreRecordParam scoreRecordParam, bool isPaging = true)
        {
            //SME la gia tri fix cung
            var paramAuditTypeIdBySME = await _auditTypeMRepository.FindAll(x => x.Audit_Kind == "SME").Select(x => x.Audit_Type_ID).ToListAsync();

            var queryAuditRateD = _auditRateDRepository.FindAll();
            var queryAuditRateM = _auditRateMRepository.FindAll().Where(x => paramAuditTypeIdBySME.Contains(x.Audit_Type_ID));
            var listAuditMes    = _mesAuditOrg.FindAll(x => x.Status == 1);

            if (scoreRecordParam.PDC != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.PDC.Trim() == scoreRecordParam.PDC);
            }
            if (scoreRecordParam.Building != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Building.Trim() == scoreRecordParam.Building);
            }
            if (scoreRecordParam.Line != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Line.Trim() == scoreRecordParam.Line);
            }
            if (scoreRecordParam.AuditType1 != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Audit_Type1.Trim() == scoreRecordParam.AuditType1);
            }
            if (scoreRecordParam.AuditType2 != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Audit_Type2.Trim() == scoreRecordParam.AuditType2);
            }
            if (scoreRecordParam.FromDate != "" && scoreRecordParam.ToDate != "")
            {
                DateTime d1 = Convert.ToDateTime(scoreRecordParam.FromDate + " 00:00:00");
                DateTime d2 = Convert.ToDateTime(scoreRecordParam.ToDate + " 23:59:59");
                queryAuditRateM = queryAuditRateM.Where(x => x.Record_Date >= d1 && x.Record_Date <= d2);
            }

            var data = queryAuditRateM.Join(listAuditMes, x => x.Line, t => t.Line_ID_2, (x, t) => new SMEScoreRecordDto
            {
                RecordId          = x.Record_ID,
                AuditDate         = x.Record_Date,
                AuditType         = x.Audit_Type1,
                AuditType2        = x.Audit_Type2,
                LineId            = x.Line,
                Line_Name         = t.Line_ID_2_Name,
                UpdateBy          = x.Updated_By,
                UpdateTime        = x.Updated_Time,
                Rating0           = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID).Sum(z => z.Rating_0),
                Rating1           = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID).Sum(z => z.Rating_1),
                Rating2           = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID).Sum(z => z.Rating_2),
                RatingNa          = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID).Sum(z => z.Rate_NA) == null ? 0 : queryAuditRateD.Where(y => y.Record_ID == x.Record_ID).Sum(z => z.Rate_NA),
                CheckAnswerAllYet = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID && y.Rate_NA == 0 && y.Rating_0 == 0 && y.Rating_1 == 0 && y.Rating_2 == 0).Count() > 0 ? false : true
            }).OrderByDescending(x => x.UpdateTime);

            return(await PagedList <SMEScoreRecordDto> .CreateAsync(data, paginationParams.PageNumber,
                                                                    paginationParams.PageSize, isPaging));
        }
Пример #4
0
        public async Task <PagedList <WaterSpiderScoreRecordDto> > GetLisWaterSpiderScoreRecord(PaginationParams paginationParams, ScoreRecordParam scoreRecordParam, bool isPaging = true)
        {
            // WS là giá trị fix cứng
            var paramAuditTypeIdByWaterSpider = await _auditTypeMRepository.FindAll(x => x.Audit_Kind.Trim() == "WS").Select(x => x.Audit_Type_ID).ToListAsync();

            var queryAuditRateM = _auditRateMRepository.FindAll().Where(x => paramAuditTypeIdByWaterSpider.Contains(x.Audit_Type_ID));
            var queryAuditRateD = _auditRateDRepository.FindAll();
            var listAuditMes    = _mesAuditOrg.FindAll(x => x.Status == 1);

            if (scoreRecordParam.PDC != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.PDC.Trim() == scoreRecordParam.PDC);
            }
            if (scoreRecordParam.Building != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Building.Trim() == scoreRecordParam.Building);
            }
            if (scoreRecordParam.Line != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Line.Trim() == scoreRecordParam.Line);
            }
            if (scoreRecordParam.AuditType1 != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Audit_Type1.Trim() == scoreRecordParam.AuditType1);
            }
            if (scoreRecordParam.AuditType2 != "")
            {
                queryAuditRateM = queryAuditRateM.Where(x => x.Audit_Type2.Trim() == scoreRecordParam.AuditType2);
            }
            if (scoreRecordParam.FromDate != "" && scoreRecordParam.ToDate != "")
            {
                DateTime d1 = Convert.ToDateTime(scoreRecordParam.FromDate + " 00:00:00");
                DateTime d2 = Convert.ToDateTime(scoreRecordParam.ToDate + " 23:59:59");
                queryAuditRateM = queryAuditRateM.Where(x => x.Record_Date >= d1 && x.Record_Date <= d2);
            }

            var data = queryAuditRateM.Join(listAuditMes, x => x.Line, t => t.Line_ID_2, (x, t) =>
                                            new WaterSpiderScoreRecordDto
            {
                RecordId          = x.Record_ID,
                AuditType         = x.Audit_Type1,
                AuditDate         = x.Record_Date,
                LineId            = x.Line,
                Line_Name         = t.Line_ID_2_Name,
                Score             = _auditRateDRepository.SumEachRating1InAuditTypeDAndAuditRateD(x.Record_ID),
                Loss              = _auditRateDRepository.SumEachRating0InAuditTypeDAndAuditRateD(x.Record_ID),
                NA                = _auditRateDRepository.SumEachRatingNAInAuditTypeDAndAuditRateD(x.Record_ID),
                CheckAnswerAllYet = queryAuditRateD.Where(y => y.Record_ID == x.Record_ID && y.Rate_NA == 0 && y.Rating_0 == 0 && y.Rating_1 == 0 && y.Rating_2 == 0).Count() > 0 ? false : true
            });
            var result = data.Distinct().ToList();

            result = result.OrderByDescending(x => x.AuditDate).ToList();
            return(PagedList <WaterSpiderScoreRecordDto> .Create(result, paginationParams.PageNumber, paginationParams.PageSize, isPaging));
        }
Пример #5
0
        public async Task <SMEStaticChartDto> GetFactoryTree()
        {
            var dataQuery = await _iMesAuditrepo.FindAll(x => x.Status == 1 && x.PDC_ID != "6" &&
                                                         x.PDC_ID != "8" && x.PDC_ID != "C" && x.PDC_ID != "D" && x.PDC_ID != "G").ToListAsync();

            SMEStaticChartDto result = new SMEStaticChartDto();

            result.Factory = "SHC";
            var dataGroup = dataQuery.GroupBy(x => new { x.PDC_ID, x.PDC_Name });

            foreach (var itemPDC in dataGroup)
            {
                PDC pdc = new PDC();
                pdc.PDCName = itemPDC.Key.PDC_Name;
                pdc.PDC_ID  = itemPDC.Key.PDC_ID;
                var listBuilding = dataQuery.Where(x => x.PDC_ID == itemPDC.Key.PDC_ID).ToList()
                                   .GroupBy(x => new { Building = x.Building.Trim(), Building_Name = x.Building_Name.Trim() });
                listBuilding = listBuilding.OrderBy(x => x.Key.Building);
                if (listBuilding.Count() != 0)
                {
                    foreach (var itemBuilding in listBuilding)
                    {
                        Builing building = new Builing();
                        building.BuildingName = itemBuilding.Key.Building_Name;
                        building.Building     = itemBuilding.Key.Building;
                        var temp = itemBuilding.Where(x => x.Building.Trim() == itemBuilding.Key.Building && x.IsSME == true && x.Line_Seq > 0).OrderBy(x => x.Line_Seq).Select(x => new { Line_ID = x.Line_ID, Line_Name = x.Line_Name, Icon_Path = x.Icon_Path }).Distinct().ToList();
                        foreach (var itemLine in temp)
                        {
                            Line line = new Line();
                            line.Line_ID   = itemLine.Line_ID;
                            line.Line_Name = itemLine.Line_Name;
                            line.Icon_Path = itemLine.Icon_Path;
                            building.ListLine.Add(line);
                        }
                        pdc.ListBuilding.Add(building);
                    }
                    result.ListDept.Add(pdc);
                }
            }
            return(result);
        }
Пример #6
0
        public async Task <string> GetBuidingByID(string Building)
        {
            var data = await _mesAuditOrgRepository.FindAll(x => x.Building == Building).FirstOrDefaultAsync();

            var Name = Building;

            if (data != null)
            {
                Name = (data.Building_Name).ToString();
            }
            return(Name);
        }
Пример #7
0
        public async Task <string> GetBuildingByID(string building)
        {
            var data = await _repoOrg.FindAll(x => x.Building == building).FirstOrDefaultAsync();

            var Name = building;

            if (data != null)
            {
                Name = (data.Building_Name).ToString();
            }
            return(Name);
        }
Пример #8
0
        public async Task <object> GetAllLine()
        {
            var data = await _repoAuditRecM.FindAll().GroupBy(x => x.Line).Select(x => new{ line_id = x.Key }).ToListAsync();

            var mesAuditOrg = _orgRepository.FindAll().OrderBy(x => x.Line_Seq);
            var result      = data.Join(mesAuditOrg, x => x.line_id, y => y.Line_ID, (x, y)
                                        => new {
                id   = x.line_id,
                text = y.Line_Name
            });

            return(result.Distinct());
        }
Пример #9
0
        public async Task <ScoreRecordDetailDto> GetScoreRecoreDetail(string recordId)
        {
            var auditRateMModel         = _repoRateM.FindSingle(x => x.Record_ID.Trim() == recordId);
            ScoreRecordDetailDto result = new ScoreRecordDetailDto();

            if (auditRateMModel != null)
            {
                var listAuditRateDModel = _repoRateD.FindAll(x => x.Record_ID == auditRateMModel.Record_ID);
                var listAuditRateD      = await listAuditRateDModel.Select(x => new AuditRateDDetailDto
                {
                    RecordId      = x.Record_ID,
                    AuditItemId   = x.Audit_Item_ID,
                    Rating0       = x.Rating_0,
                    Rating1       = x.Rating_1,
                    Rating2       = x.Rating_2,
                    RatingNA      = x.Rate_NA,
                    Remark        = x.Remark,
                    UploadPicture = x.Upload_Picture,
                    AuditItemLL   = _repoTypeD.GetAuditItemLL(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    AuditItemEN   = _repoTypeD.GetAuditItemEN(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    AuditItemZW   = _repoTypeD.GetAuditItemZW(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    TypeDrating0  = _repoTypeD.GetTypeDrating0(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    TypeDrating1  = _repoTypeD.GetTypeDrating1(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    TypeDrating2  = _repoTypeD.GetTypeDrating2(auditRateMModel.Audit_Type_ID, x.Audit_Item_ID),
                    oderby        = 0
                }).ToListAsync();

                listAuditRateD = listAuditRateD.Select(x =>
                {
                    x.oderby = (x.AuditItemId.Split(".")).Count() == 1 ? 0 : x.AuditItemId.Split(".")[1].ToInt();
                    return(x);
                }).ToList();
                listAuditRateD = listAuditRateD.OrderBy(x => x.AuditItemId.Split(".")[0].ToInt()).ThenBy(x => x.oderby).ToList();

                var dataRateMmodel = _mapper.Map <AuditRateMDto>(auditRateMModel);

                var dataUser = _repoMesUser.FindAll(x => x.User_ID.Trim() == dataRateMmodel.Updated_By.Trim()).Select(x => new
                {
                    user = x.User_ID + "_" + x.User_Name
                }).FirstOrDefault();
                dataRateMmodel.Line_ID_2_Name = _repoMesAuditOrg.FindAll(x => x.Line_ID_2.Trim() == dataRateMmodel.Line.Trim()).FirstOrDefault().Line_ID_2_Name;
                dataRateMmodel.Updated_By     = dataUser == null ? dataRateMmodel.Updated_By : dataUser.user;
                result.auditRateM             = dataRateMmodel;
                result.listAuditRateD         = listAuditRateD;
            }
            return(result);
        }
Пример #10
0
        public async Task <object> GetAllBuilding(string pdc)
        {
            var queryData = _mesAuditOrgRepository.FindAll().Where(x => x.Status == 1);

            if (!String.IsNullOrEmpty(pdc))
            {
                queryData = queryData.Where(x => x.PDC_ID.Trim() == pdc.Trim());
            }

            return(await queryData.GroupBy(x => new { x.Building, x.Building_Name }).Select(x => new { Id = x.Key.Building, Name = x.Key.Building_Name }).ToListAsync());
        }
Пример #11
0
        public async Task <PagedList <AuditRecDto> > SearchByModel(PaginationParams param, AuditRecSearch model)
        {
            var listAuditRecM   = _repoAuditRecM.FindAll();
            var listAuditRecD   = _repoAuditRecD.FindAll();
            var listAuditMes    = _mesAuditOrg.FindAll().Where(x => x.Status == 1);
            var listAuditRecDto = listAuditRecD.Join(listAuditRecM, x => x.Record_ID, y => y.Record_ID, (x, y) => new { x, y }).Join(listAuditMes, z => z.y.Line, t => t.Line_ID_2, (z, t) => new AuditRecDto
            {
                Record_ID      = z.x.Record_ID,
                Record_Time    = z.y.Record_Time,
                After_Picture  = z.x.After_Picture,
                Audit_Item     = z.x.Audit_Item,
                Audit_Type_ID  = z.x.Audit_Type_ID,
                Audit_Type     = z.x.Audit_Type_ID == null || z.x.Audit_Type_ID == "" ? "" : _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type1 + "-" + _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type2,
                Before_Picture = z.x.Before_Picture,
                Finished_Date  = z.x.Finished_Date,
                ERCS           = z.x.ERCS,
                Implement_Time = z.x.Implement_Time,
                Implement_User = z.x.Implement_User,
                Issue_EN       = z.x.Issue_EN,
                Issue_LL       = z.x.Issue_LL,
                Issue_ZW       = z.x.Issue_ZW,
                Building       = z.y.Building,
                PDC            = z.y.PDC,
                Line           = z.y.Line,
                Line_Name      = t.Line_ID_2_Name,
                ME_PIC         = z.x.ME_PIC,
                Model_Name     = z.y.Model_Name,
                Model_No       = z.y.Model_No,
                Chief          = z.y.Chief,
                Recorder       = z.y.Recorder,
                Attendees      = z.y.Attendees,
                PD_PIC         = z.x.PD_PIC,
                PD_Department  = z.x.PD_Department,
                PD_Building    = z.x.PD_Building,
                Remark         = z.x.Remark,
                Status         = z.x.Status,
                Item_no        = z.x.Item_no,
                Updated_By     = z.x.Updated_By,
                Updated_Time   = z.x.Updated_Time
            }).ToList();

            if (model.Status != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Status.Trim() == model.Status.Trim()).ToList();
            }
            if (model.Building != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Building.Trim() == model.Building.Trim()).ToList();
            }
            if (model.Line != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Line.Trim() == model.Line.Trim()).ToList();
            }
            if (model.PDC != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.PDC.Trim() == model.PDC.Trim()).ToList();
            }
            if (model.Model_No != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Model_No.Trim() == model.Model_No.Trim()).ToList();
            }
            if (model.Model_Name != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Model_Name.Trim() == model.Model_Name.Trim()).ToList();
            }
            if (model.Audit_Type_1 != "")
            {
                var auditTypeMFind = await _repoAuditTypeM.FindAll(x => x.Audit_Type1.Trim() == model.Audit_Type_1.Trim() && x.Audit_Type2.Trim() == model.Audit_Type_2.Trim()).FirstOrDefaultAsync();

                listAuditRecDto = listAuditRecDto.Where(x => x.Audit_Type_ID.Trim() == auditTypeMFind.Audit_Type_ID).ToList();
            }
            listAuditRecDto = listAuditRecDto.Select(
                x =>
            {
                x.ME_PIC_Name = GetMePicByID(x.ME_PIC);
                x.PD_PIC      = GetPdPicByID(x.PD_PIC);
                return(x);
            }).OrderByDescending(x => x.Record_Time).ThenBy(x => x.Item_no).ToList();
            return(PagedList <AuditRecDto> .Create(listAuditRecDto, param.PageNumber, param.PageSize));
        }
Пример #12
0
 public async Task <object> GetAllPDC()
 {
     return(await _mesAuditOrgRepository.FindAll(x => x.Status == 1).GroupBy(x => new { x.PDC_ID, x.PDC_Name }).Select(x => new { Id = x.Key.PDC_ID, Name = x.Key.PDC_Name }).ToListAsync());
 }
Пример #13
0
        public async Task <PagedList <AuditRecDto> > GetAllAuditRecViewModel(PaginationParams param)
        {
            var listAuditRecM = _repoAuditRecM.FindAll();
            var listAuditRecD = _repoAuditRecD.FindAll();
            var listAuditMes  = _mesAuditOrg.FindAll().Where(x => x.Status == 1);
            // var listAuditRecDto =  (from b in listAuditRecD
            //                         join a in listAuditRecM on b.Record_ID equals a.Record_ID into c
            //                         from m in c.DefaultIfEmpty()
            //                         select new AuditRecDto()
            //                         {
            //                             Record_ID = m.Record_ID, Record_Time = m.Record_Time,
            //                             Line = m.Line, Model_Name = m.Model_Name,
            //                             Model_No = m.Model_No, Item_no = b.Item_no,
            //                             Status = b.Status, ERCS = b.ERCS,
            //                             //Audit_Type_ID = b.Audit_Type_ID,
            //                             Audit_Type_ID = _repoAuditTypeM.FindById(b.Audit_Type_ID.ToString()).Audit_Type1,
            //                             Audit_Item = b.Audit_Item, Issue_ZW = b.Issue_ZW,
            //                             Issue_LL = b.Issue_LL, Issue_EN = b.Issue_EN,
            //                             Before_Picture = b.Before_Picture, After_Picture = b.After_Picture,
            //                             PD_PIC = b.PD_PIC, PD_RESP = b.PD_RESP,
            //                             ME_PIC = b.ME_PIC, Finished_Date = b.Finished_Date,
            //                             Implement_User = b.Implement_User,Implement_Time = b.Implement_Time
            //                         }).Distinct().OrderByDescending(x => x.Implement_Time);
            var listAuditRecDto = listAuditRecD.Join(listAuditRecM, x => x.Record_ID, y => y.Record_ID, (x, y) => new { x, y })
                                  .Join(listAuditMes, z => z.y.Line, t => t.Line_ID_2, (z, t)
                                        => new AuditRecDto
            {
                Record_ID      = z.x.Record_ID,
                Record_Time    = z.y.Record_Time,
                After_Picture  = z.x.After_Picture,
                Audit_Item     = z.x.Audit_Item,
                Audit_Type_ID  = z.x.Audit_Type_ID,
                Audit_Type     = z.x.Audit_Type_ID == null || z.x.Audit_Type_ID == "" ? "" : _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type1 + "-" + _repoAuditTypeM.FindById(z.x.Audit_Type_ID).Audit_Type2,
                Before_Picture = z.x.Before_Picture,
                Finished_Date  = z.x.Finished_Date,
                ERCS           = z.x.ERCS,
                Implement_Time = z.x.Implement_Time,
                Implement_User = z.x.Implement_User,
                Issue_EN       = z.x.Issue_EN,
                Issue_LL       = z.x.Issue_LL,
                Issue_ZW       = z.x.Issue_ZW,
                Building       = z.y.Building,
                PDC            = z.y.PDC,
                Line           = z.y.Line,
                Line_Name      = t.Line_ID_2_Name,
                ME_PIC         = z.x.ME_PIC,
                Model_Name     = z.y.Model_Name,
                Model_No       = z.y.Model_No,
                Chief          = z.y.Chief,
                Recorder       = z.y.Recorder,
                Attendees      = z.y.Attendees,
                PD_PIC         = z.x.PD_PIC,
                PD_Department  = z.x.PD_Department,
                PD_Building    = z.x.PD_Building,
                Remark         = z.x.Remark,
                Status         = z.x.Status,
                Item_no        = z.x.Item_no,
                Updated_By     = z.x.Updated_By,
                Updated_Time   = z.y.Updated_Time
            });

            return(await PagedList <AuditRecDto> .CreateAsync(listAuditRecDto, param.PageNumber, param.PageSize));
        }
Пример #14
0
        public async Task <List <AuditRecDto> > SearchExcel(AuditRecSearch model)
        {
            var auditTypeMs = await _repoAuditTypeM.GetAll().ToListAsync();

            var listAuditRecM   = _repoAuditRecM.FindAll();
            var listAuditRecD   = _repoAuditRecD.FindAll();
            var listAuditOrg    = _mesAuditOrg.FindAll().Where(x => x.Status == 1);
            var listAuditRecDto = await listAuditRecD.Join(listAuditRecM, x => x.Record_ID, y => y.Record_ID, (x, y)
                                                           => new AuditRecDto
            {
                Record_ID      = x.Record_ID,
                Record_Time    = y.Record_Time,
                After_Picture  = x.After_Picture,
                Audit_Item     = x.Audit_Item,
                Audit_Type_ID  = x.Audit_Type_ID,
                Audit_Type     = x.Audit_Type_ID == null || x.Audit_Type_ID == "" ? "" : _repoAuditTypeM.FindById(x.Audit_Type_ID).Audit_Type1 + "-" + _repoAuditTypeM.FindById(x.Audit_Type_ID).Audit_Type2,
                Before_Picture = x.Before_Picture,
                Finished_Date  = x.Finished_Date,
                ERCS           = x.ERCS,
                Implement_Time = x.Implement_Time,
                Implement_User = x.Implement_User,
                Issue_EN       = x.Issue_EN,
                Issue_LL       = x.Issue_LL,
                Issue_ZW       = x.Issue_ZW,
                PDC            = y.PDC,
                PDC_Name       = listAuditOrg.Where(t => t.PDC_ID == y.PDC).FirstOrDefault().PDC_Name,
                Line           = y.Line,
                Building       = y.Building,
                ME_PIC         = x.ME_PIC,
                Model_Name     = y.Model_Name,
                Model_No       = y.Model_No,
                Chief          = y.Chief,
                Recorder       = y.Recorder,
                Attendees      = y.Attendees,
                PD_PIC         = x.PD_PIC,
                PD_Department  = x.PD_Department,
                PD_Building    = x.PD_Building,
                Remark         = x.Remark,
                Status         = x.Status,
                Item_no        = x.Item_no,
                Updated_By     = x.Updated_By,
                Updated_Time   = x.Updated_Time
            }).ToListAsync();

            listAuditRecDto = listAuditRecDto.Select(x => {
                x.ME_PIC = GetMePicByID(x.ME_PIC);
                x.PD_PIC = GetPdPicByID(x.PD_PIC);
                return(x);
            }).ToList();

            if (model.Status != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Status.Trim() == model.Status.Trim()).ToList();
            }
            if (model.Line != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Line.Trim() == model.Line.Trim()).ToList();
            }
            if (model.From_Date != "" && model.To_Date != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Record_Time >= Convert.ToDateTime(model.From_Date + " 00:00") &&
                                                        x.Record_Time <= Convert.ToDateTime(model.To_Date + " 00:00")).ToList();
            }
            if (model.Model_No != "")
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Model_No.Trim() == model.Model_No.Trim()).ToList();
            }
            if (model.Model_Name != "" && model.Model_Name != string.Empty && model.Model_Name != null)
            {
                listAuditRecDto = listAuditRecDto.Where(x => x.Model_Name.Contains(model.Model_Name)).ToList();
            }
            if (model.Audit_Type_1 != "")
            {
                //  Lấy AuditTypeM Có Version lớn nhất
                var auditTypeM        = auditTypeMs.Where(x => x.Audit_Type_ID.Trim() == model.Audit_Type_1.Trim()).FirstOrDefault();
                var auditTypeMVersion = auditTypeMs.Where(x => x.Audit_Kind == auditTypeM.Audit_Kind &&
                                                          x.Audit_Type1 == auditTypeM.Audit_Type1 &&
                                                          x.Audit_Type2 == auditTypeM.Audit_Type2)
                                        .OrderByDescending(x => x.Version).FirstOrDefault();
                listAuditRecDto = listAuditRecDto.Where(x => x.Audit_Type_ID.Trim() == auditTypeMVersion.Audit_Type_ID).ToList();
            }
            return(listAuditRecDto);
        }