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 Spire.Doc; using Spire.Doc.Documents; using Spire.Doc.Fields; using System.IO; using System.Drawing; using FangYar.Common; namespace FangYar.WebUI.ashx { /// /// OaToleranceHandler 的摘要说明 /// public class OaToleranceHandler : IHttpHandler { private FangYar.BLL.OA.OA_TOLERANCE bll = new FangYar.BLL.OA.OA_TOLERANCE(); 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 "getTolerance": returnstr = getTolerance(context); break; case "toleranceSta2": returnstr = toleranceSta2(context); break; case "ListByOrg": returnstr = ListByOrg(context); break; case "toleranceTypeSta": returnstr = toleranceTypeSta(context); break; case "toleranceTypeList": returnstr = toleranceTypeList(context); break; case "htmlToWord": returnstr = htmlToWord(context); break; case "AppGetToleranceSta": returnstr = AppGetToleranceSta(context); break; case "AppGetToleranceStaList": returnstr = AppGetToleranceStaList(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 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 getTolerance(HttpContext context) { string returnstr = ""; try { string toleranceId = context.Request.Params["toleranceId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"toleranceData\":"; List data = bll.getTolerance(toleranceId); 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,\"toleranceData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "公差操作请求", "获取公差信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "公差操作请求", "获取公差信息、流转记录"); return returnstr; } //查询 private string ListByOrg(HttpContext context) { string returnstr = ""; try { string OrgId = context.Request.Params["orgId"]; string keyword = context.Request.Params["keywords"]; string type = context.Request.Params["type"]; string beginDate = context.Request.Params["startTime"]; string endDate = context.Request.Params["endTime"]; string page = context.Request.Params["page"]; string limit = context.Request.Params["limit"]; string bclass = context.Request.Params["class"]; 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 = ""; pOrgID = OrgId; if (is_content == "1") { where += " and find_in_set(org_id, cids) "; } else { where += " and ORG_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 (PPL_NAME like '%" + keyword + "%' or TITLE like '%" + keyword + "%' or L_OUT like '%" + keyword + "' or L_REASON like '%" + keyword + "%') "; } if (!string.IsNullOrEmpty(beginDate)) { where += " and ((STR_TO_DATE('" + beginDate + "','%Y-%m-%d')<=STR_TO_DATE(S_TIME,'%Y-%m-%d') "; where += " and STR_TO_DATE('" + endDate + "','%Y-%m-%d')>=STR_TO_DATE(S_TIME,'%Y-%m-%d') ) or"; where += " (STR_TO_DATE('" + beginDate + "','%Y-%m-%d')<=STR_TO_DATE(E_TIME,'%Y-%m-%d') "; where += " and STR_TO_DATE('" + endDate + "','%Y-%m-%d')>=STR_TO_DATE(E_TIME,'%Y-%m-%d') )) "; } returnstr = "{\"code\":0,\"msg\":\"\","; int count = bll.GetRecordCount(where, pOrgID); returnstr += "\"count\":" + count + ",\"data\":"; if (count == 0) { returnstr += "[]"; } else { List 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 toleranceSta2(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 list = bll.toleranceSta2(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; } #region 公差统计 WR 2021-09-11 /// /// 公差统计 /// /// /// private string toleranceTypeSta(HttpContext context) { JsonRetMo> retMo = new JsonRetMo>() { code = "1", data = new List(), msg = "" }; 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)) { var list = QueryToleranceList(ORG_ID, USERS_UID, S_Time, E_Time, is_content); var list1 = list.GroupBy(p => p.PPL_ID).ToList(); foreach (var item in list1) { retMo.data.Add(new { PPL_NAME = item.First().PPL_NAME, PPL_ID = item.Key, toleranCount = item.Count() }); } } } catch (Exception ex) { retMo.code = "0"; retMo.msg = "异常:" + ex; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "公差操作请求", "公差统计异常:" + ex); } string returnstr = FangYar.Common.JsonHelper.ToJSON1(retMo); // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "公差操作请求", "公差统计"); return returnstr; } /// /// 公差列表 /// /// /// private string toleranceTypeList(HttpContext context) { JsonRetMo> retMo = new JsonRetMo>() { code = "1", data = new List(), msg = "" }; 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)) { var list = QueryToleranceList(ORG_ID, USERS_UID, S_Time, E_Time, is_content); retMo.data = list; } } catch (Exception ex) { retMo.code = "0"; retMo.msg = "异常:" + ex; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "公差操作请求", "公差列表异常:" + ex); } string returnstr = FangYar.Common.JsonHelper.ToJSON1(retMo); // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "公差操作请求", "公差列表"); return returnstr; } /// /// 查询公差数据详情 /// /// /// /// /// /// private List QueryToleranceList(string ORG_ID, string USERS_UID, string S_Time, string E_Time, string is_content) { //查询所有出公差信息 string sqlToler = @"SELECT (SELECT d.title FROM DICTIONARY d WHERE d.id = t.L_TYPE) DIC_TEXT,t.* from OA_TOLERANCE t WHERE date_format ( t.S_TIME, '%Y-%m-%d %H:%i:%s' ) >= date_format ( '" + S_Time + @" 0:0:0', '%Y-%m-%d %H:%i:%s' ) and date_format ( t.E_TIME, '%Y-%m-%d %H:%i:%s' ) <= date_format ( '" + E_Time + @" 23:59:59', '%Y-%m-%d %H:%i:%s' ) and t.PPL_ID in (SELECT USERS_UID from TBL_SYS_EMP where IS_ADMIN='0' and ORG_ID in (SELECT ORG_ID FROM FIRE_ORG ,(select get_Org_child_list('" + ORG_ID + "') cids ) s where find_in_set(org_id,cids))) "; if (string.IsNullOrEmpty(is_content)) { sqlToler = @"SELECT (SELECT d.title FROM DICTIONARY d WHERE d.id = t.L_TYPE) DIC_TEXT,t.* from OA_TOLERANCE t WHERE date_format ( t.S_TIME, '%Y-%m-%d %H:%i:%s' ) >= date_format ( '" + S_Time + @" 0:0:0', '%Y-%m-%d %H:%i:%s' ) and date_format ( t.E_TIME, '%Y-%m-%d %H:%i:%s' ) <= date_format ( '" + E_Time + @" 23:59:59', '%Y-%m-%d %H:%i:%s' ) and t.PPL_ID in (SELECT USERS_UID from TBL_SYS_EMP where IS_ADMIN='0' and ORG_ID = '"+ ORG_ID + "') "; } //查询公差信息 DataTable dtToler = FangYar.Common.MySqlHelper.QueryTable(sqlToler); var listToler = dtToler.ToDynamicList(); if (!string.IsNullOrWhiteSpace(USERS_UID)) { listToler = listToler.Where(p => p.PPL_ID == USERS_UID).ToList(); } List retList = new List(); foreach (var item in listToler) { retList.Add(new { ID = item.ID + "", PPL_ID = item.PPL_ID + "", PPL_NAME = item.PPL_NAME + "", L_TYPE = item.L_TYPE + "", S_TIME = item.S_TIME + "", E_TIME = item.E_TIME + "", L_OUT = item.L_OUT + "", ACC_PPL = item.ACC_PPL + "", REP_PPL = item.REP_PPL + "", L_REASON = item.L_REASON + "", PHOTO = item.PHOTO + "", STATE = item.STATE + "", L_NUM = item.L_NUM + "", TITLE = item.TITLE + "", EXTENDCODE1 = item.EXTENDCODE1 + "", EXTENDCODE2 = item.EXTENDCODE2 + "", EXTENDCODE3 = item.EXTENDCODE3 + "", EXTENDCODE4 = item.EXTENDCODE4 + "", CAR_NUM = item.CAR_NUM + "", IS_RETURN = item.IS_RETURN + "", DIC_TEXT = item.DIC_TEXT + "" }); } return retList; } /// /// 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"]; string is_content = context.Request.Params["is_content"]; //实例化一个Document对象 Document doc = new Document(); doc.Watermark = null; //添加section和段落 Section section1 = doc.AddSection(); Paragraph para1 = section1.AddParagraph(); #region 获取table数据 String[] headerQiandi1 = { "姓名", "总数" }; //表头字段 var list = QueryToleranceList(Org_Id, USERS_UID, S_Time, E_Time, is_content); //汇总统计 List listCount = new List(); var list1 = list.GroupBy(p => p.PPL_ID).ToList(); foreach (var item in list1) { listCount.Add(new { PPL_NAME = item.First().PPL_NAME, PPL_ID = item.Key, toleranCount = item.Count() }); } listCount.Add(new { PPL_NAME = "合计", PPL_ID = "", toleranCount = listCount.Sum(s => s.toleranCount) }); if (listCount.Count > 0) { #region 创建Word表格 Table tableQiandi1 = section1.AddTable(); //新建表格 tableQiandi1.ResetCells(listCount.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 < listCount.Count; r++) //生成表体 { TableRow dataRow = tableQiandi1.Rows[r + 1]; dataRow.RowFormat.BackColor = Color.Empty; for (int c = 0; c < headerQiandi1.Length; c++) { //"姓名", "总数" string strVal = ""; switch (headerQiandi1[c]) { case "姓名": strVal = listCount[r].PPL_NAME + ""; break; case "总数": strVal = listCount[r].toleranCount + ""; break; } dataRow.Cells[c].Width = 145; dataRow.Height = 20; dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle; TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(strVal); tr.CharacterFormat.FontSize = 12; } } #endregion 创建Word表格 } //添加section和段落 Section section2 = doc.AddSection(); Paragraph para2 = section2.AddParagraph(); //列表 String[] headerQiandi2 = { "申请人", "出差类型", "开始时间", "结束时间", "去向", "随行人", "顶班人", "出差事由" }; //表头字段 #endregion 获取table数据 if (list.Count > 0) { #region 创建Word表格 Table tableQiandi2 = section2.AddTable(); //新建表格 tableQiandi2.ResetCells(list.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 < list.Count; r++) //生成表体 { TableRow dataRow = tableQiandi2.Rows[r + 1]; dataRow.RowFormat.BackColor = Color.Empty; for (int c = 0; c < headerQiandi2.Length; c++) { //"申请人", "出差类型", "开始时间", "结束时间", "去向", "随行人", "顶班人", "出差事由" string strVal = ""; switch (headerQiandi2[c]) { case "申请人": strVal = list[r].PPL_NAME + ""; break; case "出差类型": strVal = list[r].DIC_TEXT + ""; break; case "开始时间": strVal = list[r].S_TIME + ""; break; case "结束时间": strVal = list[r].E_TIME + ""; break; case "去向": strVal = list[r].L_OUT + ""; break; case "随行人": strVal = list[r].ACC_PPL + ""; break; case "顶班人": strVal = list[r].REP_PPL + ""; break; case "出差事由": strVal = list[r].L_REASON + ""; break; } dataRow.Cells[c].Width = 145; dataRow.Height = 20; dataRow.Cells[c].CellFormat.VerticalAlignment = VerticalAlignment.Middle; TextRange tr = dataRow.Cells[c].AddParagraph().AppendText(strVal); 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 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; } #endregion /// /// 公差统计 /// /// /// private string AppGetToleranceSta(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 string sql = ""; returnstr = "{\"code\":0,\"msg\":\"\""; sql += " with t1 as( "; sql += " SELECT o.L_TYPE,e.ORG_ID,o.S_TIME,o.E_TIME from OA_TOLERANCE o LEFT JOIN tbl_sys_emp e on e.IS_ADMIN='0' and o.ppl_id = e.users_uid "; sql += " WHERE date_format('" + stime + "', '%Y-%m-%d %H:%i:%s') <= date_format(o.S_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " and date_format('" + etime + "', '%Y-%m-%d %H:%i:%s') >= date_format(o.E_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " ),t2 as( "; sql += " SELECT ORG_ID,sum(case L_TYPE when 'ee62a186-336f-4984-b650-fd9826ad82cd' then 1 else 0 end) incar "; sql += " ,sum(case L_TYPE when '33a0821a-c264-44be-8da3-70a4077e933e' then 1 else 0 end) innocar "; sql += " ,sum(case L_TYPE when '6bba0521-37e7-4c30-9bcd-971815ac6168' then 1 else 0 end) outcar "; sql += " ,sum(case L_TYPE when '48137282-3373-4da0-836f-fd223849a85f' then 1 else 0 end) outnocar "; sql += " from t1 GROUP BY ORG_ID),t4 as( "; if (islower == "1") { sql += " SELECT * from fire_org,(select get_Org_child_list('" + org_id + "') cids ) s WHERE find_in_set(org_id,cids) and type = '0' "; } else if (islower == "0") { sql += "SELECT * from fire_org WHERE ORG_ID='" + org_id + "' "; } sql += " )SELECT t4.ORG_ID,t4.ORG_NAME,IFNULL(t2.INCAR,0) INCAR,IFNULL(t2.INNOCAR,0) INNOCAR,IFNULL(t2.OUTCAR,0) OUTCAR,IFNULL(t2.OUTNOCAR,0) OUTNOCAR from t4 LEFT JOIN t2 on t4.ORG_ID=t2.ORG_ID "; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "公差操作请求", "公差统计异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "公差操作请求", "公差统计"); return returnstr; } /// /// 公差统计列表 /// /// /// private string AppGetToleranceStaList(HttpContext context) { string returnstr = ""; try { string org_id = context.Request.Params["org_id"];//机构id string ppl_name = context.Request.Params["ppl_name"];//ppl_name string l_type = context.Request.Params["l_type"];//l_type string stime = context.Request.Params["stime"];//stime string etime = context.Request.Params["etime"];//etime string islower = context.Request.Params["islower"];//islower 0 本级 1多级 string page = context.Request.Params["page"];//page string limit = context.Request.Params["limit"];//limit int.TryParse(page, out int pageIndex); pageIndex = pageIndex < 1 ? 1 : pageIndex; int.TryParse(limit, out int pageSize); pageSize = pageSize < 1 ? 1 : pageSize; int satrtNum = (pageIndex - 1) * pageSize; string sql = ""; returnstr = "{\"code\":0,\"msg\":\"\""; sql += " select a.* ,b.org_name from ( "; sql += " select t.*,e.org_id , d.title as dtitle from OA_TOLERANCE t left"; sql += " join tbl_sys_emp e on e.IS_ADMIN='0' and t.ppl_id = e.users_uid left join dictionary d on t.l_type = d.id"; sql += " where 1 = 1"; if (!string.IsNullOrEmpty(ppl_name)) { sql += " and ppl_name like '%" + ppl_name + "%'"; } if (!string.IsNullOrEmpty(l_type)) { sql += " and l_type = '" + l_type + "'"; } sql += " and date_format('" + stime + "', '%Y-%m-%d %H:%i:%s') <= date_format(t.S_TIME, '%Y-%m-%d %H:%i:%s') "; sql += " and date_format('" + etime + "', '%Y-%m-%d %H:%i:%s') >= date_format(t.E_TIME, '%Y-%m-%d %H:%i:%s')"; sql += " )a left join fire_org b on a.org_id = b.org_id "; sql += " where "; if (islower == "1") { sql += " a.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) )"; } else if (islower == "0") { sql += " a.org_id ='" + org_id + "'"; } sql += " LIMIT " + satrtNum + ", " + pageSize; returnstr += ",\"Data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(new CommomBLL().GetTableList(sql)); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "公差操作请求", "公差统计列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "公差操作请求", "公差统计列表"); return returnstr; } public bool IsReusable { get { return false; } } } }