123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- package com.sinosoft.cm.matic.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import com.sinosoft.cm.DBUtils;
- import com.sinosoft.cm.chart.dao.ChartDaoImpl;
- import com.sinosoft.cm.common.service.ChartDaoServiceImpl;
- import com.sinosoft.cm.common.vo.ResultState;
- import com.sinosoft.cm.vo.Result;
- public class MaticDaoImpl extends ChartDaoImpl {
- private Log log = LogFactory.getLog(ChartDaoServiceImpl.class);
- public MaticDaoImpl(){
- /**
- * 关联查询查询所有视图信息
- */
- map.put("getMatic", "SELECT A.TM_BEX SORT1, A.AREA_NAME AREA_NAME, B.FD_OBJECTID FD_OBJECTID,B.TM_NAME TM_NAME,B."
- + "TM_URL TM_URL,B.TM_IMGURL TM_IMGURL,B.TM_LAYERID TM_LAYERID,B.TM_USE TM_USE,"
- + "B.TM_AREAID TM_AREAID,B.IS_DEL IS_DEL, B.UPDATEDATE UPDATEDATE ,B.TM_BEX TM_BEX,"
- + "B.SC_DEPT_ID SC_DEPT_ID, B.IS_SYNTHESIZE "
- + " FROM ECM_CM_MATICMAP A LEFT JOIN ECM_CM_THEMATIC B "
- + " ON B.TM_USE=1 AND A.AREA_ID=B.TM_AREAID AND A.IS_USED='0' AND A.IS_DEL ='0' AND B.IS_DEL = '0'"
- + " AND (SC_DEPT_ID='' OR SC_DEPT_ID IS NULL OR SC_DEPT_ID=?) ORDER BY to_number(A.TM_BEX),B.TM_NAME;");
- /**
- * 模糊查询查询
- */
- map.put("getLikeMatic", "SELECT A.AREA_NAME AREA_NAME, B.FD_OBJECTID FD_OBJECTID,B.TM_NAME TM_NAME,B."
- + "TM_URL TM_URL,B.TM_IMGURL TM_IMGURL,B.TM_LAYERID TM_LAYERID,B.TM_USE TM_USE,"
- + "B.TM_AREAID TM_AREAID,B.IS_DEL IS_DEL, B.UPDATEDATE UPDATEDATE ,B.TM_BEX TM_BEX,"
- + "B.SC_DEPT_ID SC_DEPT_ID "
- + " FROM ECM_CM_MATICMAP A,ECM_CM_THEMATIC B "
- + " WHERE B.TM_USE=1 AND A.AREA_ID=B.TM_AREAID AND A.IS_USED='0' AND A.IS_DEL ='0' "
- + " AND (SC_DEPT_ID='' OR SC_DEPT_ID IS NULL OR SC_DEPT_ID=?) AND B.TM_NAME LIKE ? ORDER BY A.AREA_NAME,B.TM_NAME;");
- /**
- * 获取默认布局
- */
- map.put("getOftenDefaultLayoutAndView", "SELECT IS_COMMONUSE FROM ECM_CM_SYSLAYOUT WHERE (IS_COMMONUSE IS NOT NULL OR IS_COMMONUSE <> '') AND SL_USERID=? AND SCREEN_STATE=?;");
- /**
- * 查询布局视图
- */
- map.put("queryLayoutById", "select FD_OBJECTID,IS_DEL,SL_LAYOUTID,SL_NAME,SL_PARAMENT,TM_BEX,SL_USERID,SCREEN_STATE from ECM_CM_SYSLAYOUT where FD_OBJECTID=?");
- /**
- * 查询视图
- */
- this.map.put("queryViewByAreaId", "SELECT OL_CONID,OL_MATICID FROM ECM_CM_OPENLAYERMATIC WHERE OL_AREAID=?");
- /**
- * 查询布局列表
- * ? 屏幕状态
- * ? 用户ID
- */
- map.put("getLayout", "SELECT * FROM ECM_CM_SYSLAYOUT WHERE SCREEN_STATE=? AND (SL_USERID='R002105430214' OR SL_USERID=?) AND IS_DEL='0';");
-
- /**
- * 通过布局ID查询相关布局信息
- */
- map.put("getMaticView", "SELECT * FROM LAYOUT_MATIC_VIEW WHERE OL_AREAID=?;");
- /**
- * 获取默认布局
- */
- map.put("getDefaultLayout","SELECT * FROM ECM_CM_SYSLAYOUT WHERE TM_BEX='1'"
- + " AND SCREEN_STATE=? AND (SL_USERID=? OR SL_USERID='R002105430214')");
- /**
- * 获取默认布局的信息
- */
- map.put("getDefaultLayoutView","SELECT * FROM LAYOUT_MATIC_VIEW WHERE OL_AREAID =?;");
- /**
- * 保存默认的自定义样式
- * ?主键id
- * ?样式名称
- * ?样式
- *
- */
- map.put("saveDefalutStyle","insert into ECM_CM_USER_SELF_STYLE"
- + "(FD_OBJECTID, STYLE_NAME, STYLE, IS_DEL, UPDATE_DATE)"
- + " VALUES(?,?,?,'0',SYSDATE())");
- /**
- * 修改默认的样式
- * ?样式
- * ?样式默认样式的id
- */
- map.put("updateStyleOfDefalutStyle", "UPDATE ECM_CM_USER_SELF_STYLE SET STYLE=?,UPDATE_DATE=SYSDATE() WHERE FD_OBJECTID=?;");
- /**
- * 查询默认的样式
- */
- map.put("searchDefaultStyleByUserId", "SELECT * FROM ECM_CM_USER_SELF_STYLE WHERE STYLE_NAME=?;");
- }
- public int update(String sqlName,Object...args) throws SQLException{
- String sql=null;
- int state=-1;
- sql=map.get(sqlName);
- if(sql.toUpperCase()=="NULL"&&"".equals(sql.trim())) throw new SQLException("sql语句不合法--->"+sql);
- state = cmt.update(sql, args);
-
- return state;
-
- }
-
- /**
- * 保存视图
- * @param name
- * @param params
- * @param userId
- * @param conId
- * @param maticId
- * @param setOften
- * @param screenState
- * @return
- */
- public String saveLayoutAndView(String name,String params,String userId,String[] conId,String[] maticId,String setOften,String screenState){
- String saveLayoutStr="insert into NWYJ.ECM_CM_SYSLAYOUT"
- + "( FD_OBJECTID, SL_NAME, SL_PARAMENT, SL_USERID, IS_DEL, UPDATEDATE, TM_BEX,IS_COMMONUSE,SCREEN_STATE) "
- + " VALUES(sq_num.NEXTVAL, ?, ?, ?, 0, SYSDATE(), 0,?,?)";
- String LayoutStr="SELECT FD_OBJECTID,UPDATEDATE,SL_NAME FROM NWYJ.ECM_CM_SYSLAYOUT "
- + " WHERE UPDATEDATE=(SELECT MAX(UPDATEDATE) "
- + " FROM NWYJ.ECM_CM_SYSLAYOUT WHERE SL_USERID= ? AND SCREEN_STATE=?)";
- String saveOpenMatic="insert into NWYJ.ECM_CM_OPENLAYERMATIC(FD_OBJECTID, OL_CONID, OL_AREAID, OL_MATICID, IS_DEL, UPDATEDATE, OL_BEX) "
- + " VALUES(sq_num.NEXTVAL, ?, ?, ?, 0,SYSDATE(), ?)";
- String result=null;
- Connection conn=null;
- PreparedStatement ps=null;
- ResultSet rs=null;
- int flag=0;
- try {
- conn=DBUtils.getConnection();
- /* conn.setAutoCommit(false);*/
- //保存视图
- log.info("===saveLayou()===sql==="+saveLayoutStr);
- ps=conn.prepareStatement(saveLayoutStr);
- ps.setString(1, name);
- if(params==null || params.toLowerCase().trim().equals("null")){
- ps.setString(2, "");
- }else{
- ps.setString(2, params);
- }
- ps.setString(3, userId);
- ps.setString(4, setOften);
- ps.setString(5, screenState);
- ps.executeUpdate();
- //获取保存视图后的主键id
- log.info("===saveLayou()===sql==="+LayoutStr);
- ps=conn.prepareStatement(LayoutStr);
- ps.setString(1, userId);
- ps.setString(2, screenState);
- rs=ps.executeQuery();
- //System.out.println(flag);
- //保存各个容器的专题图
- System.out.println("conId.length"+conId.length);
- String objectId=null;
- String viewName=null;
- while(rs.next()){
- objectId= rs.getString("FD_OBJECTID");
- viewName=rs.getString("SL_NAME");
- System.out.println("objectId="+objectId+";viewName="+viewName);
- }
- for(int count=0;count<conId.length;count++){
- log.info("===saveLayou()===sql==="+saveOpenMatic);
- ps=conn.prepareStatement(saveOpenMatic);
- ps.setString(1, conId[count]);
- ps.setString(2, objectId);
- ps.setString(3,maticId[count]);
- ps.setString(4, viewName);
- ps.executeUpdate();
- }
- /*conn.commit();*/
- result=ResultState.SUCCESS;
- } catch (Exception e) {
- e.printStackTrace();
- conn.rollback();
- log.error(e.getMessage());
- result=ResultState.FAILURE;
-
- }finally{
- DBUtils.close(rs, ps, conn);
- return result;
- }
- }
-
- /**
- * 删除视图
- * @param FD_OBJECTID
- * @param SCREEN_STATE
- * @return
- */
- public int deleteLayoutAndView(String FD_OBJECTID,String SCREEN_STATE){
- Connection conn=null;
- PreparedStatement ps=null;
- try {
- conn=DBUtils.getConnection();
- conn.setAutoCommit(false);
- ps=conn.prepareStatement("delete from ECM_CM_SYSLAYOUT where FD_OBJECTID=? AND SCREEN_STATE = ?");
- ps.setString(1, FD_OBJECTID);
- ps.setString(2, SCREEN_STATE);
- ps.executeUpdate();
- ps=conn.prepareStatement("delete from NWYJ.ECM_CM_OPENLAYERMATIC where OL_AREAID=?");
- ps.setString(1, FD_OBJECTID);
- ps.executeUpdate();
- conn.commit();
- return 1;
- } catch (SQLException e) {
- try {
- conn.rollback();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- return 0;
- }finally{
- DBUtils.close(null, ps, conn);
- }
- }
-
-
- /**
- * 设置默认视图
- * @param userId
- * @param FD_OBJECTID
- * @param screenState
- * @return
- */
- public int setDefaultSysLayou(String userId,String FD_OBJECTID,String screenState){
- Connection conn=null;
- PreparedStatement ps=null;
- try {
- conn=DBUtils.getConnection();
- conn.setAutoCommit(false);
- ps=conn.prepareStatement("UPDATE ECM_CM_SYSLAYOUT SET TM_BEX='0' WHERE SL_USERID=? AND SCREEN_STATE=?");
- ps.setString(1, userId);
- ps.setString(2, screenState);
-
- ps.executeUpdate();
- ps=conn.prepareStatement("UPDATE ECM_CM_SYSLAYOUT SET TM_BEX='1' WHERE SL_USERID=? AND FD_OBJECTID=? AND SCREEN_STATE=?");
- ps.setString(1, userId);
- ps.setString(2, FD_OBJECTID);
- ps.setString(3, screenState);
-
- ps.executeUpdate();
- conn.commit();
- return 1;
- } catch (SQLException e) {
- try {
- conn.rollback();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- e.printStackTrace();
- return 0;
- }finally{
- DBUtils.close(null, ps, conn);
- }
- }
-
- /**
- * 修改视图
- * @param name
- * @param id
- * @param conId
- * @param maticId
- * @return
- */
- public String editLayouAndView(String name,String id,String[] conId,String[] maticId){
- Connection conn=null;
- PreparedStatement ps=null;
- String setViewName="update ECM_CM_SYSLAYOUT set SL_NAME=? where FD_OBJECTID=?";
- String deleteMatics="DELETE FROM ECM_CM_OPENLAYERMATIC WHERE OL_AREAID=?";
- String insertMatics="insert into NWYJ.ECM_CM_OPENLAYERMATIC(FD_OBJECTID, OL_CONID, OL_AREAID, OL_MATICID, IS_DEL, UPDATEDATE, OL_BEX) "
- + " VALUES(sq_num.NEXTVAL, ?, ?, ?, 0,SYSDATE(), ?)";
- String result=null;
- try {
- conn=DBUtils.getConnection();
- conn.setAutoCommit(false);
- //修改视图名称
- ps=conn.prepareStatement(setViewName);
- ps.setString(1, name);
- ps.setString(2, id);
- ps.executeUpdate();
- ps.close();
- //删除视图
- ps=conn.prepareStatement(deleteMatics);
- ps.setString(1,id);
- ps.executeUpdate();
- //
- for(int i=0;i<conId.length;i++){
- ps=conn.prepareStatement(insertMatics);
- ps.setString(1, conId[i]);
- ps.setString(2, id);
- ps.setString(3, maticId[i]);
- ps.setString(4, name);
- ps.executeUpdate();
- }
- conn.commit();
- result=ResultState.SUCCESS;
- } catch (SQLException e) {
- conn.rollback();
- e.printStackTrace();
- result=ResultState.FAILURE;
- }finally{
- DBUtils.close(null, ps, conn);
- return result;
- }
- }
-
-
-
-
- }
|