Ejemplo n.º 1
0
        public async Task <List <AuditRecDDto> > GetAllAsync()
        {
            var lists = await _repoAuditRecD.FindAll().ProjectTo <AuditRecDDto>(_configMapper)
                        .OrderByDescending(x => x.Updated_Time).ToListAsync();

            return(lists);
        }
Ejemplo n.º 2
0
 public async Task <List <string> > GetAllStatus()
 {
     return(await _repoAuditRecD.FindAll().GroupBy(x => x.Status).Select(x => x.Key).ToListAsync());
 }
Ejemplo n.º 3
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);
        }