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.
479 lines
20 KiB
479 lines
20 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Reflection;
|
|
using System.Web.Script.Serialization;
|
|
using FangYar.Model;
|
|
using FangYar.BLL;
|
|
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class OaPatrolSpotHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA_PATROL_SPOT bll = new FangYar.BLL.OA_PATROL_SPOT();
|
|
private FangYar.BLL.TBL.SysEmpBLL ebll = new FangYar.BLL.TBL.SysEmpBLL();
|
|
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 = getSpotlist(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddSpot(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditSpot(context);
|
|
break;
|
|
case "DelSpot":
|
|
returnstr = DelSpot(context);
|
|
break;
|
|
case "getOrgTree":
|
|
returnstr = getOrgTree(context);
|
|
break;
|
|
case "getOrgTreeCPCS":
|
|
returnstr = getOrgTreeCPCS(context);
|
|
break;
|
|
case "IFIDGetModel":
|
|
returnstr = IFIDGetModel(context);
|
|
break;
|
|
case "IFIDGetModelLeave":
|
|
returnstr = IFIDGetModelLeave(context);
|
|
break;
|
|
case "getSpots":
|
|
returnstr = getSpots(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string getSpotlist(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string keyword = context.Request.Params["keywords"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string page = context.Request.Params["page"];
|
|
string limit = context.Request.Params["limit"];
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
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 (!string.IsNullOrEmpty(treeID) && treeID != orgId)
|
|
{
|
|
orgId = treeID;
|
|
}
|
|
where = "ORG_ID = '" + orgId + "' ";
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and (NAME like '%" + keyword + "%' or ADDR like '%" + keyword + "%')";
|
|
}
|
|
if (!string.IsNullOrEmpty(EXTENDCODE1))
|
|
{
|
|
where += " and EXTENDCODE1 = '" + EXTENDCODE1 + "' ";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.OA_PATROL_SPOT> list = bll.QueryList(pageIndex, pageSize, where, " SORT");
|
|
foreach (FangYar.Model.OA_PATROL_SPOT model in list)
|
|
{
|
|
JObject EXTENDCODE2_s = JsonConvert.DeserializeObject<JObject>(model.EXTENDCODE2);
|
|
string EXTENDCODE21 = "";
|
|
int EXTENDCODE21count = 0;
|
|
if (EXTENDCODE2_s != null)
|
|
{
|
|
foreach (JObject EXTENDCODE31obj in EXTENDCODE2_s.Value<JArray>("data"))
|
|
{
|
|
if (EXTENDCODE21count == 0)
|
|
{
|
|
EXTENDCODE21 = "" + EXTENDCODE31obj["ppl_Name"];
|
|
}
|
|
else
|
|
{
|
|
EXTENDCODE21 += "," + EXTENDCODE31obj["ppl_Name"];
|
|
}
|
|
EXTENDCODE21count++;
|
|
}
|
|
}
|
|
model.EXTENDCODE21 = EXTENDCODE21;
|
|
}
|
|
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 string AddSpot(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string spotId = Guid.NewGuid().ToString("N");
|
|
string orgId = context.Request.Params["orgId"];
|
|
string NAME = context.Request.Params["NAME"];
|
|
string SPOT_NO = context.Request.Params["SPOT_NO"];
|
|
string POINT = context.Request.Params["POINT"];
|
|
string DES = context.Request.Params["DES"];
|
|
string ADDR = context.Request.Params["ADDR"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string SORT = context.Request.Params["SORT"];
|
|
|
|
//巡查点表
|
|
FangYar.Model.OA_PATROL_SPOT model = new Model.OA_PATROL_SPOT();
|
|
model.ID = spotId;
|
|
model.NAME = NAME;
|
|
model.SPOT_NO = SPOT_NO;
|
|
model.POINT = POINT;
|
|
model.DES = DES;
|
|
model.ADDR = ADDR;
|
|
model.ORG_ID = orgId;
|
|
model.STATE = STATE;
|
|
model.SORT = SORT;
|
|
model.EXTENDCODE1 = EXTENDCODE1;
|
|
model.EXTENDCODE2 = EXTENDCODE2;
|
|
|
|
bool a = bll.ExistsSpotNo(SPOT_NO);
|
|
if (a == true)
|
|
{
|
|
msg = "对不起,该芯片编号已经存在";
|
|
}
|
|
else
|
|
{
|
|
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 EditSpot(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string NAME = context.Request.Params["NAME"];
|
|
string SPOT_NO = context.Request.Params["SPOT_NO"];
|
|
string POINT = context.Request.Params["POINT"];
|
|
string DES = context.Request.Params["DES"];
|
|
string ADDR = context.Request.Params["ADDR"];
|
|
string STATE = context.Request.Params["STATE"];
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string SORT = context.Request.Params["SORT"];
|
|
|
|
|
|
//巡查点表
|
|
FangYar.Model.OA_PATROL_SPOT model = new Model.OA_PATROL_SPOT();
|
|
model.ID = ID;
|
|
model.NAME = NAME;
|
|
model.SPOT_NO = SPOT_NO;
|
|
model.POINT = POINT;
|
|
model.DES = DES;
|
|
model.ADDR = ADDR;
|
|
model.ORG_ID = orgId;
|
|
model.STATE = STATE;
|
|
model.SORT = SORT;
|
|
model.EXTENDCODE1 = EXTENDCODE1;
|
|
model.EXTENDCODE2 = EXTENDCODE2;
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除巡查点
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns></returns>
|
|
private string DelSpot(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string ID = context.Request.Params["ID"];
|
|
string sqlDel = " delete from OA_PATROL_SPOT where id = '" + ID + "' ";
|
|
if (Common.MySqlHelper.Execute(sqlDel) > 0)
|
|
{
|
|
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;
|
|
}
|
|
|
|
//获取Tree 机构下的巡查点列表
|
|
private string getOrgTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string patrolSpotType = context.Request.Params["patrolSpotType"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgTree(orgId, patrolSpotType);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
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;
|
|
}
|
|
//获取Tree 机构下的查铺查哨点列表
|
|
private string getOrgTreeCPCS(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgTreeCPCS(orgId);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
|
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;
|
|
}
|
|
|
|
//根据IFID(芯片编号)得到一个对象实体
|
|
private string IFIDGetModel(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string IFID = context.Request.Params["IFID"];
|
|
FangYar.Model.OA_PATROL_SPOT model = bll.IFIDGetModel(ORG_ID, IFID);
|
|
if (model == null)
|
|
{
|
|
returnstr = "{}";
|
|
}
|
|
else
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = null;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "巡查点操作请求", "根据IFID(芯片编号)得到一个对象实体异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "巡查点操作请求", "根据IFID(芯片编号)得到一个对象实体");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据IFID(芯片编号)得到一个对象实体(查铺查哨判断被查人是否在岗)
|
|
private string IFIDGetModelLeave(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["ORG_ID"];
|
|
string IFID = context.Request.Params["IFID"];
|
|
FangYar.Model.OA_PATROL_SPOT model = bll.IFIDGetModel(ORG_ID, IFID);
|
|
if (model != null)
|
|
{
|
|
JObject acc_ppl_s = JsonConvert.DeserializeObject<JObject>(model.EXTENDCODE2);
|
|
|
|
if (acc_ppl_s != null)
|
|
{
|
|
//JObject acc_ppl_s2 = new JObject();
|
|
//JObject acc_ppl_s2 = new JObject();
|
|
//JArray arr = new JArray();
|
|
string acc_ppl_s2 = "{\"data\":[";
|
|
int a = 0;
|
|
foreach (JObject obj in acc_ppl_s.Value<JArray>("data"))
|
|
{
|
|
FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = ebll.GetModelByUID((string)obj["ppl_Id"]);
|
|
if (a == 0)
|
|
{
|
|
acc_ppl_s2 += "{";
|
|
}
|
|
else
|
|
{
|
|
acc_ppl_s2 += ",{";
|
|
}
|
|
acc_ppl_s2 += "\"ppl_Id\":\"" + obj["ppl_Id"] + "\"";
|
|
acc_ppl_s2 += ",\"ppl_Name\":\"" + obj["ppl_Name"] + "\"";
|
|
acc_ppl_s2 += ",\"is_work\":\"" + emodel.IS_WORK + "\"";
|
|
acc_ppl_s2 += "}";
|
|
a++;
|
|
}
|
|
acc_ppl_s2 += "]}";
|
|
model.EXTENDCODE2 = acc_ppl_s2;
|
|
returnstr = "{\"code\":1,\"msg\":\"ok\",\"data\":";
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(model);
|
|
returnstr += "}";
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"ok\",\"count\":0,\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"ok\",\"count\":0,\"data\":[]}";
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "巡查点操作请求", "查铺查哨判断被查人是否在岗异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "巡查点操作请求", "查铺查哨判断被查人是否在岗");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//获取下拉列表 机构下的巡查点列表
|
|
private string getSpots(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string patrolSpotType = context.Request.Params["patrolSpotType"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataSet data = bll.GetList(" org_id = '" + orgId + "' and EXTENDCODE1 = '" + patrolSpotType + "'");
|
|
if (data.Tables.Count > 0)
|
|
{
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(data.Tables[0]);
|
|
}
|
|
else
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|