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.
982 lines
42 KiB
982 lines
42 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Web.Script.Serialization;
|
|
using FangYar.Model;
|
|
using FangYar.BLL;
|
|
using System.IO;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class PersonAccessHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TBL_PERSONACCESS bll = new FangYar.BLL.TBL_PERSONACCESS();
|
|
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 "List":
|
|
returnstr = perList(context);
|
|
break;
|
|
case "APPCountList":
|
|
returnstr = APPCountList(context);
|
|
break;
|
|
case "EpuReport":
|
|
returnstr = EpuReport(context);
|
|
break;
|
|
case "personAccessSta":
|
|
returnstr = personAccessSta(context);
|
|
break;
|
|
case "personAccessStaForProf":
|
|
returnstr = personAccessStaForProf(context);
|
|
break;
|
|
case "personTravel":
|
|
returnstr = personTravel(context);
|
|
break;
|
|
case "TravelList":
|
|
returnstr = TravelList(context);
|
|
break;
|
|
case "expList":
|
|
expList(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
//列表数据获取
|
|
private string perList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
//判断是否APP或者小程序访问
|
|
if (Common.WebCommonUtil.IsPhoneRequest(context))
|
|
{
|
|
//增加上级转换机关机构数据转换
|
|
OrgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(OrgId);
|
|
}
|
|
|
|
string EmpId = context.Request.Params["EmpId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string startTime = context.Request.Params["startTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string IS_Attendance = context.Request.Params["IS_Attendance"] + "";
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
string is_content = context.Request.Params["is_content"];//2022-09-20 重新启用包含下级查询 页面默认不勾选
|
|
//string is_content = context.Request.Params["is_content"];//因为数据量太多,递归查询速度太慢,所以屏蔽无法查询下级单位数据
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " 1=1 ";
|
|
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
OrgId = treeID;
|
|
}
|
|
|
|
//判断是否和上级营区同驻地
|
|
string pOrgId = "";
|
|
|
|
try
|
|
{
|
|
//查询当前单位是否和上级单位同一驻地
|
|
string sqlStr1 = " SELECT IS_TOP_CAMP,PID from fire_org WHERE ORG_ID = '" + OrgId + "' ";
|
|
|
|
var dt1 = Common.MySqlHelper.QueryTable(sqlStr1);
|
|
|
|
if (dt1.Rows[0]["IS_TOP_CAMP"] + "" == "1")
|
|
{
|
|
pOrgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(dt1.Rows[0]["PID"] + "");
|
|
|
|
//var itemOrg = OrgId;
|
|
//OrgId = pOrgId;
|
|
//pOrgId = itemOrg;
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//where = " ORG_ID = '" + OrgId + "'";
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + OrgId + "' )";
|
|
////判断是否和上级营区同驻地
|
|
//if (string.IsNullOrWhiteSpace(pOrgId))
|
|
//{
|
|
// where += " and ( ORG_ID = '" + OrgId + "' )";
|
|
//}
|
|
//else
|
|
//{
|
|
// where += " and ( ORG_ID = '" + OrgId + "' or ORG_ID = '" + pOrgId + "' )";
|
|
//}
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + selDeptId + "' and DEPT_ID <> '6c9972c7ef2b4388b329003738962af7' ) ";
|
|
}
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + DeptID + "' and DEPT_ID <> '6c9972c7ef2b4388b329003738962af7' ) ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
if (!startTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
{
|
|
if (!endTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( name like '%" + keyword + "%' or ADDR like '%" + keyword + "%' or EXTEND2 like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (IS_Attendance != "1")
|
|
{
|
|
if (string.IsNullOrWhiteSpace(pOrgId))
|
|
{
|
|
where += " and EXTEND3 not in (SELECT EPUIP_ID from tbl_epuip_org where ORG_ID = '" + OrgId + "' and IS_Attendance='1') ";
|
|
}
|
|
else
|
|
{
|
|
where += " and EXTEND3 not in (SELECT EPUIP_ID from tbl_epuip_org where (ORG_ID = '" + OrgId + "' or ORG_ID = '" + pOrgId + "' ) and IS_Attendance='1') ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(EmpId))
|
|
{
|
|
where += " or EMPID = '" + EmpId + "' ";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where, OrgId);
|
|
//int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
//List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, "");
|
|
//returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
string data = "[";
|
|
List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, " (START_TIME) DESC ", OrgId);
|
|
//List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, " (START_TIME) DESC ");
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
string pic1 = "";
|
|
string pic2 = "";
|
|
if (list[i].PICTURE != null && list[i].PICTURE.ToString() != "")
|
|
{
|
|
pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
|
|
}
|
|
if (list[i].CLOSEUP_PIC != null && list[i].CLOSEUP_PIC.ToString() != "")
|
|
{
|
|
pic2 = Convert.ToBase64String((byte[])list[i].CLOSEUP_PIC);
|
|
}
|
|
|
|
data += "{\"ID\":\"" + list[i].ID + "\",\"NAME\":\"" + list[i].NAME.Replace("\0", "") + "\",\"EMPID\":\"" + list[i].EMPID + "\",\"SEX\":\"" + list[i].SEX + "\",\"PROF\":\"" + list[i].PROF + "\",\"START_TIMESTAMP\":\"" + list[i].START_TIMESTAMP + "\",\"START_TIME\":\"" + list[i].START_TIME + "\",";
|
|
data += "\"CAMERA_ID\":\"" + list[i].CAMERA_ID + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"INOROUT\":\"" + list[i].INOROUT + "\",\"ADDR\":\"" + list[i].ADDR + "\",\"ORG_NAME\":\"" + list[i].ORG_NAME + "\",";
|
|
data += "\"EXTEND1\":\"" + list[i].EXTEND1 + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4 + "\",";
|
|
data += "\"CLOSEUP_PIC_URL\":\"" + list[i].CLOSEUP_PIC_URL + "\",";
|
|
data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\"}";
|
|
|
|
if (i != list.Count - 1)
|
|
{
|
|
data += ",";
|
|
}
|
|
}
|
|
returnstr += data + "]";
|
|
}
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员出入操作请求", "列表数据获取异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员出入操作请求", "列表数据获取");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//列表数据获取
|
|
private string perListNew(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
//判断是否APP或者小程序访问
|
|
if (Common.WebCommonUtil.IsPhoneRequest(context))
|
|
{
|
|
//增加上级转换机关机构数据转换
|
|
OrgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(OrgId);
|
|
}
|
|
|
|
string EmpId = context.Request.Params["EmpId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string startTime = context.Request.Params["startTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string IS_Attendance = context.Request.Params["IS_Attendance"] + "";
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
string is_content = context.Request.Params["is_content"];//2022-09-20 重新启用包含下级查询 页面默认不勾选
|
|
//string is_content = context.Request.Params["is_content"];//因为数据量太多,递归查询速度太慢,所以屏蔽无法查询下级单位数据
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " 1=1 ";
|
|
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
OrgId = treeID;
|
|
}
|
|
|
|
//判断是否和上级营区同驻地
|
|
string pOrgId = "";
|
|
|
|
try
|
|
{
|
|
//查询当前单位是否和上级单位同一驻地
|
|
string sqlStr1 = " SELECT IS_TOP_CAMP,PID from fire_org WHERE ORG_ID = '" + OrgId + "' ";
|
|
|
|
var dt1 = Common.MySqlHelper.QueryTable(sqlStr1);
|
|
|
|
if (dt1.Rows[0]["IS_TOP_CAMP"] + "" == "1")
|
|
{
|
|
pOrgId = Common.WebCommonUtil.GetOrgIdUpLevelToDownLevel(dt1.Rows[0]["PID"] + "");
|
|
|
|
//var itemOrg = OrgId;
|
|
//OrgId = pOrgId;
|
|
//pOrgId = itemOrg;
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//where = " ORG_ID = '" + OrgId + "'";
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + OrgId + "' )";
|
|
////判断是否和上级营区同驻地
|
|
//if (string.IsNullOrWhiteSpace(pOrgId))
|
|
//{
|
|
// where += " and ( ORG_ID = '" + OrgId + "' )";
|
|
//}
|
|
//else
|
|
//{
|
|
// where += " and ( ORG_ID = '" + OrgId + "' or ORG_ID = '" + pOrgId + "' )";
|
|
//}
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + selDeptId + "' and DEPT_ID <> '6c9972c7ef2b4388b329003738962af7' ) ";
|
|
}
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + DeptID + "' and DEPT_ID <> '6c9972c7ef2b4388b329003738962af7' ) ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
if (!startTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
{
|
|
if (!endTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( name like '%" + keyword + "%' or ADDR like '%" + keyword + "%' or EXTEND2 like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (IS_Attendance != "1")
|
|
{
|
|
if (string.IsNullOrWhiteSpace(pOrgId))
|
|
{
|
|
where += " and EXTEND3 not in (SELECT EPUIP_ID from tbl_epuip_org where ORG_ID = '" + OrgId + "' and IS_Attendance='1') ";
|
|
}
|
|
else
|
|
{
|
|
where += " and EXTEND3 not in (SELECT EPUIP_ID from tbl_epuip_org where (ORG_ID = '" + OrgId + "' or ORG_ID = '" + pOrgId + "' ) and IS_Attendance='1') ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(EmpId))
|
|
{
|
|
where += " or EMPID = '" + EmpId + "' ";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where, OrgId);
|
|
//int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
//List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, "");
|
|
//returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
string data = "[";
|
|
List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, " (START_TIME) DESC ", OrgId);
|
|
//List<FangYar.Model.TBL_PERSONACCESS> list = bll.QueryList(pageIndex, pageSize, where, " (START_TIME) DESC ");
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
string pic1 = "";
|
|
string pic2 = "";
|
|
if (list[i].PICTURE != null && list[i].PICTURE.ToString() != "")
|
|
{
|
|
pic1 = Convert.ToBase64String((byte[])list[i].PICTURE);
|
|
}
|
|
if (list[i].CLOSEUP_PIC != null && list[i].CLOSEUP_PIC.ToString() != "")
|
|
{
|
|
pic2 = Convert.ToBase64String((byte[])list[i].CLOSEUP_PIC);
|
|
}
|
|
|
|
data += "{\"ID\":\"" + list[i].ID + "\",\"NAME\":\"" + list[i].NAME.Replace("\0", "") + "\",\"EMPID\":\"" + list[i].EMPID + "\",\"SEX\":\"" + list[i].SEX + "\",\"PROF\":\"" + list[i].PROF + "\",\"START_TIMESTAMP\":\"" + list[i].START_TIMESTAMP + "\",\"START_TIME\":\"" + list[i].START_TIME + "\",";
|
|
data += "\"CAMERA_ID\":\"" + list[i].CAMERA_ID + "\",\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"INOROUT\":\"" + list[i].INOROUT + "\",\"ADDR\":\"" + list[i].ADDR + "\",\"ORG_NAME\":\"" + list[i].ORG_NAME + "\",";
|
|
data += "\"EXTEND1\":\"" + list[i].EXTEND1 + "\",\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\",\"EXTEND4\":\"" + list[i].EXTEND4 + "\",";
|
|
data += "\"CLOSEUP_PIC_URL\":\"" + list[i].CLOSEUP_PIC_URL + "\",";
|
|
data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\"}";
|
|
|
|
if (i != list.Count - 1)
|
|
{
|
|
data += ",";
|
|
}
|
|
}
|
|
returnstr += data + "]";
|
|
}
|
|
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员出入操作请求", "列表数据获取异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员出入操作请求", "列表数据获取");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//查询
|
|
private string APPCountList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string strSql = "select * from viewinorout where org_id = '" + orgId + "'";
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
returnstr += "\"count\":" + 1 + ",\"data\":";
|
|
|
|
DataTable dt = bll.GetAPPList(strSql);
|
|
//DataTable dt = new DataTable();
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
returnstr += "{ ";
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
returnstr += "\"" + dt.Rows[i]["TYPE"] + "\":" + "\"" + dt.Rows[i]["NUM"] + "\"";
|
|
}
|
|
else
|
|
{
|
|
returnstr += ",\"" + dt.Rows[i]["TYPE"] + "\":" + "\"" + dt.Rows[i]["NUM"] + "\"";
|
|
}
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
else
|
|
{
|
|
returnstr += "{ }";
|
|
}
|
|
|
|
//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 EpuReport2(HttpContext context)
|
|
//{
|
|
// WriteLog("进入!");
|
|
// string returnstr = "";
|
|
// try
|
|
// {
|
|
// WriteLog(JsonConvert.SerializeObject(context.Request.QueryString));
|
|
// string context_str = JsonConvert.SerializeObject(context.Request.Params);
|
|
// WriteLog("\r\n" + context_str);
|
|
// string libraryId = context.Request.Params["libraryId"];
|
|
// string idNumber = context.Request.Params["idNumber"];
|
|
// string name = context.Request.Params["name"];
|
|
// string result = context.Request.Params["result"];
|
|
// string authTime = context.Request.Params["authTime"];
|
|
// string deviceNumber = context.Request.Params["deviceNumber"];
|
|
// string deviceName = context.Request.Params["deviceName"];
|
|
// string avatar = context.Request.Params["avatar"];
|
|
// string visitorFlag = context.Request.Params["visitorFlag"];
|
|
// string icNumber = context.Request.Params["icNumber"];
|
|
// string return_str = "libraryId=" + libraryId + "&idNumber=" + idNumber + "&name=" + name + "&result=" + result + "&authTime=" + authTime + "&deviceNumber=" + deviceNumber + "&deviceNamer=" + deviceName + "&visitorFlag=" + visitorFlag + "&avatar=" + avatar + "&icNumber=" + icNumber;
|
|
// WriteLog("\r\n" + return_str);
|
|
|
|
// FangYar.Model.MJ_DATA mj_data = new FangYar.Model.MJ_DATA();
|
|
// mj_data.libraryId = libraryId;
|
|
// mj_data.idNumber = idNumber;
|
|
// mj_data.name = name;
|
|
// mj_data.result = result;
|
|
// mj_data.authTime = authTime;
|
|
// mj_data.deviceNumber = deviceNumber;
|
|
// mj_data.deviceName = deviceName;
|
|
// mj_data.avatar = avatar;
|
|
// mj_data.visitorFlag = visitorFlag;
|
|
// mj_data.icNumber = icNumber;
|
|
// returnstr += "返回值:";
|
|
// bool flag = bll.MjData_Add(mj_data);
|
|
// returnstr += flag;
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// WriteLog("\r\n错误!" + e);
|
|
// returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// }
|
|
// return returnstr;
|
|
//}
|
|
|
|
//石河子硬件推送的数据接收
|
|
|
|
private string EpuReport(HttpContext context)
|
|
{
|
|
WriteLog("进入!");
|
|
HttpRequest request = context.Request;
|
|
Stream stream = request.InputStream;
|
|
string data = string.Empty;
|
|
string response = string.Empty;
|
|
bool isadd = false;
|
|
if (stream.Length != 0)
|
|
{
|
|
try
|
|
{
|
|
StreamReader streamReader = new StreamReader(stream);
|
|
data = streamReader.ReadToEnd();
|
|
#region 用于传递数据的输出
|
|
|
|
if (stream.Length != 0)
|
|
{
|
|
WriteLog(data.ToString());
|
|
}
|
|
#endregion
|
|
|
|
string redata_string = data.Replace(Environment.NewLine, "");
|
|
string redata_string_json = "[";
|
|
if (redata_string.Contains("} {"))
|
|
{
|
|
redata_string = redata_string.Replace("} {", "},{");
|
|
}
|
|
else if (redata_string.Contains("}{"))
|
|
{
|
|
redata_string = redata_string.Replace("}{", "},{");
|
|
}
|
|
redata_string_json += redata_string;
|
|
redata_string_json += "]";
|
|
|
|
bool flag = false;
|
|
try
|
|
{
|
|
JArray jsonStr = JsonConvert.DeserializeObject<JArray>(redata_string_json);
|
|
flag = true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
flag = false;
|
|
}
|
|
if (flag)
|
|
{
|
|
List<FangYar.Model.MJ_DATA> rz_data = JsonConvert.DeserializeObject<List<FangYar.Model.MJ_DATA>>(redata_string_json);
|
|
for (int i = 0; i < rz_data.Count; i++)
|
|
{
|
|
bll.MjData_Add(rz_data[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
WriteLog("\r\n 数据有误: 字符串不是json格式");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
WriteLog(e.Message);
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员出入操作请求", "石河子门禁数据接收异常:" + e);
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
WriteLog("输入流的长度为0!");
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "人员出入操作请求", "石河子门禁数据接收");
|
|
|
|
if (isadd == true)
|
|
{
|
|
return "true";
|
|
}
|
|
else
|
|
{
|
|
return "false";
|
|
}
|
|
|
|
}
|
|
|
|
private void WriteLog(string msg)
|
|
{
|
|
string path = AppDomain.CurrentDomain.BaseDirectory + "log\\PersonAccessHandler\\";
|
|
string filename = DateTime.Now.ToString("yyyyMMdd") + ".txt";
|
|
|
|
if (Directory.Exists(path) == false)//如果不存在就创建文件夹
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
FileInfo file = new FileInfo(path + filename);
|
|
if (!file.Exists)
|
|
{
|
|
FileStream fs;
|
|
fs = File.Create(path + filename);
|
|
fs.Close();
|
|
}
|
|
|
|
using (FileStream fs = new FileStream(path + filename, FileMode.Append, FileAccess.Write))
|
|
{
|
|
using (StreamWriter sw = new StreamWriter(fs))
|
|
{
|
|
sw.WriteLine("时间:" + DateTime.Now.ToString() + " 信息:" + msg);
|
|
}
|
|
}
|
|
}
|
|
//请假统计
|
|
private string personAccessSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and tp.ORG_ID='" + ORG_ID + "'";
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date_format('" + S_Time + "','%Y-%m-%d') < START_TIME";
|
|
strWhere += " and date_format('" + E_Time + "','%Y-%m-%d')> START_TIME";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(START_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
DataTable dt = bll.personAccessStaForProf(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 personAccessStaForProf(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
strWhere += " and tp.ORG_ID in (select org_id from fire_org o,(select get_Org_child_list('" + ORG_ID + "') cids ) s where find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and tp.ORG_ID='" + ORG_ID + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date_format('" + S_Time + "','%Y-%m-%d') < START_TIME";
|
|
strWhere += " and date_format('" + E_Time + "','%Y-%m-%d')> START_TIME";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(START_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
DataTable dt = bll.personAccessStaForProf(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 personTravel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string searchIDCard = context.Request.Params["searchIDCard"];
|
|
string searchName = context.Request.Params["searchName"];
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and (ORG_ID ='" + OrgId + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + OrgId + "') )";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(searchTime))
|
|
{
|
|
where += " and '" + searchTime + "'= date_format(t.start_time,'%Y-%m')";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchIDCard))
|
|
{
|
|
where += " and extend2= '" + searchIDCard + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchName))
|
|
{
|
|
where += " and name= '" + searchName + "'";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
|
|
//获取人员出入表中查询条件下的重复人员数据
|
|
DataTable dt = bll.getPAccessRepeat(where);
|
|
returnstr += "\"count\":" + dt.Rows.Count + ",\"data\":";
|
|
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 TravelList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string searchIDCard = context.Request.Params["searchIDCard"];
|
|
|
|
string where = " 1=1 ";
|
|
//if (!string.IsNullOrEmpty(OrgId))
|
|
//{
|
|
// where += " and ORG_ID ='" + OrgId + "'";
|
|
//}
|
|
if (!string.IsNullOrEmpty(searchTime))
|
|
{
|
|
where += " and '" + searchTime + "'= date_format(t.start_time,'%Y-%m')";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchIDCard))
|
|
{
|
|
where += " and extend2= '" + searchIDCard + "'";
|
|
}
|
|
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
|
|
//获取人员出入记录
|
|
DataTable dt = bll.TravelList(where);
|
|
returnstr += "\"count\":" + dt.Rows.Count + ",\"data\":";
|
|
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;
|
|
}
|
|
|
|
public void expList(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string startTime = context.Request.Params["startTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string IS_Attendance = context.Request.Params["IS_Attendance"] + "";
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
string is_content = context.Request.Params["is_content"];
|
|
string where = " 1=1 ";
|
|
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
OrgId = treeID;
|
|
}
|
|
//where = " ORG_ID = '" + OrgId + "'";
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + OrgId + "' )";
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + selDeptId + "' ) ";
|
|
}
|
|
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and EMPID in ( SELECT ID from tbl_sys_emp WHERE ORG_ID='" + OrgId + "' and DEPT_ID='" + DeptID + "' ) ";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
if (!startTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time >= date_format('" + startTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(endTime))
|
|
{
|
|
if (!endTime.Contains("请选择"))
|
|
{
|
|
where += " and start_time <= date_format('" + endTime + "','%Y-%m-%d %H:%i:%s')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( name like '%" + keyword + "%' or ADDR like '%" + keyword + "%' or EXTEND2 like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (IS_Attendance != "1")
|
|
{
|
|
where += " and EXTEND3 not in (SELECT EPUIP_ID from tbl_epuip_org where ORG_ID = '" + OrgId + "' and IS_Attendance='1') ";
|
|
}
|
|
|
|
int count = bll.GetRecordCount(where, OrgId);
|
|
if (count == 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
where += " order by (START_TIMESTAMP) DESC ";
|
|
System.Data.DataTable data = bll.expExcel(where, OrgId);
|
|
System.Collections.Generic.Dictionary<string, string> cellHeaders = new System.Collections.Generic.Dictionary<string, string>();
|
|
cellHeaders.Add("NAME", "姓名");
|
|
cellHeaders.Add("START_TIME", "时间");
|
|
cellHeaders.Add("ADDR", "地址");
|
|
cellHeaders.Add("ORG_NAME", "机构");
|
|
|
|
FangYar.Common.NPOIExcelHelper.ExportByWeb(data, null, cellHeaders, DateTime.Now.ToString("yyyyMMdd") + "人员出入表.xls");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "人员出入操作请求", "人员出入导出异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "人员出入操作请求", "人员出入导出");
|
|
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|