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.
668 lines
30 KiB
668 lines
30 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.IO;
|
|
using Spire.Doc;
|
|
using Spire.Doc.Documents;
|
|
using System.Drawing;
|
|
using Spire.Doc.Fields;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// FirePatrolTraHandler 的摘要说明
|
|
/// </summary>
|
|
public class FirePatrolTraHandler : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.FIRE_PATROL_TRAJECTORY bll = new FangYar.BLL.FIRE_PATROL_TRAJECTORY();
|
|
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 "getTraList":
|
|
returnstr = getTaskIDTralist(context);
|
|
break;
|
|
case "getTraCountState":
|
|
returnstr = getTraCountState(context);
|
|
break;
|
|
case "ReportInspection":
|
|
returnstr = ReportInspection(context);
|
|
break;
|
|
case "RFIDGetModel":
|
|
returnstr = RFIDGetModel(context);
|
|
break;
|
|
case "StatisticsTra":
|
|
returnstr = StatisticsTra(context);
|
|
break;
|
|
case "StatisticsTra2":
|
|
returnstr = StatisticsTra2(context);
|
|
break;
|
|
case "getTraListByTime":
|
|
returnstr = getTraListByTime(context);
|
|
break;
|
|
case "htmlToWord":
|
|
returnstr = htmlToWord(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//根据巡查任务ID查询轨迹列表
|
|
private string getTaskIDTralist(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string taskId = context.Request.Params["taskId"];
|
|
string state = context.Request.Params["state"];
|
|
string where = " TASK_ID = '" + taskId + "' ";
|
|
if (!string.IsNullOrEmpty(state))
|
|
{
|
|
if (state.Contains(","))
|
|
{
|
|
string[] state_s = state.Split(',');
|
|
string states = "";
|
|
for (int i = 0; i < state_s.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
states = "('" + state_s[i] + "'";
|
|
}
|
|
states += ",'" + state_s[i] + "'";
|
|
}
|
|
states += ")";
|
|
where += " and t.state in " + states + " ";
|
|
}
|
|
else
|
|
{
|
|
where += " and t.state = '" + state + "' ";
|
|
}
|
|
}
|
|
where += " order by TIME ";
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"TraData\":";
|
|
DataSet data = bll.GetList(where);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"TraData\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "根据巡查任务ID查询轨迹列表异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "根据巡查任务ID查询轨迹列表");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据任务ID,获取巡查点状态统计数
|
|
private string getTraCountState(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string taskId = context.Request.Params["taskId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"TraData\":";
|
|
DataTable data = bll.GetTraCountState(taskId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"TraData\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "根据任务ID,获取巡查点状态统计数异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "根据任务ID,获取巡查点状态统计数");
|
|
return returnstr;
|
|
}
|
|
|
|
//完成轨迹巡查
|
|
private string ReportInspection(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string USERS_NAME = context.Request.Params["USERS_NAME"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string TASK_ID = context.Request.Params["TASK_ID"];
|
|
string RFID = context.Request.Params["RFID"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
|
|
//上传图片
|
|
string A_PHOTO = UploadFile("FirePatrolTra", context, Guid.NewGuid().ToString("N"));
|
|
|
|
//巡查轨迹表
|
|
FangYar.Model.FIRE_PATROL_TRAJECTORY traModel = new Model.FIRE_PATROL_TRAJECTORY();
|
|
traModel.TASK_ID = TASK_ID;
|
|
traModel.TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
traModel.RFID = RFID;
|
|
traModel.STATE = STATE;
|
|
traModel.PHOTO = A_PHOTO;
|
|
|
|
|
|
string SPOT_ID = context.Request.Params["SPOT_ID"];
|
|
string SPOT_TYPE = context.Request.Params["SPOT_TYPE"];
|
|
string WATER = context.Request.Params["WATER"];
|
|
//巡查点表
|
|
FangYar.Model.FIRE_PATROL_SPOT spotModel = new Model.FIRE_PATROL_SPOT();
|
|
spotModel.RFID = RFID;
|
|
spotModel.STATE = STATE;
|
|
spotModel.WATER = WATER;
|
|
|
|
|
|
|
|
|
|
//巡查隐患表
|
|
FangYar.Model.FIRE_PATROL_DANGER dangerModel = new Model.FIRE_PATROL_DANGER();
|
|
if (STATE == "2")
|
|
{
|
|
string dangerId = Guid.NewGuid().ToString("N");
|
|
string CITY = context.Request.Params["CITY"];
|
|
string DANGER_TYPE = context.Request.Params["DANGER_TYPE"];
|
|
string TASK_NAME = context.Request.Params["TASK_NAME"];
|
|
string A_USERS_UID = context.Request.Params["A_USERS_UID"];
|
|
string A_USERS_NAME = context.Request.Params["A_USERS_NAME"];
|
|
string POINT = context.Request.Params["POINT"];
|
|
string ADDR = context.Request.Params["ADDR"];
|
|
string A_DES = context.Request.Params["A_DES"];
|
|
|
|
dangerModel.ID = dangerId;
|
|
dangerModel.TYPE = DANGER_TYPE;
|
|
dangerModel.TASK_ID = TASK_ID;
|
|
dangerModel.TASK_NAME = TASK_NAME;
|
|
dangerModel.A_USERS_UID = A_USERS_UID;
|
|
dangerModel.A_USERS_NAME = A_USERS_NAME;
|
|
dangerModel.SPOT_ID = SPOT_ID;
|
|
dangerModel.POINT = POINT;
|
|
dangerModel.ADDR = ADDR;
|
|
dangerModel.A_PHOTO = A_PHOTO;
|
|
dangerModel.ORG_ID = ORG_ID;
|
|
dangerModel.CITY = CITY;
|
|
dangerModel.A_DES = A_DES;
|
|
dangerModel.STATE = "0";
|
|
dangerModel.PERSON_NAME = A_USERS_NAME;
|
|
dangerModel.A_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
|
|
bool flag = false;
|
|
if (SPOT_TYPE == "0")
|
|
{
|
|
string IS_COM = context.Request.Params["IS_COM"];//部件完整情况
|
|
string IS_ANT = context.Request.Params["IS_ANT"];// 防锈漆(栓体)
|
|
string IS_LEAK = context.Request.Params["IS_LEAK"];// 锈死漏水
|
|
string IS_IMP = context.Request.Params["IS_IMP"];//井内污水、杂物
|
|
string IS_DAM = context.Request.Params["IS_DAM"];//有无冻损
|
|
string IS_ID = context.Request.Params["IS_ID"];//标识情况
|
|
string IS_PAINT = context.Request.Params["IS_PAINT"];//井盖刷漆
|
|
string HYD_STATE = context.Request.Params["HYD_STATE"];//可用状态
|
|
|
|
FangYar.Model.FIRE.FIRE_HYDRANT_BAK hydModel = new FangYar.Model.FIRE.FIRE_HYDRANT_BAK();
|
|
hydModel.ID = SPOT_ID;
|
|
hydModel.IS_COM = IS_COM;
|
|
hydModel.IS_ANT = IS_ANT;
|
|
hydModel.IS_LEAK = IS_LEAK;
|
|
hydModel.IS_IMP = IS_IMP;
|
|
hydModel.IS_DAM = IS_DAM;
|
|
hydModel.IS_ID = IS_ID;
|
|
hydModel.IS_PAINT = IS_PAINT;
|
|
hydModel.STATE = HYD_STATE;
|
|
|
|
flag = bll.getHydInspectionCompleted(traModel, spotModel, dangerModel, hydModel);
|
|
}
|
|
else if (SPOT_TYPE == "1")
|
|
{
|
|
string IS_COM = context.Request.Params["IS_COM"];//部件完整情况
|
|
string IS_ARP = context.Request.Params["IS_ARP"];// 外观红漆
|
|
string IS_LEAK = context.Request.Params["IS_LEAK"];// 锈死漏水
|
|
string CRANE_STATE = context.Request.Params["CRANE_STATE"];//可用状态
|
|
|
|
FangYar.Model.FIRE.FIRE_CRANE_BAK craneModel = new FangYar.Model.FIRE.FIRE_CRANE_BAK();
|
|
craneModel.ID = SPOT_ID;
|
|
craneModel.IS_COM = IS_COM;
|
|
craneModel.IS_ARP = IS_ARP;
|
|
craneModel.IS_LEAK = IS_LEAK;
|
|
craneModel.STATE = CRANE_STATE;
|
|
|
|
flag = bll.getCraneInspectionCompleted(traModel, spotModel, dangerModel, craneModel);
|
|
}
|
|
|
|
if (flag)
|
|
{
|
|
DataTable data = bll.GetTraCountState(TASK_ID);
|
|
string wxc = data.Rows[0]["WXC"].ToString();
|
|
bool flag2 = false;
|
|
if (wxc == "0")
|
|
{
|
|
FangYar.BLL.FIRE_PATROL_TASK ptbll = new FangYar.BLL.FIRE_PATROL_TASK();
|
|
FangYar.Model.FIRE_PATROL_TASK ptmodel = ptbll.GetModel(TASK_ID);
|
|
ptmodel.STATE = "1";
|
|
flag2 = ptbll.Update(ptmodel);
|
|
}
|
|
else
|
|
{
|
|
flag2 = true;
|
|
}
|
|
if (flag2)
|
|
{
|
|
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;
|
|
}
|
|
|
|
//根据IFID(芯片编号)得到一个对象实体
|
|
private string RFIDGetModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string TASK_ID = context.Request.Params["TASK_ID"];
|
|
string RFID = context.Request.Params["RFID"];
|
|
FangYar.Model.FIRE_PATROL_TRAJECTORY model = bll.RFIDGetModel(TASK_ID, RFID);
|
|
if (model == null)
|
|
{
|
|
return "{\"msg\":\"对不起,该芯片不存在\",\"code\":-1}";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"traData\":";
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
|
|
FangYar.BLL.FIRE_PATROL_SPOT spotBll = new FangYar.BLL.FIRE_PATROL_SPOT();
|
|
|
|
DataTable data = spotBll.getSpotHydModelBySpotId(model.SPOT_ID);
|
|
if (data.Rows.Count == 0)
|
|
{
|
|
data = spotBll.getSpotCraneModelBySpotId(model.SPOT_ID);
|
|
}
|
|
returnstr += ",\"spotData\":";
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = null;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "根据IFID(芯片编号)得到一个对象实体异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "根据IFID(芯片编号)得到一个对象实体");
|
|
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"];
|
|
|
|
string whereStr = "";
|
|
if (is_content == "1")
|
|
{
|
|
whereStr = " and org_id in (select org_id from fire_org o,(select get_Org_child_list('" + orgId + "') cids ) s where find_in_set(org_id,cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
whereStr = " and org_id ='" + orgId + "' ";
|
|
}
|
|
DataTable dt = bll.StatisticsTra(orgId, year, whereStr);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = null;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "按年份查询,按月份统计(未巡查、无隐患、有隐患)统计数异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "按年份查询,按月份统计(未巡查、无隐患、有隐患)统计数");
|
|
return returnstr;
|
|
}
|
|
|
|
//按机构、时间段统计(未巡查、无隐患、有隐患)统计数
|
|
private string StatisticsTra2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
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 whereStr = "";
|
|
if (is_content == "1")
|
|
{
|
|
whereStr = " find_in_set(org_id,cids) ";
|
|
}
|
|
else
|
|
{
|
|
whereStr = " org_id ='" + orgId + "' ";
|
|
}
|
|
DataTable dt = bll.StatisticsTra2(orgId, startDate, endDate, whereStr);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = null;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "按机构、时间段统计(未巡查、无隐患、有隐患)统计数异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "按机构、时间段统计(未巡查、无隐患、有隐患)统计数");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//按机构、时间段 查询列表分页
|
|
private string getTraListByTime(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
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 = null;
|
|
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(substr(time, '0', '10'), '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(substr(time, '0', '10'), '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE_PATROL_TRAJECTORY> list = bll.QueryList(pageIndex, pageSize, where, " time desc");
|
|
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 static string UploadFile(string url, HttpContext context, string CONNMOD_ID)
|
|
{
|
|
string result = "";
|
|
try
|
|
{
|
|
|
|
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
|
|
{
|
|
result += "";
|
|
}
|
|
}
|
|
result = result.Substring(0, result.Length - 1);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "上传图片异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "水资源巡查处理操作请求", "上传图片");
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
//html导出Word
|
|
private string htmlToWord(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string by1 = context.Request.Params["by1"];
|
|
string by2 = context.Request.Params["by2"];
|
|
|
|
//实例化一个Document对象
|
|
Document doc = new Document();
|
|
doc.Watermark = null;
|
|
|
|
//添加section和段落
|
|
Section section = doc.AddSection();
|
|
Paragraph para = section.AddParagraph();
|
|
//加载图片到System.Drawing.Image对象, 使用AppendPicture方法将图片插入到段落
|
|
//Image image = Image.FromFile(@"D:\File\Test\1.jpg");
|
|
Image image1 = GetImage(by1.Replace("data:image/png;base64,", ""));
|
|
Image image2 = GetImage(by2.Replace("data:image/png;base64,", ""));
|
|
Spire.Doc.Fields.DocPicture picture1 = doc.Sections[0].Paragraphs[0].AppendPicture(image1);
|
|
//设置图片大小
|
|
picture1.Width = 595;
|
|
Spire.Doc.Fields.DocPicture picture2 = doc.Sections[0].Paragraphs[0].AppendPicture(image2);
|
|
//设置图片大小
|
|
picture2.Width = 595;
|
|
String[] headerQiandi = { "巡检点名称", "巡检时间", "地点", "巡检状态" }; //表头字段
|
|
|
|
#region 获取table数据
|
|
string orgId = context.Request.Params["orgId"];
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
int pageIndex = 1;
|
|
int pageSize = 99999;
|
|
string where = null;
|
|
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) ) ";
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
where += " and date_format(substr(time, '0', '10'), '%Y-%m-%d') >= date_format('" + startDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
where += " and date_format(substr(time, '0', '10'), '%Y-%m-%d') < date_format('" + endDate + "-01', '%Y-%m-%d') ";
|
|
}
|
|
List<FangYar.Model.FIRE_PATROL_TRAJECTORY> list = bll.QueryList(pageIndex, pageSize, where, " time desc");
|
|
#endregion 获取table数据
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
string[][] arrQiandiData = new string[list.Count][];
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
string stateStr = "未巡查";
|
|
if (list[i].STATE == "1")
|
|
{
|
|
stateStr = "无隐患";
|
|
}
|
|
else
|
|
{
|
|
stateStr = "有隐患";
|
|
}
|
|
arrQiandiData[i] = new string[] {
|
|
list[i].SPOT_NAME,
|
|
list[i].TIME,
|
|
list[i].ADDR,
|
|
stateStr
|
|
};
|
|
}
|
|
#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++) //生成表头
|
|
{
|
|
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 + "\\File\\Fire_Patrol_Statistics\\";
|
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".doc";
|
|
if (Directory.Exists(path) == false)//如果不存在就创建文件夹
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
doc.SaveToFile(path + fileName, FileFormat.Doc);
|
|
returnstr = "/File/Fire_Patrol_Statistics/" + fileName;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查处理操作请求", "html导出Word异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查处理操作请求", "html导出Word");
|
|
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 GetBidTempStrng(string dataUrl)
|
|
//{
|
|
// string returnstr = "";
|
|
// try
|
|
// {
|
|
// StringBuilder sbHtml = new StringBuilder();
|
|
// // html的地址
|
|
// var path = HttpContext.Current.Server.MapPath(dataUrl);
|
|
// using (Stream inStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read))
|
|
// using (StreamReader outStream = new StreamReader(inStream, Encoding.Default))
|
|
// {
|
|
// while (!outStream.EndOfStream)
|
|
// {
|
|
// sbHtml.Append(outStream.ReadLine());
|
|
// }
|
|
// }
|
|
// returnstr = sbHtml.ToString();
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// returnstr = "";
|
|
// }
|
|
// return returnstr;
|
|
//}
|
|
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|