| | |
| | | public async Task<SqlSugarPagedList<ProcurementComplaintOutput>> Page(PageProcurementComplaintInput input) |
| | | { |
| | | input.Keyword = input.Keyword?.Trim(); |
| | | var query = _procurementComplaintRep.AsQueryable() |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.ProjectCode.Contains(input.Keyword) || u.ProjectName.Contains(input.Keyword) || u.Purchaser.Contains(input.Keyword) || u.ProcurementAgency.Contains(input.Keyword) || u.Complainant.Contains(input.Keyword) || u.ProcurementSupervisionDepartment.Contains(input.Keyword) || u.Url.Contains(input.Keyword)) |
| | | var query = _procurementComplaintRep.AsQueryable().Includes(x=>x.Complaints) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Keyword), u => u.Complaints.Any(uu=>uu.ItemDescription.Contains(input.Keyword))) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.ProjectCode), u => u.ProjectCode.Contains(input.ProjectCode.Trim())) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.ProjectName), u => u.ProjectName.Contains(input.ProjectName.Trim())) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(input.Purchaser), u => u.Purchaser.Contains(input.Purchaser.Trim())) |
| | |
| | | [ApiDescriptionSettings(Name = "Detail"), HttpGet] |
| | | public async Task<ProcurementComplaint> Detail([FromQuery] QueryByIdProcurementComplaintInput input) |
| | | { |
| | | return await _procurementComplaintRep.GetFirstAsync(u => u.Id == input.Id); |
| | | |
| | | return await _procurementComplaintRep.AsQueryable().Where(x=>x.Id==input.Id).Includes(x=>x.Complaints.OrderBy(xx=>xx.sort).ToList()).FirstAsync(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | var entity = input.Adapt<ProcurementComplaint>(); |
| | | entity.Id = Guid.NewGuid(); |
| | | int index = 0; |
| | | if (entity.Complaints != null) |
| | | foreach (var item in entity.Complaints) |
| | | { |
| | | item.Id = Guid.NewGuid(); |
| | | item.sort = index++; |
| | | } |
| | | |
| | | return await _sqlSugarClient.InsertNav(entity).Include(x=>x.Complaints).ExecuteCommandAsync(); |
| | | } |
| | |
| | | public async Task Update(UpdateProcurementComplaintInput input) |
| | | { |
| | | var entity = input.Adapt<ProcurementComplaint>(); |
| | | await _procurementComplaintRep.AsUpdateable(entity) |
| | | int index = 0; |
| | | if(entity.Complaints!=null) |
| | | foreach (var item in entity.Complaints) |
| | | { |
| | | item.Id = Guid.NewGuid(); |
| | | item.sort= index++; |
| | | } |
| | | await _procurementComplaintRep.AsSugarClient().UpdateNav(entity).Include(x=>x.Complaints) |
| | | .ExecuteCommandAsync(); |
| | | } |
| | | |
| | |
| | | /// 导入政府采购投诉数据处理记录 💾 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [DisplayName("导入政府采购投诉数据处理记录")] |
| | | [ApiDescriptionSettings(Name = "Import"), HttpPost, NonUnify, UnitOfWork] |
| | | public IActionResult ImportData([Required] IFormFile file) |
| | | { |
| | | lock (_procurementComplaintImportLock) |
| | | { |
| | | var stream = ExcelHelper.ImportData<ImportProcurementComplaintInput, ProcurementComplaint>(file, (list, markerErrorAction) => |
| | | { |
| | | _sqlSugarClient.Utilities.PageEach(list, 2048, pageItems => |
| | | { |
| | | //[DisplayName("导入政府采购投诉数据处理记录")] |
| | | //[ApiDescriptionSettings(Name = "Import"), HttpPost, NonUnify, UnitOfWork] |
| | | //public IActionResult ImportData([Required] IFormFile file) |
| | | //{ |
| | | // lock (_procurementComplaintImportLock) |
| | | // { |
| | | // var stream = ExcelHelper.ImportData<ImportProcurementComplaintInput, ProcurementComplaint>(file, (list, markerErrorAction) => |
| | | // { |
| | | // _sqlSugarClient.Utilities.PageEach(list, 2048, pageItems => |
| | | // { |
| | | |
| | | // 校验并过滤必填基本类型为null的字段 |
| | | var rows = pageItems.Where(x => { |
| | | return true; |
| | | }).Adapt<List<ProcurementComplaint>>(); |
| | | // // 校验并过滤必填基本类型为null的字段 |
| | | // var rows = pageItems.Where(x => { |
| | | // return true; |
| | | // }).Adapt<List<ProcurementComplaint>>(); |
| | | |
| | | var storageable = _procurementComplaintRep.Context.Storageable(rows) |
| | | .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProjectCode), "项目编号不能为空") |
| | | .SplitError(it => it.Item.ProjectCode?.Length > 50, "项目编号长度不能超过50个字符") |
| | | .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProjectName), "项目名称不能为空") |
| | | .SplitError(it => it.Item.ProjectName?.Length > 200, "项目名称长度不能超过200个字符") |
| | | .SplitError(it => string.IsNullOrWhiteSpace(it.Item.Purchaser), "采购人不能为空") |
| | | .SplitError(it => it.Item.Purchaser?.Length > 100, "采购人长度不能超过100个字符") |
| | | .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProcurementAgency), "采购代理机构不能为空") |
| | | .SplitError(it => it.Item.ProcurementAgency?.Length > 100, "采购代理机构长度不能超过100个字符") |
| | | .SplitError(it => it.Item.Complainant?.Length > 100, "投诉人长度不能超过100个字符") |
| | | .SplitError(it => it.Item.ProcurementSupervisionDepartment?.Length > 100, "采购监督部门长度不能超过100个字符") |
| | | .SplitError(it => it.Item.Url?.Length > 255, "线上地址长度不能超过255个字符") |
| | | .SplitInsert(_ => true) |
| | | .ToStorage(); |
| | | // var storageable = _procurementComplaintRep.Context.Storageable(rows) |
| | | // .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProjectCode), "项目编号不能为空") |
| | | // .SplitError(it => it.Item.ProjectCode?.Length > 50, "项目编号长度不能超过50个字符") |
| | | // .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProjectName), "项目名称不能为空") |
| | | // .SplitError(it => it.Item.ProjectName?.Length > 200, "项目名称长度不能超过200个字符") |
| | | // .SplitError(it => string.IsNullOrWhiteSpace(it.Item.Purchaser), "采购人不能为空") |
| | | // .SplitError(it => it.Item.Purchaser?.Length > 100, "采购人长度不能超过100个字符") |
| | | // .SplitError(it => string.IsNullOrWhiteSpace(it.Item.ProcurementAgency), "采购代理机构不能为空") |
| | | // .SplitError(it => it.Item.ProcurementAgency?.Length > 100, "采购代理机构长度不能超过100个字符") |
| | | // .SplitError(it => it.Item.Complainant?.Length > 100, "投诉人长度不能超过100个字符") |
| | | // .SplitError(it => it.Item.ProcurementSupervisionDepartment?.Length > 100, "采购监督部门长度不能超过100个字符") |
| | | // .SplitError(it => it.Item.Url?.Length > 255, "线上地址长度不能超过255个字符") |
| | | // .SplitInsert(_ => true) |
| | | // .ToStorage(); |
| | | |
| | | storageable.AsInsertable.ExecuteCommand();// 不存在插入 |
| | | storageable.AsUpdateable.ExecuteCommand();// 存在更新 |
| | | // storageable.AsInsertable.ExecuteCommand();// 不存在插入 |
| | | // storageable.AsUpdateable.ExecuteCommand();// 存在更新 |
| | | |
| | | // 标记错误信息 |
| | | markerErrorAction.Invoke(storageable, pageItems, rows); |
| | | }); |
| | | }); |
| | | // // 标记错误信息 |
| | | // markerErrorAction.Invoke(storageable, pageItems, rows); |
| | | // }); |
| | | // }); |
| | | |
| | | return stream; |
| | | } |
| | | } |
| | | // return stream; |
| | | // } |
| | | //} |
| | | } |