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.
1460 lines
63 KiB
1460 lines
63 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;
|
|
using System.IO;
|
|
using Spire.Doc;
|
|
using Spire.Doc.Documents;
|
|
using System.Drawing;
|
|
using Spire.Doc.Fields;
|
|
using System.Timers;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class OaLeaveHandler : IHttpHandler
|
|
{
|
|
private FangYar.BLL.OA_LEAVE bll = new FangYar.BLL.OA_LEAVE();
|
|
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 = getLeaveList(context);
|
|
break;
|
|
case "ListAll":
|
|
returnstr = getLeaveAllList(context);
|
|
break;
|
|
case "ListAllHomePage":
|
|
returnstr = ListAllHomePage(context);
|
|
break;
|
|
case "getOrgTree":
|
|
returnstr = getOrgTreeList(context);
|
|
break;
|
|
case "getOrgTree2":
|
|
returnstr = getOrgTreeList2(context);
|
|
break;
|
|
case "getOrgTree3":
|
|
returnstr = getOrgTreeList3(context);
|
|
break;
|
|
case "getOrgList":
|
|
returnstr = getOrgList(context);
|
|
break;
|
|
case "getOrgList2":
|
|
returnstr = getOrgList2(context);
|
|
break;
|
|
case "getOrgLeaderTree":
|
|
returnstr = getOrgLeaderTree(context);
|
|
break;
|
|
case "add":
|
|
returnstr = addLeave(context);
|
|
break;
|
|
case "getLeave":
|
|
returnstr = getLeave(context);
|
|
break;
|
|
case "editWait":
|
|
returnstr = editWait(context);
|
|
break;
|
|
case "ApplyRegression":
|
|
returnstr = ApplyRegression(context);
|
|
break;
|
|
case "ApprovalRegression":
|
|
returnstr = ApprovalRegression(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelLeave(context);
|
|
break;
|
|
case "getAksPatrolOrgTree":
|
|
returnstr = getAksPatrolOrgTree(context);
|
|
break;
|
|
case "leaveSta":
|
|
returnstr = leaveSta(context);
|
|
break;
|
|
case "homeLeaveSta":
|
|
returnstr = homeLeaveSta(context);
|
|
break;
|
|
case "homeLeaveStaAll":
|
|
returnstr = homeLeaveStaAll(context);
|
|
break;
|
|
case "leaveTypeSta":
|
|
returnstr = leaveTypeSta(context);
|
|
break;
|
|
case "LeaveTypeCountList":
|
|
returnstr = LeaveTypeCountList(context);
|
|
break;
|
|
case "leaveTypeList":
|
|
returnstr = leaveTypeList(context);
|
|
break;
|
|
case "htmlToWord":
|
|
returnstr = htmlToWord(context);
|
|
break;
|
|
case "leaveSta2":
|
|
returnstr = leaveSta2(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 + "' or PPL_ID = 'u_" + 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, " 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;
|
|
}
|
|
|
|
//查询营区内所有人员请假记录
|
|
private string getLeaveAllList(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"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
string type = context.Request.Params["type"];
|
|
string searchTime = context.Request.Params["searchTime"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
string selDeptId = context.Request.Params["selDeptId"];
|
|
//登录账号所属部门
|
|
string DeptID = context.Request.Params["DeptID"] + "";
|
|
//是否管理员账号
|
|
string IsAdmin = context.Request.Params["IsAdmin"] + "";
|
|
|
|
|
|
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 in (select users_uid from tbl_sys_emp where IS_ADMIN='0' ";
|
|
|
|
string pOrgID = "";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != orgId)
|
|
{
|
|
pOrgID = treeID;
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( find_in_set(org_id, cids) or find_in_set(DEPT_ID, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + treeID + "' or DEPT_ID = '" + treeID + "')";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
pOrgID = orgId;
|
|
if (is_content == "1")
|
|
{
|
|
where += " and ( find_in_set(org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ( ORG_ID = '" + orgId + "' or DEPT_ID = '" + orgId + "')";
|
|
}
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(selDeptId))
|
|
{
|
|
where += " and DEPT_ID = '" + selDeptId + "' ";
|
|
}
|
|
|
|
|
|
|
|
//判断是否管理员账号,如果不是管理员则只查询本部门数据
|
|
if (IsAdmin != "1")
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(DeptID))
|
|
{
|
|
where += " and DEPT_ID='" + DeptID + "' ";
|
|
}
|
|
}
|
|
|
|
where += " and users_uid is not null )";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and (L_OUT like '%" + keyword + "%' or L_REASON like '%" + keyword + "%' or PPL_NAME like '%" + keyword + "%' ) ";
|
|
}
|
|
if (!string.IsNullOrEmpty(searchTime))
|
|
{
|
|
|
|
string startTime = "", endTime = "";
|
|
if (searchTime.IndexOf(" 到 ") != -1)
|
|
{
|
|
startTime = Regex.Split(searchTime, " 到 ", RegexOptions.IgnoreCase)[0];
|
|
endTime = Regex.Split(searchTime, " 到 ", RegexOptions.IgnoreCase)[1];
|
|
}
|
|
|
|
where += " and (( STR_TO_DATE(s_time,'%Y-%m-%d')>=STR_TO_DATE('" + startTime + "','%Y-%m-%d')" +
|
|
" and STR_TO_DATE(s_time,'%Y-%m-%d')<= STR_TO_DATE('" + endTime + "', '%Y-%m-%d') ) " +
|
|
"or ( STR_TO_DATE(e_time,'%Y-%m-%d')>=STR_TO_DATE('" + startTime + "','%Y-%m-%d')" +
|
|
" and STR_TO_DATE(e_time,'%Y-%m-%d')<= STR_TO_DATE('" + endTime + "', '%Y-%m-%d') )) ";
|
|
}
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where, pOrgID);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
List<FangYar.Model.OA_LEAVE> list = bll.QueryList(pageIndex, pageSize, where, " s_time desc", pOrgID);
|
|
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 ListAllHomePage(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
|
|
string where = null;
|
|
where = " PPL_ID in (select users_uid from tbl_sys_emp where IS_ADMIN='0' ";
|
|
|
|
if (is_content == "0")
|
|
{
|
|
where += " and ( ORG_ID = '" + orgId + "' or DEPT_ID = '" + orgId + "')";
|
|
}
|
|
else
|
|
{
|
|
where += " and org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + orgId + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) )";
|
|
}
|
|
|
|
|
|
where += " and users_uid is not null )";
|
|
|
|
where += " AND state = '1'";
|
|
|
|
where += " AND date_format(S_TIME, '%Y-%m-%d' ) >= date_format('" + DateTime.Now.AddDays(-6).ToString("yyyy-MM-dd") + "', '%Y-%m-%d')";
|
|
|
|
where += " AND date_format(S_TIME, '%Y-%m-%d' ) <= date_format('" + DateTime.Now.ToString("yyyy-MM-dd") + "', '%Y-%m-%d')";
|
|
|
|
where += " order by s_time desc";
|
|
//where += " and (( STR_TO_DATE(s_time,'%Y-%m-%d')>=STR_TO_DATE('" + startTime + "','%Y-%m-%d')" +
|
|
// " and STR_TO_DATE(s_time,'%Y-%m-%d')<= STR_TO_DATE('" + endTime + "', '%Y-%m-%d') ) " +
|
|
// "or ( STR_TO_DATE(e_time,'%Y-%m-%d')>=STR_TO_DATE('" + startTime + "','%Y-%m-%d')" +
|
|
// " and STR_TO_DATE(e_time,'%Y-%m-%d')<= STR_TO_DATE('" + endTime + "', '%Y-%m-%d') )) ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.ListAllHomePage(where);
|
|
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, "请假操作请求", "首页查询营区内人员近七天请假记录异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "首页查询营区内人员近七天请假记录");
|
|
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);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
}
|
|
else
|
|
{
|
|
data.Rows[i]["nocheck"] = "true";
|
|
}
|
|
}
|
|
|
|
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, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)");
|
|
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 (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "获取Tree 机构-部门-员工(获取EMP_ID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取Tree 机构-部门-员工(获取EMP_ID)");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//获取Tree 机构-部门-员工(获取UID)
|
|
private string getOrgTreeList3(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
string type = context.Request.Params["type"];
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
FangYar.BLL.TRAIN.T_TRAININGPLAN tbll = new BLL.TRAIN.T_TRAININGPLAN();
|
|
DataTable data = tbll.getOrgTree(orgId);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
//if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
//{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
//}
|
|
//else
|
|
//{
|
|
// data.Rows[i]["nocheck"] = "true";
|
|
//}
|
|
}
|
|
|
|
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, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)");
|
|
return returnstr;
|
|
}
|
|
|
|
//获取Tree 机构-部门-员工(获取UID)
|
|
private string getOrgLeaderTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getOrgLeaderTree(orgId);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
}
|
|
else
|
|
{
|
|
data.Rows[i]["nocheck"] = "true";
|
|
}
|
|
}
|
|
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, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)");
|
|
return returnstr;
|
|
}
|
|
|
|
//获取Tree 机构-部门-员工(获取UID)
|
|
private string getAksPatrolOrgTree(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["OrgId"];
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
DataTable data = bll.getAksPatrolOrgTree(orgId);
|
|
data.Columns.Add("nocheck", typeof(string)); //数据类型为文本
|
|
for (int i = 0; i < data.Rows.Count; i++)
|
|
{
|
|
string aaa = data.Rows[i]["TYPE"].ToString();
|
|
if (data.Rows[i]["TYPE"].ToString() == "emp")
|
|
{
|
|
data.Rows[i]["nocheck"] = "false";
|
|
}
|
|
else
|
|
{
|
|
data.Rows[i]["nocheck"] = "true";
|
|
}
|
|
}
|
|
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, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取Tree 机构-部门-员工(获取UID)");
|
|
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 (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "手机端 获取Tree 机构-部门-员工(获取UID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "手机端 获取Tree 机构-部门-员工(获取UID)");
|
|
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 (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"data\":[]}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "手机端 获取Tree 机构-部门-员工(获取EMP_ID)异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "手机端 获取Tree 机构-部门-员工(获取EMP_ID)");
|
|
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 lTypeName = context.Request.Params["l_typeName"];
|
|
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))
|
|
{
|
|
JObject ppl_s = JsonConvert.DeserializeObject<JObject>(appPplId);
|
|
FangYar.BLL.TBL.SysUsersBLL ubll = new BLL.TBL.SysUsersBLL();
|
|
|
|
foreach (JObject obj in ppl_s.Value<JArray>("data"))
|
|
{
|
|
string objpplId = (string)obj["ppl_Id"];
|
|
string objpplName = (string)obj["ppl_Name"];
|
|
Model.TBL.TBL_SYS_USERS_Model usersModel = ubll.CheckLoginByUserID(objpplId);
|
|
//cwsService.CwsClient cws = new cwsService.CwsClient();
|
|
//cws.yqMessageSend(usersModel.USERS_MOBILE, pplName, "请假", "待审批");
|
|
|
|
break;
|
|
}
|
|
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 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 (Exception e)
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"error\",\"count\":0,\"leaveData\":[],\"waitData\":[] }";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "获取请假信息、流转记录异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "获取请假信息、流转记录");
|
|
return returnstr;
|
|
}
|
|
|
|
//请假审批
|
|
private string editWait(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string pplid = "";
|
|
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;
|
|
|
|
pplid = bll.editWait(model, isOver);
|
|
if (pplid != "")
|
|
{
|
|
//cwsService.CwsClient cws = new cwsService.CwsClient();
|
|
FangYar.BLL.TBL.SysUsersBLL ubll = new BLL.TBL.SysUsersBLL();
|
|
Model.TBL.TBL_SYS_USERS_Model usersModel = ubll.CheckLoginByUserID(pplid);
|
|
string org3 = "已审批";
|
|
//发送给下一位待办人
|
|
if (state == "2" && isOver == "0") org3 = "待审批";
|
|
//cws.yqMessageSend(usersModel.USERS_MOBILE, usersModel.USERS_NAME, "请假", org3);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "请假审批异常:" + e);
|
|
}
|
|
returnstr = "{\"data\":\"" + pplid + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "请假审批");
|
|
return returnstr;
|
|
}
|
|
|
|
//销假申请
|
|
private string ApplyRegression(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
string pplid = "";
|
|
string code = "0";
|
|
string msg = "发起失败";
|
|
try
|
|
{
|
|
string leaveId = context.Request.Params["leaveId"];
|
|
|
|
//请假表
|
|
FangYar.Model.OA_LEAVE model = new Model.OA_LEAVE();
|
|
model.ID = leaveId;
|
|
pplid = bll.Regression(model);
|
|
if (pplid != "")
|
|
{
|
|
msg = "发起成功";
|
|
code = "1";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "销假申请异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":\"" + code + "\",\"data\":\"" + pplid + "\",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "请假操作请求", "销假申请");
|
|
return returnstr;
|
|
}
|
|
|
|
//销假审批
|
|
private string ApprovalRegression(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string leaveId = context.Request.Params["leaveId"];
|
|
string waitId = context.Request.Params["waitId"];
|
|
string state = context.Request.Params["state"];
|
|
|
|
//待办表
|
|
FangYar.Model.OA_WAITPROCESSED model = new Model.OA_WAITPROCESSED();
|
|
model.ID = waitId;
|
|
model.TASK_ID = leaveId;
|
|
model.STATE = state;
|
|
|
|
if (bll.ApprovalRegression(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 DelLeave(HttpContext context)
|
|
{
|
|
string msg = "删除失败";
|
|
string pplId_s = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
string sTime = context.Request.Params["sTime"];
|
|
string data = bll.DelLeave(id, sTime);
|
|
string[] data_s = data.Split('。');
|
|
msg = data_s[0];
|
|
pplId_s = data_s[1];
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "删除异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "请假操作请求", "删除");
|
|
return "{\"msg\":\"" + msg + "\",\"data\":\"" + pplId_s + "\" }";
|
|
}
|
|
|
|
//请假统计
|
|
private string leaveSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and ORG_ID='" + ORG_ID + "'";
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date(S_TIME) between '" + S_Time + "' and '" + E_Time + "' ";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
DataTable dt = bll.leaveSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "请假统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "请假统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//请假统计
|
|
private string leaveTypeSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date(S_TIME) between '" + S_Time + "' and '" + E_Time + "' ";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d') ";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp,(select get_Org_child_list('" + ORG_ID + "') cids ) s where find_in_set(org_id,cids) and IS_ADMIN='0' and is_del = '0'" +
|
|
" and users_uid is not null)";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp where IS_ADMIN='0' and ORG_ID ='" + ORG_ID + "' and is_del = '0'" +
|
|
" and users_uid is not null)";
|
|
}
|
|
}
|
|
strWhere += " and STATE = '1'";
|
|
|
|
DataTable dt = bll.LeaveTypeSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
msg = "获取成功!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "请假统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "请假统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//请假列表
|
|
private string LeaveTypeCountList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
|
|
strWhere += " and date(S_TIME) between '" + S_Time + "' and '" + E_Time + "' ";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp where IS_ADMIN='0' ";
|
|
if (!string.IsNullOrEmpty(is_content))
|
|
{
|
|
strWhere += " and ORG_ID in (select o.org_id from fire_org o,(select get_Org_child_list('" + ORG_ID + "') cids ) s where o.type = '0' and FIND_IN_SET(org_id,cids))";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and ORG_ID = '" + ORG_ID + "'";
|
|
}
|
|
|
|
strWhere += " and is_del = '0' and users_uid is not null)";
|
|
}
|
|
strWhere += " and STATE = '1'";
|
|
strWhere += " order by s_time desc ";
|
|
|
|
DataTable dt = bll.LeaveTypeCountList(strWhere);
|
|
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
msg = "获取成功!";
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
code = -1;
|
|
msg = "获取失败!";
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
return returnstr;
|
|
}
|
|
|
|
//请假列表
|
|
private string leaveTypeList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
|
|
strWhere += " and date(S_TIME) between '" + S_Time + "' and '" + E_Time + "' ";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp where IS_ADMIN='0' and ORG_ID ='" + ORG_ID + "' and is_del = '0'" +
|
|
" and users_uid is not null)";
|
|
}
|
|
strWhere += " and STATE = '1'";
|
|
strWhere += " order by s_time desc ";
|
|
|
|
DataTable dt = bll.LeaveTypeList(strWhere);
|
|
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
code = 1;
|
|
msg = "获取成功!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "请假列表异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "请假列表");
|
|
return returnstr;
|
|
}
|
|
|
|
//首页请假七天统计
|
|
private string homeLeaveSta(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and ORG_ID='" + ORG_ID + "'";
|
|
DataTable dt = bll.homeLeaveSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "首页请假七天统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "首页请假七天统计");
|
|
return returnstr;
|
|
}
|
|
|
|
//首页请假七天统计
|
|
private string homeLeaveStaAll(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
string data = "";
|
|
string strWhere = " 1=1";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["Org_Id"];
|
|
if (!string.IsNullOrEmpty(ORG_ID))
|
|
{
|
|
code = 1;
|
|
strWhere += " and org_id in (select o.org_id from fire_org o,(select get_Org_child_list('" + ORG_ID + "') cids ) s where o.type = '0' and find_in_set(o.org_id,cids) )";
|
|
DataTable dt = bll.homeLeaveSta(strWhere);
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = "获取失败!";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "首页请假七天统计异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "首页请假七天统计");
|
|
return returnstr;
|
|
}
|
|
//html导出Word
|
|
private string htmlToWord(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string Org_Id = context.Request.Params["Org_Id"];
|
|
string USERS_UID = context.Request.Params["USERS_UID"];
|
|
string S_Time = context.Request.Params["S_Time"];
|
|
string E_Time = context.Request.Params["E_Time"];
|
|
string FlagUID = context.Request.Params["FlagUID"];
|
|
|
|
//实例化一个Document对象
|
|
Document doc = new Document();
|
|
doc.Watermark = null;
|
|
|
|
//添加section和段落
|
|
Section section1 = doc.AddSection();
|
|
Paragraph para1 = section1.AddParagraph();
|
|
|
|
#region 获取table数据
|
|
string strWhere = " 1=1 ";
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date_format('" + S_Time + "','%Y-%m-%d') <= date_format(S_TIME,'%Y-%m-%d')";
|
|
strWhere += " and date_format('" + E_Time + "','%Y-%m-%d') >= date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp where IS_ADMIN='0' and ORG_ID ='" + Org_Id + "' and is_del = '0'" +
|
|
" and users_uid is not null)";
|
|
}
|
|
if (!string.IsNullOrEmpty(FlagUID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + FlagUID + "'";
|
|
}
|
|
strWhere += " and STATE = '1'";
|
|
|
|
|
|
String[] headerQiandi1 = { "姓名", "事假", "病假", "探亲假", "年假", "产假", "陪护假", "总数" }; //表头字段
|
|
DataTable dt1 = bll.LeaveTypeSta(strWhere);
|
|
|
|
DataColumn dc = new DataColumn("Rowsall");
|
|
dt1.Columns.Add(dc);
|
|
int SJall = 0, BJall = 0, TQJall = 0, NJall = 0, CJall = 0, PHJall = 0;
|
|
for (int r = 0; r < dt1.Rows.Count; r++) //生成表体
|
|
{
|
|
int Rowsall = 0;
|
|
for (int c = 2; c < 8; c++)
|
|
{
|
|
Rowsall += int.Parse(dt1.Rows[r][c].ToString());
|
|
if (c == 2)
|
|
{
|
|
SJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
else if (c == 3)
|
|
{
|
|
BJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
else if (c == 4)
|
|
{
|
|
TQJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
else if (c == 5)
|
|
{
|
|
NJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
else if (c == 6)
|
|
{
|
|
CJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
else if (c == 7)
|
|
{
|
|
PHJall += int.Parse(dt1.Rows[r][c].ToString());
|
|
}
|
|
|
|
}
|
|
dt1.Rows[r]["Rowsall"] = Rowsall;
|
|
}
|
|
DataRow dr = dt1.NewRow();
|
|
dt1.Rows.Add(dr);
|
|
dt1.Rows[dt1.Rows.Count - 1][0] = "总数";
|
|
dt1.Rows[dt1.Rows.Count - 1][2] = SJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][3] = BJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][4] = TQJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][5] = NJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][6] = CJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][7] = PHJall;
|
|
dt1.Rows[dt1.Rows.Count - 1][8] = SJall + BJall + TQJall + NJall + CJall + PHJall;
|
|
dt1.Columns.Remove("PPL_ID");
|
|
|
|
if (dt1.Rows.Count > 0)
|
|
{
|
|
#region 创建Word表格
|
|
Table tableQiandi1 = section1.AddTable(); //新建表格
|
|
tableQiandi1.ResetCells(dt1.Rows.Count + 1, headerQiandi1.Length);
|
|
tableQiandi1.TableFormat.Borders.BorderType = Spire.Doc.Documents.BorderStyle.Single;
|
|
|
|
TableRow rowQiandi = tableQiandi1.Rows[0]; //添加行
|
|
rowQiandi.IsHeader = true; //设为表头
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
for (int i = 0; i < headerQiandi1.Length; i++) //生成表头
|
|
{
|
|
rowQiandi.Cells[i].Width = 145;
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.Cells[i].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
Paragraph p = rowQiandi.Cells[i].AddParagraph();
|
|
AddTextRange(section1, p, headerQiandi1[i], 14, true, "黑体", Spire.Doc.Documents.HorizontalAlignment.Center);
|
|
}
|
|
|
|
for (int r = 0; r < dt1.Rows.Count; r++) //生成表体
|
|
{
|
|
TableRow dataRow = tableQiandi1.Rows[r + 1];
|
|
dataRow.RowFormat.BackColor = Color.Empty;
|
|
for (int c = 0; c < dt1.Columns.Count; c++)
|
|
{
|
|
dataRow.Cells[c].Width = 145;
|
|
dataRow.Height = 20;
|
|
dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(dt1.Rows[r][c].ToString());
|
|
tr.CharacterFormat.FontSize = 12;
|
|
}
|
|
}
|
|
#endregion 创建Word表格
|
|
}
|
|
|
|
|
|
|
|
//添加section和段落
|
|
Section section2 = doc.AddSection();
|
|
Paragraph para2 = section2.AddParagraph();
|
|
//列表
|
|
|
|
String[] headerQiandi2 = { "姓名", "类型", "请假天数", "开始时间", "结束时间", "去向", "随行人", "顶班人", "请假事由" }; //表头字段
|
|
|
|
if (!string.IsNullOrEmpty(S_Time) && !string.IsNullOrEmpty(E_Time))
|
|
{
|
|
strWhere += " and date_format('" + S_Time + "','%Y-%m-%d') <= date_format(S_TIME,'%Y-%m-%d')";
|
|
strWhere += " and date_format('" + E_Time + "','%Y-%m-%d') >= date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and date_format(now(),'%Y-%m-%d') = date_format(S_TIME,'%Y-%m-%d')";
|
|
}
|
|
if (!string.IsNullOrEmpty(USERS_UID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + USERS_UID + "'";
|
|
}
|
|
else
|
|
{
|
|
strWhere += " and PPL_ID in (select USERS_UID from tbl_sys_emp where IS_ADMIN='0' and ORG_ID ='" + Org_Id + "' and is_del = '0'" +
|
|
" and users_uid is not null)";
|
|
}
|
|
if (!string.IsNullOrEmpty(FlagUID))
|
|
{
|
|
strWhere += " and PPL_ID = '" + FlagUID + "'";
|
|
}
|
|
strWhere += " and STATE = '1'";
|
|
strWhere += " order by s_time desc ";
|
|
|
|
DataTable dt2 = bll.LeaveTypeList(strWhere);
|
|
|
|
|
|
#endregion 获取table数据
|
|
|
|
if (dt2.Rows.Count > 0)
|
|
{
|
|
|
|
#region 创建Word表格
|
|
Table tableQiandi2 = section2.AddTable(); //新建表格
|
|
tableQiandi2.ResetCells(dt2.Rows.Count + 1, headerQiandi2.Length);
|
|
tableQiandi2.TableFormat.Borders.BorderType = Spire.Doc.Documents.BorderStyle.Single;
|
|
|
|
TableRow rowQiandi = tableQiandi2.Rows[0]; //添加行
|
|
rowQiandi.IsHeader = true; //设为表头
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
for (int i = 0; i < headerQiandi2.Length; i++) //生成表头
|
|
{
|
|
rowQiandi.Cells[i].Width = 145;
|
|
rowQiandi.Height = 30;
|
|
rowQiandi.Cells[i].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
rowQiandi.HeightType = TableRowHeightType.Auto;
|
|
Paragraph p = rowQiandi.Cells[i].AddParagraph();
|
|
AddTextRange(section2, p, headerQiandi2[i], 14, true, "黑体", Spire.Doc.Documents.HorizontalAlignment.Center);
|
|
}
|
|
|
|
for (int r = 0; r < dt2.Rows.Count; r++) //生成表体
|
|
{
|
|
TableRow dataRow = tableQiandi2.Rows[r + 1];
|
|
dataRow.RowFormat.BackColor = Color.Empty;
|
|
for (int c = 0; c < dt2.Columns.Count; c++)
|
|
{
|
|
dataRow.Cells[c].Width = 145;
|
|
dataRow.Height = 20;
|
|
dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle;
|
|
TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(dt2.Rows[r][c].ToString());
|
|
tr.CharacterFormat.FontSize = 12;
|
|
}
|
|
}
|
|
#endregion 创建Word表格
|
|
}
|
|
//保存到文档
|
|
string path = AppDomain.CurrentDomain.BaseDirectory + "\\OA\\Leave_Statistics\\";
|
|
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".doc";
|
|
if (Directory.Exists(path) == false)//如果不存在就创建文件夹
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
doc.SaveToFile(path + fileName, FileFormat.Doc);
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"url\":\"/OA/Leave_Statistics/" + fileName + "\"}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"msg\":\"" + e.Message + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "请假操作请求", "html导出Word异常:" + e);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "请假操作请求", "html导出Word");
|
|
return returnstr;
|
|
}
|
|
|
|
private Image GetImage(string fileName)
|
|
{
|
|
byte[] bytes = Convert.FromBase64String(fileName);
|
|
using (MemoryStream ms = new MemoryStream(bytes))
|
|
{
|
|
return Image.FromStream(ms);
|
|
}
|
|
}
|
|
|
|
private void AddTextRange(Section section, Paragraph pragraph, string word, float fontSize, bool isBold, string fontName, Spire.Doc.Documents.HorizontalAlignment alignType)
|
|
{
|
|
|
|
TextRange textRange = pragraph.AppendText(word);
|
|
textRange.CharacterFormat.FontSize = fontSize;
|
|
textRange.CharacterFormat.Bold = isBold;
|
|
textRange.CharacterFormat.FontName = fontName;
|
|
pragraph.Format.HorizontalAlignment = alignType;
|
|
}
|
|
|
|
|
|
|
|
//根据日期统计请假人员
|
|
private string leaveSta2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string ORG_ID = context.Request.Params["OrgId"];
|
|
string findDate = context.Request.Params["findDate"];
|
|
if (!string.IsNullOrEmpty(ORG_ID) && !string.IsNullOrEmpty(findDate))
|
|
{
|
|
returnstr = "{\"code\":0,\"msg\":\"\",\"data\":";
|
|
List<FangYar.Model.OA_LEAVE> list = bll.leaveSta2(ORG_ID, findDate);
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(list);
|
|
returnstr += "}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":-1,\"msg\":\"参数有误\",\"data\":[]}";
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|