package com.sinosoft.em.baobiao.xianlutingyun.service; import java.sql.SQLException; import java.util.List; import java.util.Map; import java.util.Set; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.ProduceMime; import net.sf.json.JSONArray; import org.apache.log4j.Logger; import com.formaction.Utils; import com.sinosoft.am.org.jdbcUtil.ORGTemplate; import com.sinosoft.lz.system.AppContext; @Path("/ExportExcelService/") public class ExportExcelServiceImpl implements ExportExcelService { private final Logger log = Logger.getLogger(getClass()); @POST @ProduceMime("application/json") @Path("/getReportClassId/") public String getReport(String params){ String report_type = Utils.getParameter("report_type", params)==null ?"": Utils.getParameter("report_type", params); String logname = Utils.getParameter("logname", params)==null ?"": Utils.getParameter("logname", params); String sql = "select REPORT_TYPE from bm_mapforreport where report_type = ?"; //Set userSet = AppContext.getInstance().getLoginUserMap().keySet(); /* if(userSet.contains(logname)){*/ List> list = null; try { list = new ORGTemplate().query(sql, report_type); } catch (SQLException e) { e.printStackTrace(); } log.info("getReport.list.size()"+list.size()); String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}"; log.info("getReport===" + result); return result; /*} return null;*/ } @POST @ProduceMime("application/json") @Path("/getColumn/") public String getColumn(String params){ String report_type = Utils.getParameter("report_type", params) ==null ? "" : Utils.getParameter("report_type", params) ; String dept_level = Utils.getParameter("dept_level", params) ==null ? "" : Utils.getParameter("dept_level", params) ; String role_id = Utils.getParameter("role_id", params) ==null ? "" : Utils.getParameter("role_id", params) ; //String logname = Utils.getParameter("logname", params) ==null ? "" : Utils.getParameter("logname", params) ; //Set userSet = AppContext.getInstance().getLoginUserMap().keySet(); /* if(userSet.contains(logname)){*/ String sql; if("R002105430210".equals(role_id) && Integer.valueOf(dept_level)>=3){ sql = "select table_column from EMC_AM_REPORT_DICTIONARY where report_type = ? and is_used = ? union select table_column from EMC_AM_REPORT_DICTIONARY where report_type = '"+report_type+"' and table_head in ('500KV线路','220KV线路')"; }else if("R002105430211".equals(role_id) && "5".equals(dept_level)){ sql = "select table_column from EMC_AM_REPORT_DICTIONARY where report_type = ? and is_used = ? union select table_column from EMC_AM_REPORT_DICTIONARY where report_type = '"+report_type+"' and table_head in ('500KV','220KV','110KV')"; }else{ sql = "select table_column from EMC_AM_REPORT_DICTIONARY where report_type= ? and is_used= ?"; } List> list = null; try { list = new ORGTemplate().query(sql, report_type,"1"); } catch (SQLException e) { e.printStackTrace(); } log.info("getColumn.list.size()"+list.size()); String result = "{\"rows\":" + JSONArray.fromObject(list).toString() + "}"; log.info("getColumn===" + result); return result; /* } return null;*/ } }