using DocumentFormat.OpenXml.Office.CoverPageProps; using Hotline.Application.Bulletin; using Hotline.Application.Identity; using Hotline.Application.Orders; using Hotline.Article; using Hotline.Caching.Interfaces; using Hotline.Configurations; using Hotline.KnowledgeBase; using Hotline.Orders; using Hotline.Repository.SqlSugar.Extensions; using Hotline.Settings; using Hotline.Settings.Hotspots; using Hotline.Share.Dtos; using Hotline.Share.Dtos.Identity; using Hotline.Share.Dtos.Schedulings; using Hotline.Share.Dtos.WebPortal; using Hotline.Share.Enums.KnowledgeBase; using Hotline.Share.Enums.Order; using Hotline.Tools; using Hotline.Users; using Hotline.WebPortal; using MapsterMapper; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using NPOI.XWPF.UserModel; using SqlSugar; using XF.Domain.Authentications; using XF.Domain.Cache; using XF.Domain.Filters; using XF.Domain.Repository; namespace Hotline.Api.Controllers { public class FwThirdController : BaseController { #region 注入 private readonly IMapper _mapper; private readonly IMediator _mediator; private readonly IRepository _bulletinRepository; private readonly IRepository _webUserRegisterRepository; private readonly IRepository _webUserAuthRepository; private readonly IRepository _webFlowAcceptRepository; private readonly ITypedCache _writeLettersSendSms; private readonly IRepository _hotspotRepository; private readonly ISystemSettingCacheManager _systemSettingCacheManager; private readonly IRepository _orderPublishRepository; private readonly IOrderRepository _orderRepository; private readonly IRepository _orderVisitRepository; private readonly IRepository _orderListRepository; private readonly IRepository _userRepository; private readonly IOrderApplication _orderApplication; private readonly ISessionContext _sessionContext; private readonly IRepository _orderVisitDetailRepository; private readonly IBulletinApplication _bulletinApplication; private readonly IRepository _oldPublicDataRepository; private readonly IRepository _knowledgeTypeRepository; private readonly IRepository _knowledgeRepository; private readonly ISystemDicDataCacheManager _systemDicDataCacheManager; private readonly IOptionsSnapshot _appOptions; private readonly ITypedCache _getVailData; private readonly IRepository _knowledgeWordRepository; private readonly ISystemDicDataCacheManager _sysDicDataCacheManager; private readonly IIdentityAppService _identityAppService; private readonly IHttpClientFactory _httpClientFactory; public FwThirdController(IMapper mapper, IMediator mediator, IRepository bulletinRepository, IRepository webUserRegisterRepository, IRepository webUserAuthRepository, IRepository webFlowAcceptRepository, ITypedCache writeLettersSendSms, IRepository hotspotRepository, ISystemSettingCacheManager systemSettingCacheManager, IRepository orderPublishRepository, IOrderRepository orderRepository, IRepository orderVisitRepository, IRepository orderListRepository, IRepository userRepository, IOrderApplication orderApplication, ISessionContext sessionContext, IRepository orderVisitDetailRepository, IBulletinApplication bulletinApplication, IRepository oldPublicDataRepository, IRepository knowledgeTypeRepository, IRepository knowledgeRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IOptionsSnapshot appOptions, ITypedCache getVailData, IRepository knowledgeWordRepository, ISystemDicDataCacheManager sysDicDataCacheManager, IIdentityAppService identityAppService, IHttpClientFactory httpClientFactory ) { _mapper = mapper; _mediator = mediator; _bulletinRepository = bulletinRepository; _webUserRegisterRepository = webUserRegisterRepository; _webUserAuthRepository = webUserAuthRepository; _webFlowAcceptRepository = webFlowAcceptRepository; _writeLettersSendSms = writeLettersSendSms; _hotspotRepository = hotspotRepository; _systemSettingCacheManager = systemSettingCacheManager; _orderPublishRepository = orderPublishRepository; _orderRepository = orderRepository; _orderVisitRepository = orderVisitRepository; _userRepository = userRepository; _orderListRepository = orderListRepository; _orderApplication = orderApplication; _sessionContext = sessionContext; _orderVisitDetailRepository = orderVisitDetailRepository; _bulletinApplication = bulletinApplication; _oldPublicDataRepository = oldPublicDataRepository; _knowledgeTypeRepository = knowledgeTypeRepository; _knowledgeRepository = knowledgeRepository; _systemDicDataCacheManager = systemDicDataCacheManager; _appOptions = appOptions; _getVailData = getVailData; _knowledgeWordRepository = knowledgeWordRepository; _sysDicDataCacheManager = sysDicDataCacheManager; _identityAppService = identityAppService; _httpClientFactory = httpClientFactory; } #endregion #region 获取Token [AllowAnonymous] [HttpPost("gettoken")] public async Task LoginWithoutCrypt([FromBody] LoginDto dto) { return await _identityAppService.LoginAsync(dto, HttpContext.RequestAborted); } #endregion #region 自贡门户查询接口 #region 受理统计 /// getacceptancetypestatisticsbymonth /// 受理统计 /// /// /// [HttpPost("getacceptancetypestatisticsbymonth")] public async Task> GetAcceptanceTypeStatisticsByMonth([FromBody] OrderFormByMonthDto dto) { if (string.IsNullOrEmpty(dto.StartTime)) dto.StartTime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); if (string.IsNullOrEmpty(dto.EndTime)) dto.EndTime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59"); //查询待 var listType = await _orderRepository.Queryable() .Where(p => p.CreationTime >= Convert.ToDateTime(dto.StartTime) && p.CreationTime <= Convert.ToDateTime(dto.EndTime) && p.Status > EOrderStatus.WaitForAccept) .Select(it => new { it.AcceptType, it.AcceptTypeCode }) .MergeTable()//将查询出来的结果合并成一个新表 .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组 .Select(it => new { name = it.AcceptType, value = SqlFunc.AggregateCount(it.AcceptTypeCode) }) .ToListAsync(); var formAcceptanceCount = _mapper.Map>(listType); if (_appOptions.Value.IsZiGong) { List orderForms = new List(); List fromName = ["咨询", "投诉", "求助", "建议", "举报", "表扬", "申报"]; foreach (var form in fromName) { var data = formAcceptanceCount.FirstOrDefault(p => p.name == form); orderForms.Add(new OrderFormCount() { name = form, value = data == null ? 0 : data.value }); } return orderForms; } return formAcceptanceCount; } #endregion #region 办理统计 /// /// 办理统计 /// /// /// [HttpPost("getacceptancetypestatisticsbymonthend")] public async Task> GetAcceptanceTypeStatisticsByMonthEnd([FromBody] OrderFormByMonthDto dto) { if (string.IsNullOrEmpty(dto.StartTime)) dto.StartTime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"); if (string.IsNullOrEmpty(dto.EndTime)) dto.EndTime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59"); //数据查询 var listFileType = await _orderRepository.Queryable() .Where(p => p.FiledTime >= Convert.ToDateTime(dto.StartTime) && p.FiledTime <= Convert.ToDateTime(dto.EndTime) && p.Status >= EOrderStatus.Visited) .Select(it => new { it.AcceptType, it.AcceptTypeCode }) .MergeTable()//将查询出来的结果合并成一个新表 .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组 .Select(it => new { name = it.AcceptType, value = SqlFunc.AggregateCount(it.AcceptTypeCode) }) .ToListAsync(); var formFileCount = _mapper.Map>(listFileType); if (_appOptions.Value.IsZiGong) { List orderForms = new List(); List fromName = ["咨询", "投诉", "求助", "建议", "举报", "表扬", "申报"]; foreach (var form in fromName) { var data = formFileCount.FirstOrDefault(p => p.name == form); orderForms.Add(new OrderFormCount() { name = form, value = data == null ? 0 : data.value }); } return orderForms; } return formFileCount; } #endregion #region 公告通知、工作简报 /// /// 公告通知、工作简报 /// /// /// [HttpPost("getarticlelistbynum")] public async Task> GetArticleListByNum([FromBody] ArticleIdByNumDto dto) { if (string.IsNullOrEmpty(dto.PushRanges)) dto.PushRanges = "2"; var items = await _bulletinRepository.Queryable() .Where(p => p.LoseEfficacyTime >= DateTime.Now) .Where(p => p.IsArrive == true) .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges)) // .Where(p => p.BulletinTypeId == dto.BulletinTypeId) .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), p => p.BulletinTypeId == dto.BulletinTypeId) .WhereIF(!string.IsNullOrEmpty(dto.CheckChar), p => p.Content.Contains(dto.CheckChar)) .WhereIF(!string.IsNullOrEmpty(dto.BulletinDisplayLocation), p => SqlFunc.JsonListObjectAny(p.DisplayLocation, "Key", dto.BulletinDisplayLocation)) .OrderByDescending(p => p.CreationTime) .Select(it => new { DataID = it.Id, it.Title, CreateDate = it.CreationTime, it.Content, it.BulletinTypeName }) .Take(dto.Num) .ToListAsync(); return _mapper.Map>(items); } /// /// 公告通知、工作简报详情 /// /// /// [HttpPost("getarticledetails")] public async Task> GetArticleDetails([FromBody] ArticleIdDto dto) { var data = await _bulletinRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted); ArticleDetailsDto detailsDto = null; if (data != null) { data.ReadedNum = data.ReadedNum++; await _bulletinRepository.UpdateAsync(data, HttpContext.RequestAborted); detailsDto = new() { NoticeID = data.Id, NoticeTypeName = data.BulletinTypeName, NoticeTitle = data.Title, NoticeBMName = data.SourceOrgName, NoticeCreateDate = data.CreationTime, NoticeRCount = data.ReadedNum, WNED_VideoUrl = "", NoticeContent = data.Content }; if (data != null && !string.IsNullOrEmpty(data.Content)) data.Content = _bulletinApplication.GetSiteUrls(data.Content); } else detailsDto = new(); List dataDto = new() { detailsDto }; return dataDto; } #endregion #region 信件选登 /// /// 查询工单发布后公开的数据 /// /// /// [HttpPost("get_order_list_publish_all")] public async Task GetOrderByListAllOpen([FromBody] QueryOrderListDto dto) { var queryNew = _orderPublishRepository.Queryable() .LeftJoin((op, p) => p.Id == op.OrderId) .Where((op, p) => op.PublishState == true) .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), (op, p) => p.No == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), (op, p) => op.ArrangeTitle.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), (op, p) => p.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), (op, p) => p.HotspotId == dto.FlowRType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), (op, p) => p.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), (op, p) => p.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), (op, p) => p.FromName.Contains(dto.FlowFrom)) .WhereIF(dto.IdentityType.HasValue, (op, p) => p.IdentityType == dto.IdentityType) .OrderByDescending((op, p) => p.CreationTime) .Select((op, p) => new OrderListDto { FlowID = p.Id, FlowCode = p.No, FlowPwd = p.Password, FlowTitle = op.ArrangeTitle, FlowFromName = p.SourceChannel, FlowPurTypeName = p.AcceptType, ConTypeName = p.HotspotName, FlowAddDate = p.CreationTime, PubDate = op.CreationTime, RSFlagName = p.Status >= EOrderStatus.Filed ? "办理完成" : "办理中" }); var queryold = _oldPublicDataRepository.Queryable() .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), p => p.OrderNo == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), p => p.Title.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), p => p.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), p => p.HotspotId == dto.FlowRType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), p => p.AcceptTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), p => p.AcceptTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), p => p.FromName.Contains(dto.FlowFrom)) .WhereIF(dto.IdentityType.HasValue, p => p.IdentityType == dto.IdentityType) .OrderByDescending(p => p.PubDate) .Select(p => new OrderListDto { FlowID = p.OrderId, FlowCode = p.OrderNo, FlowPwd = p.OrderPwd, FlowTitle = p.Title, FlowFromName = p.SourceChannelCode, FlowPurTypeName = p.AcceptTypeCode, ConTypeName = p.HotspotName, FlowAddDate = p.CreationTime, PubDate = p.CreationTime, RSFlagName = p.State == "1" ? "办理完成" : "办理中" }); var (total, items) = await _orderRepository.UnionAll(queryNew, queryold) .OrderByDescending(p => p.PubDate) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); OrderListReturnDto returnDto = new() { Total = total, PageNum = dto.PageIndex, PageCount = nPageCount, Data = _mapper.Map>(items) }; return returnDto; } /// /// 办件摘编详情 /// /// /// [HttpPost("getorderdetailbyid")] public async Task GetOrderDetailById([FromBody] ArticleIdDto dto) { var data = await _orderRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted); var orderDetail = _mapper.Map(data); if (data != null) { //如果是省工单或者是省政民互动的工单,市民不能进行评价 if (data.IsProvince == true || data.SourceChannelCode == "ZMHD") orderDetail.IsProvinceOrder = "1"; else orderDetail.IsProvinceOrder = "0"; //获取发布的数据 var orderPublish = await _orderPublishRepository.GetAsync(p => p.OrderId == data.Id, HttpContext.RequestAborted); if (orderPublish != null) { orderDetail.PubFlag = "1"; orderDetail.FlowTitle = orderPublish.ArrangeTitle; orderDetail.FlowContent = orderPublish.ArrangeContent; orderDetail.FlowResult = orderPublish.ArrangeOpinion; if (orderPublish.PublishState) orderDetail.FlowPubFlagName = "公开"; } //能否进行评价 var orderVisit = await _orderVisitRepository.GetAsync(p => p.OrderId == data.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted); if (orderVisit == null) orderDetail.VisitType = "0"; else { orderDetail.VisitType = orderVisit.VisitState switch { EVisitState.WaitForVisit => "1", EVisitState.Visited => "2", EVisitState.Visiting or EVisitState.NoSatisfiedWaitForVisit or EVisitState.None => "0", _ => "0", }; } } //List dataDto = new() { orderDetail }; return orderDetail; } #endregion #region 知识库 #region 知识库分类 /// /// 知识库分类 /// /// [HttpPost("getknowledgetype")] public async Task GetKnowledgeType() { //查询知识分类 var item = await _knowledgeTypeRepository.Queryable() .Where(p => p.ParentId == null || p.ParentId == "") .Select(p => new { SDICT_ID = p.Id, SDICT_Name = p.Name }) .ToListAsync(); //查询知识标签 var list = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.KnowledgeBaseTags).Select(p => new { SDICT_Name = p.DicDataName, SDICT_ID = p.DicDataName }).ToList(); var rsp = new { KnowledgeType = item, KnowledgeBaseTags = list, }; return rsp; } #endregion #region 知识库查询 /// /// 知识库查询 /// /// /// [HttpPost("getknowledgelist")] public async Task> GetKnowledgeList([FromBody] QueryKnowledgeList dto) { var typeSpliceName = string.Empty; if (!string.IsNullOrEmpty(dto.KnowledgeTypeId)) { var type = await _knowledgeTypeRepository.GetAsync(x => x.Name == dto.KnowledgeTypeId); typeSpliceName = type?.SpliceName; } var typeSpliceNameTags = string.Empty; if (!string.IsNullOrEmpty(dto.KnowledgeBaseTags)) { var type = await _knowledgeWordRepository.GetAsync(x => x.Tag == dto.KnowledgeBaseTags && x.IsEnable == 1); typeSpliceNameTags = type?.Id; } var (total, items) = await _knowledgeRepository.Queryable() .Where(p => p.IsPublic == true && p.Status == EKnowledgeStatus.OnShelf) .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title)) .WhereIF(!string.IsNullOrEmpty(typeSpliceNameTags), p => SqlFunc.JsonArrayAny(p.Keywords, typeSpliceNameTags) == true) .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.KnowledgeType.Any(t => t.KnowledgeTypeSpliceName.EndsWith(typeSpliceName))) .OrderByDescending(p => p.CreationTime) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); var data = new PagedDto(total, _mapper.Map>(items)); return data; } #endregion #region 知识库详情 /// /// 知识库详情 /// /// /// [HttpPost("getknowledgeinfo")] public async Task GetKnowledgeInfo([FromBody] QueryKnowledgeInfo dto) { var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted); KnowledgeInfoThirdDto detailsDto = null; if (data != null) { detailsDto = _mapper.Map(data); if (detailsDto != null && !string.IsNullOrEmpty(detailsDto.Content)) data.Content = _bulletinApplication.GetSiteUrls(data.Content); } else { detailsDto = new(); } return detailsDto; } #endregion #endregion #region 工单写信 /// /// 工单写信 /// /// /// [HttpPost("orderacceptance")] public async Task OrderAcceptance([FromBody] WebFlowAcceptDto dto) { //电话号码去空格 if (!string.IsNullOrEmpty(dto.Mobile)) dto.Mobile = dto.Mobile.Trim(); string strResult = dto.ValidateObject(); if (!string.IsNullOrEmpty(strResult)) { return OpenResponse.Ok(WebPortalDeResponse.Failed("数据验证不通过!")); } var data = _mapper.Map(dto); data.Source = ESource.WebPortal; data.SourceChannel = "因特网"; data.SourceChannelCode = "YTW"; //switch (dto.FromID) //{ // case "2": // data.SourceChannel = "APP"; // data.SourceChannelCode = "AP"; // data.Source = ESource.APP; // break; // case "3": // data.SourceChannel = "微信小程序"; // data.SourceChannelCode = "XCX"; // data.Source = ESource.WeChat; // break; // case "9"://宜宾人社专用 // data.SourceChannel = "人社APP"; // data.SourceChannelCode = "RSAPP"; // data.Source = ESource.YBHumanSocietyAPP; // break; // default: // break; //} if (!string.IsNullOrEmpty(data.LicenceNo)) { data.LicenceTypeCode = "10"; data.LicenceType = "中华人民共和国居民身份证"; } data.ExternalId = Guid.NewGuid().ToString(); data.IdentityType = dto.IdentityType; data.Transpond = false; data.IsEnforcementOrder = false; var result = await _orderApplication.ReceiveOrderFromExternalAsync(data, HttpContext.RequestAborted); OrderAcceptanceReturnDto returnDto = new(); if (result != null) { returnDto.PWD = result.Password; returnDto.Code = result.No; returnDto.State = "1"; dto.Pwd = result.Password; dto.Code = result.No; dto.OrderId = result.Id; var dtoData = _mapper.Map(dto); await _webFlowAcceptRepository.AddAsync(dtoData, HttpContext.RequestAborted); } else returnDto.State = "0"; return OpenResponse.Ok(WebPortalDeResponse.Success(returnDto)); } #endregion #region 附件上传 /// /// 附件上传 /// /// /// [HttpPost("uploadfiles")] public async Task uploadfiles(IFormFile fileData) { if (fileData == null || fileData.Length == 0) { return new GetResultDto(); } Stream stream = fileData.OpenReadStream(); byte[] fileContentBytes = StreamToBytes(stream); var client = _httpClientFactory.CreateClient("fileData"); using (var content = new MultipartFormDataContent()) { var fileContent = new ByteArrayContent(fileContentBytes); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = fileData.Name, FileName = fileData.FileName }; content.Add(fileContent, "fileData", fileData.FileName); var response = await client.PostAsync($"{_appOptions.Value.FileUpload.Url.TrimEnd('/')}/file/upload?source=HotlineWeb", content); if (response.IsSuccessStatusCode) { var result = await response.Content.ReadFromJsonAsync(); return new GetResultDto() { id = result.result.id, fileName = result.result.fileName, path = result.result.path, }; } else { return new GetResultDto(); } } } #endregion #region 工单查询 /// /// 根据编号和密码查询信件ID /// /// /// [HttpPost("getorderdetailbyno")] public async Task GetOrderDetailByNo([FromBody] GetOrderCodePwd dto) { var data = await _orderRepository.GetAsync(p => p.No == dto.OrderNo && p.Password == dto.Pwd, HttpContext.RequestAborted); if (data != null) { var orderDetail = _mapper.Map(data); if (data != null) { //如果是省工单或者是省政民互动的工单,市民不能进行评价 if (data.IsProvince == true || data.SourceChannelCode == "ZMHD") orderDetail.IsProvinceOrder = "1"; else orderDetail.IsProvinceOrder = "0"; //获取发布的数据 var orderPublish = await _orderPublishRepository.GetAsync(p => p.OrderId == data.Id, HttpContext.RequestAborted); if (orderPublish != null) { orderDetail.PubFlag = "1"; orderDetail.FlowTitle = orderPublish.ArrangeTitle; orderDetail.FlowContent = orderPublish.ArrangeContent; orderDetail.FlowResult = orderPublish.ArrangeOpinion; if (orderPublish.PublishState) orderDetail.FlowPubFlagName = "公开"; } //能否进行评价 var orderVisit = await _orderVisitRepository.GetAsync(p => p.OrderId == data.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted); if (orderVisit == null) orderDetail.VisitType = "0"; else { orderDetail.VisitType = orderVisit.VisitState switch { EVisitState.WaitForVisit => "1", EVisitState.Visited => "2", EVisitState.Visiting or EVisitState.NoSatisfiedWaitForVisit or EVisitState.None => "0", _ => "0", }; } } List dataDto = new() { orderDetail }; return orderDetail; } return new OrderDetail(); } #endregion #region 私有方法 /// /// 将文件转化为文件流 /// /// /// private byte[] StreamToBytes(Stream stream) { byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 stream.Seek(0, SeekOrigin.Begin); return bytes; } #endregion #endregion #region 泸州电信查询接口 #region 工单信息 /// /// 工单信息 /// /// /// [HttpGet("getOrderResultList")] public async Task GetOrderResultList([FromBody] DateDto dto) { TimeSpan timeSpan = dto.EndTime - dto.StartTime; if (timeSpan.TotalHours > 24) { return OpenResponse.Ok(WebPortalDeResponse>.Failed("0", "开始结束时间不能大于24小时!")); } var items = await _orderListRepository.Queryable() .Where(x => x.CreationTime >= dto.StartTime) .Where(x => x.CreationTime <= dto.EndTime) .OrderByDescending(x => x.CreationTime) .Select(it => new { Id = it.Id, No = it.No, Title = it.Title, Content = it.Content, ActualHandleOrgName = it.ActualHandleOrgName, CreationTime = it.CreationTime, FromName = it.FromName, FromPhone = string.IsNullOrEmpty(it.FromPhone) ? it.FromPhone : it.Contact }) .ToListAsync(); var OrderDto = _mapper.Map>(items); return OpenResponse.Ok(WebPortalDeResponse>.Success(OrderDto, "成功")); } #endregion #region 评价信息 /// /// 评价信息 /// /// /// [HttpGet("getVisitResultList")] public async Task GetVisitResultList([FromBody] DateDto dto) { TimeSpan timeSpan = dto.EndTime - dto.StartTime; if (timeSpan.TotalHours > 24) { return OpenResponse.Ok(WebPortalDeResponse>.Failed("0", "开始结束时间不能大于24小时!")); } var items = await _orderVisitRepository.Queryable() .Includes(x => x.OrderVisitDetails) .LeftJoin((x, op) => x.OrderId == op.OrderId) .Where(x => x.CreationTime >= dto.StartTime) .Where(x => x.CreationTime <= dto.EndTime) .OrderByDescending(x => x.CreationTime) .Select((x, op) => new { OrderID = x.OrderId, NowEvaluate = x.NowEvaluate, VisitContent = x.OrderVisitDetails.Where(n => n.VisitTarget == EVisitTarget.Org || n.VisitTarget == EVisitTarget.Seat).Select(s => s.VisitContent).First(), VisitTime = x.VisitTime, VisitName = x.Employee.Name, PublishState = op.PublishState }) .ToListAsync(); var VisitDto = _mapper.Map>(items); return OpenResponse.Ok(WebPortalDeResponse>.Success(VisitDto, "成功")); } #endregion #region 账号信息 /// /// 账号信息 /// /// /// [HttpGet("getUserResultList")] public async Task GetUserResultList() { var items = await _userRepository.Queryable() .OrderByDescending(x => x.CreationTime) .Select(it => new { UUID = it.Id, Name = it.Name }) .ToListAsync(); var UserDto = _mapper.Map>(items); return OpenResponse.Ok(WebPortalDeResponse>.Success(UserDto, "成功")); } #endregion #endregion } }