|
@@ -31,97 +31,165 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
|
|
|
|
|
|
|
|
|
- public async Task<Result> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
|
|
|
+ public async Task<JsonView> QueryInvitationOfficialActivityData(QueryInvitationOfficialActivityDataDto dto)
|
|
|
{
|
|
|
- Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
- try
|
|
|
- {
|
|
|
- string sqlWhere = string.Empty;
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.Country)) { sqlWhere += string.Format(@" And i.Country like '%{0}%'", dto.Country); }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.UnitName)) { sqlWhere += string.Format(@" And i.UnitName like '%{0}%'", dto.UnitName); }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.Contact)) { sqlWhere += string.Format(@" And i.Contact like '%{0}%'", dto.Contact); }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.Delegation)) { sqlWhere += string.Format(@" And ','+i.Delegation+',' like '%,{0},%'", dto.Delegation); }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.Field)) { sqlWhere += string.Format(@" And i.Field like '%{0}%'", dto.Field); }
|
|
|
-
|
|
|
- if (dto.CreateUserId != 0 && !string.IsNullOrWhiteSpace(dto.CreateUserId.ToString())) { sqlWhere += string.Format(@" And i.CreateUserId={0}", dto.CreateUserId); }
|
|
|
- if (!string.IsNullOrWhiteSpace(dto.StartCreateTime) && !string.IsNullOrWhiteSpace(dto.EndCreateTime))
|
|
|
- {
|
|
|
- sqlWhere += string.Format(@" And i.CreateTime between '{0}' and '{1}'", dto.StartCreateTime, dto.EndCreateTime);
|
|
|
- }
|
|
|
- sqlWhere += string.Format(@"And Isdel={0}", 0);
|
|
|
+ var result = new JsonView() { Msg = "操作失败!" };
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(sqlWhere.Trim()))
|
|
|
- {
|
|
|
- Regex r = new Regex("And");
|
|
|
- sqlWhere = r.Replace(sqlWhere, "Where", 1);
|
|
|
- }
|
|
|
- string sql = string.Format(@"select i.*,(select CnName from Sys_Users where Id=i.CreateUserId ) as CreateUserName from
|
|
|
- Res_InvitationOfficialActivityData i {0} order by CreateTime desc", sqlWhere);
|
|
|
- List<InvitationOfficialActivityDataView> _ivitiesViews = _sqlSugar.SqlQueryable<InvitationOfficialActivityDataView>(sql).ToList();
|
|
|
- if (_ivitiesViews.Count != 0)
|
|
|
- {
|
|
|
- List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().ToList();
|
|
|
+
|
|
|
+ DateTime _beginDt, _endDt;
|
|
|
+ var _beginDtBool = DateTime.TryParse(dto.StartCreateTime+" 00:00:00", out _beginDt);
|
|
|
+ var _endDtBool = DateTime.TryParse(dto.EndCreateTime + " 23:59:59", out _endDt);
|
|
|
|
|
|
- foreach (var item in _ivitiesViews)
|
|
|
- {
|
|
|
- string delegationNameList = "";
|
|
|
- string[] DelegationName = item.Delegation.Split(',');
|
|
|
- for (int i = 0; i < DelegationName.Length; i++)
|
|
|
- {
|
|
|
-
|
|
|
-
|
|
|
+ RefAsync<int> total = 0;
|
|
|
+
|
|
|
+ var _view = await _sqlSugar.Queryable<Res_InvitationOfficialActivityData>()
|
|
|
+ .LeftJoin<Sys_Users>((ioa, u) => ioa.CreateUserId == u.Id)
|
|
|
+ .Where((ioa,u) => ioa.IsDel == 0)
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Country), (ioa, u) => ioa.Country.Contains(dto.Country))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.UnitName), (ioa, u) => ioa.UnitName.Contains(dto.UnitName))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Contact), (ioa, u) => ioa.Contact.Contains(dto.Contact))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Delegation), (ioa, u) => ioa.Delegation.Contains(dto.Delegation))
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(dto.Field), (ioa, u) => ioa.Field.Contains(dto.Field))
|
|
|
+ .WhereIF(_beginDtBool && _endDtBool, (ioa, u) => ioa.CreateTime >= _beginDt && ioa.CreateTime <= _endDt)
|
|
|
+ .WhereIF(dto.CreateUserId > 0, (ioa, u) => ioa.CreateUserId == dto.CreateUserId)
|
|
|
+ .Select((ioa, u) => new {
|
|
|
+ Row_Number = ioa.RowIndex,
|
|
|
+ ioa.Id,
|
|
|
+ ioa.Country,
|
|
|
+ ioa.City,
|
|
|
+ ioa.UnitName,
|
|
|
+ ioa.Field,
|
|
|
+ ioa.Contact,
|
|
|
+ ioa.Job,
|
|
|
+ ioa.Tel,
|
|
|
+ ioa.CreateTime,
|
|
|
+ CreateUserName = u.CnName,
|
|
|
+ DelegationStr = ioa.Delegation
|
|
|
+ })
|
|
|
+ .OrderByDescending((ioa) => ioa.CreateTime)
|
|
|
+ .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
|
|
|
|
|
|
- delegationNameList += _DelegationInfos.Find(it => it.Id == int.Parse(DelegationName[i]))?.TeamName ?? "Unknown" + ",";
|
|
|
- }
|
|
|
- if (!string.IsNullOrWhiteSpace(delegationNameList))
|
|
|
- {
|
|
|
- item.DelegationStr = delegationNameList.Substring(0, delegationNameList.Length - 1);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- if (dto.PageSize == 0 && dto.PageIndex == 0)
|
|
|
- {
|
|
|
- result = new Result() { Code = 0, Msg = "查询成功!", Data = _ivitiesViews };
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- int count = _ivitiesViews.Count;
|
|
|
- float totalPage = (float)count / dto.PageSize;
|
|
|
- if (totalPage == 0) totalPage = 1;
|
|
|
- else totalPage = (int)Math.Ceiling((double)totalPage);
|
|
|
|
|
|
- List<InvitationOfficialActivityDataView> invitations = new List<InvitationOfficialActivityDataView>();
|
|
|
- for (int i = 0; i < dto.PageSize; i++)
|
|
|
- {
|
|
|
- var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
|
|
|
- if (RowIndex < _ivitiesViews.Count)
|
|
|
- {
|
|
|
- invitations.Add(_ivitiesViews[RowIndex]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- ListViewBase<InvitationOfficialActivityDataView> rst = new ListViewBase<InvitationOfficialActivityDataView>();
|
|
|
- rst.DataList = invitations;
|
|
|
- rst.DataCount = count;
|
|
|
- rst.CurrPageIndex = dto.PageIndex;
|
|
|
- rst.CurrPageSize = dto.PageSize;
|
|
|
- result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
|
|
|
- }
|
|
|
-
|
|
|
+ foreach (var item in _view)
|
|
|
+ {
|
|
|
+ string groupNameStr = "";
|
|
|
+ int[] groupIds = item.DelegationStr.Split(',').Select(x =>
|
|
|
+ {
|
|
|
+ int id;
|
|
|
+ if (int.TryParse(x, out id)) return id;
|
|
|
+ else return id;
|
|
|
+ }).ToArray();
|
|
|
+
|
|
|
+ var _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => groupIds.Contains(x.Id)).ToList();
|
|
|
+ foreach (var group in _DelegationInfos)
|
|
|
+ {
|
|
|
+ groupNameStr += $"{group.TeamName},";
|
|
|
}
|
|
|
- else
|
|
|
+ if (groupNameStr.Length > 1)
|
|
|
{
|
|
|
- result = new Result() { Code = 0, Msg = "暂无数据!", Data = _ivitiesViews };
|
|
|
+ groupNameStr= groupNameStr.Substring(0, groupNameStr.Length - 1);
|
|
|
}
|
|
|
}
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- result = new Result() { Code = -2, Msg = ex.Message };
|
|
|
- }
|
|
|
+ result.Code = StatusCodes.Status200OK;
|
|
|
+ result.Msg = $"操作成功!";
|
|
|
+ result.Data = _view;
|
|
|
+ result.Count = _view.Count;
|
|
|
+
|
|
|
return result;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -141,7 +209,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
|
|
|
|
|
|
public async Task<JsonView> IOA_OP(OpInvitationOfficialActivityDto dto)
|
|
|
{
|
|
|
- JsonView result = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败1" };
|
|
|
+ JsonView result = new JsonView() { Code = StatusCodes.Status400BadRequest, Msg = "操作失败!" };
|
|
|
|
|
|
var _info = _mapper.Map<Res_InvitationOfficialActivityData>(dto);
|
|
|
|