BiSnapshotController.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. using Hotline.Application.Snapshot;
  2. using Hotline.Share.Dtos;
  3. using Hotline.Share.Dtos.Snapshot;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Hotline.Repository.SqlSugar.Extensions;
  6. using Hotline.Share.Tools;
  7. using Hotline.Snapshot.Interfaces;
  8. using Hotline.Settings.Hotspots;
  9. using Hotline.Share.Requests;
  10. using SqlSugar;
  11. using XF.Domain.Authentications;
  12. using Hotline.Settings;
  13. using Hotline.Caching.Interfaces;
  14. using Hotline.Share.Enums.Order;
  15. using Hotline.Share.Enums.Snapshot;
  16. using XF.Utility.EnumExtensions;
  17. using Amazon.Runtime.Internal.Util;
  18. using System.Collections;
  19. using Mapster;
  20. using Hotline.Share.Dtos.Settings;
  21. namespace Hotline.Api.Controllers.Snapshot;
  22. /// <summary>
  23. /// 随手拍统计
  24. /// </summary>
  25. public class BiSnapshotController : BaseController
  26. {
  27. private readonly IBiSnapshotApplication _biSnapshotApplication;
  28. private readonly IIndustryRepository _industryRepository;
  29. private readonly ISystemDicDataCacheManager _systemDicDataCacheManager;
  30. public BiSnapshotController(IBiSnapshotApplication biSnapshotApplication, IIndustryRepository industryRepository, ISystemDicDataCacheManager systemDicDataCacheManager)
  31. {
  32. _biSnapshotApplication = biSnapshotApplication;
  33. _industryRepository = industryRepository;
  34. _systemDicDataCacheManager = systemDicDataCacheManager;
  35. }
  36. /// <summary>
  37. /// 随手拍统计基础数据
  38. /// </summary>
  39. /// <returns></returns>
  40. [HttpGet("statistics/basedata")]
  41. public async Task<Dictionary<string, object>> GetSnapshotStatisticsBaseDataAsync()
  42. {
  43. return new Dictionary<string, object>()
  44. {
  45. { "industry", await _industryRepository.GetDataBaseAsync() }
  46. };
  47. }
  48. /// <summary>
  49. /// 随手拍统计
  50. /// </summary>
  51. /// <returns></returns>
  52. [HttpGet("statistics")]
  53. public async Task<SnapshotStatisticsOutDto> GetSnapshotStatisticsAsync([FromQuery] SnapshotStatisticsInDto dto)
  54. => await _biSnapshotApplication.GetSnapshotStatisticsAsync(dto, HttpContext.RequestAborted);
  55. /// <summary>
  56. /// 随手拍统计详情集合
  57. /// </summary>
  58. /// <param name="dto"></param>
  59. /// <returns></returns>
  60. [HttpGet("statistics/details")]
  61. public async Task<PagedDto<SnapshotStatisticsDetailOutDto>> GetSnapshotStatisticsDetailAsync([FromQuery] SnapshotStatisticsDetailInDto dto)
  62. => (await _biSnapshotApplication.GetSnapshotStatisticsDetail(dto).ToPagedListAsync(dto)).ToPaged();
  63. /// <summary>
  64. /// 市民红包审核统计
  65. /// </summary>
  66. /// <param name="dto"></param>
  67. /// <returns></returns>
  68. [HttpGet("redpack/audit")]
  69. public IList<RedPackStatisticsOutDto> GetRedPackAuditStatisticsAsync([FromQuery] RedPackStatisticsInDto dto)
  70. => _biSnapshotApplication.GetRedPackAuditStatistics(dto);
  71. /// <summary>
  72. /// 市民红包审核统计详情
  73. /// </summary>
  74. /// <param name="dto"></param>
  75. /// <returns></returns>
  76. [HttpGet("redpack/audit/details")]
  77. public async Task<PagedDto<RedPackStatisticsDetailsOutDto>> GetRedPackAuditStatisticsDetailsAsync([FromQuery] RedPackStatisticsDetailsInDto dto)
  78. => (await _biSnapshotApplication.GetRedPackAuditStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
  79. /// <summary>
  80. /// 热点类型小类统计
  81. /// </summary>
  82. /// <param name="dto"></param>
  83. /// <returns></returns>
  84. [HttpGet("hotspot-statistics")]
  85. public async Task<IList<HotspotStatisticsOutDto>> GetHotspotStatisticsAsync([FromQuery] HotspotStatisticsInDto dto)
  86. => await _biSnapshotApplication.GetHotspotStatistics(dto).ToListAsync();
  87. /// <summary>
  88. /// 热点类型小类统计明细
  89. /// </summary>
  90. /// <param name="dto"></param>
  91. /// <returns></returns>
  92. [HttpGet("hotspot-statistics-detail")]
  93. public async Task<PagedDto<HotspotStatisticsDetailsOutDto>> GetHotspotStatisticsDetailAsync([FromQuery] HotspotStatisticsDetailsInDto dto)
  94. => (await _biSnapshotApplication.HotspotStatisticsDetail(dto).ToPagedListAsync(dto)).ToPaged();
  95. /// <summary>
  96. /// 热点类型-随手拍
  97. /// </summary>
  98. /// <param name="dto"></param>
  99. /// <returns></returns>
  100. [HttpGet("hotspot-data-statistics")]
  101. public async Task<IList<HotspotDataStatisticsOutDto>> GetHotspotDataStatisticsAsync([FromQuery] HotspotDataStatisticsInDto dto)
  102. {
  103. var items = await _biSnapshotApplication.GetHotspotDataStatisticsAsync(dto).ToListAsync();
  104. if (items.Count != 0)
  105. {
  106. items.Add(new HotspotDataStatisticsOutDto
  107. {
  108. Name = "合计",
  109. OrderCount = items.Sum(x => x.OrderCount),
  110. });
  111. }
  112. return items;
  113. }
  114. /// <summary>
  115. /// 办件统计-随手拍
  116. /// </summary>
  117. /// <param name="dto"></param>
  118. /// <returns></returns>
  119. [HttpGet("processing-statistics")]
  120. public async Task<IList<SnapshotProcessingStatisticsOutDto>> GetSnapshotProcessingStatistics([FromQuery] SnapshotProcessingStatisticsInDto dto)
  121. => await _biSnapshotApplication.GetSnapshotProcessingStatistics(dto).ToListAsync();
  122. /// <summary>
  123. /// 办件统计明细-随手拍
  124. /// </summary>
  125. /// <param name="dto"></param>
  126. /// <returns></returns>
  127. [HttpGet("processing-statistics-detail")]
  128. public async Task<PagedDto<SnapshotProcessingStatisticsDetailsOutDto>> GetSnapshotProcessingStatisticsDetails([FromQuery] SnapshotProcessingStatisticsDetailsInDto dto)
  129. => (await _biSnapshotApplication.GetSnapshotProcessingStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
  130. /// <summary>
  131. /// 网格员办理情况统计
  132. /// </summary>
  133. /// <param name="dto"></param>
  134. /// <returns></returns>
  135. [HttpGet("guider-work-statistics")]
  136. public async Task<IList<GuiderWorkStatisticsOutDto>> GetGuiderWorkStatisticsAsync([FromQuery] GuiderWorkStatisticsInDto dto)
  137. => await _biSnapshotApplication.GetGuiderWorkStatisticsAsync(dto).ToListAsync();
  138. /// <summary>
  139. /// 网格员办理情况统计详情
  140. /// </summary>
  141. /// <param name="dto"></param>
  142. /// <returns></returns>
  143. [HttpGet("guider-work-statistics-detail")]
  144. public async Task<PagedDto<GuiderWorkStatisticsDetailsOutDto>> GetGuiderWorkStatisticsDetailsAsync([FromQuery] GuiderWorkStatisticsDetailsInDto dto)
  145. => (await _biSnapshotApplication.GetGuiderWorkStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
  146. /// <summary>
  147. /// 网格员系统工单状态日志基础数据
  148. /// </summary>
  149. /// <returns></returns>
  150. [HttpGet("guider-work-log/basedata")]
  151. public async Task<Dictionary<string, object>> GetGuiderWorkLogsAsyncBasedataAsync()
  152. {
  153. return new Dictionary<string, object>
  154. {
  155. { "orderStatus", EnumExts.GetDescriptions<EGuiderSystemReplyType>()},
  156. };
  157. }
  158. /// <summary>
  159. /// 网格员系统工单状态日志
  160. /// </summary>
  161. /// <param name="dto"></param>
  162. /// <returns></returns>
  163. [HttpGet("guider-work-log")]
  164. public async Task<PagedDto<GuiderWorkLogsOutDto>> GetGuiderWorkLogsAsync([FromQuery] GuiderWorkLogsInDto dto)
  165. => (await _biSnapshotApplication.GetGuiderWorkLogs(dto).ToPagedListAsync(dto)).ToPaged();
  166. /// <summary>
  167. /// 重复件-随手拍
  168. /// </summary>
  169. /// <param name="dto"></param>
  170. /// <returns></returns>
  171. [HttpGet("duplicate")]
  172. public async Task<PagedDto<DuplicateItemsOutDto>> GetDuplicateItemsAsync([FromQuery] DuplicateItemsInDto dto)
  173. => (await _biSnapshotApplication.GetDuplicateItems(dto).ToPagedListAsync(dto)).ToPaged();
  174. /// <summary>
  175. /// 社区统计
  176. /// </summary>
  177. /// <param name="dto"></param>
  178. /// <returns></returns>
  179. [HttpGet("community-statistics")]
  180. public async Task<IList<CommunityStatisticsOutDto>> GetCommunityStatisticsAsync([FromQuery] CommunityStatisticsInDto dto)
  181. => await _biSnapshotApplication.GetCommunityStatistics(dto).ToListAsync();
  182. /// <summary>
  183. /// 社区统计-详情
  184. /// </summary>
  185. /// <param name="dto"></param>
  186. /// <returns></returns>
  187. [HttpGet("community-statistics-detail")]
  188. public async Task<PagedDto<CommunityStatisticsDetailsOutDto>> GetCommunityStatisticsDetailsAsync([FromQuery] CommunityStatisticsDetailsInDto dto)
  189. => (await _biSnapshotApplication.GetCommunityStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
  190. /// <summary>
  191. /// 随手拍区域统计
  192. /// </summary>
  193. /// <param name="dto"></param>
  194. /// <returns></returns>
  195. [HttpGet("county-redpack-statistics")]
  196. public async Task<IList<CountyRedPackStatisticsOutDto>> GetCountyRedPackStatisticsAsync([FromQuery] CountyRedPackStatisticsInDto dto)
  197. => await _biSnapshotApplication.GetCountyRedPackStatistics(dto).ToListAsync();
  198. /// <summary>
  199. /// 部门考核统计-随手拍
  200. /// </summary>
  201. /// <param name="dto"></param>
  202. /// <returns></returns>
  203. [HttpGet("department-statistics")]
  204. public async Task<IList<SnapshotDepartmentStatisticsOutDto>> GetSnapshotDepartmentStatisticsAsync([FromQuery] SnapshotDepartmentStatisticsInDto dto)
  205. => await _biSnapshotApplication.GetSnapshotDepartmentStatistics(dto).ToListAsync();
  206. /// <summary>
  207. /// 部门平均办理时间-随手拍
  208. /// </summary>
  209. /// <param name="dto"></param>
  210. /// <returns></returns>
  211. [HttpGet("department-avetime-statistics")]
  212. public async Task<IList<SnapshotDepartmentAveTimeStatisticsOutDto>> GetSnapshotDepartmentAveTimeStatisticsAsync([FromQuery] SnapshotDepartmentAveTimeStatisticsInDto dto)
  213. => await _biSnapshotApplication.GetSnapshotDepartmentAveTimeStatistics(dto).ToListAsync();
  214. /// <summary>
  215. /// 部门平均办理时间-随手拍-详情
  216. /// </summary>
  217. /// <param name="dto"></param>
  218. /// <returns></returns>
  219. [HttpGet("department-avetime-statistics-detail")]
  220. public async Task<PagedDto<SnapshotDepartmentAveTimeStatisticsDetailsOutDto>> GetSnapshotDepartmentAveTimeStatisticsDtailsAsync([FromQuery] SnapshotDepartmentAveTimeStatisticsDetailsInDto dto)
  221. => (await _biSnapshotApplication.GetSnapshotDepartmentAveTimeStatisticsDtails(dto).ToPagedListAsync(dto)).ToPaged();
  222. /// <summary>
  223. /// 检查合规统计
  224. /// </summary>
  225. /// <param name="dto"></param>
  226. /// <returns></returns>
  227. [HttpGet("compliant-statistics")]
  228. public async Task<IList<CompliantStatisticsOutDto>> CompliantStatisticsAsync([FromQuery] CompliantStatisticsInDto dto)
  229. {
  230. var items = await _biSnapshotApplication.GetCompliantStatistics(dto).ToListAsync();
  231. items.AddSumLine("OrgName");
  232. return items;
  233. }
  234. /// <summary>
  235. /// 行业统计
  236. /// </summary>
  237. /// <param name="dto"></param>
  238. /// <returns></returns>
  239. [HttpGet("industry-statistics")]
  240. public async Task<IndustryStatisticsOutDto> IndustryStatisticsAsync([FromQuery] IndustryStatisticsInDto dto)
  241. {
  242. return new IndustryStatisticsOutDto
  243. {
  244. Headers = await _industryRepository.Queryable().Where(m => m.IsEnable == true).Select(m => new SystemDicDataOutDto {
  245. Id = m.Id,
  246. DicDataName = m.Name,
  247. DicDataValue = m.Name,
  248. }).ToListAsync(),
  249. Data = _biSnapshotApplication.GetIndustryStatistics(dto)
  250. };
  251. }
  252. /// <summary>
  253. /// 检查合规统计-详情
  254. /// </summary>
  255. /// <param name="dto"></param>
  256. /// <returns></returns>
  257. [HttpGet("compliant-statistics-detail")]
  258. public async Task<PagedDto<CompliantStatisticsDetailsOutDto>> CompliantStatisticsDetailsAsync([FromQuery] CompliantStatisticsDetailsInDto dto)
  259. => (await _biSnapshotApplication.GetCompliantStatisticsDetails(dto).ToPagedListAsync(dto)).ToPaged();
  260. /// <summary>
  261. /// 重办统计-随手拍
  262. /// </summary>
  263. /// <param name="dto"></param>
  264. /// <returns></returns>
  265. [HttpGet("re_transact-statistics")]
  266. public async Task<ReTransactStatisticsOutDto> GetReTransactStatisticsAsync([FromQuery] ReTransactStatisticsInDto dto)
  267. {
  268. var headers = _systemDicDataCacheManager.GetSysDicDataCache(SysDicTypeConsts.InstaShotSpecialReason).Adapt<IList<SystemDicDataOutDto>>();
  269. return new ReTransactStatisticsOutDto
  270. {
  271. Headers = headers,
  272. Data = _biSnapshotApplication.GetReTransactStatistics(dto)
  273. };
  274. }
  275. /// <summary>
  276. /// 重办统计详情-随手拍
  277. /// </summary>
  278. /// <param name="dto"></param>
  279. /// <returns></returns>
  280. [HttpGet("re_transact-statistics-detail")]
  281. public async Task<PagedDto<ReTransactStatisticsDetailsOutDto>> GetReTransactStatisticsDetailAsync([FromQuery] ReTransactStatisticsDetailsInDto dto)
  282. => (await _biSnapshotApplication.GetReTransactStatisticsDetail(dto).ToPagedListAsync(dto)).ToPaged();
  283. }