WebPortalController.cs 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080
  1. using DocumentFormat.OpenXml.Spreadsheet;
  2. using Hotline.Application.Bulletin;
  3. using Hotline.Application.OrderApp;
  4. using Hotline.Article;
  5. using Hotline.Caching.Interfaces;
  6. using Hotline.Configurations;
  7. using Hotline.KnowledgeBase;
  8. using Hotline.Orders;
  9. using Hotline.Push.Notifies;
  10. using Hotline.Repository.SqlSugar.Extensions;
  11. using Hotline.Repository.SqlSugar.Knowledge;
  12. using Hotline.Settings;
  13. using Hotline.Settings.Hotspots;
  14. using Hotline.Share.Dtos;
  15. using Hotline.Share.Dtos.DataSharing.PusherHotlineDto;
  16. using Hotline.Share.Dtos.Order;
  17. using Hotline.Share.Dtos.Schedulings;
  18. using Hotline.Share.Dtos.WebPortal;
  19. using Hotline.Share.Enums.KnowledgeBase;
  20. using Hotline.Share.Enums.Order;
  21. using Hotline.Share.Enums.Push;
  22. using Hotline.WebPortal;
  23. using MapsterMapper;
  24. using MathNet.Numerics;
  25. using MediatR;
  26. using Microsoft.AspNetCore.Authorization;
  27. using Microsoft.AspNetCore.Mvc;
  28. using Microsoft.Extensions.Options;
  29. using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp.WxAppJson;
  30. using SqlSugar;
  31. using XF.Domain.Authentications;
  32. using XF.Domain.Cache;
  33. using XF.Domain.Filters;
  34. using XF.Domain.Repository;
  35. namespace Hotline.Api.Controllers
  36. {
  37. public class WebPortalController : BaseController
  38. {
  39. #region 注入
  40. private readonly IMapper _mapper;
  41. private readonly IMediator _mediator;
  42. private readonly IRepository<Bulletin> _bulletinRepository;
  43. private readonly IRepository<WebUserRegister> _webUserRegisterRepository;
  44. private readonly IRepository<WebUserAuth> _webUserAuthRepository;
  45. private readonly IRepository<WebFlowAccept> _webFlowAcceptRepository;
  46. private readonly ITypedCache<WriteLettersSendSmsDto> _writeLettersSendSms;
  47. private readonly IRepository<Hotspot> _hotspotRepository;
  48. private readonly ISystemSettingCacheManager _systemSettingCacheManager;
  49. private readonly IRepository<OrderPublish> _orderPublishRepository;
  50. private readonly IOrderRepository _orderRepository;
  51. private readonly IRepository<OrderVisit> _orderVisitRepository;
  52. private readonly IOrderApplication _orderApplication;
  53. private readonly ISessionContext _sessionContext;
  54. private readonly IRepository<OrderVisitDetail> _orderVisitDetailRepository;
  55. private readonly IBulletinApplication _bulletinApplication;
  56. private readonly IRepository<OldPublicData> _oldPublicDataRepository;
  57. private readonly IRepository<KnowledgeType> _knowledgeTypeRepository;
  58. private readonly IRepository<Knowledge> _knowledgeRepository;
  59. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  60. private readonly IOptionsSnapshot<AppConfiguration> _appOptions;
  61. private readonly ITypedCache<string> _getVailData;
  62. private readonly IRepository<KnowledgeWord> _knowledgeWordRepository;
  63. private readonly ISystemDicDataCacheManager _sysDicDataCacheManager;
  64. public WebPortalController(IMapper mapper,
  65. IMediator mediator,
  66. IRepository<Bulletin> bulletinRepository,
  67. IRepository<WebUserRegister> webUserRegisterRepository,
  68. IRepository<WebUserAuth> webUserAuthRepository,
  69. IRepository<WebFlowAccept> webFlowAcceptRepository,
  70. ITypedCache<WriteLettersSendSmsDto> writeLettersSendSms,
  71. IRepository<Hotspot> hotspotRepository,
  72. ISystemSettingCacheManager systemSettingCacheManager,
  73. IRepository<OrderPublish> orderPublishRepository,
  74. IOrderRepository orderRepository,
  75. IRepository<OrderVisit> orderVisitRepository,
  76. IOrderApplication orderApplication,
  77. ISessionContext sessionContext,
  78. IRepository<OrderVisitDetail> orderVisitDetailRepository,
  79. IBulletinApplication bulletinApplication,
  80. IRepository<OldPublicData> oldPublicDataRepository,
  81. IRepository<KnowledgeType> knowledgeTypeRepository,
  82. IRepository<Knowledge> knowledgeRepository,
  83. ISystemDicDataCacheManager systemDicDataCacheManager,
  84. IOptionsSnapshot<AppConfiguration> appOptions,
  85. ITypedCache<string> getVailData,
  86. IRepository<KnowledgeWord> knowledgeWordRepository,
  87. ISystemDicDataCacheManager sysDicDataCacheManager
  88. )
  89. {
  90. _mapper = mapper;
  91. _mediator = mediator;
  92. _bulletinRepository = bulletinRepository;
  93. _webUserRegisterRepository = webUserRegisterRepository;
  94. _webUserAuthRepository = webUserAuthRepository;
  95. _webFlowAcceptRepository = webFlowAcceptRepository;
  96. _writeLettersSendSms = writeLettersSendSms;
  97. _hotspotRepository = hotspotRepository;
  98. _systemSettingCacheManager = systemSettingCacheManager;
  99. _orderPublishRepository = orderPublishRepository;
  100. _orderRepository = orderRepository;
  101. _orderVisitRepository = orderVisitRepository;
  102. _orderApplication = orderApplication;
  103. _sessionContext = sessionContext;
  104. _orderVisitDetailRepository = orderVisitDetailRepository;
  105. _bulletinApplication = bulletinApplication;
  106. _oldPublicDataRepository = oldPublicDataRepository;
  107. _knowledgeTypeRepository = knowledgeTypeRepository;
  108. _knowledgeRepository = knowledgeRepository;
  109. _systemDicDataCacheManager = systemDicDataCacheManager;
  110. _appOptions = appOptions;
  111. _getVailData = getVailData;
  112. _knowledgeWordRepository = knowledgeWordRepository;
  113. _sysDicDataCacheManager = sysDicDataCacheManager;
  114. }
  115. #endregion
  116. #region 通知
  117. /// <summary>
  118. /// 获取列表
  119. /// </summary>
  120. /// <returns></returns>
  121. [AllowAnonymous]
  122. [HttpPost("getarticlelist")]
  123. public async Task<OpenResponse> GetArticleList([FromBody] QueryArticleListDto dto)
  124. {
  125. if (string.IsNullOrEmpty(dto.PushRanges))
  126. dto.PushRanges = "2";
  127. RefAsync<int> total = 0;
  128. var items = await _bulletinRepository.Queryable()
  129. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  130. .Where(p => p.IsArrive == true)
  131. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  132. .Where(p => p.BulletinTypeId == dto.NoticeType)
  133. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  134. .OrderByDescending(p => p.CreationTime)
  135. .Select(it => new
  136. {
  137. Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "),
  138. NoticeID = it.Id,
  139. NoticeContent = it.Content,
  140. NoticeTypeName = it.BulletinTypeName,
  141. NoticeTitle = it.Title,
  142. NoticeBMName = it.SourceOrgName,
  143. NoticeCreateDate = it.CreationTime,
  144. VideoUrl = "",
  145. WNLT_FullCode = ""
  146. })
  147. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  148. //计算总页数
  149. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  150. ArticleListDataDto dataDto = new()
  151. {
  152. PageCount = nPageCount,
  153. Total = total,
  154. data = _mapper.Map<IReadOnlyList<ArticleListDto>>(items)
  155. };
  156. return OpenResponse.Ok(WebPortalDeResponse<ArticleListDataDto>.Success(dataDto));
  157. }
  158. /// <summary>
  159. /// 获取通知公告前几条数据
  160. /// </summary>
  161. /// <param name="dto"></param>
  162. /// <returns></returns>
  163. [AllowAnonymous]
  164. [HttpPost("getarticlelistbynum")]
  165. public async Task<OpenResponse> GetArticleListByNum([FromBody] ArticleIdByNumDto dto)
  166. {
  167. if (string.IsNullOrEmpty(dto.PushRanges))
  168. dto.PushRanges = "2";
  169. var items = await _bulletinRepository.Queryable()
  170. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  171. .Where(p => p.IsArrive == true)
  172. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  173. // .Where(p => p.BulletinTypeId == dto.BulletinTypeId)
  174. .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), p => p.BulletinTypeId == dto.BulletinTypeId)
  175. .WhereIF(!string.IsNullOrEmpty(dto.CheckChar), p => p.Content.Contains(dto.CheckChar))
  176. .WhereIF(!string.IsNullOrEmpty(dto.BulletinDisplayLocation), p => SqlFunc.JsonListObjectAny(p.DisplayLocation, "Key", dto.BulletinDisplayLocation))
  177. .OrderByDescending(p => p.CreationTime)
  178. .Select(it => new
  179. {
  180. DataID = it.Id,
  181. it.Title,
  182. CreateDate = it.CreationTime,
  183. it.Content,
  184. it.BulletinTypeName
  185. })
  186. .Take(dto.Num)
  187. .ToListAsync();
  188. var data = _mapper.Map<IReadOnlyList<DataListTopDto>>(items);
  189. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<DataListTopDto>>.Success(data, "成功"));
  190. }
  191. /// <summary>
  192. /// 获取详情,修改阅读次数
  193. /// </summary>
  194. /// <param name="dto"></param>
  195. /// <returns></returns>
  196. [AllowAnonymous]
  197. [HttpPost("getarticledetails")]
  198. public async Task<OpenResponse> GetArticleDetails([FromBody] ArticleIdDto dto)
  199. {
  200. var data = await _bulletinRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  201. ArticleDetailsDto detailsDto = null;
  202. if (data != null)
  203. {
  204. data.ReadedNum = data.ReadedNum++;
  205. await _bulletinRepository.UpdateAsync(data, HttpContext.RequestAborted);
  206. detailsDto = new()
  207. {
  208. NoticeID = data.Id,
  209. NoticeTypeName = data.BulletinTypeName,
  210. NoticeTitle = data.Title,
  211. NoticeBMName = data.SourceOrgName,
  212. NoticeCreateDate = data.CreationTime,
  213. NoticeRCount = data.ReadedNum,
  214. WNED_VideoUrl = "",
  215. NoticeContent = data.Content
  216. };
  217. if (data != null && !string.IsNullOrEmpty(data.Content))
  218. data.Content = _bulletinApplication.GetSiteUrls(data.Content);
  219. }
  220. else
  221. detailsDto = new();
  222. List<ArticleDetailsDto> dataDto = new() { detailsDto };
  223. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<ArticleDetailsDto>>.Success(dataDto));
  224. }
  225. /// <summary>
  226. /// 根据分类获取详情
  227. /// </summary>
  228. /// <param name="dto"></param>
  229. /// <returns></returns>
  230. [AllowAnonymous]
  231. [HttpPost("getarticledetailsbytype")]
  232. public async Task<OpenResponse> GetArticleDetailsByType([FromBody] ArticleIdByNumDto dto)
  233. {
  234. var items = await _bulletinRepository.Queryable()
  235. .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), p => p.BulletinTypeId == dto.BulletinTypeId)
  236. .OrderByDescending(p => p.CreationTime)
  237. .Take(dto.Num)
  238. .ToListAsync();
  239. List<ArticleDetailsDto> dataDto = [];
  240. if (items != null && items.Any())
  241. {
  242. foreach (var item in items)
  243. {
  244. if (!string.IsNullOrEmpty(item.Content))
  245. item.Content = _bulletinApplication.GetSiteUrls(item.Content);
  246. dataDto.Add(new()
  247. {
  248. NoticeID = item.Id,
  249. NoticeTypeName = item.BulletinTypeName,
  250. NoticeTitle = item.Title,
  251. NoticeBMName = item.SourceOrgName,
  252. NoticeCreateDate = item.CreationTime,
  253. NoticeRCount = item.ReadedNum,
  254. WNED_VideoUrl = "",
  255. NoticeContent = item.Content
  256. });
  257. }
  258. }
  259. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<ArticleDetailsDto>>.Success(dataDto));
  260. }
  261. /// <summary>
  262. /// 上一条和下一条
  263. /// </summary>
  264. /// <param name="dto"></param>
  265. /// <returns></returns>
  266. [AllowAnonymous]
  267. [HttpPost("getpreviousandnext")]
  268. public async Task<OpenResponse> GetPreviousAndNext([FromBody] ArticlePreviousAndNextDto dto)
  269. {
  270. if (string.IsNullOrEmpty(dto.PushRanges))
  271. dto.PushRanges = "2";
  272. var sugar = _bulletinRepository.Queryable()
  273. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  274. .Where(p => p.IsArrive == true)
  275. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  276. ;
  277. if (dto.FullSearch == "1")//全文搜索
  278. {
  279. if (_appOptions.Value.IsYiBin)
  280. {
  281. sugar.Where(p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
  282. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
  283. }
  284. if (_appOptions.Value.IsZiGong)
  285. {
  286. sugar.Where(p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
  287. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
  288. }
  289. }
  290. else//指定分类
  291. {
  292. sugar.WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  293. .Where(p => p.BulletinTypeId == dto.NoticeTypeId);
  294. }
  295. var list = await sugar.OrderByDescending(p => p.CreationTime)
  296. .Select(it => new
  297. {
  298. Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "),
  299. NoticeID = it.Id,
  300. NoticeTitle = it.Title,
  301. NoticeCreateDate = it.CreationTime
  302. })
  303. .ToListAsync();
  304. //数据为空返回空数据
  305. if (list == null || list.Count == 0)
  306. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
  307. else
  308. {
  309. var temp = list.Find(p => p.NoticeID == dto.ID);
  310. if (temp != null)
  311. {
  312. List<ArticlePreviousAndNextDataDto> returnDto = new();
  313. //上一条
  314. var pTemp = list.Find(p => p.Page == temp.Page - 1);
  315. if (pTemp != null)
  316. returnDto.Add(new()
  317. {
  318. NoticeID = pTemp.NoticeID,
  319. NoticeTitle = pTemp.NoticeTitle,
  320. pntype = "p"
  321. });
  322. //下一条
  323. var nTemp = list.Find(p => p.Page == temp.Page + 1);
  324. if (nTemp != null)
  325. returnDto.Add(new()
  326. {
  327. NoticeID = nTemp.NoticeID,
  328. NoticeTitle = nTemp.NoticeTitle,
  329. pntype = "n"
  330. });
  331. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(returnDto));
  332. }
  333. else
  334. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
  335. }
  336. }
  337. /// <summary>
  338. /// 全文检索
  339. /// </summary>
  340. /// <param name="dto"></param>
  341. /// <returns></returns>
  342. [AllowAnonymous]
  343. [HttpPost("getfulltextsearchlist")]
  344. public async Task<OpenResponse> GetFullTextSearchList([FromBody] QueryArticleListDto dto)
  345. {
  346. if (string.IsNullOrEmpty(dto.PushRanges))
  347. dto.PushRanges = "2";
  348. if (string.IsNullOrEmpty(dto.Condition))
  349. return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(null));
  350. RefAsync<int> total = 0;
  351. var items = await _bulletinRepository.Queryable()
  352. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  353. .Where(p => p.IsArrive == true)
  354. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  355. .WhereIF(_appOptions.Value.IsYiBin, p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
  356. .WhereIF(_appOptions.Value.IsZiGong, p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
  357. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  358. .OrderByDescending(p => p.CreationTime)
  359. .Select(it => new
  360. {
  361. Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),
  362. NoticeID = it.Id,
  363. Content = it.Content,
  364. NoticeTypeID = it.BulletinTypeId,
  365. NoticeTypeName = it.BulletinTypeName,
  366. NoticeTitle = it.Title,
  367. NoticeBMName = it.SourceOrgName,
  368. NoticeCreateDate = it.CreationTime,
  369. TypeCode = "",
  370. })
  371. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  372. //计算总页数
  373. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  374. FullTextSearchListDataDto dataDto = new()
  375. {
  376. PageCount = nPageCount,
  377. data = _mapper.Map<IReadOnlyList<FullTextSearchListDto>>(items)
  378. };
  379. return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(dataDto));
  380. }
  381. #endregion
  382. #region 用户
  383. /// <summary>
  384. /// 添加统一认证用户数据
  385. /// </summary>
  386. /// <param name="dto"></param>
  387. /// <returns></returns>
  388. [AllowAnonymous]
  389. [HttpPost("adduserauth")]
  390. public async Task<OpenResponse> AddUserAuth([FromBody] UserModelDto dto)
  391. {
  392. bool bResult = false;
  393. // 唯一记录ID
  394. string id = dto.id;
  395. // 注册用户ID
  396. string webUserID = "";
  397. // 统一认证用户注册ID
  398. string wUAID = "";
  399. //查询是否有注册用户
  400. var dataUser = await _webUserAuthRepository.GetAsync(p => p.DataId == id, HttpContext.RequestAborted);
  401. if (dataUser != null)
  402. {
  403. webUserID = dataUser.WebUserID;
  404. wUAID = dataUser.Id;
  405. }
  406. //没有注册用户添加数据
  407. if (string.IsNullOrEmpty(webUserID))
  408. {
  409. var userRegister = _mapper.Map<WebUserRegister>(dto);
  410. userRegister.RegDate = DateTime.Now;
  411. userRegister.LastDate = DateTime.Now;
  412. webUserID = await _webUserRegisterRepository.AddAsync(userRegister, HttpContext.RequestAborted);
  413. }
  414. //统一认证数据
  415. var userAuth = _mapper.Map<WebUserAuth>(dto);
  416. if (!string.IsNullOrEmpty(wUAID))
  417. {
  418. //修改数据
  419. userAuth.Id = wUAID;
  420. await _webUserAuthRepository.UpdateAsync(userAuth, HttpContext.RequestAborted);
  421. bResult = true;
  422. }
  423. else
  424. {
  425. //新增数据
  426. userAuth.WebGUID = Guid.NewGuid().ToString();
  427. userAuth.WebUserID = webUserID;
  428. var addId = await _webUserAuthRepository.AddAsync(userAuth, HttpContext.RequestAborted);
  429. if (!string.IsNullOrEmpty(addId))
  430. bResult = true;
  431. }
  432. //判断是否成功
  433. if (bResult)
  434. return OpenResponse.Ok(WebPortalDeResponse<string>.Success(webUserID));
  435. else
  436. return OpenResponse.Ok(WebPortalDeResponse<string>.Failed());
  437. }
  438. /// <summary>
  439. /// 用户中心用户写信数据
  440. /// </summary>
  441. /// <param name="dto"></param>
  442. /// <returns></returns>
  443. [HttpPost("getorderbyuserlist")]
  444. [AllowAnonymous]
  445. public async Task<OpenResponse> GetOrderByUserList([FromBody] QueryOrderListByUserDto dto)
  446. {
  447. var dataUser = await _webUserAuthRepository.GetAsync(p => p.DataId == dto.UserId, HttpContext.RequestAborted);
  448. if (dataUser != null)
  449. {
  450. RefAsync<int> total = 0;
  451. var items = await _webFlowAcceptRepository.Queryable()
  452. .LeftJoin<Hotline.Orders.Order>((o, or) => o.OrderId == or.Id)
  453. .Where(o => o.WebUserID == dataUser.WebUserID)
  454. //重新构建数据
  455. .Select((o, or) => new
  456. {
  457. FlowID = o.OrderId,
  458. FlowCode = o.Code,
  459. FlowPwd = o.Pwd,
  460. FlowTitle = o.Title,
  461. FlowFromName = or.SourceChannel,
  462. FlowPurTypeName = o.PurTypeName,
  463. ConTypeName = or.HotspotName,
  464. FlowAddDate = o.CreationTime,
  465. RSFlagName = or.Status < EOrderStatus.Filed ? "办理中" : "办理完成",
  466. WebUserID = o.WebUserID
  467. })
  468. //将结果合并成一个表
  469. .MergeTable()
  470. .Where(p => p.WebUserID == dataUser.WebUserID)
  471. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  472. //计算总页数
  473. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  474. OrderListReturnDto returnDto = new()
  475. {
  476. PageNum = dto.PageIndex,
  477. PageCount = nPageCount,
  478. Data = _mapper.Map<IReadOnlyList<OrderListDto>>(items)
  479. };
  480. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnDto>.Success(returnDto, "成功"));
  481. }
  482. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnDto>.Success(new OrderListReturnDto(), "成功"));
  483. }
  484. /// <summary>
  485. /// 用户中心用户写信数据
  486. /// </summary>
  487. /// <param name="dto"></param>
  488. /// <returns></returns>
  489. [HttpPost("getorderbyuserphonelist")]
  490. [AllowAnonymous]
  491. public async Task<OpenResponse> GetOrderByUserPhoneList([FromBody] QueryOrderListByUserDto dto)
  492. {
  493. RefAsync<int> total = 0;
  494. var items = await _webFlowAcceptRepository.Queryable()
  495. .LeftJoin<Hotline.Orders.Order>((o, or) => o.OrderId == or.Id)
  496. .Where(o => o.Mobile == dto.PhoneNum)
  497. //重新构建数据
  498. .Select((o, or) => new
  499. {
  500. FlowID = o.OrderId,
  501. FlowCode = o.Code,
  502. FlowPwd = o.Pwd,
  503. FlowTitle = o.Title,
  504. FlowFromName = or.SourceChannel,
  505. FlowPurTypeName = o.PurTypeName,
  506. ConTypeName = or.HotspotName,
  507. FlowAddDate = o.CreationTime,
  508. RSFlagName = or.Status < EOrderStatus.Filed ? "办理中" : "办理完成",
  509. Mobile = o.Mobile
  510. })
  511. //将结果合并成一个表
  512. .MergeTable()
  513. .Where(p => p.Mobile == dto.PhoneNum)
  514. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  515. //计算总页数
  516. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  517. OrderListReturnDto returnDto = new()
  518. {
  519. PageNum = dto.PageIndex,
  520. PageCount = nPageCount,
  521. Data = _mapper.Map<IReadOnlyList<OrderListDto>>(items)
  522. };
  523. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnDto>.Success(returnDto, "成功"));
  524. }
  525. #endregion
  526. #region 短信、基础设置
  527. /// <summary>
  528. /// 短信验证码发送
  529. /// </summary>
  530. /// <param name="dto"></param>
  531. /// <returns></returns>
  532. [AllowAnonymous]
  533. [HttpPost("writeletterssendsms")]
  534. public async Task<OpenResponse> WriteLettersSendSms([FromBody] WebPortalSendSmsModelDto dto)
  535. {
  536. string keyToken = "SmsUserWriteKey_" + dto.TelNum + "_" + DateTime.Now.ToString("yyyyMMdd");
  537. var data = await _writeLettersSendSms.GetAsync(keyToken, HttpContext.RequestAborted);
  538. if (data != null)//已经发过短信
  539. {
  540. //是否可以继续发送短信(10次)
  541. if (data.SendCount > 10)
  542. //短信发送超过10条
  543. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-2"));
  544. // 验证是否在两分钟之内
  545. TimeSpan duration = DateTime.Now - data.AddTime; // 计算时间差
  546. if ((int)duration.TotalSeconds < 120)
  547. // 距离上次发送时间不足两分钟
  548. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-4"));
  549. //修改缓存信息
  550. data.SendCount++;
  551. data.SmsCode = dto.SmsCode;
  552. data.AddTime = DateTime.Now;
  553. }
  554. else
  555. {
  556. //没有发过短信,直接写入数据
  557. data = new WriteLettersSendSmsDto
  558. {
  559. AddTime = DateTime.Now,
  560. SmsCode = dto.SmsCode,
  561. MobileNum = dto.TelNum,
  562. SendCount = 1
  563. };
  564. }
  565. //这里发送短信 宜宾12345市民服务热线网站验证码{0},用于写信时验证联系电话。验证码有效期10分钟。
  566. var messageDto = new Share.Dtos.Push.MessageDto
  567. {
  568. PushBusiness = EPushBusiness.MsgCode,
  569. ExternalId = "",
  570. OrderId = "",
  571. PushPlatform = EPushPlatform.Web,
  572. Remark = "",
  573. Name = dto.TelNum,
  574. TemplateCode = "1008",
  575. Params = new List<string>() { dto.SmsCode },
  576. TelNumber = dto.TelNum,
  577. };
  578. await _mediator.Publish(new PushMessageNotify(messageDto), HttpContext.RequestAborted);
  579. //修改缓存
  580. await _writeLettersSendSms.SetAsync(keyToken, data, TimeSpan.FromDays(1), HttpContext.RequestAborted);
  581. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("1"));
  582. }
  583. /// <summary>
  584. /// 验证短信验证码是否正确 正确返回1,错误返回-1
  585. /// </summary>
  586. /// <param name="dto"></param>
  587. /// <returns></returns>
  588. [AllowAnonymous]
  589. [HttpPost("checksmscode")]
  590. public async Task<OpenResponse> CheckSmsCode([FromBody] WebPortalSendSmsModelDto dto)
  591. {
  592. string keyToken = "SmsUserWriteKey_" + dto.TelNum + "_" + DateTime.Now.ToString("yyyyMMdd");
  593. var data = await _writeLettersSendSms.GetAsync(keyToken, HttpContext.RequestAborted);
  594. //检测是否存在
  595. if (data != null)
  596. return OpenResponse.Ok(WebPortalDeResponse<string>.Success(data.SmsCode));
  597. //不存在
  598. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-1"));
  599. }
  600. /// <summary>
  601. /// 获取热点分类的树形
  602. /// </summary>
  603. /// <returns></returns>
  604. [AllowAnonymous]
  605. [HttpPost("gethotspottreelist")]
  606. public async Task<OpenResponse> GetHotspotTreeList()
  607. {
  608. var data = await _hotspotRepository.Queryable().ToTreeAsync(it => it.Children, it => it.ParentId, null);
  609. return OpenResponse.Ok(WebPortalDeResponse<List<Hotspot>>.Success(data));
  610. }
  611. /// <summary>
  612. /// 系统主题颜色
  613. /// </summary>
  614. /// <returns></returns>
  615. [AllowAnonymous]
  616. [HttpPost("getsystemsettingstheme")]
  617. public async Task<OpenResponse> GetSystemSettingsTheme()
  618. {
  619. var WebSystemSettingsTheme = bool.Parse(_systemSettingCacheManager.GetSetting(SettingConstants.WebSystemSettingsTheme).SettingValue[0]);
  620. if (WebSystemSettingsTheme == false)
  621. return OpenResponse.Ok(WebPortalDeResponse<string>.Success(""));
  622. else
  623. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("class=gray2"));
  624. }
  625. #endregion
  626. #region 办件
  627. /// <summary>
  628. /// 获取信件前6条数据
  629. /// </summary>
  630. /// <param name="dto"></param>
  631. /// <returns></returns>
  632. [HttpPost("getorderlistbynum")]
  633. [AllowAnonymous]
  634. public async Task<OpenResponse> GetOrderListByNum([FromBody] QueryOrderListByNumDto dto)
  635. {
  636. var queryNew = _orderRepository.Queryable()
  637. .LeftJoin<OrderPublish>((p, op) => p.Id == op.OrderId)
  638. .Where(p => p.IsPublicity == true)
  639. .OrderByDescending((p, op) => p.CreationTime)
  640. .Select((p, op) => new DataListTopDto
  641. {
  642. DataID = p.Id,
  643. Title = p.Title,
  644. CreateDate = op.CreationTime
  645. });
  646. var queryold = _oldPublicDataRepository.Queryable()
  647. .OrderByDescending(p => p.PubDate)
  648. .Select(p => new DataListTopDto
  649. {
  650. DataID = p.OrderId,
  651. Title = p.Title,
  652. CreateDate = p.CreationTime
  653. });
  654. var items = await _orderRepository.UnionAll(queryNew, queryold)
  655. .OrderByDescending(p => p.CreateDate)
  656. .Take(dto.Num)
  657. .ToListAsync();
  658. var data = _mapper.Map<IReadOnlyList<DataListTopDto>>(items);
  659. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<DataListTopDto>>.Success(data, "成功"));
  660. }
  661. /// <summary>
  662. /// 办件摘编列表数据
  663. /// </summary>
  664. /// <param name="dto"></param>
  665. /// <returns></returns>
  666. [HttpPost("getorderlist")]
  667. [AllowAnonymous]
  668. public async Task<OpenResponse> GetOrderList([FromBody] QueryOrderListDto dto)
  669. {
  670. RefAsync<int> total = 0;
  671. var queryNew = _orderPublishRepository.Queryable()
  672. .Includes(d => d.Order)
  673. .Where(d => d.PublishState == true && d.Order.Id != null)
  674. .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), d => d.Order.No == dto.FlowCode)
  675. .WhereIF(!string.IsNullOrEmpty(dto.FlowName), d => d.Order.Title.Contains(dto.FlowName))
  676. .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), d => d.Order.AcceptTypeCode == dto.FlowSType)
  677. .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), d => d.Order.HotspotId == dto.FlowRType)
  678. .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), d => d.Order.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate
  679. .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), d => d.Order.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate
  680. .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), d => d.Order.FromName.Contains(dto.FlowFrom))
  681. .OrderByDescending(p => p.CreationTime)
  682. .Select(p => new OrderListDto
  683. {
  684. FlowID = p.OrderId,
  685. FlowCode = p.No,
  686. FlowPwd = p.Order.Password,
  687. FlowTitle = p.Order.Title,
  688. FlowFromName = p.Order.SourceChannel,
  689. FlowPurTypeName = p.Order.AcceptType,
  690. ConTypeName = p.Order.HotspotName,
  691. FlowAddDate = p.Order.CreationTime,
  692. RSFlagName = p.Order.Status >= EOrderStatus.Filed ? "办理完成" : "办理中",
  693. PubDate = p.CreationTime
  694. });
  695. var queryold = _oldPublicDataRepository.Queryable()
  696. .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), d => d.OrderNo == dto.FlowCode)
  697. .WhereIF(!string.IsNullOrEmpty(dto.FlowName), d => d.Title.Contains(dto.FlowName))
  698. .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), d => d.AcceptTypeCode == dto.FlowSType)
  699. .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), d => d.PubDate >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate
  700. .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), d => d.PubDate <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate
  701. .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), d => d.FromName.Contains(dto.FlowFrom))
  702. .OrderByDescending(p => p.PubDate)
  703. .Select(p => new OrderListDto
  704. {
  705. FlowID = p.OrderId,
  706. FlowCode = p.OrderNo,
  707. FlowPwd = p.OrderPwd,
  708. FlowTitle = p.Title,
  709. FlowFromName = p.SourceChannel,
  710. FlowPurTypeName = p.AcceptType,
  711. ConTypeName = p.HotspotName,
  712. FlowAddDate = p.AcceptTime,
  713. RSFlagName = p.State == "1" ? "办理完成" : "办理中",
  714. PubDate = p.CreationTime
  715. });
  716. var items = await _orderRepository.UnionAll(queryNew, queryold)
  717. .OrderByDescending(p => p.PubDate)
  718. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  719. //计算总页数
  720. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  721. OrderListReturnDto returnDto = new()
  722. {
  723. PageNum = dto.PageIndex,
  724. PageCount = nPageCount,
  725. Data = _mapper.Map<IReadOnlyList<OrderListDto>>(items)
  726. };
  727. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnDto>.Success(returnDto, "成功"));
  728. }
  729. /// <summary>
  730. /// 查询工单发布后公开的数据
  731. /// </summary>
  732. /// <param name="dto"></param>
  733. /// <returns></returns>
  734. [HttpPost("get_order_list_publish_all")]
  735. [AllowAnonymous]
  736. public async Task<OpenResponse> GetOrderByListAllOpen([FromBody] QueryOrderListDto dto)
  737. {
  738. var queryNew = _orderPublishRepository.Queryable()
  739. .LeftJoin<Order>((op, p) => p.Id == op.OrderId)
  740. .Where((op, p) => op.PublishState == true)
  741. .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), (op, p) => p.No == dto.FlowCode)
  742. .WhereIF(!string.IsNullOrEmpty(dto.FlowName), (op, p) => op.ArrangeTitle.Contains(dto.FlowName))
  743. .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), (op, p) => p.AcceptTypeCode == dto.FlowSType)
  744. .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), (op, p) => p.HotspotId == dto.FlowRType)
  745. .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), (op, p) => p.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate
  746. .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), (op, p) => p.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate
  747. .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), (op, p) => p.FromName.Contains(dto.FlowFrom))
  748. .WhereIF(dto.IdentityType.HasValue, (op, p) => p.IdentityType == dto.IdentityType)
  749. .OrderByDescending((op, p) => p.CreationTime)
  750. .Select((op, p) => new OrderListDto
  751. {
  752. FlowID = p.Id,
  753. FlowCode = p.No,
  754. FlowPwd = p.Password,
  755. FlowTitle = op.ArrangeTitle,
  756. FlowFromName = p.SourceChannel,
  757. FlowPurTypeName = p.AcceptType,
  758. ConTypeName = p.HotspotName,
  759. FlowAddDate = p.CreationTime,
  760. PubDate = op.CreationTime,
  761. RSFlagName = p.Status >= EOrderStatus.Filed ? "办理完成" : "办理中"
  762. });
  763. var queryold = _oldPublicDataRepository.Queryable()
  764. .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), p => p.OrderNo == dto.FlowCode)
  765. .WhereIF(!string.IsNullOrEmpty(dto.FlowName), p => p.Title.Contains(dto.FlowName))
  766. .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), p => p.AcceptTypeCode == dto.FlowSType)
  767. .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), p => p.HotspotId == dto.FlowRType)
  768. .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), p => p.AcceptTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate
  769. .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), p => p.AcceptTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate
  770. .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), p => p.FromName.Contains(dto.FlowFrom))
  771. .WhereIF(dto.IdentityType.HasValue, p => p.IdentityType == dto.IdentityType)
  772. .OrderByDescending(p => p.PubDate)
  773. .Select(p => new OrderListDto
  774. {
  775. FlowID = p.OrderId,
  776. FlowCode = p.OrderNo,
  777. FlowPwd = p.OrderPwd,
  778. FlowTitle = p.Title,
  779. FlowFromName = p.SourceChannelCode,
  780. FlowPurTypeName = p.AcceptTypeCode,
  781. ConTypeName = p.HotspotName,
  782. FlowAddDate = p.CreationTime,
  783. PubDate = p.CreationTime,
  784. RSFlagName = p.State == "1" ? "办理完成" : "办理中"
  785. });
  786. var (total, items) = await _orderRepository.UnionAll(queryNew, queryold)
  787. .OrderByDescending(p => p.PubDate)
  788. .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
  789. //计算总页数
  790. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  791. OrderListReturnDto returnDto = new()
  792. {
  793. Total = total,
  794. PageNum = dto.PageIndex,
  795. PageCount = nPageCount,
  796. Data = _mapper.Map<IReadOnlyList<OrderListDto>>(items)
  797. };
  798. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnDto>.Success(returnDto, "成功"));
  799. }
  800. /// <summary>
  801. /// 查询工单发布后公开的数据
  802. /// </summary>
  803. /// <param name="dto"></param>
  804. /// <returns></returns>
  805. [HttpPost("get_order_list_all_bynoortitle")]
  806. [AllowAnonymous]
  807. public async Task<OpenResponse> GetOrderByListAllByNoOrTitle([FromBody] QueryOrderListDto dto)
  808. {
  809. var (total, items) = await _orderPublishRepository.Queryable()
  810. .LeftJoin<Order>((op, p) => p.Id == op.OrderId)
  811. .WhereIF(!string.IsNullOrEmpty(dto.FlowCode), (op, p) => p.No == dto.FlowCode)
  812. .WhereIF(!string.IsNullOrEmpty(dto.FlowName), (op, p) => op.ArrangeTitle.Contains(dto.FlowName))
  813. .WhereIF(!string.IsNullOrEmpty(dto.FlowSType), (op, p) => p.AcceptTypeCode == dto.FlowSType)
  814. .WhereIF(!string.IsNullOrEmpty(dto.FlowRType), (op, p) => p.HotspotId == dto.FlowRType)
  815. .WhereIF(!string.IsNullOrEmpty(dto.FlowSDate), (op, p) => p.StartTime >= DateTime.Parse(DateTime.Parse(dto.FlowSDate).ToString("yyyy-MM-dd 00:00:00")))//dto.FlowSDate
  816. .WhereIF(!string.IsNullOrEmpty(dto.FlowEDate), (op, p) => p.StartTime <= DateTime.Parse(DateTime.Parse(dto.FlowEDate).ToString("yyyy-MM-dd 00:00:00")))// dto.FlowEDate
  817. .WhereIF(!string.IsNullOrEmpty(dto.FlowFrom), (op, p) => p.FromName.Contains(dto.FlowFrom))
  818. .WhereIF(dto.IdentityType.HasValue, (op, p) => p.IdentityType == dto.IdentityType)
  819. .OrderByDescending((op, p) => p.CreationTime)
  820. .Select((op, p) => new OrderListDto
  821. {
  822. FlowID = p.Id,
  823. FlowCode = p.No,
  824. FlowPwd = p.Password,
  825. FlowTitle = op.ArrangeTitle,
  826. FlowFromName = p.SourceChannel,
  827. FlowPurTypeName = p.AcceptType,
  828. ConTypeName = p.HotspotName,
  829. FlowAddDate = p.CreationTime,
  830. PubDate = op.CreationTime,
  831. RSFlagName = p.Status >= EOrderStatus.Filed ? "办理完成" : "办理中"
  832. })
  833. .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
  834. OrderListReturnAllDto returnDto = new()
  835. {
  836. Total = total,
  837. Data = _mapper.Map<IReadOnlyList<OrderListDto>>(items)
  838. };
  839. return OpenResponse.Ok(WebPortalDeResponse<OrderListReturnAllDto>.Success(returnDto, "成功"));
  840. }
  841. /// <summary>
  842. /// 办件摘编详情
  843. /// </summary>
  844. /// <param name="dto"></param>
  845. /// <returns></returns>
  846. [AllowAnonymous]
  847. [HttpPost("getorderdetailbyid")]
  848. public async Task<OpenResponse> GetOrderDetailById([FromBody] ArticleIdDto dto)
  849. {
  850. var data = await _orderRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  851. var orderDetail = _mapper.Map<OrderDetail>(data);
  852. if (_appOptions.Value.IsZiGong)
  853. {
  854. orderDetail.FlowResult = "";
  855. }
  856. if (data != null)
  857. {
  858. //如果是省工单或者是省政民互动的工单,市民不能进行评价
  859. if (data.IsProvince == true || data.SourceChannelCode == "ZMHD")
  860. orderDetail.IsProvinceOrder = "1";
  861. else
  862. orderDetail.IsProvinceOrder = "0";
  863. //获取发布的数据
  864. var orderPublish = await _orderPublishRepository.GetAsync(p => p.OrderId == data.Id, HttpContext.RequestAborted);
  865. if (orderPublish != null)
  866. {
  867. orderDetail.PubFlag = "1";
  868. orderDetail.FlowTitle = orderPublish.ArrangeTitle;
  869. orderDetail.FlowContent = orderPublish.ArrangeContent;
  870. if (_appOptions.Value.IsZiGong)
  871. {
  872. if (data.Source == ESource.ProvinceStraight)
  873. orderDetail.FlowResult = orderPublish.ArrangeOpinion;
  874. if (data.Source != ESource.ProvinceStraight && data.Status >= EOrderStatus.Visited)
  875. orderDetail.FlowResult = orderPublish.ArrangeOpinion;
  876. }
  877. else
  878. orderDetail.FlowResult = orderPublish.ArrangeOpinion;
  879. if (orderPublish.PublishState)
  880. orderDetail.FlowPubFlagName = "公开";
  881. }
  882. //能否进行评价
  883. var orderVisit = await _orderVisitRepository.GetAsync(p => p.OrderId == data.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  884. if (orderVisit == null)
  885. orderDetail.VisitType = "0";
  886. else
  887. {
  888. orderDetail.VisitType = orderVisit.VisitState switch
  889. {
  890. EVisitState.WaitForVisit => "1",
  891. EVisitState.Visited => "2",
  892. EVisitState.Visiting or EVisitState.NoSatisfiedWaitForVisit or EVisitState.None => "0",
  893. _ => "0",
  894. };
  895. }
  896. }
  897. List<OrderDetail> dataDto = new() { orderDetail };
  898. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<OrderDetail>>.Success(dataDto));
  899. }
  900. /// <summary>
  901. /// 根据编号和密码查询信件ID
  902. /// </summary>
  903. /// <param name="dto"></param>
  904. /// <returns></returns>
  905. [AllowAnonymous]
  906. [HttpPost("getorderid")]
  907. public async Task<OpenResponse> GetOrderId([FromBody] GetOrderCodePwd dto)
  908. {
  909. var data = await _orderRepository.GetAsync(p => p.No == dto.OrderNo && p.Password == dto.Pwd, HttpContext.RequestAborted);//&& p.Status > EOrderStatus.Published
  910. return OpenResponse.Ok(WebPortalDeResponse<string>.Success(data?.Id));
  911. }
  912. /// <summary>
  913. /// 办件摘编详情
  914. /// </summary>
  915. /// <param name="dto"></param>
  916. /// <returns></returns>
  917. [AllowAnonymous]
  918. [HttpPost("getorderdetailbyno")]
  919. public async Task<OpenResponse> GetOrderDetailByNo([FromBody] GetOrderCodePwd dto)
  920. {
  921. var data = await _orderRepository.GetAsync(p => p.No == dto.OrderNo && p.Password == dto.Pwd, HttpContext.RequestAborted);
  922. if (data != null)
  923. {
  924. var orderDetail = _mapper.Map<OrderDetail>(data);
  925. if (data != null)
  926. {
  927. //如果是省工单或者是省政民互动的工单,市民不能进行评价
  928. if (data.IsProvince == true || data.SourceChannelCode == "ZMHD")
  929. orderDetail.IsProvinceOrder = "1";
  930. else
  931. orderDetail.IsProvinceOrder = "0";
  932. //获取发布的数据
  933. var orderPublish = await _orderPublishRepository.GetAsync(p => p.OrderId == data.Id, HttpContext.RequestAborted);
  934. if (orderPublish != null)
  935. {
  936. orderDetail.PubFlag = "1";
  937. orderDetail.FlowTitle = orderPublish.ArrangeTitle;
  938. orderDetail.FlowContent = orderPublish.ArrangeContent;
  939. orderDetail.FlowResult = orderPublish.ArrangeOpinion;
  940. if (orderPublish.PublishState)
  941. orderDetail.FlowPubFlagName = "公开";
  942. }
  943. //能否进行评价
  944. var orderVisit = await _orderVisitRepository.GetAsync(p => p.OrderId == data.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  945. if (orderVisit == null)
  946. orderDetail.VisitType = "0";
  947. else
  948. {
  949. orderDetail.VisitType = orderVisit.VisitState switch
  950. {
  951. EVisitState.WaitForVisit => "1",
  952. EVisitState.Visited => "2",
  953. EVisitState.Visiting or EVisitState.NoSatisfiedWaitForVisit or EVisitState.None => "0",
  954. _ => "0",
  955. };
  956. }
  957. }
  958. List<OrderDetail> dataDto = new() { orderDetail };
  959. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<OrderDetail>>.Success(dataDto));
  960. }
  961. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<string>>.Failed(code: "0", description: "查询失败"));
  962. }
  963. /// <summary>
  964. /// 写信接口
  965. /// </summary>
  966. /// <param name="dto"></param>
  967. /// <returns></returns>
  968. [AllowAnonymous]
  969. [HttpPost("orderacceptance")]
  970. public async Task<OpenResponse> OrderAcceptance([FromBody] WebFlowAcceptDto dto)
  971. {
  972. //电话号码去空格
  973. if (!string.IsNullOrEmpty(dto.Mobile))
  974. dto.Mobile = dto.Mobile.Trim();
  975. var data = _mapper.Map<Hotline.Share.Dtos.Order.AddOrderDto>(dto);
  976. data.Source = ESource.WebPortal;
  977. data.SourceChannel = "因特网";
  978. data.SourceChannelCode = "YTW";
  979. switch (dto.FromID)
  980. {
  981. case "2":
  982. data.SourceChannel = "APP";
  983. data.SourceChannelCode = "AP";
  984. data.Source = ESource.APP;
  985. break;
  986. case "3":
  987. data.SourceChannel = "微信小程序";
  988. data.SourceChannelCode = "XCX";
  989. data.Source = ESource.WeChat;
  990. break;
  991. case "9"://宜宾人社专用
  992. data.SourceChannel = "人社APP";
  993. data.SourceChannelCode = "RSAPP";
  994. data.Source = ESource.YBHumanSocietyAPP;
  995. break;
  996. default:
  997. break;
  998. }
  999. if (!string.IsNullOrEmpty(data.LicenceNo))
  1000. {
  1001. data.LicenceTypeCode = "10";
  1002. data.LicenceType = "中华人民共和国居民身份证";
  1003. }
  1004. data.ExternalId = Guid.NewGuid().ToString();
  1005. data.IdentityType = dto.IdentityType;
  1006. data.Transpond = false;
  1007. data.IsEnforcementOrder = false;
  1008. var result = await _orderApplication.ReceiveOrderFromExternalAsync(data, HttpContext.RequestAborted);
  1009. OrderAcceptanceReturnDto returnDto = new();
  1010. if (result != null)
  1011. {
  1012. returnDto.PWD = result.Password;
  1013. returnDto.Code = result.No;
  1014. returnDto.State = "1";
  1015. dto.Pwd = result.Password;
  1016. dto.Code = result.No;
  1017. dto.OrderId = result.Id;
  1018. var dtoData = _mapper.Map<WebFlowAccept>(dto);
  1019. await _webFlowAcceptRepository.AddAsync(dtoData, HttpContext.RequestAborted);
  1020. }
  1021. else
  1022. returnDto.State = "0";
  1023. return OpenResponse.Ok(WebPortalDeResponse<OrderAcceptanceReturnDto>.Success(returnDto));
  1024. }
  1025. /// <summary>
  1026. /// 受理类型和热点统计
  1027. /// </summary>
  1028. /// <returns></returns>
  1029. [AllowAnonymous]
  1030. [HttpPost("getchartdata")]
  1031. public async Task<OpenResponse> GetChartData()
  1032. {
  1033. var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  1034. var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1035. //数据查询
  1036. var listType = await _orderRepository.Queryable()
  1037. .Where(p => p.CreationTime >= startDate && p.CreationTime <= endDate && p.Status > EOrderStatus.WaitForAccept)
  1038. .Select(it => new
  1039. {
  1040. it.AcceptType,
  1041. it.AcceptTypeCode
  1042. })
  1043. .MergeTable()//将查询出来的结果合并成一个新表
  1044. .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组
  1045. .Select(it => new
  1046. {
  1047. name = it.AcceptType,
  1048. value = SqlFunc.AggregateCount(it.AcceptTypeCode)
  1049. })
  1050. .ToListAsync();
  1051. var listHot = await _orderRepository.Queryable()
  1052. .Where(it => it.CreationTime >= startDate && it.CreationTime <= endDate && it.Status > EOrderStatus.WaitForAccept)
  1053. .Select(it => new
  1054. {
  1055. HotspotId = it.HotspotId.Substring(SqlFunc.MappingColumn<int>("0"), SqlFunc.MappingColumn<int>("2")),
  1056. })
  1057. .MergeTable()
  1058. .Where(it => it.HotspotId != "18")
  1059. .GroupBy(it => it.HotspotId)//对新表进行分组
  1060. .Select(it => new
  1061. {
  1062. HotspotId = it.HotspotId,
  1063. num = SqlFunc.AggregateCount(it.HotspotId)
  1064. })
  1065. .OrderByDescending(it => it.num)
  1066. .Take(5)
  1067. .MergeTable()
  1068. .LeftJoin<Hotspot>((it, h) => it.HotspotId == h.Id)
  1069. .Select((it, h) => new
  1070. {
  1071. typeName = h.HotSpotName,
  1072. num = it.num
  1073. }).ToListAsync();
  1074. ////数据查询-查询总数前5的数据
  1075. //var listHot = await _orderRepository.Queryable()
  1076. // .Where(p => p.StartTime >= startDate && p.StartTime <= endDate && p.Status > EOrderStatus.WaitForAccept)
  1077. // .Select(it => new
  1078. // {
  1079. // it.HotspotId,
  1080. // it.HotspotName
  1081. // })
  1082. // .MergeTable()//将查询出来的结果合并成一个新表
  1083. // .GroupBy(it => new { it.HotspotId, it.HotspotName })//对新表进行分组
  1084. // .Select(it => new
  1085. // {
  1086. // typeName = it.HotspotName,
  1087. // num = SqlFunc.AggregateCount(it.HotspotId)
  1088. // })
  1089. // .OrderByDescending(it => it.num)
  1090. // .Take(5)
  1091. // .ToListAsync();
  1092. GetChartDataDto dataDto = new()
  1093. {
  1094. formCount = _mapper.Map<IReadOnlyList<OrderFormCount>>(listType),
  1095. hotCount = _mapper.Map<IReadOnlyList<OrderHotCount>>(listHot)
  1096. };
  1097. return OpenResponse.Ok(WebPortalDeResponse<GetChartDataDto>.Success(dataDto));
  1098. }
  1099. /// <summary>
  1100. /// 获取统计数据
  1101. /// </summary>
  1102. /// <returns></returns>
  1103. [AllowAnonymous]
  1104. [HttpPost("getstatist")]
  1105. public async Task<OpenResponse> GetStatist()
  1106. {
  1107. var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  1108. var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1109. //GetStatistDto getStatistDto = new()
  1110. //{
  1111. // AllCount = await _orderRepository.Queryable().Where(p => p.Status > EOrderStatus.WaitForAccept).CountAsync(),
  1112. // AllTrandCount = await _orderRepository.Queryable().Where(p => p.Status >= EOrderStatus.Filed).CountAsync(),
  1113. // DayCount = await _orderRepository.Queryable().Where(p => p.StartTime >= startDate && p.StartTime <= endDate && p.Status > EOrderStatus.WaitForAccept).CountAsync(),
  1114. // DayTrandCount = await _orderRepository.Queryable().Where(p => p.ActualHandleTime >= startDate && p.ActualHandleTime <= endDate && p.Status >= EOrderStatus.Filed).CountAsync()
  1115. //};
  1116. var getStatistDto = await _orderRepository.Queryable()
  1117. .Select(p => new GetStatistDto
  1118. {
  1119. AllCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Status > EOrderStatus.WaitForAccept, 1, 0)) + 7079457,
  1120. AllTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.Status >= EOrderStatus.Filed, 1, 0)) + 7079214,
  1121. DayCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.Status > EOrderStatus.WaitForAccept, 1, 0)),
  1122. DayTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.FiledTime >= startDate && p.FiledTime <= endDate && p.Status >= EOrderStatus.Filed, 1, 0)),
  1123. })
  1124. .FirstAsync();
  1125. return OpenResponse.Ok(WebPortalDeResponse<GetStatistDto>.Success(getStatistDto));
  1126. }
  1127. /// <summary>
  1128. /// 获取统计数据 今日数据
  1129. /// </summary>
  1130. /// <returns></returns>
  1131. [AllowAnonymous]
  1132. [HttpPost("todaygetstatist")]
  1133. public async Task<OpenResponse> GetTodayStatist()
  1134. {
  1135. var startDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  1136. var endDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  1137. var getStatistDto = await _orderRepository.Queryable()
  1138. .Select(p => new GetStatistDto
  1139. {
  1140. DayCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.Status > EOrderStatus.WaitForAccept, 1, 0)),
  1141. DayTrandCount = SqlFunc.AggregateSum(SqlFunc.IIF(p.CreationTime >= startDate && p.CreationTime <= endDate && p.FiledTime >= startDate && p.FiledTime <= endDate && p.Status >= EOrderStatus.Filed, 1, 0)),
  1142. })
  1143. .FirstAsync();
  1144. return OpenResponse.Ok(WebPortalDeResponse<GetStatistDto>.Success(getStatistDto));
  1145. }
  1146. #endregion
  1147. #region 评价
  1148. /// <summary>
  1149. /// 获取待评价部门信息
  1150. /// </summary>
  1151. /// <param name="dto"></param>
  1152. /// <returns></returns>
  1153. [AllowAnonymous]
  1154. [HttpPost("getwaitvisitdata")]
  1155. public async Task<OpenResponse> GetWaitVisitData([FromBody] ArticleIdDto dto)
  1156. {
  1157. var dataOrder = await _orderVisitRepository.GetAsync(p => p.OrderId == dto.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  1158. if (dataOrder == null)
  1159. return OpenResponse.Ok(WebPortalDeResponse<List<WaitVisitListDataDto>>.Failed("工单不能评价!"));
  1160. if (dataOrder.VisitState != EVisitState.WaitForVisit)
  1161. return OpenResponse.Ok(WebPortalDeResponse<List<WaitVisitListDataDto>>.Failed("工单已经评价!"));
  1162. var data = await _orderVisitDetailRepository.Queryable()
  1163. .Where(p => p.VisitId == dataOrder.Id && p.VisitTarget == EVisitTarget.Org)
  1164. .ToListAsync();
  1165. var listDat = _mapper.Map<List<WaitVisitListDataDto>>(data);
  1166. return OpenResponse.Ok(WebPortalDeResponse<List<WaitVisitListDataDto>>.Success(listDat));
  1167. }
  1168. /// <summary>
  1169. /// 评价内容
  1170. /// </summary>
  1171. /// <param name="dto"></param>
  1172. /// <returns></returns>
  1173. [AllowAnonymous]
  1174. [HttpPost("receivevisitdata")]
  1175. public async Task<OpenResponse> ReceiveVisitData([FromBody] OrderVisitListDataDto dto)
  1176. {
  1177. if (dto == null || dto.VistListDtos == null || dto.VistListDtos.Count == 0)
  1178. return OpenResponse.Ok(WebPortalDeResponse<string>.Failed("评价数据不能为空!"));
  1179. var dataOrder = await _orderVisitRepository.GetAsync(p => p.OrderId == dto.OrderId && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  1180. if (dataOrder == null)
  1181. return OpenResponse.Ok(WebPortalDeResponse<string>.Failed("工单已经评价!"));
  1182. //组装数据
  1183. OrderVisitWebDto visitWebDto = new()
  1184. {
  1185. VisitType = Hotline.Share.Enums.Order.EVisitType.WebVisit,
  1186. VisitTime = DateTime.Now
  1187. };
  1188. List<OrderVisitDetailWebDto> orderVisitDetails = new();
  1189. #region 部门评价
  1190. //部门评价
  1191. //遍历数据
  1192. foreach (var item in dto.VistListDtos)
  1193. {
  1194. Hotline.Share.Dtos.Kv kv = item.SatisfactionCode switch
  1195. {
  1196. "5" => new Hotline.Share.Dtos.Kv { Key = "5", Value = "非常满意" },
  1197. "4" => new Hotline.Share.Dtos.Kv { Key = "4", Value = "满意" },
  1198. "2" => new Hotline.Share.Dtos.Kv { Key = "2", Value = "不满意" },
  1199. _ => new Hotline.Share.Dtos.Kv { Key = "7", Value = "不做评价" },
  1200. };
  1201. //组装回访数据
  1202. visitWebDto.Id = item.VisitId;
  1203. OrderVisitDetailWebDto detailDto = new()
  1204. {
  1205. Id = item.Id,
  1206. VisitTarget = Hotline.Share.Enums.Order.EVisitTarget.Org,
  1207. OrgProcessingResults = kv,
  1208. OrgNoSatisfiedReason = new List<Hotline.Share.Dtos.Kv>(),
  1209. OrgHandledAttitude = kv,
  1210. VisitContent = item.VisitContent
  1211. };
  1212. orderVisitDetails.Add(detailDto);
  1213. }
  1214. #endregion
  1215. visitWebDto.OrderVisitDetailDto = orderVisitDetails;
  1216. //推送数据
  1217. await _orderApplication.OrderVisitWeb(visitWebDto, HttpContext.RequestAborted);
  1218. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("1"));
  1219. }
  1220. #endregion
  1221. #region 知识库
  1222. /// <summary>
  1223. /// 获取知识库分类
  1224. /// </summary>
  1225. /// <returns></returns>
  1226. [HttpPost("getknowledgetype")]
  1227. [AllowAnonymous]
  1228. public async Task<OpenResponse> GetKnowledgeType()
  1229. {
  1230. //查询知识分类
  1231. var item = await _knowledgeTypeRepository.Queryable()
  1232. .Where(p => p.ParentId == null || p.ParentId == "")
  1233. .Select(p => new
  1234. {
  1235. SDICT_ID = p.Id,
  1236. SDICT_Name = p.Name
  1237. })
  1238. .ToListAsync();
  1239. //查询知识标签
  1240. var list = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.KnowledgeBaseTags).Select(p => new
  1241. {
  1242. SDICT_Name = p.DicDataName,
  1243. SDICT_ID = p.DicDataName
  1244. }).ToList();
  1245. var rsp = new
  1246. {
  1247. KnowledgeType = item,
  1248. KnowledgeBaseTags = list,
  1249. };
  1250. return OpenResponse.Ok(WebPortalDeResponse<object>.Success(rsp));
  1251. }
  1252. /// <summary>
  1253. /// 知识库查询
  1254. /// </summary>
  1255. /// <param name="dto"></param>
  1256. /// <returns></returns>
  1257. [HttpPost("getknowledgelist")]
  1258. [AllowAnonymous]
  1259. public async Task<OpenResponse> GetKnowledgeList([FromBody] QueryKnowledgeList dto)
  1260. {
  1261. var typeSpliceName = string.Empty;
  1262. if (!string.IsNullOrEmpty(dto.KnowledgeTypeId))
  1263. {
  1264. var type = await _knowledgeTypeRepository.GetAsync(x => x.Name == dto.KnowledgeTypeId);
  1265. typeSpliceName = type?.SpliceName;
  1266. }
  1267. var typeSpliceNameTags = string.Empty;
  1268. if (!string.IsNullOrEmpty(dto.KnowledgeBaseTags))
  1269. {
  1270. var type = await _knowledgeWordRepository.GetAsync(x => x.Tag == dto.KnowledgeBaseTags && x.IsEnable == 1);
  1271. typeSpliceNameTags = type?.Id;
  1272. }
  1273. var (total, items) = await _knowledgeRepository.Queryable()
  1274. .Where(p => p.IsPublic == true && p.Status == EKnowledgeStatus.OnShelf)
  1275. .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title))
  1276. .WhereIF(!string.IsNullOrEmpty(typeSpliceNameTags), p => SqlFunc.JsonArrayAny(p.Keywords, typeSpliceNameTags) == true)
  1277. .WhereIF(!string.IsNullOrEmpty(typeSpliceName), x => x.KnowledgeType.Any(t => t.KnowledgeTypeSpliceName.EndsWith(typeSpliceName)))
  1278. .OrderByDescending(p => p.CreationTime)
  1279. .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
  1280. var data = new PagedDto<KnowledgeInfoDto>(total, _mapper.Map<IReadOnlyList<KnowledgeInfoDto>>(items));
  1281. return OpenResponse.Ok(WebPortalDeResponse<PagedDto<KnowledgeInfoDto>>.Success(data));
  1282. }
  1283. /// <summary>
  1284. /// 获取知识库详情
  1285. /// </summary>
  1286. /// <param name="dto"></param>
  1287. /// <returns></returns>
  1288. [HttpPost("getknowledgeinfo")]
  1289. [AllowAnonymous]
  1290. public async Task<OpenResponse> GetKnowledgeInfo([FromBody] QueryKnowledgeInfo dto)
  1291. {
  1292. var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  1293. KnowledgeInfoDto detailsDto = null;
  1294. if (data != null)
  1295. {
  1296. detailsDto = _mapper.Map<KnowledgeInfoDto>(data);
  1297. if (detailsDto != null && !string.IsNullOrEmpty(detailsDto.Content))
  1298. data.Content = _bulletinApplication.GetSiteUrls(data.Content);
  1299. }
  1300. else
  1301. {
  1302. detailsDto = new();
  1303. }
  1304. List<KnowledgeInfoDto> dataDto = [detailsDto];
  1305. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<KnowledgeInfoDto>>.Success(dataDto));
  1306. }
  1307. #endregion
  1308. #region 查询受理类型
  1309. /// <summary>
  1310. /// 查询受理类型----受理量
  1311. /// </summary>
  1312. /// <param name="dto"></param>
  1313. /// <returns></returns>
  1314. [HttpPost("getacceptancetypestatisticsbymonth")]
  1315. [AllowAnonymous]
  1316. public async Task<OpenResponse> GetAcceptanceTypeStatisticsByMonth([FromBody] OrderFormByMonthDto dto)
  1317. {
  1318. if (string.IsNullOrEmpty(dto.StartTime))
  1319. dto.StartTime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  1320. if (string.IsNullOrEmpty(dto.EndTime))
  1321. dto.EndTime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  1322. //查询待
  1323. var listType = await _orderRepository.Queryable()
  1324. .Where(p => p.CreationTime >= Convert.ToDateTime(dto.StartTime) && p.CreationTime <= Convert.ToDateTime(dto.EndTime) && p.Status > EOrderStatus.WaitForAccept)
  1325. .Select(it => new
  1326. {
  1327. it.AcceptType,
  1328. it.AcceptTypeCode
  1329. })
  1330. .MergeTable()//将查询出来的结果合并成一个新表
  1331. .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组
  1332. .Select(it => new
  1333. {
  1334. name = it.AcceptType,
  1335. value = SqlFunc.AggregateCount(it.AcceptTypeCode)
  1336. })
  1337. .ToListAsync();
  1338. var formAcceptanceCount = _mapper.Map<List<OrderFormCount>>(listType);
  1339. if (_appOptions.Value.IsZiGong)
  1340. {
  1341. List<OrderFormCount> orderForms = new List<OrderFormCount>();
  1342. List<string> fromName = ["咨询", "投诉", "求助", "建议", "举报", "表扬", "申报"];
  1343. foreach (var form in fromName)
  1344. {
  1345. var data = formAcceptanceCount.FirstOrDefault(p => p.name == form);
  1346. orderForms.Add(new OrderFormCount()
  1347. {
  1348. name = form,
  1349. value = data == null ? 0 : data.value
  1350. });
  1351. }
  1352. return OpenResponse.Ok(WebPortalDeResponse<List<OrderFormCount>>.Success(orderForms));
  1353. }
  1354. return OpenResponse.Ok(WebPortalDeResponse<List<OrderFormCount>>.Success(formAcceptanceCount));
  1355. }
  1356. /// <summary>
  1357. /// 查询受理类型---办结量
  1358. /// </summary>
  1359. /// <param name="dto"></param>
  1360. /// <returns></returns>
  1361. [HttpPost("getacceptancetypestatisticsbymonthend")]
  1362. [AllowAnonymous]
  1363. public async Task<OpenResponse> GetAcceptanceTypeStatisticsByMonthEnd([FromBody] OrderFormByMonthDto dto)
  1364. {
  1365. if (string.IsNullOrEmpty(dto.StartTime))
  1366. dto.StartTime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  1367. if (string.IsNullOrEmpty(dto.EndTime))
  1368. dto.EndTime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  1369. //数据查询
  1370. var listFileType = await _orderRepository.Queryable()
  1371. .Where(p => p.FiledTime >= Convert.ToDateTime(dto.StartTime) && p.FiledTime <= Convert.ToDateTime(dto.EndTime) && p.Status >= EOrderStatus.Visited)
  1372. .Select(it => new
  1373. {
  1374. it.AcceptType,
  1375. it.AcceptTypeCode
  1376. })
  1377. .MergeTable()//将查询出来的结果合并成一个新表
  1378. .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组
  1379. .Select(it => new
  1380. {
  1381. name = it.AcceptType,
  1382. value = SqlFunc.AggregateCount(it.AcceptTypeCode)
  1383. })
  1384. .ToListAsync();
  1385. var formFileCount = _mapper.Map<IReadOnlyList<OrderFormCount>>(listFileType);
  1386. if (_appOptions.Value.IsZiGong)
  1387. {
  1388. List<OrderFormCount> orderForms = new List<OrderFormCount>();
  1389. List<string> fromName = ["咨询", "投诉", "求助", "建议", "举报", "表扬", "申报"];
  1390. foreach (var form in fromName)
  1391. {
  1392. var data = formFileCount.FirstOrDefault(p => p.name == form);
  1393. orderForms.Add(new OrderFormCount()
  1394. {
  1395. name = form,
  1396. value = data == null ? 0 : data.value
  1397. });
  1398. }
  1399. return OpenResponse.Ok(WebPortalDeResponse<List<OrderFormCount>>.Success(orderForms));
  1400. }
  1401. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<OrderFormCount>>.Success(formFileCount));
  1402. }
  1403. #endregion
  1404. #region 缓存值
  1405. /// <summary>
  1406. /// 缓存值
  1407. /// </summary>
  1408. /// <param name="dto"></param>
  1409. /// <returns></returns>
  1410. [HttpPost("setgetvaildata")]
  1411. [AllowAnonymous]
  1412. public async Task<OpenResponse> SetGetVailData([FromBody] GetVailDataDto dto)
  1413. {
  1414. if (string.IsNullOrEmpty(dto.Key) || string.IsNullOrEmpty(dto.Value))
  1415. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-1"));
  1416. string strGuid = Guid.NewGuid().ToString();
  1417. string keyToken = dto.Key + strGuid;
  1418. await _getVailData.SetAsync(keyToken, dto.Value, TimeSpan.FromHours(1), cancellationToken: HttpContext.RequestAborted);
  1419. return OpenResponse.Ok(WebPortalDeResponse<string>.Success(strGuid));
  1420. }
  1421. /// <summary>
  1422. /// 缓存值
  1423. /// </summary>
  1424. /// <param name="dto"></param>
  1425. /// <returns></returns>
  1426. [HttpPost("getgetvaildata")]
  1427. [AllowAnonymous]
  1428. public async Task<OpenResponse> GetGetVailData([FromBody] GetVailDataDto dto)
  1429. {
  1430. if (string.IsNullOrEmpty(dto.Key))
  1431. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-1"));
  1432. var data = await _getVailData.GetAsync(dto.Key, cancellationToken: HttpContext.RequestAborted);
  1433. if (!string.IsNullOrEmpty(data) && data == dto.Value)
  1434. {
  1435. await _getVailData.RemoveAsync(dto.Key, cancellationToken: HttpContext.RequestAborted);
  1436. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("1"));
  1437. }
  1438. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("-1"));
  1439. }
  1440. #endregion
  1441. #region 通知-宜宾
  1442. /// <summary>
  1443. /// 获取列表
  1444. /// </summary>
  1445. /// <returns></returns>
  1446. [AllowAnonymous]
  1447. [HttpPost("getarticlelist_yibin")]
  1448. public async Task<OpenResponse> GetArticleListYiBin([FromBody] QueryArticleListDto dto)
  1449. {
  1450. if (string.IsNullOrEmpty(dto.PushRanges))
  1451. dto.PushRanges = "2";
  1452. RefAsync<int> total = 0;
  1453. var items1 = _bulletinRepository.Queryable()
  1454. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  1455. .Where(p => p.IsArrive == true)
  1456. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  1457. .Where(p => p.BulletinTypeId == dto.NoticeType)
  1458. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  1459. .Select(it => new ArticleListDto
  1460. {
  1461. Page = 0,
  1462. NoticeID = it.Id,
  1463. //NoticeContent = it.Content,
  1464. NoticeTypeName = it.BulletinTypeName,
  1465. NoticeTitle = it.Title,
  1466. NoticeBMName = it.SourceOrgName,
  1467. NoticeCreateDate = it.CreationTime,
  1468. VideoUrl = "",
  1469. WNLT_FullCode = ""
  1470. });
  1471. List<ArticleListDto> items = new List<ArticleListDto>();
  1472. if (dto.NoticeType == "6")
  1473. {
  1474. //知识库
  1475. var items2 = _knowledgeRepository.Queryable()
  1476. .Where(k => k.IsPublic == true)
  1477. .Where(k => k.Status == EKnowledgeStatus.OnShelf)
  1478. .Where(k => k.Attribution == "部门知识库")
  1479. .Select(it => new ArticleListDto
  1480. {
  1481. Page = 0,
  1482. NoticeID = it.Id,
  1483. //NoticeContent = it.Content,
  1484. NoticeTypeName = "知识库",
  1485. NoticeTitle = it.Title,
  1486. NoticeBMName = it.CreatorOrgName,
  1487. NoticeCreateDate = it.CreationTime,
  1488. VideoUrl = "",
  1489. WNLT_FullCode = ""
  1490. });
  1491. items = await _orderRepository.UnionAll(items1, items2)
  1492. .Select(x => new ArticleListDto
  1493. {
  1494. Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
  1495. NoticeID = x.NoticeID,
  1496. //NoticeContent = x.NoticeContent,
  1497. NoticeTypeName = x.NoticeTypeName,
  1498. NoticeTitle = x.NoticeTitle,
  1499. NoticeBMName = x.NoticeBMName,
  1500. NoticeCreateDate = x.NoticeCreateDate,
  1501. VideoUrl = x.VideoUrl,
  1502. WNLT_FullCode = x.WNLT_FullCode
  1503. })
  1504. .OrderByDescending(p => p.NoticeCreateDate)
  1505. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1506. }
  1507. else
  1508. {
  1509. items = await items1
  1510. .OrderByDescending(p => p.NoticeCreateDate)
  1511. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1512. }
  1513. //计算总页数
  1514. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  1515. ArticleListDataDto dataDto = new()
  1516. {
  1517. PageCount = nPageCount,
  1518. Total = total,
  1519. data = _mapper.Map<IReadOnlyList<ArticleListDto>>(items)
  1520. };
  1521. return OpenResponse.Ok(WebPortalDeResponse<ArticleListDataDto>.Success(dataDto));
  1522. }
  1523. /// <summary>
  1524. /// 获取详情,修改阅读次数
  1525. /// </summary>
  1526. /// <param name="dto"></param>
  1527. /// <returns></returns>
  1528. [AllowAnonymous]
  1529. [HttpPost("getarticledetails_yibin")]
  1530. public async Task<OpenResponse> GetArticleDetailsYiBin([FromBody] ArticleIdDto dto)
  1531. {
  1532. ArticleDetailsDto detailsDto = null;
  1533. if (dto.TypeName == "知识库")
  1534. {
  1535. var data = await _knowledgeRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  1536. if (data != null)
  1537. {
  1538. data.PageView = data.PageView + 1;
  1539. await _knowledgeRepository.UpdateAsync(data, HttpContext.RequestAborted);
  1540. detailsDto = new()
  1541. {
  1542. NoticeID = data.Id,
  1543. NoticeTypeName = "知识库",
  1544. NoticeTitle = data.Title,
  1545. NoticeBMName = data.CreatorOrgName,
  1546. NoticeCreateDate = data.CreationTime,
  1547. NoticeRCount = data.PageView,
  1548. WNED_VideoUrl = "",
  1549. NoticeContent = data.Content
  1550. };
  1551. if (data != null && !string.IsNullOrEmpty(data.Content))
  1552. data.Content = _bulletinApplication.GetSiteUrls(data.Content);
  1553. }
  1554. else
  1555. detailsDto = new();
  1556. }
  1557. else
  1558. {
  1559. var data = await _bulletinRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  1560. if (data != null)
  1561. {
  1562. data.ReadedNum = data.ReadedNum + 1;
  1563. await _bulletinRepository.UpdateAsync(data, HttpContext.RequestAborted);
  1564. detailsDto = new()
  1565. {
  1566. NoticeID = data.Id,
  1567. NoticeTypeName = data.BulletinTypeName,
  1568. NoticeTitle = data.Title,
  1569. NoticeBMName = data.SourceOrgName,
  1570. NoticeCreateDate = data.CreationTime,
  1571. NoticeRCount = data.ReadedNum,
  1572. WNED_VideoUrl = "",
  1573. NoticeContent = data.Content
  1574. };
  1575. if (data != null && !string.IsNullOrEmpty(data.Content))
  1576. data.Content = _bulletinApplication.GetSiteUrls(data.Content);
  1577. }
  1578. else
  1579. detailsDto = new();
  1580. }
  1581. List<ArticleDetailsDto> dataDto = new() { detailsDto };
  1582. return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<ArticleDetailsDto>>.Success(dataDto));
  1583. }
  1584. /// <summary>
  1585. /// 上一条和下一条
  1586. /// </summary>
  1587. /// <param name="dto"></param>
  1588. /// <returns></returns>
  1589. [AllowAnonymous]
  1590. [HttpPost("getpreviousandnext_yibin")]
  1591. public async Task<OpenResponse> GetPreviousAndNextYiBin([FromBody] ArticlePreviousAndNextDto dto)
  1592. {
  1593. if (string.IsNullOrEmpty(dto.PushRanges))
  1594. dto.PushRanges = "2";
  1595. var sugar = _bulletinRepository.Queryable()
  1596. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  1597. .Where(p => p.IsArrive == true)
  1598. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges));
  1599. if (dto.FullSearch == "1")//全文搜索
  1600. {
  1601. if (_appOptions.Value.IsYiBin)
  1602. {
  1603. sugar.Where(p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
  1604. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
  1605. }
  1606. if (_appOptions.Value.IsZiGong)
  1607. {
  1608. sugar.Where(p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
  1609. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Content.Contains(dto.Condition) || p.Title.Contains(dto.Condition));
  1610. }
  1611. }
  1612. else//指定分类
  1613. {
  1614. sugar.WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  1615. .Where(p => p.BulletinTypeId == dto.NoticeTypeId);
  1616. }
  1617. var items1 = sugar.Select(it => new ArticleDetailDataDto
  1618. {
  1619. Page = SqlFunc.RowNumber($"{it.CreationTime} desc "),// SqlFunc.MappingColumn(default(int), " row_number() over( order by 'NoticeCreateDate' ) "),
  1620. NoticeID = it.Id,
  1621. NoticeTitle = it.Title,
  1622. NoticeTypeName = it.BulletinTypeName,
  1623. NoticeCreateDate = it.CreationTime
  1624. });
  1625. List<ArticleDetailDataDto> list = new List<ArticleDetailDataDto>();
  1626. if (dto.NoticeTypeId == "6")
  1627. {
  1628. //知识库
  1629. var items2 = _knowledgeRepository.Queryable()
  1630. .Where(k => k.IsPublic == true)
  1631. .Where(k => k.Status == EKnowledgeStatus.OnShelf)
  1632. .Where(k => k.Attribution == "部门知识库")
  1633. .WhereIF(!string.IsNullOrEmpty(dto.Condition), k => k.Content.Contains(dto.Condition) || k.Title.Contains(dto.Condition))
  1634. .Select(it => new ArticleDetailDataDto
  1635. {
  1636. Page = 0,
  1637. NoticeID = it.Id,
  1638. NoticeTitle = it.Title,
  1639. NoticeTypeName = "知识库",
  1640. NoticeCreateDate = it.CreationTime
  1641. });
  1642. list = await _orderRepository.UnionAll(items1, items2)
  1643. .Select(x => new ArticleDetailDataDto
  1644. {
  1645. Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
  1646. NoticeID = x.NoticeID,
  1647. NoticeTitle = x.NoticeTitle,
  1648. NoticeTypeName = x.NoticeTypeName,
  1649. NoticeCreateDate = x.NoticeCreateDate
  1650. })
  1651. .OrderByDescending(x => x.NoticeCreateDate)
  1652. .ToListAsync();
  1653. }
  1654. else
  1655. {
  1656. list = await items1.OrderByDescending(x => x.NoticeCreateDate).ToListAsync();
  1657. }
  1658. //数据为空返回空数据
  1659. if (list == null || list.Count == 0)
  1660. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
  1661. else
  1662. {
  1663. var temp = list.Find(p => p.NoticeID == dto.ID);
  1664. if (temp != null)
  1665. {
  1666. List<ArticlePreviousAndNextDataDto> returnDto = new();
  1667. //上一条
  1668. var pTemp = list.Find(p => p.Page == temp.Page - 1);
  1669. if (pTemp != null)
  1670. returnDto.Add(new()
  1671. {
  1672. NoticeID = pTemp.NoticeID,
  1673. NoticeTitle = pTemp.NoticeTitle,
  1674. NoticeTypeName = pTemp.NoticeTypeName,
  1675. pntype = "p"
  1676. });
  1677. //下一条
  1678. var nTemp = list.Find(p => p.Page == temp.Page + 1);
  1679. if (nTemp != null)
  1680. returnDto.Add(new()
  1681. {
  1682. NoticeID = nTemp.NoticeID,
  1683. NoticeTitle = nTemp.NoticeTitle,
  1684. NoticeTypeName = nTemp.NoticeTypeName,
  1685. pntype = "n"
  1686. });
  1687. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(returnDto));
  1688. }
  1689. else
  1690. return OpenResponse.Ok(WebPortalDeResponse<List<ArticlePreviousAndNextDataDto>>.Success(null));
  1691. }
  1692. }
  1693. /// <summary>
  1694. /// 全文检索
  1695. /// </summary>
  1696. /// <param name="dto"></param>
  1697. /// <returns></returns>
  1698. [AllowAnonymous]
  1699. [HttpPost("getfulltextsearchlist_yibin")]
  1700. public async Task<OpenResponse> GetFullTextSearchList_YiBin([FromBody] QueryArticleListDto dto)
  1701. {
  1702. if (string.IsNullOrEmpty(dto.PushRanges))
  1703. dto.PushRanges = "2";
  1704. if (string.IsNullOrEmpty(dto.Condition))
  1705. return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(null));
  1706. RefAsync<int> total = 0;
  1707. var items1 = _bulletinRepository.Queryable()
  1708. .Where(p => p.LoseEfficacyTime >= DateTime.Now)
  1709. .Where(p => p.IsArrive == true)
  1710. .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
  1711. .WhereIF(_appOptions.Value.IsYiBin, p => p.BulletinTypeId == "1" || p.BulletinTypeId == "5" || p.BulletinTypeId == "6" || p.BulletinTypeId == "7" || p.BulletinTypeId == "3" || p.BulletinTypeId == "4")
  1712. .WhereIF(_appOptions.Value.IsZiGong, p => p.BulletinTypeId == "5013" || p.BulletinTypeId == "5016" || p.BulletinTypeId == "5011" || p.BulletinTypeId == "5015" || p.BulletinTypeId == "5017")
  1713. .WhereIF(!string.IsNullOrEmpty(dto.Condition), p => p.Title.Contains(dto.Condition))
  1714. .OrderByDescending(p => p.CreationTime)
  1715. .Select(it => new FullTextSearchListDto
  1716. {
  1717. Page = 0,
  1718. NoticeID = it.Id,
  1719. //Content = it.Content,
  1720. NoticeTypeID = it.BulletinTypeId,
  1721. NoticeTypeName = it.BulletinTypeName,
  1722. NoticeTitle = it.Title,
  1723. NoticeBMName = it.SourceOrgName,
  1724. NoticeCreateDate = it.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
  1725. TypeCode = ""
  1726. });
  1727. List<FullTextSearchListDto> items = new List<FullTextSearchListDto>();
  1728. if (dto.NoticeType == "6")
  1729. {
  1730. //知识库
  1731. var items2 = _knowledgeRepository.Queryable()
  1732. .Where(k => k.IsPublic == true)
  1733. .Where(k => k.Status == EKnowledgeStatus.OnShelf)
  1734. .Where(k => k.Attribution == "部门知识库")
  1735. .WhereIF(!string.IsNullOrEmpty(dto.Condition), k => k.Content.Contains(dto.Condition) || k.Title.Contains(dto.Condition))
  1736. .Select(it => new FullTextSearchListDto
  1737. {
  1738. Page = 0,
  1739. NoticeID = it.Id,
  1740. //NoticeContent = it.Content,
  1741. NoticeTypeID = "6",
  1742. NoticeTypeName = "知识库",
  1743. NoticeTitle = it.Title,
  1744. NoticeBMName = it.CreatorOrgName,
  1745. NoticeCreateDate = it.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"),
  1746. TypeCode = ""
  1747. });
  1748. items = await _orderRepository.UnionAll(items1, items2)
  1749. .Select(x => new FullTextSearchListDto
  1750. {
  1751. Page = SqlFunc.RowNumber($"{x.NoticeCreateDate} desc "),
  1752. NoticeID = x.NoticeID,
  1753. //NoticeContent = it.Content,
  1754. NoticeTypeID = x.NoticeTypeID,
  1755. NoticeTypeName = x.NoticeTypeName,
  1756. NoticeTitle = x.NoticeTitle,
  1757. NoticeBMName = x.NoticeBMName,
  1758. NoticeCreateDate = x.NoticeCreateDate,
  1759. TypeCode = ""
  1760. })
  1761. .OrderByDescending(p => p.NoticeCreateDate)
  1762. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1763. }
  1764. else
  1765. {
  1766. items = await items1
  1767. .OrderByDescending(p => p.NoticeCreateDate)
  1768. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1769. }
  1770. //计算总页数
  1771. int nPageCount = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(total) / dto.PageSize));
  1772. FullTextSearchListDataDto dataDto = new()
  1773. {
  1774. PageCount = nPageCount,
  1775. data = _mapper.Map<IReadOnlyList<FullTextSearchListDto>>(items)
  1776. };
  1777. return OpenResponse.Ok(WebPortalDeResponse<FullTextSearchListDataDto>.Success(dataDto));
  1778. }
  1779. #endregion
  1780. #region 办件-宜宾
  1781. /// <summary>
  1782. /// 办件摘编详情
  1783. /// </summary>
  1784. /// <param name="dto"></param>
  1785. /// <returns></returns>
  1786. [AllowAnonymous]
  1787. [HttpPost("getorderdetailbyid_yibin")]
  1788. public async Task<object> GetOrderDetailByIdYiBin([FromBody] ArticleIdDto dto)
  1789. {
  1790. var data = await _orderRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
  1791. var orderDetail = _mapper.Map<OrderDetail>(data);
  1792. if (data != null)
  1793. {
  1794. //如果是省工单或者是省政民互动的工单,市民不能进行评价
  1795. if (data.IsProvince == true || data.SourceChannelCode == "ZMHD")
  1796. orderDetail.IsProvinceOrder = "1";
  1797. else
  1798. orderDetail.IsProvinceOrder = "0";
  1799. //获取发布的数据
  1800. var orderPublish = await _orderPublishRepository.GetAsync(p => p.OrderId == data.Id, HttpContext.RequestAborted);
  1801. if (orderPublish != null)
  1802. {
  1803. orderDetail.PubFlag = "1";
  1804. orderDetail.FlowTitle = orderPublish.ArrangeTitle;
  1805. orderDetail.FlowContent = orderPublish.ArrangeContent;
  1806. orderDetail.FlowResult = orderPublish.ArrangeOpinion;
  1807. if (orderPublish.PublishState)
  1808. orderDetail.FlowPubFlagName = "公开";
  1809. orderDetail.FirstVisitResult = data.FirstVisitResult;
  1810. }
  1811. //能否进行评价
  1812. var orderVisit = await _orderVisitRepository.GetAsync(p => p.OrderId == data.Id && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  1813. if (orderVisit == null)
  1814. orderDetail.VisitType = "0";
  1815. else
  1816. {
  1817. orderDetail.VisitType = orderVisit.VisitState switch
  1818. {
  1819. EVisitState.WaitForVisit or EVisitState.SMSVisiting or EVisitState.SMSUnsatisfied => "1",
  1820. EVisitState.Visited => "2",
  1821. EVisitState.Visiting or EVisitState.NoSatisfiedWaitForVisit or EVisitState.None => "0",
  1822. _ => "0",
  1823. };
  1824. }
  1825. }
  1826. //List<OrderDetail> dataDto = new() { orderDetail };
  1827. //return OpenResponse.Ok(WebPortalDeResponse<IReadOnlyList<OrderDetail>>.Success(dataDto));
  1828. var dissatisfiedReason = _sysDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.DissatisfiedReason);
  1829. return new
  1830. {
  1831. OrderDetail = orderDetail,
  1832. DissatisfiedReason = dissatisfiedReason
  1833. };
  1834. }
  1835. #endregion
  1836. #region 评价-宜宾
  1837. /// <summary>
  1838. /// 评价内容
  1839. /// </summary>
  1840. /// <param name="dto"></param>
  1841. /// <returns></returns>
  1842. [AllowAnonymous]
  1843. [HttpPost("receivevisitdata_yibin")]
  1844. public async Task<OpenResponse> ReceiveVisitData_YiBin([FromBody] OrderVisitListDataDto dto)
  1845. {
  1846. if (dto == null || dto.VistListDtos == null || dto.VistListDtos.Count == 0)
  1847. return OpenResponse.Ok(WebPortalDeResponse<string>.Failed("评价数据不能为空!"));
  1848. var dataOrder = await _orderVisitRepository.GetAsync(p => p.OrderId == dto.OrderId && p.VisitState != EVisitState.None, HttpContext.RequestAborted);
  1849. if (dataOrder == null)
  1850. return OpenResponse.Ok(WebPortalDeResponse<string>.Failed("工单已经评价!"));
  1851. //组装数据
  1852. OrderVisitWebDto visitWebDto = new()
  1853. {
  1854. VisitType = Hotline.Share.Enums.Order.EVisitType.WebVisit,
  1855. VisitTime = DateTime.Now
  1856. };
  1857. List<OrderVisitDetailWebDto> orderVisitDetails = new();
  1858. #region 部门评价
  1859. //部门评价
  1860. //遍历数据
  1861. foreach (var item in dto.VistListDtos)
  1862. {
  1863. Hotline.Share.Dtos.Kv kv = item.SatisfactionCode switch
  1864. {
  1865. "5" => new Hotline.Share.Dtos.Kv { Key = "5", Value = "非常满意" },
  1866. "4" => new Hotline.Share.Dtos.Kv { Key = "4", Value = "满意" },
  1867. "2" => new Hotline.Share.Dtos.Kv { Key = "2", Value = "不满意" },
  1868. _ => new Hotline.Share.Dtos.Kv { Key = "7", Value = "不做评价" },
  1869. };
  1870. //组装回访数据
  1871. visitWebDto.Id = item.VisitId;
  1872. OrderVisitDetailWebDto detailDto = new()
  1873. {
  1874. Id = item.Id,
  1875. VisitTarget = Hotline.Share.Enums.Order.EVisitTarget.Org,
  1876. OrgProcessingResults = kv,
  1877. OrgNoSatisfiedReason = item.OrgNoSatisfiedReason,
  1878. OrgHandledAttitude = kv,
  1879. VisitContent = item.VisitContent,
  1880. IsContact = item.IsContact,
  1881. Volved = item.Volved
  1882. };
  1883. orderVisitDetails.Add(detailDto);
  1884. }
  1885. #endregion
  1886. visitWebDto.OrderVisitDetailDto = orderVisitDetails;
  1887. //推送数据
  1888. await _orderApplication.OrderVisitWeb(visitWebDto, HttpContext.RequestAborted);
  1889. return OpenResponse.Ok(WebPortalDeResponse<string>.Success("1"));
  1890. }
  1891. #endregion
  1892. }
  1893. }