Commit 6769256d by 钟博

科室、人员、用户批量添加

parent 11fcfc84
...@@ -315,7 +315,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request) ...@@ -315,7 +315,7 @@ public ApiResponse SelfInfos([FromBody] UserRequest request)
if (request.Role <= 0) if (request.Role <= 0)
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false; user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First().Type ?? 0) : false;
else else
user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First(t=>t.RoleID==request.Role).Type ?? 0) : false; user.IsAgainAdmin = user.Role != null ? roleArray.Contains(user.Role.First(t => t.RoleID == request.Role).Type ?? 0) : false;
return new ApiResponse(ResponseType.OK, user); return new ApiResponse(ResponseType.OK, user);
} }
...@@ -379,8 +379,8 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody] ...@@ -379,8 +379,8 @@ public ApiResponse DeleteUser([CustomizeValidator(RuleSet = "Delete"), FromBody]
[HttpPost] [HttpPost]
public ApiResponse GetBatchUserStructrue() public ApiResponse GetBatchUserStructrue()
{ {
var result=_userService.GetUserHandsFlat(); var result = _userService.GetUserHandsFlat();
return new ApiResponse(ResponseType.OK,result); return new ApiResponse(ResponseType.OK, result);
} }
...@@ -391,10 +391,19 @@ public ApiResponse GetBatchUserStructrue() ...@@ -391,10 +391,19 @@ public ApiResponse GetBatchUserStructrue()
/// <returns></returns> /// <returns></returns>
[Route("BatchSaveUser")] [Route("BatchSaveUser")]
[HttpPost] [HttpPost]
public ApiResponse BatchSaveUser([FromBody]UserCollectData data) public ApiResponse BatchSaveUser([FromBody] UserCollectData data)
{ {
_userService.SaveUserHandsFlat(data); var result = _userService.SaveUserHandsFlat(data);
switch (result)
{
case 1:
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
case 2:
return new ApiResponse(ResponseType.Error, "登录名重复");
default:
return new ApiResponse(ResponseType.Error, "核算单元填写错误");
}
} }
} }
} }
\ No newline at end of file
...@@ -187,11 +187,11 @@ public ApiResponse DeptIncomeDetail([CustomizeValidator(RuleSet = "Select"), Fro ...@@ -187,11 +187,11 @@ public ApiResponse DeptIncomeDetail([CustomizeValidator(RuleSet = "Select"), Fro
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("person/GetBatchPersonStructrue")] [Route("person/GetBatchPersonStructrue/{hospitalId}")]
public ApiResponse GetBatchPersonStructrue(int hospitalId) public ApiResponse GetBatchPersonStructrue(int hospitalId)
{ {
var result=personService.GetBatchPersonStructrue(hospitalId); var result = personService.GetBatchPersonStructrue(hospitalId);
return new ApiResponse(ResponseType.OK,result); return new ApiResponse(ResponseType.OK, result);
} }
/// <summary> /// <summary>
...@@ -199,11 +199,14 @@ public ApiResponse GetBatchPersonStructrue(int hospitalId) ...@@ -199,11 +199,14 @@ public ApiResponse GetBatchPersonStructrue(int hospitalId)
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("person/BathSavePerson")] [Route("person/{allotId}/BathSavePerson/{hospitalId}")]
public ApiResponse BathSavePerson(int allotId,int hospitalId,SaveCollectData request) public ApiResponse BathSavePerson(int allotId, int hospitalId, SaveCollectData request)
{ {
personService.BathSavePerson(allotId, hospitalId, request); var result = personService.BathSavePerson(allotId, hospitalId, request);
if (result)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
else
return new ApiResponse(ResponseType.Error,"出勤天数或预留比例格式错误");
} }
/// <summary> /// <summary>
...@@ -211,7 +214,7 @@ public ApiResponse BathSavePerson(int allotId,int hospitalId,SaveCollectData req ...@@ -211,7 +214,7 @@ public ApiResponse BathSavePerson(int allotId,int hospitalId,SaveCollectData req
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("dept/GetDeptStructrue")] [Route("dept/GetDeptStructrue/{hospitalId}")]
public ApiResponse GetDeptStructrue(int hospitalId) public ApiResponse GetDeptStructrue(int hospitalId)
{ {
var result = personService.GetDepartmentHands(hospitalId); var result = personService.GetDepartmentHands(hospitalId);
...@@ -223,8 +226,8 @@ public ApiResponse GetDeptStructrue(int hospitalId) ...@@ -223,8 +226,8 @@ public ApiResponse GetDeptStructrue(int hospitalId)
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("dept/SaveDeptHands")] [Route("dept/SaveDeptHands/{hospitalId}")]
public ApiResponse SaveDeptHands(int hospitalId,SaveCollectData request) public ApiResponse SaveDeptHands(int hospitalId, SaveCollectData request)
{ {
personService.SaveDeptDicHands(hospitalId, request); personService.SaveDeptDicHands(hospitalId, request);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class PerEmployeeRquest
{
public string AccountingUnit { get; set; }
public string Department { get; set; }
public string DoctorName { get; set; }
public string PersonnelNumber { get; set; }
public string JobCategory { get; set; }
public string Duty { get; set; }
public string JobTitle { get; set; }
public string UnitType { get; set; }
public int? AttendanceDay { get; set; }
public decimal? ReservedRatio { get; set; }
public string Remark { get; set; }
}
}
...@@ -9,6 +9,8 @@ public class UserHandsResponse ...@@ -9,6 +9,8 @@ public class UserHandsResponse
public string RealName { get; set; } public string RealName { get; set; }
public string Login { get; set; } public string Login { get; set; }
public string Password { get; set; } public string Password { get; set; }
public string Mobile { get; set; }
public string Mail { get; set; }
public string Department { get; set; } public string Department { get; set; }
public string RoleName { get; set; } public string RoleName { get; set; }
public string HosName { get; set; } public string HosName { get; set; }
......
...@@ -14,6 +14,7 @@ public class SaveCollectData ...@@ -14,6 +14,7 @@ public class SaveCollectData
public class UserCollectData public class UserCollectData
{ {
public int HospitalId { get; set; }
public int? CreateUser { get; set; } public int? CreateUser { get; set; }
public string[] ColHeaders { get; set; } public string[] ColHeaders { get; set; }
public string[][] Data { get; set; } public string[][] Data { get; set; }
......
...@@ -643,9 +643,15 @@ public bool AgainDelete(CofAgainRequest request) ...@@ -643,9 +643,15 @@ public bool AgainDelete(CofAgainRequest request)
/// <returns></returns> /// <returns></returns>
public List<cof_accounting> GetAccountingList(AccoungingRequest request) public List<cof_accounting> GetAccountingList(AccoungingRequest request)
{ {
var list = request.Type != 2 ? cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId) switch (request.Type)
: cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId && t.UnitType == request.UnitType); {
return list; case 1: //返回accounting列表
case 2: //返回核算单元类型
default:
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId);
case 3: //返回核算单元
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId && t.UnitType == request.UnitType);
}
} }
/// <summary> /// <summary>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -598,24 +599,13 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId) ...@@ -598,24 +599,13 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId)
}).ToList()); }).ToList());
var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId); var deptdics = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId);
var ss = deptdics?.Where(t => !new string[] { UnitType.专家组.ToString() }.Contains(t.UnitType));
if (result.Columns != null && result.Columns.Any()) if (result.Columns != null && result.Columns.Any())
{ {
foreach (var column in result.Columns) foreach (var column in result.Columns)
{ {
if (column.Data == "角色")
{ if (column.Data == "人员类别")
column.Type = "autocomplete";
column.Source = deptdics?.Where(t => !new string[] { UnitType.行政后勤.ToString(), UnitType.特殊核算组.ToString() }.Contains(t.UnitType)).Select(t => t.AccountingUnit).Distinct().ToArray();
column.Strict = true;
}
else if (column.Data == "分配医院")
{
column.Type = "autocomplete";
column.Source = deptdics.Select(t => t.Department).Distinct().ToArray();
column.Strict = true;
}
else if (column.Data == "人员类别")
{ {
column.Type = "autocomplete"; column.Type = "autocomplete";
column.Source = deptdics? column.Source = deptdics?
...@@ -623,6 +613,11 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId) ...@@ -623,6 +613,11 @@ public HandsonTable GetBatchPersonStructrue(int hospitalId)
.Select(t => t.UnitType).Distinct().ToArray(); .Select(t => t.UnitType).Distinct().ToArray();
column.Strict = true; column.Strict = true;
} }
else if (new[] { "出勤天数", "预留比例" }.Contains(column.Data))
{
column.Type = "numeric";
column.NumericFormat = new NumericFormat { Pattern = "0,00" };
}
} }
} }
return result; return result;
...@@ -636,84 +631,100 @@ public HandsonTable GetDepartmentHands(int hospitalId) ...@@ -636,84 +631,100 @@ public HandsonTable GetDepartmentHands(int hospitalId)
Visible = 1, Visible = 1,
Readnoly = 0 Readnoly = 0
}).ToList()); }).ToList());
#region 科室下拉
if (handson.Columns != null && handson.Columns.Any()) //if (handson.Columns != null && handson.Columns.Any())
{ //{
foreach (var column in handson.Columns) // foreach (var column in handson.Columns)
{ // {
if (column.Data == "标准科室") // if (column.Data == "标准科室")
{ // {
column.Type = "autocomplete"; // column.Type = "autocomplete";
column.Source = DeptDics(hospitalId, 2).Select(c => c.Value).ToArray(); // column.Source = DeptDics(hospitalId, 2).Select(c => c.Value).ToArray();
column.Strict = true; // column.Strict = true;
} // }
else if (column.Data == "系统科室") // else if (column.Data == "系统科室")
{ // {
column.Type = "autocomplete"; // column.Type = "autocomplete";
column.Source = DeptDics(hospitalId, 1).Select(c => c.Value).ToArray(); // column.Source = DeptDics(hospitalId, 1).Select(c => c.Value).ToArray();
column.Strict = true; // column.Strict = true;
} // }
else if (new[] { "住院·核算单元医生组", "住院·核算单元护理组", "住院·核算单元医技组", "门诊·核算单元医生组", "门诊·核算单元护理组", "门诊·核算单元医技组" }.Contains(column.Data)) // else if (new[] { "住院·核算单元医生组", "住院·核算单元护理组", "住院·核算单元医技组", "门诊·核算单元医生组", "门诊·核算单元护理组", "门诊·核算单元医技组" }.Contains(column.Data))
{ // {
column.Type = "autocomplete"; // column.Type = "autocomplete";
column.Source = DeptDics(hospitalId, 3).Select(c => c.Value).ToArray(); // column.Source = DeptDics(hospitalId, 3).Select(c => c.Value).ToArray();
column.Strict = true; // column.Strict = true;
} // }
else if (column.Data == "行政后勤") // else if (column.Data == "行政后勤")
{ // {
column.Type = "autocomplete"; // column.Type = "autocomplete";
column.Source = DeptDics(hospitalId, 4).Select(c => c.Value).ToArray(); // column.Source = DeptDics(hospitalId, 4).Select(c => c.Value).ToArray();
column.Strict = true; // column.Strict = true;
} // }
else if (column.Data == "特殊核算组") // else if (column.Data == "特殊核算组")
{ // {
column.Type = "autocomplete"; // column.Type = "autocomplete";
column.Source = DeptDics(hospitalId, 5).Select(c => c.Value).ToArray(); // column.Source = DeptDics(hospitalId, 5).Select(c => c.Value).ToArray();
column.Strict = true; // column.Strict = true;
} // }
} // }
} //}
#endregion
return handson; return handson;
} }
public void BathSavePerson(int AllotId, int HospitalId, SaveCollectData request) public bool BathSavePerson(int AllotId, int HospitalId, SaveCollectData request)
{ {
var dicData = CreateDataRow(request, Person); var dicData = CreateDataRow(request, Person);
List<per_employee> employees = new List<per_employee>(); List<per_employee> employees = new List<per_employee>();
var persons = peremployeeRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
foreach (var item in dicData) foreach (var item in dicData)
{ {
if (!string.IsNullOrEmpty(item["AttendanceDay"]) && !string.IsNullOrEmpty(item["ReservedRatio"]) )
{
if ((!Regex.IsMatch(item["AttendanceDay"], "^([12][0-9]|31|[1-9])$")) || (!Regex.IsMatch(item["ReservedRatio"], @"0.\d+")))
return false;
}
var json = JsonHelper.Serialize(item); var json = JsonHelper.Serialize(item);
var data = JsonHelper.Deserialize<per_employee>(json); var data = JsonHelper.Deserialize<per_employee>(json);
if (!string.IsNullOrEmpty(data.Department) || !string.IsNullOrEmpty(data.AccountingUnit)) if (persons.Any(t => t.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim() && t.DoctorName?.Trim() == data.DoctorName?.Trim())
|| employees.Any(w => w.Department?.Trim() == data.Department?.Trim() && w.DoctorName?.Trim() == data.DoctorName?.Trim())) continue;
if (!string.IsNullOrEmpty(data.Department?.Trim()) || !string.IsNullOrEmpty(data.AccountingUnit?.Trim()) || !string.IsNullOrEmpty(data.DoctorName?.Trim()))
{ {
data.HospitalId = HospitalId; data.HospitalId = HospitalId;
data.AllotId = AllotId; data.AllotId = AllotId;
data.DoctorName = data.DoctorName?.Trim();
data.PersonnelNumber = data.PersonnelNumber?.Trim();
data.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")); data.CreateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd"));
employees.Add(data); employees.Add(data);
} }
peremployeeRepository.AddRange(employees.ToArray());
} }
if(employees.Any())
peremployeeRepository.AddRange(employees.ToArray());
return true;
} }
public void SaveDeptDicHands(int HospitalId, SaveCollectData request) public void SaveDeptDicHands(int HospitalId, SaveCollectData request)
{ {
var dicData = CreateDataRow(request, DeptDic); var dicData = CreateDataRow(request, DeptDic);
var depts = perdeptdicRepository.GetEntities(t => t.HospitalId == HospitalId).Select(w => new { w.Department, w.HISDeptName }).Distinct();
List<per_dept_dic> deptDics = new List<per_dept_dic>(); List<per_dept_dic> deptDics = new List<per_dept_dic>();
foreach (var dic in dicData) foreach (var dic in dicData)
{ {
var json = JsonHelper.Serialize(dic); var json = JsonHelper.Serialize(dic);
var data = JsonHelper.Deserialize<DeptdicHands>(json); var data = JsonHelper.Deserialize<DeptdicHands>(json);
if (depts.Any(t => t.Department?.Trim() == data.Department?.Trim() && t.HISDeptName?.Trim() == data.HISDeptName?.Trim())
|| deptDics.Any(w => w.Department?.Trim() == data.Department?.Trim() && w.HISDeptName?.Trim() == data.HISDeptName?.Trim())) continue;
if (!string.IsNullOrEmpty(data.Department) || !string.IsNullOrEmpty(data.HISDeptName)) if (!string.IsNullOrEmpty(data.Department?.Trim()) || !string.IsNullOrEmpty(data.HISDeptName?.Trim()))
{ {
DeptDicList(HospitalId, deptDics, data); DeptDicList(HospitalId, deptDics, data);
} }
} }
perdeptdicRepository.Execute("delete from per_dept_dic where HospitalId = @HospitalId", new { HospitalId }); if(deptDics.Any())
perdeptdicRepository.AddRange(deptDics.ToArray()); perdeptdicRepository.AddRange(deptDics.ToArray());
} }
...@@ -727,22 +738,22 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan ...@@ -727,22 +738,22 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan
if (data.InpatDoctorAccounting != "") if (data.InpatDoctorAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatDoctorAccounting; deptDic.AccountingUnit = data.InpatDoctorAccounting?.Trim();
deptDic.UnitType = "医生组"; deptDic.UnitType = "医生组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
if (data.InpatNurseAccounting != "") if (data.InpatNurseAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatNurseAccounting; deptDic.AccountingUnit = data.InpatNurseAccounting?.Trim();
deptDic.UnitType = "护理组"; deptDic.UnitType = "护理组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
if (data.InpatTechnicAccounting != "") if (data.InpatTechnicAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "住院", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.InpatTechnicAccounting; deptDic.AccountingUnit = data.InpatTechnicAccounting?.Trim();
deptDic.UnitType = "医技组"; deptDic.UnitType = "医技组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
...@@ -757,22 +768,22 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan ...@@ -757,22 +768,22 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan
if (data.OutDoctorAccounting != "") if (data.OutDoctorAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutDoctorAccounting; deptDic.AccountingUnit = data.OutDoctorAccounting?.Trim();
deptDic.UnitType = "医生组"; deptDic.UnitType = "医生组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
if (data.OutNurseAccounting != "") if (data.OutNurseAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutNurseAccounting; deptDic.AccountingUnit = data.OutNurseAccounting?.Trim();
deptDic.UnitType = "护理组"; deptDic.UnitType = "护理组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
if (data.OutTechnicAccounting != "") if (data.OutTechnicAccounting != "")
{ {
per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department, HISDeptName = data.HISDeptName, CreateTime = nowTime }; per_dept_dic deptDic = new per_dept_dic() { Source = "门诊", HospitalId = HospitalId, Department = data.Department?.Trim(), HISDeptName = data.HISDeptName?.Trim(), CreateTime = nowTime };
deptDic.AccountingUnit = data.OutTechnicAccounting; deptDic.AccountingUnit = data.OutTechnicAccounting?.Trim();
deptDic.UnitType = "医技组"; deptDic.UnitType = "医技组";
deptDics.Add(deptDic); deptDics.Add(deptDic);
} }
...@@ -786,10 +797,10 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan ...@@ -786,10 +797,10 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan
per_dept_dic deptDic = new per_dept_dic() per_dept_dic deptDic = new per_dept_dic()
{ {
HospitalId = HospitalId, HospitalId = HospitalId,
Department = data.Department, Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName, HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime, CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting, AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "行政后勤" UnitType = "行政后勤"
}; };
deptDics.Add(deptDic); deptDics.Add(deptDic);
...@@ -800,10 +811,10 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan ...@@ -800,10 +811,10 @@ private void DeptDicList(int HospitalId, List<per_dept_dic> deptDics, DeptdicHan
per_dept_dic deptDic = new per_dept_dic() per_dept_dic deptDic = new per_dept_dic()
{ {
HospitalId = HospitalId, HospitalId = HospitalId,
Department = data.Department, Department = data.Department?.Trim(),
HISDeptName = data.HISDeptName, HISDeptName = data.HISDeptName?.Trim(),
CreateTime = nowTime, CreateTime = nowTime,
AccountingUnit = data.LogisticsAccounting, AccountingUnit = data.LogisticsAccounting?.Trim(),
UnitType = "特殊核算组" UnitType = "特殊核算组"
}; };
deptDics.Add(deptDic); deptDics.Add(deptDic);
......
...@@ -724,30 +724,41 @@ public HandsonTable GetUserHandsFlat() ...@@ -724,30 +724,41 @@ public HandsonTable GetUserHandsFlat()
return result; return result;
} }
public void SaveUserHandsFlat(UserCollectData request) public int SaveUserHandsFlat(UserCollectData request)
{
try
{ {
var dicData = CreateDataRow(request, Users); var dicData = CreateDataRow(request, Users);
var getUsers = _userRepository.GetEntities();
var roles = _roleRepository.GetEntities(); var roles = _roleRepository.GetEntities();
var hospitals = _hospitalRepository.GetEntities(); var hospitals = _hospitalRepository.GetEntities();
var depts = _perdeptdicRepository.GetEntities(t => t.HospitalId == request.HospitalId).Select(w=>w.Department).Distinct();
List<sys_user> users = new List<sys_user>(); List<sys_user> users = new List<sys_user>();
List<sys_user_role> userRoles = new List<sys_user_role>(); List<sys_user_role> userRoles = new List<sys_user_role>();
List<sys_user_hospital> userHoss = new List<sys_user_hospital>(); List<sys_user_hospital> userHoss = new List<sys_user_hospital>();
var roleArr = new[] { "护士长", "科主任", "特殊科室", "行政科室" };
foreach (var item in dicData) foreach (var item in dicData)
{ {
var json = JsonHelper.Serialize(item); var json = JsonHelper.Serialize(item);
var data = JsonHelper.Deserialize<UserHandsResponse>(json); var data = JsonHelper.Deserialize<UserHandsResponse>(json);
if (!string.IsNullOrEmpty(data.Login) && !string.IsNullOrEmpty(data.RealName))
if (users.Any(c => c.Login == data.Login) || getUsers.Any(c => c.Login == data?.Login)) return 2;
if (roleArr.Contains(data.RoleName) && !depts.Any(t => t == data.Department)) return 3;
if (!string.IsNullOrEmpty(data.Login) && !string.IsNullOrEmpty(data.RealName) && !string.IsNullOrEmpty(data.HosName))
{ {
var user = new sys_user var user = new sys_user
{ {
RealName = data.RealName, RealName = data.RealName,
CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")), CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm:dd")),
CreateUser = request.CreateUser, CreateUser = request.CreateUser,
Department = data.Department, Department = data?.Department ?? "",
IsDelete = 1, IsDelete = 1,
Login = data.Login, Login = data.Login,
Password = data.Password, Password = data?.Password ?? "123456",
States = 1 States = 1,
Mobile = data?.Mobile ?? "",
Mail = data?.Mail ?? ""
}; };
users.Add(user); users.Add(user);
...@@ -769,6 +780,12 @@ public void SaveUserHandsFlat(UserCollectData request) ...@@ -769,6 +780,12 @@ public void SaveUserHandsFlat(UserCollectData request)
var hosJoin = userHoss.Join(users, t => new { }, w => new { }, (t, w) => new sys_user_hospital { HospitalID = t.HospitalID, UserID = w.ID }); var hosJoin = userHoss.Join(users, t => new { }, w => new { }, (t, w) => new sys_user_hospital { HospitalID = t.HospitalID, UserID = w.ID });
_userroleRepository.AddRange(roleJoin.ToArray()); _userroleRepository.AddRange(roleJoin.ToArray());
_userhospitalRepository.AddRange(hosJoin.ToArray()); _userhospitalRepository.AddRange(hosJoin.ToArray());
return 1;
}
catch (Exception e)
{
throw e;
}
} }
public static Dictionary<string, string> Users { get; } = new Dictionary<string, string> public static Dictionary<string, string> Users { get; } = new Dictionary<string, string>
...@@ -776,6 +793,8 @@ public void SaveUserHandsFlat(UserCollectData request) ...@@ -776,6 +793,8 @@ public void SaveUserHandsFlat(UserCollectData request)
{nameof(sys_user.RealName), "姓名"}, {nameof(sys_user.RealName), "姓名"},
{nameof(sys_user.Login), "登录名"}, {nameof(sys_user.Login), "登录名"},
{nameof(sys_user.Password), "密码"}, {nameof(sys_user.Password), "密码"},
{nameof(sys_user.Mobile), "手机号码"},
{nameof(sys_user.Mail), "邮箱"},
{nameof(sys_role.RoleName), "角色"}, {nameof(sys_role.RoleName), "角色"},
{nameof(sys_user.Department), "核算单元"}, {nameof(sys_user.Department), "核算单元"},
{nameof(sys_hospital.HosName), "分配医院"}, {nameof(sys_hospital.HosName), "分配医院"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment