|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
package com.xit.core.config.database;
|
|
|
|
|
|
|
|
|
|
import com.plf.client.Client;
|
|
|
|
|
import com.xit.biz.cmm.dto.ComboCodeDto;
|
|
|
|
|
import com.xit.core.constant.ErrorCode;
|
|
|
|
|
import com.xit.core.exception.CustomBaseException;
|
|
|
|
|
import com.xit.core.exception.MpowerException;
|
|
|
|
|
import com.xit.core.util.DBUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
@ -36,9 +35,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
T instance = null;
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
@ -47,10 +47,15 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
if (result.equals("true")){
|
|
|
|
|
row = client.getMaxRow("list1");
|
|
|
|
|
if(row > 1) throw new MpowerException("조회된 데이타가 단일행이 아닙니다");
|
|
|
|
|
if(row == 0) return null;
|
|
|
|
|
instance = getT(type, getFeilds(fields), 0, client);
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return instance;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -66,9 +71,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
public String selectOneColumn(String sql){
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
@ -77,13 +83,17 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
if (result.equals("true")){
|
|
|
|
|
row = client.getMaxRow("list1");
|
|
|
|
|
if(row > 1) throw new MpowerException("조회된 데이타가 단일행이 아닙니다");
|
|
|
|
|
if(row == 0) return null;
|
|
|
|
|
String value = client.getString("list1", 0, 0);
|
|
|
|
|
if(" ".equals(value)) value = "";
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -95,9 +105,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
List<Long> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
@ -113,9 +124,13 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
list.add(Long.valueOf(client.getString("list1", i, 0)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -128,9 +143,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
List<T> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
@ -148,6 +164,8 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
@ -166,14 +184,17 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(listSql, "SQL cannot be null");
|
|
|
|
|
|
|
|
|
|
long totalCnt = 0L;
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", cntQuery));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", cntQuery));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
totalCnt = Long.parseLong(client.getString("list1", 0, 0));
|
|
|
|
|
if(totalCnt <= 0) return new PageImpl<>(new ArrayList<>(), pageable, 0);
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error(e.getLocalizedMessage());
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
@ -200,9 +221,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
Map<String,Object> map = null;
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
@ -216,9 +238,13 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
for (int j = 0; j < fields.size(); j++) {
|
|
|
|
|
map.put(fields.get(j), client.getString("list1", 0, j));
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -230,9 +256,10 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
List<Map<String,Object>> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
|
|
|
|
|
@ -249,9 +276,13 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
}
|
|
|
|
|
list.add(map);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -259,6 +290,45 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GET 공통 콤보 코드 목록
|
|
|
|
|
* code 값을 숫자형으로 인식하는 오류로 별도 처리
|
|
|
|
|
*/
|
|
|
|
|
public List<ComboCodeDto> selectComboCodeList(String sql){
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
List<ComboCodeDto> list = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml("select", sql));
|
|
|
|
|
client.Request();
|
|
|
|
|
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
|
|
|
|
|
|
int row;
|
|
|
|
|
if (result.equals("true")){
|
|
|
|
|
row = client.getMaxRow("list1");
|
|
|
|
|
if(row>0) {
|
|
|
|
|
for (int i = 0; i < row; i++) {
|
|
|
|
|
list.add(new ComboCodeDto(client.getString("list1", i, 0), client.getString("list1", i, 1)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getLocalizedMessage());
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
|
disConnection(client);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getQueryXml(String syntax, String sql){
|
|
|
|
|
log.info(sql);
|
|
|
|
|
return String.format(
|
|
|
|
@ -294,17 +364,23 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
private int dmlQuery(String sql, String syntax) {
|
|
|
|
|
Objects.requireNonNull(sql, "SQL cannot be null");
|
|
|
|
|
|
|
|
|
|
Client client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml(syntax, sql));
|
|
|
|
|
Client client = null;
|
|
|
|
|
try {
|
|
|
|
|
client = getConnection();
|
|
|
|
|
client.setInput("SQLXML", getQueryXml(syntax, sql));
|
|
|
|
|
|
|
|
|
|
client.Request();
|
|
|
|
|
String result = client.getString("result", 0, 0);
|
|
|
|
|
|
|
|
|
|
if (result.equals("true")){
|
|
|
|
|
System.out.println("<<<<<<<<<<<<===========#$#$#$$##$#$$#$#$$$$$$$====>>>>>>>>>");
|
|
|
|
|
}else{
|
|
|
|
|
throw new MpowerException("SQL 오류::"+result);
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
}catch (MpowerException e){
|
|
|
|
|
throw e;
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
throw new MpowerException(ErrorCode.MPOWER_ERROR);
|
|
|
|
|
} finally {
|
|
|
|
@ -371,3 +447,53 @@ public abstract class BaseMpowerDaoSupport {
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
//첨부파일 터널링 서버로 복사
|
|
|
|
|
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 = MpowerUtil.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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|