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.
294 lines
14 KiB
294 lines
14 KiB
using FangYar.BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Globalization;
|
|
using System.Web;
|
|
using FangYar.Model.OA;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaTodayArrangementHandler 当天安排(当天学习训练内容)
|
|
/// </summary>
|
|
public class OaTodayArrangementHandler : IHttpHandler
|
|
{
|
|
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 "GetList":
|
|
returnstr = GetList(context);
|
|
break;
|
|
case "GetModelByOrgDate":
|
|
returnstr = GetModelByOrgDate(context);
|
|
break;
|
|
case "GetModelById":
|
|
returnstr = GetModelById(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = Add(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = Edit(context);
|
|
break;
|
|
}
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetList(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string is_content = context.Request.Params["is_content"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string treeID = context.Request.Params["treeID"];
|
|
if (!string.IsNullOrWhiteSpace(treeID))
|
|
{
|
|
orgId = treeID;
|
|
}
|
|
if (string.IsNullOrEmpty(orgId))
|
|
{
|
|
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}";
|
|
}
|
|
string startDate = context.Request.Params["startDate"];
|
|
string endDate = context.Request.Params["endDate"];
|
|
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 sql = @"select t.*,org.ORG_NAME from oa_today_arrangement t left join fire_org org on t.ORG_ID=org.ORG_ID,(select get_Org_child_list('" + orgId + "') cids) s where 1=1 ";
|
|
if (is_content == "1")
|
|
{
|
|
sql += " and ( find_in_set(t.org_id, cids) ) ";
|
|
}
|
|
else
|
|
{
|
|
sql += " and ( t.ORG_ID = '" + orgId + "' )";
|
|
}
|
|
if (!string.IsNullOrEmpty(startDate))
|
|
{
|
|
sql += " and date_format(t.ADate,'%Y-%m-%d') >= date_format('" + startDate + "','%Y-%m-%d') ";
|
|
}
|
|
if (!string.IsNullOrEmpty(endDate))
|
|
{
|
|
sql += " and date_format(t.ADate,'%Y-%m-%d') <= date_format('" + endDate + "','%Y-%m-%d') ";
|
|
}
|
|
int count = FangYar.Common.MySqlHelper.QueryTable(sql).Rows.Count;
|
|
|
|
sql += "order by t.ADate desc limit " + (pageIndex - 1) * pageSize + ", " + pageSize;
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "当天安排操作请求", "查询");
|
|
|
|
return "{\"code\":0,\"msg\":\"\",\"count\":" + count + ",\"data\":" + FangYar.Common.JsonHelper.ToJson(dt) + "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
var b = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "当天安排操作请求", "查询异常:" + e);
|
|
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":[]}";
|
|
}
|
|
}
|
|
|
|
//根据机构ID、日期获取 单条数据
|
|
private string GetModelByOrgDate(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string aDate = context.Request.Params["aDate"];
|
|
string sql = @"select * from oa_today_arrangement where org_id = '" + orgId + @"' and aDate = '" + aDate + @"' order by U_Time desc";
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
CommomModelBLL comm = new CommomModelBLL();
|
|
List<OA_TODAY_ARRANGEMENT> list = comm.GetModelFromDB<OA_TODAY_ARRANGEMENT>(dt);
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "当天安排操作请求", "根据机构ID、日期获取 单条数据");
|
|
if (list.Count > 0)
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"操作成功!\",\"data\":" + FangYar.Common.JsonHelper.ToJson(list[0]) + "}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"操作成功!\",\"data\":{}}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
var b = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "当天安排操作请求", "根据机构ID、日期获取 单条数据异常:" + e);
|
|
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":{}}";
|
|
}
|
|
}
|
|
|
|
//根据ID获取 单条数据
|
|
private string GetModelById(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
string sql = @"select * from oa_today_arrangement where id = '" + id + @"'";
|
|
DataTable dt = FangYar.Common.MySqlHelper.QueryTable(sql);
|
|
CommomModelBLL comm = new CommomModelBLL();
|
|
List<OA_TODAY_ARRANGEMENT> list = comm.GetModelFromDB<OA_TODAY_ARRANGEMENT>(dt);
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "当天安排操作请求", "根据ID获取 单条数据");
|
|
if (list.Count > 0)
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"操作成功!\",\"data\":" + FangYar.Common.JsonHelper.ToJson(list[0]) + "}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"操作成功!\",\"data\":{}}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
var b = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "当天安排操作请求", "根据ID获取 单条数据异常:" + e);
|
|
return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员!\",\"error\":\"" + b + "\",\"data\":{}}";
|
|
}
|
|
}
|
|
|
|
//添加
|
|
private string Add(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string orgId = context.Request.Params["orgId"];
|
|
string aDate = context.Request.Params["aDate"];
|
|
string morningCon = context.Request.Params["morningCon"];
|
|
string afternoonCon = context.Request.Params["afternoonCon"];
|
|
string nightCon = context.Request.Params["nightCon"];
|
|
string userUid = context.Request.Params["userUid"];
|
|
string aTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
|
|
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
|
|
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
|
|
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
|
|
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
|
|
|
|
string sql = @"insert into oa_today_arrangement(
|
|
org_id,adate,morning_con,afternoon_con,night_con,a_per,a_time,EXTENDCODE1,EXTENDCODE2,EXTENDCODE3,EXTENDCODE4,EXTENDCODE5,EXTENDCODE6
|
|
) values (
|
|
'" + orgId + @"','" + aDate + @"','" + morningCon + @"','" + afternoonCon + @"','" + nightCon + @"','" + userUid + @"','" + aTime + @"',
|
|
'" + EXTENDCODE1 + @"','" + EXTENDCODE2 + @"','" + EXTENDCODE3 + @"','" + EXTENDCODE4 + @"','" + EXTENDCODE5 + @"','" + EXTENDCODE6 + @"'
|
|
)";
|
|
int dt = FangYar.Common.MySqlHelper.Execute(sql);
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "当天安排操作请求", "添加");
|
|
if (dt > 0)
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"添加成功!\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":\"-1\",\"msg\":\"添加失败!\"}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
var b = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "当天安排操作请求", "添加异常:" + e);
|
|
return "{\"code\":\"-1\",\"msg\":\"添加异常,请联系平台管理员!\",\"error\":\"" + b + "\"}";
|
|
}
|
|
}
|
|
|
|
//修改
|
|
private string Edit(HttpContext context)
|
|
{
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
string orgId = context.Request.Params["orgId"];
|
|
string aDate = context.Request.Params["aDate"];
|
|
string morningCon = context.Request.Params["morningCon"];
|
|
string afternoonCon = context.Request.Params["afternoonCon"];
|
|
string nightCon = context.Request.Params["nightCon"];
|
|
string userUid = context.Request.Params["userUid"];
|
|
string uTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
|
|
|
|
string EXTENDCODE1 = context.Request.Params["EXTENDCODE1"];
|
|
string EXTENDCODE2 = context.Request.Params["EXTENDCODE2"];
|
|
string EXTENDCODE3 = context.Request.Params["EXTENDCODE3"];
|
|
string EXTENDCODE4 = context.Request.Params["EXTENDCODE4"];
|
|
string EXTENDCODE5 = context.Request.Params["EXTENDCODE5"];
|
|
string EXTENDCODE6 = context.Request.Params["EXTENDCODE6"];
|
|
|
|
string sql = @"update oa_today_arrangement set
|
|
org_id = '" + orgId + @"',
|
|
aDate = '" + aDate + @"',
|
|
morning_con = '" + morningCon + @"',
|
|
afternoon_con = '" + afternoonCon + @"',
|
|
night_con = '" + nightCon + @"',
|
|
u_per = '" + userUid + @"',
|
|
u_time = '" + uTime + @"',
|
|
EXTENDCODE1 = '" + EXTENDCODE1 + @"',
|
|
EXTENDCODE2 = '" + EXTENDCODE2 + @"',
|
|
EXTENDCODE3 = '" + EXTENDCODE3 + @"',
|
|
EXTENDCODE4 = '" + EXTENDCODE4 + @"',
|
|
EXTENDCODE5 = '" + EXTENDCODE5 + @"',
|
|
EXTENDCODE6 = '" + EXTENDCODE6 + @"'
|
|
where id = '" + id + @"'";
|
|
int dt = FangYar.Common.MySqlHelper.Execute(sql);
|
|
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "当天安排操作请求", "修改");
|
|
if (dt > 0)
|
|
{
|
|
return "{\"code\":\"200\",\"msg\":\"修改成功!\"}";
|
|
}
|
|
else
|
|
{
|
|
return "{\"code\":\"-1\",\"msg\":\"修改失败!\"}";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
var a = Regex.Replace(e.Message, @"\r", "");
|
|
var b = Regex.Replace(a, @"\n", "");
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "当天安排操作请求", "修改异常:" + e);
|
|
return "{\"code\":\"-1\",\"msg\":\"修改异常,请联系平台管理员!\",\"error\":\"" + b + "\"}";
|
|
}
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|