using DocumentFormat.OpenXml.Spreadsheet; using Hotline.Application.Bulletin; using Hotline.Application.Orders; using Hotline.Article; using Hotline.Caching.Interfaces; using Hotline.Configurations; using Hotline.KnowledgeBase; using Hotline.Orders; using Hotline.Push.Notifies; using Hotline.Repository.SqlSugar.Extensions; using Hotline.Settings; using Hotline.Settings.Hotspots; using Hotline.Share.Dtos; using Hotline.Share.Dtos.DataSharing.PusherHotlineDto; using Hotline.Share.Dtos.Order; using Hotline.Share.Dtos.Schedulings; using Hotline.Share.Dtos.WebPortal; using Hotline.Share.Enums.KnowledgeBase; using Hotline.Share.Enums.Order; using Hotline.Share.Enums.Push; using Hotline.WebPortal; using MapsterMapper; using MathNet.Numerics; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using SqlSugar; using XF.Domain.Authentications; using XF.Domain.Cache; using XF.Domain.Filters; using XF.Domain.Repository; namespace Hotline.Api.Controllers { public class WebPortalController : BaseController { 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 IOrderApplication _orderApplication; private readonly ISessionContext _sessionContext; private readonly IRepository _orderVisitDetailRepository; private readonly IBulletinApplication _bulletinApplication; private readonly IRepository _oldPublicDataRepository; private readonly IRepository _knowledgeRelationTypeRepository; private readonly IRepository _knowledgeTypeRepository; private readonly IRepository _knowledgeRepository; private readonly ISystemDicDataCacheManager _systemDicDataCacheManager; private readonly IOptionsSnapshot _appOptions; private readonly ITypedCache _getVailData; public WebPortalController(IMapper mapper, IMediator mediator, IRepository bulletinRepository, IRepository webUserRegisterRepository, IRepository webUserAuthRepository, IRepository webFlowAcceptRepository, ITypedCache writeLettersSendSms, IRepository hotspotRepository, ISystemSettingCacheManager systemSettingCacheManager, IRepository orderPublishRepository, IOrderRepository orderRepository, IRepository orderVisitRepository, IOrderApplication orderApplication, ISessionContext sessionContext, IRepository orderVisitDetailRepository, IBulletinApplication bulletinApplication, IRepository oldPublicDataRepository, IRepository knowledgeRelationTypeRepository, IRepository knowledgeTypeRepository, IRepository knowledgeRepository, ISystemDicDataCacheManager systemDicDataCacheManager, IOptionsSnapshot appOptions, ITypedCache getVailData ) { _mapper = mapper; _mediator = mediator; _bulletinRepository = bulletinRepository; _webUserRegisterRepository = webUserRegisterRepository; _webUserAuthRepository = webUserAuthRepository; _webFlowAcceptRepository = webFlowAcceptRepository; _writeLettersSendSms = writeLettersSendSms; _hotspotRepository = hotspotRepository; _systemSettingCacheManager = systemSettingCacheManager; _orderPublishRepository = orderPublishRepository; _orderRepository = orderRepository; _orderVisitRepository = orderVisitRepository; _orderApplication = orderApplication; _sessionContext = sessionContext; _orderVisitDetailRepository = orderVisitDetailRepository; _bulletinApplication = bulletinApplication; _oldPublicDataRepository = oldPublicDataRepository; _knowledgeRelationTypeRepository = knowledgeRelationTypeRepository; _knowledgeTypeRepository = knowledgeTypeRepository; _knowledgeRepository = knowledgeRepository; _systemDicDataCacheManager = systemDicDataCacheManager; _appOptions = appOptions; _getVailData = getVailData; } #region 通知 /// /// 获取列表 /// /// [AllowAnonymous] [HttpPost("getarticlelist")] public async Task GetArticleList([FromBody] QueryArticleListDto dto) { if (string.IsNullOrEmpty(dto.PushRanges)) dto.PushRanges = "2"; RefAsync total = 0; 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.NoticeType) .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition)) .OrderByDescending(p => p.CreationTime) .Select(it => new { Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "), NoticeID = it.Id, NoticeContent = it.Content, NoticeTypeName = it.BulletinTypeName, NoticeTitle = it.Title, NoticeBMName = it.SourceOrgName, NoticeCreateDate = it.CreationTime, VideoUrl = "", WNLT_FullCode = "" }) .ToPageListAsync(dto.PageIndex, dto.PageSize, total); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); ArticleListDataDto dataDto = new() { PageCount = nPageCount, Total = total, data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(dataDto)); } /// /// 获取通知公告前几条数据 /// /// /// [AllowAnonymous] [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(); var data = _mapper.Map>(items); return OpenResponse.Ok(WebPortalDeResponse>.Success(data, "成功")); } /// /// 获取详情,修改阅读次数 /// /// /// [AllowAnonymous] [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 OpenResponse.Ok(WebPortalDeResponse>.Success(dataDto)); } /// /// 根据分类获取详情 /// /// /// [AllowAnonymous] [HttpPost("getarticledetailsbytype")] public async Task GetArticleDetailsByType([FromBody] ArticleIdByNumDto dto) { var items = await _bulletinRepository.Queryable() .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), p => p.BulletinTypeId == dto.BulletinTypeId) .OrderByDescending(p => p.CreationTime) .Take(dto.Num) .ToListAsync(); List dataDto = []; if (items != null && items.Any()) { foreach (var item in items) { if (!string.IsNullOrEmpty(item.Content)) item.Content = _bulletinApplication.GetSiteUrls(item.Content); dataDto.Add(new() { NoticeID = item.Id, NoticeTypeName = item.BulletinTypeName, NoticeTitle = item.Title, NoticeBMName = item.SourceOrgName, NoticeCreateDate = item.CreationTime, NoticeRCount = item.ReadedNum, WNED_VideoUrl = "", NoticeContent = item.Content }); } } return OpenResponse.Ok(WebPortalDeResponse>.Success(dataDto)); } /// /// 上一条和下一条 /// /// /// [AllowAnonymous] [HttpPost("getpreviousandnext")] public async Task GetPreviousAndNext([FromBody] ArticlePreviousAndNextDto dto) { if (string.IsNullOrEmpty(dto.PushRanges)) dto.PushRanges = "2"; var sugar = _bulletinRepository.Queryable() .Where(p => p.LoseEfficacyTime >= DateTime.Now) .Where(p => p.IsArrive == true) .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges)) ; if (dto.FullSearch == "1")//全文搜索 { if (_appOptions.Value.IsYiBin) { sugar.Where(p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4") .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition)); } if (_appOptions.Value.IsZiGong) { sugar.Where(p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017") .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition)); } } else//指定分类 { sugar.WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition)) .Where(p => p.BulletinTypeId == dto.NoticeTypeId); } var list = await sugar.OrderByDescending(p => p.CreationTime) .Select(it => new { Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "), NoticeID = it.Id, NoticeTitle = it.Title, NoticeCreateDate = it.CreationTime }) .ToListAsync(); //数据为空返回空数据 if (list == null || list.Count == 0) return OpenResponse.Ok(WebPortalDeResponse>.Success(null)); else { var temp = list.Find(p => p.NoticeID == dto.ID); if (temp != null) { List returnDto = new(); //上一条 var pTemp = list.Find(p => p.Page == temp.Page - 1); if (pTemp != null) returnDto.Add(new() { NoticeID = pTemp.NoticeID, NoticeTitle = pTemp.NoticeTitle, pntype = "p" }); //下一条 var nTemp = list.Find(p => p.Page == temp.Page + 1); if (nTemp != null) returnDto.Add(new() { NoticeID = nTemp.NoticeID, NoticeTitle = nTemp.NoticeTitle, pntype = "n" }); return OpenResponse.Ok(WebPortalDeResponse>.Success(returnDto)); } else return OpenResponse.Ok(WebPortalDeResponse>.Success(null)); } } /// /// 全文检索 /// /// /// [AllowAnonymous] [HttpPost("getfulltextsearchlist")] public async Task GetFullTextSearchList([FromBody] QueryArticleListDto dto) { if (string.IsNullOrEmpty(dto.PushRanges)) dto.PushRanges = "2"; if (string.IsNullOrEmpty(dto.Condition)) return OpenResponse.Ok(WebPortalDeResponse.Success(null)); RefAsync total = 0; 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)) .WhereIF(_appOptions.Value.IsYiBin, p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4") .WhereIF(_appOptions.Value.IsZiGong, p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017") .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition)) .OrderByDescending(p => p.CreationTime) .Select(it => new { Page = SqlFunc.RowNumber($"{it.CreationTime} desc "), NoticeID = it.Id, Content = it.Content, NoticeTypeID = it.BulletinTypeId, NoticeTypeName = it.BulletinTypeName, NoticeTitle = it.Title, NoticeBMName = it.SourceOrgName, NoticeCreateDate = it.CreationTime, TypeCode = "", }) .ToPageListAsync(dto.PageIndex, dto.PageSize, total); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); FullTextSearchListDataDto dataDto = new() { PageCount = nPageCount, data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(dataDto)); } #endregion #region 用户 /// /// 添加统一认证用户数据 /// /// /// [AllowAnonymous] [HttpPost("adduserauth")] public async Task AddUserAuth([FromBody] UserModelDto dto) { bool bResult = false; // 唯一记录ID string id = dto.id; // 注册用户ID string webUserID = ""; // 统一认证用户注册ID string wUAID = ""; //查询是否有注册用户 var dataUser = await _webUserAuthRepository.GetAsync(p => p.DataId == id, HttpContext.RequestAborted); if (dataUser != null) { webUserID = dataUser.WebUserID; wUAID = dataUser.Id; } //没有注册用户添加数据 if (string.IsNullOrEmpty(webUserID)) { var userRegister = _mapper.Map(dto); userRegister.RegDate = DateTime.Now; userRegister.LastDate = DateTime.Now; webUserID = await _webUserRegisterRepository.AddAsync(userRegister, HttpContext.RequestAborted); } //统一认证数据 var userAuth = _mapper.Map(dto); if (!string.IsNullOrEmpty(wUAID)) { //修改数据 userAuth.Id = wUAID; await _webUserAuthRepository.UpdateAsync(userAuth, HttpContext.RequestAborted); bResult = true; } else { //新增数据 userAuth.WebGUID = Guid.NewGuid().ToString(); userAuth.WebUserID = webUserID; var addId = await _webUserAuthRepository.AddAsync(userAuth, HttpContext.RequestAborted); if (!string.IsNullOrEmpty(addId)) bResult = true; } //判断是否成功 if (bResult) return OpenResponse.Ok(WebPortalDeResponse.Success(webUserID)); else return OpenResponse.Ok(WebPortalDeResponse.Failed()); } /// /// 用户中心用户写信数据 /// /// /// [HttpPost("getorderbyuserlist")] [AllowAnonymous] public async Task GetOrderByUserList([FromBody] QueryOrderListByUserDto dto) { var dataUser = await _webUserAuthRepository.GetAsync(p => p.DataId == dto.UserId, HttpContext.RequestAborted); if (dataUser != null) { RefAsync total = 0; var items = await _webFlowAcceptRepository.Queryable() .LeftJoin((o, or) => o.OrderId == or.Id) .Where(o => o.WebUserID == dataUser.WebUserID) //重新构建数据 .Select((o, or) => new { FlowID = o.OrderId, FlowCode = o.Code, FlowPwd = o.Pwd, FlowTitle = o.Title, FlowFromName = or.SourceChannel, FlowPurTypeName = o.PurTypeName, ConTypeName = or.HotspotName, FlowAddDate = o.CreationTime, RSFlagName = or.Status < EOrderStatus.Filed ? "办理中" : "办理完成", WebUserID = o.WebUserID }) //将结果合并成一个表 .MergeTable() .Where(p => p.WebUserID == dataUser.WebUserID) .ToPageListAsync(dto.PageIndex, dto.PageSize, total); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); OrderListReturnDto returnDto = new() { PageNum = dto.PageIndex, PageCount = nPageCount, Data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(returnDto, "成功")); } return OpenResponse.Ok(WebPortalDeResponse.Success(new OrderListReturnDto(), "成功")); } /// /// 用户中心用户写信数据 /// /// /// [HttpPost("getorderbyuserphonelist")] [AllowAnonymous] public async Task GetOrderByUserPhoneList([FromBody] QueryOrderListByUserDto dto) { RefAsync total = 0; var items = await _webFlowAcceptRepository.Queryable() .LeftJoin((o, or) => o.OrderId == or.Id) .Where(o => o.Mobile == dto.PhoneNum) //重新构建数据 .Select((o, or) => new { FlowID = o.OrderId, FlowCode = o.Code, FlowPwd = o.Pwd, FlowTitle = o.Title, FlowFromName = or.SourceChannel, FlowPurTypeName = o.PurTypeName, ConTypeName = or.HotspotName, FlowAddDate = o.CreationTime, RSFlagName = or.Status < EOrderStatus.Filed ? "办理中" : "办理完成", Mobile = o.Mobile }) //将结果合并成一个表 .MergeTable() .Where(p => p.Mobile == dto.PhoneNum) .ToPageListAsync(dto.PageIndex, dto.PageSize, total); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); OrderListReturnDto returnDto = new() { PageNum = dto.PageIndex, PageCount = nPageCount, Data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(returnDto, "成功")); } #endregion #region 短信、基础设置 /// /// 短信验证码发送 /// /// /// [AllowAnonymous] [HttpPost("writeletterssendsms")] public async Task WriteLettersSendSms([FromBody] WebPortalSendSmsModelDto dto) { string keyToken = "SmsUserWriteKey_" + dto.TelNum + "_" + DateTime.Now.ToString("yyyyMMdd"); var data = await _writeLettersSendSms.GetAsync(keyToken, HttpContext.RequestAborted); if (data != null)//已经发过短信 { //是否可以继续发送短信(10次) if (data.SendCount > 10) //短信发送超过10条 return OpenResponse.Ok(WebPortalDeResponse.Success("-2")); // 验证是否在两分钟之内 TimeSpan duration = DateTime.Now - data.AddTime; // 计算时间差 if ((int)duration.TotalSeconds < 120) // 距离上次发送时间不足两分钟 return OpenResponse.Ok(WebPortalDeResponse.Success("-4")); //修改缓存信息 data.SendCount++; data.SmsCode = dto.SmsCode; data.AddTime = DateTime.Now; } else { //没有发过短信,直接写入数据 data = new WriteLettersSendSmsDto { AddTime = DateTime.Now, SmsCode = dto.SmsCode, MobileNum = dto.TelNum, SendCount = 1 }; } //这里发送短信 宜宾12345市民服务热线网站验证码{0},用于写信时验证联系电话。验证码有效期10分钟。 var messageDto = new Share.Dtos.Push.MessageDto { PushBusiness = EPushBusiness.MsgCode, ExternalId = "", OrderId = "", PushPlatform = EPushPlatform.Web, Remark = "", Name = dto.TelNum, TemplateCode = "1008", Params = new List() { dto.SmsCode }, TelNumber = dto.TelNum, }; await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted); //修改缓存 await _writeLettersSendSms.SetAsync(keyToken, data, TimeSpan.FromDays(1), HttpContext.RequestAborted); return OpenResponse.Ok(WebPortalDeResponse.Success("1")); } /// /// 验证短信验证码是否正确 正确返回1,错误返回-1 /// /// /// [AllowAnonymous] [HttpPost("checksmscode")] public async Task CheckSmsCode([FromBody] WebPortalSendSmsModelDto dto) { string keyToken = "SmsUserWriteKey_" + dto.TelNum + "_" + DateTime.Now.ToString("yyyyMMdd"); var data = await _writeLettersSendSms.GetAsync(keyToken, HttpContext.RequestAborted); //检测是否存在 if (data != null) return OpenResponse.Ok(WebPortalDeResponse.Success(data.SmsCode)); //不存在 return OpenResponse.Ok(WebPortalDeResponse.Success("-1")); } /// /// 获取热点分类的树形 /// /// [AllowAnonymous] [HttpPost("gethotspottreelist")] public async Task GetHotspotTreeList() { var data = await _hotspotRepository.Queryable().ToTreeAsync(it => it.Children, it => it.ParentId, null); return OpenResponse.Ok(WebPortalDeResponse>.Success(data)); } /// /// 系统主题颜色 /// /// [AllowAnonymous] [HttpPost("getsystemsettingstheme")] public async Task GetSystemSettingsTheme() { var WebSystemSettingsTheme = bool.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.WebSystemSettingsTheme).SettingValue[0]); if (WebSystemSettingsTheme == false) return OpenResponse.Ok(WebPortalDeResponse.Success("")); else return OpenResponse.Ok(WebPortalDeResponse.Success("class=gray2")); } #endregion #region 办件 /// /// 获取信件前6条数据 /// /// /// [HttpPost("getorderlistbynum")] [AllowAnonymous] public async Task GetOrderListByNum([FromBody] QueryOrderListByNumDto dto) { var queryNew = _orderRepository.Queryable() .LeftJoin((p, op) => p.Id == op.OrderId) .Where(p => p.IsPublicity == true) .OrderByDescending((p, op) => p.CreationTime) .Select((p, op) => new DataListTopDto { DataID = p.Id, Title = p.Title, CreateDate = op.CreationTime }); var queryold = _oldPublicDataRepository.Queryable() .OrderByDescending(p => p.PubDate) .Select(p => new DataListTopDto { DataID = p.OrderId, Title = p.Title, CreateDate = p.CreationTime }); var items = await _orderRepository.UnionAll(queryNew, queryold) .OrderByDescending(p => p.CreateDate) .Take(dto.Num) .ToListAsync(); var data = _mapper.Map>(items); return OpenResponse.Ok(WebPortalDeResponse>.Success(data, "成功")); } /// /// 办件摘编列表数据 /// /// /// [HttpPost("getorderlist")] [AllowAnonymous] public async Task GetOrderList([FromBody] QueryOrderListDto dto) { RefAsync total = 0; var queryNew = _orderPublishRepository.Queryable() .Includes(d => d.Order) .Where(d => d.PublishState == true && d.Order.Id != null) .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), d => d.Order.No == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), d => d.Order.Title.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), d => d.Order.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), d => d.Order.HotspotId == dto.FlowRType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), d => d.Order.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), d => d.Order.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), d => d.Order.FromName.Contains(dto.FlowFrom)) .OrderByDescending(p => p.CreationTime) .Select(p => new OrderListDto { FlowID = p.OrderId, FlowCode = p.No, FlowPwd = p.Order.Password, FlowTitle = p.Order.Title, FlowFromName = p.Order.SourceChannel, FlowPurTypeName = p.Order.AcceptType, ConTypeName = p.Order.HotspotName, FlowAddDate = p.Order.CreationTime, RSFlagName = p.Order.Status >= EOrderStatus.Filed ? "办理完成" : "办理中", PubDate = p.CreationTime }); var queryold = _oldPublicDataRepository.Queryable() .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), d => d.OrderNo == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), d => d.Title.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), d => d.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), d => d.PubDate >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), d => d.PubDate <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), d => d.FromName.Contains(dto.FlowFrom)) .OrderByDescending(p => p.PubDate) .Select(p => new OrderListDto { FlowID = p.OrderId, FlowCode = p.OrderNo, FlowPwd = p.OrderPwd, FlowTitle = p.Title, FlowFromName = p.SourceChannel, FlowPurTypeName = p.AcceptType, ConTypeName = p.HotspotName, FlowAddDate = p.AcceptTime, RSFlagName = p.State == "1" ? "办理完成" : "办理中", PubDate = p.PubDate }); var items = await _orderRepository.UnionAll(queryNew, queryold) .OrderByDescending(p => p.PubDate) .ToPageListAsync(dto.PageIndex, dto.PageSize, total); //计算总页数 int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize)); OrderListReturnDto returnDto = new() { PageNum = dto.PageIndex, PageCount = nPageCount, Data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(returnDto, "成功")); } /// /// /// 查询工单发布后公开的数据 /// /// /// [HttpPost("get_order_list_publish_all")] [AllowAnonymous] public async Task GetOrderByListAllOpen([FromBody] QueryOrderListDto dto) { var queryNew = _orderRepository.Queryable() .LeftJoin((p, op) => p.Id == op.OrderId) .Where(p => p.IsPublicity == true) .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), (p, op) => p.No == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), (p, op) => p.Title.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), (p, op) => p.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), (p, op) => p.HotspotId == dto.FlowRType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), (p, op) => p.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), (p, op) => p.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), (p, op) => p.FromName.Contains(dto.FlowFrom)) .WhereIF(dto.IdentityType.HasValue, (p, op) => p.IdentityType == dto.IdentityType) .OrderByDescending((p, op) => p.CreationTime) .Select((p, op) => new OrderListDto { FlowID = p.Id, FlowCode = p.No, FlowPwd = p.Password, FlowTitle = p.Title, 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 OpenResponse.Ok(WebPortalDeResponse.Success(returnDto, "成功")); } /// /// 查询工单发布后公开的数据 /// /// /// [HttpPost("get_order_list_all_bynoortitle")] [AllowAnonymous] public async Task GetOrderByListAllByNoOrTitle([FromBody] QueryOrderListDto dto) { var (total, items) = await _orderRepository.Queryable(includeDeleted: true) .LeftJoin((p, op) => p.Id == op.OrderId) .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), (p, op) => p.No == dto.FlowCode) .WhereIF(!string.IsNullOrEmpty(dto.FlowName), (p, op) => p.Title.Contains(dto.FlowName)) .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), (p, op) => p.AcceptTypeCode == dto.FlowSType) .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), (p, op) => p.HotspotId == dto.FlowRType) .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), (p, op) => p.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), (p, op) => p.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), (p, op) => p.FromName.Contains(dto.FlowFrom)) .WhereIF(dto.IdentityType.HasValue, (p, op) => p.IdentityType == dto.IdentityType) .OrderByDescending((p, op) => p.CreationTime) .Select((p, op) => new OrderListDto { FlowID = p.Id, FlowCode = p.No, FlowPwd = p.Password, FlowTitle = p.Title, FlowFromName = p.SourceChannel, FlowPurTypeName = p.AcceptType, ConTypeName = p.HotspotName, FlowAddDate = p.CreationTime, PubDate = op.CreationTime, RSFlagName = p.Status >= EOrderStatus.Filed ? "办理完成" : "办理中" }) .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted); OrderListReturnAllDto returnDto = new() { Total = total, Data = _mapper.Map>(items) }; return OpenResponse.Ok(WebPortalDeResponse.Success(returnDto, "成功")); } /// /// 办件摘编详情 /// /// /// [AllowAnonymous] [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 OpenResponse.Ok(WebPortalDeResponse>.Success(dataDto)); } /// /// 根据编号和密码查询信件ID /// /// /// [AllowAnonymous] [HttpPost("getorderid")] public async Task GetOrderId([FromBody] GetOrderCodePwd dto) { var data = await _orderRepository.GetAsync(p => p.No == dto.OrderNo && p.Password == dto.Pwd, HttpContext.RequestAborted);//&& p.Status > EOrderStatus.Published return OpenResponse.Ok(WebPortalDeResponse.Success(data?.Id)); } /// /// 办件摘编详情 /// /// /// [AllowAnonymous] [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 OpenResponse.Ok(WebPortalDeResponse>.Success(dataDto)); } return OpenResponse.Ok(WebPortalDeResponse>.Failed(code: "0", description: "查询失败")); } /// /// 写信接口 /// /// /// [AllowAnonymous] [HttpPost("orderacceptance")] public async Task OrderAcceptance([FromBody] WebFlowAcceptDto dto) { //电话号码去空格 if (!string.IsNullOrEmpty(dto.Mobile)) dto.Mobile = dto.Mobile.Trim(); var data = _mapper.Map(dto); data.Source = ESource.WebPortal; if (string.IsNullOrEmpty(data.SourceChannelCode)) { data.SourceChannel = "因特网"; data.SourceChannelCode = "YTW"; } if (dto.FromID == "2") { data.SourceChannel = "APP"; data.SourceChannelCode = "AP"; data.Source = ESource.APP; } if (dto.FromID == "3") { data.SourceChannel = "微信"; data.SourceChannelCode = "WX"; data.Source = ESource.WeChat; } 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)); } /// /// 受理类型和热点统计 /// /// [AllowAnonymous] [HttpPost("getchartdata")] public async Task GetChartData() { var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); //数据查询 var listType = await _orderRepository.Queryable() .Where(p => p.CreationTime >= startDate && p.CreationTime <= endDate && 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 listHot = await _orderRepository.Queryable() .Where(it => it.CreationTime >= startDate && it.CreationTime <= endDate && it.Status > EOrderStatus.WaitForAccept) .Select(it => new { HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn("0"), SqlFunc.MappingColumn("2")), }) .MergeTable() .Where(it => it.HotspotId != "18") .GroupBy(it => it.HotspotId)//对新表进行分组 .Select(it => new { HotspotId = it.HotspotId, num = SqlFunc.AggregateCount(it.HotspotId) }) .OrderByDescending(it => it.num) .Take(5) .MergeTable() .LeftJoin((it, h) => it.HotspotId == h.Id) .Select((it, h) => new { typeName = h.HotSpotName, num = it.num }).ToListAsync(); ////数据查询-查询总数前5的数据 //var listHot = await _orderRepository.Queryable() // .Where(p => p.StartTime >= startDate && p.StartTime <= endDate && p.Status > EOrderStatus.WaitForAccept) // .Select(it => new // { // it.HotspotId, // it.HotspotName // }) // .MergeTable()//将查询出来的结果合并成一个新表 // .GroupBy(it => new { it.HotspotId, it.HotspotName })//对新表进行分组 // .Select(it => new // { // typeName = it.HotspotName, // num = SqlFunc.AggregateCount(it.HotspotId) // }) // .OrderByDescending(it => it.num) // .Take(5) // .ToListAsync(); GetChartDataDto dataDto = new() { formCount = _mapper.Map>(listType), hotCount = _mapper.Map>(listHot) }; return OpenResponse.Ok(WebPortalDeResponse.Success(dataDto)); } /// /// 获取统计数据 /// /// [AllowAnonymous] [HttpPost("getstatist")] public async Task GetStatist() { var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); //GetStatistDto getStatistDto = new() //{ // AllCount = await _orderRepository.Queryable().Where(p => p.Status > EOrderStatus.WaitForAccept).CountAsync(), // AllTrandCount = await _orderRepository.Queryable().Where(p => p.Status >= EOrderStatus.Filed).CountAsync(), // DayCount = await _orderRepository.Queryable().Where(p => p.StartTime >= startDate && p.StartTime <= endDate && p.Status > EOrderStatus.WaitForAccept).CountAsync(), // DayTrandCount = await _orderRepository.Queryable().Where(p => p.ActualHandleTime >= startDate && p.ActualHandleTime <= endDate && p.Status >= EOrderStatus.Filed).CountAsync() //}; var getStatistDto = await _orderRepository.Queryable() .Select(p => new GetStatistDto { AllCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Status > EOrderStatus.WaitForAccept, 1, 0)) + 7079457, AllTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Status >= EOrderStatus.Filed, 1, 0)) + 7079214, DayCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.Status > EOrderStatus.WaitForAccept, 1, 0)), DayTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.FiledTime >= startDate && p.FiledTime <= endDate && p.Status >= EOrderStatus.Filed, 1, 0)), }) .FirstAsync(); return OpenResponse.Ok(WebPortalDeResponse.Success(getStatistDto)); } /// /// 获取统计数据 今日数据 /// /// [AllowAnonymous] [HttpPost("todaygetstatist")] public async Task GetTodayStatist() { var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); var getStatistDto = await _orderRepository.Queryable() .Select(p => new GetStatistDto { DayCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.Status > EOrderStatus.WaitForAccept, 1, 0)), DayTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.FiledTime >= startDate && p.FiledTime <= endDate && p.Status >= EOrderStatus.Filed, 1, 0)), }) .FirstAsync(); return OpenResponse.Ok(WebPortalDeResponse.Success(getStatistDto)); } #endregion #region 评价 /// /// 获取待评价部门信息 /// /// /// [AllowAnonymous] [HttpPost("getwaitvisitdata")] public async Task GetWaitVisitData([FromBody] ArticleIdDto dto) { var dataOrder = await _orderVisitRepository.GetAsync(p => p.OrderId == dto.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted); if (dataOrder == null) return OpenResponse.Ok(WebPortalDeResponse>.Failed("工单不能评价!")); if (dataOrder.VisitState != EVisitState.WaitForVisit) return OpenResponse.Ok(WebPortalDeResponse>.Failed("工单已经评价!")); var data = await _orderVisitDetailRepository.Queryable() .Where(p => p.VisitId == dataOrder.Id && p.VisitTarget == EVisitTarget.Org) .ToListAsync(); var listDat = _mapper.Map>(data); return OpenResponse.Ok(WebPortalDeResponse>.Success(listDat)); } /// /// 评价内容 /// /// /// [AllowAnonymous] [HttpPost("receivevisitdata")] public async Task ReceiveVisitData([FromBody] OrderVisitListDataDto dto) { if (dto == null || dto.VistListDtos == null || dto.VistListDtos.Count == 0) return OpenResponse.Ok(WebPortalDeResponse.Failed("评价数据不能为空!")); var dataOrder = await _orderVisitRepository.GetAsync(p => p.OrderId == dto.OrderId && p.VisitState != EVisitState.None, HttpContext.RequestAborted); if (dataOrder == null) return OpenResponse.Ok(WebPortalDeResponse.Failed("工单已经评价!")); //组装数据 OrderVisitWebDto visitWebDto = new() { VisitType = Hotline.Share.Enums.Order.EVisitType.WebVisit, VisitTime = DateTime.Now }; List orderVisitDetails = new(); #region 部门评价 //部门评价 //遍历数据 foreach (var item in dto.VistListDtos) { Hotline.Share.Dtos.Kv kv = item.SatisfactionCode switch { "5" => new Hotline.Share.Dtos.Kv { Key = "5", Value = "非常满意" }, "4" => new Hotline.Share.Dtos.Kv { Key = "4", Value = "满意" }, "2" => new Hotline.Share.Dtos.Kv { Key = "2", Value = "不满意" }, _ => new Hotline.Share.Dtos.Kv { Key = "7", Value = "不做评价" }, }; //组装回访数据 visitWebDto.Id = item.VisitId; OrderVisitDetailWebDto detailDto = new() { Id = item.Id, VisitTarget = Hotline.Share.Enums.Order.EVisitTarget.Org, OrgProcessingResults = kv, OrgNoSatisfiedReason = new List(), OrgHandledAttitude = kv, VisitContent = item.VisitContent }; orderVisitDetails.Add(detailDto); } #endregion visitWebDto.OrderVisitDetailDto = orderVisitDetails; //推送数据 await _orderApplication.OrderVisitWeb(visitWebDto, HttpContext.RequestAborted); return OpenResponse.Ok(WebPortalDeResponse.Success("1")); } #endregion /// /// 获取知识库分类 /// /// [HttpPost("getknowledgetype")] [AllowAnonymous] 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 OpenResponse.Ok(WebPortalDeResponse.Success(rsp)); } /// /// 知识库查询 /// /// /// [HttpPost("getknowledgelist")] [AllowAnonymous] 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 _knowledgeTypeRepository.GetAsync(x => x.Name == dto.KnowledgeBaseTags); typeSpliceNameTags = type?.SpliceName; } 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 => p.KnowledgeType.Any(t => t.KnowledgeTypeSpliceName.EndsWith(typeSpliceNameTags))) .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 OpenResponse.Ok(WebPortalDeResponse>.Success(data)); } /// /// 获取知识库详情 /// /// /// [HttpPost("getknowledgeinfo")] [AllowAnonymous] public async Task GetKnowledgeInfo([FromBody] QueryKnowledgeInfo dto) { var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted); KnowledgeInfoDto 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(); } List dataDto = [detailsDto]; return OpenResponse.Ok(WebPortalDeResponse>.Success(dataDto)); } /// /// 查询受理类型----受理量 /// /// /// [HttpPost("getacceptancetypestatisticsbymonth")] [AllowAnonymous] 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 OpenResponse.Ok(WebPortalDeResponse>.Success(orderForms)); } return OpenResponse.Ok(WebPortalDeResponse>.Success(formAcceptanceCount)); } /// /// 查询受理类型---办结量 /// /// /// [HttpPost("getacceptancetypestatisticsbymonthend")] [AllowAnonymous] 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 OpenResponse.Ok(WebPortalDeResponse>.Success(orderForms)); } return OpenResponse.Ok(WebPortalDeResponse>.Success(formFileCount)); } /// /// 缓存值 /// /// /// [HttpPost("setgetvaildata")] [AllowAnonymous] public async Task SetGetVailData([FromBody] GetVailDataDto dto) { if (string.IsNullOrEmpty(dto.Key) || string.IsNullOrEmpty(dto.Value)) return OpenResponse.Ok(WebPortalDeResponse.Success("-1")); string strGuid = Guid.NewGuid().ToString(); string keyToken = dto.Key + strGuid; await _getVailData.SetAsync(keyToken, dto.Value, TimeSpan.FromHours(1), cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(WebPortalDeResponse.Success(strGuid)); } /// /// 缓存值 /// /// /// [HttpPost("getgetvaildata")] [AllowAnonymous] public async Task GetGetVailData([FromBody] GetVailDataDto dto) { if (string.IsNullOrEmpty(dto.Key)) return OpenResponse.Ok(WebPortalDeResponse.Success("-1")); var data = await _getVailData.GetAsync(dto.Key, cancellationToken: HttpContext.RequestAborted); if (!string.IsNullOrEmpty(data) && data == dto.Value) { await _getVailData.RemoveAsync(dto.Key, cancellationToken: HttpContext.RequestAborted); return OpenResponse.Ok(WebPortalDeResponse.Success("1")); } return OpenResponse.Ok(WebPortalDeResponse.Success("-1")); } } }