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.
288 lines
12 KiB
288 lines
12 KiB
using MySql.Data.MySqlClient;
|
|
using NPOI.SS.Formula.Functions;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class ZYTFirePlanHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.FIRE.FIRE_ORG org_bll = new FangYar.BLL.FIRE.FIRE_ORG();
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "战训预案请求", "", "1");
|
|
context.Response.ContentType = "text/plain";
|
|
string action = context.Request.Params["Action"];
|
|
string returnstr = "";
|
|
|
|
switch (action)
|
|
{
|
|
case "List":
|
|
returnstr = List(context);
|
|
break;
|
|
case "Save":
|
|
returnstr = SavePlan(context);
|
|
break;
|
|
case "Delete":
|
|
returnstr = DeletePlan(context);
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string List(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;
|
|
int startIndex = 0;
|
|
int endIndex = 10;
|
|
if (!string.IsNullOrEmpty(page)) { pageIndex = int.Parse(page); }
|
|
if (!string.IsNullOrEmpty(limit)) { pageSize = int.Parse(limit); }
|
|
startIndex = (pageIndex - 1) * pageSize ;
|
|
endIndex = pageSize;
|
|
|
|
string where = " AUTHORITY_ORGID like '%" + OrgId + "%'";
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and PLAN_TITLE like '%" + keyword + "%'";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
|
|
int count = FangYar.Common.MySqlHelper.GetCount("select count(*) from t_fireplan where " + where);
|
|
|
|
where += " ORDER BY LAST_MODIFICATION_TIME limit " + startIndex + "," + endIndex ;
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = FangYar.Common.MySqlHelper.Query("select * from t_fireplan where "+where).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"" + e.Message + "\":\"error\",\"count\":0,\"data\":[]}";
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "战训预案请求", "查询异常:" + e.Message, "1");
|
|
}
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "战训预案请求", "查询", "1");
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
/// 保存预案
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string SavePlan(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "保存失败!";
|
|
string operate = "EDIT";
|
|
int rows = 0;
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
if (string.IsNullOrEmpty(ID))
|
|
{
|
|
ID = Guid.NewGuid().ToString("N");
|
|
operate = "ADD";
|
|
}
|
|
string PLAN_TITLE = context.Request.Params["PLAN_TITLE"];
|
|
string PLAN_URL = context.Request.Params["PLAN_URL"];
|
|
string AUTHORITY_TYPE = context.Request.Params["AUTHORITY_TYPE"];
|
|
string AUTHORITY_ORGID = context.Request.Params["AUTHORITY_ORGID"];
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string ORG_NAME = context.Request.Params["ORG_NAME"];
|
|
string CREATE_USERSUID = context.Request.Params["CREATE_USERSUID"];
|
|
string LAST_MODIFICATION_USERSUID = context.Request.Params["LAST_MODIFICATION_USERSUID"];
|
|
|
|
string temp_orgid = ORG_ID;//默认本单位
|
|
if (AUTHORITY_TYPE == "0")//全区
|
|
{
|
|
temp_orgid = "D8DC637B8B984848A63F82A018AFAEB0";
|
|
}
|
|
else if (AUTHORITY_TYPE == "1")//全支队
|
|
{
|
|
FangYar.Model.FIRE.FIRE_ORG data = org_bll.GetModel(ORG_ID);
|
|
if (data != null && (data.EXTENDCODE1 == "1" || data.EXTENDCODE1 == "2"))
|
|
{
|
|
temp_orgid = getZDOrg(data.PID).ORG_ID;
|
|
}
|
|
else if (data.EXTENDCODE1 == "0" && data.ISORG=="1") //支队机关
|
|
{
|
|
temp_orgid = getZDOrg(data.PID).ORG_ID;
|
|
}
|
|
else if (data.EXTENDCODE1 == "3")
|
|
{
|
|
temp_orgid = "734389c7ae364584aea9918693bba3de";//总队机关
|
|
}
|
|
else
|
|
{
|
|
temp_orgid = data.ORG_ID;//总队
|
|
}
|
|
}
|
|
|
|
|
|
if (AUTHORITY_TYPE == "2")//本单位
|
|
{
|
|
AUTHORITY_ORGID = ORG_ID;
|
|
}
|
|
else
|
|
{
|
|
var dt = FangYar.Common.MySqlHelper.Query("select get_Org_child_list('" + temp_orgid + "') cids").Tables[0];
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
var dr = dt.Rows[0];
|
|
if (dr != null && dr["cids"] != null)
|
|
{
|
|
AUTHORITY_ORGID = dr["cids"].ToString();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (operate == "ADD")
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("INSERT INTO t_fireplan(");
|
|
strSql.Append("ID,PLAN_TITLE,PLAN_TYPE,PLAN_URL,AUTHORITY_TYPE,AUTHORITY_ORGID,ORG_ID,ORG_NAME,CREATE_USERSUID,CREATION_TIME,LAST_MODIFICATION_USERSUID,LAST_MODIFICATION_TIME)");
|
|
strSql.Append(" values (");
|
|
strSql.Append("@ID,@PLAN_TITLE,@PLAN_TYPE,@PLAN_URL,@AUTHORITY_TYPE,@AUTHORITY_ORGID,@ORG_ID,@ORG_NAME,@CREATE_USERSUID,@CREATION_TIME,@LAST_MODIFICATION_USERSUID,@LAST_MODIFICATION_TIME)");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@ID", ID),
|
|
new MySqlParameter("@PLAN_TITLE", PLAN_TITLE),
|
|
new MySqlParameter("@PLAN_TYPE", "2"),
|
|
new MySqlParameter("@PLAN_URL", PLAN_URL),
|
|
new MySqlParameter("@AUTHORITY_TYPE", AUTHORITY_TYPE),
|
|
new MySqlParameter("@AUTHORITY_ORGID", AUTHORITY_ORGID),
|
|
new MySqlParameter("@ORG_ID", ORG_ID),
|
|
new MySqlParameter("@ORG_NAME", ORG_NAME),
|
|
new MySqlParameter("@CREATE_USERSUID", CREATE_USERSUID),
|
|
new MySqlParameter("@CREATION_TIME", DateTime.Now),
|
|
new MySqlParameter("@LAST_MODIFICATION_USERSUID", LAST_MODIFICATION_USERSUID),
|
|
new MySqlParameter("@LAST_MODIFICATION_TIME", DateTime.Now)};
|
|
rows = FangYar.Common.MySqlHelper.ExecuteSql(strSql.ToString(), parameters);
|
|
}
|
|
else
|
|
{
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("update t_fireplan set ");
|
|
strSql.Append("PLAN_TITLE=@PLAN_TITLE,");
|
|
strSql.Append("PLAN_URL=@PLAN_URL,");
|
|
strSql.Append("AUTHORITY_TYPE=@AUTHORITY_TYPE,");
|
|
strSql.Append("AUTHORITY_ORGID=@AUTHORITY_ORGID,");
|
|
strSql.Append("LAST_MODIFICATION_USERSUID=@LAST_MODIFICATION_USERSUID,");
|
|
strSql.Append("LAST_MODIFICATION_TIME=@LAST_MODIFICATION_TIME"); ;
|
|
strSql.Append(" where ID=@ID ");
|
|
MySqlParameter[] parameters = {
|
|
new MySqlParameter("@PLAN_TITLE", PLAN_TITLE),
|
|
new MySqlParameter("@PLAN_URL", PLAN_URL),
|
|
new MySqlParameter("@AUTHORITY_TYPE", AUTHORITY_TYPE),
|
|
new MySqlParameter("@AUTHORITY_ORGID", AUTHORITY_ORGID),
|
|
new MySqlParameter("@LAST_MODIFICATION_USERSUID", LAST_MODIFICATION_USERSUID),
|
|
new MySqlParameter("@LAST_MODIFICATION_TIME", DateTime.Now),
|
|
new MySqlParameter("@ID",ID)};
|
|
|
|
rows = FangYar.Common.MySqlHelper.ExecuteSql(strSql.ToString(), parameters);
|
|
}
|
|
if (rows > 0)
|
|
{
|
|
msg = "保存成功!";
|
|
code = 1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "保存失败";
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "战训预案保存", "保存异常:" + e.Message, "1");
|
|
}
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "战训预案保存", "保存", "1");
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
return returnstr;
|
|
}
|
|
/// <summary>
|
|
/// 删除预案
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DeletePlan(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string PlanList = context.Request.Params["PlanList"];
|
|
string[] PlanArray = PlanList.Split(',');
|
|
string PlanListString = "";
|
|
for (int i = 0; i < PlanArray.Length; i++)
|
|
{
|
|
if (i == 0)
|
|
{
|
|
PlanListString = "'" + PlanArray[i] + "'";
|
|
}
|
|
else
|
|
{
|
|
PlanListString += ",'" + PlanArray[i] + "'";
|
|
}
|
|
}
|
|
StringBuilder strSql = new StringBuilder();
|
|
strSql.Append("delete from t_fireplan ");
|
|
strSql.Append(" where ID in (" + PlanListString + ") ");
|
|
int rows = FangYar.Common.MySqlHelper.ExecuteSql(strSql.ToString());
|
|
msg = "删除失败!";
|
|
if (rows > 0)
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "删除失败!";
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "战训预案删除", "保存异常:" + e.Message, "1");
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
return returnstr;
|
|
}
|
|
//向上获取支队
|
|
private FangYar.Model.FIRE.FIRE_ORG getZDOrg(string orgid)
|
|
{
|
|
FangYar.Model.FIRE.FIRE_ORG data = org_bll.GetModel(orgid);
|
|
if(data.EXTENDCODE1=="0")
|
|
return data;
|
|
else
|
|
return getZDOrg(data.PID);
|
|
}
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|