2024-03-06 12:45 이미지 명 변경

This commit is contained in:
myname 2024-03-06 12:46:06 +09:00
parent 2cb7cb126e
commit 3f48a2c453
7 changed files with 241 additions and 139 deletions

View File

@ -33,6 +33,10 @@ public interface EgovFileMngService {
//압축 다운로드를 위한 첨부파일 목록 조회
public List<FileVO> selectZipFileList(FileVO fvo) throws Exception;
//체험신청서 전용
public List<FileVO> selectZipFileExprnList(FileVO fvo) throws Exception;
/**
* 하나의 파일에 대한 정보(속성 상세) 등록한다.
*

View File

@ -96,7 +96,27 @@ public class FileVO implements Serializable {
public String orderQuery;
public String getMaxFileNum() {
public String scholInsttNm; //학교기관이름
public String chrgNm; //담당자이름
public String getScholInsttNm() {
return scholInsttNm;
}
public void setScholInsttNm(String scholInsttNm) {
this.scholInsttNm = scholInsttNm;
}
public String getChrgNm() {
return chrgNm;
}
public void setChrgNm(String chrgNm) {
this.chrgNm = chrgNm;
}
public String getMaxFileNum() {
return maxFileNum;
}

View File

@ -13,7 +13,6 @@ import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl;
import kcc.com.cmm.service.EgovFileMngService;
import kcc.com.cmm.service.FileVO;
import kcc.ve.instr.tngrVisitEdu.eduInfo.service.VEEduAplctVO;
import kcc.ve.instr.tngrVisitEdu.rprtInfo.service.VEEduRprtVO;
/**
* @Class Name : EgovFileMngServiceImpl.java
@ -95,6 +94,11 @@ public class EgovFileMngServiceImpl extends EgovAbstractServiceImpl implements E
return fileMngDAO.selectZipFileList(fvo);
}
@Override
public List<FileVO> selectZipFileExprnList(FileVO fvo) throws Exception {
return fileMngDAO.selectZipFileExprnList(fvo);
}
/**
* 여러 개의 파일에 대한 정보(속성 상세) 수정한다.
*

View File

@ -119,6 +119,11 @@ public class FileManageDAO extends EgovComAbstractDAO {
return (List<FileVO>) list("FileManageDAO.selectZipFileList", vo);
}
@SuppressWarnings("unchecked")
public List<FileVO> selectZipFileExprnList(FileVO vo) throws Exception {
return (List<FileVO>) list("FileManageDAO.selectZipFileExprnList", vo);
}
/**
* 파일 구분자에 대한 최대값을 구한다.
*

View File

@ -15,6 +15,7 @@ import kcc.com.cmm.ComDefaultCodeVO;
import kcc.com.cmm.ComDefaultVO;
import kcc.com.cmm.service.CmmnDetailCode;
import kcc.com.cmm.service.EgovCmmUseService;
import kcc.com.cmm.service.FileVO;
import kcc.kccadr.sch.service.SchduleManageVO;
import kcc.let.uat.uia.service.SsoLoginVO;
import kcc.let.uss.umt.service.UserManageVO;
@ -584,6 +585,25 @@ public class EgovCryptoUtil {
// CndtnTrgtMngVO
//
//VEEduAplctVOList - 복호화
public List<FileVO> decryptFileVOList(List<FileVO> p_fileVOList){
for (int i=0;i<p_fileVOList.size();i++) {
FileVO fileVO = this.decryptFileVOInfo(p_fileVOList.get(i));
p_fileVOList.set(i, fileVO);
}
return p_fileVOList;
}
//VEAQestnrVO
//VEAQestnrVO - 복호화
public FileVO decryptFileVOInfo(FileVO p_fileVO){
//if (!"".equals(p_vEAQestnrVO.getChrgNm())) p_vEAQestnrVO.setChrgNm(this.decrypt(p_vEAQestnrVO.getChrgNm()));
if (!"".equals(p_fileVO.getChrgNm())) p_fileVO.setChrgNm(this.decrypt(p_fileVO.getChrgNm()));
return p_fileVO;
}
//////////////////////////////////////////////////
//
@ -670,5 +690,4 @@ public class EgovCryptoUtil {
return vEPrcsDetailVOList;
}
}

View File

@ -580,152 +580,160 @@ String[] order = {
, HttpServletRequest request, HttpServletResponse response) throws Exception {
vEEduAplctVO.setEduAplctOrdList(Arrays.asList(vEEduAplctVO.getChk().split(",")));
List<VEEduAplctVO> vEEduAplctVOList = vEEduMIXService.selectExprnAtchFileDownList(vEEduAplctVO);
vEEduAplctVOList = egovCryptoUtil.decryptVEEduAplctVOList(vEEduAplctVOList);
//첨부파일있는 항목만 재배치
String orgnZipNm = "체험교실 신청서.zip";
String downloadType = "A";
//첨부파일있는 항목만 재배치
List<String> atchFileIdList = new ArrayList<String>();
vEEduAplctVOList.forEach( vo -> {
if(vo.getScholSealAtchFileId() != null) {
atchFileIdList.add(vo.getScholSealAtchFileId());
}
});
List<VEEduAplctVO> fileYEduList = new ArrayList<VEEduAplctVO>();
vEEduAplctVOList.forEach( vo -> {
if(vo.getScholSealAtchFileId() != null) {
fileYEduList.add(vo);
}
});
FileVO fileVO = new FileVO();
fileVO.setDownloadType(downloadType);
fileVO.setAtchFileIdList(atchFileIdList);
List<FileVO> fvoList = fileService.selectZipFileList(fileVO); // 해당 기능에 맞게 파일 조회
int size = 1024;
byte[] buf = new byte[size];
String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm;
FileInputStream fis = null;
ZipArchiveOutputStream zos = null;
BufferedInputStream bis = null;
int fileCnt = 0;
try {
System.out.println("outZipNm : "+ outZipNm);
// Zip 파일생성
zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm)));
Iterator<FileVO> fvoIterator = fvoList.iterator();
Iterator<VEEduAplctVO> fileYEduIterator = fileYEduList.iterator();
while (fvoIterator.hasNext() && fileYEduIterator.hasNext() ){
FileVO vo = fvoIterator.next();
VEEduAplctVO eduVO = fileYEduIterator.next();
zos.setEncoding("UTF-8");
// Create a file object
File file = new File(vo.getFileStreCours() + "/" + vo.getStreFileNm());
// 1. check if the file exists or not
boolean isExists = file.exists();
if(isExists) {
System.out.println("getStreFileNm() " + vo.getStreFileNm());
System.out.println("I find the existFile.txt");
fileCnt++;
} else {
continue;
vEEduAplctVO.setEduAplctOrdList(Arrays.asList(vEEduAplctVO.getChk().split(",")));
List<VEEduAplctVO> vEEduAplctVOList = vEEduMIXService.selectExprnAtchFileDownList(vEEduAplctVO);
vEEduAplctVOList = egovCryptoUtil.decryptVEEduAplctVOList(vEEduAplctVOList);
//첨부파일있는 항목만 재배치
String orgnZipNm = "체험교실 신청서.zip";
String downloadType = "A";
//첨부파일있는 항목만 재배치
List<String> atchFileIdList = new ArrayList<String>();
vEEduAplctVOList.forEach( vo -> {
if(vo.getScholSealAtchFileId() != null) {
atchFileIdList.add(vo.getScholSealAtchFileId());
}
});
/*String renamedFileName = generateRenamedFileName(vo.getOrignlFileNm());*/
String renamedFileName = eduVO.getScholInsttNm() + "_" + eduVO.getChrgNm() + "_신청서."+ vo.getFileExtsn();
vo.setOrignlFileNm(renamedFileName);
//buffer에 해당파일의 stream을 입력한다.
fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm());
bis = new BufferedInputStream(fis,size);
//zip에 넣을 다음 entry 가져온다.
zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm()));
//준비된 버퍼에서 집출력스트림으로 write 한다.
int len;
while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len);
bis.close();
fis.close();
zos.closeArchiveEntry();
List<VEEduAplctVO> fileYEduList = new ArrayList<VEEduAplctVO>();
vEEduAplctVOList.forEach( vo -> {
if(vo.getScholSealAtchFileId() != null) {
fileYEduList.add(vo);
}
});
zos.close();
FileVO fileVO = new FileVO();
fileVO.setDownloadType(downloadType);
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally{
if( zos != null ) zos.close();
if( fis != null ) fis.close();
if( bis != null ) bis.close();
}
fileVO.setAtchFileIdList(atchFileIdList);
List<FileVO> fvoList = fileService.selectZipFileExprnList(fileVO); // 해당 기능에 맞게 파일 조회
fvoList = egovCryptoUtil.decryptFileVOList(fvoList);
File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm);
long fSize = uFile.length();
int size = 1024;
byte[] buf = new byte[size];
if (fSize > 0) {
String mimetype = "application/x-msdownload";
String outZipNm = fvoList.get(0).getFileStreCours()+File.separator + orgnZipNm;
FileInputStream fis = null;
ZipArchiveOutputStream zos = null;
BufferedInputStream bis = null;
response.setContentType(mimetype);
setDisposition(orgnZipNm, request, response);
//response.setContentLength(fSize);
BufferedInputStream in = null;
BufferedOutputStream out = null;
int fileCnt = 0;
try {
in = new BufferedInputStream(new FileInputStream(uFile));
out = new BufferedOutputStream(response.getOutputStream());
System.out.println("outZipNm : "+ outZipNm);
// Zip 파일생성
zos = new ZipArchiveOutputStream(new BufferedOutputStream(new FileOutputStream(outZipNm)));
FileCopyUtils.copy(in, out);
out.flush();
} catch (Exception ex) {
LOGGER.debug("IGNORED: {}", ex.getMessage());
} finally {
if (in != null) {
try {
in.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
if (out != null) {
try {
out.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
Iterator<FileVO> fvoIterator = fvoList.iterator();
Iterator<VEEduAplctVO> fileYEduIterator = fileYEduList.iterator();
while (fvoIterator.hasNext() && fileYEduIterator.hasNext() ){
FileVO vo = fvoIterator.next();
VEEduAplctVO eduVO = fileYEduIterator.next();
zos.setEncoding("UTF-8");
// Create a file object
File file = new File(vo.getFileStreCours() + "/" + vo.getStreFileNm());
// 1. check if the file exists or not
boolean isExists = file.exists();
if(isExists) {
System.out.println("getStreFileNm() " + vo.getStreFileNm());
System.out.println("I find the existFile.txt");
fileCnt++;
} else {
continue;
}
/*String renamedFileName = generateRenamedFileName(vo.getOrignlFileNm());*/
//String renamedFileName = eduVO.getScholInsttNm() + "_" + eduVO.getChrgNm() + "_신청서."+ vo.getFileExtsn();
String renamedFileName = vo.getScholInsttNm() + "_" + vo.getChrgNm() + "_신청서."+ vo.getFileExtsn();
vo.setOrignlFileNm(renamedFileName);
//buffer에 해당파일의 stream을 입력한다.
fis = new FileInputStream(vo.getFileStreCours() + "/" + vo.getStreFileNm());
bis = new BufferedInputStream(fis,size);
//zip에 넣을 다음 entry 가져온다.
zos.putArchiveEntry(new ZipArchiveEntry(vo.getOrignlFileNm()));
//준비된 버퍼에서 집출력스트림으로 write 한다.
int len;
while((len = bis.read(buf,0,size)) != -1) zos.write(buf,0,len);
bis.close();
fis.close();
zos.closeArchiveEntry();
}
zos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally{
if( zos != null ) zos.close();
if( fis != null ) fis.close();
if( bis != null ) bis.close();
}
File uFile = new File(fvoList.get(0).getFileStreCours(), orgnZipNm);
long fSize = uFile.length();
if (fSize > 0) {
String mimetype = "application/x-msdownload";
response.setContentType(mimetype);
setDisposition(orgnZipNm, request, response);
//response.setContentLength(fSize);
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(uFile));
out = new BufferedOutputStream(response.getOutputStream());
FileCopyUtils.copy(in, out);
out.flush();
} catch (Exception ex) {
LOGGER.debug("IGNORED: {}", ex.getMessage());
} finally {
if (in != null) {
try {
in.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
if (out != null) {
try {
out.close();
} catch (Exception ignore) {
LOGGER.debug("IGNORED: {}", ignore.getMessage());
}
}
}
//파일 다운로드 파일 삭제
File delFile = new File(outZipNm);
delFile.delete();
} else {
response.setContentType("application/x-msdownload");
PrintWriter printwriter = response.getWriter();
printwriter.println("<html>");
printwriter.println("<br><br><br><h2>Could not get file name:<br>" + orgnZipNm + "</h2>");
printwriter.println("<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>");
printwriter.println("<br><br><br>&copy; webAccess");
printwriter.println("</html>");
printwriter.flush();
printwriter.close();
}
//파일 다운로드 파일 삭제
File delFile = new File(outZipNm);
delFile.delete();
} else {
response.setContentType("application/x-msdownload");
PrintWriter printwriter = response.getWriter();
printwriter.println("<html>");
printwriter.println("<br><br><br><h2>Could not get file name:<br>" + orgnZipNm + "</h2>");
printwriter.println("<br><br><br><center><h3><a href='javascript: history.go(-1)'>Back</a></h3></center>");
printwriter.println("<br><br><br>&copy; webAccess");
printwriter.println("</html>");
printwriter.flush();
printwriter.close();
}catch(Exception ex) {
ex.printStackTrace();
}
}
/**

View File

@ -18,6 +18,8 @@
<result property="streFileNm" column="STRE_FILE_NM" columnIndex="8"/>
<result property="creatDt" column="CREAT_DT" columnIndex="9"/>
<result property="fileSize" column="FILE_SIZE" columnIndex="10"/>
<result property="scholInsttNm" column="scholInsttNm" columnIndex="11"/>
<result property="chrgNm" column="chrgNm" columnIndex="12"/>
</resultMap>
<resultMap id="fileDetail" class="kcc.com.cmm.service.FileVO">
@ -87,6 +89,46 @@
ORDER BY b.FILE_SN
</select>
<select id="FileManageDAO.selectZipFileExprnList" parameterClass="FileVO" resultMap="fileList" >
/* FileManageDAO.selectZipFileExprnList */
SELECT
a.ATCH_FILE_ID, b.FILE_CN, b.FILE_SN, b.FILE_STRE_COURS, b.STRE_FILE_NM,
b.FILE_EXTSN, b.ORIGNL_FILE_NM, b.FILE_SIZE, TO_CHAR(a.CREAT_DT, 'YYYY-MM-DD HH24:MI:SS' ) AS CREAT_DT
, c.schol_instt_nm AS scholInsttNm
, c.chrg_nm AS chrgNm
FROM
LETTNFILE a, LETTNFILEDETAIL b, VE_EDU_APLCT c
WHERE
a.ATCH_FILE_ID = b.ATCH_FILE_ID
AND
a.ATCH_FILE_ID =c.SCHOL_SEAL_ATCH_FILE_ID
AND
a.USE_AT = 'Y'
<isEqual property="downloadType" compareValue="A">
AND a.ATCH_FILE_ID IN
<iterate property="atchFileIdList" open="(" close=")" conjunction=",">
#atchFileIdList[]#
</iterate>
<isNotEmpty property="fileSn">
AND b.FILE_SN = #fileSn#
</isNotEmpty>
</isEqual>
<isEqual property="downloadType" compareValue="B">
AND a.ATCH_FILE_ID = #atchFileId#
AND b.FILE_SN IN
<iterate property="atchFileSnList" open="(" close=")" conjunction=",">
#atchFileSnList[]#
</iterate>
</isEqual>
ORDER BY b.FILE_SN
</select>
<insert id="FileManageDAO.insertFileMaster" parameterClass="FileVO" >
<![CDATA[
INSERT INTO LETTNFILE
@ -278,7 +320,7 @@
</update>
<select id="FileManageDAO.selectZipFileOrderList" parameterClass="FileVO" resultMap="fileList" >
/* FileManageDAO.selectZipFileList */
/* FileManageDAO.selectZipFileOrderList */
SELECT
a.ATCH_FILE_ID, b.FILE_CN, b.FILE_SN, b.FILE_STRE_COURS, b.STRE_FILE_NM,
b.FILE_EXTSN, b.ORIGNL_FILE_NM, b.FILE_SIZE, TO_CHAR(a.CREAT_DT, 'YYYY-MM-DD HH24:MI:SS' ) AS CREAT_DT