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.
1801 lines
76 KiB
1801 lines
76 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using Newtonsoft.Json;
|
|
using System.IO;
|
|
using Spire.Doc;
|
|
using Spire.Doc.Documents;
|
|
using System.Drawing;
|
|
using Spire.Doc.Fields;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// CarHandler 的摘要说明
|
|
/// </summary>
|
|
public class CarHandler : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.TBL_SYS_CAR bll = new FangYar.BLL.TBL_SYS_CAR();
|
|
FangYar.BLL.TBL_CARACCESS cabll = new BLL.TBL_CARACCESS();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "CarList":
|
|
returnstr = GetCarList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddCar(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditOrgEmp(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelCar(context);
|
|
break;
|
|
case "GetTree":
|
|
returnstr = GetTree(context);
|
|
break;
|
|
case "CarLocationList":
|
|
returnstr = CarLocationList(context);
|
|
break;
|
|
case "View":
|
|
returnstr = View(context);
|
|
break;
|
|
case "GetCarAccessList":
|
|
returnstr = GetCarAccessList(context);
|
|
break;
|
|
case "ViewAccess":
|
|
returnstr = ViewAccess(context);
|
|
break;
|
|
case "GetCarWeek":
|
|
returnstr = GetCarWeek(context);
|
|
break;
|
|
case "GetAppCarList":
|
|
returnstr = GetAppCarList(context);
|
|
break;
|
|
case "CarNumGetModel":
|
|
returnstr = CarNumGetModel(context);
|
|
break;
|
|
case "expList":
|
|
expList(context);
|
|
break;
|
|
case "GetCarListByIMEI":
|
|
returnstr = GetCarListByIMEI(context);
|
|
break;
|
|
case "carAccessSta":
|
|
returnstr = carAccessSta(context);
|
|
break;
|
|
case "carAccessSta2":
|
|
returnstr = carAccessSta2(context);
|
|
break;
|
|
case "homeCarSta":
|
|
returnstr = homeCarSta(context);
|
|
break;
|
|
case "StatisticsTra":
|
|
returnstr = StatisticsTra(context);
|
|
break;
|
|
case "getCarAccListByTime":
|
|
returnstr = getCarAccListByTime(context);
|
|
break;
|
|
case "getCarAccListByTime2":
|
|
returnstr = getCarAccListByTime2(context);
|
|
break;
|
|
case "htmlToWord":
|
|
returnstr = htmlToWord(context);
|
|
break;
|
|
case "htmlToWord2":
|
|
returnstr = htmlToWord2(context);
|
|
break;
|
|
case "getSubordinateData":
|
|
returnstr = getSubordinateData(context);
|
|
break;
|
|
case "getPerAndCarStatisticss":
|
|
returnstr = getPerAndCarStatisticss(context);
|
|
break;
|
|
case "htmlToWord3":
|
|
HtmlToWord3(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
|
|
//查询
|
|
private string GetCarList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string OrgList = context.Request.Params["OrgList"];
|
|
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 bclass = context.Request.Params["class"];
|
|
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)
|
|
{
|
|
|
|
if (is_content == "1")
|
|
{
|
|
where = "( org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids)) ";
|
|
where += " or DEPT_ID in ( select o.org_id from fire_org o,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids)) ";
|
|
}
|
|
else
|
|
{
|
|
where = "( ORG_ID = '" + treeID + "'";
|
|
where += " or DEPT_ID = '" + treeID + "')";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
if (is_content == "1")
|
|
{
|
|
if (!string.IsNullOrEmpty(bclass))
|
|
{
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
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) and CLASS = '" + bclass + "' and CAR_NUM like '%" + keyword + "%' and (is_del != '1' or is_del is null))) ";
|
|
where += " or DEPT_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 = " (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) and CLASS = '" + bclass + "' and (is_del != '1' or is_del is null))) ";
|
|
where += " or DEPT_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
|
|
{
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
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) and CAR_NUM like '%" + keyword + "%' )) ";
|
|
where += " or DEPT_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 = " (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))) ";
|
|
where += " or DEPT_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 = "(ORG_ID = '" + OrgId + "'";
|
|
where += " or DEPT_ID = '" + OrgId + "')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(bclass))
|
|
{
|
|
where += " and CLASS = '" + bclass + "'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " CAR_NUM like '%" + keyword + "%' ";
|
|
}
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += " (is_del != '1' or is_del is null)";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<Model.TBL_SYS_CAR> list = bll.QueryList(pageIndex, pageSize, where, "");
|
|
returnstr += Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string AddCar(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string car_name = context.Request.Params["car_name"];//车辆名称
|
|
string car_no = context.Request.Params["car_no"];//车辆编号
|
|
string org_id = context.Request.Params["org_id"]; //上机消防机关
|
|
string dept_id = context.Request.Params["dept_id"]; //本机消防机关
|
|
|
|
string car_num = context.Request.Params["car_num"];//车辆号牌
|
|
string car_code = context.Request.Params["car_code"];//车辆登记代号
|
|
|
|
string frame_num = context.Request.Params["frame_num"];//车架号
|
|
string engine_no = context.Request.Params["engine_no"];//发动机号
|
|
string trademark = context.Request.Params["trademark"];//商标
|
|
string gbcode = context.Request.Params["gbcode"];//国标代码
|
|
string factory = context.Request.Params["factory"];//出厂厂家
|
|
|
|
string liableman = context.Request.Params["liableman"]; //责任人名称
|
|
string region = context.Request.Params["region"]; //所属辖区
|
|
//string isrun = context.Request.Params["isrun"];//是否运行
|
|
string bigclass = context.Request.Params["class"];//大类型
|
|
string type = context.Request.Params["type"];//小类型
|
|
|
|
string watwernum = context.Request.Params["waternum"];//载水量
|
|
string drypowder = context.Request.Params["drypowder"];//载干粉量
|
|
string heightboardingcar = context.Request.Params["heightboardingcar"]; //登高车工作高度
|
|
string frothamount = context.Request.Params["frothamount"]; //泡沫量
|
|
string frothamounta = context.Request.Params["frothamounta"];//类泡沫量
|
|
|
|
string frothamountb = context.Request.Params["frothamountb"];//类泡沫量
|
|
string frothamountmulti = context.Request.Params["frothamountmulti"];//多功能泡沫量
|
|
string liquidlevel = context.Request.Params["liquidlevel"];//液位
|
|
string pressure = context.Request.Params["pressure"];//压力
|
|
string telnum = context.Request.Params["telnum"];//电话
|
|
|
|
string PHOTO = context.Request.Params["PHOTO"];//车辆照片
|
|
string IMEI = context.Request.Params["IMEI"];//车辆照片
|
|
string remarks = context.Request.Params["REMARKS"];//备注
|
|
|
|
//车辆表
|
|
FangYar.Model.TBL_SYS_CAR model = new Model.TBL_SYS_CAR();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.CAR_NAME = car_name;
|
|
model.CAR_NO = car_no;
|
|
model.ORG_ID = org_id; ;
|
|
model.DEPT_ID = dept_id;
|
|
model.CAR_NUM = car_num;
|
|
model.CAR_CODE = car_code;
|
|
model.FRAME_NUM = frame_num;
|
|
model.ENGINE_NO = engine_no;
|
|
model.TRADEMARK = trademark;
|
|
model.GB_CODE = gbcode;
|
|
model.FACTORY = factory;
|
|
model.LIABLEMAN = liableman;
|
|
model.REGION = region;
|
|
model.ISRUN = "0";
|
|
model.CLASS = bigclass;
|
|
model.TYPE = type;
|
|
model.REMARKS = remarks;
|
|
model.TELNUM = telnum;
|
|
if (!string.IsNullOrEmpty(watwernum))
|
|
{
|
|
model.WATERNUM = Convert.ToDecimal(watwernum);
|
|
}
|
|
if (!string.IsNullOrEmpty(drypowder))
|
|
{
|
|
model.DRYPOWDER = Convert.ToDecimal(drypowder);
|
|
}
|
|
if (!string.IsNullOrEmpty(heightboardingcar))
|
|
{
|
|
model.HEIGHTBOARDINGCAR = Convert.ToDecimal(heightboardingcar);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamount))
|
|
{
|
|
model.FROTHAMOUNT = Convert.ToDecimal(frothamount);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamounta))
|
|
{
|
|
model.FROTHAMOUNTA = Convert.ToDecimal(frothamounta);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamountb))
|
|
{
|
|
model.FROTHAMOUNTB = Convert.ToDecimal(frothamountb);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamountmulti))
|
|
{
|
|
model.FROTHAMOUNTMULTI = Convert.ToDecimal(frothamountmulti);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(liquidlevel))
|
|
{
|
|
model.LIQUIDLEVEL = Convert.ToDecimal(liquidlevel);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(pressure))
|
|
{
|
|
model.PRESSURE = Convert.ToDecimal(pressure);
|
|
}
|
|
|
|
model.ISSTART = "0";
|
|
model.ISAPPLY = "0";
|
|
model.PHOTO = PHOTO;
|
|
model.IMEI = IMEI;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch
|
|
{
|
|
msg = "添加失败!";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string EditOrgEmp(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
string car_name = context.Request.Params["car_name"];//车辆名称
|
|
string car_no = context.Request.Params["car_no"];//车辆编号
|
|
string org_id = context.Request.Params["org_id"]; //上机消防机关
|
|
string dept_id = context.Request.Params["dept_id"]; //本机消防机关
|
|
string car_num = context.Request.Params["car_num"];//车辆号牌
|
|
string car_code = context.Request.Params["car_code"];//车辆登记代号
|
|
|
|
string frame_num = context.Request.Params["frame_num"];//车架号
|
|
string engine_no = context.Request.Params["engine_no"];//发动机号
|
|
string trademark = context.Request.Params["trademark"];//商标
|
|
string gbcode = context.Request.Params["gbcode"];//国标代码
|
|
string factory = context.Request.Params["factory"];//出厂厂家
|
|
|
|
string liableman = context.Request.Params["liableman"]; //责任人名称
|
|
string region = context.Request.Params["region"]; //所属辖区
|
|
//string isrun = context.Request.Params["isrun"];//是否运行
|
|
string bigclass = context.Request.Params["class"];//大类型
|
|
string type = context.Request.Params["type"];//小类型
|
|
|
|
string watwernum = context.Request.Params["waternum"];//载水量
|
|
string drypowder = context.Request.Params["drypowder"];//载干粉量
|
|
string heightboardingcar = context.Request.Params["heightboardingcar"]; //登高车工作高度
|
|
string frothamount = context.Request.Params["frothamount"]; //泡沫量
|
|
string frothamounta = context.Request.Params["frothamounta"];//类泡沫量
|
|
|
|
string frothamountb = context.Request.Params["frothamountb"];//类泡沫量
|
|
string frothamountmulti = context.Request.Params["frothamountmulti"];//多功能泡沫量
|
|
string liquidlevel = context.Request.Params["liquidlevel"];//液位
|
|
string pressure = context.Request.Params["pressure"];//压力
|
|
string telnum = context.Request.Params["telnum"];//电话
|
|
string isstart = context.Request.Params["isstart"];//是否启动
|
|
string isapply = context.Request.Params["isapply"];//申请状态
|
|
|
|
string PHOTO = context.Request.Params["PHOTO"];//车辆照片
|
|
string IMEI = context.Request.Params["IMEI"];//车辆照片
|
|
string remarks = context.Request.Params["remarks"];//备注
|
|
FangYar.Model.TBL_SYS_CAR model = new Model.TBL_SYS_CAR();
|
|
model = bll.GetModel(id);
|
|
if (model != null)
|
|
{
|
|
model.ID = id;
|
|
model.CAR_NAME = car_name;
|
|
model.CAR_NO = car_no;
|
|
model.ORG_ID = org_id;
|
|
model.DEPT_ID = dept_id;
|
|
model.CAR_NUM = car_num;
|
|
model.CAR_CODE = car_code;
|
|
model.FRAME_NUM = frame_num;
|
|
model.ENGINE_NO = engine_no;
|
|
model.TRADEMARK = trademark;
|
|
model.GB_CODE = gbcode;
|
|
model.FACTORY = factory;
|
|
model.LIABLEMAN = liableman;
|
|
model.REGION = region;
|
|
model.ISRUN = "0";
|
|
model.CLASS = bigclass;
|
|
model.TYPE = type;
|
|
model.REMARKS = remarks;
|
|
model.TELNUM = telnum;
|
|
|
|
if (!string.IsNullOrEmpty(watwernum))
|
|
{
|
|
model.WATERNUM = Convert.ToDecimal(watwernum);
|
|
}
|
|
if (!string.IsNullOrEmpty(drypowder))
|
|
{
|
|
model.DRYPOWDER = Convert.ToDecimal(drypowder);
|
|
}
|
|
if (!string.IsNullOrEmpty(heightboardingcar))
|
|
{
|
|
model.HEIGHTBOARDINGCAR = Convert.ToDecimal(heightboardingcar);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamount))
|
|
{
|
|
model.FROTHAMOUNT = Convert.ToDecimal(frothamount);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamounta))
|
|
{
|
|
model.FROTHAMOUNTA = Convert.ToDecimal(frothamounta);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamountb))
|
|
{
|
|
model.FROTHAMOUNTB = Convert.ToDecimal(frothamountb);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(frothamountmulti))
|
|
{
|
|
model.FROTHAMOUNTMULTI = Convert.ToDecimal(frothamountmulti);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(liquidlevel))
|
|
{
|
|
model.LIQUIDLEVEL = Convert.ToDecimal(liquidlevel);
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(pressure))
|
|
{
|
|
model.PRESSURE = Convert.ToDecimal(pressure);
|
|
}
|
|
|
|
if (!String.IsNullOrWhiteSpace(isstart))
|
|
{
|
|
model.ISSTART = isstart;
|
|
}
|
|
else
|
|
{
|
|
model.ISSTART = "0";
|
|
}
|
|
|
|
if (!String.IsNullOrWhiteSpace(isapply))
|
|
{
|
|
model.ISAPPLY = isapply;
|
|
}
|
|
model.PHOTO = PHOTO;
|
|
model.IMEI = IMEI;
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
else
|
|
{
|
|
msg = "修改失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//删除车辆
|
|
private string DelCar(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string EmpList = context.Request.Params["carList"];
|
|
string[] EmpArray = EmpList.Split(',');
|
|
string EmpListString = "";
|
|
for (int i = 0; i < EmpArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
EmpListString = "'" + EmpArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
EmpListString += ",'" + EmpArray[i] + "'";
|
|
}
|
|
}
|
|
if (bll.DeleteList(EmpListString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
return returnstr;
|
|
}
|
|
|
|
//获取车辆tree
|
|
private string GetTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.GetListCarTree(orgId).Tables[0];
|
|
//DataTable data = bll.GetList("ORG_ID='" + orgId + "' and class !=2").Tables[0];
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
if (data.Rows[i]["TYPE"].ToString() == "car")
|
|
{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
}
|
|
else
|
|
{
|
|
data.Rows[i]["nocheck"] = "true";
|
|
}
|
|
}
|
|
returnstr += Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
private string View(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
string data = "";
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];//车辆id
|
|
DataTable dt = new DataTable();
|
|
dt = bll.CarInfo(ID).Tables[0];
|
|
if (dt != null)
|
|
{
|
|
msg = "查看成功!";
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
else
|
|
{
|
|
msg = "查看失败!";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "添加失败!";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
private string GetCarAccessList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string type = context.Request.Params["type"];
|
|
string beginDate = context.Request.Params["startTime"];
|
|
string endDate = context.Request.Params["endTime"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string bclass = context.Request.Params["class"];
|
|
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)
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where = " org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = " ORG_ID = '" + treeID + "'";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
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 = " ORG_ID = '" + OrgId + "'";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(bclass))
|
|
{
|
|
if (bclass == "1")
|
|
{
|
|
where += " and CLASS = '1'";
|
|
}
|
|
else
|
|
{
|
|
where += " and CLASS != '1'";
|
|
}
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( CAR_PLATE like '%" + keyword + "%' or COLOR like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (!String.IsNullOrWhiteSpace(beginDate) && !String.IsNullOrWhiteSpace(endDate))
|
|
{
|
|
if (endDate.Split(' ')[1].TrimStart().TrimEnd().Equals("00:00:00"))
|
|
{
|
|
endDate = endDate.ToDateString() + " 23:59:59";
|
|
}
|
|
//where += " and (START_TIME between '" + beginDate + "' and '" + endDate + "')";
|
|
where += " and (START_TIME between date_format('" + beginDate + "','%Y-%m-%d %H:%i:%s') and date_format('" + endDate + "','%Y-%m-%d %H:%i:%s'))";
|
|
}
|
|
where += " order by START_TIME desc";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = cabll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
string data = "[";
|
|
List<FangYar.Model.TBL_CARACCESS> list = cabll.QueryList(pageIndex, pageSize, where, "");
|
|
|
|
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);
|
|
}
|
|
string className = list[i].CLASS == "0" ? "公务车" : (list[i].CLASS == "1" ? "执勤车" : "私家车");
|
|
data += "{\"ID\":\"" + list[i].ID + "\",\"TYPE\":\"" + list[i].TYPE + "\",\"CAR_PLATE\":\"" + list[i].CAR_PLATE + "\",\"COLOR\":\"" + list[i].COLOR + "\",\"CAR_COLOR\":\"" + list[i].CAR_COLOR + "\",\"CAR_LOGO\":\"" + list[i].CAR_LOGO + "\",\"START_TIME\":\"" + list[i].START_TIME + "\",\"CAMERA_ID\":\"" + list[i].CAMERA_ID + "\",";
|
|
data += "\"ORG_ID\":\"" + list[i].ORG_ID + "\",\"VEHICLETYPE\":\"" + list[i].VEHICLETYPE + "\",\"CAR_ID\":\"" + list[i].CAR_ID + "\",\"INOROUT\":\"" + list[i].INOROUT + "\",\"CLASS\":\"" + list[i].CLASS + "\",\"CLASS_NAME\":\"" + className + "\",\"ADDR\":\"" + list[i].ADDR + "\",\"DUTYMANS\":\"" + list[i].DUTYMANS + "\",\"ORG_NAME\":\"" + list[i].ORG_NAME + "\",\"APPLY_ID\":\"" + list[i].APPLY_ID + "\",\"USERMAN\":\"" + list[i].USERMAN + "\",";
|
|
data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\",";
|
|
data += "\"EXTEND2\":\"" + list[i].EXTEND2 + "\",\"EXTEND3\":\"" + list[i].EXTEND3 + "\"}";
|
|
|
|
if (i != list.Count - 1)
|
|
{
|
|
data += ",";
|
|
}
|
|
}
|
|
returnstr += data + "]";
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
}
|
|
return returnstr;
|
|
}
|
|
//获取车辆进出的详细记录
|
|
private string ViewAccess(HttpContext context)
|
|
{
|
|
FangYar.BLL.TBL_CARACCESS cabll = new BLL.TBL_CARACCESS();
|
|
string strwhere = "1=1 ";
|
|
string returnstr = "";
|
|
string data = "";
|
|
string applyString = "\"\"";
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];//
|
|
DataTable dt = new DataTable();
|
|
|
|
if (!string.IsNullOrEmpty(ID))
|
|
{
|
|
|
|
strwhere += "and ID='" + ID + "'";
|
|
}
|
|
dt = cabll.GetAccessInfo(strwhere).Tables[0];
|
|
if (dt != null)
|
|
{
|
|
msg = "查看成功!";
|
|
data = "[";
|
|
|
|
string pic1 = "";
|
|
string pic2 = "";
|
|
if (dt.Rows[0]["PICTURE"] != null && dt.Rows[0]["PICTURE"].ToString() != "")
|
|
{
|
|
pic1 = Convert.ToBase64String((byte[])dt.Rows[0]["PICTURE"]);
|
|
}
|
|
if (dt.Rows[0]["CLOSEUP_PIC"] != null && dt.Rows[0]["CLOSEUP_PIC"].ToString() != "")
|
|
{
|
|
pic2 = Convert.ToBase64String((byte[])dt.Rows[0]["CLOSEUP_PIC"]);
|
|
}
|
|
//data += "{\"ID\":\"" + dt.Rows[0]["ID"].ToString() + "\",\"TYPE\":\"" + dt.Rows[0]["TYPE"].ToString() + "\",\"CAR_PLATE\":\"" + dt.Rows[0]["CAR_PLATE"].ToString() + "\",\"COLOR\":\"" + dt.Rows[0]["COLOR"].ToString() + "\",\"CAR_COLOR\":\"" + dt.Rows[0]["CAR_COLOR"].ToString() + "\",\"CAR_LOGO\":\"" + dt.Rows[0]["CAR_LOGO"].ToString() + "\",\"START_TIME\":\"" + dt.Rows[0]["START_TIME"].ToString() + "\",\"CAMERA_ID\":\"" + dt.Rows[0]["CAMERA_ID"].ToString() + "\",";
|
|
//data += "\"ORG_ID\":\"" + dt.Rows[0]["ORG_ID"].ToString() + "\",\"ORG_NAME\":\"" + dt.Rows[0]["ORG_NAME"].ToString() + "\",\"VEHICLETYPE\":\"" + dt.Rows[0]["VEHICLETYPE"].ToString() + "\",\"CAR_ID\":\"" + dt.Rows[0]["CAR_ID"].ToString() + "\",\"INOROUT\":\"" + dt.Rows[0]["INOROUT"].ToString() + "\",\"CLASS\":\"" + dt.Rows[0]["CLASS"].ToString() + "\",\"ADDR\":\"" + dt.Rows[0]["ADDR"].ToString() + "\",\"DUTYMANS\":\"" + dt.Rows[0]["DUTYMANS"].ToString() + "\",";
|
|
//data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\",";
|
|
//data += "\"EXTEND2\":\"" + dt.Rows[0]["EXTEND2"].ToString() + "\",\"EXTEND3\":\"" + dt.Rows[0]["EXTEND3"].ToString() + "\"}";
|
|
|
|
string className = dt.Rows[0]["CLASS"].ToString() == "0" ? "公务车" : (dt.Rows[0]["CLASS"].ToString() == "1" ? "执勤车" : "私家车");
|
|
data += "{\"ID\":\"" + dt.Rows[0]["ID"].ToString() + "\",\"TYPE\":\"" + dt.Rows[0]["TYPE"].ToString() + "\",\"CAR_PLATE\":\"" + dt.Rows[0]["CAR_PLATE"].ToString() + "\",\"COLOR\":\"" + dt.Rows[0]["COLOR"].ToString() + "\",\"CAR_COLOR\":\"" + dt.Rows[0]["CAR_COLOR"].ToString() + "\",\"CAR_LOGO\":\"" + dt.Rows[0]["CAR_LOGO"].ToString() + "\",\"START_TIME\":\"" + dt.Rows[0]["START_TIME"].ToString() + "\",\"CAMERA_ID\":\"" + dt.Rows[0]["CAMERA_ID"].ToString() + "\",";
|
|
data += "\"ORG_ID\":\"" + dt.Rows[0]["ORG_ID"].ToString() + "\",\"VEHICLETYPE\":\"" + dt.Rows[0]["VEHICLETYPE"].ToString() + "\",\"CAR_ID\":\"" + dt.Rows[0]["CAR_ID"].ToString() + "\",\"INOROUT\":\"" + dt.Rows[0]["INOROUT"].ToString() + "\",\"CLASS\":\"" + dt.Rows[0]["CLASS"].ToString() + "\",\"CLASS_NAME\":\"" + className + "\",\"ADDR\":\"" + dt.Rows[0]["ADDR"].ToString() + "\",\"DUTYMANS\":\"" + dt.Rows[0]["DUTYMANS"].ToString() + "\",\"ORG_NAME\":\"" + dt.Rows[0]["ORG_NAME"].ToString() + "\",\"APPLY_ID\":\"" + dt.Rows[0]["APPLY_ID"].ToString() + "\",\"USERMAN\":\"" + dt.Rows[0]["USERMAN"].ToString() + "\",";
|
|
data += "\"PICTURE\":\"" + pic1 + "\",\"CLOSEUP_PIC\":\"" + pic2 + "\",";
|
|
data += "\"EXTEND2\":\"" + dt.Rows[0]["EXTEND2"].ToString() + "\",\"EXTEND3\":\"" + dt.Rows[0]["EXTEND3"].ToString() + "\"";
|
|
//data += "\"LIABLEMAN\":\"" + dt.Rows[0]["LIABLEMAN"].ToString() + "\",\"DEPT_NAME\":\"" + dt.Rows[0]["DEPT_NAME"].ToString() + "\"";
|
|
data += "}]";
|
|
FangYar.BLL.TBL_SYS_CARAPPLY applyBll = new FangYar.BLL.TBL_SYS_CARAPPLY();
|
|
FangYar.Model.TBL_SYS_CARAPPLY applyModel = applyBll.GetModel(dt.Rows[0]["APPLY_ID"].ToString());
|
|
if (applyModel != null) applyString = FangYar.Common.JsonHelper.ToJson(applyModel);
|
|
}
|
|
else
|
|
{
|
|
msg = "查看失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "查看失败!";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"data\":" + data + ",\"applyModel\":" + applyString + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//获取车辆轨迹点坐标列表
|
|
private string CarLocationList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
string strWhere = "";
|
|
string ids = "";
|
|
try
|
|
{
|
|
string carList = context.Request.Params["carList"];
|
|
string stime = context.Request.Params["stime"];
|
|
string etime = context.Request.Params["etime"];
|
|
string type = context.Request.Params["type"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
|
|
string[] carids = carList.Split(',');
|
|
|
|
|
|
if (carids.Length > 0)
|
|
{
|
|
foreach (string id in carids)
|
|
{
|
|
ids += "'" + id + "',";
|
|
}
|
|
ids += "' '";
|
|
|
|
strWhere = "carid in (" + ids + ")";
|
|
if (!string.IsNullOrEmpty(stime))
|
|
{
|
|
strWhere += " and ( locatetime between '" + stime + "' and '" + etime + "')";
|
|
}
|
|
|
|
DataTable data = bll.CarLocationList(strWhere, type).Tables[0];
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
//获取车辆数量趋势
|
|
private string GetCarWeek(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(cabll.TotalDaysAlarm(7, where));
|
|
returnstr += "}";
|
|
}
|
|
catch
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"\",";
|
|
returnstr += "}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
//APP查询车辆列表
|
|
private string GetAppCarList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string carName = context.Request.Params["carName"];
|
|
string carNum = context.Request.Params["carNum"];
|
|
string carType = context.Request.Params["carType"];
|
|
string isRun = context.Request.Params["isRun"];
|
|
string isStart = context.Request.Params["isStart"];
|
|
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(carName))
|
|
{
|
|
where += " and CAR_NAME like '%" + carName + "%'";
|
|
}
|
|
if (!string.IsNullOrEmpty(carNum))
|
|
{
|
|
where += " and CAR_NUM like '%" + carNum + "%' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(carType))
|
|
{
|
|
where += " and CLASS = '" + carType + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(isRun))
|
|
{
|
|
where += " and ISRUN = '" + isRun + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(isStart))
|
|
{
|
|
where += " and ISSTART = '" + isStart + "'";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.TBL_SYS_CAR> 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 CarNumGetModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
string data = "";
|
|
string msg = "";
|
|
try
|
|
{
|
|
string CARNUM = context.Request.Params["CARNUM"];//车牌号
|
|
FangYar.Model.TBL_SYS_CAR model = bll.CarNumGetModel("", CARNUM);
|
|
if (model != null)
|
|
{
|
|
msg = "查看成功!";
|
|
data = FangYar.Common.JsonHelper.ToJson(model);
|
|
}
|
|
else
|
|
{
|
|
msg = "查看失败!";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "查看失败!";
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
//导出公务车辆
|
|
|
|
private void expList(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string bclass = context.Request.Params["class"];
|
|
|
|
string where = "1=1 and (is_del != '1' or is_del is null)";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( org_id in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) ) ";
|
|
where += " or DEPT_ID in ( select o.org_id from fire_org o ,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids) )) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + treeID + "'";
|
|
where += " or DEPT_ID = '" + treeID + "')";
|
|
}
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
if (is_content == "1")
|
|
{
|
|
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) ) ";
|
|
where += " or DEPT_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 = '" + OrgId + "'";
|
|
where += " or DEPT_ID = '" + OrgId + "')";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(bclass))
|
|
{
|
|
where += " and CLASS = '" + bclass + "'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
if (where != null)
|
|
{
|
|
where += " and ";
|
|
}
|
|
where += "( CAR_NUM like '%" + keyword + "%' or CAR_NAME like '%" + keyword + "%')";
|
|
}
|
|
int count = bll.GetRecordCount(where);
|
|
|
|
if (count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.expList(where);
|
|
|
|
System.Collections.Generic.Dictionary<string, string> cellHeaders = new System.Collections.Generic.Dictionary<string, string>();
|
|
cellHeaders.Add("CLASS", "车辆类型");
|
|
cellHeaders.Add("CAR_NAME", "车辆名称");
|
|
cellHeaders.Add("CAR_NO", "车辆编码");
|
|
cellHeaders.Add("CAR_NUM", "号牌号码");
|
|
cellHeaders.Add("TYPE", "车辆应用");
|
|
cellHeaders.Add("ORG_NAME", "机构");
|
|
|
|
cellHeaders.Add("DEPT_NAME", "部门");
|
|
cellHeaders.Add("CAR_CODE", "车辆登记代号");
|
|
cellHeaders.Add("FRAME_NUM", "车架号");
|
|
cellHeaders.Add("ENGINE_NO", "发动机编号");
|
|
cellHeaders.Add("TRADEMARK", "商标");
|
|
|
|
cellHeaders.Add("GB_CODE", "国标代码");
|
|
cellHeaders.Add("LIABLEMAN", "责任人");
|
|
cellHeaders.Add("TELNUM", "电话");
|
|
//cellHeaders.Add("FACTORY", "厂家名称1");
|
|
|
|
cellHeaders.Add("FACTORYNAME", "厂家名称");
|
|
cellHeaders.Add("AREA_NAME", "所属辖区");
|
|
|
|
cellHeaders.Add("ISRUN", "是否运行");
|
|
cellHeaders.Add("ISSTART", "是否启动");
|
|
cellHeaders.Add("ISAPPLY", "申请状态");
|
|
cellHeaders.Add("REMARKS", "备注");
|
|
cellHeaders.Add("LIMIT", "车辆限速");
|
|
cellHeaders.Add("EMP_NAME", "驾驶员");
|
|
|
|
cellHeaders.Add("WATERNUM", "载水量");
|
|
cellHeaders.Add("DRYPOWDER", "载干粉量");
|
|
cellHeaders.Add("HEIGHTBOARDINGCAR", "登高车工作高度");
|
|
cellHeaders.Add("FROTHAMOUNT", "泡沫量");
|
|
cellHeaders.Add("FROTHAMOUNTA", "类泡沫量");
|
|
|
|
cellHeaders.Add("FROTHAMOUNTB", "类泡沫量");
|
|
cellHeaders.Add("FROTHAMOUNTMULTI", "多功能泡沫量");
|
|
cellHeaders.Add("LIQUIDLEVEL", "液位");
|
|
cellHeaders.Add("PRESSURE", "压力");
|
|
|
|
FangYar.Common.NPOIExcelHelper.ExportByWeb(dt, null, cellHeaders, DateTime.Now.ToString("yyyyMMddHHmmss") + "车辆信息表.xls");
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
//查询装有IMEI的车辆
|
|
private string GetCarListByIMEI(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string carNum = context.Request.Params["carNum"];
|
|
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 = " (IMEI is not null or FACTORY = '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(carNum))
|
|
{
|
|
where += " and CAR_NUM like '%" + carNum + "%' ";
|
|
}
|
|
where += " and (is_del != '1' or is_del is null)";
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.TBL_SYS_CAR> 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 carAccessSta(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 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 = cabll.carAccessSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "获取失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
/***
|
|
* 车辆出入比例统计
|
|
*/
|
|
private string carAccessSta2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = "";
|
|
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))
|
|
{
|
|
return "{\"code\":" + code + ",\"msg\":\"所属机构不能为空\",\"data\":" + data + "}";
|
|
}
|
|
if (is_content == "1")
|
|
{
|
|
strWhere = " org_id in (select o.org_id from fire_org o,(select get_Org_child_list('"+ ORG_ID + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
strWhere = " org_id = '" + ORG_ID + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date_format('" + S_Time + "-01','%Y-%m-%d') < date_format(START_TIME,'%Y-%m-%d')";
|
|
strWhere += " and date_format('" + E_Time + "-01','%Y-%m-%d') > date_format(START_TIME,'%Y-%m-%d')";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(START_TIME,'%Y-%m-%d')";
|
|
}
|
|
DataTable dt = cabll.carAccessSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
}
|
|
catch
|
|
{
|
|
msg = "获取失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 首页车辆统计
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string homeCarSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and ORG_ID='" + ORG_ID + "' and (is_del != '1' or is_del is null)";
|
|
DataTable dt = bll.homeCarSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
msg = "获取失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//按年份查询,按月份统计(未巡查、无隐患、有隐患)统计数
|
|
private string StatisticsTra(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string year = context.Request.Params["year"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
DataTable dt = cabll.StatisticsTra(orgId, year, is_content);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = null;
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//按车牌号、时间段 查询列表分页
|
|
private string getCarAccListByTime(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string carNum = context.Request.Params["carNum"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
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 (carNum != null && carNum != "")
|
|
{
|
|
where = " CAR_PLATE = '" + carNum + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(where))
|
|
{
|
|
where += "and";
|
|
}
|
|
if (is_content == "1")
|
|
{
|
|
where += " 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(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " org_id = '" + orgId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
where += " and date_format(START_TIME, '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(START_TIME, '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = cabll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
where += " order by START_TIME desc";
|
|
List<FangYar.Model.TBL_CARACCESS> list = cabll.QueryList(pageIndex, pageSize, where, "");
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//按车牌号、时间段 分组统计出入次数
|
|
private string getCarAccListByTime2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
int count = 0;
|
|
string where = null;
|
|
try
|
|
{
|
|
string carNum = context.Request.Params["carNum"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (string.IsNullOrEmpty(orgId))
|
|
{
|
|
return "{\"code\":" + code + ",\"msg\":\"所属机构不能为空\",\"data\":" + data + "}";
|
|
}
|
|
if (carNum != null && carNum != "")
|
|
{
|
|
where = " c.CAR_PLATE = '" + carNum + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(where))
|
|
{
|
|
where += "and";
|
|
}
|
|
if (is_content == "1")
|
|
{
|
|
where += " c.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(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " c.org_id = '" + orgId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
where += " and date_format(c.START_TIME, '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(c.START_TIME, '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
where += " AND c.class in ('0','1') GROUP BY o.org_name, c.CAR_PLATE, c.class";
|
|
|
|
DataTable dt = cabll.getCarAccListByTime2(where);
|
|
code = 0;
|
|
count = dt.Rows.Count;
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
catch
|
|
{
|
|
msg = "获取失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//html导出Word
|
|
private string htmlToWord(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string by1 = context.Request.Params["by1"];
|
|
|
|
|
|
//实例化一个Document对象
|
|
Document doc = new Document();
|
|
doc.Watermark = null;
|
|
|
|
//添加section和段落
|
|
Section section = doc.AddSection();
|
|
Paragraph para = section.AddParagraph();
|
|
//加载图片到System.Drawing.Image对象, 使用AppendPicture方法将图片插入到段落
|
|
if (by1 != null && by1 != "")
|
|
{
|
|
by1 = HttpUtility.UrlDecode(by1);
|
|
Image image1 = GetImage(by1.Replace("data:image/png;base64,", ""));
|
|
Spire.Doc.Fields.DocPicture picture1 = doc.Sections[0].Paragraphs[0].AppendPicture(image1);
|
|
//设置图片大小
|
|
picture1.Width = 595;
|
|
}
|
|
|
|
String[] headerQiandi = { "所属消防机构", "车牌号", "时间", "方向", "车辆类别" }; //表头字段
|
|
|
|
#region 获取table数据
|
|
string carNum = context.Request.Params["carNum"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
int pageIndex = 1;
|
|
int pageSize = 99999;
|
|
string where = null;
|
|
if (carNum != null && carNum != "")
|
|
{
|
|
where = " CAR_PLATE = '" + carNum + "' ";
|
|
}
|
|
else
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where = " 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(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where = " org_id = '" + orgId + "' ";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
where += " and date_format(START_TIME, '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(START_TIME, '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
where += " order by START_TIME desc";
|
|
List<FangYar.Model.TBL_CARACCESS> list = cabll.QueryList(pageIndex, pageSize, where, "");
|
|
#endregion 获取table数据
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
string[][] arrQiandiData = new string[list.Count][];
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
var classStr = "无类型";
|
|
switch (list[i].CLASS)
|
|
{
|
|
case "0":
|
|
classStr = "公务车";
|
|
break;
|
|
case "1":
|
|
classStr = "执勤车";
|
|
break;
|
|
case "2":
|
|
classStr = "私家车";
|
|
break;
|
|
}
|
|
|
|
var inoroutStr = "未知";
|
|
switch (list[i].INOROUT)
|
|
{
|
|
case "0":
|
|
inoroutStr = "进入";
|
|
break;
|
|
case "1":
|
|
inoroutStr = "离开";
|
|
break;
|
|
}
|
|
arrQiandiData[i] = new string[] {
|
|
list[i].ORG_NAME,
|
|
list[i].CAR_PLATE,
|
|
list[i].START_TIME.ToString(),
|
|
inoroutStr,
|
|
classStr
|
|
};
|
|
}
|
|
#region 创建Word表格
|
|
Table tableQiandi = section.AddTable(); //新建表格
|
|
tableQiandi.ResetCells(list.Count + 1, headerQiandi.Length);
|
|
tableQiandi.TableFormat.Borders.BorderType = Spire.Doc.Documents.BorderStyle.Single;
|
|
|
|
TableRow rowQiandi = tableQiandi.Rows[0]; //添加行
|
|
rowQiandi.IsHeader = true; //设为表头
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
for (int i = 0; i < headerQiandi.Length; i++) //生成表头
|
|
{
|
|
if (i == 2)
|
|
{
|
|
rowQiandi.Cells[i].Width = 170;
|
|
}
|
|
else if (i == 3)
|
|
{
|
|
rowQiandi.Cells[i].Width = 120;
|
|
}
|
|
else
|
|
{
|
|
rowQiandi.Cells[i].Width = 145;
|
|
}
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.Cells[i].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
Paragraph p = rowQiandi.Cells[i].AddParagraph();
|
|
AddTextRange(section, p, headerQiandi[i], 14, true, "黑体", Spire.Doc.Documents.HorizontalAlignment.Center);
|
|
}
|
|
|
|
for (int r = 0; r < arrQiandiData.Length; r++) //生成表体
|
|
{
|
|
TableRow dataRow = tableQiandi.Rows[r + 1];
|
|
dataRow.RowFormat.BackColor = Color.Empty;
|
|
for (int c = 0; c < arrQiandiData[r].Length; c++)
|
|
{
|
|
if (c == 2)
|
|
{
|
|
dataRow.Cells[c].Width = 170;
|
|
}
|
|
else if (c == 3)
|
|
{
|
|
dataRow.Cells[c].Width = 120;
|
|
}
|
|
else
|
|
{
|
|
dataRow.Cells[c].Width = 145;
|
|
}
|
|
dataRow.Height = 20;
|
|
dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(arrQiandiData[r][c]);
|
|
tr.CharacterFormat.FontSize = 12;
|
|
}
|
|
}
|
|
#endregion 创建Word表格
|
|
}
|
|
//保存到文档
|
|
string path = AppDomain.CurrentDomain.BaseDirectory + "\\OA\\VehicleAccess_Statistics\\";
|
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".doc";
|
|
if (Directory.Exists(path) == false)//如果不存在就创建文件夹
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
doc.SaveToFile(path + fileName, FileFormat.Doc);
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"url\":\"/OA/VehicleAccess_Statistics/" + fileName + "\"}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\"}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
//html导出Word
|
|
private string htmlToWord2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
//实例化一个Document对象
|
|
Document doc = new Document();
|
|
doc.Watermark = null;
|
|
|
|
//添加section和段落
|
|
Section section = doc.AddSection();
|
|
Paragraph para = section.AddParagraph();
|
|
|
|
String[] headerQiandi = { "所属消防机构", "车牌号", "车辆类别", "出入次数" }; //表头字段
|
|
|
|
#region 获取table数据
|
|
string carNum = context.Request.Params["carNum"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string where = null;
|
|
if (string.IsNullOrEmpty(orgId))
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"所属机构不能为空\"}";
|
|
}
|
|
if (carNum != null && carNum != "")
|
|
{
|
|
where = " c.CAR_PLATE = '" + carNum + "' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(where))
|
|
{
|
|
where += "and";
|
|
}
|
|
if (is_content == "1")
|
|
{
|
|
where += " c.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(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " c.org_id = '" + orgId + "' ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
where += " and date_format(c.START_TIME, '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(c.START_TIME, '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
where += " AND c.class in ('0','1') GROUP BY o.org_name, c.CAR_PLATE, c.class";
|
|
|
|
DataTable dt = cabll.getCarAccListByTime2(where);
|
|
#endregion 获取table数据
|
|
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
string[][] arrQiandiData = new string[dt.Rows.Count][];
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
arrQiandiData[i] = new string[] {
|
|
dt.Rows[i]["ORG_NAME"].ToString(),
|
|
dt.Rows[i]["CAR_PLATE"].ToString(),
|
|
dt.Rows[i]["CLASS_NAME"].ToString(),
|
|
dt.Rows[i]["COUNTNUM"].ToString()
|
|
};
|
|
}
|
|
#region 创建Word表格
|
|
Table tableQiandi = section.AddTable(); //新建表格
|
|
tableQiandi.ResetCells(dt.Rows.Count + 1, headerQiandi.Length);
|
|
tableQiandi.TableFormat.Borders.BorderType = Spire.Doc.Documents.BorderStyle.Single;
|
|
|
|
TableRow rowQiandi = tableQiandi.Rows[0]; //添加行
|
|
rowQiandi.IsHeader = true; //设为表头
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
for (int i = 0; i < headerQiandi.Length; i++) //生成表头
|
|
{
|
|
rowQiandi.Cells[i].Width = 145;
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.Cells[i].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
Paragraph p = rowQiandi.Cells[i].AddParagraph();
|
|
AddTextRange(section, p, headerQiandi[i], 14, true, "黑体", Spire.Doc.Documents.HorizontalAlignment.Center);
|
|
}
|
|
|
|
for (int r = 0; r < arrQiandiData.Length; r++) //生成表体
|
|
{
|
|
TableRow dataRow = tableQiandi.Rows[r + 1];
|
|
dataRow.RowFormat.BackColor = Color.Empty;
|
|
for (int c = 0; c < arrQiandiData[r].Length; c++)
|
|
{
|
|
dataRow.Cells[c].Width = 145;
|
|
dataRow.Height = 20;
|
|
dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(arrQiandiData[r][c]);
|
|
tr.CharacterFormat.FontSize = 12;
|
|
}
|
|
}
|
|
#endregion 创建Word表格
|
|
}
|
|
//保存到文档
|
|
string path = AppDomain.CurrentDomain.BaseDirectory + "\\OA\\VehicleAccess_Statistics\\";
|
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".doc";
|
|
if (Directory.Exists(path) == false)//如果不存在就创建文件夹
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
doc.SaveToFile(path + fileName, FileFormat.Doc);
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"url\":\"/OA/VehicleAccess_Statistics/" + fileName + "\"}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\"}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
|
|
private Image GetImage(string fileName)
|
|
{
|
|
byte[] bytes = Convert.FromBase64String(fileName);
|
|
using (MemoryStream ms = new MemoryStream(bytes))
|
|
{
|
|
return Image.FromStream(ms);
|
|
}
|
|
}
|
|
|
|
private void AddTextRange(Section section, Paragraph pragraph, string word, float fontSize, bool isBold, string fontName, Spire.Doc.Documents.HorizontalAlignment alignType)
|
|
{
|
|
|
|
TextRange textRange = pragraph.AppendText(word);
|
|
textRange.CharacterFormat.FontSize = fontSize;
|
|
textRange.CharacterFormat.Bold = isBold;
|
|
textRange.CharacterFormat.FontName = fontName;
|
|
pragraph.Format.HorizontalAlignment = alignType;
|
|
}
|
|
|
|
|
|
|
|
//首页统计下级单位车辆/人员数量
|
|
private string getSubordinateData(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
//车数
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"carData\":";
|
|
string carWhere = " (is_del != '1' or is_del is null) and org_id in (select o1.org_id from fire_org o1 where o1.pid = '" + ORG_ID + "' )";
|
|
DataTable cardt = bll.homeCarSta(carWhere);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(cardt);
|
|
|
|
//人数
|
|
FangYar.BLL.TBL.SysEmpBLL ebll = new FangYar.BLL.TBL.SysEmpBLL();
|
|
returnstr += ",\"perData\":";
|
|
string perWhere = " is_del='0' and org_id in (select o1.org_id from fire_org o1 where o1.pid = '" + ORG_ID + "' )";
|
|
DataTable perdt = ebll.personSta(perWhere);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(perdt);
|
|
|
|
//列表
|
|
returnstr += ",\"listData\":";
|
|
DataTable listdt = bll.getSubordinateData(ORG_ID);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(listdt);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"carData\":[],\"perData\":[] }";
|
|
}
|
|
return returnstr;
|
|
}
|
|
//统计分析人员、车辆按单位统计
|
|
private string getPerAndCarStatisticss(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
{
|
|
DataTable dt = bll.getPerAndCarStatisticss(OrgId);
|
|
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"" + e.Message + "\",\"count\":0,\"data\":[]}";
|
|
}
|
|
return returnstr;
|
|
}
|
|
//导出excel
|
|
private void HtmlToWord3(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
|
|
//string whereStr = "";
|
|
//if (!string.IsNullOrEmpty(OrgId))
|
|
//{
|
|
// whereStr = " and pid ='" + OrgId + "' ";
|
|
//}
|
|
|
|
DataTable dt = bll.getPerAndCarStatisticss(OrgId);
|
|
|
|
if (dt.Rows.Count == 0)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
dt.Columns.Remove("ORG_ID");
|
|
dt.Columns.Remove("PID");
|
|
System.Collections.Generic.Dictionary<string, string> cellHeaders = new System.Collections.Generic.Dictionary<string, string>();
|
|
|
|
|
|
cellHeaders.Add("ORG_NAME", "单位名称");
|
|
cellHeaders.Add("PERNUM", "人员总数");
|
|
cellHeaders.Add("CARNUM", "车辆总数");
|
|
|
|
|
|
FangYar.Common.NPOIExcelHelper.ExportByWeb(dt, null, cellHeaders, DateTime.Now.ToString("yyyyMMddHHmmss") + "单位人员、车辆统计表.xls");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|