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.
1690 lines
72 KiB
1690 lines
72 KiB
11 months ago
|
using Newtonsoft.Json;
|
||
|
using Spire.Xls;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.IO;
|
||
|
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)
|
||
|
{
|
||
|
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 "getOrgTreeList3": //获取Tree 机构-部门 - 员工(包含所有下级,获取UID)
|
||
|
returnstr = getOrgTreeList3(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 "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 "personSta2":
|
||
|
returnstr = personSta2(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;
|
||
|
}
|
||
|
|
||
|
context.Response.Write(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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return 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\":[]";
|
||
|
}
|
||
|
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\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
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 searchAccess = context.Request.Params["searchAccess"];
|
||
|
string is_content = context.Request.Params["is_content"];
|
||
|
|
||
|
string pOrgID = "";
|
||
|
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;
|
||
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
||
|
{
|
||
|
pOrgID = treeID;
|
||
|
if (is_content == "1")
|
||
|
{
|
||
|
where = "( find_in_set(org_id, cids) or find_in_set(DEPT_ID, cids) ) ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
where = "( ORG_ID = '" + treeID + "' or DEPT_ID = '" + treeID + "')";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
|
||
|
pOrgID = OrgId;
|
||
|
if (is_content == "1")
|
||
|
{
|
||
|
where = "( find_in_set(org_id, cids) or find_in_set(DEPT_ID, cids) ) ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
where = "( ORG_ID = '" + OrgId + "' or DEPT_ID = '" + OrgId + "')";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(keyword))
|
||
|
{
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += "( emp_name 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(searchAccess))
|
||
|
{
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += "IS_ACCESS = '" + searchAccess + "'";
|
||
|
}
|
||
|
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += " is_del = '0'";
|
||
|
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 ", pOrgID);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
||
|
}
|
||
|
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 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 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 strWhere = " EMP_NUM ='" + empNum + "' and ORG_ID ='" + orgId + "' and EMP_NUM is not null";
|
||
|
DataTable dt = bll.GetTable(strWhere);
|
||
|
if (dt.Rows.Count > 0)
|
||
|
{
|
||
|
msg = "单位内编号重复,请修改后添加!";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//员工表
|
||
|
FangYar.Model.TBL.TBL_SYS_EMP_Model model = new Model.TBL.TBL_SYS_EMP_Model();
|
||
|
model.USERS_UID = usersUid;
|
||
|
model.EMP_NAME = empName;
|
||
|
model.EMP_NUM = empNum;
|
||
|
model.EMP_SEX = empSex;
|
||
|
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.DURING_ACCESS_PERIOD = during_access_period;
|
||
|
model.ISDRIVER = isdriver;
|
||
|
model.FILENUM = filenum;
|
||
|
model.PERMISSIONNUM = permissionnum;
|
||
|
model.FIRSTCARD = firstcard;
|
||
|
model.EFFECTIVETIME = effictivetime;
|
||
|
model.PERMITTEDORGAN = permittedorgan;
|
||
|
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 (bll.AddEmp(model))
|
||
|
{
|
||
|
msg = "添加成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else { msg = "添加失败!"; }
|
||
|
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
msg = e.Message;
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
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 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 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"];
|
||
|
|
||
|
//员工表
|
||
|
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.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.DURING_ACCESS_PERIOD = during_access_period;
|
||
|
model.ISDRIVER = isdriver;
|
||
|
model.FILENUM = filenum;
|
||
|
model.PERMISSIONNUM = permissionnum;
|
||
|
model.FIRSTCARD = firstcard;
|
||
|
model.EFFECTIVETIME = effictivetime;
|
||
|
model.PERMITTEDORGAN = permittedorgan;
|
||
|
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 (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 = "修改失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
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
|
||
|
{
|
||
|
msg = "修改失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//删除人员
|
||
|
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;
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"delempdvc\":\"" + delempdvc + "\"}";
|
||
|
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.QueryList(1, 1, strWhere, "");
|
||
|
data = FangYar.Common.JsonHelper.ToJson(list[0]);
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "获取失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
//上传excel
|
||
|
private string impExcel(HttpContext context)
|
||
|
{
|
||
|
string returnStr = "";
|
||
|
string msg = "", successInfo = "", errInfo = "", updateInfo = "";
|
||
|
string org_id = "";
|
||
|
try
|
||
|
{
|
||
|
org_id = context.Request.Params["org_id"];
|
||
|
|
||
|
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 + ") order by MOD_CODE , DIC_ORDER");
|
||
|
//定义四个新的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();
|
||
|
|
||
|
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;
|
||
|
|
||
|
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)
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
if (bllEmp.AddEmp(modelEmp))
|
||
|
{
|
||
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "添加成功!*";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
successInfo += empOrder + ":" + modelEmp.EMP_NAME + "*未添加成功!";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
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;
|
||
|
|
||
|
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;
|
||
|
|
||
|
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;
|
||
|
|
||
|
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 + "此身份证号属岗外人员,已更新为岗内人员!*";
|
||
|
}
|
||
|
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 + "\"}";
|
||
|
}
|
||
|
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].Text;
|
||
|
}
|
||
|
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 page = context.Request.Params["page"];
|
||
|
string limit = context.Request.Params["limit"];
|
||
|
string searchTime = context.Request.Params["searchTime"];
|
||
|
string searchAccess = context.Request.Params["searchAccess"];
|
||
|
string is_content = context.Request.Params["is_content"];
|
||
|
|
||
|
string where = null;
|
||
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
||
|
{
|
||
|
if (is_content == "1")
|
||
|
{
|
||
|
where = "(org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) ) ";
|
||
|
where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids))) ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
where = " (ORG_ID = '" + treeID + "'";
|
||
|
where += " or DEPT_ID = '" + treeID + "')";
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (is_content == "1")
|
||
|
{
|
||
|
where = "(org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids)) ";
|
||
|
where += " or DEPT_ID in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids))) ";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
where = " (ORG_ID = '" + OrgId + "'";
|
||
|
where += " or DEPT_ID = '" + OrgId + "')";
|
||
|
}
|
||
|
|
||
|
}
|
||
|
if (!string.IsNullOrEmpty(keyword))
|
||
|
{
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += "( emp_name 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(searchAccess))
|
||
|
{
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += "IS_ACCESS = '" + searchAccess + "'";
|
||
|
}
|
||
|
|
||
|
if (where != null)
|
||
|
{
|
||
|
where += " and ";
|
||
|
}
|
||
|
where += " is_del = '0'";
|
||
|
int count = bll.GetRecordCount(where);
|
||
|
if (count == 0)
|
||
|
{
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
System.Data.DataTable data = bll.expExcel(1, count, where, " emp_name ");
|
||
|
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("MAR_NAME", "婚姻状况");
|
||
|
cellHeaders.Add("IS_WORK_NAME", "在岗情况");
|
||
|
cellHeaders.Add("ENLISTED_TIME", "入伍时间");
|
||
|
|
||
|
|
||
|
cellHeaders.Add("IS_ACCESS", "是否允许外出");
|
||
|
cellHeaders.Add("DURING_ACCESS_PERIOD", "允许出入时间段");
|
||
|
|
||
|
FangYar.Common.NPOIExcelHelper.ExportByWeb(data, null, cellHeaders, DateTime.Now.ToString("yyyyMMddHHmmss") + "人员信息表.xls");
|
||
|
}
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
}
|
||
|
}
|
||
|
//人员统计
|
||
|
private string personSta(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='" + ORG_ID + "'";
|
||
|
strWhere += " and is_del='0'";
|
||
|
DataTable dt = bll.personSta(strWhere);
|
||
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "获取失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
||
|
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
|
||
|
{
|
||
|
msg = "获取失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//人员实力统计
|
||
|
private string personStrengthSta(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='" + ORG_ID + "'";
|
||
|
DataTable dt = bll.personStrengthSta(strWhere);
|
||
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
||
|
}
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "获取失败!";
|
||
|
}
|
||
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
||
|
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\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
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
|
||
|
{
|
||
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}";
|
||
|
}
|
||
|
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\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
|
||
|
private string getEmpNum(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
returnstr = "{\"code\":1,\"msg\":\"\",\"data\":\"";
|
||
|
string empnum = bll.GetEmpNum();
|
||
|
returnstr += empnum;
|
||
|
returnstr += "\"}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":\"\"}";
|
||
|
}
|
||
|
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\":[]}";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
public bool IsReusable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|