전기차,장애인 과태료시스템 FTP접속 추가

main
이범준 2 months ago
parent c87a967f49
commit 36d88fc7e1

@ -2,7 +2,6 @@ package cokr.xit.fims.rent.service.bean;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
@ -362,8 +361,10 @@ public class LsctBean extends AbstractBean {
* TB_CRDN, TB_PAYER .
* @param req
* @return
* @throws JSchException
* @throws NumberFormatException
*/
public List<DataObject> getLsctList(RentQuery req) {
public List<DataObject> getLsctList(RentQuery req) throws Exception {
// 기존 과태료 시스템에서 사용하던 암/복호화 함수 사용을 위해서..
XitAria crypto = new XitAria("xit-aria");
@ -527,13 +528,97 @@ public class LsctBean extends AbstractBean {
throw new RuntimeException("[F] 단속 부가 대장 등록 작업에 실패하였습니다."); // 예외를 발생시켜서 DB Rollback
}
/////////////////////////////////////////////////
//FTP 서버 정보 조회
DataObject main = mainList.get(iLoop);
DataObject ftpQuery = new DataObject()
.set("SGG_CD", main.string("MM_SGGCODE"))
.set("TASK_SE_CD", main.string("MM_TASKGB"));
DataObject storageServer = finSysFtpMapper.selectFtpInfo(ftpQuery);
/////////////////////////////////////////////////
//SFTP접속
Session session = null;
JSch jsch = new JSch();
Channel channel = null;
ChannelSftp channelSftp = null;
//세션객체 생성
session = jsch.getSession("admin", "127.0.0.1", Integer.parseInt("22"));
session.setPassword("pass");
//세션관련 설정정보 설정
java.util.Properties config = new java.util.Properties();
//호스트 정보 검사하지 않는다.
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setTimeout(10000); //타임아웃 설정
//log.info("connect.. " + connIp);
System.out.println("connect.. ");
session.connect(); //접속
channel = session.openChannel("sftp"); //sftp 채널 접속
channel.connect();
channelSftp = (ChannelSftp) channel;
String remoteWorkPath = storageServer.string("REMOTE_WORK_PATH");
channelSftp.cd(remoteWorkPath);
//접속완료
///////////////////////////////////////////////////////////////////
boolean fileSearchEnd = false;
int i = 1;
while(!fileSearchEnd) {
///////////////////////////////////////////////
// 단속ID로 단속 파일 다운로드
String i_char = "";
switch (i) {
case 1:i_char="A";break;
case 2:i_char="B";break;
case 3:i_char="C";break;
case 4:i_char="D";break;
}
String remoteFileName = main.string("MM_CODE")+i_char+".JPG";
String remoteFilePath = remoteWorkPath+remoteFileName;
InputStream is = channelSftp.get(remoteFilePath);
if(is == null) {
fileSearchEnd = true;
continue;
}
byte[] bytesOfFile = is.readAllBytes();
is.close();
/////////////////////////////////////////////
// 단속 파일 등록
List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
Relation rel = new FileInfo.Relation().setInfoType(Crdn.INF_TYPE).setInfoKey(crdn.getCrdnId());
String originalFileName = remoteFileName;
DataHolder dataHolder = new FileInfo.DataHolder(rel, originalFileName, bytesOfFile);
List<FileInfo> fileInfoList = new FileInfoFactory().createFileInfos(List.of(dataHolder));
fileBean.create(fileInfoList);
//
i++;
if(i >= 5) {
fileSearchEnd = true;
}
}
/////////////////////////////
//sftp연결종료
session.disconnect();
} else {
//
}
}
}

Loading…
Cancel
Save