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.
410 lines
17 KiB
410 lines
17 KiB
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Spire.Xls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Text.RegularExpressions;
|
|
using System.Web;
|
|
|
|
namespace FangYar.WebUI.ashx
|
|
{
|
|
/// <summary>
|
|
/// OaLeaveHandler 的摘要说明
|
|
/// </summary>
|
|
public class TSubjectGradeStandard : IHttpHandler
|
|
{
|
|
private FangYar.BLL.TRAIN.T_SUBJECTGRADESTANDARD bll = new BLL.TRAIN.T_SUBJECTGRADESTANDARD();
|
|
private FangYar.BLL.TRAIN.T_SUBJECT sub_bll = new BLL.TRAIN.T_SUBJECT();
|
|
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 = GetTSubjectGradeStandardList(context);
|
|
break;
|
|
case "Add":
|
|
returnstr = AddTSubjectGradeStandard(context);
|
|
break;
|
|
case "Edit":
|
|
returnstr = EditTSubjectGradeStandard(context);
|
|
break;
|
|
case "Del":
|
|
returnstr = DelTSubjectGradeStandard(context);
|
|
break;
|
|
case "GetSubject":
|
|
returnstr = GetSubject(context);
|
|
break;
|
|
case "GetStandardList":
|
|
returnstr = GetStandardList(context); //根据科目获取标准
|
|
break;
|
|
case "GetStandardList2":
|
|
returnstr = GetStandardList2(context); //根据科目获取标准(结果下限倒叙,年龄倒叙)
|
|
break;
|
|
}
|
|
|
|
context.Response.Write(returnstr);
|
|
}
|
|
|
|
//查询
|
|
private string GetTSubjectGradeStandardList(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 subjectid = context.Request.Params["subjectid"];
|
|
string is_content = context.Request.Params["is_content"];
|
|
|
|
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 = " 1=1 ";
|
|
if (!string.IsNullOrEmpty(treeID) && treeID != OrgId)
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where += " and org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + treeID + "') cids ) s where find_in_set(org_id,cids)) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ORG_ID = '" + treeID + "'";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (is_content == "1")
|
|
{
|
|
where += " and org_id in ( select o.org_id from fire_org o,(select get_Org_child_list('" + OrgId + "') cids ) s where find_in_set(org_id,cids)) ";
|
|
}
|
|
else
|
|
{
|
|
where += " and ORG_ID = '" + OrgId + "'";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(keyword))
|
|
{
|
|
where += " and ( NAME like '%" + keyword + "%' or DESCRIPTION like '%" + keyword + "%')";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(subjectid))
|
|
{
|
|
where += " and SUBJECTID = '" + subjectid + "'";
|
|
}
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = bll.GetListByPage(where, "", startIndex, endIndex).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);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "不同科目评分标准操作请求", "查询");
|
|
return returnstr;
|
|
}
|
|
|
|
//添加
|
|
private string AddTSubjectGradeStandard(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string staobjarry = context.Request.Params["staobjarry"];
|
|
|
|
List<FangYar.Model.OA.CommonSql> ht = new List<FangYar.Model.OA.CommonSql>();
|
|
JArray jArray = JArray.Parse(staobjarry);
|
|
foreach (JObject obj in jArray)
|
|
{
|
|
FangYar.Model.TRAIN.T_SUBJECTGRADESTANDARD model = new Model.TRAIN.T_SUBJECTGRADESTANDARD();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.GENDER = obj["gender"].ToString();
|
|
model.SUBJECTID = obj["subjectid"].ToString();
|
|
model.SUBJECTNAME = obj["subjectname"].ToString();
|
|
model.UNITOFMEASUREMEN = obj["unitofmeasuremen"].ToString();
|
|
model.STA1 = obj["sta1"].ToString();
|
|
model.STA2 = obj["sta2"].ToString();
|
|
model.STASYS1 = obj["stasys1"].ToString();
|
|
model.STASYS2 = obj["stasys2"].ToString();
|
|
model.ACHIEVEMENT1 = obj["achievement1"].ToString();
|
|
model.ACHIEVEMENT2 = obj["achievement2"].ToString();
|
|
model.ORG_ID = obj["OrgId"].ToString();
|
|
model.ORG_NAME = obj["OrgName"].ToString();
|
|
|
|
FangYar.Model.OA.CommonSql staModel = bll.getInsertStaSql(model);
|
|
ht.Add(staModel);
|
|
}
|
|
|
|
if (FangYar.Common.MySqlHelper.ExecuteSqlTranBool(ht))
|
|
{
|
|
code = 1;
|
|
msg = "操作成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "操作失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "不同科目评分标准操作请求", "添加异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Add, "不同科目评分标准操作请求", "添加");
|
|
return returnstr;
|
|
}
|
|
|
|
//修改
|
|
private string EditTSubjectGradeStandard(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string staobjarry = context.Request.Params["staobjarry"];
|
|
string subjectid = context.Request.Params["subjectid"];
|
|
|
|
List<FangYar.Model.OA.CommonSql> ht = new List<FangYar.Model.OA.CommonSql>();
|
|
//事务删除
|
|
FangYar.Model.OA.CommonSql delModel = bll.getDeleteStaSql(subjectid);
|
|
ht.Add(delModel);
|
|
|
|
//事务添加
|
|
JArray jArray = JArray.Parse(staobjarry);
|
|
foreach (JObject obj in jArray)
|
|
{
|
|
FangYar.Model.TRAIN.T_SUBJECTGRADESTANDARD model = new Model.TRAIN.T_SUBJECTGRADESTANDARD();
|
|
model.ID = Guid.NewGuid().ToString("N");
|
|
model.GENDER = obj["gender"].ToString();
|
|
model.SUBJECTID = obj["subjectid"].ToString();
|
|
model.SUBJECTNAME = obj["subjectname"].ToString();
|
|
model.UNITOFMEASUREMEN = obj["unitofmeasuremen"].ToString();
|
|
model.STA1 = obj["sta1"].ToString();
|
|
model.STASYS1 = obj["stasys1"].ToString();
|
|
model.ACHIEVEMENT1 = obj["achievement1"].ToString();
|
|
model.ORG_ID = obj["OrgId"].ToString();
|
|
model.ORG_NAME = obj["OrgName"].ToString();
|
|
model.AGE1 = obj["age1"].ToString();
|
|
|
|
FangYar.Model.OA.CommonSql staModel = bll.getInsertStaSql(model);
|
|
ht.Add(staModel);
|
|
}
|
|
|
|
if (FangYar.Common.MySqlHelper.ExecuteSqlTranBool(ht))
|
|
{
|
|
code = 1;
|
|
msg = "操作成功";
|
|
}
|
|
else
|
|
{
|
|
code = 0;
|
|
msg = "操作失败";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "不同科目评分标准操作请求", "修改异常:" + e);
|
|
}
|
|
returnstr = "{\"msg\":\"" + msg + "\",\"code\":" + code + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Update, "不同科目评分标准操作请求", "修改");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//删除
|
|
private string DelTSubjectGradeStandard(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
try
|
|
{
|
|
string id = context.Request.Params["id"];
|
|
if (bll.Delete(id))
|
|
{
|
|
msg = "删除成功!";
|
|
code = 1;
|
|
}
|
|
else
|
|
{
|
|
msg = "删除失败!";
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
msg = e.Message;
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "不同科目评分标准操作请求", "删除异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\"}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Delete, "不同科目评分标准操作请求", "删除");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//查询大类
|
|
private string GetSubject(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string org_id = context.Request.Params["org_id"];
|
|
returnstr = "{\"code\":1,\"成功\":\"error\",\"count\":0,\"data\":";
|
|
string whereStr = " ORG_ID ='" + org_id + "'";
|
|
DataTable dt = sub_bll.GetList(whereStr).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);
|
|
}
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "不同科目评分标准操作请求", "查询大类");
|
|
return returnstr;
|
|
}
|
|
|
|
//根据科目获取标准
|
|
private string GetStandardList(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
int code = -1;
|
|
string msg = "";
|
|
int count = 0;
|
|
string data = "";
|
|
try
|
|
{
|
|
string subjectid = context.Request.Params["subjectid"];
|
|
string gender = context.Request.Params["gender"];
|
|
string where = " SUBJECTID = '" + subjectid + "' and GENDER='" + gender + "' order by (ACHIEVEMENT1) desc, (AGE1) asc ";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
code = 0;
|
|
msg = "无数据";
|
|
data = "[]";
|
|
}
|
|
else
|
|
{
|
|
code = 1;
|
|
msg = "获取数据成功";
|
|
DataTable dt = bll.GetList(where).Tables[0];
|
|
data = FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
code = -1;
|
|
msg = e.Message;
|
|
data = "[]";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "不同科目评分标准操作请求", "根据科目获取标准异常:" + e);
|
|
}
|
|
returnstr = "{\"code\":" + code + ",\"msg\":\"" + msg + "\",\"count\":" + count + ",\"data\":" + data + "}";
|
|
// 记录操作日志
|
|
BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "不同科目评分标准操作请求", "根据科目获取标准");
|
|
return returnstr;
|
|
}
|
|
|
|
|
|
//根据科目获取标准(根据科目单位,排序)
|
|
private string GetStandardList2(HttpContext context)
|
|
{
|
|
string returnstr = "";
|
|
try
|
|
{
|
|
string subjectid = context.Request.Params["subjectid"];
|
|
string company = context.Request.Params["company"];
|
|
string where = " SUBJECTID = '" + subjectid + "'";
|
|
|
|
returnstr = "{\"code\":0,\"msg\":\"\",";
|
|
int count = bll.GetRecordCount(where);
|
|
returnstr += "\"count\":" + count + ",\"data\":";
|
|
if (count == 0)
|
|
{
|
|
returnstr += "[]";
|
|
}
|
|
else
|
|
{
|
|
if (company == "0")
|
|
{
|
|
where += " order by (GENDER) ,(AGE1) desc ,(STASYS1)";
|
|
}
|
|
else if (company == "1")
|
|
{
|
|
where += " order by (GENDER) ,(AGE1) desc ,(STASYS1) desc";
|
|
}
|
|
|
|
DataTable dt = bll.GetList(where).Tables[0];
|
|
returnstr += FangYar.Common.JsonHelper.ToJson(dt);
|
|
}
|
|
returnstr += "}";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
returnstr = "{\"code\":-1,\"" + e.Message + "\":\"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;
|
|
}
|
|
}
|
|
}
|
|
}
|