public ActionResult GetListJson(Pagination pagination, string queryJson) { string orgcode = OperatorProvider.Provider.Current().OrganizeCode; var watch = CommonHelper.TimerStart(); pagination.p_kid = "ID"; pagination.p_fields = "NO,info.createuserid,info.createuserdeptcode,info.createuserorgcode,info.NAME,TYPE,ORGNAME,DEPTNAME,POSTNAME,SHOULDNUM,UNIT,TIMENUM,TIMETYPE,RECENTTIME,NEXTTIME,ISSUENUM,'' InStock,yj.value"; pagination.p_tablename = "BIS_LABORINFO info left join (select name,value from bis_laboreamyj where createuserorgcode='" + orgcode + "') yj on info.name=yj.name"; pagination.conditionJson = " 1=1"; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); if (user.IsSystem) { pagination.conditionJson = "1=1"; } else { if (laborinfobll.GetPer()) { pagination.conditionJson += " and CREATEUSERORGCODE='" + user.OrganizeCode + "'"; } else { string where = new ERCHTMS.Busines.AuthorizeManage.AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value); pagination.conditionJson += " and " + where; } } var data = laborinfobll.GetPageList(pagination, queryJson); DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL(); var datadetail = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'"); for (int i = 0; i < data.Rows.Count; i++) { DataItemModel dm = datadetail.Where(it => it.ItemName == data.Rows[i]["NAME"].ToString()).FirstOrDefault(); if (dm != null) { data.Rows[i]["InStock"] = dm.ItemValue.ToString(); } } var JsonData = new { rows = data, total = pagination.total, page = pagination.page, records = pagination.records, costtime = CommonHelper.TimerEnd(watch), }; return(Content(JsonData.ToJson())); }
/// <summary> /// 导出到Excel /// </summary> /// <param name="queryJson"></param> /// <returns></returns> public ActionResult Excel(string queryJson) { string wheresql = ""; Operator user = ERCHTMS.Code.OperatorProvider.Provider.Current(); if (user.IsSystem) { wheresql = "1=1"; } else { string where = new ERCHTMS.Busines.AuthorizeManage.AuthorizeBLL().GetModuleDataAuthority(ERCHTMS.Code.OperatorProvider.Provider.Current(), HttpContext.Request.Cookies["currentmoduleId"].Value); wheresql += " and " + where; } DataTable dt = laborinfobll.GetTable(queryJson, wheresql); DataItemDetailBLL dataItemDetailBLL = new DataItemDetailBLL(); var datadetail = dataItemDetailBLL.GetDataItemListByItemCode("'LaborName'"); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i][0] = i + 1; dt.Rows[i]["TimeType"] = dt.Rows[i]["TimeNum"].ToString() + dt.Rows[i]["TimeType"].ToString(); DataItemModel dm = datadetail.Where(it => it.ItemName == dt.Rows[i]["NAME"].ToString()).FirstOrDefault(); if (dm != null) { dt.Rows[i]["InStock"] = dm.ItemValue.ToString(); } else { dt.Rows[i]["InStock"] = ""; } } string FileUrl = @"\Resource\ExcelTemplate\劳动防护用品管理_导出.xls"; AsposeExcelHelper.ExecuteResult(dt, FileUrl, "劳动防护用品管理清单", "劳动防护用品管理列表"); return(Success("导出成功。")); }