402 lines
13 KiB
C#
402 lines
13 KiB
C#
using HL_FristAidPlatform_DataBase;
|
||
using HL_FristAidPlatform_Help;
|
||
using HL_FristAidPlatform_Help.Model;
|
||
using HL_FristAidPlatform_IDataBase;
|
||
using HL_FristAidPlatform_Models;
|
||
using System.Collections.Generic;
|
||
|
||
namespace HL_FristAidPlatform_Bussiness
|
||
{
|
||
/// <summary>
|
||
/// 用户
|
||
/// </summary>
|
||
public class T_SYS_UserBLL
|
||
{
|
||
private IT_SYS_User IService = new T_SYS_UserDB();
|
||
|
||
#region 增
|
||
public MessageModel<T_SYS_User> Add(T_SYS_User entity)
|
||
{
|
||
if (IService.Add(entity))
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删
|
||
public MessageModel<T_SYS_User> Dels(long id)
|
||
{
|
||
if (IService.Dels(id) > 0)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 逻辑删除用户
|
||
/// </summary>
|
||
/// <param name="id">用户编号</param>
|
||
/// <param name="deleteFlag">标记:0取消删除 1删除</param>
|
||
/// <returns></returns>
|
||
public MessageModel<T_SYS_User> LogicalDelete(long id, int deleteFlag)
|
||
{
|
||
if (IService.LogicalDelete(id, deleteFlag) > 0)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 改
|
||
public MessageModel<T_SYS_User> Update(T_SYS_User entity)
|
||
{
|
||
if (IService.Update(entity))
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新基本信息
|
||
/// </summary>
|
||
/// <param name="entity"></param>
|
||
/// <returns></returns>
|
||
public MessageModel<T_SYS_User> UpdateInfo(T_SYS_User user)
|
||
{
|
||
if (IService.UpdateInfo(user) > 0)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新密码
|
||
/// </summary>
|
||
/// <param name="user"></param>
|
||
/// <returns></returns>
|
||
public MessageModel<T_SYS_User> UpdatePassword(T_SYS_User user)
|
||
{
|
||
T_SYS_User user1 = new T_SYS_User();
|
||
|
||
user1 = IService.Get(user.ID);
|
||
|
||
if (user.Password == user1.Password)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "新密码与原密码相同!" };
|
||
}
|
||
|
||
if (IService.UpdatePassword(user) > 0)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新登录信息
|
||
/// </summary>
|
||
/// <param name="lastLoginIP">最后登录IP</param>
|
||
/// <param name="isOnline">是否在线0是1否</param>
|
||
/// <param name="id">用户编号</param>
|
||
/// <returns></returns>
|
||
public MessageModel<T_SYS_User> UpdateLoginInfo(int isOnline, long id, string lastLoginIP = "")
|
||
{
|
||
if (IService.UpdateLoginInfo(isOnline, id, lastLoginIP) > 0)
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = true, Msg = "操作成功" };
|
||
}
|
||
else
|
||
{
|
||
return new MessageModel<T_SYS_User> { Success = false, Msg = "操作失败" };
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 查
|
||
public TableModel<T_SYS_UserModel> GetPageList(int pageIndex, int pageSize, int gender, string keyWord)
|
||
{
|
||
return IService.GetPageList(pageIndex, pageSize, gender, keyWord);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取列表
|
||
/// </summary>
|
||
/// <param name="departmentsIds">所属部门ID集合</param>
|
||
/// <param name="keyWord">关键词</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_SYS_UserModel> GetList(string departmentsIds, string keyWord)
|
||
{
|
||
return IService.GetList(departmentsIds, keyWord);
|
||
}
|
||
|
||
public T_SYS_User Get(long id)
|
||
{
|
||
return IService.Get(id);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 用户登陆
|
||
/// </summary>
|
||
/// <param name="loginName">登录名</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_SYS_UserModel> Login(string loginName, string passWord)
|
||
{
|
||
List<string> OperatList = new List<string>();
|
||
string[] Operats = null;
|
||
string OperatValue = "";
|
||
TableModel<T_SYS_UserModel> tableModel = new TableModel<T_SYS_UserModel>();
|
||
T_SYS_UserModel t_SYS_UserModel = new T_SYS_UserModel();
|
||
tableModel = IService.Login(loginName, passWord);
|
||
foreach (var item in tableModel.Data)
|
||
{
|
||
if (!string.IsNullOrEmpty(item.RoleOperating))
|
||
{
|
||
Operats = item.RoleOperating.Split('#');
|
||
for (int i = 0; Operats.Length > i; i++)
|
||
{
|
||
if (!OperatList.Contains(Operats[i]))
|
||
{
|
||
OperatList.Add(Operats[i]);
|
||
OperatValue += Operats[i] + '#';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (tableModel.Data.Count > 0)
|
||
{
|
||
t_SYS_UserModel = tableModel.Data[0];
|
||
t_SYS_UserModel.RoleOperating = OperatValue;
|
||
}
|
||
tableModel.Data.Clear();
|
||
tableModel.Data.Add(t_SYS_UserModel);
|
||
return tableModel;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据where条件查询用户
|
||
/// </summary>
|
||
/// <param name="where"></param>
|
||
/// <returns></returns>
|
||
public TableModel<T_SYS_User> GetModelByWhere(string where)
|
||
{
|
||
return IService.GetModelByWhere(where);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 判断登录名是否存在
|
||
/// </summary>
|
||
/// <param name="userId">用户编号</param>
|
||
/// <param name="loginName">登录名</param>
|
||
/// <param name="flag">1:新增2:修改</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_SYS_User> CheckIsExist(long userId, string loginName, int flag)
|
||
{
|
||
return IService.CheckIsExist(userId, loginName, flag);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据GUID获取用户
|
||
/// </summary>
|
||
/// <param name="guid">编号GUID</param>
|
||
/// <returns></returns>
|
||
public TableModel<T_SYS_User> GetByGuid(string guid)
|
||
{
|
||
return IService.GetByGuid(guid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据科室编号和人员类型获取用户列表
|
||
/// </summary>
|
||
/// <param name="hospitalGuid">患者所属院区(GUID)</param>
|
||
/// <param name="departmentsIds">科室编号(,分割)</param>
|
||
/// <param name="personnelTypes">人员类型(,分割)</param>
|
||
/// <returns></returns>
|
||
public string GetList_DepartmentsUser(string hospitalGuid, string departmentsIds, string personnelTypes)
|
||
{
|
||
return IService.GetList_DepartmentsUser(hospitalGuid, departmentsIds, personnelTypes);
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 当前登录用户是否是120用户
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
public string Is120User(long id)
|
||
{
|
||
return IService.Is120User(id);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取出车人员列表
|
||
/// </summary>
|
||
/// <param name="hospitalGuid"></param>
|
||
/// <param name="state"></param>
|
||
/// <param name="type">0 未绑定 1 已绑定车辆</param>
|
||
/// <param name="name"></param>
|
||
/// <param name="gender"></param>
|
||
/// <returns></returns>
|
||
public TableModel<FirstAidUserModel> GetFirstAidUserList(string hospitalGuid, int state, int type, string name, int gender, int pageIndex, int pageSize)
|
||
{
|
||
return IService.GetFirstAidUserList(hospitalGuid, state, type, name, gender, pageIndex, pageSize);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新状态
|
||
/// </summary>
|
||
/// <param name="model"></param>
|
||
/// <returns></returns>
|
||
public bool UpdateSate(UserUpdateSateModel model)
|
||
{
|
||
return IService.UpdateSate(model);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取空闲且未绑定车辆人员
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public TableModel<OwnerlessPersonnelModel> GetOwnerlessPersonnel(string hospitalGuid)
|
||
{
|
||
return IService.GetOwnerlessPersonnel(hospitalGuid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取空闲且未绑定车辆的医生
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public TableModel<OwnerlessPersonnelModel> GetDoctor(string hospitalGuid)
|
||
{
|
||
return IService.GetDoctor(hospitalGuid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取空闲且未绑定车辆的司机
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public TableModel<OwnerlessPersonnelModel> GetDriver(string hospitalGuid)
|
||
{
|
||
return IService.GetDriver(hospitalGuid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取空闲且未绑定车辆的护士
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public TableModel<OwnerlessPersonnelModel> GetNurse(string hospitalGuid)
|
||
{
|
||
return IService.GetNurse(hospitalGuid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取出车人员
|
||
/// </summary>
|
||
/// <param name="hospitalGuid"></param>
|
||
/// <param name="type">0司机 1医生 2护士</param>
|
||
/// <returns></returns>
|
||
public TableModel<DrvingUserModel> GetDrvingUserList(string hospitalGuid, int type)
|
||
{
|
||
return IService.GetDrvingUserList(hospitalGuid, type);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批量分配(车辆绑定人员)
|
||
/// </summary>
|
||
/// <param name="list"></param>
|
||
/// <param name="guid"></param>
|
||
/// <returns></returns>
|
||
public int VehiclePersonnelPlan(PlanDrvingPersonnelModel model)
|
||
{
|
||
List<T_SYS_User> list = new List<T_SYS_User>();
|
||
string[] str = model.PerList.Split(new char[] { ',' });
|
||
if (str.Length > 0)
|
||
{
|
||
for (int i = 0; i < str.Length; i++)
|
||
{
|
||
T_SYS_User per = new T_SYS_User();
|
||
per.GUID = str[i];
|
||
list.Add(per);
|
||
}
|
||
}
|
||
|
||
return IService.VehiclePersonnelPlan(list, model.GUID);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 批量解绑(车辆解除绑定人员)
|
||
/// </summary>
|
||
/// <param name="list"></param>
|
||
/// <param name="guid"></param>
|
||
/// <returns></returns>
|
||
public int VehicleUnbundling(VehicleUnbundlingModel model)
|
||
{
|
||
return IService.VehicleUnbundling(model.GUID);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据车辆GUID查询绑定的人员
|
||
/// </summary>
|
||
/// <param name="ambulanceGUID"></param>
|
||
/// <returns></returns>
|
||
public List<PerofAmbulanceModel> GetPerofAmbulance(string ambulanceGUID)
|
||
{
|
||
return IService.GetPerofAmbulance(ambulanceGUID);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 根据车辆查询用户ID
|
||
/// </summary>
|
||
/// <param name="vehicleGuid"></param>
|
||
/// <returns></returns>
|
||
public TableModel<UserIDModel> GetUserIdOfVehicle(string[] guid)
|
||
{
|
||
return IService.GetUserIdOfVehicle(guid);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 医生/护士列表
|
||
/// </summary>
|
||
/// <param name="hosptalGuid"></param>
|
||
/// <returns></returns>
|
||
public TableModel<MedicalWorkersList> GetMedicalWorkersList(string hosptalGuid, int type)
|
||
{
|
||
return IService.GetMedicalWorkersList(hosptalGuid, type);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取部门人员-对象数组
|
||
/// </summary>
|
||
/// <param name="hospitalGuid"></param>
|
||
/// <returns></returns>
|
||
public List<DepartmentUserModel> GetDepartmentUsers(string hospitalGuid)
|
||
{
|
||
return IService.GetDepartmentUsers(hospitalGuid);
|
||
}
|
||
}
|
||
}
|