BiSnapshotController.cs 14 KB

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