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.
401 lines
16 KiB
401 lines
16 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// FirePatrolTaskHandler 的摘要说明
|
|
/// </summary>
|
|
public class FirePatrolTaskHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.FIRE_PATROL_TASK bll = new FangYar.BLL.FIRE_PATROL_TASK();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "水资源巡查任务操作请求", "");
|
|
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = getTasklist(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddTask(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditTask(context);
|
|
break;
|
|
case "UserIdList":
|
|
returnstr = getUserIdTasklist(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelTask(context);
|
|
break;
|
|
case "upPatrolTaskPer":
|
|
returnstr = upPatrolTaskPer(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string getTasklist(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
int pageIndex = 1;
|
|
int pageSize = 10;//
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
string where = null;
|
|
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))";
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and NAME like '%" + keyword + "%' or USERS_NAME like '%" + keyword + "%' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE_PATROL_TASK> list = bll.QueryList(pageIndex, pageSize, where, "S_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;
|
|
}
|
|
|
|
//根据User_ID查询
|
|
private string getUserIdTasklist(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string userid = context.Request.Params["userId"];
|
|
string state = context.Request.Params["state"];
|
|
|
|
//FangYar.BLL.TBL.SysEmpBLL ebll = new FangYar.BLL.TBL.SysEmpBLL();
|
|
//FangYar.Model.TBL.TBL_SYS_EMP_Model empModel = ebll.GetModelByUserID(orgId, userid);
|
|
|
|
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;
|
|
where = "ORG_ID = '" + orgId + "' ";
|
|
//if (!string.IsNullOrEmpty(empModel.ID))
|
|
//{
|
|
// where += " and USERS_UID = '"+ empModel.ID + "' ";
|
|
//}else
|
|
//{
|
|
// return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
|
//}
|
|
if (!string.IsNullOrEmpty(userid))
|
|
{
|
|
where += " and instr(','||USERS_UID||',',','||'" + userid + "'||',')<>0";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
}
|
|
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 state in " + states + " ";
|
|
}
|
|
else
|
|
{
|
|
where += " and state = '" + state + "' ";
|
|
}
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.FIRE_PATROL_TASK> list = bll.QueryList(pageIndex, pageSize, where, " S_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, "水资源巡查任务操作请求", "根据User_ID查询异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "水资源巡查任务操作请求", "根据User_ID查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加巡查任务
|
|
private string AddTask(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string taskId = Guid.NewGuid().ToString("N");
|
|
string USER_ID = context.Request.Params["UserId"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string PLAN_ID = context.Request.Params["PLAN_ID"];
|
|
string NAME = context.Request.Params["NAME"];
|
|
string S_TIME = context.Request.Params["S_TIME"];
|
|
string E_TIME = context.Request.Params["E_TIME"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string USERS_NAME = context.Request.Params["USERS_NAME"];
|
|
string SPOTS = context.Request.Params["SPOTS"];
|
|
string SPOT_IDS = context.Request.Params["SPOT_IDS"];
|
|
string SPOT_NAMES = context.Request.Params["SPOT_NAMES"];
|
|
string CITY = context.Request.Params["CITY"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
|
|
//巡查任务表
|
|
FangYar.Model.FIRE_PATROL_TASK model = new Model.FIRE_PATROL_TASK();
|
|
model.ID = taskId;
|
|
model.PLAN_ID = PLAN_ID;
|
|
model.NAME = NAME;
|
|
model.S_TIME = S_TIME;
|
|
model.E_TIME = E_TIME;
|
|
model.USERS_UID = USERS_UID;
|
|
model.USERS_NAME = USERS_NAME;
|
|
model.SPOTS = SPOTS;
|
|
model.SPOT_IDS = SPOT_IDS;
|
|
model.SPOT_NAMES = SPOT_NAMES;
|
|
model.A_PER = USER_ID;
|
|
model.CITY = CITY;
|
|
model.ORG_ID = orgId;
|
|
model.STATE = STATE;
|
|
|
|
if (bll.Add(model))
|
|
{
|
|
msg = "添加成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "添加失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "添加失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查任务操作请求", "添加巡查任务异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "水资源巡查任务操作请求", "添加巡查任务");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//修改巡查任务
|
|
private string EditTask(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string USER_ID = context.Request.Params["UserId"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string PLAN_ID = context.Request.Params["PLAN_ID"];
|
|
string NAME = context.Request.Params["NAME"];
|
|
string S_TIME = context.Request.Params["S_TIME"];
|
|
string E_TIME = context.Request.Params["E_TIME"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string USERS_NAME = context.Request.Params["USERS_NAME"];
|
|
string SPOT_IDS = context.Request.Params["SPOT_IDS"];
|
|
string SPOT_NAMES = context.Request.Params["SPOT_NAMES"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
|
|
//巡查任务表
|
|
FangYar.Model.FIRE_PATROL_TASK model = new Model.FIRE_PATROL_TASK();
|
|
model.ID = ID;
|
|
model.NAME = NAME;
|
|
model.PLAN_ID = PLAN_ID;
|
|
model.S_TIME = S_TIME;
|
|
model.E_TIME = E_TIME;
|
|
model.USERS_UID = USERS_UID;
|
|
model.USERS_NAME = USERS_NAME;
|
|
model.SPOT_IDS = SPOT_IDS;
|
|
model.SPOT_NAMES = SPOT_NAMES;
|
|
model.ORG_ID = orgId;
|
|
model.STATE = STATE;
|
|
model.U_PER = USER_ID;
|
|
|
|
if (bll.Update(model))
|
|
{
|
|
msg = "修改成功!";
|
|
code = 1;
|
|
}
|
|
else { msg = "修改失败!"; }
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "修改失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查任务操作请求", "修改巡查任务异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "水资源巡查任务操作请求", "修改巡查任务");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//删除巡查任务
|
|
private string DelTask(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string TaskList = context.Request.Params["TaskList"];
|
|
string[] TaskArray = TaskList.Split(',');
|
|
string TaskListString = "";
|
|
for (int i = 0; i < TaskArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
TaskListString = "'" + TaskArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
TaskListString += ",'" + TaskArray[i] + "'";
|
|
}
|
|
}
|
|
if (bll.DeleteList(TaskListString))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "水资源巡查任务操作请求", "删除巡查任务异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "水资源巡查任务操作请求", "删除巡查任务");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改 此次巡查任务是由谁巡查的
|
|
private string upPatrolTaskPer(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string taskId = context.Request.Params["taskId"]; //巡查任务ID
|
|
string personName = context.Request.Params["EXTENDCODE2"]; //巡查员姓名
|
|
|
|
//巡查任务表
|
|
FangYar.Model.FIRE_PATROL_TASK model = bll.GetModel(taskId);
|
|
model.EXTENDCODE2 = personName;
|
|
DateTime t1 = Convert.ToDateTime(model.E_TIME);
|
|
DateTime t2 = DateTime.Now;
|
|
if (t1 < t2)
|
|
{
|
|
msg = "任务已超时无法在巡查!";
|
|
}
|
|
else
|
|
{
|
|
if (personName != "" && personName != null)
|
|
{
|
|
if (bll.Update(model))
|
|
{
|
|
FangYar.BLL.FIRE_PATROL_TRAJECTORY ptbll = new FangYar.BLL.FIRE_PATROL_TRAJECTORY();
|
|
DataTable data = ptbll.GetTraList(taskId);
|
|
foreach (DataRow dr in data.Rows)
|
|
{
|
|
string state = dr["STATE"].ToString();
|
|
if (state == "0")
|
|
{
|
|
string id = dr["ID"].ToString();
|
|
ptbll.UpdateByIdYToState(id, personName);
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|