diff --git a/repo/MPowerClient.jar b/repo/MPowerClient.jar new file mode 100644 index 0000000..512793f Binary files /dev/null and b/repo/MPowerClient.jar differ diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java index 9045e44..b1a52f8 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/BoardController.java @@ -48,7 +48,8 @@ public class BoardController { final BoardDto dto, @Parameter(hidden = true) final Pageable pageable) { - return RestResponse.of(service.findAll(dto, pageable)); + //return RestResponse.of(service.findAll(dto, pageable)); + return RestResponse.of(service.findAllTest(dto)); } @Secured(policy = SecurityPolicy.TOKEN) diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java index 9c62d63..3d209a3 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IBoardService.java @@ -5,9 +5,13 @@ import com.xit.biz.ctgy.entity.MinCivBoard680; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import java.util.Map; + public interface IBoardService { Page findAll(final BoardDto dto, Pageable pageable); + + Map findAllTest(final BoardDto dto); Page findAll2(final MinCivBoard680 entity, Pageable pageable); int modifyByCiCode(Long ciCode); diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java index f417951..7d19cc0 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/BoardService.java @@ -12,6 +12,7 @@ import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.support.jpa.JpaUtil; import com.xit.core.util.Checks; import com.xit.core.util.CommUtil; +import com.xit.core.util.mpower.MpowerUtil; import lombok.AllArgsConstructor; import org.mapstruct.factory.Mappers; import org.springframework.data.domain.Example; @@ -23,6 +24,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Map; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; @@ -39,7 +41,48 @@ public class BoardService implements IBoardService { pageable = JpaUtil.getPagingInfo(pageable); return repository.findAll(dto, pageable); } - + @Transactional(readOnly = true) + public Map findAllTest(final BoardDto dto){ + MpowerUtil sendXml = new MpowerUtil(); + String query = "SELECT ci_code ciCode,\n" + + " name ciName,\n" + + " ci_contentno ciContentno,\n" + + " ci_title ciTitle,\n" + + " ci_contents ciContents,\n" + + " ci_nalja ciNalja,\n" + + " ci_step ciStep,\n" + + " ci_revel ciRevel,\n" + + " ci_ref ciRef,\n" + + " ci_hit ciHit,\n" + + " ci_pass ciPass,\n" + + " ci_id ciId \n" + + " FROM min_civ_board680 LEFT OUTER JOIN min_userinfo ON (ci_id = userid)\n" + + " WHERE ci_code IN\n" + + " (20,\n" + + " 19,\n" + + " 18,\n" + + " 17,\n" + + " 16,\n" + + " 13,\n" + + " 15,\n" + + " 12,\n" + + " 14,\n" + + " 11,\n" + + " 9,\n" + + " 10,\n" + + " 7,\n" + + " 8,\n" + + " 6,\n" + + " 4,\n" + + " 3,\n" + + " 1,\n" + + " 5,\n" + + " 2)"; + sendXml.setFeilds("ciCode, ciName, ciContentno, ciTitle, ciContents, ciNalja, ciStep, ciRevel, ciRef, ciHit, ciPass, ciId"); + sendXml.setQuery(query); + Map eMap = sendXml.selectCustomQuery(); + return eMap; + } @Transactional(readOnly = true) public Page findAll2(final MinCivBoard680 entity, Pageable pageable) { pageable = JpaUtil.getPagingInfo(pageable); diff --git a/src/main/java/com/xit/core/util/mpower/MpowerUtil.java b/src/main/java/com/xit/core/util/mpower/MpowerUtil.java new file mode 100644 index 0000000..e8c4eac --- /dev/null +++ b/src/main/java/com/xit/core/util/mpower/MpowerUtil.java @@ -0,0 +1,851 @@ +package com.xit.core.util.mpower; + +import java.nio.charset.StandardCharsets; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.*; + +//import org.apache.log4j.Logger; + +//import com.gpki.util.Base64; +import com.plf.client.Client; + +//import egovframework.rte.psl.dataaccess.util.EgovMap; + +public class MpowerUtil { + //DBName Properties +// static String DbName2 = PropertiesUtil.getValue("Globals.DBName"); + static String DbName2 = "gn"; + + + Client mpower = null; + static Client mpower2 = null; + //static String hostip = "115.21.123.19"; + static String hostip = "127.0.0.1"; + static int port = 9999; + static String query = ""; + String wholeQuery = ""; + //protected static Logger logger = Logger.getLogger(MpowerUtil.class.getName()); + static ArrayList feilds = new ArrayList(); + static String feild = ""; + static String tmpFeilds = ""; + static Boolean RowNum = false; + static String tableNm = ""; + static String WhereStr = ""; + static String Orderby = ""; + static int pageIndex = 0; + static int firstIndex = 0; + static int lastIndex = 10; + static int recordCountPerPage = 10; + static String beforeXml = ""; + static String afterXmlsp = "]]>"; + static Boolean pagingYn = false; + + + //Ps변수 + static String Params = ""; + static String finalParams = ""; + static String threeXml = ""; + static String threeXmlEnd = ""; + static String forXmlEnd = ""; + static int psParamCount = 0; + static String psFinalFarams =""; + static String QueryXml = ""; + + //static String vioPhoto = PropertiesUtil.getValue("Globals.vioPhoto"); //주정차사진경로 + static String vioPhoto = ""; + //static String vioPhotoBus = PropertiesUtil.getValue("Globals.vioPhotoBus"); //버스사진경로 + static String vioPhotoBus = ""; + //static String tunullingFile = PropertiesUtil.getValue("Globals.tunullingFile"); //터널링서버에 복사되는 첨부파일 위치 + static String tunullingFile = ""; + + public void setQuery(String query){ + MpowerUtil.query = query; + } + + public void setRowNum(boolean truefalse){ + RowNum = truefalse; + } + + public void setPageIndex(int pi){ + pageIndex = pi; + } + + public void setRecordCountPerPage(int rcpp){ + recordCountPerPage = rcpp; + } + + public int getRecordCountPerPage(){ + return recordCountPerPage; + } + + public String getWholeQuery() { + return wholeQuery; + } + + public void setWholeQuery(String wholeQuery) { + this.wholeQuery = wholeQuery; + } + + public void setFeild(String feildNm){ + feilds.add(feildNm); + } + + public void setFeild2(String feildNm){ + feild = feildNm; + } + + public void setTableNm(String tNm){ + tableNm = tNm; + } + public void setWhereStr(String whr){ + WhereStr += whr; + } + public void setOrderby(String ob){ + Orderby += ob; + } + + public int getFirstIndex() { + return (pageIndex - 1) * recordCountPerPage +1; + } + + public int getLastIndex() { + return lastIndex = pageIndex * recordCountPerPage; + } + + public void setPagingYn(Boolean yn){ + pagingYn = yn; + } + + public void AddParam(String inputType,String Val){ + psParamCount ++; + Params += ""; + } + + //kkj추가 + public void AddParam2(String inputType,long Val){ + psParamCount ++; + Params += ""; + } + + public void setParamsBody(){ + Params = "" + Params + ""; + + afterXmlsp = "]]>"; + forXmlEnd = ""; + } + + public void setSPQuerysBody(){ + QueryXml = beforeXmlsp + tableNm + "(" +psFinalFarams + ")" + afterXmlsp + Params + forXmlEnd; + } + + public void AddFinalParam(int count){ + for(int i=0;i PsQuery() throws Exception{ + //EgovMap resultEgov = new EgovMap(); + Map resultEgov = new HashMap<>(); + try{ + AddFinalParam(psParamCount); + setParamsBody(); + setSPQuerysBody(); + resultEgov = connreturnMpwoer(QueryXml); + }catch(Exception e) + { + e.printStackTrace(); + }finally{ + clearValidation(); + } + return resultEgov; + } + + public Map connreturnMpwoer(String psQuery) throws Exception{ + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", psQuery); + mpower.Request(); + //EgovMap eMap = new EgovMap(); + Map eMap = new HashMap<>(); + eMap.put("result",mpower.getString("result", 0, 0)); + + int cnt = 1; + for( int i = 0 ; i < mpower.getMaxCol("list1"); i++){ + eMap.put("list"+cnt,mpower.getString("list1", 0, i)); + cnt ++; + } + return eMap; + } + + public List selectQuery() { + String fileList = ""; + for(int cnt = 0;cnt mList = new ArrayList(); + List mList= new ArrayList<>(); + + try { + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", query); + mpower.Request(); + String result = mpower.getString("result", 0, 0); + int row; + if (result.equals("true")){ + row = mpower.getMaxRow("list1"); + if(row>0){ + for(int i=0;i m = new HashMap<>(); + for(int j=0;j(); + tableNm = ""; + WhereStr = ""; + Orderby = ""; + } + + return mList; + } + + private void clearValidation() { + query = ""; + feilds = new ArrayList(); + tableNm = ""; + WhereStr = ""; + Orderby=""; + psParamCount = 0; + QueryXml = ""; + Params = ""; + psFinalFarams = ""; + recordCountPerPage = 10; + feild = ""; + } + + + /** + * @ 페이징 처리 SELECT 호출 + * @return + */ + public Map selectListQuery() { + //EgovMap mListMap = new EgovMap(); + Map mListMap = new HashMap<>(); + //배열로 넘어온 필드를 String 오브젝트로 변형 + String fileList = ""; + for(int cnt = 0;cnt(); + this.setFeilds("RN, "+tmpFeilds); + } + + //List mList = new ArrayList(); + List mList = new ArrayList<>(); + System.out.println("mlistmlist"); + System.out.println(mList); + System.out.println("mlistmlist"); + int mListCount = 0; + try { + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", query); + mpower.Request(); + String result = mpower.getString("result", 0, 0); + int row = 0; + if (result.equals("true")){ + row = mpower.getMaxRow("list1"); + if(row>0){ + for(int i=0;i m = new HashMap<>(); + for(int j=0;j0){ + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", Cquery); + mpower.Request(); + + String strList1 = mpower.getString("list1", 0, 0); + + if( !strList1.equals("") && strList1 != null){ + mListCount = Integer.parseInt(strList1); + } + mpower.disconnect(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally{ + clearValidation(); + } + System.out.println("엠리스트트트트트"); + System.out.println(mListCount); + System.out.println(mListMap); + System.out.println(mList); + System.out.println("엠리스트트트트트"); + mListMap.put("mListCount", mListCount); + return mListMap; + } + + // + + /** + * @ 페이징 처리 SELECT 호출 + * @return + * @throws SQLException + */ + public Map selectListQueryNew() throws SQLException { + //EgovMap mListMap = new EgovMap(); + Map mListMap = new HashMap<>(); + //배열로 넘어온 필드를 String 오브젝트로 변형 + String fileList = ""; + for(int cnt = 0;cnt(); + this.setFeilds("RN, "+tmpFeilds); + } + + //List mList = new ArrayList(); + List mList = new ArrayList<>(); + int mListCount = 0; + + Connection con; + Statement stmt; //단순 쿼리 실행 + PreparedStatement pstmt = null; //컴파일시 디비에 먼저 파싱하므로 Statement 보다 빠름 + CallableStatement cstmt; //프로시져를 호출하므로 속도가 PreparedStatement 보다 빠름 + ResultSet rs = null; + String dbURL = "jdbc:oracle:thin:@115.21.123.114:1521:ora10g"; + String driver = "oracle.jdbc.OracleDriver"; + + try { + Class.forName(driver); + } catch (ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + con = DriverManager.getConnection(dbURL, "TRAFFIC", "xhdgkq0"); + + //3.1 Statement 객체로 구문객체 생성 및 실행 + int size = 0; + try{ + System.out.println("Query :" + finalQuery); + pstmt = con.prepareStatement(finalQuery); + rs = pstmt.executeQuery(); // 이거 왜 실행안??? + System.out.println("rs:" + rs); + boolean chpoint = false; + while(rs.next()) + { + size = rs.getInt(1); + //EgovMap m = new EgovMap(); + Map m = new HashMap<>(); + if(!chpoint) + { + for(int j=0;j selectListQuery2() { + //EgovMap mListMap = new EgovMap(); + Map mListMap = new HashMap<>(); + //배열로 넘어온 필드를 String 오브젝트로 변형 + String fileList = ""; + for(int cnt = 0;cnt(); + this.setFeilds("RN, "+tmpFeilds); + } + + //List mList = new ArrayList(); + List mList = new ArrayList<>(); + int mListCount = 0; + try { + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", query); + mpower.Request(); + String result = mpower.getString("result", 0, 0); + int row = 0; + if (result.equals("true")){ + row = mpower.getMaxRow("list1"); + if(row>0){ + for(int i=0;i m = new HashMap<>(); + for(int j=0;j0){ + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", Cquery); + mpower.Request(); + + String strList1 = mpower.getString("list1", 0, 0); + + if( !strList1.equals("") && strList1 != null){ + mListCount = Integer.parseInt(strList1); + } + mpower.disconnect(); + } + + } catch (Exception e) { + e.printStackTrace(); + } finally{ + clearValidation(); + } + mListMap.put("mListCount", mListCount); + return mListMap; + } + + public Map selectListQuery_pay() { + //EgovMap mListMap = new EgovMap(); + Map mListMap = new HashMap<>(); + //배열로 넘어온 필드를 String 오브젝트로 변형 + String fileList = ""; + for(int cnt = 0;cnt(); + this.setFeilds("RN, "+tmpFeilds); + } + + //List mList = new ArrayList(); + List mList = new ArrayList<>(); + int mListCount = 0; + try { + mpower2 = new Client(hostip,port); + mpower2.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower2.setInput("SQLXML", query); + mpower2.Request(); + String result = mpower2.getString("result", 0, 0); + int row = 0; + if (result.equals("true")){ + row = mpower2.getMaxRow("list1"); + if(row>0){ + for(int i=0;i m = new HashMap<>(); + for(int j=0;j0){ + mpower2.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower2.setInput("SQLXML", Cquery); + mpower2.Request(); + mListCount = Integer.parseInt(mpower2.getString("list1", 0, 0)); + //System.out.println("mListCount:"+mListCount); + } + //logger.debug("END getString list1"); + mpower2.disconnect(); + //logger.debug(Cquery); + //logger.debug("==============================================================================================================="); + + } catch (Exception e) { + e.printStackTrace(); + } finally{ + clearValidation(); + } + mListMap.put("mListCount", mListCount); + return mListMap; + } + + /** + * @ 페이징 처리 SELECT 호출 + * @return + */ + public Map selectCustomQuery() { + //EgovMap mListMap = new EgovMap(); + Map mListMap = new HashMap<>(); + //배열로 넘어온 필드를 String 오브젝트로 변형 + String fileList = ""; + for(int cnt = 0;cnt mList = new ArrayList(); + List mList = new ArrayList<>(); + int mListCount = 0; + try { + mpower = new Client(hostip,port); + mpower.getConnection("MPowerXmlToQuery.xmlQuery1"); + mpower.setInput("SQLXML", query); + mpower.Request(); + String result = mpower.getString("result", 0, 0); + int row; + if (result.equals("true")){ + row = mpower.getMaxRow("list1"); + if(row>0){ + for(int i=0;i m = new HashMap<>(); + if(!"".equals(feild) && feild != null){ + m.put("cbContent", mpower.getString("list1", i, 4)); + }else{ + for(int j=0;j