软测单独项目
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.
 
 
 
 
 
 

674 lines
24 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;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class ZYFireOrgHandler : IHttpHandler
{
private FangYar.BLL.FIRE.FIRE_ORG bll = new FangYar.BLL.FIRE.FIRE_ORG();
private FangYar.BLL.ToTree_BLL blltree = new BLL.ToTree_BLL();
private FangYar.BLL.TBL.SysAreaBLL abll = new BLL.TBL.SysAreaBLL();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string action = context.Request.Params["Action"];
string returnstr = "";
switch (action)
{
case "OrgTree":
returnstr = GetOrgDeptTree(context);
break;
case "OrgList2":
returnstr = GetOrgTree(context);
break;
case "AreaList":
returnstr = GetAreaList(context);
break;
case "AreaList2":
returnstr = GetAreaList2(context);
break;
case "AreaPID":
returnstr = GetAreaPID(context);
break;
case "OrgList":
returnstr = GetOrgList(context);
break;
case "GetOrg":
returnstr = GetOrg(context);
break;
case "Add":
returnstr = AddOrg(context);
break;
case "Edit":
returnstr = EditOrg(context);
break;
case "Del":
returnstr = DelOrg(context);
break;
case "getFireOrgTree":
returnstr = getFireOrgTree(context);
break;
case "getFireOrgName":
returnstr = getFireOrgName(context);
break;
case "OrgList3":
returnstr = GetOrgList3(context);
break;
//根据地区编码获取组织机构ID
case "getOrgIdByCity":
returnstr = GetOrgIdByCity(context);
break;
//根据地区编码获取地区城市名称
case "getCityNameByCity":
returnstr = getCityNameByCity(context);
break;
}
context.Response.Write(returnstr);
}
//机构树
private string GetOrgTree(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["OrgId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
List<FangYar.Model.FIRE.FIRE_ORG> data = bll.GetOrgListTreeByOrgId(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\":";
List<FangYar.Model.FIRE.FIRE_ORG> data = bll.GetListTreeByOrgId(orgId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//获取父级行政区ID
private string GetAreaPID(HttpContext context)
{
string returnstr = "";
try
{
string ORG_ID = context.Request.Params["ORG_ID"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
FangYar.Model.FIRE.FIRE_ORG data = bll.GetModel(ORG_ID);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//获取行政区列表
private string GetAreaList(HttpContext context)
{
string returnstr = "";
try
{
string PID = context.Request.Params["PID"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = bll.GetAreaList(" PID ='" + PID + "' or AREA_CODE = '" + PID + "'");
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//根据ORG_ID获取行政区列表
private string GetAreaList2(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = bll.GetAreaList2(OrgId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//查询
private string GetOrgList(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
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 TYPE = context.Request.Params["TYPE"];
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)
{
where += " ORG_ID = '" + treeID + "'";
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += " ORG_NAME like '%" + keyword + "%' ";
}
if (!string.IsNullOrEmpty(OrgId))
{
if (where == null)
{
where += " 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)) ";
}
else
{
where += " and 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)) ";
}
}
if (!string.IsNullOrEmpty(TYPE))
{
if (where != null)
{
where += " and ";
}
where += " TYPE in ('" + TYPE + "') ";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.FIRE.FIRE_ORG> list = bll.QueryList(pageIndex, pageSize, where, "");
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//获取队站信息
private string GetOrg(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["orgId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"Data\":";
FangYar.Model.FIRE.FIRE_ORG data = bll.getOrg(orgId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
//添加机构
private string AddOrg(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ORG_ID = Guid.NewGuid().ToString("N");
string PID = context.Request.Params["PID"];
string USER_ID = context.Request.Params["USER_ID"];
string ORG_NO = context.Request.Params["ORG_NO"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string ATTR = context.Request.Params["ATTR"];
string ORG_LEVEL = context.Request.Params["ORG_LEVEL"];
string ORG_TYPE = context.Request.Params["ORG_TYPE"];
string ADDR = context.Request.Params["ADDR"];
string DES = context.Request.Params["DES"];
string AFF = context.Request.Params["AFF"];
string CODE = context.Request.Params["CODE"];
string CONT = context.Request.Params["CONT"];
string PHONE = context.Request.Params["PHONE"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string CITY = context.Request.Params["CITY"];
string CITY_NAME = context.Request.Params["CITY_NAME"];
string STATE = context.Request.Params["STATE"];
string TYPE = context.Request.Params["TYPE"];
string SORT = context.Request.Params["SORT"];
string CHARGELEADER = context.Request.Params["CHARGELEADER"];
string LEADER = context.Request.Params["LEADER"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string ALL_NUM = context.Request.Params["ALL_NUM"];
//消防机构表
FangYar.Model.FIRE.FIRE_ORG model = new Model.FIRE.FIRE_ORG();
model.ORG_ID = ORG_ID;
model.PID = PID;
model.ORG_NO = ORG_NO;
model.ORG_NAME = ORG_NAME;
model.ATTR = ATTR;
model.ORG_LEVEL = ORG_LEVEL;
model.ORG_TYPE = ORG_TYPE;
model.ADDR = ADDR;
model.DES = DES;
model.AFF = AFF;
model.CODE = CODE;
model.CONT = CONT;
model.PHONE = PHONE;
model.LON = LON;
model.LAT = LAT;
model.CITY = CITY;
model.STATE = STATE;
model.A_PER = USER_ID;
if (!string.IsNullOrEmpty(TYPE))
{
model.TYPE = int.Parse(TYPE);
}
if (!string.IsNullOrEmpty(SORT))
{
model.SORT = int.Parse(SORT);
}
model.CHARGELEADER = CHARGELEADER;
model.LEADER = LEADER;
model.ALL_NUM = ALL_NUM;
model.EXTENDCODE1 = EXTENDCODE1;
FangYar.Model.TBL.TBL_SYS_AREA_PID_Model area_s = abll.GetPIDS(CITY);
//Camp_Fire2.CwsClient cf = new Camp_Fire2.CwsClient();
//string flag = cf.insertGroup(ORG_ID, ORG_NAME, CITY, area_s.CODE_S, CITY_NAME, area_s.NAME_S);
if (bll.AddOrg(model))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = "添加失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//修改机构信息
private string EditOrg(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string ORG_ID = context.Request.Params["ID"];
string PID = context.Request.Params["PID"];
string USER_ID = context.Request.Params["USER_ID"];
string ORG_NO = context.Request.Params["ORG_NO"];
string ORG_NAME = context.Request.Params["ORG_NAME"];
string ATTR = context.Request.Params["ATTR"];
string ORG_LEVEL = context.Request.Params["ORG_LEVEL"];
string ORG_TYPE = context.Request.Params["ORG_TYPE"];
string ADDR = context.Request.Params["ADDR"];
string DES = context.Request.Params["DES"];
string AFF = context.Request.Params["AFF"];
string CODE = context.Request.Params["CODE"];
string CONT = context.Request.Params["CONT"];
string PHONE = context.Request.Params["PHONE"];
string LON = context.Request.Params["LON"];
string LAT = context.Request.Params["LAT"];
string CITY = context.Request.Params["CITY"];
string STATE = context.Request.Params["STATE"];
string TYPE = context.Request.Params["TYPE"];
string SORT = context.Request.Params["SORT"];
string CHARGELEADER = context.Request.Params["CHARGELEADER"];
string LEADER = context.Request.Params["LEADER"];
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
string ALL_NUM = context.Request.Params["ALL_NUM"];
//消防机构表
FangYar.Model.FIRE.FIRE_ORG model = new Model.FIRE.FIRE_ORG();
model.ORG_ID = ORG_ID;
model.PID = PID;
model.ORG_NO = ORG_NO;
model.ORG_NAME = ORG_NAME;
model.ATTR = ATTR;
model.ORG_LEVEL = ORG_LEVEL;
model.ORG_TYPE = ORG_TYPE;
model.ADDR = ADDR;
model.DES = DES;
model.AFF = AFF;
model.CODE = CODE;
model.CONT = CONT;
model.PHONE = PHONE;
model.LON = LON;
model.LAT = LAT;
model.CITY = CITY;
model.STATE = STATE;
model.U_PER = USER_ID;
if (!string.IsNullOrEmpty(TYPE))
{
model.TYPE = int.Parse(TYPE);
}
if (!string.IsNullOrEmpty(SORT))
{
model.SORT = int.Parse(SORT);
}
model.CHARGELEADER = CHARGELEADER;
model.LEADER = LEADER;
model.ALL_NUM = ALL_NUM;
model.EXTENDCODE1 = EXTENDCODE1;
if (bll.EditOrg(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch (Exception e)
{
msg = "修改失败!";
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
return returnstr;
}
//删除人员
private string DelOrg(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string OrgList = context.Request.Params["OrgList"];
string[] OrgArray = OrgList.Split(',');
string OrgListString = "";
for (int i = 0; i < OrgArray.Length; i++)
{
if (i == 0)
{
OrgListString = "'" + OrgArray[i] + "'";
}
else
{
OrgListString += ",'" + OrgArray[i] + "'";
}
}
var rcode = bll.DelOrg(OrgListString);
if (rcode == 0)
{
msg = "删除成功!";
code = 1;
}
else if (rcode == 1)
{
msg = "所选机构还有下级机构关联,请移除下级机构后再删除当前所选机构!";
}
else if (rcode == 2)
{
msg = "所选机构还有消防队站关联,请移除消防队站后再删除当前所选机构!";
}
else if (rcode == 3)
{
msg = "删除失败!";
}
}
catch
{
msg = "删除失败!";
}
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
return returnstr;
}
//字典表机构树
private string getFireOrgTree(HttpContext context)
{
string returnstr = "";
try
{
string ORG_ID = context.Request.Params["ORG_ID"];
List<FangYar.Model.TreeNodeModel> list = new List<Model.TreeNodeModel>();
//list = blltree.GetTree("ORG_ID", "PID", "ORG_NAME", "FIRE_ORG", where, list);
list = blltree.GetTree2("ORG_ID", "PID", "ORG_NAME", "FIRE_ORG", ORG_ID, list);
returnstr = "{\"data\":";
if (list.Count == 0)
{
returnstr += "[]";
}
else
{
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch
{
returnstr = "{\"data\":[]}";
}
return returnstr;
}
//获取机构名称,获取单个model数据
private string getFireOrgName(HttpContext context)
{
string returnstr = "";
try
{
FangYar.BLL.FIRE.FIRE_ORG fireorg_bll = new BLL.FIRE.FIRE_ORG();
string ID = context.Request.Params["ID"];
int count = fireorg_bll.GetRecordCount(" ORG_ID ='" + ID + "'");
if (count > 0)
{
returnstr = "{\"code\":1,\"data\":";
FangYar.Model.FIRE.FIRE_ORG model = fireorg_bll.GetModel(ID);
returnstr += FangYar.Common.JsonHelper.ToJson(model);
returnstr += "}";
}
else
{
returnstr = "{\"code\":0,\"data\":[]}";
}
}
catch
{
returnstr = "{\"code\":0,\"data\":[]}";
}
return returnstr;
}
//查询(只查询机构,不查询部门)
private string GetOrgList3(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
string page = context.Request.Params["page"];
string limit = context.Request.Params["limit"];
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(OrgId))
{
if (where != null)
{
where += " and ";
}
where += " (ORG_ID = '" + OrgId + "' or PID = '" + OrgId + "') and TYPE = '0'";
}
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.FIRE.FIRE_ORG> list = bll.QueryList(pageIndex, pageSize, where, "");
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
}
return returnstr;
}
/// <summary>
/// 根据地区编码获取组织机构ID
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
private string GetOrgIdByCity(HttpContext context)
{
string returnstr = "";
try
{
string cityCode = context.Request.Params["cityCode"];
int pageIndex = 1;
int pageSize = 1;
string where = " CITY ='" + cityCode + "' ";
returnstr = "{\"code\":0,\"msg\":\"\",";
List<FangYar.Model.FIRE.FIRE_ORG> list = bll.QueryList(pageIndex, pageSize, where, " field(type,0,1),field(EXTENDCODE1, 3, 0, 2, 1),field( ISORG, 0, 1 ),sort asc ");
returnstr += "\"data\":{\"orgId\":\"" + list[0].ORG_ID + "\",\"orgName\":\"" + list[0].ORG_NAME + "\"}";
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
}
return returnstr;
}
/// <summary>
/// 根据地区编码获取地区城市名称
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
private string getCityNameByCity(HttpContext context)
{
string returnstr = "";
try
{
string cityCode = context.Request.Params["cityCode"];
if (cityCode.IndexOf("0000") > 0)
{
cityCode = cityCode.Substring(0, 2) + "0100";
}
string sqlStr = " SELECT AREA_NAME from tbl_sys_area WHERE AREA_CODE = '" + cityCode + "' ";
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sqlStr);
returnstr = "{\"code\":0,\"msg\":\"\",";
if (dt.Rows.Count > 0)
{
string cityName = dt.Rows[0]["AREA_NAME"] + "";
cityName = cityName.Replace("市", "").Replace("县", "").Replace("地区", "").Replace("区", "");
cityName = cityName.Replace("县", "");
returnstr += "\"data\":\"" + cityName + "\"";
}
else
{
returnstr += "\"data\":\"\"";
}
returnstr += "}";
}
catch
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":\"\"}";
}
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}