99cbdf1ad8df05b2609f310b5f3495e459af715d.svn-base 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. package com.sinosoft.lz.system.menu.dao;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.text.SimpleDateFormat;
  7. import java.util.ArrayList;
  8. import java.util.Date;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. import org.apache.log4j.Logger;
  13. import com.persistence.DbConnection;
  14. import com.sinosoft.lz.system.menu.vo.Module;
  15. public class SysModuleDao {
  16. private final static Logger log = Logger.getLogger(SysModuleDao.class);
  17. public List<Module> getModuleByUserId(String user_id) {
  18. StringBuffer sql = new StringBuffer();
  19. //sql.append(" select FD_OBJECTID,USER_ID,UL_ID,UPDATEDATE,IS_DEL,LI_ID,MODULE_FUN,SORT,TITLE_NAME from SYS_INDEX_MODULE where IS_DEL = '0' ");
  20. sql.append(" select distinct m.*,a.sort from SYS_INDEX_MODULE a,SYS_MODULE m where a.LI_ID = m.SYS_LI_ID and a.is_del = '0' ");
  21. sql.append(" and a.USER_ID = ? ");
  22. //sql.append("'"+user_id+"'");
  23. sql.append(" ORDER BY a.SORT ASC ");
  24. DbConnection dbConn = new DbConnection();
  25. Connection conn = null;
  26. PreparedStatement pstm = null;
  27. ResultSet rs = null;
  28. List<Module> menuList = new ArrayList<Module>();
  29. try{
  30. conn = dbConn.getConnection();
  31. pstm = conn.prepareStatement(sql.toString());
  32. pstm.setString(1,user_id);
  33. rs = pstm.executeQuery();
  34. while(rs.next()){
  35. Module module = new Module();
  36. module.setFd_objectid(rs.getString("FD_OBJECTID"));
  37. //module.setUser_id(rs.getString("USER_ID"));
  38. module.setUl_id(rs.getString("SYS_UL_ID"));
  39. module.setLi_id(rs.getString("SYS_LI_ID"));
  40. module.setUpdatedate(rs.getString("UPDATEDATE"));
  41. module.setSort(rs.getString("SORT"));
  42. module.setModule_fun(rs.getString("SYS_MODULE_FUN"));
  43. module.setIs_del(rs.getString("IS_DEL"));
  44. module.setTitle(rs.getString("SYS_TITLE_NAME"));
  45. module.setModule_url(rs.getString("MODULE_URL"));
  46. menuList.add(module);
  47. }
  48. }catch(Exception e){
  49. log.error("查询菜单错误"+e.getMessage());
  50. }finally{
  51. try {
  52. rs.close();
  53. pstm.close();
  54. conn.close();
  55. } catch (SQLException e) {
  56. log.error("关闭数据库连接错误:"+e.getMessage());
  57. }
  58. }
  59. return menuList;
  60. }
  61. public String addModuleByUserId(Module module) {
  62. String result = "error";
  63. String sql = "INSERT INTO SYS_INDEX_MODULE (FD_OBJECTID,USER_ID,UPDATEDATE,IS_DEL,LI_ID,SORT) VALUES(?, ?, ?, ?, ?, ?)";
  64. DbConnection dbConn = new DbConnection();
  65. Connection conn = null;
  66. PreparedStatement pstm = null;
  67. try {
  68. conn = dbConn.getConnection();
  69. pstm = conn.prepareStatement(sql);
  70. //设置参数值
  71. pstm.setString(1, module.getFd_objectid());
  72. pstm.setString(2, module.getUser_id());
  73. pstm.setString(3, module.getUpdatedate());
  74. pstm.setString(4, module.getIs_del());
  75. pstm.setString(5, module.getLi_id());
  76. pstm.setString(6, module.getSort());
  77. int rs = pstm.executeUpdate();
  78. if(rs==1){
  79. result = "insert";
  80. }
  81. } catch (ClassNotFoundException e) {
  82. // TODO Auto-generated catch block
  83. e.printStackTrace();
  84. } catch (SQLException e) {
  85. // TODO Auto-generated catch block
  86. e.printStackTrace();
  87. }finally{
  88. try {
  89. pstm.close();
  90. conn.close();
  91. } catch (SQLException e) {
  92. // TODO Auto-generated catch block
  93. log.error("关闭数据库连接错误:"+e.getMessage());
  94. }
  95. }
  96. return result;
  97. }
  98. public int checkAddModule(String user_id, String li_id,String sort,String is_del) {
  99. int result = 0;
  100. String sql = "update SYS_INDEX_MODULE set IS_DEL=?,UPDATEDATE=?, SORT=? where USER_ID=? and LI_ID=?";
  101. DbConnection dbConn = new DbConnection();
  102. Connection conn = null;
  103. PreparedStatement pstm = null;
  104. try {
  105. conn = dbConn.getConnection();
  106. pstm = conn.prepareStatement(sql);
  107. //设置参数值
  108. Date date = new Date();
  109. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  110. pstm.setString(1, is_del);
  111. pstm.setString(2, sdf.format(date));
  112. pstm.setString(3, sort);
  113. pstm.setString(4, user_id);
  114. pstm.setString(5, li_id);
  115. result = pstm.executeUpdate();
  116. } catch (ClassNotFoundException e) {
  117. // TODO Auto-generated catch block
  118. e.printStackTrace();
  119. } catch (SQLException e) {
  120. // TODO Auto-generated catch block
  121. e.printStackTrace();
  122. }finally{
  123. try {
  124. pstm.close();
  125. conn.close();
  126. } catch (SQLException e) {
  127. // TODO Auto-generated catch block
  128. log.error("关闭数据库连接错误:"+e.getMessage());
  129. }
  130. }
  131. return result;
  132. }
  133. public List<Module> getAllModule(String user_id, String parent_menu,String corp_id) {
  134. StringBuffer sql = new StringBuffer();
  135. //sql.append("select FD_OBJECTID,SYS_TITLE_NAME,UPDATEDATE,IMG_URL,SYS_LI_ID,PARENT_MENU from SYS_MODULE where IS_DEL = '0' ");
  136. sql.append(" select distinct a.FD_OBJECTID,a.SYS_TITLE_NAME,a.UPDATEDATE,a.IMG_URL,a.SYS_LI_ID,a.PARENT_MENU ,a.MODULE_DEPT_LEVEL ");
  137. sql.append(" from SYS_MODULE a left join SYS_DEPARTMENT d on d.CORP_ID = ? ");
  138. sql.append(" where a.IS_DEL = '0' AND ( a.MODULE_DEPT_LEVEL = d.DEPT_LEVEL OR a.MODULE_DEPT_LEVEL IS NULL) ");
  139. if(parent_menu!=null&&!"".equals(parent_menu)){
  140. sql.append(" and a.PARENT_MENU like ? ");
  141. //sql.append("'%"+parent_menu+"%'");
  142. }
  143. //sql.append(" ORDER BY SORT DESC ");
  144. DbConnection dbConn = new DbConnection();
  145. Connection conn = null;
  146. PreparedStatement pstm = null;
  147. ResultSet rs = null;
  148. List<Module> menuList = new ArrayList<Module>();
  149. try{
  150. conn = dbConn.getConnection();
  151. pstm = conn.prepareStatement(sql.toString());
  152. pstm.setString(1, corp_id);
  153. if(parent_menu!=null&&!"".equals(parent_menu)){
  154. pstm.setString(2, "%"+parent_menu+"%");
  155. }
  156. rs = pstm.executeQuery();
  157. while(rs.next()){
  158. Module module = new Module();
  159. module.setFd_objectid(rs.getString("FD_OBJECTID"));
  160. module.setLi_id(rs.getString("SYS_LI_ID"));
  161. module.setUpdatedate(rs.getString("UPDATEDATE"));
  162. module.setImg_url(rs.getString("IMG_URL"));
  163. module.setTitle(rs.getString("SYS_TITLE_NAME"));
  164. module.setParent_menu(rs.getString("PARENT_MENU"));
  165. menuList.add(module);
  166. }
  167. }catch(Exception e){
  168. log.error("查询菜单错误"+e.getMessage());
  169. }finally{
  170. try {
  171. rs.close();
  172. pstm.close();
  173. conn.close();
  174. } catch (SQLException e) {
  175. log.error("关闭数据库连接错误:"+e.getMessage());
  176. }
  177. }
  178. return menuList;
  179. }
  180. public int delectModult(String user_id, String li_id) {
  181. int result = 0;
  182. String sql = "update SYS_INDEX_MODULE set IS_DEL='1' where USER_ID=? and LI_ID=?";
  183. DbConnection dbConn = new DbConnection();
  184. Connection conn = null;
  185. PreparedStatement pstm = null;
  186. try {
  187. conn = dbConn.getConnection();
  188. pstm = conn.prepareStatement(sql);
  189. //设置参数值
  190. pstm.setString(1, user_id);
  191. pstm.setString(2, li_id);
  192. result = pstm.executeUpdate();
  193. } catch (ClassNotFoundException e) {
  194. // TODO Auto-generated catch block
  195. e.printStackTrace();
  196. } catch (SQLException e) {
  197. // TODO Auto-generated catch block
  198. e.printStackTrace();
  199. }finally{
  200. try {
  201. pstm.close();
  202. conn.close();
  203. } catch (SQLException e) {
  204. // TODO Auto-generated catch block
  205. log.error("关闭数据库连接错误:"+e.getMessage());
  206. }
  207. }
  208. return result;
  209. }
  210. public List<Module> getSearchModule(String user_id, String moduleName,String corp_id) {
  211. StringBuffer sql = new StringBuffer();
  212. sql.append(" select distinct a.FD_OBJECTID,a.SYS_TITLE_NAME,a.UPDATEDATE,a.IMG_URL,a.SYS_LI_ID,a.PARENT_MENU ,a.MODULE_DEPT_LEVEL ");
  213. sql.append(" from SYS_MODULE a left join SYS_DEPARTMENT d on d.CORP_ID = ? ");
  214. sql.append(" where a.IS_DEL = '0' AND ( a.MODULE_DEPT_LEVEL = d.DEPT_LEVEL OR a.MODULE_DEPT_LEVEL IS NULL) ");
  215. if(moduleName!=null&&!"".equals(moduleName)){
  216. sql.append(" and a.SYS_TITLE_NAME like ? ");
  217. //sql.append("'%"+moduleName+"%'");
  218. }
  219. //sql.append(" ORDER BY SORT DESC ");
  220. DbConnection dbConn = new DbConnection();
  221. Connection conn = null;
  222. PreparedStatement pstm = null;
  223. ResultSet rs = null;
  224. List<Module> menuList = new ArrayList<Module>();
  225. try{
  226. conn = dbConn.getConnection();
  227. pstm = conn.prepareStatement(sql.toString());
  228. pstm.setString(1, corp_id);
  229. if(moduleName!=null&&!"".equals(moduleName)){
  230. pstm.setString(2, "%"+moduleName+"%");
  231. }
  232. rs = pstm.executeQuery();
  233. while(rs.next()){
  234. Module module = new Module();
  235. module.setFd_objectid(rs.getString("FD_OBJECTID"));
  236. module.setLi_id(rs.getString("SYS_LI_ID"));
  237. module.setUpdatedate(rs.getString("UPDATEDATE"));
  238. module.setIs_del(rs.getString("IS_DEL"));
  239. module.setImg_url(rs.getString("IMG_URL"));
  240. module.setTitle(rs.getString("SYS_TITLE_NAME"));
  241. module.setParent_menu(rs.getString("PARENT_MENU"));
  242. menuList.add(module);
  243. }
  244. }catch(Exception e){
  245. log.error("查询菜单错误"+e.getMessage());
  246. }finally{
  247. try {
  248. rs.close();
  249. pstm.close();
  250. conn.close();
  251. } catch (SQLException e) {
  252. log.error("关闭数据库连接错误:"+e.getMessage());
  253. }
  254. }
  255. return menuList;
  256. }
  257. /***************以上是模块的数据操作*********************************/
  258. /***************以下是个别模块里面的内容******************************/
  259. public List<Map<String, String>> queryURLData(String user_id,String com_id) {
  260. StringBuffer sql = new StringBuffer();
  261. sql.append("select TOP 0 , 5 FD_OBJECTID,TM_NAME,TM_URL from ECM_CM_THEMATIC where IS_DEL = '0' and TM_AREAID='0006' and IS_EXTERNAL='0' and TM_USE = '1' and ( SC_DEPT_ID = ? or SC_DEPT_ID = '' or SC_DEPT_ID is null ) ");
  262. //sql.append(" and USER_ID = ");
  263. //sql.append("'"+user_id+"'");
  264. sql.append(" ORDER BY UPDATEDATE DESC ");
  265. log.info("===集成URL=====sql===="+sql);
  266. DbConnection dbConn = new DbConnection();
  267. Connection conn = null;
  268. PreparedStatement pstm = null;
  269. ResultSet rs = null;
  270. List<Map<String, String>> menuList = new ArrayList<Map<String, String>>();
  271. try{
  272. conn = dbConn.getConnection();
  273. pstm = conn.prepareStatement(sql.toString());
  274. pstm.setString(1, com_id);
  275. rs = pstm.executeQuery();
  276. while(rs.next()){
  277. Map<String, String> map = new HashMap<String, String>();
  278. map.put("url_name", rs.getString("TM_NAME"));
  279. map.put("url_url", rs.getString("TM_URL"));
  280. menuList.add(map);
  281. }
  282. }catch(Exception e){
  283. log.error("查询菜单错误"+e.getMessage());
  284. }finally{
  285. try {
  286. rs.close();
  287. pstm.close();
  288. conn.close();
  289. } catch (SQLException e) {
  290. log.error("关闭数据库连接错误:"+e.getMessage());
  291. }
  292. }
  293. return menuList;
  294. }
  295. public List<Map<String, String>> queryGongGaoData(String deptIds,String deptNames) {
  296. StringBuffer sql = new StringBuffer();
  297. //sql.append("select TOP 0 , 1 * from SYS_NOTICE where NOTICE_AREA LIKE ? AND NOTICE_AREA_NAME LIKE ? ");
  298. sql.append("select TOP 0 , 1 * from SYS_NOTICE where NOTICE_AREA LIKE ? ");
  299. sql.append(" ORDER BY UPDATEDATE DESC ");
  300. DbConnection dbConn = new DbConnection();
  301. Connection conn = null;
  302. PreparedStatement pstm = null;
  303. ResultSet rs = null;
  304. List<Map<String, String>> menuList = new ArrayList<Map<String, String>>();
  305. try{
  306. conn = dbConn.getConnection();
  307. pstm = conn.prepareStatement(sql.toString());
  308. pstm.setString(1, "%"+deptIds+",%");
  309. //pstm.setString(2, "%"+deptNames+"%");
  310. rs = pstm.executeQuery();
  311. while(rs.next()){
  312. Map<String, String> map = new HashMap<String, String>();
  313. map.put("FD_OBJECTID", rs.getString("FD_OBJECTID"));
  314. map.put("TITLE", rs.getString("TITLE"));
  315. map.put("SUBTIME", rs.getString("SUBTIME"));
  316. map.put("CONTENT", rs.getString("CONTENT"));
  317. map.put("DEPT_NAME", rs.getString("DEPT_NAME"));
  318. map.put("PERSON", rs.getString("PERSON"));
  319. menuList.add(map);
  320. }
  321. }catch(Exception e){
  322. log.error("查询首页公告错误"+e.getMessage());
  323. }finally{
  324. try {
  325. rs.close();
  326. pstm.close();
  327. conn.close();
  328. } catch (SQLException e) {
  329. log.error("关闭数据库连接错误:"+e.getMessage());
  330. }
  331. }
  332. return menuList;
  333. }
  334. public List<Map<String, String>> queryAccessoryData(String mainId) {
  335. StringBuffer sql = new StringBuffer();
  336. sql.append("select top 5 fd_objectid, name,filepath,fileext,savename,updatedate,UPLOADTIME from Sys_Comm_FileImg where is_del = '0' and MAINID = '"+mainId+"' order by updatedate desc");
  337. DbConnection dbConn = new DbConnection();
  338. Connection conn = null;
  339. PreparedStatement pstm = null;
  340. ResultSet rs = null;
  341. List<Map<String, String>> menuList = new ArrayList<Map<String, String>>();
  342. try{
  343. conn = dbConn.getConnection();
  344. pstm = conn.prepareStatement(sql.toString());
  345. rs = pstm.executeQuery();
  346. while(rs.next()){
  347. Map<String, String> map = new HashMap<String, String>();
  348. map.put("fd_id", rs.getString("FD_OBJECTID"));
  349. map.put("name", rs.getString("NAME"));
  350. map.put("filepath", rs.getString("FILEPATH"));
  351. map.put("fileext", rs.getString("FILEEXT"));
  352. map.put("savename", rs.getString("SAVENAME"));
  353. map.put("uploadtime", rs.getString("UPLOADTIME"));
  354. menuList.add(map);
  355. }
  356. }catch(Exception e){
  357. log.error("查询首页附件信息错误"+e.getMessage());
  358. }finally{
  359. try {
  360. rs.close();
  361. pstm.close();
  362. conn.close();
  363. } catch (SQLException e) {
  364. log.error("关闭数据库连接错误:"+e.getMessage());
  365. }
  366. }
  367. return menuList;
  368. }
  369. }