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.
354 lines
13 KiB
354 lines
13 KiB
11 months ago
|
using Newtonsoft.Json.Linq;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Web;
|
||
|
|
||
|
namespace FangYar.WebUI.ashx
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// OaLeaveHandler 的摘要说明
|
||
|
/// </summary>
|
||
|
public class ZYOaLeaveHandler : IHttpHandler
|
||
|
{
|
||
|
private FangYar.BLL.OA_LEAVE bll = new FangYar.BLL.OA_LEAVE();
|
||
|
public void ProcessRequest(HttpContext context)
|
||
|
{
|
||
|
context.Response.ContentType = "text/plain";
|
||
|
string action = context.Request.Params["Action"];
|
||
|
string returnstr = "";
|
||
|
|
||
|
switch (action)
|
||
|
{
|
||
|
case "List":
|
||
|
returnstr = getLeaveList(context);
|
||
|
break;
|
||
|
case "getOrgTree":
|
||
|
returnstr = getOrgTreeList(context);
|
||
|
break;
|
||
|
case "getOrgTree2":
|
||
|
returnstr = getOrgTreeList2(context);
|
||
|
break;
|
||
|
case "getOrgList":
|
||
|
returnstr = getOrgList(context);
|
||
|
break;
|
||
|
case "getOrgList2":
|
||
|
returnstr = getOrgList2(context);
|
||
|
break;
|
||
|
case "add":
|
||
|
returnstr = addLeave(context);
|
||
|
break;
|
||
|
case "getLeave":
|
||
|
returnstr = getLeave(context);
|
||
|
break;
|
||
|
case "editWait":
|
||
|
returnstr = editWait(context);
|
||
|
break;
|
||
|
}
|
||
|
context.Response.Write(returnstr);
|
||
|
}
|
||
|
|
||
|
//查询
|
||
|
private string getLeaveList(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string userId = context.Request.Params["userId"];
|
||
|
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 = "PPL_ID = '" + userId + "' ";
|
||
|
if (!string.IsNullOrEmpty(keyword))
|
||
|
{
|
||
|
where += " and L_OUT like '" + keyword + "' or L_REASON like '" + keyword + "' ";
|
||
|
}
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
||
|
int count = bll.GetRecordCount(where);
|
||
|
returnstr += "\"count\":" + count + ",\"data\":";
|
||
|
if (count == 0)
|
||
|
{
|
||
|
returnstr += "[]";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
List<FangYar.Model.OA_LEAVE> list = bll.QueryList(pageIndex, pageSize, where, null);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
||
|
}
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//获取Tree 机构-部门-员工(获取UID)
|
||
|
private string getOrgTreeList(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
string type = context.Request.Params["type"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgTree(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//获取Tree 机构-部门-员工(获取EMP_ID)
|
||
|
private string getOrgTreeList2(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
string type = context.Request.Params["type"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgTree2(orgId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
|
||
|
//手机端 获取Tree 机构-部门-员工(获取UID)
|
||
|
private string getOrgList(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgTree(orgId);
|
||
|
|
||
|
//List<Dictionary<string, JArray>> dict = new List<Dictionary<string, JArray>>();
|
||
|
//foreach (DataRow d in data.Rows)
|
||
|
//{
|
||
|
// if (d["TYPE"].ToString() == "org" || d["TYPE"].ToString() == "dept")
|
||
|
// {
|
||
|
// Dictionary<string, JArray> dictOrg = new Dictionary<string, JArray>();
|
||
|
|
||
|
// JArray farray = new JArray();
|
||
|
// //JObject fobj = new JObject();
|
||
|
// //JProperty fname = new JProperty("name", d["NAME"].ToString());
|
||
|
// //fobj.Add(fname);
|
||
|
// farray.Add(d["NAME"].ToString());
|
||
|
// dictOrg.Add("name", farray);
|
||
|
// JArray empa = new JArray();
|
||
|
// foreach (DataRow d1 in data.Rows)
|
||
|
// {
|
||
|
// if (d1["TYPE"].ToString() == "emp" && d1["PID"].ToString() == d["ID"].ToString())
|
||
|
// {
|
||
|
// JObject emp = new JObject();
|
||
|
// JProperty id = new JProperty("id", d1["ID"].ToString());
|
||
|
// JProperty name = new JProperty("name", d1["NAME"].ToString());
|
||
|
// emp.Add(id);
|
||
|
// emp.Add(name);
|
||
|
// empa.Add(emp);
|
||
|
// }
|
||
|
// }
|
||
|
// dictOrg.Add("data", empa);
|
||
|
// dict.Add(dictOrg);
|
||
|
|
||
|
// }
|
||
|
//}
|
||
|
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//手机端 获取Tree 机构-部门-员工(获取EMP_ID)
|
||
|
private string getOrgList2(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string orgId = context.Request.Params["OrgId"];
|
||
|
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
||
|
DataTable data = bll.getOrgTree2(orgId);
|
||
|
|
||
|
List<Dictionary<string, JArray>> dict = new List<Dictionary<string, JArray>>();
|
||
|
foreach (DataRow d in data.Rows)
|
||
|
{
|
||
|
if (d["TYPE"].ToString() == "org" || d["TYPE"].ToString() == "dept")
|
||
|
{
|
||
|
Dictionary<string, JArray> dictOrg = new Dictionary<string, JArray>();
|
||
|
JArray fname = new JArray();
|
||
|
fname.Add(d["NAME"].ToString());
|
||
|
dictOrg.Add("name", fname);
|
||
|
JArray empa = new JArray();
|
||
|
foreach (DataRow d1 in data.Rows)
|
||
|
{
|
||
|
if (d1["TYPE"].ToString() == "emp" && d1["PID"].ToString() == d["ID"].ToString())
|
||
|
{
|
||
|
JObject emp = new JObject();
|
||
|
emp.Add(d1["ID"].ToString());
|
||
|
emp.Add(d1["NAME"].ToString());
|
||
|
empa.Add(emp);
|
||
|
}
|
||
|
}
|
||
|
dictOrg.Add("data", empa);
|
||
|
dict.Add(dictOrg);
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(dict);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//添加请假
|
||
|
private string addLeave(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
try
|
||
|
{
|
||
|
string leaveId = Guid.NewGuid().ToString("N");
|
||
|
string pplId = context.Request.Params["ppl_id"];
|
||
|
string pplName = context.Request.Params["ppl_name"];
|
||
|
string lType = context.Request.Params["l_type"];
|
||
|
string sTime = context.Request.Params["s_time"];
|
||
|
string eTime = context.Request.Params["e_time"];
|
||
|
string lNum = context.Request.Params["l_num"];
|
||
|
string lOut = context.Request.Params["l_out"];
|
||
|
string accPplId = context.Request.Params["acc_pplId"];
|
||
|
string repPplId = context.Request.Params["rep_pplId"];
|
||
|
string lReason = context.Request.Params["l_reason"];
|
||
|
string appPplId = context.Request.Params["app_pplId"];
|
||
|
|
||
|
//请假表
|
||
|
FangYar.Model.OA_LEAVE model = new Model.OA_LEAVE();
|
||
|
model.ID = leaveId;
|
||
|
model.PPL_ID = pplId;
|
||
|
model.PPL_NAME = pplName;
|
||
|
model.L_TYPE = lType;
|
||
|
model.S_TIME = sTime;
|
||
|
model.E_TIME = eTime;
|
||
|
model.L_OUT = lOut;
|
||
|
model.ACC_PPL = accPplId;
|
||
|
model.REP_PPL = repPplId;
|
||
|
model.L_NUM = lNum;
|
||
|
model.L_REASON = lReason;
|
||
|
model.PHOTO = "";
|
||
|
model.STATE = "0";
|
||
|
|
||
|
if (bll.AddLeave(model, appPplId))
|
||
|
{
|
||
|
msg = "添加成功!";
|
||
|
code = 1;
|
||
|
}
|
||
|
else { msg = "添加失败!"; }
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "添加失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//获取请假信息、流转记录
|
||
|
private string getLeave(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
try
|
||
|
{
|
||
|
string leaveId = context.Request.Params["leaveId"];
|
||
|
returnstr = "{\"code\":0,\"msg\":\"\",\"leaveData\":";
|
||
|
List<DataTable> data = bll.getLeave(leaveId);
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data[0]);
|
||
|
returnstr += ",\"waitData\":";
|
||
|
returnstr += FangYar.Common.JsonHelper.ToJson(data[1]);
|
||
|
returnstr += "}";
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]";
|
||
|
}
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
//请假审批
|
||
|
private string editWait(HttpContext context)
|
||
|
{
|
||
|
string returnstr = "";
|
||
|
int code = -1;
|
||
|
string msg = "";
|
||
|
string usercode = "";
|
||
|
try
|
||
|
{
|
||
|
string leaveId = context.Request.Params["leaveId"];
|
||
|
string waitId = context.Request.Params["waitId"];
|
||
|
string state = context.Request.Params["state"];
|
||
|
string sort = context.Request.Params["sort"];
|
||
|
string aOpinion = context.Request.Params["a_opinion"];
|
||
|
string isOver = context.Request.Params["isOver"];
|
||
|
|
||
|
FangYar.Model.OA_WAITPROCESSED model = new Model.OA_WAITPROCESSED();
|
||
|
model.ID = waitId;
|
||
|
model.TASK_ID = leaveId;
|
||
|
model.STATE = state;
|
||
|
model.SORT = Convert.ToInt32(sort);
|
||
|
model.A_OPINION = aOpinion;
|
||
|
if (!string.IsNullOrEmpty(bll.editWait(model, isOver)))
|
||
|
{
|
||
|
msg = "审批成功!";
|
||
|
code = 1;
|
||
|
usercode = bll.editWait(model, isOver);
|
||
|
}
|
||
|
else { msg = "审批失败!"; }
|
||
|
}
|
||
|
catch
|
||
|
{
|
||
|
msg = "审批失败!";
|
||
|
}
|
||
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "\",\"usercode\":" + usercode + "}";
|
||
|
return returnstr;
|
||
|
}
|
||
|
|
||
|
public bool IsReusable
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|