You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2851 lines
127 KiB
2851 lines
127 KiB
using Newtonsoft.Json;
|
|
using Spire.Xls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class SysEmpHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL();
|
|
|
|
public class ReturnInfo
|
|
{
|
|
public string code { get; set; }
|
|
public string msg { get; set; }
|
|
public string count { get; set; }
|
|
public string[] data { get; set; }
|
|
}
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "人员操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "OrgDeptTree"://机构树
|
|
returnstr = getOrgTree(context);
|
|
break;
|
|
case "OrgDeptEmpTree"://机构树(包含人员)
|
|
returnstr = OrgDeptEmpTree(context);
|
|
break;
|
|
case "OrgDeptTree2"://机构-部门树(包含父级机构下属消防站)
|
|
returnstr = getOrgStaTree(context);
|
|
break;
|
|
case "getOrgOnlyTree"://机构及所有下属机构)
|
|
returnstr = getOrgOnlyTree(context);
|
|
break;
|
|
case "getOrgDeptTree"://机构-部门树(包含所在机构下部门)
|
|
returnstr = getOrgDeptTree(context);
|
|
break;
|
|
case "getUseruId":
|
|
returnstr = GetUseruId(context);
|
|
break;
|
|
case "OrgEmpList":
|
|
returnstr = GetOrgEmpList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddOrgEmp(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditOrgEmp(context);
|
|
break;
|
|
case "EditInfo":
|
|
returnstr = EditInfo(context);
|
|
break;
|
|
//批量删除
|
|
case "Del":
|
|
returnstr = DelOrgEmp(context);
|
|
break;
|
|
//恢复删除
|
|
case "ClearDel":
|
|
returnstr = ClearDel(context);
|
|
break;
|
|
//人员退出
|
|
case "ExitEmp":
|
|
returnstr = ExitEmp(context);
|
|
break;
|
|
|
|
case "ResetPwd":
|
|
returnstr = ResetPwd(context);
|
|
break;
|
|
case "getUserByUId":
|
|
returnstr = getUserByUId(context);
|
|
break;
|
|
case "impExcel":
|
|
returnstr = impExcel(context);
|
|
break;
|
|
case "expExcel":
|
|
expExcel(context);
|
|
break;
|
|
case "getEmpTreeByorgid":
|
|
returnstr = getEmpTreeByorgid(context);
|
|
break;
|
|
case "personSta":
|
|
returnstr = personSta(context);
|
|
break;
|
|
case "personStaAll":
|
|
returnstr = personStaAll(context);
|
|
break;
|
|
case "personStrengthSta":
|
|
returnstr = personStrengthSta(context);
|
|
break;
|
|
case "GetEmpList":
|
|
returnstr = GetEmpList(context);
|
|
break;
|
|
case "GetEmpByUID":
|
|
returnstr = GetEmpByUID(context);
|
|
break;
|
|
case "Distribute":
|
|
returnstr = Distribute(context);
|
|
break;
|
|
case "getEmpNum":
|
|
returnstr = getEmpNum(context);
|
|
break;
|
|
case "getOrgEmpGroupSelectByOrgId":
|
|
returnstr = getOrgEmpGroupSelectByOrgId(context);
|
|
break;
|
|
case "personSta2":
|
|
returnstr = personSta2(context);
|
|
break;
|
|
case "personSta3": // 人员实力——手机端
|
|
returnstr = personSta3(context);
|
|
break;
|
|
|
|
case "getOrgTreeList3":
|
|
returnstr = getOrgTreeList3(context);
|
|
break;
|
|
case "GetHealthUserInfoByUid":
|
|
returnstr = GetHealthUserInfoByUid(context);
|
|
break;
|
|
case "getEmpListByOrgId":
|
|
returnstr = getEmpListByOrgId(context);
|
|
break;
|
|
case "homePageLeaveTolerance":
|
|
returnstr = homePageLeaveTolerance(context);
|
|
break;
|
|
case "getOrgCityOnlyTree"://机构及所有下属机构(包含行政区划编码)
|
|
returnstr = getOrgCityOnlyTree(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
|
|
|
|
//机构树
|
|
private string getOrgTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgAndDeptTree(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构树异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构树");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
|
|
//机构树(包含人员)
|
|
private string OrgDeptEmpTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
//DataTable orgdata = bll.getOrgAndDeptTree(orgId);
|
|
//string orgIds = "";
|
|
//for (int i=0;i< orgdata.Rows.Count;i++)
|
|
//{
|
|
// if (i == 0)
|
|
// {
|
|
// orgIds = "'" + orgdata.Rows[i]["id"].ToString() + "'";
|
|
// }
|
|
// else
|
|
// {
|
|
// orgIds += ",'" + orgdata.Rows[i]["id"].ToString() + "'";
|
|
// }
|
|
//}
|
|
DataTable data = bll.getOrgAndDeptAndEmpTree(orgId);
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构树(包含人员)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构树(包含人员)");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
|
|
//机构-部门树(包含父级机构下属消防站)
|
|
private string getOrgStaTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgTree2(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构-部门树(包含父级机构下属消防站)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构-部门树(包含父级机构下属消防站)");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//机构-部门树(包含所在机构下部门)
|
|
private string getOrgDeptTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgDeptTree(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构-部门树(包含所在机构下部门)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构-部门树(包含所在机构下部门)");
|
|
return returnstr;
|
|
}
|
|
|
|
//获取机构及所有下属机构(只有机构)
|
|
private string getOrgOnlyTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgOnlyTree(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "获取机构及所有下属机构(只有机构)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "获取机构及所有下属机构(只有机构)");
|
|
return returnstr;
|
|
}
|
|
|
|
//获取可以绑定的登录账号
|
|
private string GetUseruId(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string usersUid = context.Request.Params["usersUid"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getUseruId(orgId, usersUid);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "获取可以绑定的登录账号异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "获取可以绑定的登录账号");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//查询
|
|
private string GetOrgEmpList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string OrgList = context.Request.Params["OrgList"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string is_work = context.Request.Params["is_work"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string is_manage_cadre = context.Request.Params["is_manage_cadre"];
|
|
string pol = context.Request.Params["pol"];
|
|
string face = context.Request.Params["face"];
|
|
string cert = context.Request.Params["cert"];
|
|
string nation = context.Request.Params["nation"];
|
|
string prof = context.Request.Params["prof"];
|
|
|
|
//是否查询包含管理员账号数据
|
|
string is_admin = context.Request.Params["is_admin"];
|
|
//是否查询删除人员数据
|
|
string is_DelQueyr = context.Request.Params["is_DelQueyr"] + "";
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = null;
|
|
string pOrgID = "";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
pOrgID = treeID;
|
|
if (is_content == "1")
|
|
{
|
|
where = "( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = "( ORG_ID = '" + treeID + "' )";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
pOrgID = OrgId;
|
|
if (is_content == "1")
|
|
{
|
|
where = "( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = "( ORG_ID = '" + OrgId + "' )";
|
|
}
|
|
|
|
}
|
|
//or DEPT_ID = '" + OrgId + "'
|
|
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " DEPT_ID = '" + selDeptId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( emp_name like '%" + keyword + "%' or EMP_MOBILE like '%" + keyword + "%')";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchTime))
|
|
{
|
|
string startTime = "", endTime = "";
|
|
if (searchTime.IndexOf(" - ") != -1)
|
|
{
|
|
startTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[0];
|
|
endTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[1];
|
|
}
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "ENLISTED_TIME >= '" + startTime + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "ENLISTED_TIME <= '" + endTime + "'";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(is_work))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
|
|
if (is_work == "1")
|
|
{
|
|
where += " is_work = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " is_work != '1'";
|
|
}
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(is_admin))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
|
|
if (is_admin == "1")
|
|
{
|
|
where += " is_admin = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " (is_admin != '1' or is_admin is null)";
|
|
}
|
|
}
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and DEPT_ID='" + DeptID + "' ";
|
|
}
|
|
}
|
|
|
|
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
if (string.IsNullOrWhiteSpace(is_DelQueyr))
|
|
{
|
|
where += " is_del = '0'";
|
|
}
|
|
else
|
|
{
|
|
if (is_DelQueyr == "1")
|
|
{
|
|
where += " is_del = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " is_del = '0'";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(is_manage_cadre))
|
|
{
|
|
|
|
if (is_admin != "1" && is_manage_cadre == "0")
|
|
{
|
|
where += " and prof='-1' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "1")
|
|
{
|
|
where += " and prof='15' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "2")
|
|
{
|
|
where += " and prof!='15' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "3")
|
|
{
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(pol))
|
|
{
|
|
where += " and pol='" + pol + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(face))
|
|
{
|
|
where += " and face='" + face + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(cert))
|
|
{
|
|
where += " and cert='" + cert + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(nation))
|
|
{
|
|
where += " and nation='" + nation + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(prof))
|
|
{
|
|
where += " and prof='" + prof + "' ";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where, pOrgID);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
//List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.QueryList(pageIndex, pageSize, where, " (sort) desc , emp_num ");
|
|
List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.QueryList(pageIndex, pageSize, where, " sort desc, emp_num ", pOrgID);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加人员
|
|
private string AddOrgEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string usersUid = context.Request.Params["users_uid"];
|
|
string empName = context.Request.Params["emp_name"];
|
|
string empNum = context.Request.Params["emp_num"];
|
|
string empSex = context.Request.Params["emp_sex"];
|
|
string BLOOD_TYPE = context.Request.Params["BLOOD_TYPE"];
|
|
string orgId = context.Request.Params["org_id"];
|
|
string deptId = context.Request.Params["dept_id"];
|
|
string empEmail = context.Request.Params["emp_email"];
|
|
string empMobile = context.Request.Params["emp_mobile"];
|
|
string idnumber = context.Request.Params["idnumber"];
|
|
string birthday = context.Request.Params["birthday"];
|
|
string familyaddr = context.Request.Params["familyaddr"];
|
|
|
|
string cert = context.Request.Params["cert"];
|
|
string nation = context.Request.Params["nation"];
|
|
string face = context.Request.Params["face"];
|
|
string mar = context.Request.Params["mar"];
|
|
string isWork = context.Request.Params["is_work"];
|
|
string prof = context.Request.Params["prof"];
|
|
string tags = context.Request.Params["tags"];
|
|
string posts = context.Request.Params["posts"];
|
|
string pol = context.Request.Params["pol"];
|
|
string photo = context.Request.Params["photo"];
|
|
string isLeader = context.Request.Params["isLeader"];
|
|
string enlisted_time = context.Request.Params["enlisted_time"];
|
|
string is_access = context.Request.Params["is_access"];
|
|
string is_SubCampVideo = context.Request.Params["is_SubCampVideo"];
|
|
string AccessAllowedMode = context.Request.Params["AccessAllowedMode"];
|
|
string during_access_period = context.Request.Params["during_access_period"];
|
|
|
|
string isdriver = context.Request.Params["isdriver"];
|
|
string filenum = context.Request.Params["filenum"];
|
|
string permissionnum = context.Request.Params["permissionnum"];
|
|
string firstcard = context.Request.Params["firstcard"];
|
|
string effictivetime = context.Request.Params["effictivetime"];
|
|
string permittedorgan = context.Request.Params["permittedorgan"];
|
|
string ALL_ANNUAL_LEAVE = context.Request.Params["ALL_ANNUAL_LEAVE"];
|
|
string AVAILABLE_ANNUAL_LEAVE = context.Request.Params["AVAILABLE_ANNUAL_LEAVE"];
|
|
|
|
string IS_ADMIN = context.Request.Params["IS_ADMIN"] + "";
|
|
|
|
string strWhere = " EMP_NUM ='" + empNum + "' and ORG_ID ='" + orgId + "' and EMP_NUM is not null ";
|
|
|
|
string sql = " SELECT ID,EMP_NAME,USERS_UID,EMP_MOBILE,IDNUMBER,EMP_NUM from tbl_sys_emp WHERE USERS_UID='" + empMobile
|
|
+ "' or EMP_MOBILE='" + empMobile + "' or IDNUMBER ='" + idnumber + "' or (ORG_ID='" + orgId + "' and EMP_NUM ='" + empNum + "') ";
|
|
var dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
|
|
//获取是否存在现有人员编号重的情况
|
|
//int count = bll.GetRecordCount(" EMP_NUM ='" + empNum + "' and ORG_ID ='" + orgId + "' and EMP_NUM is not null and is_del='0' ");
|
|
int count = dt.Rows.Count;
|
|
if (count > 0)
|
|
{
|
|
//msg = "单位内编号重复,请修改后添加!";
|
|
|
|
msg = "重复信息:<br />";
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if ((dt.Rows[i]["USERS_UID"] + "").Trim() == empMobile)
|
|
{
|
|
msg += "已有账号与手机号重复;<br />";
|
|
}
|
|
if ((dt.Rows[i]["EMP_MOBILE"] + "").Trim() == empMobile)
|
|
{
|
|
msg += "手机号重复;<br />";
|
|
}
|
|
if ((dt.Rows[i]["idnumber"] + "").Trim() == idnumber)
|
|
{
|
|
msg += "身份证号重复;<br />";
|
|
}
|
|
if ((dt.Rows[i]["EMP_NUM"] + "").Trim() == empNum)
|
|
{
|
|
msg += "编号重复;<br />";
|
|
}
|
|
}
|
|
msg += "请确认输入信息是否正确";
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
Model.TBL.TBL_SYS_EMP_Model model = new Model.TBL.TBL_SYS_EMP_Model();
|
|
//员工表
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
//model.USERS_UID = usersUid;
|
|
model.EMP_NAME = empName;
|
|
model.EMP_NUM = empNum;
|
|
model.EMP_SEX = empSex;
|
|
model.BLOOD_TYPE = BLOOD_TYPE;
|
|
model.ORG_ID = orgId;
|
|
model.DEPT_ID = deptId;
|
|
model.EMP_EMAIL = empEmail;
|
|
model.EMP_MOBILE = empMobile;
|
|
model.IDNUMBER = idnumber;
|
|
model.BIRTHDAY = birthday;
|
|
model.FAMILYADDR = familyaddr;
|
|
model.CERT = cert;
|
|
model.NATION = nation;
|
|
model.FACE = face;
|
|
model.MAR = mar;
|
|
model.IS_WORK = isWork;
|
|
model.PROF = prof;
|
|
model.TAGS = tags;
|
|
model.POSTS = posts;
|
|
|
|
model.POL = pol;
|
|
model.PHOTO = photo;
|
|
model.IS_LEADER = isLeader;
|
|
model.IS_DEL = "0";
|
|
model.ENLISTED_TIME = enlisted_time;
|
|
model.IS_ACCESS = is_access;
|
|
model.IS_SUBCAMPVIDEO = is_SubCampVideo;
|
|
//model.DURING_ACCESS_PERIOD = during_access_period;
|
|
model.DURING_ACCESS_PERIOD2 = during_access_period;
|
|
model.ISDRIVER = isdriver;
|
|
model.FILENUM = filenum;
|
|
model.PERMISSIONNUM = permissionnum;
|
|
model.FIRSTCARD = firstcard;
|
|
model.EFFECTIVETIME = effictivetime;
|
|
model.PERMITTEDORGAN = permittedorgan;
|
|
|
|
model.IS_ADMIN = IS_ADMIN;
|
|
|
|
if (!string.IsNullOrEmpty(ALL_ANNUAL_LEAVE))
|
|
{
|
|
model.ALL_ANNUAL_LEAVE = decimal.Parse(ALL_ANNUAL_LEAVE);
|
|
}
|
|
if (!string.IsNullOrEmpty(AVAILABLE_ANNUAL_LEAVE))
|
|
{
|
|
model.AVAILABLE_ANNUAL_LEAVE = decimal.Parse(AVAILABLE_ANNUAL_LEAVE);
|
|
}
|
|
if (!string.IsNullOrEmpty(AccessAllowedMode))
|
|
{
|
|
model.ACCESSALLOWEDMODE = int.Parse(AccessAllowedMode);
|
|
}
|
|
if (bll.AddEmp(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "人员操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改人员信息
|
|
private string EditOrgEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string empId = context.Request.Params["ID"];
|
|
string usersUid = context.Request.Params["users_uid"];
|
|
string empName = context.Request.Params["emp_name"];
|
|
string empNum = context.Request.Params["emp_num"];
|
|
string empSex = context.Request.Params["emp_sex"];
|
|
string BLOOD_TYPE = context.Request.Params["BLOOD_TYPE"];
|
|
string orgId = context.Request.Params["org_id"];
|
|
string deptId = context.Request.Params["dept_id"];
|
|
string empEmail = context.Request.Params["emp_email"];
|
|
string empMobile = context.Request.Params["emp_mobile"];
|
|
string idnumber = context.Request.Params["idnumber"];
|
|
string birthday = context.Request.Params["birthday"];
|
|
string familyaddr = context.Request.Params["familyaddr"];
|
|
string cert = context.Request.Params["cert"];
|
|
string nation = context.Request.Params["nation"];
|
|
string face = context.Request.Params["face"];
|
|
string mar = context.Request.Params["mar"];
|
|
string isWork = context.Request.Params["is_work"];
|
|
string prof = context.Request.Params["prof"];
|
|
string tags = context.Request.Params["tags"];
|
|
string posts = context.Request.Params["posts"];
|
|
string pol = context.Request.Params["pol"];
|
|
string photo = context.Request.Params["photo"];
|
|
string isLeader = context.Request.Params["isLeader"];
|
|
string enlisted_time = context.Request.Params["enlisted_time"];
|
|
string is_access = context.Request.Params["is_access"];
|
|
string is_SubCampVideo = context.Request.Params["is_SubCampVideo"];
|
|
string AccessAllowedMode = context.Request.Params["AccessAllowedMode"];
|
|
string during_access_period = context.Request.Params["during_access_period"];
|
|
|
|
string isdriver = context.Request.Params["isdriver"];
|
|
string filenum = context.Request.Params["filenum"];
|
|
string permissionnum = context.Request.Params["permissionnum"];
|
|
string firstcard = context.Request.Params["firstcard"];
|
|
string effictivetime = context.Request.Params["effictivetime"];
|
|
string permittedorgan = context.Request.Params["permittedorgan"];
|
|
string ALL_ANNUAL_LEAVE = context.Request.Params["ALL_ANNUAL_LEAVE"];
|
|
string AVAILABLE_ANNUAL_LEAVE = context.Request.Params["AVAILABLE_ANNUAL_LEAVE"];
|
|
string IS_ADMIN = context.Request.Params["IS_ADMIN"] + "";
|
|
|
|
//员工表
|
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = new Model.TBL.TBL_SYS_EMP_Model();
|
|
model.ID = empId;
|
|
model.USERS_UID = usersUid;
|
|
model.EMP_NAME = empName;
|
|
model.EMP_NUM = empNum;
|
|
model.EMP_SEX = empSex;
|
|
model.BLOOD_TYPE = BLOOD_TYPE;
|
|
model.ORG_ID = orgId;
|
|
model.DEPT_ID = deptId;
|
|
model.EMP_EMAIL = empEmail;
|
|
model.EMP_MOBILE = empMobile;
|
|
model.IDNUMBER = idnumber;
|
|
model.BIRTHDAY = birthday;
|
|
model.FAMILYADDR = familyaddr;
|
|
model.CERT = cert;
|
|
model.NATION = nation;
|
|
model.FACE = face;
|
|
model.MAR = mar;
|
|
model.IS_WORK = isWork;
|
|
model.PROF = prof;
|
|
model.TAGS = tags;
|
|
model.POSTS = posts;
|
|
|
|
model.POL = pol;
|
|
model.PHOTO = photo;
|
|
model.IS_DEL = "0";
|
|
model.IS_LEADER = isLeader;
|
|
model.ENLISTED_TIME = enlisted_time;
|
|
model.IS_ACCESS = is_access;
|
|
model.IS_SUBCAMPVIDEO = is_SubCampVideo;
|
|
//model.DURING_ACCESS_PERIOD = during_access_period;
|
|
model.DURING_ACCESS_PERIOD2 = during_access_period;
|
|
model.ISDRIVER = isdriver;
|
|
model.FILENUM = filenum;
|
|
model.PERMISSIONNUM = permissionnum;
|
|
model.FIRSTCARD = firstcard;
|
|
model.EFFECTIVETIME = effictivetime;
|
|
model.PERMITTEDORGAN = permittedorgan;
|
|
|
|
model.IS_ADMIN = IS_ADMIN;
|
|
|
|
if (!string.IsNullOrEmpty(ALL_ANNUAL_LEAVE))
|
|
{
|
|
model.ALL_ANNUAL_LEAVE = decimal.Parse(ALL_ANNUAL_LEAVE);
|
|
}
|
|
if (!string.IsNullOrEmpty(AVAILABLE_ANNUAL_LEAVE))
|
|
{
|
|
model.AVAILABLE_ANNUAL_LEAVE = decimal.Parse(AVAILABLE_ANNUAL_LEAVE);
|
|
}
|
|
if (!string.IsNullOrEmpty(AccessAllowedMode))
|
|
{
|
|
model.ACCESSALLOWEDMODE = int.Parse(AccessAllowedMode);
|
|
}
|
|
|
|
string sql = " SELECT ID,EMP_NAME,USERS_UID,EMP_MOBILE,IDNUMBER,EMP_NUM from tbl_sys_emp WHERE USERS_UID='" + empMobile
|
|
+ "' or EMP_MOBILE='" + empMobile + "' or IDNUMBER ='" + idnumber + "' or (ORG_ID='" + orgId + "' and EMP_NUM ='" + empNum + "') ";
|
|
var dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
|
|
int count = dt.Rows.Count;
|
|
|
|
bool isUpdEmp = true;
|
|
|
|
if (count > 0)
|
|
{
|
|
//msg = "单位内编号重复,请修改后添加!";
|
|
|
|
msg = "重复信息:<br />";
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
//同信息ID不验证
|
|
if ((dt.Rows[i]["ID"] + "").Trim().ToLower() == empId.Trim().ToLower())
|
|
{
|
|
continue;
|
|
}
|
|
if ((dt.Rows[i]["USERS_UID"] + "").Trim() == empMobile && (dt.Rows[i]["ID"] + "").Trim().ToLower() != empId.Trim().ToLower())
|
|
{
|
|
msg += "已有账号与手机号重复;<br />";
|
|
isUpdEmp = false;
|
|
}
|
|
if ((dt.Rows[i]["EMP_MOBILE"] + "").Trim() == empMobile && (dt.Rows[i]["ID"] + "").Trim().ToLower() != empId.Trim().ToLower())
|
|
{
|
|
msg += "手机号重复;<br />";
|
|
isUpdEmp = false;
|
|
}
|
|
if ((dt.Rows[i]["idnumber"] + "").Trim() == idnumber && (dt.Rows[i]["ID"] + "").Trim().ToLower() != empId.Trim().ToLower())
|
|
{
|
|
msg += "身份证号重复;<br />";
|
|
isUpdEmp = false;
|
|
}
|
|
if ((dt.Rows[i]["EMP_NUM"] + "").Trim() == empNum && (dt.Rows[i]["ID"] + "").Trim().ToLower() != empId.Trim().ToLower())
|
|
{
|
|
msg += "编号重复;<br />";
|
|
isUpdEmp = false;
|
|
}
|
|
}
|
|
msg += "请确认输入信息是否正确";
|
|
|
|
}
|
|
if (isUpdEmp)
|
|
{
|
|
if (bll.EditEmp(model))
|
|
{
|
|
FangYar.BLL.TBL.SysUsersBLL ubll = new BLL.TBL.SysUsersBLL();
|
|
ubll.UpdateOrgId(model.USERS_UID, model.ORG_ID);
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "人员操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改人员信息
|
|
private string EditInfo(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string UsersUid = context.Request.Params["UsersUid"];
|
|
string UsersName = context.Request.Params["UsersName"];
|
|
string UsersEmail = context.Request.Params["UsersEmail"];
|
|
string UsersMobile = context.Request.Params["UsersMobile"];
|
|
string emp_num = context.Request.Params["emp_num"];
|
|
string sex = context.Request.Params["sex"];
|
|
string idnumber = context.Request.Params["idnumber"];
|
|
string cert = context.Request.Params["cert"];
|
|
string nation = context.Request.Params["nation"];
|
|
string face = context.Request.Params["face"];
|
|
string mar = context.Request.Params["mar"];
|
|
|
|
string strWhere = " USERS_UID='" + UsersUid + "'";
|
|
//员工表
|
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = bll.QueryList(1, 1, strWhere, "")[0];
|
|
model.USERS_UID = UsersUid;
|
|
model.EMP_NAME = UsersName;
|
|
model.EMP_EMAIL = UsersEmail;
|
|
model.EMP_MOBILE = UsersMobile;
|
|
model.EMP_NUM = emp_num;
|
|
model.EMP_SEX = sex;
|
|
model.IDNUMBER = idnumber;
|
|
model.CERT = cert;
|
|
model.NATION = nation;
|
|
model.FACE = face;
|
|
model.MAR = mar;
|
|
if (bll.EditEmp(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "人员操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除人员
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DelOrgEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string delempdvc = "";
|
|
try
|
|
{
|
|
string org_id = context.Request.Params["org_id"];
|
|
string EmpList = context.Request.Params["EmpList"];
|
|
string UserUid = context.Request.Params["UserUid"];
|
|
string EmpNos = context.Request.Params["EmpNos"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
string[] UidArray = UserUid.Split(',');
|
|
string UserUidString = "";
|
|
for (int i = 0; i < UidArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
UserUidString = "'" + UidArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
UserUidString += ",'" + UidArray[i] + "'";
|
|
}
|
|
}
|
|
//删除门禁机中的人员信息
|
|
FangYar.BLL.OA.TBL_EPUIP_ORG bll_ep = new BLL.OA.TBL_EPUIP_ORG();
|
|
string whereStr = " ORG_ID ='" + org_id + "' and EXTEND2 = '0' ";
|
|
List<FangYar.Model.OA.TBL_EPUIP_ORG> list = bll_ep.GetModelList(whereStr);
|
|
|
|
try
|
|
{
|
|
if (list.Count > 0)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
string[] EmpNoArray = EmpNos.Split(',');
|
|
for (int j = 0; j < EmpNoArray.Length; j++)
|
|
{
|
|
//删除人员数据
|
|
string EmpNo = EmpNoArray[j];
|
|
string DvcAddress = list[i].DVCADDRESS;
|
|
string dvcPort = list[i].DVCPORT;
|
|
string userName = list[i].USERNAME;
|
|
string password = list[i].PASSWORD;
|
|
string requestURI = list[i].SERVICEADDR + "api/User/DelEmployee";
|
|
string requestMethod = "POST";
|
|
string json = "{\"DvcAddress\":\"" + DvcAddress + "\",\"dvcPort\":\"" + dvcPort + "\",\"userName\":\"" + userName
|
|
+ "\",\"password\":\"" + password + "\",\"employeeNo\":\"" + EmpNo + "\"}";
|
|
|
|
//将数据发送给网络服务
|
|
string returnStr = SendHttpRequest(requestURI, requestMethod, json).Replace("\\\"", "\"").Trim('"');
|
|
ReturnInfo flag = JsonConvert.DeserializeObject<ReturnInfo>(returnStr);//返回"true","false"
|
|
//delempdvc += EmpNo + ":门禁机ip" + DvcAddress+" , " + flag.msg;
|
|
if (flag.code == "-1")
|
|
{
|
|
delempdvc = "从" + EmpNo + "开始,删除失败,请稍后再试!";
|
|
return "{\"code\":99,\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
//returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + ",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
if (bll.DelEmp(EmpListString, UserUidString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 人员退出队伍
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string ExitEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string delempdvc = "";
|
|
try
|
|
{
|
|
string org_id = context.Request.Params["org_id"];
|
|
string EmpList = context.Request.Params["EmpList"];
|
|
string UserUid = context.Request.Params["UserUid"];
|
|
string EmpNos = context.Request.Params["EmpNos"];
|
|
string ExitRemark = context.Request.Params["ExitRemark"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
//for (int i = 0; i < EmpArray.Length; i++)
|
|
//{
|
|
// if (i == 0)
|
|
// {
|
|
// EmpListString = "'" + EmpArray[i] + "'";
|
|
// }
|
|
// else
|
|
// {
|
|
// EmpListString += ",'" + EmpArray[i] + "'";
|
|
// }
|
|
//}
|
|
|
|
string[] UidArray = UserUid.Split(',');
|
|
string UserUidString = "";
|
|
for (int i = 0; i < UidArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
UserUidString = "'" + UidArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
UserUidString += ",'" + UidArray[i] + "'";
|
|
}
|
|
}
|
|
//插入退出记录表
|
|
try
|
|
{
|
|
string insSql = "INSERT INTO tbl_sys_emp_exit_log (ID,Users_uid,Emp_Id,Use_Id,Exit_Remark,Old_Org_Id,Old_Dept_Id)" +
|
|
"SELECT CONCAT(date_format(now(),'%Y%m%d%H%i%s'),USERS_UID) ID,Users_uid USERS_UID, ID Emp_Id,'' Use_Id, '" + ExitRemark +
|
|
"' Exit_Remark, ORG_ID Old_Org_Id, DEPT_ID Old_Dept_Id from tbl_sys_emp WHERE USERS_UID in (" + UserUidString + ")";
|
|
FangYar.Common.MySqlHelper.Execute(insSql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
// 更新人员数据所属营区信息到退伍营区
|
|
try
|
|
{
|
|
string updSql = " UPDATE tbl_sys_emp set org_id='BFCE45A5-85EA-56CA-029A-8D6238B9F565' WHERE USERS_UID in (" + UserUidString + "); " +
|
|
" UPDATE tbl_sys_users set org_id='BFCE45A5-85EA-56CA-029A-8D6238B9F565' WHERE USERS_UID in (" + UserUidString + "); ";
|
|
|
|
FangYar.Common.MySqlHelper.Execute(updSql);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
msg = "操作成功!";
|
|
code = 1;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "退伍操作异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员操作请求", "退伍操作");
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
/// 恢复删除人员
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string ClearDel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string delempdvc = "";
|
|
try
|
|
{
|
|
string org_id = context.Request.Params["org_id"];
|
|
string EmpList = context.Request.Params["EmpList"];
|
|
string UserUid = context.Request.Params["UserUid"];
|
|
string EmpNos = context.Request.Params["EmpNos"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
string[] UidArray = UserUid.Split(',');
|
|
string UserUidString = "";
|
|
for (int i = 0; i < UidArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
UserUidString = "'" + UidArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
UserUidString += ",'" + UidArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
if (bll.ClearDel(EmpListString, UserUidString))
|
|
{
|
|
msg = "操作成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "操作失败!";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "恢复删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员操作请求", "恢复删除");
|
|
return returnstr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置密码
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string ResetPwd(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string delempdvc = "";
|
|
try
|
|
{
|
|
string org_id = context.Request.Params["org_id"];
|
|
string EmpList = context.Request.Params["EmpList"];
|
|
string UserUid = context.Request.Params["UserUid"];
|
|
string EmpNos = context.Request.Params["EmpNos"];
|
|
//初始密码
|
|
var InitPassword = System.Configuration.ConfigurationManager.AppSettings["InitPassword"] + "";
|
|
if (string.IsNullOrWhiteSpace(InitPassword))
|
|
{
|
|
InitPassword = "119";
|
|
}
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
|
|
string[] UidArray = UserUid.Split(',');
|
|
string UserUidString = "";
|
|
for (int i = 0; i < UidArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
UserUidString = "'" + UidArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
UserUidString += ",'" + UidArray[i] + "'";
|
|
}
|
|
}
|
|
var UsersPwd = FangYar.Common.Md5.GetMD5String(InitPassword);
|
|
if (bll.ResetPwd(UsersPwd, UserUidString))
|
|
{
|
|
msg = "重置成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "重置失败!";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "密码重置异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "人员操作请求", "密码重置");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据id获取人员信息
|
|
private string getUserByUId(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "{}";
|
|
try
|
|
{
|
|
string UID = context.Request.Params["uid"];
|
|
if (!string.IsNullOrEmpty(UID))
|
|
{
|
|
code = 1;
|
|
string strWhere = " USERS_UID='" + UID + "'";
|
|
List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.QueryEmp(1, 1, strWhere, "");
|
|
data = FangYar.Common.JsonHelper.ToJson(list[0]);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
msg = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "根据id获取人员信息异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "根据id获取人员信息");
|
|
return returnstr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 截取出身年月日
|
|
/// </summary>
|
|
/// <param name="IDCard">身份证号</param>
|
|
/// <returns></returns>
|
|
public static string GetDate(string IDCard)
|
|
{
|
|
try
|
|
{
|
|
string BirthDay = "";
|
|
string strYear;
|
|
string strMonth;
|
|
string strDay;
|
|
if (IDCard.Length == 15)
|
|
{
|
|
strYear = IDCard.Substring(6, 2);
|
|
strMonth = IDCard.Substring(8, 2);
|
|
strDay = IDCard.Substring(10, 2);
|
|
BirthDay = "19" + strYear + "- " + strMonth + "- " + strDay;
|
|
}
|
|
if (IDCard.Length == 18)
|
|
{
|
|
strYear = IDCard.Substring(6, 4);
|
|
strMonth = IDCard.Substring(10, 2);
|
|
strDay = IDCard.Substring(12, 2);
|
|
BirthDay = strYear + "-" + strMonth + "-" + strDay;
|
|
}
|
|
return BirthDay;
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
return "";
|
|
}
|
|
|
|
//上传excel
|
|
private string impExcel(HttpContext context)
|
|
{
|
|
string returnStr = "";
|
|
string msg = "", successInfo = "", errInfo = "", updateInfo = "";
|
|
string org_id = "";
|
|
//选择的树目录
|
|
string treeID = "";
|
|
try
|
|
{
|
|
org_id = context.Request.Params["org_id"] + "";
|
|
treeID = context.Request.Params["treeID"] + "";
|
|
if (string.IsNullOrWhiteSpace(treeID))
|
|
{
|
|
org_id = treeID;
|
|
}
|
|
var file = context.Request.Files[0]; //获取选中文件
|
|
Stream stream = file.InputStream; //将文件转为流
|
|
Workbook workbook = new Workbook();
|
|
//将文件流内容读取到workbook对象里面
|
|
workbook.LoadFromStream(stream);
|
|
//得到第一个Sheet页
|
|
Worksheet sheet = workbook.Worksheets[0];
|
|
DataTable dtImp = SheetToDataTable(true, sheet);
|
|
|
|
//获取字典数据
|
|
FangYar.BLL.CommomBLL common_bll = new BLL.CommomBLL();
|
|
string modtypes = "CERTTYPE,NATIONTYPE,FACETYPE,MARTYPE,PROFTYPE,POLTYPE";
|
|
string[] modtypeArray = modtypes.Split(','); //; modtypes.Split(',');
|
|
string modtype_s = "";
|
|
for (int i = 0; i < modtypeArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
modtype_s = "'" + modtypeArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
modtype_s += ",'" + modtypeArray[i] + "'";
|
|
}
|
|
}
|
|
DataTable dataModCode = common_bll.GetTableList("*", "tbl_sys_dicdetail", " MOD_CODE in(" + modtype_s + ") ");
|
|
//定义四个新的datatable
|
|
DataTable tableCerttype = dataModCode.Clone(),
|
|
tableNationtype = dataModCode.Clone(),
|
|
tableFacetype = dataModCode.Clone(),
|
|
tableMartype = dataModCode.Clone(),
|
|
tableProftype = dataModCode.Clone(),
|
|
tablePoltype = dataModCode.Clone();
|
|
for (int i = 0; i < dataModCode.Rows.Count; i++)
|
|
{
|
|
if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "CERTTYPE")
|
|
{
|
|
tableCerttype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
else if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "NATIONTYPE")
|
|
{
|
|
tableNationtype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
else if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "FACETYPE")
|
|
{
|
|
tableFacetype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
else if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "MARTYPE")
|
|
{
|
|
tableMartype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
else if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "PROFTYPE")
|
|
{
|
|
tableProftype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
else if (dataModCode.Rows[i]["MOD_CODE"].ToString() == "POLTYPE")
|
|
{
|
|
tablePoltype.Rows.Add(dataModCode.Rows[i].ItemArray);
|
|
}
|
|
}
|
|
|
|
FangYar.BLL.FIRE.FIRE_ORG bllFireOrg = new BLL.FIRE.FIRE_ORG();
|
|
FangYar.BLL.TBL.SysEmpBLL bllEmp = new BLL.TBL.SysEmpBLL();
|
|
for (int i = 0; i < dtImp.Rows.Count; i++)
|
|
{
|
|
string empOrder = dtImp.Rows[i][0].ToString();
|
|
string empName = dtImp.Rows[i][1].ToString();
|
|
string empNum = dtImp.Rows[i][2].ToString();
|
|
string empSex = dtImp.Rows[i][3].ToString();
|
|
string orgName = dtImp.Rows[i][4].ToString();
|
|
string deptName = dtImp.Rows[i][5].ToString();
|
|
string empEmail = dtImp.Rows[i][6].ToString();
|
|
string empMobile = dtImp.Rows[i][7].ToString();
|
|
string empIdNumber = dtImp.Rows[i][8].ToString();
|
|
string empCert = dtImp.Rows[i][9].ToString();
|
|
string empNation = dtImp.Rows[i][10].ToString();
|
|
string empFace = dtImp.Rows[i][11].ToString();
|
|
string empMar = dtImp.Rows[i][12].ToString();
|
|
string empEnlisted = dtImp.Rows[i][13].ToString();
|
|
string empProf = dtImp.Rows[i][14].ToString();
|
|
string empPol = dtImp.Rows[i][15].ToString();
|
|
if (!string.IsNullOrWhiteSpace(empIdNumber))
|
|
{
|
|
empIdNumber = empIdNumber.Replace("\n", "");
|
|
empIdNumber = empIdNumber.Replace("'", "");
|
|
|
|
empIdNumber.Trim();
|
|
|
|
}
|
|
|
|
FangYar.Model.FIRE.FIRE_ORG modelFireOrg1 = bllFireOrg.getOrgByOrgName(orgName, "0", org_id); // 0机构1部门
|
|
if (modelFireOrg1 != null)
|
|
{
|
|
FangYar.Model.TBL.TBL_SYS_EMP_Model modelEmp = bllEmp.GetModelByIDnumber(modelFireOrg1.ORG_ID, empIdNumber);
|
|
if (modelEmp == null) //新增
|
|
{
|
|
modelEmp = new Model.TBL.TBL_SYS_EMP_Model();
|
|
modelEmp.ID = Guid.NewGuid().ToString("N");
|
|
modelEmp.EMP_NAME = empName;
|
|
modelEmp.EMP_NUM = empNum;
|
|
modelEmp.EMP_SEX = empSex;
|
|
modelEmp.ORG_ID = modelFireOrg1.ORG_ID;
|
|
modelEmp.ORG_NAME = modelFireOrg1.ORG_NAME;
|
|
modelEmp.BIRTHDAY = GetDate(empIdNumber);
|
|
|
|
////临时修改,只处理新增,不处理更新数据
|
|
//if (!string.IsNullOrWhiteSpace(empNum))
|
|
//{
|
|
// modelEmp.PHOTO = "Upload/ExcelImgEmp/img/" + empNum + ".JPG";
|
|
//}
|
|
|
|
FangYar.Model.FIRE.FIRE_ORG modelFireOrg2 = bllFireOrg.getOrgByOrgNamePID(modelFireOrg1.ORG_ID, deptName, "1"); // 0机构1部门
|
|
if (modelFireOrg2 != null)
|
|
{
|
|
modelEmp.DEPT_ID = modelFireOrg2.ORG_ID;
|
|
modelEmp.DEPT_NAME = modelFireOrg2.ORG_NAME;
|
|
}
|
|
modelEmp.EMP_EMAIL = empEmail;
|
|
modelEmp.EMP_MOBILE = empMobile;
|
|
modelEmp.IS_DEL = "0";
|
|
modelEmp.IDNUMBER = empIdNumber;
|
|
|
|
DataRow[] drs1 = tableCerttype.Select("DIC_TEXT = '" + empCert + "'");
|
|
if (drs1 != null)
|
|
{
|
|
if (drs1.Length > 0)
|
|
{
|
|
modelEmp.CERT = drs1[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs2 = tableNationtype.Select("DIC_TEXT = '" + empNation + "'");
|
|
if (drs2 != null)
|
|
{
|
|
if (drs2.Length > 0)
|
|
{
|
|
modelEmp.NATION = drs2[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs3 = tableFacetype.Select("DIC_TEXT = '" + empFace + "'");
|
|
if (drs3 != null)
|
|
{
|
|
if (drs3.Length > 0)
|
|
{
|
|
modelEmp.FACE = drs3[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs4 = tableMartype.Select("DIC_TEXT = '" + empMar + "'");
|
|
if (drs4 != null)
|
|
{
|
|
if (drs4.Length > 0)
|
|
{
|
|
modelEmp.MAR = drs4[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs5 = tableProftype.Select("DIC_TEXT = '" + empProf + "'");
|
|
if (drs5 != null)
|
|
{
|
|
if (drs5.Length > 0)
|
|
{
|
|
modelEmp.PROF = drs5[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs6 = tablePoltype.Select("DIC_TEXT = '" + empPol + "'");
|
|
if (drs6 != null)
|
|
{
|
|
if (drs6.Length > 0)
|
|
{
|
|
modelEmp.POL = drs6[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
modelEmp.IS_WORK = "1";
|
|
modelEmp.ENLISTED_TIME = empEnlisted;
|
|
modelEmp.IS_ADMIN = "0";
|
|
|
|
if (bllEmp.AddEmp(modelEmp))
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "添加成功!*";
|
|
}
|
|
else
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "*未添加成功!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
////临时修改,只处理新增,不处理更新数据
|
|
//if (string.IsNullOrWhiteSpace(empNum))
|
|
//{
|
|
// continue;
|
|
//}
|
|
//else
|
|
//{
|
|
// // modelEmp.PHOTO = "Upload/ExcelImgEmp/img/" + empNum + ".JPG";
|
|
// string phonoStr = "Upload/ExcelImgEmp/img/" + empNum + ".JPG";
|
|
// string updSql = " UPDATE tbl_sys_emp SET PHOTO='" + phonoStr + "' WHERE IDNUMBER='" + empIdNumber + "' ";
|
|
// FangYar.Common.MySqlHelper.ExecuteSql(updSql);
|
|
// successInfo += empOrder + ":" + modelEmp.EMP_NAME + "已有该身份证号人员,更新未成功!*";
|
|
// continue;
|
|
//}
|
|
if (modelEmp.IS_DEL == "0") //正常
|
|
{
|
|
modelEmp.EMP_NAME = empName;
|
|
modelEmp.EMP_NUM = empNum;
|
|
modelEmp.EMP_SEX = empSex;
|
|
modelEmp.ORG_ID = modelFireOrg1.ORG_ID;
|
|
modelEmp.ORG_NAME = modelFireOrg1.ORG_NAME;
|
|
modelEmp.BIRTHDAY = GetDate(empIdNumber);
|
|
|
|
FangYar.Model.FIRE.FIRE_ORG modelFireOrg2 = bllFireOrg.getOrgByOrgNamePID(modelFireOrg1.ORG_ID, deptName, "1"); // 1机构2部门
|
|
if (modelFireOrg2 != null)
|
|
{
|
|
modelEmp.DEPT_ID = modelFireOrg2.ORG_ID;
|
|
modelEmp.DEPT_NAME = modelFireOrg2.ORG_NAME;
|
|
}
|
|
modelEmp.EMP_EMAIL = empEmail;
|
|
modelEmp.EMP_MOBILE = empMobile;
|
|
|
|
|
|
DataRow[] drs1 = tableCerttype.Select("DIC_TEXT = '" + empCert + "'");
|
|
if (drs1 != null)
|
|
{
|
|
if (drs1.Length > 0)
|
|
{
|
|
modelEmp.CERT = drs1[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs2 = tableNationtype.Select("DIC_TEXT = '" + empNation + "'");
|
|
if (drs2 != null)
|
|
{
|
|
if (drs2.Length > 0)
|
|
{
|
|
modelEmp.NATION = drs2[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs3 = tableFacetype.Select("DIC_TEXT = '" + empFace + "'");
|
|
if (drs3 != null)
|
|
{
|
|
if (drs3.Length > 0)
|
|
{
|
|
modelEmp.FACE = drs3[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs4 = tableMartype.Select("DIC_TEXT = '" + empMar + "'");
|
|
if (drs4 != null)
|
|
{
|
|
if (drs4.Length > 0)
|
|
{
|
|
modelEmp.MAR = drs4[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs5 = tableProftype.Select("DIC_TEXT = '" + empProf + "'");
|
|
if (drs5 != null)
|
|
{
|
|
if (drs5.Length > 0)
|
|
{
|
|
modelEmp.PROF = drs5[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
DataRow[] drs6 = tablePoltype.Select("DIC_TEXT = '" + empPol + "'");
|
|
if (drs6 != null)
|
|
{
|
|
if (drs6.Length > 0)
|
|
{
|
|
modelEmp.POL = drs6[0]["DIC_VALUE"].ToString();
|
|
}
|
|
}
|
|
modelEmp.IS_WORK = "1";
|
|
modelEmp.ENLISTED_TIME = empEnlisted;
|
|
|
|
if (bllEmp.EditEmp(modelEmp))
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "已有该身份证号人员,更新成功!*";
|
|
}
|
|
else
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "已有该身份证号人员,更新未成功!*";
|
|
}
|
|
}
|
|
else //删除,更新状态
|
|
{
|
|
modelEmp.EMP_NAME = empName;
|
|
modelEmp.EMP_NUM = empNum;
|
|
modelEmp.EMP_SEX = empSex;
|
|
modelEmp.ORG_ID = modelFireOrg1.ORG_ID;
|
|
modelEmp.ORG_NAME = modelFireOrg1.ORG_NAME;
|
|
modelEmp.BIRTHDAY = GetDate(empIdNumber);
|
|
|
|
FangYar.Model.FIRE.FIRE_ORG modelFireOrg2 = bllFireOrg.getOrgByOrgNamePID(modelFireOrg1.ORG_ID, deptName, "2"); // 1机构2部门
|
|
if (modelFireOrg2 != null)
|
|
{
|
|
modelEmp.DEPT_ID = modelFireOrg2.ORG_ID;
|
|
modelEmp.DEPT_NAME = modelFireOrg2.ORG_NAME;
|
|
}
|
|
modelEmp.EMP_EMAIL = empEmail;
|
|
modelEmp.EMP_MOBILE = empMobile;
|
|
|
|
DataRow[] drs1 = tableCerttype.Select("DIC_TEXT = '" + empCert + "'");
|
|
if (drs1 != null)
|
|
{
|
|
modelEmp.CERT = drs1[0]["DIC_VALUE"].ToString();
|
|
}
|
|
DataRow[] drs2 = tableNationtype.Select("DIC_TEXT = '" + empNation + "'");
|
|
if (drs2 != null)
|
|
{
|
|
modelEmp.NATION = drs2[0]["DIC_VALUE"].ToString();
|
|
}
|
|
DataRow[] drs3 = tableFacetype.Select("DIC_TEXT = '" + empFace + "'");
|
|
if (drs3 != null)
|
|
{
|
|
modelEmp.FACE = drs3[0]["DIC_VALUE"].ToString();
|
|
}
|
|
DataRow[] drs4 = tableMartype.Select("DIC_TEXT = '" + empMar + "'");
|
|
if (drs4 != null)
|
|
{
|
|
modelEmp.MAR = drs4[0]["DIC_VALUE"].ToString();
|
|
}
|
|
DataRow[] drs5 = tableProftype.Select("DIC_TEXT = '" + empProf + "'");
|
|
if (drs5 != null)
|
|
{
|
|
modelEmp.PROF = drs5[0]["DIC_VALUE"].ToString();
|
|
}
|
|
DataRow[] drs6 = tablePoltype.Select("DIC_TEXT = '" + empPol + "'");
|
|
if (drs6 != null)
|
|
{
|
|
modelEmp.POL = drs6[0]["DIC_VALUE"].ToString();
|
|
}
|
|
modelEmp.IS_WORK = "1";
|
|
modelEmp.ENLISTED_TIME = empEnlisted;
|
|
modelEmp.IS_DEL = "0";
|
|
|
|
|
|
if (bllEmp.EditEmp(modelEmp))
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "此身份证号属岗外人员,已更新为岗内人员!*";
|
|
//修改账号的删除状态
|
|
FangYar.BLL.TBL.SysUsersBLL usersbll = new BLL.TBL.SysUsersBLL();
|
|
FangYar.Model.TBL.TBL_SYS_USERS_Model usersmodel = usersbll.GetModelByUID(modelEmp.USERS_UID);
|
|
if (usersmodel != null)
|
|
{
|
|
usersmodel.USERS_STATE = "0";
|
|
usersbll.Edit(usersmodel);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "此身份证号添加未成功!*";
|
|
}
|
|
}
|
|
//successInfo += empOrder + ":" + modelEmp.EMP_NAME + "身份证号重复,未添加成功!*";
|
|
//更新
|
|
}
|
|
}
|
|
else
|
|
{
|
|
successInfo += empOrder + ":" + empName + "机构填写有误或没有权限添加其他单位信息,未添加成功!*";
|
|
}
|
|
}
|
|
returnStr = "{\"code\": 1,\"msg\": \"" + msg + "\",\"successInfo\": \"" + successInfo + "\",\"errInfo\": \"" + errInfo + "\",\"updateInfo\": \"" + updateInfo + "\"}";
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
returnStr = "{\"code\": 1,\"msg\": \"" + ex.Message + "\",\"successInfo\": \"" + successInfo + "\",\"errInfo\": \"" + errInfo + "\",\"updateInfo\": \"" + updateInfo + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "上传Excel异常:" + ex);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "人员操作请求", "上传Excel");
|
|
return returnStr;
|
|
}
|
|
/// <summary>
|
|
/// 将Excel以文件流转换DataTable
|
|
/// </summary>
|
|
/// <param name="hasTitle">是否有表头</param>
|
|
/// <param name="stream">文件流</param>
|
|
/// <param name="tableindex">文件簿索引</param>
|
|
public DataTable ExcelToDataTableFormStream(bool hasTitle = true, Stream stream = null, int tableindex = 0)
|
|
{
|
|
//新建Workbook
|
|
Workbook workbook = new Workbook();
|
|
//将文件流内容读取到workbook对象里面
|
|
workbook.LoadFromStream(stream);
|
|
//得到第一个Sheet页
|
|
Worksheet sheet = workbook.Worksheets[tableindex];
|
|
return SheetToDataTable(hasTitle, sheet);
|
|
}
|
|
|
|
private DataTable SheetToDataTable(bool hasTitle, Worksheet sheet)
|
|
{
|
|
int iRowCount = sheet.Rows.Length;
|
|
int iColCount = sheet.Columns.Length;
|
|
DataTable dt = new DataTable();
|
|
//生成列头
|
|
for (int i = 0; i < iColCount; i++)
|
|
{
|
|
var name = "column" + i;
|
|
if (hasTitle)
|
|
{
|
|
var txt = sheet.Range[1, i + 1].Text;
|
|
if (!string.IsNullOrEmpty(txt)) name = txt;
|
|
}
|
|
while (dt.Columns.Contains(name)) name = name + "_1";//重复行名称会报错。
|
|
dt.Columns.Add(new DataColumn(name, typeof(string)));
|
|
}
|
|
//生成行数据
|
|
int rowIdx = hasTitle ? 2 : 1;
|
|
for (int iRow = rowIdx; iRow <= iRowCount; iRow++)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
for (int iCol = 1; iCol <= iColCount; iCol++)
|
|
{
|
|
dr[iCol - 1] = sheet.Range[iRow, iCol].DisplayedText;
|
|
}
|
|
dt.Rows.Add(dr);
|
|
}
|
|
return RemoveEmpty(dt);
|
|
}
|
|
/// <summary>
|
|
/// 去除空行
|
|
/// </summary>
|
|
/// <param name="dt"></param>
|
|
/// <returns></returns>
|
|
private DataTable RemoveEmpty(DataTable dt)
|
|
{
|
|
List<DataRow> removelist = new List<DataRow>();
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
bool rowdataisnull = true;
|
|
for (int j = 0; j < dt.Columns.Count; j++)
|
|
{
|
|
if (!string.IsNullOrEmpty(dt.Rows[i][j].ToString().Trim()))
|
|
{
|
|
rowdataisnull = false;
|
|
}
|
|
}
|
|
if (rowdataisnull)
|
|
{
|
|
removelist.Add(dt.Rows[i]);
|
|
}
|
|
}
|
|
for (int i = 0; i < removelist.Count; i++)
|
|
{
|
|
dt.Rows.Remove(removelist[i]);
|
|
}
|
|
return dt;
|
|
}
|
|
public void expExcel(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string OrgList = context.Request.Params["OrgList"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string is_work = context.Request.Params["is_work"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string is_manage_cadre = context.Request.Params["is_manage_cadre"];
|
|
string pol = context.Request.Params["pol"];
|
|
string face = context.Request.Params["face"];
|
|
string cert = context.Request.Params["cert"];
|
|
string nation = context.Request.Params["nation"];
|
|
string prof = context.Request.Params["prof"];
|
|
//是否查询包含管理员账号数据
|
|
string is_admin = context.Request.Params["is_admin"];
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = null;
|
|
string pOrgID = "";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
pOrgID = treeID;
|
|
if (is_content == "1")
|
|
{
|
|
where = "( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = "( ORG_ID = '" + treeID + "' )";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
pOrgID = OrgId;
|
|
if (is_content == "1")
|
|
{
|
|
where = "( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = "( ORG_ID = '" + OrgId + "' )";
|
|
}
|
|
|
|
}
|
|
//or DEPT_ID = '" + OrgId + "'
|
|
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " DEPT_ID = '" + selDeptId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( emp_name like '%" + keyword + "%' or EMP_MOBILE like '%" + keyword + "%' or USERS_UID like '%" + keyword + "%' or IDNUMBER like '%" + keyword + "%')";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchTime))
|
|
{
|
|
string startTime = "", endTime = "";
|
|
if (searchTime.IndexOf(" - ") != -1)
|
|
{
|
|
startTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[0];
|
|
endTime = Regex.Split(searchTime, " - ", RegexOptions.IgnoreCase)[1];
|
|
}
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "ENLISTED_TIME >= '" + startTime + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "ENLISTED_TIME <= '" + endTime + "'";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(is_work))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
|
|
if (is_work == "1")
|
|
{
|
|
where += " is_work = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " is_work != '1'";
|
|
}
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(is_admin))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
|
|
if (is_admin == "1")
|
|
{
|
|
where += " is_admin = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " (is_admin != '1' or is_admin is null)";
|
|
}
|
|
}
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and DEPT_ID='" + DeptID + "' ";
|
|
}
|
|
}
|
|
|
|
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " is_del = '0'";
|
|
|
|
if (!string.IsNullOrWhiteSpace(is_manage_cadre))
|
|
{
|
|
|
|
if (is_admin != "1" && is_manage_cadre == "0")
|
|
{
|
|
where += " and prof='-1' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "1")
|
|
{
|
|
where += " and prof='15' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "2")
|
|
{
|
|
where += " and prof!='15' ";
|
|
}
|
|
else if (is_admin != "1" && is_manage_cadre == "3")
|
|
{
|
|
}
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(pol))
|
|
{
|
|
where += " and pol='" + pol + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(face))
|
|
{
|
|
where += " and face='" + face + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(cert))
|
|
{
|
|
where += " and cert='" + cert + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(nation))
|
|
{
|
|
where += " and nation='" + nation + "' ";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(prof))
|
|
{
|
|
where += " and prof='" + prof + "' ";
|
|
}
|
|
|
|
int count = bll.GetRecordCount(where, pOrgID);
|
|
if (count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
System.Data.DataTable data = bll.expExcel(1, count, where, " emp_name ", pOrgID);
|
|
System.Collections.Generic.Dictionary<string, string> cellHeaders = new System.Collections.Generic.Dictionary<string, string>();
|
|
cellHeaders.Add("EMP_NAME", "姓名");
|
|
cellHeaders.Add("EMP_NUM", "编号");
|
|
cellHeaders.Add("EMP_SEX", "性别");
|
|
cellHeaders.Add("ORG_NAME", "机构");
|
|
cellHeaders.Add("DEPT_NAME", "部门");
|
|
|
|
cellHeaders.Add("EMP_EMAIL", "邮箱");
|
|
cellHeaders.Add("EMP_MOBILE", "电话");
|
|
cellHeaders.Add("IDNUMBER", "身份证号");
|
|
cellHeaders.Add("CERT_NAME", "学历");
|
|
cellHeaders.Add("NATION_NAME", "民族");
|
|
cellHeaders.Add("PROF_NAME", "职位类型");
|
|
cellHeaders.Add("POL_NAME", "消防救援衔");
|
|
|
|
|
|
cellHeaders.Add("FACE_NAME", "政治面貌");
|
|
cellHeaders.Add("IS_WORK_NAME", "在岗情况");
|
|
cellHeaders.Add("ENLISTED_TIME", "入伍时间");
|
|
|
|
|
|
cellHeaders.Add("IS_ACCESS", "是否允许外出");
|
|
cellHeaders.Add("DURING_ACCESS_PERIOD", "允许出入时间段");
|
|
cellHeaders.Add("BLOOD_TYPE", "血型");
|
|
cellHeaders.Add("FAMILYADDR", "现家庭住址");
|
|
cellHeaders.Add("TAGS", "标签");
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "导出");
|
|
FangYar.Common.NPOIExcelHelper.ExportByWeb(data, null, cellHeaders, DateTime.Now.ToString("yyyyMMddHHmmss") + "人员信息表.xls");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "导出异常:" + e);
|
|
}
|
|
}
|
|
//人员统计
|
|
private string personSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append("select IFNULL(sum(p.ZG), 0) ZG,IFNULL(sum(p.JY), 0) JY ,IFNULL(sum(p.XJ), 0) XJ ,IFNULL(sum(p.QJ), 0) QJ ,IFNULL(sum(p.XX), 0) XX ,IFNULL(sum(p.PX), 0) PX ,IFNULL(sum(p.BG), 0) BG ,IFNULL(sum(p.ZY), 0) ZY ,IFNULL(sum(p.CC), 0) CC ,IFNULL(sum(p.CG), 0) CG ,IFNULL(sum(p.ZLBD), 0) ZLBD ,IFNULL(sum(p.QT), 0) QT ,IFNULL(sum(p.KONG), 0) KONG,IFNULL(sum(p.zs), 0) ZS,IFNULL( sum( p.WC ), 0 ) WC ");
|
|
sql.Append(" from(select ");
|
|
sql.Append("CASE WHEN e.IS_WORK ='1' THEN 1 ELSE 0 END ZG");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='2' THEN 1 ELSE 0 END JY");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='3' THEN 1 ELSE 0 END XJ");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='4' THEN 1 ELSE 0 END QJ");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='5' THEN 1 ELSE 0 END XX");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='6' THEN 1 ELSE 0 END PX");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='7' THEN 1 ELSE 0 END BG");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='8' THEN 1 ELSE 0 END ZY");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='9' THEN 1 ELSE 0 END CC");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='10' THEN 1 ELSE 0 END CG");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='11' THEN 1 ELSE 0 END ZLBD");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='12' THEN 1 ELSE 0 END QT");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='13' THEN 1 ELSE 0 END WC");
|
|
sql.Append(",CASE WHEN e.IS_WORK ='' THEN 1 ELSE 0 END KONG ");
|
|
sql.Append(",1 zs ");
|
|
sql.Append("from tbl_sys_emp e ");
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
sql.Append(",(select get_Org_child_list('" + ORG_ID + "') cids ) s where find_in_set(org_id,cids) ");
|
|
}
|
|
else
|
|
{
|
|
sql.Append(" where ORG_ID='" + ORG_ID + "'");
|
|
}
|
|
sql.Append(" and IS_ADMIN='0' and is_del='0') p ");
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql.ToString());
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员统计");
|
|
return returnstr;
|
|
}
|
|
//人员统计
|
|
private string personStaAll(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + ORG_ID + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) ) ";
|
|
strWhere += " and is_del='0'";
|
|
DataTable dt = bll.personSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//人员实力统计
|
|
private string personStrengthSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string sql = " select SUM(case PROF when 15 then 1 else 0 END) ZZY,SUM(case PROF when 16 then 1 else 0 END) HTZXFY,SUM(case PROF when 17 then 1 else 0 END) XFWY,SUM(case PROF when 18 then 1 else 0 END) GQGWRY,SUM( CASE PROF WHEN 19 THEN 1 ELSE 0 END ) XFY,SUM( CASE ifnull(PROF,'') WHEN '' THEN 1 ELSE 0 END ) WZ from tbl_sys_emp";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
sql += ",(select get_Org_child_list('" + ORG_ID + "') cids ) s where find_in_set(org_id,cids) and IS_ADMIN='0' and is_del = '0'";
|
|
}
|
|
else
|
|
{
|
|
sql += " where ORG_ID='" + ORG_ID + "' and IS_ADMIN='0' and is_del = '0'";
|
|
}
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员实力统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员实力统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//机构树
|
|
private string getEmpTreeByorgid(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getProcOrganization(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构树异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构树");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
//查询
|
|
private string GetEmpList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
|
|
|
|
string where = " IS_ADMIN='0' ";
|
|
|
|
where += " and ORG_ID = '" + OrgId + "'";
|
|
|
|
where += " and is_del = '0'";
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
FangYar.BLL.CommomBLL commombll = new BLL.CommomBLL();
|
|
DataTable dt = commombll.GetTableList(" USERS_UID,EMP_NAME ,EMP_MOBILE ", " TBL_SYS_EMP ", where);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
private string GetEmpByUID(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string UID = context.Request.Params["UID"];
|
|
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(UID))
|
|
{
|
|
where += " and USERS_UID = '" + UID + "'";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"error\",\"data\":[]}";
|
|
}
|
|
returnstr = "{\"code\":1,\"msg\":\"\",\"data\":";
|
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = bll.GetModelByUID(UID);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
private string Distribute(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
string org_id = context.Request.Params["org_id"];
|
|
string photopath = context.Request.Params["photopath"];
|
|
string employeeNo = context.Request.Params["employeeNo"];
|
|
string name = context.Request.Params["name"];
|
|
//string rightPlan = context.Request.Params["rightPlan"];
|
|
string rightPlan = "1";
|
|
|
|
FangYar.BLL.OA.TBL_EPUIP_ORG bll_ep = new BLL.OA.TBL_EPUIP_ORG();
|
|
string whereStr = " ORG_ID ='" + org_id + "' and EXTEND2 = '0' ";
|
|
List<FangYar.Model.OA.TBL_EPUIP_ORG> list = bll_ep.GetModelList(whereStr);
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
//下发人员数据
|
|
string DvcAddress = list[i].DVCADDRESS;
|
|
string dvcPort = list[i].DVCPORT;
|
|
string userName = list[i].USERNAME;
|
|
string password = list[i].PASSWORD;
|
|
string requestURL = list[i].SERVICEADDR + "/api/User/AddEmployee";
|
|
string requestMethod = "POST";
|
|
string json1 = "{\"DvcAddress\":\"" + DvcAddress + "\",\"dvcPort\":\"" + dvcPort + "\",\"userName\":\"" + userName
|
|
+ "\",\"password\":\"" + password + "\",\"employeeNo\":\"" + employeeNo + "\",\"name\":\"" + name
|
|
+ "\",\"rightPlan\":\"" + rightPlan + "\"}";
|
|
//将数据发送给网络服务 "{\"code\":\"1\",\"msg\":\"下发用户成功\",\"count\":0,\"data\":[]}"
|
|
string a = SendHttpRequest(requestURL, requestMethod, json1).Replace("\\\"", "\"").Trim('"');
|
|
ReturnInfo flag = JsonConvert.DeserializeObject<ReturnInfo>(a);//返回"true","false"
|
|
if (flag.code == "1")
|
|
{
|
|
//下发人员照片
|
|
string path = context.Server.MapPath("~/") + photopath;
|
|
|
|
if (System.IO.File.Exists(path))
|
|
{
|
|
Byte[] imagebytes = System.IO.File.ReadAllBytes(path);
|
|
if (imagebytes.Length == 0)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"人员信息下发,但平台未维护人员的照片信息,请维护后重新下发!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
var base64 = Convert.ToBase64String(imagebytes);
|
|
string requestURI2 = list[i].SERVICEADDR + "/api/Face/AddFace";
|
|
string json2 = "{\"DvcAddress\":\"" + DvcAddress + "\",\"dvcPort\":\"" + dvcPort + "\",\"userName\":\"" + userName
|
|
+ "\",\"password\":\"" + password + "\",\"employeeNo\":\"" + employeeNo
|
|
+ "\",\"imgData\":\"" + base64 + "\"}";
|
|
//将数据发送给网络服务
|
|
ReturnInfo flag2 = JsonConvert.DeserializeObject<ReturnInfo>(SendHttpRequest(requestURI2, requestMethod, json2).Replace("\\\"", "\"").Trim('"'));//返回"true","false"
|
|
if (flag2.code == "1")
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"人员信息下发成功\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + flag.msg + "\",\"data\":[]}";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"人员信息下发,但平台未维护人员的照片信息,请维护后重新下发!\",\"data\":[]}";
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + flag.msg + "\",\"data\":[]}";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"营区人脸门禁设备暂时未维护到平台中,请先维护设备!\",\"data\":[]}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员下发异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员下发");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
private string getEmpNum(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"\",\"data\":\"";
|
|
string empnum = bll.GetEmpNum();
|
|
returnstr += empnum;
|
|
returnstr += "\"}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":\"\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
public static string SendHttpRequest(string requestURI, string requestMethod, string json)
|
|
{
|
|
string ReqResult = "";
|
|
try
|
|
{
|
|
//json格式请求数据
|
|
string requestData = json;
|
|
//拼接URL
|
|
string serviceUrl = requestURI;//string.Format("{0}/{1}", requestURI, requestMethod);
|
|
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
|
|
//post请求
|
|
myRequest.Method = requestMethod;
|
|
if (true)// (requestData != "")
|
|
{
|
|
//utf-8编码
|
|
byte[] buf = System.Text.Encoding.GetEncoding("UTF-8").GetBytes(requestData);
|
|
|
|
myRequest.ContentLength = buf.Length;
|
|
myRequest.Timeout = 5000;
|
|
//指定为json否则会出错
|
|
myRequest.ContentType = "application/json";
|
|
//myRequest.ContentType = "application/x-www-form-urlencoded ";
|
|
myRequest.MaximumAutomaticRedirections = 1;
|
|
myRequest.AllowAutoRedirect = true;
|
|
|
|
Stream newStream = myRequest.GetRequestStream();
|
|
newStream.Write(buf, 0, buf.Length);
|
|
newStream.Close();
|
|
}
|
|
//获得接口返回值
|
|
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
|
|
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.GetEncoding("utf-8"));
|
|
ReqResult = reader.ReadToEnd();
|
|
reader.Close();
|
|
myResponse.Close();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
ReqResult = e.Message;
|
|
}
|
|
return ReqResult;
|
|
}
|
|
|
|
|
|
//机构-人员分组下拉框
|
|
private string getOrgEmpGroupSelectByOrgId(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable dt = bll.getEmpCountByOrgId(orgId);
|
|
string data = "[";
|
|
int index = 0;
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
decimal total = decimal.Parse(dt.Rows[i]["TOTAL"].ToString());
|
|
if (total > 0)
|
|
{
|
|
string pid = dt.Rows[i]["ORG_ID"].ToString();
|
|
if (index > 0) { data += ","; }
|
|
data += "{";
|
|
data += "\"id\":\"" + pid + "\"";
|
|
data += ",\"name\":\"" + dt.Rows[i]["ORG_NAME"].ToString() + "\"";
|
|
data += ",\"pid\":\"0\"";
|
|
data += "}";
|
|
index++;
|
|
//List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.getEmpListByOrgId(pid, "1");
|
|
//喀什部门临时方法
|
|
List<FangYar.Model.TBL.TBL_SYS_EMP_Model> list = bll.getEmpListByDeptId(pid, "1");
|
|
for (int j = 0; j < list.Count; j++)
|
|
{
|
|
if (index > 0) { data += ","; }
|
|
data += "{";
|
|
data += "\"id\":\"" + list[j].USERS_UID + "\"";
|
|
data += ",\"name\":\"" + list[j].EMP_NAME + "\"";
|
|
data += ",\"pid\":\"" + pid + "\"";
|
|
data += "}";
|
|
index++;
|
|
}
|
|
}
|
|
}
|
|
data += "]";
|
|
returnstr += data + "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员分组下拉框异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员分组下拉框");
|
|
return returnstr;
|
|
}
|
|
|
|
//人员在岗统计——手机端
|
|
private string personSta3(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["OrgId"];
|
|
string findDate = context.Request.Params["findDate"];
|
|
if (!string.IsNullOrEmpty(ORG_ID) && !string.IsNullOrEmpty(findDate))
|
|
{
|
|
FangYar.BLL.FIRE.FIRE_ORG bllOrg = new BLL.FIRE.FIRE_ORG();
|
|
FangYar.Model.FIRE.FIRE_ORG modelOrg = bllOrg.GetModel(ORG_ID);
|
|
|
|
DataTable dt = bll.personSta3(ORG_ID, findDate, modelOrg.EXTENDCODE1, modelOrg.ISORG);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":" + code + ",\"msg\":\"参数有误\",\"data\":[]}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员在岗统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员在岗统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//人员在岗统计
|
|
private string personSta2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["OrgId"];
|
|
string findDate = context.Request.Params["findDate"];
|
|
if (!string.IsNullOrEmpty(ORG_ID) && !string.IsNullOrEmpty(findDate))
|
|
{
|
|
DataTable dt = bll.personSta2(ORG_ID, findDate);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":" + code + ",\"msg\":\"参数有误\",\"data\":[]}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "人员在岗统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "人员在岗统计");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//获取Tree 机构-部门-员工(包含所有下级,获取UID)
|
|
private string getOrgTreeList3(HttpContext context)
|
|
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string type = context.Request.Params["type"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
FangYar.BLL.TBL.SysEmpBLL tbll = new BLL.TBL.SysEmpBLL();
|
|
DataTable data = tbll.getOrgTree3(orgId);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
//if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
//{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
//}
|
|
//else
|
|
//{
|
|
// data.Rows[i]["nocheck"] = "true";
|
|
//}
|
|
}
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "获取Tree 机构-部门-员工(包含所有下级,获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "获取Tree 机构-部门-员工(包含所有下级,获取UID)");
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
/// 华为手环健康接口,根据用户账号获取个人信息:
|
|
/// 所属机构、联系方式、消防救援衔、入伍时间、政治面貌、岗位、兴趣爱好
|
|
/// </summary>
|
|
public string GetHealthUserInfoByUid(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string userUid = context.Request.Params["userUid"];
|
|
DataTable model = bll.GetHealthUserInfoByUid(userUid);
|
|
|
|
if (model == null)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"未查询到该人员信息!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":200,\"msg\":\"获取信息成功!\",\"data\":";
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
returnstr += "}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-2,\"msg\":\"error\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "华为手环健康接口,根据用户账号获取个人信息异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "华为手环健康接口,根据用户账号获取个人信息");
|
|
return returnstr;
|
|
}
|
|
|
|
//机构-人员分组下拉框
|
|
private string getEmpListByOrgId(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string Type = context.Request.Params["Type"];
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return "{\"code\": -1,\"msg\":\"参数有误\",\"data\":[]}"; ;
|
|
}
|
|
|
|
//查询机构下所有人员信息
|
|
string sql = "SELECT e.USERS_UID,e.EMP_NAME,e.ORG_ID,e.DEPT_ID FROM TBL_SYS_EMP e WHERE e.ORG_ID = '" + OrgId + "' AND e.IS_DEL = '0' AND e.USERS_UID IS NOT NULL ";
|
|
|
|
switch (Type)
|
|
{
|
|
case "1":
|
|
sql = "SELECT e.USERS_UID,e.EMP_NAME,e.ORG_ID,e.DEPT_ID FROM TBL_SYS_EMP e,(select get_Org_child_list('" + OrgId + "') cids) s WHERE find_in_set(org_id, cids) and e.IS_DEL = '0' AND e.USERS_UID IS NOT NULL";
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
//查询人员信息
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
returnstr = "{\"code\": 200,\"msg\":\"成功\",\"data\":" + FangYar.Common.JsonHelper.ToJson(dt) + "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "机构-人员分组下拉框异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "机构-人员分组下拉框");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//首页获取未在岗信息
|
|
private string homePageLeaveTolerance(HttpContext context)
|
|
{
|
|
string returnstr = "{\"code\": 0,\"msg\":\"没有数据\",\"data\":[]}";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return "{\"code\": -1,\"msg\":\"参数有误\",\"data\":[]}"; ;
|
|
}
|
|
|
|
string sql1 = "";
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
if (is_content == "0")
|
|
{
|
|
sql1 = @"select USERS_UID, EMP_NAME , CASE IS_WORK WHEN '1' THEN '在岗' WHEN '2' THEN '借用' WHEN '3' THEN '休假'
|
|
WHEN '4' THEN '请假' WHEN '5' THEN '学习' WHEN '6' THEN '培训' WHEN '7' THEN '帮工' WHEN '8' THEN '住院'
|
|
WHEN '9' THEN '出差' WHEN '10' THEN '出国' WHEN '11' THEN '滞留部队' WHEN '12' THEN '其他' WHEN '13' THEN '外出'
|
|
ELSE '其他' END as IS_WORKTEXT from tbl_sys_emp where ORG_ID='" + OrgId + "' and IS_DEL = '0' and is_work !='1' and (USERS_UID !='' or USERS_UID is not null) and IS_ADMIN != '1'";
|
|
}
|
|
else
|
|
{
|
|
sql1 = @"select USERS_UID, EMP_NAME , CASE IS_WORK WHEN '1' THEN '在岗' WHEN '2' THEN '借用' WHEN '3' THEN '休假'
|
|
WHEN '4' THEN '请假' WHEN '5' THEN '学习' WHEN '6' THEN '培训' WHEN '7' THEN '帮工' WHEN '8' THEN '住院'
|
|
WHEN '9' THEN '出差' WHEN '10' THEN '出国' WHEN '11' THEN '滞留部队' WHEN '12' THEN '其他' WHEN '13' THEN '外出'
|
|
ELSE '其他' END as IS_WORKTEXT from tbl_sys_emp where org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) ) and IS_DEL = '0' and is_work !='1' and (USERS_UID !='' or USERS_UID is not null) and IS_ADMIN != '1'";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sql1 = @"select USERS_UID, EMP_NAME , CASE IS_WORK WHEN '1' THEN '在岗' WHEN '2' THEN '借用' WHEN '3' THEN '休假'
|
|
WHEN '4' THEN '请假' WHEN '5' THEN '学习' WHEN '6' THEN '培训' WHEN '7' THEN '帮工' WHEN '8' THEN '住院'
|
|
WHEN '9' THEN '出差' WHEN '10' THEN '出国' WHEN '11' THEN '滞留部队' WHEN '12' THEN '其他' WHEN '13' THEN '外出'
|
|
ELSE '其他' END as IS_WORKTEXT from tbl_sys_emp where ORG_ID='" + OrgId + "' and IS_DEL = '0' and is_work !='1' and (USERS_UID !='' or USERS_UID is not null) and IS_ADMIN != '1'";
|
|
}
|
|
|
|
DataTable dt1 = FangYar.Common.MySqlHelper.QueryTable(sql1);
|
|
|
|
List<homePageLeaveToleranceMans> listMans = new List<homePageLeaveToleranceMans>();
|
|
for (int i = 0; i < dt1.Rows.Count; i++)
|
|
{
|
|
listMans.Add(new homePageLeaveToleranceMans()
|
|
{
|
|
uid = dt1.Rows[i]["USERS_UID"].ToString(),
|
|
name = dt1.Rows[i]["EMP_NAME"].ToString(),
|
|
worktext = dt1.Rows[i]["IS_WORKTEXT"].ToString()
|
|
});
|
|
}
|
|
|
|
string uids = "";
|
|
if (dt1.Rows.Count > 0)
|
|
{
|
|
for (int i = 0; i < dt1.Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
uids += "'" + dt1.Rows[i]["USERS_UID"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
uids += ",'" + dt1.Rows[i]["USERS_UID"].ToString() + "'";
|
|
}
|
|
}
|
|
|
|
string sql2 = @"with t1 as
|
|
(
|
|
select '1' as tasktype,( SELECT d.title FROM DICTIONARY d WHERE d.id = lb.L_TYPE ) DIC_TEXT,lb.* from(
|
|
select ppl_id, max(S_TIME) as S_TIME from oa_leave where PPL_ID in (" + uids + @") AND STATE='1' and IS_RETURN !='2' GROUP BY ppl_id
|
|
)la left join oa_leave lb on la.ppl_id = lb.ppl_id and la.S_TIME = lb.S_TIME
|
|
|
|
union all
|
|
|
|
select '2' as tasktype,( SELECT d.title FROM DICTIONARY d WHERE d.id = tb.L_TYPE ) DIC_TEXT,tb.* from(
|
|
select ppl_id, max(S_TIME) as S_TIME from oa_tolerance where PPL_ID in (" + uids + @") AND STATE='1' and IS_RETURN !='2' GROUP BY ppl_id
|
|
)ta left join oa_tolerance tb on ta.ppl_id = tb.ppl_id and ta.S_TIME = tb.S_TIME
|
|
)
|
|
select t1.*from(
|
|
select ppl_id, max(S_TIME) as S_TIME from t1 GROUP BY ppl_id
|
|
)oa left join t1 on oa.ppl_id = t1.ppl_id and oa.S_TIME = t1.S_TIME ORDER BY t1.S_TIME desc";
|
|
|
|
DataTable dt2 = FangYar.Common.MySqlHelper.QueryTable(sql2);
|
|
string olmanString = "";
|
|
for (int i = 0; i < dt2.Rows.Count; i++)
|
|
{
|
|
olmanString += "'" + dt2.Rows[i]["PPL_ID"].ToString() + "',";
|
|
}
|
|
|
|
List<homePageLeaveToleranceMans> listMansNotLT = listMans.Where(p => !olmanString.Contains("'" + p.uid + "'")).ToList<homePageLeaveToleranceMans>();
|
|
|
|
for (int i = 0; i < listMansNotLT.Count; i++)
|
|
{
|
|
DataRow newRow = dt2.NewRow();
|
|
newRow["tasktype"] = "3";
|
|
newRow["DIC_TEXT"] = listMansNotLT[i].worktext;
|
|
newRow["ID"] = "";
|
|
newRow["PPL_ID"] = listMansNotLT[i].uid;
|
|
newRow["PPL_NAME"] = listMansNotLT[i].name;
|
|
newRow["L_TYPE"] = "";
|
|
newRow["S_TIME"] = "";
|
|
newRow["E_TIME"] = "";
|
|
|
|
dt2.Rows.Add(newRow);
|
|
|
|
}
|
|
|
|
returnstr = "{\"code\": 0,\"msg\":\"成功\",\"data\":" + FangYar.Common.JsonHelper.ToJson(dt2) + "}";
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "首页获取未在岗信息异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "首页获取未在岗信息");
|
|
return returnstr;
|
|
}
|
|
|
|
//机构及所有下属机构(包含行政区划编码)
|
|
private string getOrgCityOnlyTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgCityOnlyTree(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员操作请求", "获取机构及所有下属机构(只有机构)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员操作请求", "获取机构及所有下属机构(只有机构)");
|
|
return returnstr;
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
public class homePageLeaveToleranceMans
|
|
{
|
|
public string uid { get; set; }
|
|
public string name { get; set; }
|
|
public string worktext { get; set; }
|
|
}
|
|
}
|