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

799 lines
35 KiB

using System;
using System.Collections.Generic;
using System.Web;
using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text;
namespace FangYar.WebUI.ashx
{
/// <summary>
/// OaLeaveHandler 的摘要说明
/// </summary>
public class FireEpuHandler : IHttpHandler
{
private FangYar.BLL.FIRE.FIRE_EPUIP bll = new FangYar.BLL.FIRE.FIRE_EPUIP();
private FangYar.BLL.FIRE.FIRE_STATION sbll = new FangYar.BLL.FIRE.FIRE_STATION();
private FangYar.BLL.TBL.SysEmpBLL ebll = new FangYar.BLL.TBL.SysEmpBLL();
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 "EpuList":
returnstr = GetEpuList(context);
break;
case "Add":
returnstr = AddEpu(context);
break;
case "Edit":
returnstr = EditEpu(context);
break;
case "StaList":
returnstr = getStaList(context);
break;
case "Del":
returnstr = DelEpu(context);
break;
case "getEquipmentTree":
returnstr = getEquipmentTree(context);
break;
case "getEquipmentListByOrgId":
returnstr = getEquipmentListByOrgId(context);
break;
case "getFireEpuipCarListByCarId":
returnstr = getFireEpuipCarListByCarId(context);
break;
case "AddFireEpuipCar":
returnstr = AddFireEpuipCar(context);
break;
case "getCarListByEpuId":
returnstr = getCarListByEpuId(context);
break;
case "epuStatisticalChart":
returnstr = epuStatisticalChart(context);
break;
}
context.Response.Write(returnstr);
}
//查询
private string GetEpuList(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
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 is_content = context.Request.Params["is_content"];
string epuType = context.Request.Params["epuType"];
string epuTypeId = context.Request.Params["epuTypeId"];
int pageIndex = 1;
int pageSize = 10;
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
string where = "";
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
{
if (is_content == "1")
{
where = "org_id in ( select org_id from fire_org, (SELECT get_Org_child_list('" + treeID + "') cids) t where find_in_set(ORG_ID, cids))";
}
else
{
where = " ORG_ID = '" + treeID + "'";
}
}
else
{
if (is_content == "1")
{
where = "org_id in ( select org_id from fire_org, (SELECT get_Org_child_list('" + OrgId + "') cids) t where find_in_set(ORG_ID, cids))";
}
else
{
where = " ORG_ID = '" + OrgId + "'";
}
}
if (!string.IsNullOrEmpty(keyword))
{
if (where != null)
{
where += " and ";
}
where += "( name like '%" + keyword + "%' or sta_name like '%" + keyword + "%' or detail_name like '%" + keyword + "%')";
}
if (!string.IsNullOrEmpty(epuTypeId))
{
if (where != null)
{
where += " and ";
}
if (epuType == "dic")
{
where += "type_id in (select id from fire_epuip_type where dic_id = '" + epuTypeId + "')";
}
else
{
where += "type_id = '" + epuTypeId + "'";
}
}
if (where != null)
{
where += " and ";
}
where += "KC_NUM > 0";
returnstr = "{\"code\":0,\"msg\":\"\",";
int count = bll.GetRecordCount(where);
returnstr += "\"count\":" + count + ",\"data\":";
if (count == 0)
{
returnstr += "[]";
}
else
{
List<FangYar.Model.FIRE.FIRE_EPUIP> list = bll.QueryList(pageIndex, pageSize, where, " NAME ");
returnstr += FangYar.Common.JsonHelper.ToJson(list);
}
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "消防装备操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "消防装备操作请求", "查询");
return returnstr;
}
//获取所属消防机关列表
private string getStaList(HttpContext context)
{
string returnstr = "";
try
{
string orgId = context.Request.Params["OrgId"];
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = sbll.getStaList(orgId);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "消防装备操作请求", "获取所属消防机关列表异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "消防装备操作请求", "获取所属消防机关列表");
return returnstr;
}
//添加消防装备
private string AddEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string USER_ID = context.Request.Params["USER_ID"];
string ID = Guid.NewGuid().ToString("N");
string TYPE_ID = context.Request.Params["TYPE_ID"];
string CODE = context.Request.Params["CODE"];
string TYPE_CODE = context.Request.Params["TYPE_CODE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string EQ_NUM = context.Request.Params["EQ_NUM"];
string UNIT_PER = context.Request.Params["UNIT_PER"];
string UNIT_W_PHONE = context.Request.Params["UNIT_W_PHONE"];
string UNIT_M_PHONE = context.Request.Params["UNIT_M_PHONE"];
string CONT_PER = context.Request.Params["CONT_PER"];
string CONT_W_PHONE = context.Request.Params["CONT_W_PHONE"];
string CONT_M_PHONE = context.Request.Params["CONT_M_PHONE"];
string CONT_R_PHONE = context.Request.Params["CONT_R_PHONE"];
string UNIT = context.Request.Params["UNIT"];
string UNIT_ADDR = context.Request.Params["UNIT_ADDR"];
string PRICE = context.Request.Params["PRICE"];
string RESERVE = context.Request.Params["RESERVE"];
string R_TIME = context.Request.Params["R_TIME"];
string Q_G_P = context.Request.Params["Q_G_P"];
string DES = context.Request.Params["DES"];
string ADDR = context.Request.Params["ADDR"];
string UNIT_MEAS = context.Request.Params["UNIT_MEAS"];
string E_NAME = context.Request.Params["E_NAME"];
string H_LEVEL = context.Request.Params["H_LEVEL"];
string SECRET = context.Request.Params["SECRET"];
string DUTY_PHONE = context.Request.Params["DUTY_PHONE"];
string TRADEMARK = context.Request.Params["TRADEMARK"];
string MANUFACTOR = context.Request.Params["MANUFACTOR"];
string LIABLE = context.Request.Params["LIABLE"];
string EXTENDCODE1_PATH = context.Request.Params["EXTENDCODE1_PATH"];
string STATE = context.Request.Params["STATE"];
string REMARKS = context.Request.Params["REMARKS"];
string DETAIL_NAME = context.Request.Params["DETAIL_NAME"];
string KC_NUM = context.Request.Params["KC_NUM"];
//消防装备表
FangYar.Model.FIRE.FIRE_EPUIP model = new Model.FIRE.FIRE_EPUIP();
model.ID = ID;
model.TYPE_ID = TYPE_ID;
model.CODE = CODE;
model.TYPE_CODE = TYPE_CODE;
model.ORG_ID = ORG_ID;
if (!string.IsNullOrEmpty(EQ_NUM))
{
model.EQ_NUM = int.Parse(EQ_NUM);
}
else
{
model.EQ_NUM = 1;
}
if (!string.IsNullOrEmpty(KC_NUM))
{
model.KC_NUM = int.Parse(KC_NUM);
}
else
{
model.KC_NUM = 1;
}
model.UNIT_PER = UNIT_PER;
model.UNIT_W_PHONE = UNIT_W_PHONE;
model.UNIT_M_PHONE = UNIT_M_PHONE;
model.CONT_PER = CONT_PER;
model.CONT_W_PHONE = CONT_W_PHONE;
model.CONT_M_PHONE = CONT_M_PHONE;
model.CONT_R_PHONE = CONT_R_PHONE;
model.UNIT = UNIT;
model.UNIT_ADDR = UNIT_ADDR;
model.PRICE = PRICE;
model.RESERVE = RESERVE;
model.R_TIME = R_TIME;
model.Q_G_P = Q_G_P;
model.DES = DES;
model.ADDR = ADDR;
model.UNIT_MEAS = UNIT_MEAS;
model.E_NAME = E_NAME;
model.H_LEVEL = H_LEVEL;
model.SECRET = SECRET;
model.DUTY_PHONE = DUTY_PHONE;
model.TRADEMARK = TRADEMARK;
model.MANUFACTOR = MANUFACTOR;
model.LIABLE = LIABLE;
model.EXTENDCODE1 = EXTENDCODE1_PATH;
model.STATE = STATE;
model.REMARKS = REMARKS;
model.A_PER = USER_ID;
model.DETAIL_NAME = DETAIL_NAME;
model.A_TIME = DateTime.Now.ToString("G");
if (bll.AddEpu(model))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = "添加失败:装备编码有重复数据";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "消防装备操作请求", "添加异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "消防装备操作请求", "添加");
return returnstr;
}
//修改消防装备
private string EditEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string USER_ID = context.Request.Params["USER_ID"];
string ID = context.Request.Params["ID"];
string TYPE_ID = context.Request.Params["TYPE_ID"];
string CODE = context.Request.Params["CODE"];
string TYPE_CODE = context.Request.Params["TYPE_CODE"];
string ORG_ID = context.Request.Params["ORG_ID"];
string EQ_NUM = context.Request.Params["EQ_NUM"];
string UNIT_PER = context.Request.Params["UNIT_PER"];
string UNIT_W_PHONE = context.Request.Params["UNIT_W_PHONE"];
string UNIT_M_PHONE = context.Request.Params["UNIT_M_PHONE"];
string CONT_PER = context.Request.Params["CONT_PER"];
string CONT_W_PHONE = context.Request.Params["CONT_W_PHONE"];
string CONT_M_PHONE = context.Request.Params["CONT_M_PHONE"];
string CONT_R_PHONE = context.Request.Params["CONT_R_PHONE"];
string UNIT = context.Request.Params["UNIT"];
string UNIT_ADDR = context.Request.Params["UNIT_ADDR"];
string PRICE = context.Request.Params["PRICE"];
string RESERVE = context.Request.Params["RESERVE"];
string R_TIME = context.Request.Params["R_TIME"];
string Q_G_P = context.Request.Params["Q_G_P"];
string DES = context.Request.Params["DES"];
string ADDR = context.Request.Params["ADDR"];
string UNIT_MEAS = context.Request.Params["UNIT_MEAS"];
string E_NAME = context.Request.Params["E_NAME"];
string H_LEVEL = context.Request.Params["H_LEVEL"];
string SECRET = context.Request.Params["SECRET"];
string DUTY_PHONE = context.Request.Params["DUTY_PHONE"];
string TRADEMARK = context.Request.Params["TRADEMARK"];
string MANUFACTOR = context.Request.Params["MANUFACTOR"];
string LIABLE = context.Request.Params["LIABLE"];
string EXTENDCODE1_PATH = context.Request.Params["EXTENDCODE1_PATH"];
string STATE = context.Request.Params["STATE"];
string REMARKS = context.Request.Params["REMARKS"];
string DETAIL_NAME = context.Request.Params["DETAIL_NAME"];
string KC_NUM = context.Request.Params["KC_NUM"];
//消防装备表
FangYar.Model.FIRE.FIRE_EPUIP model = new Model.FIRE.FIRE_EPUIP();
model.ID = ID;
model.TYPE_ID = TYPE_ID;
model.CODE = CODE;
model.TYPE_CODE = TYPE_CODE;
model.ORG_ID = ORG_ID;
if (!string.IsNullOrEmpty(EQ_NUM))
{
model.EQ_NUM = int.Parse(EQ_NUM);
}
else
{
model.EQ_NUM = 1;
}
if (!string.IsNullOrEmpty(KC_NUM))
{
model.KC_NUM = int.Parse(KC_NUM);
}
else
{
model.KC_NUM = 1;
}
model.UNIT_PER = UNIT_PER;
model.UNIT_W_PHONE = UNIT_W_PHONE;
model.UNIT_M_PHONE = UNIT_M_PHONE;
model.CONT_PER = CONT_PER;
model.CONT_W_PHONE = CONT_W_PHONE;
model.CONT_M_PHONE = CONT_M_PHONE;
model.CONT_R_PHONE = CONT_R_PHONE;
model.UNIT = UNIT;
model.UNIT_ADDR = UNIT_ADDR;
model.PRICE = PRICE;
model.RESERVE = RESERVE;
model.R_TIME = R_TIME;
model.Q_G_P = Q_G_P;
model.DES = DES;
model.ADDR = ADDR;
model.UNIT_MEAS = UNIT_MEAS;
model.E_NAME = E_NAME;
model.H_LEVEL = H_LEVEL;
model.SECRET = SECRET;
model.DUTY_PHONE = DUTY_PHONE;
model.TRADEMARK = TRADEMARK;
model.MANUFACTOR = MANUFACTOR;
model.LIABLE = LIABLE;
model.EXTENDCODE1 = EXTENDCODE1_PATH;
model.STATE = STATE;
model.REMARKS = REMARKS;
model.DETAIL_NAME = DETAIL_NAME;
model.U_PER = USER_ID;
model.U_TIME = DateTime.Now.ToString("G");
if (bll.EditEpu(model))
{
msg = "修改成功!";
code = 1;
}
else { msg = "修改失败!"; }
}
catch (Exception e)
{
msg = "修改失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "消防装备操作请求", "修改异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "消防装备操作请求", "修改");
return returnstr;
}
//删除消防装备
private string DelEpu(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
try
{
string EpuList = context.Request.Params["EpuList"];
string[] EpuArray = EpuList.Split(',');
string EpuListString = "";
for (int i = 0; i < EpuArray.Length; i++)
{
if (i == 0)
{
EpuListString = "'" + EpuArray[i] + "'";
}
else
{
EpuListString += ",'" + EpuArray[i] + "'";
}
}
if (bll.DeleteList(EpuListString))
{
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 getEquipmentTree(HttpContext context)
{
string returnstr = "";
try
{
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
string sql = "select id,name,dic_id as pid,'epu' as type from fire_epuip_type where dic_id is not null union all (select id,dic_text as name,'0' as pid,'dic' as type from tbl_sys_dicdetail where mod_code = 'EQUIPMENT_TYPE' order by dic_order+0)";
DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "装备操作请求", "装备类别异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "装备操作请求", "装备类别");
return returnstr;
}
//根据orgId获取消防装备列表
private string getEquipmentListByOrgId(HttpContext context)
{
string returnstr = "";
try
{
string OrgId = context.Request.Params["OrgId"];
if (string.IsNullOrEmpty(OrgId))
{
return "{\"code\":0,\"msg\":\"参数异常,请刷新页面后重试\",\"count\":0,\"data\":[]}";
}
string sql = "select * from fire_epuip where org_id = '" + OrgId + "'";
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "装备操作请求", "装备类别异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "装备操作请求", "装备类别");
return returnstr;
}
private string getFireEpuipCarListByCarId (HttpContext context)
{
string returnstr = "";
try
{
string CarId = context.Request.Params["CarId"];
string OrgId = context.Request.Params["OrgId"];
if (string.IsNullOrEmpty(CarId))
{
return "{\"code\":0,\"msg\":\"参数异常,请刷新页面后重试\",\"count\":0,\"data\":[]}";
}
string sql = "select * from fire_epuip_car where CAR_ID = '"+ CarId + "' and ORG_ID = '" + OrgId + "'";
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "车载装备操作请求", "查询异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "车载装备操作请求", "查询");
return returnstr;
}
private string AddFireEpuipCar(HttpContext context)
{
string returnstr = "";
int code = -1;
string msg = "";
string errorStr = "";
try
{
string CAR_ID = context.Request.Params["carId"];
string CAR_NUM = context.Request.Params["carNum"];
string ORG_ID = context.Request.Params["orgId"];
string arrStr = context.Request.Params["arrStr"];
JArray arr = JArray.Parse(arrStr);
JArray jArray = (JArray)JsonConvert.DeserializeObject(arrStr);
try
{
string epuUpdateSql = "update fire_epuip e left join fire_epuip_car c on e.id = c.epu_id set e.CZ_NUM = e.CZ_NUM - c.NUM, e.KC_NUM = e.KC_NUM + c.NUM where c.CAR_ID = '" + CAR_ID + "' and c.ORG_ID = '" + ORG_ID + "' ";
FangYar.Common.MySqlHelper.ExecuteSql(epuUpdateSql);
string delSql = "delete from fire_epuip_car where CAR_ID = '" + CAR_ID + "' and ORG_ID = '" + ORG_ID + "'";
FangYar.Common.MySqlHelper.ExecuteSql(delSql);
}
catch (Exception e) { }
foreach (JObject item in arr)
{
string EPU_ID = item["EPU_ID"].ToString();
string EPU_NAME = item["EPU_NAME"].ToString();
decimal NUM = 0;
try
{
NUM = decimal.Parse(item["NUM"].ToString());
}
catch(Exception e){ }
string sql = "select IFNULL(KC_NUM,0) as KC_NUM,IFNULL(CZ_NUM,0) as CZ_NUM from fire_epuip where id = '" + EPU_ID + "'";
DataSet ds = FangYar.Common.MySqlHelper.Query(sql);
if (ds.Tables[0].Rows.Count > 0)
{
DataRow row = ds.Tables[0].Rows[0];
if (row != null)
{
try
{
decimal kcNum = decimal.Parse(row["KC_NUM"].ToString());
decimal czNum = decimal.Parse(row["CZ_NUM"].ToString());
if (kcNum >= NUM)
{
string addSql = @"insert into fire_epuip_car(ID,EPU_ID,CAR_ID,CAR_NUM,NUM,ORG_ID) value (
'" + Guid.NewGuid().ToString("N") + @"',
'" + EPU_ID + @"',
'" + CAR_ID + @"',
'" + CAR_NUM + @"',
'" + NUM + @"',
'" + ORG_ID + @"')";
FangYar.Common.MySqlHelper.ExecuteSql(addSql);
decimal newKcNum = kcNum - NUM;
decimal newCzNum = czNum + NUM;
string updateSql = @"update fire_epuip set KC_NUM = '"+ newKcNum + @"', CZ_NUM = '" + newCzNum + @"', EQ_NUM = CZ_NUM + KC_NUM where id = '" + EPU_ID + @"'";
FangYar.Common.MySqlHelper.ExecuteSql(updateSql);
}
else
{
errorStr += "【" + EPU_NAME + "】库存不足,请通过左侧【<span style=\"color: #54ff00\">消防装备</span>】菜单进行维护,增加库存数量;<br />";
}
}
catch (Exception e)
{
errorStr += "【" + EPU_NAME + "】维护失败,请刷新页面后重试;<br />";
}
}
else
{
errorStr += "【" + EPU_NAME + "】装备不存在,请刷新页面后重试;<br />";
}
}
else
{
errorStr += "【" + EPU_NAME + "】装备不存在,请刷新页面后重试;<br />";
}
}
if (string.IsNullOrEmpty(errorStr))
{
msg = "添加成功!";
code = 1;
}
else { msg = "添加失败!"; }
}
catch (Exception e)
{
msg = "添加失败!";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "车载装备操作请求", "添加异常:" + e);
}
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + ",\"errorStr\":\"" + errorStr + "\"}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "车载装备操作请求", "添加");
return returnstr;
}
//根据epuId获取车辆列表
private string getCarListByEpuId(HttpContext context)
{
string returnstr = "";
try
{
string EpuId = context.Request.Params["EpuId"];
if (string.IsNullOrEmpty(EpuId))
{
return "{\"code\":0,\"msg\":\"参数异常,请刷新页面后重试\",\"count\":0,\"data\":[]}";
}
string sql = "select * from fire_epuip_car where EPU_ID = '" + EpuId + "'";
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql);
returnstr += FangYar.Common.JsonHelper.ToJson(data);
returnstr += "}";
}
catch (Exception e)
{
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "装备操作请求", "车载装备异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "装备操作请求", "车载装备");
return returnstr;
}
//装备统计(饼图)
private string epuStatisticalChart(HttpContext context)
{
string returnstr = "";
try
{
string is_content = context.Request.Params["is_content"];
string OrgId = context.Request.Params["OrgId"];
if (string.IsNullOrEmpty(OrgId))
{
return "{\"code\":0,\"msg\":\"参数异常,请刷新页面后重试\",\"count\":0,\"data\":[]}";
}
string DicId = context.Request.Params["DicId"];
string epuStaSql = "";
if (string.IsNullOrEmpty(DicId))
{
string dicSql = "select ID,DIC_TEXT from tbl_sys_dicdetail where mod_code = 'EQUIPMENT_TYPE'";
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(dicSql);
if (dt.Rows.Count > 0)
{
try
{
foreach (DataRow row in dt.Rows)
{
string dictId = row["ID"].ToString();
string dictName = row["DIC_TEXT"].ToString();
if (!string.IsNullOrEmpty(epuStaSql)) {
epuStaSql += " union all ";
}
string is_content_sql = "";
if (is_content == "1")
{
is_content_sql = ", (select get_Org_child_list('" + OrgId + "') cids) s where ( find_in_set(org_id, cids) ) ";
}
else
{
is_content_sql = " where ORG_ID = '" + OrgId + "' ";
}
epuStaSql += "select '"+ dictName + "' as name, ifnull(sum(e.cz_num),0) as cz_num, ifnull(sum(e.kc_num),0) as kc_num from fire_epuip e"+ is_content_sql + "and e.type_id in (select id from fire_epuip_type where DIC_ID = '" + dictId + "')";
}
}
catch (Exception e) { }
}
}else
{
string dicSql = "select ID,NAME as DIC_TEXT from fire_epuip_type where dic_id = '"+ DicId + "'";
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(dicSql);
if (dt.Rows.Count > 0)
{
try
{
foreach (DataRow row in dt.Rows)
{
string dictId = row["ID"].ToString();
string dictName = row["DIC_TEXT"].ToString();
if (!string.IsNullOrEmpty(epuStaSql))
{
epuStaSql += " union all ";
}
string is_content_sql = "";
if (is_content == "1")
{
is_content_sql = ", (select get_Org_child_list('" + OrgId + "') cids) s where ( find_in_set(org_id, cids) ) ";
}
else
{
is_content_sql = " where ORG_ID = '" + OrgId + "' ";
}
epuStaSql += "select '" + dictName + "' as name, ifnull(sum(e.cz_num),0) as cz_num, ifnull(sum(e.kc_num),0) as kc_num from fire_epuip e" + is_content_sql + "and e.type_id = '" + dictId + "'";
}
}
catch (Exception e) { }
}
}
if (!string.IsNullOrEmpty(epuStaSql))
{
returnstr = "{\"code\":1,\"msg\":\"操作成功!\",\"data\":";
DataTable resDt = FangYar.Common.MySqlHelper.QueryTable(epuStaSql);
returnstr += FangYar.Common.JsonHelper.ToJson(resDt) + "}";
}
else
{
returnstr = "{\"code\":0,\"msg\":\"未查询到数据!\",\"data\":[]}";
}
}
catch (Exception e)
{
returnstr = "{\"code\":-1,\"msg\":\"数据异常,请刷新页面后重试\",\"data\":[]}";
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "装备操作请求", "车载装备异常:" + e);
}
// 记录操作日志
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "装备操作请求", "车载装备");
return returnstr;
}
public bool IsReusable
{
get
{
return false;
}
}
}
}