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.
516 lines
22 KiB
516 lines
22 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 Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class FireInspectHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.FIRE.FIRE_INSPECT bll = new FangYar.BLL.FIRE.FIRE_INSPECT();
|
|
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 = GetInspectList(context);
|
|
break;
|
|
case "GetInspectWeek":
|
|
returnstr = GetInspectWeek(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddInspect(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditInspect(context);
|
|
break;
|
|
case "homeInspectSta":
|
|
returnstr = homeInspectSta(context);
|
|
break;
|
|
case "homeInspectStaAll":
|
|
returnstr = homeInspectStaAll(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询查铺查哨
|
|
private string GetInspectList(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"];
|
|
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(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( cn_name like '%" + keyword + "%' or ADDR like '%" + keyword + "%')";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE.FIRE_INSPECT> list = bll.QueryList(pageIndex, pageSize, where, "L_DATE DESC ");
|
|
foreach (FangYar.Model.FIRE.FIRE_INSPECT model in list)
|
|
{
|
|
JObject EXTENDCODE1_s = JsonConvert.DeserializeObject<JObject>(model.EXTENDCODE1);
|
|
JObject EXTENDCODE3_s = JsonConvert.DeserializeObject<JObject>(model.EXTENDCODE3);
|
|
JObject EXTENDCODE5_s = JsonConvert.DeserializeObject<JObject>(model.EXTENDCODE5);
|
|
JObject LEAVE_PER_s = JsonConvert.DeserializeObject<JObject>(model.LEAVE_PER);
|
|
string EXTENDCODE11 = "", EXTENDCODE31 = "", EXTENDCODE51 = "", LEAVE_PER1 = "";
|
|
int EXTENDCODE11count = 0, EXTENDCODE31count = 0, EXTENDCODE51count = 0, LEAVE_PER1count = 0;
|
|
if (EXTENDCODE1_s != null)
|
|
{
|
|
foreach (JObject EXTENDCODE11obj in EXTENDCODE1_s.Value<JArray>("data"))
|
|
{
|
|
if (EXTENDCODE11count == 0)
|
|
{
|
|
EXTENDCODE11 = "" + EXTENDCODE11obj["ppl_Name"];
|
|
}
|
|
else
|
|
{
|
|
EXTENDCODE11 += "," + EXTENDCODE11obj["ppl_Name"];
|
|
}
|
|
EXTENDCODE11count++;
|
|
}
|
|
}
|
|
if (EXTENDCODE3_s != null)
|
|
{
|
|
foreach (JObject EXTENDCODE31obj in EXTENDCODE3_s.Value<JArray>("data"))
|
|
{
|
|
if (EXTENDCODE31count == 0)
|
|
{
|
|
EXTENDCODE31 = "" + EXTENDCODE31obj["ppl_Name"];
|
|
}
|
|
else
|
|
{
|
|
EXTENDCODE31 += "," + EXTENDCODE31obj["ppl_Name"];
|
|
}
|
|
EXTENDCODE31count++;
|
|
}
|
|
}
|
|
if (EXTENDCODE5_s != null)
|
|
{
|
|
foreach (JObject EXTENDCODE51obj in EXTENDCODE5_s.Value<JArray>("data"))
|
|
{
|
|
if (EXTENDCODE51count == 0)
|
|
{
|
|
EXTENDCODE51 = "" + EXTENDCODE51obj["ppl_Name"];
|
|
}
|
|
else
|
|
{
|
|
EXTENDCODE51 += "," + EXTENDCODE51obj["ppl_Name"];
|
|
}
|
|
EXTENDCODE51count++;
|
|
}
|
|
}
|
|
if (LEAVE_PER_s != null)
|
|
{
|
|
foreach (JObject LEAVE_PER1obj in LEAVE_PER_s.Value<JArray>("data"))
|
|
{
|
|
if (LEAVE_PER1count == 0)
|
|
{
|
|
LEAVE_PER1 = "" + LEAVE_PER1obj["ppl_Name"];
|
|
}
|
|
else
|
|
{
|
|
LEAVE_PER1 += "," + LEAVE_PER1obj["ppl_Name"];
|
|
}
|
|
LEAVE_PER1count++;
|
|
}
|
|
}
|
|
model.EXTENDCODE11 = EXTENDCODE11;
|
|
model.EXTENDCODE31 = EXTENDCODE31;
|
|
model.EXTENDCODE51 = EXTENDCODE51;
|
|
model.LEAVE_PER1 = LEAVE_PER1;
|
|
}
|
|
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 GetInspectWeek(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"\",";
|
|
returnstr += "\"data\":";
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string where = "1=1";
|
|
where += " and (ORG_ID ='" + ORG_ID + "' or ORG_ID in (select o.org_id from fire_org o where o.pid = '" + ORG_ID + "') )";
|
|
returnstr += JsonConvert.SerializeObject(bll.TotalDaysAlarm(7, where));
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨操作请求", "获取车辆数量趋势异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨操作请求", "获取车辆数量趋势");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
|
|
//添加查铺查哨
|
|
private string AddInspect(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = Guid.NewGuid().ToString("N");
|
|
string CN_ID = context.Request.Params["CN_ID"];
|
|
string CN_NAME = context.Request.Params["CN_NAME"];
|
|
string SN_ID = context.Request.Params["SN_ID"];
|
|
string SN_NAME = context.Request.Params["SN_NAME"];
|
|
string FID = context.Request.Params["FID"];
|
|
string L_STATE = context.Request.Params["L_STATE"];
|
|
string L_WORK = context.Request.Params["L_WORK"];
|
|
string ADDR = context.Request.Params["ADDR"];
|
|
string LON = context.Request.Params["LON"];
|
|
string LAT = context.Request.Params["LAT"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
|
|
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
|
|
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
|
|
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
|
|
string LEAVE_PER = context.Request.Params["LEAVE_PER"];
|
|
string LEAVE_NUM = context.Request.Params["LEAVE_NUM"];
|
|
|
|
//上传图片
|
|
string A_PHOTO = UploadFile("FireInspect", context, ID);
|
|
|
|
//查铺查哨表
|
|
FangYar.Model.FIRE.FIRE_INSPECT model = new Model.FIRE.FIRE_INSPECT();
|
|
model.ID = ID;
|
|
model.CN_ID = CN_ID;
|
|
model.CN_NAME = CN_NAME;
|
|
model.SN_ID = SN_ID;
|
|
model.SN_NAME = SN_NAME;
|
|
model.FID = FID;
|
|
model.L_STATE = L_STATE;
|
|
model.L_WORK = L_WORK;
|
|
model.ADDR = ADDR;
|
|
model.LON = LON;
|
|
model.LAT = LAT;
|
|
model.ORG_ID = ORG_ID;
|
|
|
|
model.EXTENDCODE1 = EXTENDCODE1;
|
|
model.EXTENDCODE2 = EXTENDCODE2;
|
|
model.EXTENDCODE3 = EXTENDCODE3;
|
|
model.EXTENDCODE4 = EXTENDCODE4;
|
|
model.EXTENDCODE5 = EXTENDCODE5;
|
|
model.EXTENDCODE6 = EXTENDCODE6;
|
|
model.LEAVE_PER = LEAVE_PER;
|
|
model.LEAVE_NUM = LEAVE_NUM;
|
|
model.A_PHOTO = A_PHOTO;
|
|
|
|
if (bll.Add(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 EditInspect(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string CN_ID = context.Request.Params["CN_ID"];
|
|
string CN_NAME = context.Request.Params["CN_NAME"];
|
|
string SN_ID = context.Request.Params["SN_ID"];
|
|
string SN_NAME = context.Request.Params["SN_NAME"];
|
|
string FID = context.Request.Params["FID"];
|
|
string L_STATE = context.Request.Params["L_STATE"];
|
|
string L_WORK = context.Request.Params["L_WORK"];
|
|
string ADDR = context.Request.Params["ADDR"];
|
|
string LON = context.Request.Params["LON"];
|
|
string LAT = context.Request.Params["LAT"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
|
|
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
|
|
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
|
|
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
|
|
string LEAVE_PER = context.Request.Params["LEAVE_PER"];
|
|
string LEAVE_NUM = context.Request.Params["LEAVE_NUM"];
|
|
|
|
//查铺查哨表
|
|
FangYar.Model.FIRE.FIRE_INSPECT model = new Model.FIRE.FIRE_INSPECT();
|
|
model.ID = ID;
|
|
model.CN_ID = CN_ID;
|
|
model.CN_NAME = CN_NAME;
|
|
model.SN_ID = SN_ID;
|
|
model.SN_NAME = SN_NAME;
|
|
model.FID = FID;
|
|
model.L_STATE = L_STATE;
|
|
model.L_WORK = L_WORK;
|
|
model.ADDR = ADDR;
|
|
model.LON = LON;
|
|
model.LAT = LAT;
|
|
model.ORG_ID = ORG_ID;
|
|
|
|
model.EXTENDCODE1 = EXTENDCODE1;
|
|
model.EXTENDCODE2 = EXTENDCODE2;
|
|
model.EXTENDCODE3 = EXTENDCODE3;
|
|
model.EXTENDCODE4 = EXTENDCODE4;
|
|
model.EXTENDCODE5 = EXTENDCODE5;
|
|
model.EXTENDCODE6 = EXTENDCODE6;
|
|
model.LEAVE_PER = LEAVE_PER;
|
|
model.LEAVE_NUM = LEAVE_NUM;
|
|
|
|
|
|
if (bll.Update(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;
|
|
}
|
|
|
|
//home页面查铺统计
|
|
private string homeInspectSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int count = 0;
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string SN_ID = context.Request.Params["SN_ID"];
|
|
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
if (string.IsNullOrEmpty(SN_ID))
|
|
{
|
|
SN_ID = "1";
|
|
}
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and (ORG_ID ='" + OrgId + "')";
|
|
}
|
|
where += " and t.sn_id = '" + SN_ID + "'";
|
|
where += " and extendcode2 is not null";
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"\",";
|
|
DataTable dt = bll.homeSta(pageIndex, pageSize, where, " l_time desc");
|
|
count = dt.Rows.Count;
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨操作请求", "home页面查铺统计异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨操作请求", "home页面查铺统计");
|
|
return returnstr;
|
|
}
|
|
//home页面查铺统计
|
|
private string homeInspectStaAll(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int count = 0;
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string SN_ID = context.Request.Params["SN_ID"];
|
|
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
if (string.IsNullOrEmpty(SN_ID))
|
|
{
|
|
SN_ID = "1";
|
|
}
|
|
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
string where = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where += " and org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) ) ";
|
|
}
|
|
where += " and t.sn_id = '" + SN_ID + "'";
|
|
where += " and extendcode2 is not null";
|
|
|
|
returnstr = "{\"code\":1,\"msg\":\"\",";
|
|
DataTable dt = bll.homeSta(pageIndex, pageSize, where, " l_time desc");
|
|
count = dt.Rows.Count;
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
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, "查铺查哨操作请求", "home页面查铺统计异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨操作请求", "home页面查铺统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//上传图片
|
|
private static string UploadFile(string url, HttpContext context, string CONNMOD_ID)
|
|
{
|
|
string result = "";
|
|
if (context.Request.Files.Count > 0)
|
|
{
|
|
string ImageFilePath = "/Upload/" + url + "/" + DateTime.Now.Year.ToString() + "/" + DateTime.Now.Month.ToString();
|
|
if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(ImageFilePath)) == false)//如果不存在就创建文件夹
|
|
{
|
|
System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(ImageFilePath));
|
|
}
|
|
for (int i = 0; i < context.Request.Files.Count; i++)
|
|
{
|
|
HttpPostedFile item = context.Request.Files[i];
|
|
string fileName = CONNMOD_ID + i + ".png";
|
|
try
|
|
{
|
|
string rootPath = System.AppDomain.CurrentDomain.BaseDirectory + ImageFilePath;
|
|
item.SaveAs(rootPath + fileName);
|
|
result += ImageFilePath + fileName + ",";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result += "";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨操作请求", "上传图片异常:" + e);
|
|
}
|
|
}
|
|
result = result.Substring(0, result.Length - 1);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "查铺查哨操作请求", "上传图片");
|
|
return result;
|
|
}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|