Browse Source

修改添加律师的接口,添加数据统计接口

develop-lawyerExampaper
胡超1 2 years ago
parent
commit
fde797656f
  1. 213
      24Hour/Controllers/Common/LawyerArchivesController.cs

213
24Hour/Controllers/Common/LawyerArchivesController.cs

@ -1,4 +1,5 @@
using AutoMapper; using AutoMapper;
using AutoMapper.Internal;
using com.sun.xml.@internal.bind.v2.model.core; using com.sun.xml.@internal.bind.v2.model.core;
using Elight.Entity; using Elight.Entity;
using Elight.Entity.APPDto.Lawyer; using Elight.Entity.APPDto.Lawyer;
@ -11,12 +12,15 @@ using Elight.Utility.Code;
using Elight.Utility.Extensions; using Elight.Utility.Extensions;
using Elight.Utility.logs; using Elight.Utility.logs;
using java.lang; using java.lang;
using java.time;
using javax.xml.crypto; using javax.xml.crypto;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json; using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
using SqlSugar.Extensions;
using System.Linq;
using System.Net.WebSockets; using System.Net.WebSockets;
using System.Text; using System.Text;
using static _24Hour.TwentySystemProxyClient; using static _24Hour.TwentySystemProxyClient;
@ -121,9 +125,29 @@ namespace _24Hour.Controllers.Common
{ {
try try
{ {
var data = await _db.Queryable<App_Sys_UserModel>().FirstAsync(x => x.cardId == input.cardId && x.IsDeleted == 0); var data = await _db.Queryable<App_Sys_UserModel>().FirstAsync(x => x.cardId == input.cardId && x.IsDeleted == 0 && x.isdeactivate == 0);
if (data != null) if (data != null)
{ {
#region 为了避免律师先在一体机刷卡自动创建账号后无法添加律师身份的问题
if (data.identity != "律师")
{
data.identity = "律师";
}
try
{
_db.BeginTran();
var num = await _db.Updateable(data)
.WhereColumns(x => x.Id)
.IgnoreColumns(ignoreAllNullColumns: true)
.ExecuteCommandAsync();
_db.CommitTran();
}
catch (Exception ex)
{
logger.LogError(ex, "AddLawyer");
}
#endregion
result.IsSucceed = false; result.IsSucceed = false;
result.Message = "用户已存在"; result.Message = "用户已存在";
return result; return result;
@ -670,6 +694,181 @@ namespace _24Hour.Controllers.Common
}; };
return result; return result;
} }
/// <summary>
/// 统计阅卷信息
/// </summary>
/// <param name="stime">开始时间</param>
/// <param name="etime">结束时间</param>
/// <param name="groupby">分类类型 有效值:year,month,day</param>
/// <returns></returns>
[HttpGet]
[Route("CountReadStatusByTime")]
public async Task<Result> CountReadStatusByTime(DateTime? stime, DateTime? etime, string groupby)
{
#region 入参校验
DateTime starttime = stime == null ? DateHelper.GetStartDateOfDay(DateTime.Now.AddDays(-30)) : stime.Value;
DateTime endtime = etime == null ? DateHelper.GetEndDateOfDay(DateTime.Now) : etime.Value;
if (string.IsNullOrEmpty(groupby) || (groupby.ToLower() != "year" && groupby.ToLower() != "month" && groupby.ToLower() != "day"))
{
groupby = "day";
}
#endregion
try
{
#region 根据入参获取查询区间
var dates = new List<DateTime>();
DateTime start, end;
switch (groupby)
{
case "year":
dates = DateHelper.GetArrayByYear(starttime, endtime);
start = DateHelper.GetStartDateOfYear(starttime);
end = DateHelper.GetEndDateOfYear(endtime);
break;
case "month":
dates = DateHelper.GetArrayByMonth(starttime, endtime);
start = DateHelper.GetStartDateOfMonth(starttime);
end = DateHelper.GetEndDateOfMonth(endtime);
break;
default:
dates = DateHelper.GetArrayByDay(starttime, endtime);
start = DateHelper.GetStartDateOfDay(starttime);
end = DateHelper.GetEndDateOfDay(endtime);
break;
}
#endregion
#region 查询已经阅卷的统计信息
var readedlist = await Task.Run(async () =>
{
var registerCount = await _db.Queryable<LawyerArchives>()
.Where(x => x.status != 0)
.Where(x => x.actualStartTime != null && x.actualStartTime >= start)
.Where(x => x.actualStartTime != null && x.actualStartTime <= end)
.Where(x => x.unitcode == _userdata.unitCode)
.Where(x => x.IsDeleted == 0)
.ToListAsync();
var groupedlist = groupby switch
{
"year" => registerCount.GroupBy(x => DateHelper.GetStartDateOfYear(x.actualStartTime.Value))
.ToDictionary(x => x.Key, x => x.Count()),
"month" => registerCount.GroupBy(x => DateHelper.GetStartDateOfMonth(x.actualStartTime.Value))
.ToDictionary(x => x.Key, x => x.Count()),
_ => registerCount.GroupBy(x => x.actualStartTime.Value.Date)
.ToDictionary(x => x.Key, x => x.Count())
};
foreach (var item in dates)
{
if (groupedlist.ContainsKey(item) == false)
{
groupedlist.Add(item, 0);
}
}
var res = groupedlist.OrderBy(x => x.Key).Select(x => new
{
name = groupby switch
{
"year" => x.Key.ToString("yyyy"),
"month" => x.Key.ToString("yyyy-MM"),
_ => x.Key.ToString("yyyy-MM-dd")
},
value = x.Value
}).ToList();
return res;
});
#endregion
#region 根据查阅状态进行分组
var groupbystatus = await Task.Run(async () =>
{
var registerCount = await _db.Queryable<LawyerArchives>()
.Where(x => x.createTime != null && x.createTime >= start)
.Where(x => x.createTime != null && x.createTime <= end)
.Where(x => x.unitcode == _userdata.unitCode)
.Where(x => x.IsDeleted == 0)
.Where(x => x.status != null)
.ToListAsync();
var a = registerCount.GroupBy(x => x.status)
.ToDictionary(x => x.Key, x => x.Count());
var res = a.Select(x => new
{
name = x.Key switch
{
0 => "待查阅",
1 => "查阅中",
2 => "已查阅",
_ => "待查阅"
},
value = x.Value
}).ToList();
return res;
});
#endregion
#region 根据案件类型进行分组
var groupbycasetype = await Task.Run(async () =>
{
var registerCount = await _db.Queryable<LawyerArchives>()
.Where(x => x.createTime != null && x.createTime >= start)
.Where(x => x.createTime != null && x.createTime <= end)
.Where(x => x.unitcode == _userdata.unitCode)
.Where(x => x.IsDeleted == 0)
.Where(x => x.status != null)
.LeftJoin<JZJBXX>((x, e) => x.jzlbxxId == e.Id)
.GroupBy((x, e) => new { e.ajlbmc })
.Select((x, e) => new
{
name = e.ajlbmc,
value = SqlFunc.AggregateCount(e.ajlbmc)
})
.Take(10)
.ToListAsync();
if (registerCount.Count >= 10)
{
var excount = registerCount.Sum(x => x.value);
var allCount = await _db.Queryable<LawyerArchives>()
.Where(x => x.createTime != null && x.createTime >= start)
.Where(x => x.createTime != null && x.createTime <= end)
.Where(x => x.unitcode == _userdata.unitCode)
.Where(x => x.IsDeleted == 0)
.Where(x => x.status != null)
.CountAsync();
if (allCount > excount)
{
var list = new[]
{
new
{
name = "其他",
value = allCount-excount,
}
};
registerCount.AddRange(list);
}
}
return registerCount;
});
#endregion
result.IsSucceed = true;
result.result = new
{
GroupByReadStatus = readedlist,
GroupByStatus = groupbystatus,
GroupByType = groupbycasetype
};
}
catch
{
result.IsSucceed = false;
};
return result;
}
/// <summary> /// <summary>
/// 按律师分类 /// 按律师分类
/// </summary> /// </summary>
@ -795,19 +994,19 @@ namespace _24Hour.Controllers.Common
//[Route("EncodeData")] //[Route("EncodeData")]
//public async Task<Result> EncodeData(string id) //public async Task<Result> EncodeData(string id)
//{ //{
// var data = await _db.Queryable<App_LawyerServicesModel>().LeftJoin<App_Sys_UserModel>((lawyer, user) => lawyer.createuserId == user.Id) // var groupedlist = await _db.Queryable<App_LawyerServicesModel>().LeftJoin<App_Sys_UserModel>((lawyer, user) => lawyer.createuserId == user.Id)
// .Where(lawyer => lawyer.Id == id) // .Where(lawyer => lawyer.Id == id)
// .Select((lawyer, user) => new // .Select((lawyer, user) => new
// { // {
// info = lawyer, // info = lawyer,
// user // user
// }).FirstAsync(); // }).FirstAsync();
// if (data != null) // if (groupedlist != null)
// { // {
// var dto = new // var dto = new
// { // {
// info = mapper.Map<QRLawyerServiceDto>(data.info), // info = mapper.Map<QRLawyerServiceDto>(groupedlist.info),
// user = mapper.Map<QRUserDto>(data.user) // user = mapper.Map<QRUserDto>(groupedlist.user)
// }; // };
// var encodingdata = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(dto))); // var encodingdata = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(dto)));
// result.IsSucceed = true; // result.IsSucceed = true;
@ -823,11 +1022,11 @@ namespace _24Hour.Controllers.Common
//[HttpPost] //[HttpPost]
//[HiddenApi] //[HiddenApi]
//[Route("DecodeQRData")] //[Route("DecodeQRData")]
//public Task<Result> DecodeQRData(DecodeData data) //public Task<Result> DecodeQRData(DecodeData groupedlist)
//{ //{
// try // try
// { // {
// var basestr = Convert.FromBase64String(data.EncodingString); // var basestr = Convert.FromBase64String(groupedlist.EncodingString);
// var str = Encoding.UTF8.GetString(basestr); // var str = Encoding.UTF8.GetString(basestr);
// var model = str.ConvertToAnonymousType(new // var model = str.ConvertToAnonymousType(new

Loading…
Cancel
Save