442 lines
15 KiB
Java
442 lines
15 KiB
Java
package seed.com.gtm.seedfile;
|
|
|
|
import java.io.File;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpSession;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import egovframework.rte.fdl.property.EgovPropertyService;
|
|
import egovframework.rte.psl.dataaccess.util.EgovMap;
|
|
import seed.com.gtm.dao.SeedFileDao;
|
|
import seed.com.gtm.service.BaseService;
|
|
import seed.utils.SeedDateUtil;
|
|
import seed.utils.SeedProperties;
|
|
import seed.utils.SeedUtils;
|
|
|
|
@Service
|
|
public class SeedFileService {
|
|
|
|
/*AS-IS 분쟁조정은 config.properties에서 프로퍼티 호출
|
|
현재는 globals.properties 프로퍼티 호출*/
|
|
|
|
@Autowired
|
|
private SeedFileDao dao;
|
|
|
|
@Autowired
|
|
private BaseService bservice;
|
|
|
|
@Resource(name = "propertiesService")
|
|
protected EgovPropertyService propertyService;
|
|
|
|
//임시 파일 저장 경로
|
|
@Value("#{globalSettings['file.temp.path']}")
|
|
private String globalTempPath;
|
|
//파일 저장 경로
|
|
@Value("#{globalSettings['file.real.path']}")
|
|
private String globalRealPath;
|
|
//루트 경로
|
|
@Value("#{globalSettings['root.path']}")
|
|
private String globalRootPath;
|
|
|
|
public void fileInsert(Map<String, Object> paramMap, HttpServletRequest request, HttpSession session){
|
|
|
|
String siteIdx = SeedUtils.setReplaceNull(session.getAttribute("siteIdx"));
|
|
if(siteIdx.equals("")){
|
|
siteIdx = SeedUtils.setReplaceNull(request.getParameter("siteIdx"));
|
|
}
|
|
String fileFuncType = (String)paramMap.get("fileFuncType");
|
|
String fileChgType = (String)paramMap.get("fileChgType");
|
|
|
|
SeedProperties seedProperties = new SeedProperties();
|
|
|
|
/*AS-IS 분쟁조정 첨부파일 경로 설정*/
|
|
/*String rootPath = null;
|
|
String tempPath = seedProperties.getConfigValue("file.temp.path");
|
|
if(fileFuncType.equals("trublchargermng")){
|
|
rootPath = seedProperties.getConfigValue("root.path");
|
|
}else{
|
|
rootPath = seedProperties.getConfigValue("file.real.path");
|
|
}*/
|
|
|
|
String rootPath = null;
|
|
String tempPath = globalTempPath;
|
|
if(fileFuncType.equals("trublchargermng") || fileFuncType.indexOf("X-")>-1){ //gw 연동용 파일
|
|
rootPath = globalRootPath;
|
|
}else{
|
|
rootPath = globalRealPath;
|
|
}
|
|
|
|
|
|
|
|
SeedDateUtil seedDateUtil = new SeedDateUtil();
|
|
String toDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMdd");
|
|
String renameDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMddHHmmss");
|
|
|
|
SeedUtils.setSeedMkDirs(rootPath + "/"+siteIdx+"/"+ fileFuncType);
|
|
|
|
int fileCnt = 0;
|
|
|
|
String[] uploadFileName = request.getParameterValues("uploadFileName");
|
|
String[] uploadFileReName = request.getParameterValues("uploadFileReName");
|
|
String[] copyContractYnList = request.getParameterValues("copyContractYn");
|
|
|
|
try {
|
|
System.out.println("uploadFileName");
|
|
/*System.out.println(uploadFileName.length); */
|
|
}catch(Exception ex) {
|
|
ex.printStackTrace();
|
|
}
|
|
|
|
|
|
if(uploadFileName!=null && uploadFileName.length > 0){
|
|
|
|
for(int i=0; i<uploadFileName.length; i++){
|
|
|
|
String uploadFileNameData = uploadFileName[i];
|
|
String uploadFileReNameData = uploadFileReName[i];
|
|
String copyContractYn = "";
|
|
if(copyContractYnList != null){
|
|
copyContractYn = copyContractYnList[i];
|
|
}
|
|
|
|
String fileType = uploadFileNameData.substring(uploadFileNameData.lastIndexOf(".")+1, uploadFileNameData.length());
|
|
String reFileName = renameDate + "_" + SeedUtils.getSeedMD5Code(String.valueOf(SeedUtils.getRandom(999,1)));
|
|
|
|
File oldFile = null;
|
|
if(fileFuncType.equals("trublchargermng") || fileFuncType.indexOf("X-")>-1){
|
|
oldFile = new File(rootPath + "/"+siteIdx+"/upload/tempFiles/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
}else{
|
|
oldFile = new File(tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
}
|
|
|
|
System.out.println(oldFile.getAbsolutePath());
|
|
|
|
|
|
if(oldFile.exists()){
|
|
Long fileSize = oldFile.length();
|
|
String filePath ="";
|
|
if(fileFuncType.equals("trublchargermng") || fileFuncType.indexOf("X-")>-1){
|
|
SeedUtils.setSeedFileCopy(rootPath + "/"+siteIdx+"/upload/tempFiles/"+fileFuncType+ "/" + uploadFileReNameData,
|
|
rootPath + "/"+siteIdx+"/upload/uploadFiles/"+fileFuncType+"/"+reFileName+"."+fileType);
|
|
|
|
filePath = rootPath + "/"+siteIdx+"/upload/uploadFiles/"+fileFuncType+"/"+reFileName+"."+fileType;
|
|
}else{
|
|
|
|
//241029 - 첨부파일 복사를 위해 real 파일 생성 처리
|
|
/* File makeFile = null;
|
|
makeFile = new File(rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName);
|
|
if(! makeFile.exists()){
|
|
//경로에 해당하는 디렉토리들을 생성
|
|
if(makeFile.getParentFile().mkdirs()){
|
|
try {
|
|
makeFile.createNewFile(); //이후 파일 생성
|
|
} catch (IOException e) {
|
|
// TODO Auto-generated catch block
|
|
}
|
|
}
|
|
}*/
|
|
|
|
SeedUtils.setSeedFileCopy(tempPath + "/"+siteIdx+"/"+fileFuncType + "/" + uploadFileReNameData,
|
|
rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType);
|
|
|
|
filePath = rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType;
|
|
}
|
|
|
|
System.out.println(oldFile.getAbsolutePath());
|
|
|
|
paramMap.put("uploadFileNameData", uploadFileNameData);
|
|
paramMap.put("reFileName", reFileName+"."+fileType);
|
|
paramMap.put("fileSize", fileSize);
|
|
paramMap.put("fileType", fileType);
|
|
paramMap.put("filePath", filePath);
|
|
paramMap.put("copyContractYn", copyContractYn);
|
|
//파일타입에 따라서 sql분기
|
|
if(fileFuncType.equals("mediation")){
|
|
System.out.println(oldFile.getAbsolutePath());
|
|
dao.caseInsert(paramMap);
|
|
}else{
|
|
System.out.println(oldFile.getAbsolutePath());
|
|
|
|
if (!"".equals(fileChgType)) {
|
|
paramMap.put("fileFuncType", fileChgType);
|
|
}
|
|
|
|
System.out.println(paramMap.get("fileText").toString());
|
|
|
|
dao.fileInsert(paramMap);
|
|
}
|
|
|
|
oldFile.delete();
|
|
fileCnt = fileCnt+1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void fileInsertEgov(EgovMap paramMap, HttpServletRequest request, HttpSession session)throws Exception {
|
|
System.out.println(">>>>>>>fileInsertEgov<<<<<<<<<");
|
|
try {
|
|
|
|
String siteIdx = SeedUtils.setReplaceNull(session.getAttribute("siteIdx"));
|
|
if(siteIdx.equals("")){
|
|
siteIdx = SeedUtils.setReplaceNull(request.getParameter("siteIdx"));
|
|
}
|
|
String fileFuncType = (String)paramMap.get("fileFuncType");
|
|
|
|
SeedProperties seedProperties = new SeedProperties();
|
|
|
|
/*String rootPath = seedProperties.getConfigValue("file.real.path");
|
|
String tempPath = seedProperties.getConfigValue("file.temp.path");*/
|
|
|
|
/*241216 global 값으로 수정*/
|
|
/*String rootPath = propertyService.getString("file.real.path");
|
|
String tempPath = propertyService.getString("file.temp.path");*/
|
|
String rootPath = globalRealPath;
|
|
String tempPath = globalTempPath;
|
|
|
|
SeedDateUtil seedDateUtil = new SeedDateUtil();
|
|
String toDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMdd");
|
|
String renameDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMddHHmmss");
|
|
|
|
SeedUtils.setSeedMkDirs(rootPath + "/"+siteIdx+ "/" +fileFuncType);
|
|
|
|
int fileCnt = 0;
|
|
|
|
String[] uploadFileName = request.getParameterValues("uploadFileName");
|
|
String[] uploadFileReName = request.getParameterValues("uploadFileReName");
|
|
String[] copyContractYnList = request.getParameterValues("copyContractYn");
|
|
String[] fileGubun = request.getParameterValues("fileGubun");
|
|
String[] fileMemo = request.getParameterValues("fileMemo");
|
|
|
|
if(uploadFileName!=null && uploadFileName.length > 0){
|
|
|
|
for(int i=0; i<uploadFileName.length; i++){
|
|
|
|
String uploadFileNameData = uploadFileName[i];
|
|
String uploadFileReNameData = uploadFileReName[i];
|
|
String fileGubunData = fileGubun[i];
|
|
String fileMemoData = "";
|
|
|
|
if(fileMemo !=null && fileMemo.length > 0){
|
|
if(uploadFileName.length == fileMemo.length){
|
|
fileMemoData = fileMemo[i];
|
|
}
|
|
}
|
|
|
|
|
|
String copyContractYn = "";
|
|
if(copyContractYnList != null){
|
|
copyContractYn = copyContractYnList[i];
|
|
}
|
|
|
|
String fileType = uploadFileNameData.substring(uploadFileNameData.lastIndexOf(".")+1, uploadFileNameData.length());
|
|
String reFileName = renameDate + "_" + SeedUtils.getSeedMD5Code(String.valueOf(SeedUtils.getRandom(999,1)));
|
|
|
|
File oldFile = new File(tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
System.out.println(">>>>>>>fileInsertEgov0<<<<<<<<<"+tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
if(oldFile.exists()){
|
|
|
|
Long fileSize = oldFile.length();
|
|
|
|
SeedUtils.setSeedFileCopy(tempPath + "/"+siteIdx+"/"+fileFuncType + "/" + uploadFileReNameData,
|
|
rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType);
|
|
|
|
|
|
paramMap.put("uploadFileNameData", uploadFileNameData);
|
|
paramMap.put("reFileName", reFileName+"."+fileType);
|
|
paramMap.put("fileSize", fileSize);
|
|
paramMap.put("fileType", fileType);
|
|
paramMap.put("filePath", rootPath + "/"+siteIdx+"/"+fileFuncType+"/");
|
|
paramMap.put("copyContractYn", copyContractYn);
|
|
paramMap.put("fileGubun", fileGubunData);
|
|
paramMap.put("fileMemo", fileMemoData);
|
|
//파일타입에 따라서 sql분기
|
|
/*if(fileFuncType.equals("mediation")){
|
|
dao.caseInsert(paramMap);
|
|
}else{
|
|
dao.fileInsert(paramMap);
|
|
}*/
|
|
System.out.println(">>>>>>>fileInsertEgov1<<<<<<<<<");
|
|
bservice.insert(paramMap);
|
|
System.out.println(">>>>>>>fileInsertEgov2<<<<<<<<<");
|
|
|
|
oldFile.delete();
|
|
fileCnt = fileCnt+1;
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
public void fileInsertSameTime(EgovMap paramMap, HttpServletRequest request, HttpSession session)throws Exception {
|
|
System.out.println(">>>>>>>fileInsertEgov<<<<<<<<<");
|
|
try {
|
|
|
|
String siteIdx = SeedUtils.setReplaceNull(session.getAttribute("siteIdx"));
|
|
if(siteIdx.equals("")){
|
|
siteIdx = SeedUtils.setReplaceNull(request.getParameter("siteIdx"));
|
|
}
|
|
String fileFuncType = (String)paramMap.get("fileFuncType");
|
|
String fileGubun = (String)paramMap.get("fileGubun");
|
|
String fileMemo = (String)paramMap.get("fileMemo");
|
|
|
|
SeedProperties seedProperties = new SeedProperties();
|
|
|
|
/*String rootPath = seedProperties.getConfigValue("file.real.path");
|
|
String tempPath = seedProperties.getConfigValue("file.temp.path");*/
|
|
|
|
/*241216 global 값으로 수정*/
|
|
/*String rootPath = propertyService.getString("file.real.path");
|
|
String tempPath = propertyService.getString("file.temp.path");*/
|
|
String rootPath = globalRealPath;
|
|
String tempPath = globalTempPath;
|
|
|
|
SeedDateUtil seedDateUtil = new SeedDateUtil();
|
|
String toDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMdd");
|
|
String renameDate = seedDateUtil.getSimpleDateFormat(new Date(), "yyyyMMddHHmmss");
|
|
|
|
SeedUtils.setSeedMkDirs(rootPath + "/"+siteIdx+ "/" +fileFuncType);
|
|
|
|
int fileCnt = 0;
|
|
|
|
String[] uploadFileName = request.getParameterValues("uploadFileName");
|
|
String[] uploadFileReName = request.getParameterValues("uploadFileReName");
|
|
String[] copyContractYnList = request.getParameterValues("copyContractYn");
|
|
String[] uploadFileTarget = request.getParameterValues("uploadFileTarget");
|
|
|
|
if(uploadFileName!=null && uploadFileName.length > 0){
|
|
|
|
for(int i=0; i<uploadFileName.length; i++){
|
|
|
|
String uploadFileNameData = uploadFileName[i];
|
|
String uploadFileReNameData = uploadFileReName[i];
|
|
String fileMemoData = "";
|
|
String uploadFileTargetData = uploadFileTarget[i];
|
|
|
|
|
|
String copyContractYn = "";
|
|
if(copyContractYnList != null){
|
|
copyContractYn = copyContractYnList[i];
|
|
}
|
|
|
|
String fileType = uploadFileNameData.substring(uploadFileNameData.lastIndexOf(".")+1, uploadFileNameData.length());
|
|
String reFileName = renameDate + "_" + SeedUtils.getSeedMD5Code(String.valueOf(SeedUtils.getRandom(999,1)));
|
|
|
|
File oldFile = new File(tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
System.out.println(">>>>>>>fileInsertEgov0<<<<<<<<<"+tempPath + "/"+siteIdx+"/"+fileFuncType+ "/" + uploadFileReNameData);
|
|
if(oldFile.exists()){
|
|
|
|
Long fileSize = oldFile.length();
|
|
|
|
SeedUtils.setSeedFileCopy(tempPath + "/"+siteIdx+"/"+fileFuncType + "/" + uploadFileReNameData,
|
|
rootPath + "/"+siteIdx+"/"+fileFuncType+"/"+reFileName+"."+fileType);
|
|
|
|
|
|
paramMap.put("uploadFileNameData", uploadFileNameData);
|
|
paramMap.put("reFileName", reFileName+"."+fileType);
|
|
paramMap.put("fileSize", fileSize);
|
|
paramMap.put("fileType", fileType);
|
|
paramMap.put("filePath", rootPath + "/"+siteIdx+"/"+fileFuncType+"/");
|
|
paramMap.put("copyContractYn", copyContractYn);
|
|
paramMap.put("fileGubun", fileGubun);
|
|
paramMap.put("fileMemo", fileMemo);
|
|
//파일타입에 따라서 sql분기
|
|
/*if(fileFuncType.equals("mediation")){
|
|
dao.caseInsert(paramMap);
|
|
}else{
|
|
dao.fileInsert(paramMap);
|
|
}*/
|
|
System.out.println(">>>>>>>fileInsertEgov1<<<<<<<<<");
|
|
try {
|
|
String[] target = uploadFileTarget[i].split("@");
|
|
|
|
String rceptNo = target[0];
|
|
String caseNo = target[1];
|
|
|
|
paramMap.put("rceptNo", rceptNo);
|
|
paramMap.put("fileAdd1", caseNo);
|
|
bservice.insert(paramMap);
|
|
}catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
System.out.println(">>>>>>>fileInsertEgov2<<<<<<<<<");
|
|
|
|
oldFile.delete();
|
|
fileCnt = fileCnt+1;
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
public List<Map<String, Object>> fileList(Map<String,Object> paramMap){
|
|
return dao.fileList(paramMap);
|
|
}
|
|
|
|
public Map<String, Object> fileOne(Map<String,Object> paramMap){
|
|
return dao.fileOne(paramMap);
|
|
}
|
|
|
|
/*일반 게시판 파일 (T_EXTRA_FILE)*/
|
|
public void fileDel(Map<String,Object> paramMap){
|
|
if(paramMap.get("deleteFileData") != "" && paramMap.get("deleteFileData") != null){
|
|
|
|
String delIdx = (String)paramMap.get("deleteFileData");
|
|
String[] delList = delIdx.split(",");
|
|
|
|
for(int i = 0; i < delList.length; i++){
|
|
paramMap.put("dataIdx", delList[i]);
|
|
dao.fileDel(paramMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*사건관련 파일 (C_CASEFILE)*/
|
|
public void caseFileDel(Map<String,Object> paramMap){
|
|
if(paramMap.get("deleteFileData") != "" && paramMap.get("deleteFileData") != null){
|
|
|
|
String delIdx = (String)paramMap.get("deleteFileData");
|
|
String[] delList = delIdx.split(",");
|
|
for(int i = 0; i < delList.length; i++){
|
|
paramMap.put("dataIdx", delList[i]);
|
|
dao.caseDelete(paramMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void fileDelAll(Map<String,Object> paramMap){
|
|
dao.fileDelAll(paramMap);
|
|
}
|
|
|
|
public List<Map<String, Object>> caseFileList(Map<String,Object> paramMap){
|
|
return dao.caseFileList(paramMap);
|
|
}
|
|
|
|
public List<EgovMap> caseFileListEgov(EgovMap paramMap){
|
|
return dao.caseFileListEgov(paramMap);
|
|
}
|
|
|
|
public Map<String, Object> caseFileOne(Map<String,Object> paramMap){
|
|
return dao.caseFileOne(paramMap);
|
|
}
|
|
|
|
public void hisInsert(Map<String,Object> paramMap){
|
|
dao.hisInsert(paramMap);
|
|
}
|
|
|
|
}
|