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.
428 lines
16 KiB
428 lines
16 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// SysOrgHandler 的摘要说明
|
|
/// </summary>
|
|
public class SysOrgHandler : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.TBL.SysOrgBLL bll = new BLL.TBL.SysOrgBLL();
|
|
private FangYar.BLL.ToTree_BLL blltree = new BLL.ToTree_BLL();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "营区操作请求", "");
|
|
|
|
context.Response.ContentType = "text/json";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = GetModelList(context);
|
|
break;
|
|
case "GetFaceDatabaseList":
|
|
returnstr = GetFaceDatabaseList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddModel(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditModel(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelModel(context);
|
|
break;
|
|
case "OrgTree":
|
|
returnstr = GetOrgTree(context);
|
|
break;
|
|
case "getOrgName":
|
|
returnstr = getOrgName(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetModelList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string keywords = context.Request.Params["keywords"];
|
|
string limit = context.Request.Params["limit"];
|
|
string page = context.Request.Params["page"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = null;
|
|
if (!string.IsNullOrEmpty(keywords))
|
|
{
|
|
where = "ORG_CODE like '" + keywords + "' or ORG_NAME like '" + keywords + "' or ORG_ADDR like '" + keywords + "' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.Count(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.TBL.TBL_SYS_ORG_Model> list = bll.QueryList(pageIndex, pageSize, where, null);
|
|
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, "营区操作请求", "查询");
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "营区操作请求", "查询");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 人脸库模拟数据
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetFaceDatabaseList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string keywords = context.Request.Params["keywords"];
|
|
string org_id = context.Request.Params["org_id"];
|
|
string limit = context.Request.Params["limit"];
|
|
string page = context.Request.Params["page"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(limit)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
|
|
var pindex = (pageIndex - 1) * pageSize;
|
|
pindex = pindex < 0 ? 0 : pindex;
|
|
|
|
string where = " WHERE find_in_set(org_id,cids) and TYPE = '0' ";
|
|
if (!string.IsNullOrEmpty(keywords))
|
|
{
|
|
where += " and Org_Name like '%" + keywords + "%' ";
|
|
}
|
|
string sqlCount = " SELECT count(1) c from fire_org ,(select get_Org_child_list('" + org_id + "') cids ) s " + where;
|
|
string sqlQuery = " SELECT org_id,org_name,(SELECT count(1) from tbl_sys_emp e WHERE e.ORG_ID = fire_org.ORG_ID and IS_DEL = '0' and is_admin = '0' ) empCount from " +
|
|
" fire_org ,(select get_Org_child_list('" + org_id + "') cids ) s " + where +
|
|
" ORDER BY EXTENDCODE4 limit " + pindex + " , " + pageSize;
|
|
var dtCount = FangYar.Common.MySqlHelper.QueryTable(sqlCount);
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = Convert.ToInt32(dtCount.Rows[0][0] + "");
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
var dt = FangYar.Common.MySqlHelper.QueryTable(sqlQuery);
|
|
|
|
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, "营区操作请求", "查询");
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "营区操作请求", "查询");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
//添加
|
|
private string AddModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string PID = context.Request.Params["PID"];
|
|
string orgCode = context.Request.Params["orgCode"];
|
|
string orgName = context.Request.Params["orgName"];
|
|
string orgAddr = context.Request.Params["orgAddr"];
|
|
string orgType = context.Request.Params["orgType"];
|
|
string orgPerson = context.Request.Params["orgPerson"];
|
|
string orgTel = context.Request.Params["orgTel"];
|
|
string idDel = context.Request.Params["idDel"];
|
|
string areaID = context.Request.Params["areaID"];
|
|
string areaIDs = context.Request.Params["areaIDs"];
|
|
if (string.IsNullOrEmpty(orgCode))
|
|
{
|
|
msg = "编号不能为空!";
|
|
}
|
|
|
|
else if (string.IsNullOrEmpty(orgName))
|
|
{
|
|
msg = "名称不能为空!";
|
|
}
|
|
else
|
|
{
|
|
|
|
FangYar.Model.TBL.TBL_SYS_ORG_Model model = new Model.TBL.TBL_SYS_ORG_Model();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.AREA_ID = areaID;
|
|
model.AREA_IDS = areaIDs;
|
|
model.IS_DEL = "0";
|
|
model.ORG_ADDR = orgAddr;
|
|
model.ORG_CODE = orgCode;
|
|
model.ORG_NAME = orgName;
|
|
model.ORG_PERSON = orgPerson;
|
|
model.ORG_TEL = orgTel;
|
|
model.ORG_TYPE = orgType;
|
|
if (!string.IsNullOrEmpty(PID))
|
|
{
|
|
model.PID = PID;
|
|
}
|
|
else
|
|
{
|
|
model.PID = "-1";
|
|
|
|
}
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "添加失败!";
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "营区操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "营区操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
//修改
|
|
private string EditModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string PID = context.Request.Params["PID"];
|
|
string orgCode = context.Request.Params["orgCode"];
|
|
string orgName = context.Request.Params["orgName"];
|
|
string orgAddr = context.Request.Params["orgAddr"];
|
|
string orgType = context.Request.Params["orgType"];
|
|
string orgPerson = context.Request.Params["orgPerson"];
|
|
string orgTel = context.Request.Params["orgTel"];
|
|
string idDel = context.Request.Params["idDel"];
|
|
string areaID = context.Request.Params["areaID"];
|
|
string areaIDs = context.Request.Params["areaIDs"];
|
|
|
|
if (string.IsNullOrEmpty(orgCode))
|
|
{
|
|
msg = "编号不能为空!";
|
|
}
|
|
|
|
else if (string.IsNullOrEmpty(orgName))
|
|
{
|
|
msg = "名称不能为空!";
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
FangYar.Model.TBL.TBL_SYS_ORG_Model model = bll.GetModelByID(ID);
|
|
if (model == null)
|
|
{
|
|
msg = "记录不存在!";
|
|
}
|
|
else
|
|
{
|
|
|
|
model.AREA_ID = areaID;
|
|
model.AREA_IDS = areaIDs;
|
|
model.IS_DEL = "0";
|
|
model.ORG_ADDR = orgAddr;
|
|
model.ORG_CODE = orgCode;
|
|
model.ORG_NAME = orgName;
|
|
model.ORG_PERSON = orgPerson;
|
|
model.ORG_TEL = orgTel;
|
|
model.ORG_TYPE = orgType;
|
|
if (!string.IsNullOrEmpty(PID))
|
|
{
|
|
model.PID = PID;
|
|
}
|
|
else
|
|
{
|
|
model.PID = "-1";
|
|
|
|
}
|
|
if (bll.Edit(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败!";
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "营区操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "营区操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
//删除
|
|
private string DelModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string UIDList = context.Request.Params["UIDList"];
|
|
UIDList = UIDList.Replace(",", "','");
|
|
if (bll.Delete(UIDList))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "营区操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "营区操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
//字典表机构树
|
|
private string GetOrgTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string treeid = context.Request.Params["treeid"];
|
|
|
|
|
|
string where = null;
|
|
if (!string.IsNullOrEmpty(treeid))
|
|
{
|
|
where = " ORG_ID = " + treeid;
|
|
}
|
|
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
|
|
list = blltree.GetTree("ORG_ID", "PID", "ORG_NAME", "FIRE_ORG", where, list);
|
|
returnstr = "{\"data\":";
|
|
if (list.Count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "营区操作请求", "字典表机构树异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "营区操作请求", "字典表机构树");
|
|
return returnstr;
|
|
|
|
}
|
|
//获取机构名称,获取单个model数据
|
|
private string getOrgName(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
int count = bll.Count("ID ='" + ID + "'");
|
|
if (count > 0)
|
|
{
|
|
returnstr = "{\"code\":1,\"data\":";
|
|
FangYar.Model.TBL.TBL_SYS_ORG_Model model = bll.GetModelByID(ID);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
returnstr += "}";
|
|
}
|
|
else
|
|
{
|
|
|
|
returnstr = "{\"code\":0,\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "营区操作请求", "获取机构名称,获取单个model数据异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "营区操作请求", "获取机构名称,获取单个model数据");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|