Merge branch 'dev'
commit
b869a7ebad
@ -0,0 +1,48 @@
|
||||
package com.xit.core.config.database;
|
||||
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.dao.support.DaoSupport;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
public abstract class BaseMybatisDaoSupport extends DaoSupport
|
||||
{
|
||||
|
||||
private SqlSession sqlSession;
|
||||
private SqlSessionFactory sqlSessionFactory;
|
||||
private boolean extenalSqlSession = false;
|
||||
|
||||
public final void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
|
||||
this.sqlSession = sqlSessionTemplate;
|
||||
this.extenalSqlSession = true;
|
||||
}
|
||||
|
||||
public final SqlSession getSqlSession() {
|
||||
return sqlSession;
|
||||
}
|
||||
|
||||
public final void setSqlSession(SqlSession sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
public final SqlSessionFactory getSqlSessionFactory() {
|
||||
return sqlSessionFactory;
|
||||
}
|
||||
|
||||
public final void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
|
||||
this.sqlSessionFactory = sqlSessionFactory;
|
||||
if(!this.extenalSqlSession) {
|
||||
this.sqlSession = new SqlSessionTemplate(sqlSessionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkDaoConfig() throws IllegalArgumentException {
|
||||
Assert.notNull(this.sqlSession, "Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.xit.core.config.support;
|
||||
|
||||
import org.springframework.web.filter.CharacterEncodingFilter;
|
||||
|
||||
public class EucKrEncodingFilter extends CharacterEncodingFilter {
|
||||
|
||||
public EucKrEncodingFilter() {
|
||||
setEncoding("EUC-KR");
|
||||
setForceEncoding(true);
|
||||
}
|
||||
}
|
@ -0,0 +1,465 @@
|
||||
package com.xit.core.util.mpower;
|
||||
|
||||
import com.plf.client.Client;
|
||||
import com.xit.core.util.CommUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.apache.ibatis.mapping.BoundSql;
|
||||
import org.apache.ibatis.mapping.ParameterMapping;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class MpowerUtils {
|
||||
//DBName Properties
|
||||
// static String DbName2 = PropertiesUtil.getValue("Globals.DBName");
|
||||
static String DbName2 = "gn";
|
||||
|
||||
|
||||
Client mpower = null;
|
||||
static String hostip = "127.0.0.1";
|
||||
static int port = 9999;
|
||||
static String query = "";
|
||||
static ArrayList<String> feilds = new ArrayList<String>();
|
||||
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 lastIndex = 10;
|
||||
static int recordCountPerPage = 10;
|
||||
static String beforeXml = "<?xml version='1.0' encoding='euc-kr'?><QUERYS DBNAME='"+DbName2+"' DEBUG='true'><QUERY TYPE='select' BATCH='false'><SQL><![CDATA[";
|
||||
static String afterXml = "]]></SQL></QUERY></QUERYS>";
|
||||
|
||||
|
||||
|
||||
//Ps변수
|
||||
static String Params = "";
|
||||
|
||||
static int psParamCount = 0;
|
||||
static String psFinalFarams ="";
|
||||
static String QueryXml = "";
|
||||
|
||||
static String vioPhoto = "";
|
||||
static String vioPhotoBus = "";
|
||||
static String tunullingFile = "";
|
||||
|
||||
public void setQuery(String query){
|
||||
MpowerUtils.query = query;
|
||||
}
|
||||
|
||||
public void setFeild(String feildNm){
|
||||
feilds.add(feildNm);
|
||||
}
|
||||
|
||||
public int getFirstIndex() {
|
||||
return (pageIndex - 1) * recordCountPerPage +1;
|
||||
}
|
||||
|
||||
public int getLastIndex() {
|
||||
return lastIndex = pageIndex * recordCountPerPage;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> selectQuery() {
|
||||
String fileList = "";
|
||||
for(int cnt = 0;cnt<feilds.size();cnt++){
|
||||
if(cnt==0){
|
||||
fileList += feilds.get(cnt);
|
||||
}else{
|
||||
fileList += "," + feilds.get(cnt);
|
||||
}
|
||||
}
|
||||
|
||||
query = beforeXml + "select "+ fileList +" from " + tableNm + WhereStr + afterXml ;
|
||||
//logger.debug("=====================================================Select Query==================================================");
|
||||
//logger.debug("select "+fileList +" from "+tableNm + WhereStr);
|
||||
System.out.println("select "+fileList +" from "+tableNm + WhereStr);
|
||||
|
||||
//List<EgovMap> mList = new ArrayList<EgovMap>();
|
||||
List<Map<String, Object>> mList= new ArrayList<Map<String, Object>>();
|
||||
|
||||
try {
|
||||
mpower = new Client(hostip,port);
|
||||
mpower.getConnection("MPowerXmlToQuery.xmlQuery1");
|
||||
mpower.setInput("SQLXML", query);
|
||||
mpower.Request();
|
||||
String result = mpower.getString("result", 0, 0);
|
||||
System.out.println("#######$$$$$$$$$$$$$$$$$$"+result);
|
||||
|
||||
int row;
|
||||
if (result.equals("true")){
|
||||
row = mpower.getMaxRow("list1");
|
||||
if(row>0){
|
||||
for(int i=0;i<row;i++){
|
||||
//EgovMap m = new EgovMap();
|
||||
Map<String,Object> m = new HashMap<>();
|
||||
for(int j=0;j<feilds.size();j++){
|
||||
m.put(feilds.get(j), mpower.getString("list1", i, j));
|
||||
}
|
||||
mList.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
//logger.debug("SelectList Count :: "+mList.size()+"건");
|
||||
//logger.debug("===================================================================================================================");
|
||||
mpower.disconnect();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
query = "";
|
||||
feilds = new ArrayList<String>();
|
||||
tableNm = "";
|
||||
WhereStr = "";
|
||||
Orderby = "";
|
||||
}
|
||||
|
||||
return mList;
|
||||
}
|
||||
|
||||
private void clearValidation() {
|
||||
query = "";
|
||||
feilds = new ArrayList<String>();
|
||||
tableNm = "";
|
||||
WhereStr = "";
|
||||
Orderby="";
|
||||
psParamCount = 0;
|
||||
QueryXml = "";
|
||||
Params = "";
|
||||
psFinalFarams = "";
|
||||
recordCountPerPage = 10;
|
||||
feild = "";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ 페이징 처리 SELECT 호출
|
||||
* @return
|
||||
*/
|
||||
public Map<String,Object> selectListQuery() {
|
||||
//EgovMap mListMap = new EgovMap();
|
||||
Map<String,Object> mListMap = new HashMap<>();
|
||||
//배열로 넘어온 필드를 String 오브젝트로 변형
|
||||
String fileList = "";
|
||||
for(int cnt = 0;cnt<feilds.size();cnt++){
|
||||
if(cnt==0){
|
||||
fileList += feilds.get(cnt);
|
||||
}else{
|
||||
fileList += "," + feilds.get(cnt);
|
||||
}
|
||||
}
|
||||
|
||||
String init="";
|
||||
String init2="";
|
||||
init = beforeXml + "select RN,"+ fileList +" from(";
|
||||
init2 = ")TB where RN BETWEEN "+getFirstIndex()+" and "+getLastIndex()+afterXml;
|
||||
query = init;
|
||||
query = query+"select ROWNUM RN,"+fileList+" from(";
|
||||
query = query+"select "+fileList+" ";
|
||||
query = query+"from "+tableNm+" ";
|
||||
query = query+WhereStr+" ";
|
||||
query = query+Orderby;
|
||||
query = query+")TA";
|
||||
query = query+init2;
|
||||
System.out.println("이곳은쿼리");
|
||||
System.out.println(query);
|
||||
System.out.println("이곳은쿼리");
|
||||
String Cquery = beforeXml + "select count(*) from " + tableNm +" "+ WhereStr +afterXml;
|
||||
|
||||
if(RowNum == true){
|
||||
feilds = new ArrayList<String>();
|
||||
this.setFeilds("RN, "+tmpFeilds);
|
||||
}
|
||||
|
||||
//List<EgovMap> mList = new ArrayList<EgovMap>();
|
||||
List<Map<String, Object>> 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<row;i++){
|
||||
//EgovMap m = new EgovMap();
|
||||
Map<String,Object> m = new HashMap<>();
|
||||
for(int j=0;j<feilds.size();j++){
|
||||
if(RowNum == false){
|
||||
m.put(feilds.get(j), mpower.getString("list1", i, j+1));
|
||||
}else if(RowNum == true){
|
||||
m.put(feilds.get(j), mpower.getString("list1", i, j));
|
||||
}
|
||||
}
|
||||
mList.add(m);
|
||||
}
|
||||
mListMap.put("mList", mList);
|
||||
}
|
||||
}
|
||||
mpower.disconnect();
|
||||
|
||||
if(row>0){
|
||||
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<String,Object> selectListQueryNew() throws SQLException {
|
||||
//EgovMap mListMap = new EgovMap();
|
||||
Map<String,Object> mListMap = new HashMap<>();
|
||||
//배열로 넘어온 필드를 String 오브젝트로 변형
|
||||
String fileList = "";
|
||||
for(int cnt = 0;cnt<feilds.size();cnt++){
|
||||
if(cnt==0){
|
||||
fileList += feilds.get(cnt);
|
||||
}else{
|
||||
fileList += "," + feilds.get(cnt);
|
||||
}
|
||||
}
|
||||
String finalQuery = "";
|
||||
String Cquery = beforeXml + "select count(*) from " + tableNm +" "+ WhereStr +afterXml;
|
||||
if(!"".equals(feild) && feild != null){
|
||||
finalQuery = query;
|
||||
}else{
|
||||
finalQuery = "select " + fileList +" from " + tableNm +" "+ WhereStr;
|
||||
}
|
||||
if(RowNum == true){
|
||||
feilds = new ArrayList<String>();
|
||||
this.setFeilds("RN, "+tmpFeilds);
|
||||
}
|
||||
|
||||
//List<EgovMap> mList = new ArrayList<EgovMap>();
|
||||
List<Map<String, Object>> mList = new ArrayList<Map<String, Object>>();
|
||||
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<String,Object> m = new HashMap<>();
|
||||
if(!chpoint)
|
||||
{
|
||||
for(int j=0;j<size;j++){
|
||||
if(!"".equals(feild) && feild != null){
|
||||
m.put("cbContent", rs.getString(feilds.get(j).toString()));
|
||||
}else{
|
||||
m.put(feilds.get(j),rs.getString(feilds.get(j).toString()));
|
||||
}
|
||||
|
||||
}
|
||||
mList.add(m);
|
||||
}
|
||||
}
|
||||
mListMap.put("mList", mList);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
try{
|
||||
rs.close();
|
||||
pstmt.close();
|
||||
con.close();
|
||||
clearValidation();
|
||||
}catch(SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return mListMap;
|
||||
}
|
||||
//
|
||||
|
||||
/**
|
||||
* @ 페이징 처리 SELECT 호출
|
||||
* @return
|
||||
*/
|
||||
public List<Map<String,Object>> selectCustomQuery() {
|
||||
//EgovMap mListMap = new EgovMap();
|
||||
Map<String,Object> mListMap = new HashMap<>();
|
||||
//배열로 넘어온 필드를 String 오브젝트로 변형
|
||||
String fileList = "";
|
||||
for(int cnt = 0;cnt<feilds.size();cnt++){
|
||||
if(cnt==0){
|
||||
fileList += feilds.get(cnt);
|
||||
}else{
|
||||
fileList += "," + feilds.get(cnt);
|
||||
}
|
||||
}
|
||||
query = beforeXml+query+afterXml;
|
||||
//logger.debug("=====================================================Select Query==================================================");
|
||||
//logger.debug(query);
|
||||
|
||||
System.out.println("======"+query);
|
||||
//List<EgovMap> mList = new ArrayList<EgovMap>();
|
||||
List<Map<String,Object>> mList = new ArrayList<>();
|
||||
int mListCount = 0;
|
||||
try {
|
||||
mpower = new Client(hostip,port);
|
||||
mpower.setCryptEnable(false);
|
||||
mpower.getConnection("MPowerXmlToQuery.xmlQuery1");
|
||||
mpower.setInput("SQLXML", query);
|
||||
mpower.Request();
|
||||
String result = mpower.getString("result", 0, 0);
|
||||
|
||||
System.out.println("#######message = "+mpower.getMessage());
|
||||
System.out.println("#######message charset = "+CommUtil.detectCharset(mpower.getMessage().getBytes()));
|
||||
|
||||
|
||||
int row;
|
||||
if (result.equals("true")){
|
||||
row = mpower.getMaxRow("list1");
|
||||
if(row>0){
|
||||
for(int i=0;i<row;i++){
|
||||
//EgovMap m = new EgovMap();
|
||||
Map<String,Object> m = new HashMap<>();
|
||||
if(!"".equals(feild) && feild != null){
|
||||
m.put("cbContent", mpower.getString("list1", i, 4));
|
||||
}else{
|
||||
for(int j=0;j<feilds.size();j++){
|
||||
m.put(feilds.get(j), mpower.getString("list1", i, j));
|
||||
}
|
||||
}
|
||||
mList.add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
mpower.disconnect();
|
||||
//logger.debug("===============================================================================================================");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally{
|
||||
clearValidation();
|
||||
}
|
||||
return mList;
|
||||
}
|
||||
|
||||
|
||||
public void setFeilds(String string) {
|
||||
String[] m = string.split(",");
|
||||
for(int i=0;i<m.length;i++){
|
||||
setFeild(m[i].trim());
|
||||
}
|
||||
tmpFeilds = string;
|
||||
}
|
||||
|
||||
|
||||
//첨부파일 터널링 서버로 복사
|
||||
public void fnFileUpload(String tmpFileLocation,String realRcRilenm){
|
||||
String fph = tunullingFile; //터널링에 복사되는 파일경로
|
||||
try{
|
||||
Client mp = new Client("127.0.0.1", 2500);
|
||||
mp.getConnection("XitFile.XitUpload");
|
||||
mp.setInput("dir",tunullingFile);
|
||||
mp.setInput("upfile1",tmpFileLocation+realRcRilenm,true);
|
||||
mp.Request();
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//logger.debug(fph);
|
||||
}
|
||||
|
||||
|
||||
//터널링에서 웹서버로 첨부파일 복사
|
||||
public static void fnDownFile(String fileName,String sessionId){
|
||||
String serviceName = "XitFile.XitDownload";
|
||||
String fph = MpowerUtils.class.getResource("").getPath();
|
||||
fph = fph.replace("WEB-INF/classes/xit/cmmn/utill/", "vioPhoto/"+sessionId+"/"); //웹서버 저장 위치
|
||||
String fphs = fph.substring(0,1);
|
||||
if(fphs.equals("/")){
|
||||
fph = fph.substring(1);
|
||||
}
|
||||
String tmpTunullingFile = tunullingFile; //터널링에 저장된 단속사진 경로
|
||||
|
||||
try{
|
||||
Client mp = new Client("127.0.0.1", 2500);
|
||||
mp.getConnection("XitFile.XitDownload");
|
||||
mp.setInput("dnfile1",tmpTunullingFile+ fileName); //터널링에 실질 존재하는 경로,파일명
|
||||
mp.Request();
|
||||
String result = mp.getString("result", 0, 0);
|
||||
|
||||
if (result.equals("true")){
|
||||
mp.getFileName("imageA");
|
||||
mp.savefile("imageA", fph);
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
//logger.debug("웹서버 저장되는 첨부파일 위치:"+fph);
|
||||
System.out.println("웹서버 저장되는 첨부파일 위치:"+fph);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="board">
|
||||
|
||||
<select id="selectBoardList" parameterType="com.xit.biz.ctgy.dto.BoardDto" resultType="camelCaseLinkedMap">
|
||||
/* board-mapper|selectBoardList|julim */
|
||||
SELECT MCB.ci_code,
|
||||
MU.name,
|
||||
MCB.ci_contentno,
|
||||
MCB.ci_title,
|
||||
MCB.ci_contents,
|
||||
MCB.ci_nalja,
|
||||
MCB.ci_step,
|
||||
MCB.ci_revel,
|
||||
MCB.ci_ref,
|
||||
MCB.ci_hit,
|
||||
MCB.ci_pass,
|
||||
MCB.ci_id
|
||||
FROM min_civ_board680 MCB
|
||||
LEFT OUTER JOIN min_userinfo MU
|
||||
ON MCB.ci_id = MU.userid
|
||||
<where>
|
||||
<if test="ciTitle != null and ciTitle != ''">
|
||||
AND INSTR(MCB.ci_title, #{ciTitle}) > 0
|
||||
</if>
|
||||
<if test='ciName != null and ciName != ""'>
|
||||
AND MCB.ci_name like #{ciName}||'%'
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY MCB.ci_ref DESC,
|
||||
MCB.ci_step ASC,
|
||||
MCB.ci_code DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue