|
@@ -0,0 +1,205 @@
|
|
|
|
+using Hotline.Article;
|
|
|
|
+using Hotline.Orders;
|
|
|
|
+using Hotline.Repository.SqlSugar.Extensions;
|
|
|
|
+using Hotline.Share.Dtos;
|
|
|
|
+using Hotline.Share.Dtos.Article;
|
|
|
|
+using Hotline.Share.Dtos.DataSharingSearch;
|
|
|
|
+using Hotline.Share.Dtos.Order;
|
|
|
|
+using Hotline.Share.Enums.Article;
|
|
|
|
+using Hotline.Share.Enums.Order;
|
|
|
|
+using MapsterMapper;
|
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
+using SqlSugar;
|
|
|
|
+using XF.Domain.Repository;
|
|
|
|
+
|
|
|
|
+namespace Hotline.Api.Controllers
|
|
|
|
+{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 提供给DS查询数据用
|
|
|
|
+ /// </summary>
|
|
|
|
+ public class DataSharingController : BaseController
|
|
|
|
+ {
|
|
|
|
+ private readonly IMapper _mapper;
|
|
|
|
+ private readonly IOrderRepository _orderRepository;
|
|
|
|
+ private readonly IRepository<Bulletin> _bulletinRepository;
|
|
|
|
+
|
|
|
|
+ public DataSharingController(IMapper mapper,
|
|
|
|
+ IOrderRepository orderRepository,
|
|
|
|
+ IRepository<Bulletin> bulletinRepository)
|
|
|
|
+ {
|
|
|
|
+ _mapper = mapper;
|
|
|
|
+ _orderRepository = orderRepository;
|
|
|
|
+ _bulletinRepository = bulletinRepository;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 根据工单编号和密码查询信件详情
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ [HttpPost("get_order_detail_by_no_pwd")]
|
|
|
|
+ public async Task<OrderDto> GetOrderDetail([FromBody] GetOrderNoPwdDto dto)
|
|
|
|
+ {
|
|
|
|
+ var order = await _orderRepository.Queryable()
|
|
|
|
+ .Where(p => p.No == dto.No && p.Password == dto.Password)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.SourceChannelCode), p => p.SourceChannelCode == dto.SourceChannelCode)
|
|
|
|
+ .FirstAsync();
|
|
|
|
+
|
|
|
|
+ return _mapper.Map<OrderDto>(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 根据工单Id查询信件详情
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ [HttpPost("get_order_detail_by_id")]
|
|
|
|
+ public async Task<OrderDto> GetOrderDetailById([FromBody] GetOrderDetailDto dto)
|
|
|
|
+ {
|
|
|
|
+ var order = await _orderRepository.Queryable()
|
|
|
|
+ .Where(p => p.Id == dto.Id)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.No), p => p.No == dto.No)
|
|
|
|
+ .FirstAsync();
|
|
|
|
+ return _mapper.Map<OrderDto>(order);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 平台查询自己写入的工单
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get_order_list_own")]
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ public async Task<PagedDto<OrderDto>> GetOrderByList([FromBody] GetOrderList dto)
|
|
|
|
+ {
|
|
|
|
+ var (total, items) = await _orderRepository.Queryable()
|
|
|
|
+ .Where(p => p.SourceChannelCode == dto.SourceChannelCode)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.No), p => p.No == dto.No)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Mobile), p => p.Contact.Contains(dto.Mobile))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.AcceptTypeCode), p => p.AcceptTypeCode == dto.AcceptTypeCode)
|
|
|
|
+ .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
|
|
|
|
+ .WhereIF(dto.EndTime.HasValue, p => p.CreationTime < dto.EndTime)
|
|
|
|
+ .OrderByDescending(p => p.CreationTime)
|
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询工单发布后公开的数据
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get_order_list_publish")]
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ public async Task<PagedDto<OrderDto>> GetOrderByListOpen([FromBody] GetOrderList dto)
|
|
|
|
+ {
|
|
|
|
+ var (total, items) = await _orderRepository.Queryable()
|
|
|
|
+ .Includes(d => d.OrderPublish)
|
|
|
|
+ .Where(p => p.OrderPublish.PublishState == true)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.No), p => p.No == dto.No)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Title), p => p.Title.Contains(dto.Title))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Mobile), p => p.Contact.Contains(dto.Mobile))
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.AcceptTypeCode), p => p.AcceptTypeCode == dto.AcceptTypeCode)
|
|
|
|
+ .WhereIF(dto.StartTime.HasValue, p => p.CreationTime >= dto.StartTime)
|
|
|
|
+ .WhereIF(dto.EndTime.HasValue, p => p.CreationTime < dto.EndTime)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.AreaCode), p => p.AreaCode == dto.AreaCode)
|
|
|
|
+ .OrderByDescending(p => p.CreationTime)
|
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ return new PagedDto<OrderDto>(total, _mapper.Map<IReadOnlyList<OrderDto>>(items));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 查询公告列表
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("query_bulletin_list")]
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ public async Task<PagedDto<BulletinDto>> QueryBulletinList([FromQuery] GetBulletinListDto dto)
|
|
|
|
+ {
|
|
|
|
+ var (total, items) = await _bulletinRepository.Queryable()
|
|
|
|
+ .Where(p => p.LoseEfficacyTime >= DateTime.Now)
|
|
|
|
+ .Where(p => SqlFunc.JsonListObjectAny(p.PushRanges, "Key", dto.PushRanges))
|
|
|
|
+ .Where(p => p.IsArrive == true && p.BulletinState == EBulletinState.ReviewPass)
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.BulletinTypeId), d => d.BulletinTypeId == dto.BulletinTypeId)
|
|
|
|
+ .OrderByDescending(p => p.BulletinTime)
|
|
|
|
+ .ToPagedListAsync(dto.PageIndex, dto.PageSize, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ return new PagedDto<BulletinDto>(total, _mapper.Map<IReadOnlyList<BulletinDto>>(items));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 公告详情
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="dto"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get_bulletin_detail")]
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ public async Task<BulletinDto> GetBulletinEntity([FromBody] GetOrderDetailDto dto)
|
|
|
|
+ {
|
|
|
|
+ var model = await _bulletinRepository.Queryable()
|
|
|
|
+ .Includes(x => x.ExaminMan)
|
|
|
|
+ .FirstAsync(x => x.Id == dto.Id && x.IsArrive == true && x.BulletinState == EBulletinState.ReviewPass, HttpContext.RequestAborted);
|
|
|
|
+
|
|
|
|
+ if (model != null)
|
|
|
|
+ {
|
|
|
|
+ model.ReadedNum = model.ReadedNum++;
|
|
|
|
+ await _bulletinRepository.UpdateAsync(model, HttpContext.RequestAborted);
|
|
|
|
+ }
|
|
|
|
+ return _mapper.Map<BulletinDto>(model);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 今日受理分类统计
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [HttpPost("get_pur_type_report")]
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ public async Task<object> GetPurTypeReport()
|
|
|
|
+ {
|
|
|
|
+ var list = await _orderRepository.Queryable()
|
|
|
|
+ .Where(p => p.CreationTime >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")))
|
|
|
|
+ .Where(p => p.CreationTime <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")))
|
|
|
|
+ .Select(it => new
|
|
|
|
+ {
|
|
|
|
+ it.AcceptType,
|
|
|
|
+ it.AcceptTypeCode
|
|
|
|
+ })
|
|
|
|
+ .MergeTable()//将查询出来的结果合并成一个新表
|
|
|
|
+ .GroupBy(it => new { it.AcceptType, it.AcceptTypeCode })//对新表进行分组
|
|
|
|
+ .Select(it => new
|
|
|
|
+ {
|
|
|
|
+ PurTypeName = it.AcceptType,
|
|
|
|
+ Count = SqlFunc.AggregateCount(it.AcceptTypeCode)
|
|
|
|
+ })
|
|
|
|
+ .ToListAsync();
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 今日统计
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ [AllowAnonymous]
|
|
|
|
+ [HttpPost("get_day_count")]
|
|
|
|
+ public async Task<object> GetDayCount()
|
|
|
|
+ {
|
|
|
|
+ //今日已办结
|
|
|
|
+ var dayTrandCount = await _orderRepository.Queryable().Where(p => p.CreationTime >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")) &&
|
|
|
|
+ p.CreationTime <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")) && p.Status >= EOrderStatus.Filed).CountAsync();
|
|
|
|
+
|
|
|
|
+ //今日总量
|
|
|
|
+ var dayCount = await _orderRepository.Queryable().Where(p => p.CreationTime >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")) &&
|
|
|
|
+ p.CreationTime <= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"))).CountAsync();
|
|
|
|
+
|
|
|
|
+ return new { DayTrandCount = dayTrandCount, DayCount = dayCount };
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|