|
@@ -0,0 +1,115 @@
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using OASystem.API.OAMethodLib;
|
|
|
+using OASystem.Domain.Dtos.Groups;
|
|
|
+using OASystem.Domain.Dtos.Statistics;
|
|
|
+using OASystem.Domain.ViewModels.Groups;
|
|
|
+using OASystem.Domain.ViewModels.Statistics;
|
|
|
+using OASystem.Infrastructure.Repositories.Groups;
|
|
|
+
|
|
|
+namespace OASystem.API.Controllers
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// 统计模块
|
|
|
+ /// </summary>
|
|
|
+ [Route("api/[controller]")]
|
|
|
+ //[ApiController]
|
|
|
+ public class StatisticsController : ControllerBase
|
|
|
+ {
|
|
|
+
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ private readonly SqlSugarClient _sqlSugar;
|
|
|
+ private readonly DelegationInfoRepository _groupRep;
|
|
|
+ private readonly SetDataRepository _setDataRep;
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Init
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="mapper"></param>
|
|
|
+ /// <param name="sqlSugar"></param>
|
|
|
+ /// <param name="groupRep"></param>
|
|
|
+ /// <param name="setDataRep"></param>
|
|
|
+ public StatisticsController(IMapper mapper, SqlSugarClient sqlSugar, DelegationInfoRepository groupRep, SetDataRepository setDataRep)
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ _groupRep = groupRep;
|
|
|
+ _setDataRep = setDataRep;
|
|
|
+ _sqlSugar = sqlSugar;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 团组报表
|
|
|
+ /// Items
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_dto">团组列表请求dto</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost]
|
|
|
+ [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
|
|
|
+ public async Task<IActionResult> PostGroupStatementItems(GroupStatementItemsDto _dto)
|
|
|
+ {
|
|
|
+ #region 参数验证
|
|
|
+ if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
|
|
|
+ if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
|
|
|
+
|
|
|
+ PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
|
|
|
+ #region 页面操作权限验证
|
|
|
+ pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
|
|
|
+
|
|
|
+ if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
|
|
|
+ {
|
|
|
+ string sqlWhere = string.Empty;
|
|
|
+ if (_dto.IsSure == 0) //未完成
|
|
|
+ {
|
|
|
+ sqlWhere += string.Format(@" And IsSure = 0");
|
|
|
+ }
|
|
|
+ else if (_dto.IsSure == 1) //已完成
|
|
|
+ {
|
|
|
+ sqlWhere += string.Format(@" And IsSure = 1");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(_dto.SearchCriteria))
|
|
|
+ {
|
|
|
+ string tj = _dto.SearchCriteria;
|
|
|
+ sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or ClientName Like '%{3}%' Or su.CnName Like '%{4}%')",
|
|
|
+ tj, tj, tj, tj, tj);
|
|
|
+ }
|
|
|
+
|
|
|
+ string sql = string.Format(@"Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
|
|
|
+ gdi.Id,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
|
|
|
+ ClientName,ClientUnit,VisitDate,ssd.Id TeamTypeId, ssd.Name TeamType,
|
|
|
+ VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime,
|
|
|
+ pr.LastCollectionTime
|
|
|
+ From Grp_DelegationInfo gdi
|
|
|
+ Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
|
|
|
+ Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
|
|
|
+ Left Join Sys_Users su On gdi.JietuanOperator = su.Id
|
|
|
+ Left Join (
|
|
|
+ SELECT Diid, MAX(CreateTime) LastCollectionTime
|
|
|
+ FROM Fin_ProceedsReceived
|
|
|
+ Where IsDel = 0
|
|
|
+ GROUP BY Diid
|
|
|
+ ) pr On gdi.Id = pr.Diid
|
|
|
+ Where gdi.IsDel = 0 {0} ", sqlWhere);
|
|
|
+
|
|
|
+ RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
|
|
|
+ var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatementItemView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
|
|
|
+
|
|
|
+ var _view = new
|
|
|
+ {
|
|
|
+ PageFuncAuth = pageFunAuthView,
|
|
|
+ Data = _DelegationList
|
|
|
+ };
|
|
|
+ return Ok(JsonView(true, "查询成功!", _view, total));
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(JsonView(false, "查询失败"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|