public async Task <ErrData <bool> > HealthStaffSaveOrUpdateAsync(QueryData <HealthStaffQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; var res = await HealthPcOperaters.HealthAccountOperater.HealthStaffSaveOrUpdateAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { if (query.Criteria.Id <= 0) { result.SetInfo(true, "添加成功!", 200); } else { result.SetInfo(true, "修改成功!", 200); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > HealthTitleSaveAsync(QueryData <HealthTitleSaveQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; var model = query.Criteria; model.TitleId = Guid.NewGuid().ToString("N"); model.Creator = string.IsNullOrEmpty(query.Extend.UserNo) ? string.Empty : query.Extend.UserNo; query.Criteria = model; var res = await HealthPcOperaters.HealthTitleOperater.HealthTitleSaveAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "保存数据成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <ISysUserModel> > LoginAsync(QueryData <SysUserQuery> query) { var result = new ErrData <ISysUserModel>(); var dt = DateTime.Now; query.Criteria.IsDelete = false; query.Criteria.Access = true; var res = await _service.GetUserAllAsync(query); if (res.HasErr) { result.SetInfo(null, res.ErrMsg, res.ErrCode); } else { if (res.Data.Count > 0) { result.SetInfo(res.Data.FirstOrDefault(), "登录成功!", 200); } else { result.SetInfo(null, "用户名或密码不正确!", -201); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > AppSaveOrUpdateAsync(QueryData <SysAppSaveOrUpdateQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; query.Criteria.Creator = query.Extend.UserNo; query.Criteria.CreateName = query.Extend.UserName; query.Criteria.CreateTime = DateTime.Now; query.Criteria.Updator = query.Extend.UserNo; query.Criteria.UpdateName = query.Extend.UserName; query.Criteria.UpdateTime = DateTime.Now; var res = await _service.AppSaveOrUpdateAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, res.ErrMsg, 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > HealthStaffBatchDeleteAsync(QueryData <HealthStaffBatchDeleteQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; if (query.Criteria.LstStaffNo.Count <= 0) { result.SetInfo(false, "请选择需要删除的数据!", -102); } else { var res = await HealthPcOperaters.HealthAccountOperater.HealthStaffBatchDeleteAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "批量删除成功!", 200); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > RegisterAsync(QueryData <SysUserSaveOrUpdateQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; query.Criteria.Creator = "Register"; query.Criteria.CreateName = "注册"; query.Criteria.CreateTime = DateTime.Now; query.Criteria.RegisterTime = DateTime.Now; query.Criteria.Access = false; var res = await _service.UserSaveOrUpdateAsync(query); if (res.HasErr) { if (res.ErrCode == -101) { result.SetInfo(false, "注册新用户失败,请重试!", res.ErrCode); } else { result.SetInfo(false, res.ErrMsg, res.ErrCode); } } else { result.SetInfo(true, "注册新用户成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <IHealthUser> > HealthUserLoginExAsync(QueryData <HealthUserQuery> query) { var result = new ErrData <IHealthUser>(); var dt = DateTime.Now; var res = await HealthPcOperaters.HealthAccountOperater.GetHealthUserPageAsync(query); if (res.HasErr) { result.SetInfo(res.ErrMsg, res.ErrCode); } else { var queryEx = new QueryData <WcfADUserInfoQuery>() { Criteria = new WcfADUserInfoQuery() { UserName = query.Criteria.AdAccount, Password = query.Criteria.Pwd } }; var resUser = await WCFOperators.TlgChinaOperater.GetADUserInfoAsync(queryEx); if (resUser.HasErr) { result.SetInfo(resUser.ErrMsg, resUser.ErrCode); } else { if (string.IsNullOrEmpty(resUser.Data?.UserNo)) { result.SetInfo("用户名或密码错误!", -102); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } IHealthUser info = new HealthUser(); info.UserNo = resUser.Data.UserNo; info.UserName = resUser.Data.UserName; info.AdAccount = resUser.Data.ADAccount; info.IsAdmin = false; if (res.Data.Count > 0) { info.IsAdmin = res.Data.FirstOrDefault().IsAdmin; } result.SetInfo(info, "登录成功!", 200); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <byte[]> > HealthContentExcelExportUserStaffAllAsync(QueryData <HealthContentQuery> query) { var result = new ErrData <byte[]>(); var dt = DateTime.Now; var queryUser = new QueryData <HealthUserQuery>() { Criteria = new HealthUserQuery() { AdAccount = query.Extend.UserNo } }; #region 验证AD账号是否已添加权限 var resUser = await HealthPcOperaters.HealthAccountOperater.GetHealthUserPageAsync(queryUser); if (resUser.HasErr || resUser.Data.Count <= 0) { result.SetInfo("账号不存在!", -102); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } var loginUser = resUser.Data.FirstOrDefault(); #endregion if (loginUser.IsAdmin)//登录账号为管理员时,根据HR负责人作为sheet导出 { result = await HealthContentExcelExportByHrAllAsync(loginUser, query); } else//登录账号为非管理员时,登陆人作为sheet导出其权限下体检内容 { var dicTable = new Dictionary <string, DataTable>(); var queryEx = query.Criteria; queryEx.UpStaffNo = loginUser.IsAdmin ? string.Empty : loginUser.UserNo; query.Criteria = queryEx; var dtUserStaff = await GetHealthContentUserStaffAllAsync(query); if (dtUserStaff.HasErr) { result.SetInfo(dtUserStaff.Msg, dtUserStaff.Code); return(result); } else { dicTable.Add(loginUser.UserName, dtUserStaff.Results[0]); } result.Data = EPPlusHelper.ExcelExport(dicTable); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <DDUserInfoModel> > GetDDUserInfoAsync(QueryData <WebServiceDDQuery> query) { var result = new ErrData <DDUserInfoModel>(); var dt = DateTime.Now; var res = await HealthMobileOperaters.TlgChinaWebServiceOperater.GetDDUserInfoAsync(query); if (res.HasErr) { result.SetInfo(res.ErrMsg, res.ErrCode); } else { if (string.IsNullOrEmpty(res.Data)) { result.SetInfo("获取钉钉用户信息失败", -102); } else { var userInfoVar = new DDUserInfoModel(); string json = ReplaceString(res.Data); string[] userArr = json.Split(','); for (int i = 0; i < userArr.Length; i++) { if (userArr[i].ToString().Contains("userid")) { string[] valueId = userArr[i].ToString().Split(':'); userInfoVar.useeid = valueId[1].ToString(); } if (userArr[i].ToString().Contains("jobnumber")) { string[] valueJobnumber = userArr[i].ToString().Split(':'); userInfoVar.jobnumber = valueJobnumber[1].ToString(); } if (userArr[i].ToString().Contains("name")) { string[] valueName = userArr[i].ToString().Split(':'); userInfoVar.name = valueName[1].ToString(); } } result.Data = userInfoVar; result.SetInfo(userInfoVar, "获取成功", 200); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <byte[]> > HealthContentExcelExportAllAsync(QueryData <HealthContentQuery> query) { var result = new ErrData <byte[]>(); var dt = DateTime.Now; var queryComm = new QueryData <HealthStaffQuery>() { Criteria = new HealthStaffQuery() { CommondLeaderNo = string.Empty, CommandLeader = string.Empty } }; var comm = await HealthPcOperaters.HealthContentOperater.GetHealthStaffCommandAllAsync(queryComm); if (comm.HasErr) { result.SetInfo(comm.ErrMsg, comm.ErrCode); } else { var dicTable = new Dictionary <string, DataTable>(); foreach (var item in comm.Data) { var queryEx = query.Criteria; queryEx.CommondLeaderNo = item.CommondLeaderNo; query.Criteria = queryEx; var dtComm = await GetHealthContentAllAsync(query); if (dtComm.HasErr) { result.SetInfo(dtComm.Msg, dtComm.Code); return(result); } else { if (!dicTable.ContainsKey(item.CommandLeader)) { dicTable.Add(item.CommandLeader, dtComm.Results[0]); } } } result.Data = EPPlusHelper.ExcelExport(dicTable); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 根据HR负责人作为sheet导出 /// </summary> /// <param name="loginUser"></param> /// <param name="query"></param> /// <returns></returns> private async Task <ErrData <byte[]> > HealthContentExcelExportByHrAllAsync(IHealthUser loginUser, QueryData <HealthContentQuery> query) { var result = new ErrData <byte[]>(); var dt = DateTime.Now; var queryHr = new QueryData <HealthStaffQuery>() { Criteria = new HealthStaffQuery() { HrLeaderNo = loginUser.IsAdmin ? string.Empty : loginUser.UserNo, HrLeader = string.Empty } }; var comm = await HealthPcOperaters.HealthContentOperater.GetHealthStaffHrAllAsync(queryHr); if (comm.HasErr) { result.SetInfo(comm.ErrMsg, comm.ErrCode); } else { var dicTable = new Dictionary <string, DataTable>(); foreach (var item in comm.Data) { var queryEx = query.Criteria; queryEx.HrLeaderNo = item.HrLeaderNo; query.Criteria = queryEx; var dtHr = await GetHealthContentHrAllAsync(query); if (dtHr.HasErr) { result.SetInfo(dtHr.Msg, dtHr.Code); return(result); } else { if (!dicTable.ContainsKey(item.HrLeader)) { dicTable.Add(item.HrLeader, dtHr.Results[0]); } } } result.Data = EPPlusHelper.ExcelExport(dicTable); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > GroupUserSaveOrUpdateAsync(QueryData <SysGroupUserParams> param) { var result = new ErrData <bool>(); var dt = DateTime.Now; var lstInfo = new List <ISysGroupUserModel>(); foreach (var item in param.Criteria.LstGroupUser) { if (item.GroupMaster)//组织总负责人只能有一个 { lstInfo.ForEach(p => p.GroupMaster = false); } var info = IoCContainer.Resolve <ISysGroupUserModel>(); info.GroupNo = param.Criteria.GroupNo; info.UserNo = item.UserNo; info.UserName = item.UserName; info.GroupMaster = item.GroupMaster; info.GroupManager = item.GroupManager; info.Creator = param.Extend.UserNo; info.CreateName = param.Extend.UserName; info.CreateTime = dt; lstInfo.Add(info); } var query = new QueryData <SysGroupUserSaveOrUpdateQuery>() { Criteria = new SysGroupUserSaveOrUpdateQuery() { GroupNo = param.Criteria.GroupNo, CompanyNo = param.Criteria.CompanyNo, LstGroupUser = lstInfo } }; var res = await _service.GroupUserSaveOrUpdateAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "更新组织用户成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ActionResult> Login(LoginViewModel model) { var result = new ErrData <string>(); var query = new QueryData <SysUserQuery>() { Criteria = new SysUserQuery() { UserName = model.UserName, StaffNo = model.StaffNo, AdAccount = model.AdAccount, Mobile = model.Mobile, Email = model.Email, Pwd = model.Password } }; var res = await _manager.LoginAsync(query); if (res.HasErr) { result.SetInfo(res.Msg, res.Code); } else { var user = new LoginUser(); user.UserNo = res.Data.UserNo; user.UserName = res.Data.UserName; user.RealName = res.Data.RealName; user.StaffNo = res.Data.StaffNo; user.AdAccount = res.Data.AdAccount; user.Mobile = res.Data.Mobile; user.Email = res.Data.Email; user.IsAdmin = res.Data.IsAdmin; user.AppNo = model.AppNo; var claimsIdentity = _jwtFactory.GenerateClaimsIdentity(user); var tokenJson = await _jwtFactory.GenerateEncodedToken(user.UserNo, claimsIdentity); var token = JsonConvert.DeserializeObject <TokenModel>(tokenJson); result.SetInfo(token.auth_token, "登录成功!", 200); } result.ExpandSeconds = res.ExpandSeconds; return(Ok(result)); }
public async Task <ErrData <IHealthUser> > HealthUserLoginAsync(QueryData <HealthUserQuery> query) { var result = new ErrData <IHealthUser>(); var dt = DateTime.Now; var res = await HealthPcOperaters.HealthAccountOperater.GetHealthUserPageAsync(query); if (res.HasErr) { result.SetInfo(res.ErrMsg, res.ErrCode); } else { if (res.Data.Count <= 0) { result.SetInfo("账号无权限,请联系管理员。", -102); } else { var queryEx = new QueryData <WcfADUserGuidQuery>() { Criteria = new WcfADUserGuidQuery() { UserName = query.Criteria.AdAccount, Password = query.Criteria.Pwd } }; var resGuid = await WCFOperators.TlgChinaOperater.GetUserADGuidAsync(queryEx); if (string.IsNullOrEmpty(resGuid.Data)) { result.SetInfo("用户名或密码错误!", -102); } else { var userModel = res.Data.FirstOrDefault(); result.SetInfo(userModel, "登录成功!", 200); } } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > HealthTitleDeleteAsync(QueryData <HealthTitleDeleteQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; var res = await HealthPcOperaters.HealthTitleOperater.HealthTitleDeleteAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "删除数据成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > AppDeleteAsync(QueryData <SysAppDeleteQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; var res = await _service.AppDeleteAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "删除成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 异常错误信息捕获,将错误信息用Json方式返回 /// </summary> /// <param name="context"></param> /// <param name="statusCode"></param> /// <param name="msg"></param> /// <returns></returns> private static Task HandleExceptionAsync(HttpContext context, int statusCode, string msg) { var err = new ErrData <bool>(); err.SetInfo(false, msg, statusCode); var result = JsonConvert.SerializeObject(err); context.Response.ContentType = "application/json;charset=utf-8"; return(context.Response.WriteAsync(result)); }
public async Task <ErrData <bool> > HealthUserStaffSaveAsync(QueryData <HealthUserStaffModel> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; if (string.IsNullOrEmpty(query.Criteria.UserNo) || query.Criteria.LstStaffNo.Count <= 0) { result.SetInfo(false, "填写信息不完整!", -102); } else { var lstUserStaff = new List <IHealthUserStaff>(); foreach (var staffNo in query.Criteria.LstStaffNo) { var info = HealthPcOperaters.HealthAccountOperater.NewHealthUserStaff(); info.UserNo = query.Criteria.UserNo; info.StaffNo = staffNo; info.Creator = query.Extend.UserNo; info.CreateName = query.Extend.UserName; lstUserStaff.Add(info); } var queryEx = new QueryData <HealthUserStaffSaveQuery>() { Criteria = new HealthUserStaffSaveQuery() { LstUserStaff = lstUserStaff } }; var res = await HealthPcOperaters.HealthAccountOperater.HealthUserStaffSaveAsync(queryEx); if (res.HasErr) { result.SetInfo(res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "保存成功。", 200); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > UserRoleSaveOrUpdateAsync(QueryData <SysUserRoleParams> param) { var result = new ErrData <bool>(); var dt = DateTime.Now; var lstInfo = new List <ISysUserRoleModel>(); foreach (var item in param.Criteria.LstUserRole) { var info = IoCContainer.Resolve <ISysUserRoleModel>(); info.UserNo = param.Criteria.UserNo; info.RoleNo = item.RoleNo; info.RoleName = item.RoleName; info.Creator = param.Extend.UserNo; info.CreateName = param.Extend.UserName; info.CreateTime = dt; lstInfo.Add(info); } var query = new QueryData <SysUserRoleSaveOrUpdateQuery>() { Criteria = new SysUserRoleSaveOrUpdateQuery() { UserNo = param.Criteria.UserNo, AppNo = param.Criteria.AppNo, LstUserRole = lstInfo } }; var res = await _service.UserRoleSaveOrUpdateAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "更新用户角色成功!", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 根据工号获取人员信息 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <ErrData <HealthStaff> > GetHealthStaffInfoAsync(QueryData <GetHealthStaffInfoQuery> query) { var result = new ErrData <HealthStaff>(); HealthStaff healthStaff = null; var dt = DateTime.Now; var res = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(query); if (res.HasErr) { result.SetInfo(res.ErrMsg, res.ErrCode); } else { if (res.Data.Count > 0) { healthStaff = new HealthStaff(); healthStaff.AggLeader = res.Data[0].AggLeader; healthStaff.AggLeaderNo = res.Data[0].AggLeaderNo; healthStaff.CommandLeader = res.Data[0].CommandLeader; healthStaff.CommondLeaderNo = res.Data[0].CommondLeaderNo; healthStaff.GroupLeader = res.Data[0].GroupLeader; healthStaff.GroupLeaderNo = res.Data[0].GroupLeaderNo; healthStaff.GroupType = res.Data[0].GroupType; healthStaff.HrLeader = res.Data[0].HrLeader; healthStaff.HrLeaderNo = res.Data[0].HrLeaderNo; healthStaff.Id = res.Data[0].Id; healthStaff.StaffName = res.Data[0].StaffName; healthStaff.StaffNo = res.Data[0].StaffNo; } result.Data = healthStaff; result.SetInfo(healthStaff, "获取成功", 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <byte[]> > HealthContentExcelExportAsync(QueryData <HealthContentQuery> query) { var result = new ErrData <byte[]>(); var dt = DateTime.Now; var table = await GetHealthContentPageAsyncEx(query); if (table.HasErr) { result.SetInfo(table.Msg, table.Code); } else { result.Data = EPPlusHelper.ExcelExport("体检表", table.Results[0]); if (result.Data == null || result.Data.Length == 0) { result.SetInfo("无数据导出!", -102); } } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <IActionResult> HealthLogin(HealthLoginViewModel model) { var result = new ErrData <string>(); var query = new QueryData <HealthUserQuery>() { Criteria = new HealthUserQuery() { AdAccount = model.UserName, Pwd = model.Password } }; var res = await _manager.HealthUserLoginExAsync(query); if (res.HasErr) { result.SetInfo(res.Msg, res.Code); } else { var user = new LoginUser(); user.UserNo = res.Data.UserNo; user.UserName = res.Data.UserName; user.AdAccount = res.Data.AdAccount; user.IsAdmin = res.Data.IsAdmin; var claimsIdentity = _jwtFactory.GenerateClaimsIdentity(user); var tokenJson = await _jwtFactory.GenerateEncodedToken(user.UserNo, claimsIdentity); var token = JsonConvert.DeserializeObject <TokenModel>(tokenJson); result.SetInfo(token.auth_token, "成功", 200); } return(Ok(result)); }
public async Task <ErrData <bool> > HealthStaffImportAsync(QueryData <Stream> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; if (query.Criteria == null) { result.SetInfo("请先选择防疫信息表!", -102); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } //将Excel转换成DataTable var tables = EPPlusHelper.ExcelImport(query.Criteria, 2); if (tables == null) { result.SetInfo("防疫信息表有误,请检查!", -102); } else { #region 组装员工资料、组长权限、集合组长权限、HR负责人权限 var lstStaff = new List <IHealthStaff>(); var lstGroupStaff = new List <IHealthUserStaff>(); var lstAggStaff = new List <IHealthUserStaff>(); var lstHrStaff = new List <IHealthUserStaff>(); foreach (var table in tables) { if (table != null && table.Rows.Count > 0) { foreach (DataRow row in table.Rows) { //员工资料 var staff = HealthPcOperaters.HealthAccountOperater.NewHealthStaff();//存入health_staff staff.StaffNo = row[2].ToString(); staff.StaffName = row[3].ToString(); staff.GroupType = row[4].ToString(); staff.GroupLeader = row[5].ToString(); staff.GroupLeaderNo = row[6].ToString(); staff.AggLeader = row[7].ToString(); staff.AggLeaderNo = row[8].ToString(); staff.CommandLeader = row[9].ToString(); staff.CommondLeaderNo = row[10].ToString(); staff.HrLeader = row[11].ToString(); staff.HrLeaderNo = row[12].ToString(); lstStaff.Add(staff); //组长权限 var groupStaff = HealthPcOperaters.HealthAccountOperater.NewHealthUserStaff();//存入health_user_staff groupStaff.UserNo = row[6].ToString(); groupStaff.StaffNo = row[2].ToString(); groupStaff.Creator = query.Extend.UserNo; groupStaff.CreateName = query.Extend.UserName; lstGroupStaff.Add(groupStaff); //集合组长权限 var aggStaff = HealthPcOperaters.HealthAccountOperater.NewHealthUserStaff();//存入health_user_staff aggStaff.UserNo = row[8].ToString(); aggStaff.StaffNo = row[2].ToString(); aggStaff.Creator = query.Extend.UserNo; aggStaff.CreateName = query.Extend.UserName; lstAggStaff.Add(aggStaff); //HR负责人权限 var hrStaff = HealthPcOperaters.HealthAccountOperater.NewHealthUserStaff();//存入health_user_staff hrStaff.UserNo = row[12].ToString(); hrStaff.StaffNo = row[2].ToString(); hrStaff.Creator = query.Extend.UserNo; hrStaff.CreateName = query.Extend.UserName; lstHrStaff.Add(hrStaff); } } } #endregion #region 数据库操作 if (lstStaff.Count > 0 && lstGroupStaff.Count > 0 && lstAggStaff.Count > 0 && lstHrStaff.Count > 0) { var queryEx = new QueryData <HealthStaffImportQuery>() { Criteria = new HealthStaffImportQuery() { LstStaff = lstStaff, LstGroupStaff = lstGroupStaff, LstAggStaff = lstAggStaff, LstHrStaff = lstHrStaff } }; var res = await HealthPcOperaters.HealthAccountOperater.HealthStaffImportAsync(queryEx); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, "导入成功!", 200); } } else { result.SetInfo("防疫信息表数据不完整,请检查!", -102); } #endregion } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <byte[]> > HealthContentExcelExportUserStaffAdAllAsync(QueryData <HealthContentQuery> query) { var result = new ErrData <byte[]>(); var dt = DateTime.Now; IHealthUser loginUser = new HealthUser(); #region 验证AD账号是否已添加权限 var queryUser = new QueryData <HealthUserQuery>() { Criteria = new HealthUserQuery() { AdAccount = query.Extend.UserNo } }; var healthUser = await HealthPcOperaters.HealthAccountOperater.GetHealthUserPageAsync(queryUser);//根据health_user判断是否管理员 if (healthUser.HasErr) { result.SetInfo(healthUser.ErrMsg, healthUser.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } var queryAd = new QueryData <WcfADUserInfoQuery>() { Criteria = new WcfADUserInfoQuery() { UserName = query.Extend.UserNo, Password = query.Extend.Pwd } }; var resUser = await WCFOperators.TlgChinaOperater.GetADUserInfoAsync(queryAd);//根据wcf获取账号信息 if (resUser.HasErr) { result.SetInfo(resUser.ErrMsg, resUser.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } else { if (string.IsNullOrEmpty(resUser.Data?.UserNo)) { result.SetInfo("用户名或密码错误!", -102); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } loginUser.UserNo = resUser.Data.UserNo; loginUser.UserName = resUser.Data.UserName; loginUser.AdAccount = resUser.Data.ADAccount; loginUser.IsAdmin = false; if (healthUser.Data.Count > 0) { loginUser.IsAdmin = healthUser.Data.FirstOrDefault().IsAdmin; } } #endregion if (loginUser.IsAdmin)//登录账号为管理员时,根据HR负责人作为sheet导出 { result = await HealthContentExcelExportByHrAllAsync(loginUser, query); } else//登录账号为非管理员时,登陆人作为sheet导出其权限下体检内容 { var dicTable = new Dictionary <string, DataTable>(); var queryEx = query.Criteria; queryEx.UpStaffNo = loginUser.IsAdmin ? string.Empty : loginUser.UserNo; query.Criteria = queryEx; var dtUserStaff = await GetHealthContentUserStaffAllAsync(query); if (dtUserStaff.HasErr) { result.SetInfo(dtUserStaff.Msg, dtUserStaff.Code); return(result); } else { dicTable.Add(loginUser.UserName, dtUserStaff.Results[0]); } result.Data = EPPlusHelper.ExcelExport(dicTable); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
public async Task <ErrData <bool> > UserSaveOrUpdateAsync(QueryData <SysUserSaveOrUpdateQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; #region 验证输入合法性 if (query.Criteria.IsAdmin && !query.Extend.IsAdmin) { result.SetInfo(false, "您无权限设置管理员账号信息!", -201); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } if (string.IsNullOrEmpty(query.Criteria.CompanyNo)) { if (!string.IsNullOrEmpty(query.Criteria.StaffNo)) { result.SetInfo(false, "工号不为空时,请先选择所属公司!", -201); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } if (!string.IsNullOrEmpty(query.Criteria.AdAccount)) { result.SetInfo(false, "AD账号不为空时,请先选择所属公司!", -201); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } } if (query.Criteria.Access && string.IsNullOrEmpty(query.Criteria.Descr)) { result.SetInfo(false, "设置账户为有效时,请输入审批描述!", -201); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } if (!query.Criteria.Access && string.IsNullOrEmpty(query.Criteria.RejectedReason)) { result.SetInfo(false, "设置账户为无效时,请输入拒绝理由!", -201); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } #endregion query.Criteria.Creator = query.Extend.UserNo; query.Criteria.CreateName = query.Extend.UserName; query.Criteria.CreateTime = DateTime.Now; query.Criteria.Updator = query.Extend.UserNo; query.Criteria.UpdateName = query.Extend.UserName; query.Criteria.UpdateTime = DateTime.Now; query.Criteria.RegisterTime = DateTime.Now; if (!string.IsNullOrEmpty(query.Criteria.Descr)) { query.Criteria.ApprovedBy = query.Extend.UserNo; query.Criteria.ApprovedName = query.Extend.UserName; query.Criteria.ApprovedTime = DateTime.Now; } if (!string.IsNullOrEmpty(query.Criteria.RejectedReason)) { query.Criteria.RejectedBy = query.Extend.UserNo; query.Criteria.RejectedName = query.Extend.UserName; query.Criteria.RejectedTime = DateTime.Now; } var res = await _service.UserSaveOrUpdateAsync(query); if (res.HasErr) { result.SetInfo(false, res.ErrMsg, res.ErrCode); } else { result.SetInfo(true, res.ErrMsg, 200); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 根据工号和日期获取体检填写详细 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <ErrData <List <Health_content_DetailModel> > > GetHealthContentDetailInfoAsync(QueryData <HealthStaffCountQuery_Model> query) { var result = new ErrData <List <Health_content_DetailModel> >(); var dt = DateTime.Now; List <Health_content_DetailModel> content_DetailModels = new List <Health_content_DetailModel>();; try { GetHealthStaffCountQuery countQuery = new GetHealthStaffCountQuery(); countQuery.date = query.Criteria.date; countQuery.userNo = query.Criteria.userNo; var queryDetail = new QueryData <GetHealthStaffCountQuery>(); queryDetail.Criteria = countQuery; var res = await HealthMobileOperaters.HealthContentOperater.GetHealthContentDetailsInfoByNoAndDate(queryDetail); if (res.HasErr) { result.SetInfo(content_DetailModels, res.ErrMsg, res.ErrCode); } else { if (res.Data.Count > 0) { //content_DetailModels = new List<Health_content_DetailModel>(); foreach (var item in res.Data) { if (!string.IsNullOrEmpty(item.Answer)) { string[] AnswerArr = item.Answer.Split(';'); if (AnswerArr.Length > 0) { for (int i = 0; i < AnswerArr.Length; i++) { string[] cont = AnswerArr[i].Split(':'); Health_content_DetailModel health_Content_Detail = new Health_content_DetailModel(); if (string.IsNullOrEmpty(cont[0])) { health_Content_Detail.Content = ""; continue; } else { health_Content_Detail.Content = cont[0]; } if (string.IsNullOrEmpty(cont[1])) { health_Content_Detail.Answer = ""; } else { health_Content_Detail.Answer = cont[1]; } health_Content_Detail.ContentId = item.ContentId; health_Content_Detail.CreateName = item.CreateName; health_Content_Detail.CreateTime = item.CreateTime; health_Content_Detail.Creator = item.Creator; health_Content_Detail.titleId = item.TitleId; health_Content_Detail.TitleType = item.TitleType; content_DetailModels.Add(health_Content_Detail); } } } } } result.Data = content_DetailModels; result.SetInfo(content_DetailModels, "成功", 200); } } catch (Exception ex) { result.SetInfo(ex.ToString(), -500); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 提交体检内容详细信息 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <ErrData <ReturnToFactoryStartModel> > InsertHealthContentMaAsync(QueryData <Health_content_Model> query) { var result = new ErrData <ReturnToFactoryStartModel>(); var dt = DateTime.Now; ReturnToFactoryStartModel returnToFactoryStart = new ReturnToFactoryStartModel();; try { InsertHealthContentQuery contentQuery = new InsertHealthContentQuery(); contentQuery.Answer = query.Criteria.Answer; contentQuery.ContentId = query.Criteria.ContentId; contentQuery.CreateName = query.Criteria.CreateName; contentQuery.CreateTime = query.Criteria.CreateTime; contentQuery.Creator = query.Criteria.Creator; contentQuery.titleId = query.Criteria.TitleId; contentQuery.TitleType = query.Criteria.TitleType; contentQuery.IsPass = query.Criteria.IsPass; contentQuery.NotPassReson = query.Criteria.NotPassReson; //返厂判断 if (query.Criteria.IsPass == true) { returnToFactoryStart.Start = "OK"; } else { returnToFactoryStart.Start = "NG"; } returnToFactoryStart.Massage = contentQuery.NotPassReson; //到组织结构表中验证工号的正确 GetHealthStaffInfoQuery staffInfoByNoQuery = new GetHealthStaffInfoQuery(); staffInfoByNoQuery.StaffNo = query.Criteria.Creator; staffInfoByNoQuery.StaffName = ""; var queryByNoYZ = new QueryData <GetHealthStaffInfoQuery>(); queryByNoYZ.Criteria = staffInfoByNoQuery; var resYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNoYZ); if (resYZ.HasErr) { result.SetInfo(returnToFactoryStart, "通过工号验证工号是否归属组织表失败", resYZ.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } else { if (resYZ.Data == null || resYZ.Data.Count == 0) { //如果通过工号查询不到就用姓名查询 GetHealthStaffInfoQuery staffInfoByNameQuery = new GetHealthStaffInfoQuery(); staffInfoByNameQuery.StaffNo = ""; staffInfoByNameQuery.StaffName = query.Criteria.CreateName; var queryByNameYZ = new QueryData <GetHealthStaffInfoQuery>(); queryByNameYZ.Criteria = staffInfoByNameQuery; var resNameYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNameYZ); if (resNameYZ.HasErr) { result.SetInfo(returnToFactoryStart, "通过姓名验证工号是否归属组织表失败", resYZ.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } else { //工号姓名都没有查到 if (resNameYZ.Data == null || resNameYZ.Data.Count == 0) { result.SetInfo(returnToFactoryStart, "未查询到工号:" + query.Criteria.Creator + "组织人员信息,请找当地HR确认", -111); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } //通过姓名查询到了 else { result.SetInfo(returnToFactoryStart, "工号:" + query.Criteria.Creator + "异常,请联系HR:" + resNameYZ.Data[0].HrLeader, -111); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } } } } //保存体检填写内容 var queryXQ = new QueryData <InsertHealthContentQuery>(); queryXQ.Criteria = contentQuery; var res = await HealthMobileOperaters.HealthContentOperater.InsertHealthContent(queryXQ); if (res.HasErr) { result.SetInfo(returnToFactoryStart, "体检详细信息提交失败", res.ErrCode); } else { result.Data = returnToFactoryStart; result.SetInfo(returnToFactoryStart, "成功", 200); } } catch (Exception ex) { result.SetInfo(ex.ToString(), -500); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 根据工号获取承诺书确认信息 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <ErrData <bool> > GetHealthPledgeByNoMaAsync(QueryData <GetHealthPledgeInfoQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; try { //到组织结构表中验证工号的正确 //GetHealthStaffInfoQuery staffInfoQuery = new GetHealthStaffInfoQuery(); //staffInfoQuery.StaffNo = query.Criteria.StaffNo; //var queryYZ = new QueryData<GetHealthStaffInfoQuery>(); //queryYZ.Criteria = staffInfoQuery; //var resYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryYZ); //if (resYZ.HasErr) //{ // result.SetInfo(false, "验证工号是否归属组织表失败", resYZ.ErrCode); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; //} //else //{ // if (resYZ.Data == null || resYZ.Data.Count == 0) // { // result.SetInfo(false, "未查询到工号:" + queryYZ.Criteria.StaffNo + "组织人员信息", -111); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; // } //} //---------------- //到组织结构表中验证工号的正确 //GetHealthStaffInfoQuery staffInfoByNoQuery = new GetHealthStaffInfoQuery(); //staffInfoByNoQuery.StaffNo = query.Criteria.StaffNo; //staffInfoByNoQuery.StaffName = ""; //var queryByNoYZ = new QueryData<GetHealthStaffInfoQuery>(); //queryByNoYZ.Criteria = staffInfoByNoQuery; //var resYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNoYZ); //if (resYZ.HasErr) //{ // result.SetInfo(false, "通过工号验证工号是否归属组织表失败", resYZ.ErrCode); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; //} //else //{ // if (resYZ.Data == null || resYZ.Data.Count == 0) // { // //如果通过工号查询不到就用姓名查询 // GetHealthStaffInfoQuery staffInfoByNameQuery = new GetHealthStaffInfoQuery(); // staffInfoByNameQuery.StaffNo = ""; // staffInfoByNameQuery.StaffName = query.Criteria.StaffName; // var queryByNameYZ = new QueryData<GetHealthStaffInfoQuery>(); // queryByNameYZ.Criteria = staffInfoByNameQuery; // var resNameYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNameYZ); // if (resNameYZ.HasErr) // { // result.SetInfo(false, "通过姓名验证工号是否归属组织表失败", resYZ.ErrCode); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; // } // else // { // //工号姓名都没有查到 // if (resNameYZ.Data == null || resNameYZ.Data.Count == 0) // { // result.SetInfo(false, "未查询到工号:" + query.Criteria.StaffNo + "组织人员信息,请找当地HR确认", -111); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; // } // //通过姓名查询到了 // else // { // result.SetInfo(false, "工号:" + query.Criteria.StaffNo + "异常,请联系HR:" + resNameYZ.Data[0].HrLeader, -111); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; // } // } // } //} //var pledgeInfoQuery = new GetHealthPledgeInfoQuery(); //pledgeInfoQuery.StaffNo = query.Criteria.StaffNo; //var queryCN = new QueryData<GetHealthPledgeInfoQuery>(); //queryCN.Criteria = pledgeInfoQuery; //var res = await HealthMobileOperaters.Health_pledgeServiceOperater.GetHealthPledgeInfo(queryCN); //if (res.HasErr) //{ // result.SetInfo(false, "承诺书确认提交失败", res.ErrCode); //} //else //{ // //如果根据工号查询到确认承诺书记录返回true,代表已阅读并且已经提交 // if (res.Data.Count > 0) // { // result.SetInfo(true, "承诺书已确认", 200); // } // else // { // result.SetInfo(false, "承诺书未确认", -101); // } //} result.SetInfo(true, "承诺书已确认", 200); } catch (Exception ex) { result.SetInfo(ex.ToString(), -500); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }
/// <summary> /// 保存确认承诺书 /// </summary> /// <param name="query"></param> /// <returns></returns> public async Task <ErrData <bool> > InsertHealthPledgeInfoMaAsync(QueryData <InsertHealthPledgeInfoQuery> query) { var result = new ErrData <bool>(); var dt = DateTime.Now; try { //到组织结构表中验证工号的正确 //GetHealthStaffInfoQuery staffInfoQuery = new GetHealthStaffInfoQuery(); //staffInfoQuery.StaffNo = query.Criteria.StaffNo; //var queryYZ = new QueryData<GetHealthStaffInfoQuery>(); //queryYZ.Criteria = staffInfoQuery; //var resYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryYZ); //if (resYZ.HasErr) //{ // result.SetInfo(false, "验证工号是否归属组织表失败", resYZ.ErrCode); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; //} //else //{ // if (resYZ.Data == null || resYZ.Data.Count == 0) // { // result.SetInfo(false, "未查询到工号:" + queryYZ.Criteria.StaffNo + "组织人员信息", -111); // result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; // return result; // } //} //到组织结构表中验证工号的正确 GetHealthStaffInfoQuery staffInfoByNoQuery = new GetHealthStaffInfoQuery(); staffInfoByNoQuery.StaffNo = query.Criteria.StaffNo; staffInfoByNoQuery.StaffName = ""; var queryByNoYZ = new QueryData <GetHealthStaffInfoQuery>(); queryByNoYZ.Criteria = staffInfoByNoQuery; var resYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNoYZ); if (resYZ.HasErr) { result.SetInfo(false, "通过工号验证工号是否归属组织表失败", resYZ.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } else { if (resYZ.Data == null || resYZ.Data.Count == 0) { //如果通过工号查询不到就用姓名查询 GetHealthStaffInfoQuery staffInfoByNameQuery = new GetHealthStaffInfoQuery(); staffInfoByNameQuery.StaffNo = ""; staffInfoByNameQuery.StaffName = query.Criteria.StaffName; var queryByNameYZ = new QueryData <GetHealthStaffInfoQuery>(); queryByNameYZ.Criteria = staffInfoByNameQuery; var resNameYZ = await HealthMobileOperaters.Health_staffServiceOperater.GetHealthStaffInfo(queryByNameYZ); if (resNameYZ.HasErr) { result.SetInfo(false, "通过姓名验证工号是否归属组织表失败", resYZ.ErrCode); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } else { //工号姓名都没有查到 if (resNameYZ.Data == null || resNameYZ.Data.Count == 0) { result.SetInfo(false, "未查询到工号:" + query.Criteria.StaffNo + "组织人员信息,请找当地HR确认", -111); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } //通过姓名查询到了 else { result.SetInfo(false, "工号:" + query.Criteria.StaffNo + "异常,请联系HR:" + resNameYZ.Data[0].HrLeader, -111); result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); } } } } var pledgeInfoAddQuery = new InsertHealthPledgeInfoQuery(); pledgeInfoAddQuery.StaffNo = query.Criteria.StaffNo; pledgeInfoAddQuery.IsSign = query.Criteria.IsSign; pledgeInfoAddQuery.PledgeType = query.Criteria.PledgeType; pledgeInfoAddQuery.SignTime = query.Criteria.SignTime; pledgeInfoAddQuery.StaffName = query.Criteria.StaffName; var queryCN = new QueryData <InsertHealthPledgeInfoQuery>(); queryCN.Criteria = pledgeInfoAddQuery; var res = await HealthMobileOperaters.Health_pledgeServiceOperater.InsertHealthPledgeInfo(queryCN); if (res.HasErr) { result.SetInfo(false, "保存确认承诺书失败", res.ErrCode); } else { result.SetInfo(true, "成功", 200); } } catch (Exception ex) { result.SetInfo(ex.ToString(), -500); } result.ExpandSeconds = (DateTime.Now - dt).TotalSeconds; return(result); }