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.
1328 lines
60 KiB
1328 lines
60 KiB
using FangYar.Model;
|
|
using FangYar.Model.OA;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// Oa_PatrolSentryTaskHandler 的摘要说明
|
|
/// </summary>
|
|
public class Oa_PatrolSentryTaskHandler : IHttpHandler
|
|
{
|
|
|
|
private FangYar.BLL.OA.OA_PATROLSENTRYTASK bll = new BLL.OA.OA_PATROLSENTRYTASK();
|
|
private FangYar.BLL.FIRE.FIRE_INSPECT ins_bll = new BLL.FIRE.FIRE_INSPECT();
|
|
private FangYar.BLL.FIRE.FIRE_SHIFTS shifts_bll = new BLL.FIRE.FIRE_SHIFTS();
|
|
private FangYar.BLL.OA_PATROL_SPOT spot_bll = new BLL.OA_PATROL_SPOT();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "查铺查哨2操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = getList(context);
|
|
break;
|
|
case "getInspectList":
|
|
returnstr = getInspectList(context);
|
|
break;
|
|
case "getInspectModel":
|
|
returnstr = getInspectModel(context);
|
|
break;
|
|
case "getShiftsModel":
|
|
returnstr = getShiftsModel(context);
|
|
break;
|
|
case "AddInspect":
|
|
returnstr = AddInspect(context);
|
|
break;
|
|
case "ListByOrgId":
|
|
returnstr = ListByOrgId(context);
|
|
break;
|
|
case "ListBySentryTask":
|
|
returnstr = ListBySentryTask(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = Del(context);
|
|
break;
|
|
case "AddTran":
|
|
returnstr = AddTran(context);
|
|
break;
|
|
case "AddTranBySelectSpots":
|
|
returnstr = AddTranBySelectSpots(context);
|
|
break;
|
|
case "DelSentryTask":
|
|
returnstr = DelSentryTask(context);
|
|
break;
|
|
case "GetInspectEcharsData":
|
|
returnstr = GetInspectEcharsData(context);
|
|
break;
|
|
case "appList":
|
|
returnstr = appList(context);
|
|
break;
|
|
case "appListHistory":
|
|
returnstr = appListHistory(context);
|
|
break;
|
|
case "GetCPCSStaDataHome":
|
|
returnstr = GetCPCSStaDataHome(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string getList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string PATROLLERID = context.Request.Params["PATROLLERID"];
|
|
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); }
|
|
int endIndex = pageSize;
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
|
|
string where = null;
|
|
where = " PATROLLERID = '" + PATROLLERID + "' ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, " BEGINDATE desc", startIndex, endIndex).Tables[0];
|
|
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, "查铺查哨2操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
private string getInspectList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string SENTRYTASKID = context.Request.Params["SENTRYTASKID"];
|
|
|
|
string where = null;
|
|
where = " SENTRYTASKID = '" + SENTRYTASKID + "' ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = ins_bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = ins_bll.GetList(where).Tables[0];
|
|
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, "查铺查哨2操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据IFID(芯片编号)得到一个对象实体(查铺查哨判断被查人是否在岗)
|
|
private string getInspectModel(HttpContext context)
|
|
{
|
|
int code = -1;
|
|
string msg = "";
|
|
int count = 0;
|
|
string data = "";
|
|
|
|
try
|
|
{
|
|
string SENTRYTASKID = context.Request.Params["SENTRYTASKID"];
|
|
string FID = context.Request.Params["FID"];
|
|
string where = null;
|
|
where = " SENTRYTASKID = '" + SENTRYTASKID + "' ";
|
|
where += " and FID = '" + FID + "' ";
|
|
|
|
count = ins_bll.GetRecordCount(where);
|
|
|
|
if (count == 0)
|
|
{
|
|
code = 0;
|
|
msg = "未查询到巡检点信息,请您核对。";
|
|
data += "[]";
|
|
}
|
|
else
|
|
{
|
|
code = 1;
|
|
msg = "OK";
|
|
DataTable dt = ins_bll.GetList(where).Tables[0];
|
|
data += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = "系统错误,请联系管理员!";
|
|
count = 0;
|
|
data = "[]";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", " 查铺查哨判断被查人是否在岗异常:" + e);
|
|
}
|
|
string returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "根据IFID(芯片编号)得到一个对象实体(查铺查哨判断被查人是否在岗)");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加查铺
|
|
private string AddInspect(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"];
|
|
string FORMAT = context.Request.Params["FORMAT"];
|
|
|
|
//上传图片
|
|
string A_PHOTO = UploadFile("FireInspect", context, ID);
|
|
|
|
//判断查铺查哨任务是否开始,是否完成,修改任务状态
|
|
//?????
|
|
|
|
//查铺查哨表
|
|
FangYar.Model.FIRE.FIRE_INSPECT2 model = ins_bll.GetModel2(ID);
|
|
if (model != null)
|
|
{
|
|
model.ID = ID;
|
|
model.CN_ID = CN_ID;
|
|
model.CN_NAME = CN_NAME;
|
|
model.L_DATE = DateTime.Now;
|
|
model.L_TIME = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
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;
|
|
model.FORMAT = FORMAT;
|
|
}
|
|
|
|
if (ins_bll.Update2(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "添加查铺异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "查铺查哨2操作请求", "添加查铺");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据当前哨位值班人
|
|
private string getShiftsModel(HttpContext context)
|
|
{
|
|
int code = -1;
|
|
string msg = "";
|
|
int count = 0;
|
|
string data = "";
|
|
|
|
try
|
|
{
|
|
string FID = context.Request.Params["FID"];
|
|
string where = null;
|
|
where = " EXTENDCODE3 = '" + FID + "' ";
|
|
|
|
count = shifts_bll.GetRecordCount(where);
|
|
|
|
if (count == 0)
|
|
{
|
|
code = 0;
|
|
//msg = "未查询到哨位点配置信息,请您核对。";
|
|
msg = "该点不为哨位点或未制定哨兵值班任务!";
|
|
data += "[]";
|
|
}
|
|
else
|
|
{
|
|
where += " and O_DATE < date_format('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','%Y-%m-%d %H:%i:%s')";
|
|
where += " and T_DATE > date_format('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','%Y-%m-%d %H:%i:%s')";
|
|
int count2 = shifts_bll.GetRecordCount(where);
|
|
if (count2 == 0)
|
|
{
|
|
code = 0;
|
|
msg = "当前时间未配置在岗人员!";
|
|
data += "[]";
|
|
}
|
|
else
|
|
{
|
|
code = 1;
|
|
msg = "OK";
|
|
DataTable dt = shifts_bll.GetList(where).Tables[0];
|
|
string datastr = "{ \"data\":[";
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
{
|
|
//此处O_ID应为账号,以后再改
|
|
datastr += "{\"ppl_Id\":\"" + dt.Rows[i]["O_UID"].ToString() + "\",\"ppl_Name\":\"" + dt.Rows[i]["O_NAME"].ToString() + "\"}";
|
|
|
|
if (i < dt.Rows.Count - 1)
|
|
{
|
|
datastr += ",";
|
|
}
|
|
}
|
|
datastr += "]}";
|
|
data = datastr;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = "系统错误,请联系管理员!";
|
|
count = 0;
|
|
data = "[]";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "根据当前哨位值班人异常:" + e);
|
|
}
|
|
string returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "根据当前哨位值班人");
|
|
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;
|
|
System.Drawing.Image img = Image.FromStream(item.InputStream);
|
|
//创建画布
|
|
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(img);
|
|
g.DrawString(DateTime.Now.ToString(), new Font("黑体", 100), new SolidBrush(Color.Black), 10, 10);
|
|
|
|
//释放画布
|
|
g.Dispose();
|
|
System.Drawing.Image img2 = new Bitmap(img);
|
|
img.Dispose();
|
|
img2.Save(rootPath + fileName);
|
|
img2.Dispose();
|
|
result += ImageFilePath + fileName + ",";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
result += "";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "上传图片异常:" + e);
|
|
}
|
|
|
|
}
|
|
result = result.Substring(0, result.Length - 1);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "查铺查哨2操作请求", "上传图片");
|
|
return result;
|
|
}
|
|
|
|
//
|
|
private string ListByOrgId(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
int endIndex = pageSize;
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(treeID))
|
|
{
|
|
OrgId = treeID;
|
|
}
|
|
if (!string.IsNullOrEmpty(OrgId))
|
|
{
|
|
where = " ORGID ='" + OrgId + "'";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, " BEGINDATE desc", startIndex, endIndex).Tables[0];
|
|
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, "查铺查哨2操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//
|
|
private string ListBySentryTask(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string SentryTaskID = context.Request.Params["SentryTaskID"];
|
|
|
|
string where = "";
|
|
if (!string.IsNullOrEmpty(SentryTaskID))
|
|
{
|
|
where = " SENTRYTASKID ='" + SentryTaskID + "'";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = ins_bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = ins_bll.GetList(where).Tables[0];
|
|
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, "查铺查哨2操作请求", "查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string Del(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
|
|
if (ins_bll.Delete(ID))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"删除成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"删除失败!\",\"data\":[]}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"删除失败!\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "删除异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "查铺查哨2操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
|
|
|
|
//private string AddTran(HttpContext context)
|
|
//{
|
|
// string returnstr = "";
|
|
// try
|
|
// {
|
|
// //string ID = Guid.NewGuid().ToString("N");
|
|
// string ID = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
// string orgid = context.Request.Params["orgid"];
|
|
// string patrollerid = context.Request.Params["patrollerid"];
|
|
// string patroller = context.Request.Params["patroller"];
|
|
// string plandate = context.Request.Params["plandate"];
|
|
// string startTime = context.Request.Params["startTime"];
|
|
// string endTime = context.Request.Params["endTime"];
|
|
// string createby = context.Request.Params["createby"];
|
|
|
|
// FangYar.Model.OA.OA_PATROLSENTRYTASK model = new Model.OA.OA_PATROLSENTRYTASK();
|
|
// model.ID = ID;
|
|
// model.ORGID = orgid;
|
|
// //model.TASKNAME = plandate + "-" + Convert.ToDateTime(plandate).AddDays(1).ToString("yyyy-MM-dd") + "查铺查哨任务";
|
|
// model.TASKNAME = plandate + "查铺查哨任务";
|
|
// model.PATROLLERID = patrollerid;
|
|
// model.PATROLLER = patroller;
|
|
|
|
// model.BEGINDATE = Convert.ToDateTime(startTime);
|
|
// model.ENDDATE = Convert.ToDateTime(endTime);
|
|
// model.STATE = "0";
|
|
// model.CREATEDATE = DateTime.Now;
|
|
// model.CREATEBY = createby;
|
|
// model.UPDATEDATE = DateTime.Now;
|
|
// model.UPDATEBY = "";
|
|
|
|
// //查询巡查点信息
|
|
// FangYar.Model.OA_PATROL_SPOT dalpatrolspot = new Model.OA_PATROL_SPOT();
|
|
// string where = " 1=1 and ( extendcode1='1' or extendcode1='2') and ORG_ID='" + orgid + "'";
|
|
// DataTable patrolspot = spot_bll.GetList(where).Tables[0];
|
|
|
|
// if (bll.AddTran(model, patrolspot))
|
|
// {
|
|
// returnstr = "{\"code\":1,\"msg\":\"添加成功!\",\"data\":[]}";
|
|
// }
|
|
// else
|
|
// {
|
|
// returnstr = "{\"code\":0,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
// }
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// returnstr = "{\"code\":-1,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
// }
|
|
// return returnstr;
|
|
|
|
//}
|
|
private string AddTran(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
//string ID = Guid.NewGuid().ToString("N");
|
|
string orgid = context.Request.Params["orgid"];
|
|
string patrollerid = context.Request.Params["patrollerid"];
|
|
string patroller = context.Request.Params["patroller"];
|
|
string plandate = context.Request.Params["plandate"];
|
|
string startTime = context.Request.Params["startTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
string createby = context.Request.Params["createby"];
|
|
string startTime2 = context.Request.Params["startTime2"];
|
|
string endTime2 = context.Request.Params["endTime2"];
|
|
string pid = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
|
|
FangYar.Model.OA.OA_PATROLSENTRYTASK model = new Model.OA.OA_PATROLSENTRYTASK();
|
|
model.ID = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
model.ORGID = orgid;
|
|
//model.TASKNAME = plandate + "-" + Convert.ToDateTime(plandate).AddDays(1).ToString("yyyy-MM-dd") + "查铺查哨任务";
|
|
model.TASKNAME = plandate + "查铺查哨任务";
|
|
model.PATROLLERID = patrollerid;
|
|
model.PATROLLER = patroller;
|
|
model.BEGINDATE = Convert.ToDateTime(startTime);
|
|
model.ENDDATE = Convert.ToDateTime(endTime);
|
|
model.STATE = "0";
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.CREATEBY = createby;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
model.UPDATEBY = "";
|
|
model.TASKFLAG = pid;
|
|
|
|
//查询巡查点信息
|
|
FangYar.Model.OA_PATROL_SPOT dalpatrolspot = new Model.OA_PATROL_SPOT();
|
|
string where = " 1=1 and ( extendcode1='1' or extendcode1='2') and ORG_ID='" + orgid + "'";
|
|
DataTable patrolspot = spot_bll.GetList(where).Tables[0];
|
|
|
|
if (bll.AddTran(model, patrolspot))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"添加成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
}
|
|
|
|
//添加第二次
|
|
model.ID = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
model.BEGINDATE = Convert.ToDateTime(startTime2);
|
|
model.ENDDATE = Convert.ToDateTime(endTime2);
|
|
|
|
if (bll.AddTran(model, patrolspot))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"添加成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "添加异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "查铺查哨2操作请求", "添加");
|
|
return returnstr;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 添加查铺查哨任务,前端选择巡查点
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string AddTranBySelectSpots(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
//string ID = Guid.NewGuid().ToString("N");
|
|
string orgid = context.Request.Params["orgid"];
|
|
string patrollerid = context.Request.Params["patrollerid"];
|
|
string patroller = context.Request.Params["patroller"];
|
|
string plandate = context.Request.Params["plandate"];
|
|
string startTime = context.Request.Params["startTime"];
|
|
string endTime = context.Request.Params["endTime"];
|
|
string createby = context.Request.Params["createby"];
|
|
string startTime2 = context.Request.Params["startTime2"];
|
|
string endTime2 = context.Request.Params["endTime2"];
|
|
string pid = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
string spotIds = context.Request.Params["spotIds"];
|
|
|
|
|
|
FangYar.Model.OA.OA_PATROLSENTRYTASK model = new Model.OA.OA_PATROLSENTRYTASK();
|
|
model.ID = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
model.ORGID = orgid;
|
|
//model.TASKNAME = plandate + "-" + Convert.ToDateTime(plandate).AddDays(1).ToString("yyyy-MM-dd") + "查铺查哨任务";
|
|
model.TASKNAME = plandate + "查铺查哨任务";
|
|
model.PATROLLERID = patrollerid;
|
|
model.PATROLLER = patroller;
|
|
model.BEGINDATE = Convert.ToDateTime(startTime);
|
|
model.ENDDATE = Convert.ToDateTime(endTime);
|
|
model.STATE = "0";
|
|
model.CREATEDATE = DateTime.Now;
|
|
model.CREATEBY = createby;
|
|
model.UPDATEDATE = DateTime.Now;
|
|
model.UPDATEBY = "";
|
|
model.TASKFLAG = pid;
|
|
|
|
//string[] spotArr = spotIds.Split(',');
|
|
spotIds = ("'" + spotIds + "'").Replace(",", "','");
|
|
|
|
|
|
//查询巡查点信息
|
|
FangYar.Model.OA_PATROL_SPOT dalpatrolspot = new Model.OA_PATROL_SPOT();
|
|
string where = " ID IN (" + spotIds + ")";
|
|
DataTable patrolspot = spot_bll.GetList(where).Tables[0];
|
|
|
|
if (bll.AddTran(model, patrolspot))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"添加成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
}
|
|
|
|
//添加第二次
|
|
model.ID = BitConverter.ToString(Guid.NewGuid().ToByteArray()).Replace("-", "");
|
|
model.BEGINDATE = Convert.ToDateTime(startTime2);
|
|
model.ENDDATE = Convert.ToDateTime(endTime2);
|
|
|
|
if (bll.AddTran(model, patrolspot))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"添加成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"添加失败!\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "添加查铺查哨任务,前端选择巡查点异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "查铺查哨2操作请求", "添加查铺查哨任务,前端选择巡查点");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
|
|
private string DelSentryTask(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string idList = context.Request.Params["idList"];
|
|
//string[] idArray = idList.Split(',');
|
|
//string idListString = "";
|
|
//for (int i = 0; i < idArray.Length; i++)
|
|
//{
|
|
// if (i == 0)
|
|
// {
|
|
// idListString = "'" + idArray[i] + "'";
|
|
// }
|
|
// else
|
|
// {
|
|
// idListString += ",'" + idArray[i] + "'";
|
|
// }
|
|
//}
|
|
|
|
if (bll.DeleteList(idList))
|
|
{
|
|
returnstr = "{\"code\":1,\"msg\":\"删除成功!\",\"data\":[]}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"删除失败!\",\"data\":[]}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"删除失败!\",\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "删除异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "查铺查哨2操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 查铺查哨数据统计——一体化首页
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetCPCSStaDataHome(HttpContext context)
|
|
{
|
|
string returnstr = "{\"code\":1,\"msg\":\"成功!\",\"dataOrg\":[],\"dataNum\":[]}";
|
|
|
|
try
|
|
{
|
|
//机构信息ID
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
//查询日期
|
|
string dayStr = context.Request.Params["day"];
|
|
|
|
string is_content = context.Request.Params["is_content"];
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(dayStr))
|
|
{
|
|
dayStr = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
|
|
}
|
|
|
|
//开始时间、结束时间
|
|
string startDayStr = dayStr + " 00:00:00", endDayStr = dayStr + " 23:59:59";
|
|
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return returnstr = "{\"code\":0,\"msg\":\"机构ID不能为空!\",\"dataOrg\":[],\"dataNum\":[]}";
|
|
}
|
|
|
|
//所有巡查点详情缓存集合
|
|
List<OA_PATROL_SpotDetailsMO> SpotDetails = new List<OA_PATROL_SpotDetailsMO>();
|
|
|
|
//查铺查哨任务获取,包含所有下级数据
|
|
string sqlTaskCS = @"select ID TASK_ID,ORGID ORG_ID,'' SPOT_IDS,TASKNAME TASK_NAME from OA_PATROLSENTRYTASK,(select get_Org_child_list('" + OrgId + @"') cids ) s where find_in_set(ORGID, cids) and REPLACE(TASKNAME,'查铺查哨任务','')= '" + dayStr + "'";
|
|
//and date_format(BEGINDATE,'%Y-%m-%d %H:%i:%s') >= date_format('" + startDayStr + @"','%Y-%m-%d %H:%i:%s')
|
|
//and date_format(ENDDATE,'%Y-%m-%d %H:%i:%s') <= date_format('" + endDayStr + @"','%Y-%m-%d %H:%i:%s')";
|
|
|
|
DataTable dtTaskCS = FangYar.Common.MySqlHelper.QueryTable(sqlTaskCS);
|
|
List<OA_PATROL_TaskMO> listTaskCS = new List<OA_PATROL_TaskMO>();
|
|
//任务ID集合
|
|
string taskCSSpots = "";
|
|
for (int i = 0; i < dtTaskCS.Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
taskCSSpots += "'" + dtTaskCS.Rows[i]["TASK_ID"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
taskCSSpots += ",'" + dtTaskCS.Rows[i]["TASK_ID"].ToString() + "'";
|
|
}
|
|
listTaskCS.Add(new OA_PATROL_TaskMO()
|
|
{
|
|
ORG_ID = dtTaskCS.Rows[i]["ORG_ID"] + "",
|
|
SPOT_IDS = dtTaskCS.Rows[i]["SPOT_IDS"] + "",
|
|
TASK_ID = dtTaskCS.Rows[i]["TASK_ID"] + "",
|
|
TASK_NAME = dtTaskCS.Rows[i]["TASK_NAME"] + "",
|
|
});
|
|
}
|
|
if (string.IsNullOrEmpty(taskCSSpots))
|
|
{
|
|
taskCSSpots = "''";
|
|
}
|
|
|
|
//根据任务ID来查询所有查铺查哨详情
|
|
string sqlSpotDetailsCPCS = @"SELECT ORG_ID,(SELECT ID from OA_PATROL_SPOT o WHERE SPOT_NO=FID LIMIT 1 ) SPOT_ID ,SN_ID EXTENDCODE1 ,SENTRYTASKID TASK_ID, ADDR NAME ,L_TIME from fire_inspect
|
|
WHERE SENTRYTASKID in (" + taskCSSpots + ")";
|
|
|
|
//查询所有巡查点详情结果集
|
|
DataTable dtSpotDetailsCPCS = FangYar.Common.MySqlHelper.QueryTable(sqlSpotDetailsCPCS);
|
|
//遍历添加所有巡查点详情信息
|
|
for (int i = 0; i < dtSpotDetailsCPCS.Rows.Count; i++)
|
|
{
|
|
SpotDetails.Add(new OA_PATROL_SpotDetailsMO()
|
|
{
|
|
PATROL_TIME = dtSpotDetailsCPCS.Rows[i]["L_TIME"] + "",
|
|
EXTENDCODE1 = dtSpotDetailsCPCS.Rows[i]["EXTENDCODE1"] + "",
|
|
ORG_ID = dtSpotDetailsCPCS.Rows[i]["ORG_ID"] + "",
|
|
SPOT_ID = dtSpotDetailsCPCS.Rows[i]["SPOT_ID"] + "",
|
|
TASK_ID = dtSpotDetailsCPCS.Rows[i]["TASK_ID"] + "",
|
|
}); ;
|
|
}
|
|
|
|
//返回echar结果集模型
|
|
OA_PATROL_Statistics_EcharMO echarMo = new OA_PATROL_Statistics_EcharMO()
|
|
{
|
|
listCPData = new List<int>(),
|
|
listCSData = new List<int>(),
|
|
listOrgName = new List<string>(),
|
|
listXCData = new List<int>(),
|
|
};
|
|
|
|
//获取传参的机构ID的Model
|
|
FangYar.BLL.FIRE.FIRE_ORG bllOrg = new BLL.FIRE.FIRE_ORG();
|
|
FangYar.Model.FIRE.FIRE_ORG modelOrg = bllOrg.GetModel(OrgId);
|
|
|
|
string sqlOrg = "";
|
|
|
|
//大队、消防站、机关、训保支队,展示本级和下级数据
|
|
if (modelOrg.EXTENDCODE1 == "1" || modelOrg.EXTENDCODE1 == "2" || modelOrg.ISORG == "1" || OrgId == "36e8032be5f54a3cb994c4ac74ac3f77")
|
|
{
|
|
sqlOrg = " SELECT *,( SELECT get_Org_child_list(ORG_ID) ) as cids FROM FIRE_ORG WHERE type = '0' AND ( org_id = '" + OrgId + "' or PID = '" + OrgId + "') ORDER BY field(EXTENDCODE1, '3', '0', '2', '1'),field(ISORG, '0', '1')";
|
|
|
|
}
|
|
else
|
|
{ // 总队、支队展示子级数据
|
|
sqlOrg = " SELECT *,( SELECT get_Org_child_list(ORG_ID) ) as cids FROM FIRE_ORG WHERE type = '0' AND PID = '" + OrgId + "' ORDER BY field(EXTENDCODE1, '3', '0', '2', '1'),field(ISORG, '0', '1')";
|
|
|
|
}
|
|
DataTable dtOrg = FangYar.Common.MySqlHelper.QueryTable(sqlOrg);
|
|
|
|
List<string> listOrg = new List<string>();
|
|
List<string> listNum = new List<string>();
|
|
for (int i = 0; i < dtOrg.Rows.Count; i++)
|
|
{
|
|
try
|
|
{
|
|
string ORG_ID = dtOrg.Rows[i]["ORG_ID"] + "";
|
|
string CIDS = dtOrg.Rows[i]["CIDS"] + "";
|
|
string ORG_NAME = dtOrg.Rows[i]["EXTENDCODE3"] + "";
|
|
int SpotCount = 0;
|
|
//总点数
|
|
int SpotCPCount = 0;
|
|
//完成数
|
|
int SpotCPCK = 0;
|
|
//所有查铺查哨点总数 //大队、消防站、机关、训保支队,展示本级和下级数据
|
|
if (modelOrg.EXTENDCODE1 == "1" || modelOrg.EXTENDCODE1 == "2" || modelOrg.ISORG == "1" || OrgId == "36e8032be5f54a3cb994c4ac74ac3f77")
|
|
{
|
|
SpotCount = SpotDetails.Where(p => p.ORG_ID == ORG_ID).Count();
|
|
//总点数
|
|
SpotCPCount = SpotDetails.Where(p => p.ORG_ID == ORG_ID).Count();
|
|
//完成数
|
|
SpotCPCK = SpotDetails.Where(p => p.ORG_ID == ORG_ID && !string.IsNullOrEmpty(p.PATROL_TIME)).Count();
|
|
}
|
|
else
|
|
{
|
|
SpotCount = SpotDetails.Where(p => CIDS.Contains(p.ORG_ID)).Count();
|
|
//总点数
|
|
SpotCPCount = SpotDetails.Where(p => CIDS.Contains(p.ORG_ID)).Count();
|
|
//完成数
|
|
SpotCPCK = SpotDetails.Where(p => CIDS.Contains(p.ORG_ID) && !string.IsNullOrEmpty(p.PATROL_TIME)).Count();
|
|
}
|
|
|
|
listOrg.Add(ORG_NAME);
|
|
listNum.Add(((double)SpotCPCK / (SpotCPCount == 0 ? 1 : SpotCPCount) * 100).ToString("0.##"));
|
|
|
|
}
|
|
catch (Exception e) { }
|
|
}
|
|
|
|
//此处返回值有问题
|
|
returnstr = "{\"code\":1,\"msg\":\"获取数据成功!\",\"dataOrg\":\"" + string.Join(",", listOrg.ToArray()) + "\",\"dataNum\":[" + string.Join(",", listNum.ToArray()) + "]}";
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"操作异常!\",\"dataOrg\":[],\"dataNum\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨完成率统计桌面操作请求", "查询巡查数据统计异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨完成率统计桌面操作请求", "查询巡查数据统计");
|
|
return returnstr;
|
|
|
|
}
|
|
|
|
#region 询巡查数据统计 wr
|
|
/// <summary>
|
|
/// 查询巡查数据统计
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string GetInspectEcharsData(HttpContext context)
|
|
{
|
|
|
|
JsonRetMo<OA_PATROL_StatisticsMO> retMo = new JsonRetMo<OA_PATROL_StatisticsMO>() { code = "1", data = new OA_PATROL_StatisticsMO(), msg = "" };
|
|
|
|
try
|
|
{
|
|
//机构信息ID
|
|
string OrgId = context.Request.Params["OrgId"];
|
|
//查询日期
|
|
string dayStr = context.Request.Params["day"];
|
|
|
|
string is_content = context.Request.Params["is_content"];
|
|
|
|
//开始时间、结束时间
|
|
string startDayStr = dayStr + " 00:00:00", endDayStr = dayStr + " 23:59:59";
|
|
|
|
if (string.IsNullOrEmpty(OrgId))
|
|
{
|
|
return FangYar.Common.JsonHelper.ToJSON1(new JsonRetMo<OA_PATROL_StatisticsMO>() { code = "0", data = new OA_PATROL_StatisticsMO(), msg = "所属机构不能为空" });
|
|
}
|
|
|
|
//所有巡查点详情缓存集合
|
|
List<OA_PATROL_SpotDetailsMO> SpotDetails = new List<OA_PATROL_SpotDetailsMO>();
|
|
string whereStr = "";
|
|
if (is_content == "1")
|
|
{
|
|
whereStr = " find_in_set(ORGID, cids) ";
|
|
}
|
|
else
|
|
{
|
|
whereStr = " ORGID ='" + OrgId + "' ";
|
|
}
|
|
//查铺查哨任务获取
|
|
string sqlTaskCS = @"select ID TASK_ID,ORGID ORG_ID,'' SPOT_IDS,TASKNAME TASK_NAME from OA_PATROLSENTRYTASK,(select get_Org_child_list('" + OrgId + @"') cids ) s where " + whereStr + " and REPLACE(TASKNAME,'查铺查哨任务','')= '" + dayStr + "'";
|
|
//and date_format(BEGINDATE,'%Y-%m-%d %H:%i:%s') >= date_format('" + startDayStr + @"','%Y-%m-%d %H:%i:%s')
|
|
//and date_format(ENDDATE,'%Y-%m-%d %H:%i:%s') <= date_format('" + endDayStr + @"','%Y-%m-%d %H:%i:%s')";
|
|
|
|
DataTable dtTaskCS = FangYar.Common.MySqlHelper.QueryTable(sqlTaskCS);
|
|
List<OA_PATROL_TaskMO> listTaskCS = new List<OA_PATROL_TaskMO>();
|
|
//任务ID集合
|
|
string taskCSSpots = "";
|
|
for (int i = 0; i < dtTaskCS.Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
taskCSSpots += "'" + dtTaskCS.Rows[i]["TASK_ID"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
taskCSSpots += ",'" + dtTaskCS.Rows[i]["TASK_ID"].ToString() + "'";
|
|
}
|
|
listTaskCS.Add(new OA_PATROL_TaskMO()
|
|
{
|
|
ORG_ID = dtTaskCS.Rows[i]["ORG_ID"] + "",
|
|
SPOT_IDS = dtTaskCS.Rows[i]["SPOT_IDS"] + "",
|
|
TASK_ID = dtTaskCS.Rows[i]["TASK_ID"] + "",
|
|
TASK_NAME = dtTaskCS.Rows[i]["TASK_NAME"] + "",
|
|
});
|
|
}
|
|
if (string.IsNullOrEmpty(taskCSSpots))
|
|
{
|
|
taskCSSpots = "''";
|
|
}
|
|
|
|
//根据任务ID来查询所有查铺查哨详情
|
|
string sqlSpotDetailsCPCS = @"SELECT ORG_ID,(SELECT ID from OA_PATROL_SPOT o WHERE SPOT_NO=FID LIMIT 1 ) SPOT_ID ,SN_ID EXTENDCODE1 ,SENTRYTASKID TASK_ID, ADDR NAME ,L_TIME from fire_inspect
|
|
WHERE SENTRYTASKID in (" + taskCSSpots + ")";
|
|
|
|
//查询所有巡查点详情结果集
|
|
DataTable dtSpotDetailsCPCS = FangYar.Common.MySqlHelper.QueryTable(sqlSpotDetailsCPCS);
|
|
//遍历添加所有巡查点详情信息
|
|
for (int i = 0; i < dtSpotDetailsCPCS.Rows.Count; i++)
|
|
{
|
|
SpotDetails.Add(new OA_PATROL_SpotDetailsMO()
|
|
{
|
|
PATROL_TIME = dtSpotDetailsCPCS.Rows[i]["L_TIME"] + "",
|
|
EXTENDCODE1 = dtSpotDetailsCPCS.Rows[i]["EXTENDCODE1"] + "",
|
|
ORG_ID = dtSpotDetailsCPCS.Rows[i]["ORG_ID"] + "",
|
|
SPOT_ID = dtSpotDetailsCPCS.Rows[i]["SPOT_ID"] + "",
|
|
TASK_ID = dtSpotDetailsCPCS.Rows[i]["TASK_ID"] + "",
|
|
}); ;
|
|
}
|
|
if (is_content == "1")
|
|
{
|
|
whereStr = " find_in_set(opt.ORG_ID, cids) ";
|
|
}
|
|
else
|
|
{
|
|
whereStr = " opt.ORG_ID ='" + OrgId + "' ";
|
|
}
|
|
|
|
////获取巡查巡检任务 天任务获取当天的,周任务获取当周的
|
|
//string sqlXCTaskList = @"SELECT DISTINCT opt.*,opp.CYCLE FROM oa_patrol_task opt left join oa_patrol_plan opp on opt.PLAN_ID = opp.ID ,(select get_Org_child_list('" + OrgId + @"') cids ) s where " + whereStr + ""
|
|
// + "and CYCLE = '1' and date_format(opt.S_TIME, '%Y-%m-%d' ) <= date_format('" + dayStr + @"', '%Y-%m-%d')
|
|
// AND date_format(opt.E_TIME, '%Y-%m-%d' ) >= date_format('" + dayStr + @"', '%Y-%m-%d')
|
|
// union all
|
|
// SELECT DISTINCT opt.*,opp.CYCLE FROM oa_patrol_task opt left join oa_patrol_plan opp on opt.PLAN_ID = opp.ID ,(select get_Org_child_list('" + OrgId + @"') cids ) s where " + whereStr + ""
|
|
// + "and(CYCLE = '0' OR CYCLE is null or CYCLE = '') and date_format(opt.S_TIME, '%Y-%m-%d' ) = date_format('" + dayStr + @"', '%Y-%m-%d')";
|
|
|
|
//获取巡查巡检任务 天任务获取当天的,周任务获取当周的
|
|
string sqlXCTaskList = @"SELECT DISTINCT opt.* FROM oa_patrol_task opt left join oa_patrol_plan opp on opt.PLAN_ID = opp.ID ,(select get_Org_child_list('" + OrgId + @"') cids ) s where " + whereStr + ""
|
|
+ " and date_format(opt.S_TIME, '%Y-%m-%d' ) <= date_format('" + dayStr + @"', '%Y-%m-%d')
|
|
AND date_format(opt.E_TIME, '%Y-%m-%d' ) >= date_format('" + dayStr + @"', '%Y-%m-%d')";
|
|
|
|
|
|
DataTable dtTaskXC = FangYar.Common.MySqlHelper.QueryTable(sqlXCTaskList);
|
|
//巡查任务ID集合
|
|
string taskXCSpots = "";
|
|
List<OA_PATROL_TaskMO> listTaskXC = new List<OA_PATROL_TaskMO>();
|
|
for (int i = 0; i < dtTaskXC.Rows.Count; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
taskXCSpots += "'" + dtTaskXC.Rows[i]["ID"].ToString() + "'";
|
|
}
|
|
else
|
|
{
|
|
taskXCSpots += ",'" + dtTaskXC.Rows[i]["ID"].ToString() + "'";
|
|
}
|
|
|
|
listTaskXC.Add(new OA_PATROL_TaskMO()
|
|
{
|
|
ORG_ID = dtTaskXC.Rows[i]["ORG_ID"] + "",
|
|
SPOT_IDS = dtTaskXC.Rows[i]["SPOT_IDS"] + "",
|
|
TASK_ID = dtTaskXC.Rows[i]["ID"] + "",
|
|
TASK_NAME = dtTaskXC.Rows[i]["NAME"] + "",
|
|
});
|
|
}
|
|
if (string.IsNullOrEmpty(taskXCSpots))
|
|
{
|
|
taskXCSpots = "''";
|
|
}
|
|
|
|
//查询巡检巡查详情
|
|
string sqlSpotDetails = @"SELECT distinct ORG_ID,SPOT_ID,TASK_ID ,STATE ,TIME from OA_PATROL_TRAJECTORY
|
|
WHERE TASK_ID in (" + taskXCSpots + ")";
|
|
//查询所有巡查点详情结果集
|
|
DataTable dtSpotDetails = FangYar.Common.MySqlHelper.QueryTable(sqlSpotDetails);
|
|
|
|
//遍历添加所有巡查点详情信息
|
|
for (int i = 0; i < dtSpotDetails.Rows.Count; i++)
|
|
{
|
|
SpotDetails.Add(new OA_PATROL_SpotDetailsMO()
|
|
{
|
|
ORG_ID = dtSpotDetails.Rows[i]["ORG_ID"] + "",
|
|
SPOT_ID = dtSpotDetails.Rows[i]["SPOT_ID"] + "",
|
|
TASK_ID = dtSpotDetails.Rows[i]["TASK_ID"] + "",
|
|
PATROL_TIME = dtSpotDetails.Rows[i]["TIME"] + "",
|
|
EXTENDCODE1 = "3",
|
|
});
|
|
}
|
|
|
|
//返回echar结果集模型
|
|
OA_PATROL_Statistics_EcharMO echarMo = new OA_PATROL_Statistics_EcharMO()
|
|
{
|
|
listCPData = new List<int>(),
|
|
listCSData = new List<int>(),
|
|
listOrgName = new List<string>(),
|
|
listXCData = new List<int>(),
|
|
};
|
|
|
|
if (is_content == "1")
|
|
{
|
|
whereStr = " find_in_set(ORG_ID, cids) ";
|
|
}
|
|
else
|
|
{
|
|
whereStr = " ORG_ID ='" + OrgId + "' ";
|
|
}
|
|
//查询所有机构
|
|
string sqlOrg = "select * from FIRE_ORG,(select get_Org_child_list('" + OrgId + @"') cids ) s where type='0' and " + whereStr + "";
|
|
DataTable dtOrg = FangYar.Common.MySqlHelper.QueryTable(sqlOrg);
|
|
List<OA_PATROL_Statistics_TableMO> listOrg = new List<OA_PATROL_Statistics_TableMO>();
|
|
for (int i = 0; i < dtOrg.Rows.Count; i++)
|
|
{
|
|
try
|
|
{
|
|
string ORG_ID = dtOrg.Rows[i]["ORG_ID"] + "";
|
|
string ORG_NAME = dtOrg.Rows[i]["ORG_NAME"] + "";
|
|
|
|
//{EXTENDCODE1 1 查铺 2 查哨 3 巡检巡查 }
|
|
//所有类型巡查点总数
|
|
int SpotCount = SpotDetails.Where(p => p.ORG_ID == ORG_ID).Count();
|
|
//查铺总点数
|
|
int SpotCPCount = SpotDetails.Where(p => p.EXTENDCODE1 == "1" && p.ORG_ID == ORG_ID).Count();
|
|
//查铺完成数
|
|
int SpotCPCK = SpotDetails.Where(p => p.EXTENDCODE1 == "1" && p.ORG_ID == ORG_ID && !string.IsNullOrEmpty(p.PATROL_TIME)).Count();
|
|
//查哨总点数
|
|
int SpotCSCount = SpotDetails.Where(p => p.EXTENDCODE1 == "2" && p.ORG_ID == ORG_ID).Count();
|
|
//查哨完成数
|
|
int SpotCSCK = SpotDetails.Where(p => p.EXTENDCODE1 == "2" && p.ORG_ID == ORG_ID && !string.IsNullOrEmpty(p.PATROL_TIME)).Count();
|
|
|
|
//巡检巡查总数
|
|
int SpotXCCount = SpotDetails.Where(p => p.EXTENDCODE1 == "3" && p.ORG_ID == ORG_ID).Count();
|
|
|
|
//巡检巡查总数
|
|
int SpotXCCK = SpotDetails.Where(p => p.EXTENDCODE1 == "3" && p.ORG_ID == ORG_ID && !string.IsNullOrEmpty(p.PATROL_TIME)).Count();
|
|
|
|
|
|
listOrg.Add(new OA_PATROL_Statistics_TableMO()
|
|
{
|
|
ORG_ID = ORG_ID,
|
|
PID = dtOrg.Rows[i]["PID"] + "",
|
|
TYPE = dtOrg.Rows[i]["TYPE"] + "",
|
|
ADDR = dtOrg.Rows[i]["ADDR"] + "",
|
|
CONT = dtOrg.Rows[i]["CONT"] + "",
|
|
PHONE = dtOrg.Rows[i]["PHONE"] + "",
|
|
ORG_NAME = ORG_NAME,
|
|
SpotCount = SpotCount,
|
|
SpotCPCount = SpotCPCount,
|
|
SpotCSCount = SpotCSCount,
|
|
SpotXCCount = SpotXCCount,
|
|
SpotCPCK = SpotCPCK,
|
|
SpotCSCK = SpotCSCK,
|
|
SpotXCCK = SpotXCCK,
|
|
//spotCPInfo = new OA_PATROL_SpotNotCKDataMO() { listAllSpot = listAllSpotCP, listISCKSpot = listISCKSpotCP, listNotCKSpot = listNotCKSpotCP },
|
|
//spotCSInfo = new OA_PATROL_SpotNotCKDataMO() { listAllSpot = listAllSpotCS, listISCKSpot = listISCKSpotCS, listNotCKSpot = listNotCKSpotCS },
|
|
//spotXCInfo = new OA_PATROL_SpotNotCKDataMO() { listAllSpot = listAllSpotXC, listISCKSpot = listISCKSpotXC, listNotCKSpot = listNotCKSpotXC },
|
|
});
|
|
|
|
//添加Echar数据
|
|
echarMo.listXCData.Add(SpotXCCK);
|
|
echarMo.listOrgName.Add(ORG_NAME);
|
|
echarMo.listCSData.Add(SpotCSCK);
|
|
echarMo.listCPData.Add(SpotCPCK);
|
|
|
|
}
|
|
catch (Exception e) { }
|
|
}
|
|
|
|
retMo.data.treeSpid = listOrg.Where(p => p.ORG_ID == OrgId).First().PID;
|
|
retMo.data.tbData = listOrg;
|
|
retMo.data.echarData = echarMo;
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
retMo.code = "0";
|
|
retMo.msg = "异常:" + e;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "查铺查哨2操作请求", "查询巡查数据统计异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "查询巡查数据统计");
|
|
return FangYar.Common.JsonHelper.ToJSON1(retMo);
|
|
|
|
}
|
|
|
|
|
|
//APP接口 待办列表
|
|
private string appList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string PATROLLERID = context.Request.Params["PATROLLERID"];
|
|
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); }
|
|
int endIndex = pageSize;
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
|
|
//string where = " PATROLLERID = '" + PATROLLERID + "' ";
|
|
string where = " INSTR(concat(',',PATROLLERID,','),concat(',','" + PATROLLERID + "',',')) >0";
|
|
where += " and date_format(ENDDATE, '%Y-%m-%d %H:%i:%s') >= date_format(now(), '%Y-%m-%d %H:%i:%s')";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, " BEGINDATE ", startIndex, endIndex).Tables[0];
|
|
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, "查铺查哨2操作请求", "APP接口 待办列表异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "APP接口 待办列表");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//APP接口 历史列表
|
|
private string appListHistory(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string PATROLLERID = context.Request.Params["PATROLLERID"];
|
|
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); }
|
|
int endIndex = pageSize;
|
|
int startIndex = (pageIndex - 1) * pageSize;
|
|
|
|
string where = null;
|
|
//where = " PATROLLERID = '" + PATROLLERID + "' ";
|
|
where = " INSTR(concat(',',PATROLLERID,','),concat(',','" + PATROLLERID + "',',')) >0";
|
|
|
|
where += " and date_format(ENDDATE, '%Y-%m-%d %H:%i:%s') < date_format(now(), '%Y-%m-%d %H:%i:%s')";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, " BEGINDATE desc", startIndex, endIndex).Tables[0];
|
|
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, "查铺查哨2操作请求", "APP接口 历史列表异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "查铺查哨2操作请求", "APP接口 历史列表");
|
|
return returnstr;
|
|
}
|
|
|
|
#endregion
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|