|
|
|
@ -11,6 +11,7 @@ using Elight.Utility;
|
|
|
|
|
using Elight.Utility.Code; |
|
|
|
|
using Elight.Utility.Extensions; |
|
|
|
|
using Elight.Utility.logs; |
|
|
|
|
using java.io; |
|
|
|
|
using java.lang; |
|
|
|
|
using java.time; |
|
|
|
|
using javax.xml.crypto; |
|
|
|
@ -20,6 +21,7 @@ using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
|
|
using Newtonsoft.Json; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using SqlSugar.Extensions; |
|
|
|
|
using System.Data; |
|
|
|
|
using System.Linq; |
|
|
|
|
using System.Net.WebSockets; |
|
|
|
|
using System.Text; |
|
|
|
@ -115,6 +117,124 @@ namespace _24Hour.Controllers.Common
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 导入律师库信息,先调用/api/Common/Upload_Files1将文件上传至库,然后用url调用ImportLawyerData |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="path">excel文件相对路径</param> |
|
|
|
|
/// <returns></returns> |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("ImportLawyerData")] |
|
|
|
|
public async Task<Result> ImportLawyerData(string path) |
|
|
|
|
{ |
|
|
|
|
Result res = new Result(); |
|
|
|
|
int updated = 0, added = 0; |
|
|
|
|
var ext = Path.GetExtension(path).ToLower(); |
|
|
|
|
|
|
|
|
|
if (ext == ".xlsx" || ext == ".xls") |
|
|
|
|
{ |
|
|
|
|
if (System.IO.File.Exists(path)) |
|
|
|
|
{ |
|
|
|
|
var reader = new ExcelReader(path); |
|
|
|
|
var dt = reader.ExcelToDataTable(); |
|
|
|
|
if (dt != null) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lawyers = new List<App_Sys_UserModel>(); |
|
|
|
|
foreach (DataRow dr in dt.Rows) |
|
|
|
|
{ |
|
|
|
|
var cardid = dr.Field<string>("证件编号"); |
|
|
|
|
if (string.IsNullOrEmpty(cardid)) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
lawyers.Add(new() |
|
|
|
|
{ |
|
|
|
|
Id = Guid.NewGuid().ToString(), |
|
|
|
|
name = dr.Field<string>("姓名"), |
|
|
|
|
sex = dr?.Field<string>("性别")?.Contains('男') == true ? 0 : 1, |
|
|
|
|
phone = dr.Field<string>("手机号码"), |
|
|
|
|
departmentName = dr.Field<string>("执业机构"), |
|
|
|
|
identitycardId = dr.Field<string>("执业证号"), |
|
|
|
|
cardId = dr.Field<string>("证件编号"), |
|
|
|
|
unitCode = _userdata.unitCode, |
|
|
|
|
|
|
|
|
|
createtime = DateTime.Now, |
|
|
|
|
createuserId = _userdata.createuserId, |
|
|
|
|
createusername = _userdata.name, |
|
|
|
|
identity = "律师", |
|
|
|
|
usertype = 1, |
|
|
|
|
audit = 0, |
|
|
|
|
|
|
|
|
|
isdeactivate = 0, |
|
|
|
|
IsDeleted = 0, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
var cardids = lawyers.Select(e => e.cardId).ToList(); |
|
|
|
|
var lawyersInDb = await _db.Queryable<App_Sys_UserModel>().In(x => x.cardId, cardids).ToListAsync(); |
|
|
|
|
if (lawyersInDb.Any()) |
|
|
|
|
{ |
|
|
|
|
var updatelist = new List<App_Sys_UserModel>(); |
|
|
|
|
foreach (var item in lawyersInDb) |
|
|
|
|
{ |
|
|
|
|
var lawyerinfo = lawyers.FirstOrDefault(x => x.cardId == item.cardId); |
|
|
|
|
if (lawyerinfo == null) |
|
|
|
|
{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (item.name != lawyerinfo.name || |
|
|
|
|
item.sex != lawyerinfo.sex || |
|
|
|
|
item.phone != lawyerinfo.phone || |
|
|
|
|
item.departmentName != lawyerinfo.departmentName || |
|
|
|
|
item.cardId != lawyerinfo.cardId) |
|
|
|
|
{ |
|
|
|
|
item.name = lawyerinfo.name; |
|
|
|
|
item.sex = lawyerinfo.sex; |
|
|
|
|
item.phone = lawyerinfo.phone; |
|
|
|
|
item.departmentName = lawyerinfo.departmentName; |
|
|
|
|
item.cardId = lawyerinfo.cardId; |
|
|
|
|
updatelist.Add(item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (updatelist.Any()) |
|
|
|
|
updated = await _db.Updateable(updatelist) |
|
|
|
|
.IgnoreColumns(ignoreAllNullColumns: true) |
|
|
|
|
.ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
var addlawyers = lawyers.Where(x => lawyersInDb.Any(e => e.cardId == x.cardId) == false).ToList(); |
|
|
|
|
|
|
|
|
|
if (addlawyers.Any()) |
|
|
|
|
added = await _db.Insertable(addlawyers).ExecuteCommandAsync(); |
|
|
|
|
|
|
|
|
|
res.IsSucceed = true; |
|
|
|
|
res.result = new |
|
|
|
|
{ |
|
|
|
|
updated, |
|
|
|
|
added |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
res.IsSucceed = false; |
|
|
|
|
res.Message = "数据异常"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
res.IsSucceed = false; |
|
|
|
|
res.Message = "文件不存在"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
res.IsSucceed = false; |
|
|
|
|
res.Message = "文件格式不支持"; |
|
|
|
|
} |
|
|
|
|
if (System.IO.File.Exists(path)) |
|
|
|
|
System.IO.File.Delete(path); |
|
|
|
|
return res; |
|
|
|
|
} |
|
|
|
|
/// <summary> |
|
|
|
|
/// 同步外网律师人员信息(未完成) (根据律师身份证号更新或新增用户信息) |
|
|
|
|
/// </summary> |
|
|
|
|
/// <param name="input"></param> |
|
|
|
|