diff --git a/src/main/java/itn/let/fax/user/web/FaxRestController.java b/src/main/java/itn/let/fax/user/web/FaxRestController.java index dc22c307..16dfbb94 100644 --- a/src/main/java/itn/let/fax/user/web/FaxRestController.java +++ b/src/main/java/itn/let/fax/user/web/FaxRestController.java @@ -198,7 +198,7 @@ public class FaxRestController { } - + } diff --git a/src/main/java/itn/let/mjo/test/service/TestVO.java b/src/main/java/itn/let/mjo/test/service/TestVO.java new file mode 100644 index 00000000..5bfdb92d --- /dev/null +++ b/src/main/java/itn/let/mjo/test/service/TestVO.java @@ -0,0 +1,18 @@ +package itn.let.mjo.test.service; + +public class TestVO { + + private String fileNm; + + public String getFileNm() { + return fileNm; + } + + public void setFileNm(String fileNm) { + this.fileNm = fileNm; + } + + + + +} diff --git a/src/main/java/itn/let/mjo/test/web/TestController.java b/src/main/java/itn/let/mjo/test/web/TestController.java index 245302a2..a17472d4 100644 --- a/src/main/java/itn/let/mjo/test/web/TestController.java +++ b/src/main/java/itn/let/mjo/test/web/TestController.java @@ -1,7 +1,16 @@ package itn.let.mjo.test.web; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.math.RoundingMode; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.ArrayList; @@ -13,25 +22,42 @@ import java.util.List; import java.util.Map; import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.mail.internet.ContentDisposition; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.apache.commons.lang.StringUtils; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.rendering.ImageType; +import org.apache.pdfbox.rendering.PDFRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.SystemEnvironmentPropertySource; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.FileSystemResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; +import org.springframework.web.util.UriUtils; import egovframework.rte.fdl.idgnr.EgovIdGnrService; import egovframework.rte.fdl.security.userdetails.util.EgovUserDetailsHelper; @@ -83,6 +109,7 @@ import itn.let.utl.user.service.CheckFileUtil; import itn.let.utl.user.service.CheckLoginUtil; import itn.let.utl.user.service.CheckNoServiceCommon; + @Controller public class TestController { @@ -1909,6 +1936,8 @@ public class TestController { //일괄변환에 의한 단문, 장문 별개로 전송을 했기 때문에 각각 전송 결과 건수를 합쳐준 후 결과를 modelAndView로 리턴해준다. String returnMessage = ""; String returnStatus = ""; + String msgGroupIdListComma = ""; + String msgTypeListComma = ""; //그림 결과 내용 if(!returnImgMap.isEmpty()) { @@ -1925,6 +1954,7 @@ public class TestController { returnMessage = returnImgMap.get("message"); returnStatus = returnImgMap.get("result"); + msgGroupIdListComma = returnImgMap.get("msgGroupId"); }else { returnMessage = returnImgMap.get("message"); @@ -1955,6 +1985,12 @@ public class TestController { returnMessage = returnLongMap.get("message"); returnStatus = returnLongMap.get("result"); + msgGroupIdListComma = StringUtils.isNotEmpty(msgGroupIdListComma) + ? msgGroupIdListComma+","+returnLongMap.get("msgGroupId") + : returnLongMap.get("msgGroupId"); + msgTypeListComma = StringUtils.isNotEmpty(msgTypeListComma) + ? msgTypeListComma+","+"6" + : "6"; }else { returnMessage = returnLongMap.get("message"); @@ -1985,6 +2021,12 @@ public class TestController { returnMessage = returnShortMap.get("message"); returnStatus = returnShortMap.get("result"); + msgGroupIdListComma = StringUtils.isNotEmpty(msgGroupIdListComma) + ? msgGroupIdListComma+","+returnShortMap.get("msgGroupId") + : returnShortMap.get("msgGroupId"); + msgTypeListComma = StringUtils.isNotEmpty(msgTypeListComma) + ? msgTypeListComma+","+"4" + : "4"; }else { returnMessage = returnShortMap.get("message"); @@ -2000,8 +2042,8 @@ public class TestController { } - modelAndView.addObject("msgType", mjonMsgVO.getMsgType()); - modelAndView.addObject("msgGroupId", mjonMsgVO.getMsgGroupId()); + modelAndView.addObject("msgType", msgTypeListComma); + modelAndView.addObject("msgGroupId", msgGroupIdListComma); modelAndView.addObject("message", returnMessage); modelAndView.addObject("result", returnStatus); modelAndView.addObject("resultSts", resultSts); @@ -2545,7 +2587,7 @@ public class TestController { } System.out.println("========================================================================="); - System.out.println("+++++++++++++++++++++++++++++++++++++++++++ resultSts ::: " + resultSts); + System.out.println(" 25xx +++++++++++++++++++++++++++++++++++++++++++ resultSts ::: " + resultSts); System.out.println("========================================================================="); try { @@ -2645,6 +2687,8 @@ public class TestController { returnMap.put("message", "문자 전송이 완료되었습니다."); returnMap.put("result", "success"); + returnMap.put("msgGroupId", mjonMsgVO.getMsgGroupId()); + returnMap.put("resultSts", Integer.toString(resultSts)); returnMap.put("resultSts", Integer.toString(resultSts)); returnMap.put("resultBlockSts", Integer.toString(resultBlockSts)); return returnMap; @@ -3038,9 +3082,198 @@ public class TestController { + + @RequestMapping(value= {"/web/user/login/fileTest.do"}) + public void downloadAndSaveFile() throws Exception { + + String downloadUrl = "http://192.168.0.11:5000/converHWPtoPDF"; + String filePath = "D:\\Development\\test_dev"; + String fileNm = "저작권분쟁조정규칙(20220516)"; +// String fileNm = "testFileName(20220516)"; + String fileExt = ".pdf"; + String cnvtfileExt = ".jpg"; + + + + byte[] fileData = fileSendAnddownloadFile(downloadUrl, filePath + File.separator + fileNm + ".hwp"); +// byte[] fileData = downloadFile(downloadUrl, fileNm); + this.saveFile(fileData, filePath, fileNm+fileExt); + this.pdfToJpg(filePath, fileNm, fileExt, cnvtfileExt); + } + + /** + * @methodName : fileSendAnddownloadFile + * @author : 이호영 + * @date : 2023.08.04 + * @description : 파일을 보내서 PFD로 변환한 파일을 받는다 + * @param downloadUrl + * @param filePathNm + * @return + * @throws IOException + */ + public byte[] fileSendAnddownloadFile(String downloadUrl, String filePathNm) throws IOException { + RestTemplate restTemplate = new RestTemplate(); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + // Create a ByteArrayResource to wrap the file content without relying on the file system + FileSystemResource fileResource = new FileSystemResource(filePathNm); + + // To ensure correct encoding for non-ASCII characters + String encodedFilename = UriUtils.encode(fileResource.getFilename(), "UTF-8"); + + // Create a new HttpEntity for file and use encoded filename + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("file", new ByteArrayResource(Files.readAllBytes(fileResource.getFile().toPath())) { + @Override + public String getFilename() { + return encodedFilename; + } + }); + + + + HttpEntity> entity = new HttpEntity<>(body, headers); + + ResponseEntity responseEntity = restTemplate.exchange(downloadUrl, HttpMethod.POST, entity, byte[].class); + + if (responseEntity.getStatusCodeValue() == 200) { + return responseEntity.getBody(); + } else { + throw new RuntimeException("Failed to download file from " + downloadUrl); + } + } + + /** + * @methodName : downloadFile + * @author : 이호영 + * @date : 2023.08.04 + * @description : 서버에 파일을 요청해서 받는 형식 + * @param downloadUrl + * @param fileNm + * @return + public byte[] downloadFile(String downloadUrl, String fileNm) { + RestTemplate restTemplate = new RestTemplate(); + + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("fileNm", fileNm); + HttpEntity> entity = new HttpEntity<>(body, headers); + + + ResponseEntity responseEntity = restTemplate.exchange(downloadUrl, HttpMethod.POST, entity, byte[].class); + +// System.out.println("responseEntity :: "+ responseEntity); + if (responseEntity.getStatusCodeValue() == 200) { + return responseEntity.getBody(); + } else { + throw new RuntimeException("Failed to download file from " + downloadUrl); + } + } + */ + /** + * @methodName : saveFile + * @author : 이호영 + * @date : 2023.08.04 + * @description : 파일 저장 + * @param fileData + * @param filePath + * @param fileNm + */ + public void saveFile(byte[] fileData, String filePath, String fileNm) { + Path path = Paths.get(filePath, fileNm); + + try { + Files.write(path, fileData); + } catch (IOException e) { + throw new RuntimeException("Failed to save file to " + filePath, e); + } + } + /** + * @methodName : pdfToJpg + * @author : 이호영 + * @date : 2023.08.04 + * @description : 저장한 파일을 불러와서 파일명의 폴더를 생성하여 jpg로 저장 + * @param filePath + * @param fileNm + * @param oriFileExt + * @param cnvtfileExt + * @throws Exception + */ + public void pdfToJpg(String filePath, String fileNm, String oriFileExt, String cnvtfileExt) throws Exception { + + File file = new File(filePath + File.separator + fileNm + oriFileExt); + PDDocument document = PDDocument.load(file); + try { + + int pageCount = document.getNumberOfPages(); + PDFRenderer pdfRenderer = new PDFRenderer(document); + + System.out.println("pageCount : "+ pageCount); + + String saveFilePath = this.filePathChk(filePath + File.separator +fileNm); + + if(StringUtils.isNotEmpty(saveFilePath)) + { + + for (int i = 0; i < pageCount; i++) { + + BufferedImage imageObj = pdfRenderer.renderImageWithDPI(i, 100, ImageType.RGB); + File outputfile = new File(saveFilePath + File.separator + fileNm + i + cnvtfileExt); + ImageIO.write(imageObj, "jpg", outputfile); + } + } + + + } catch (Exception e) { + e.printStackTrace(); + // TODO: handle exception + }finally { + if (document != null) { + document.close(); + } + } + + } + + /** + * @methodName : filePathChk + * @author : 이호영 + * @date : 2023.08.04 + * @description : jpg 파일 저장할 디렉토리 생성 + * @param filePath + * @return + */ + private String filePathChk(String filePath) { + // TODO Auto-generated method stub + String directoryPath = filePath; + + Path path = Paths.get(directoryPath); + + if (!Files.exists(path)) { + try { + + Files.createDirectories(path); + System.out.println("Directory created"); + return directoryPath; + } catch (IOException e) { + throw new RuntimeException("Failed to create directory!", e); + } + } else { + System.out.println("Directory already exists"); + } + + return null; + + } + } diff --git a/src/main/webapp/WEB-INF/jsp/uss/ion/apikey/UserAPIKEYModify.jsp b/src/main/webapp/WEB-INF/jsp/uss/ion/apikey/UserAPIKEYModify.jsp index acd465b0..4a6a8ef5 100644 --- a/src/main/webapp/WEB-INF/jsp/uss/ion/apikey/UserAPIKEYModify.jsp +++ b/src/main/webapp/WEB-INF/jsp/uss/ion/apikey/UserAPIKEYModify.jsp @@ -649,8 +649,10 @@ function fnSelectMber(mberId) { - + @@ -667,6 +669,10 @@ function fnSelectMber(mberId) { onclick="fn_delete('Y'); return false;"> + + + diff --git a/src/main/webapp/WEB-INF/jsp/web/api/appMgmt.jsp b/src/main/webapp/WEB-INF/jsp/web/api/appMgmt.jsp index fb41db38..6298b82d 100644 --- a/src/main/webapp/WEB-INF/jsp/web/api/appMgmt.jsp +++ b/src/main/webapp/WEB-INF/jsp/web/api/appMgmt.jsp @@ -322,7 +322,7 @@ function fn_reg_user_4_apikey(){ - + ${apiVO.frstRegistPnttm} ${apiVO.lastUpdtPnttm} 승인 @@ -366,7 +366,7 @@ function fn_reg_user_4_apikey(){ - + ${apiVO.lastUpdtPnttm} @@ -377,11 +377,11 @@ function fn_reg_user_4_apikey(){ 사용 - + - <%-- + ${apiVO.lastUpdtPnttm} @@ -392,10 +392,9 @@ function fn_reg_user_4_apikey(){ 미사용 - - + - --%> + API KEY 발급 내역이 없습니다. @@ -427,7 +426,7 @@ function fn_reg_user_4_apikey(){ - + ${result.frstRegistPnttm} @@ -461,8 +460,9 @@ function fn_reg_user_4_apikey(){ -

* 대역 등록을 원하실 경우 상위 IP만 작성하시면 됩니다. ex) 92.168.255.0 ~ 192.168.255.255 대역을 등록할 경우 192.168. 255. 입력

-

* IP는 최대 10개까지 등록 가능합니다. 단, IP 대역은 1개의 IP로 계산합니다.

+ + +

* IP는 최대 10개까지 등록 가능합니다. 단, IP 대역은 1개의 IP로 계산합니다.

diff --git a/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp index 3ea3a456..dd42e1ea 100644 --- a/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp +++ b/src/main/webapp/sample_mjon/jsp_example_send_msg_r1.jsp @@ -25,7 +25,7 @@ //회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용 //실제서비스용 final String mberId = "dudgusw"; //문자온 로그인 아이디 - final String apiKey = "769089bdd0363e0d0b1d20761a8d013bd"; //발급받은 api ke + final String apiKey = "0096519c62100b9eea77c040a6045c"; //발급받은 api ke //테스트용 diff --git a/src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp b/src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp index d7683df5..29f2e5e0 100644 --- a/src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp +++ b/src/main/webapp/sample_mjon/jsp_example_send_msgs_r1.jsp @@ -25,7 +25,7 @@ //회원아이디, APIKEY - 보안을 위해 실제 서비스 시에는 이곳에 mberId와 apiKey 값을 적어서 사용 //실제서비스용 final String mberId = "dudgusw"; //문자온 로그인 아이디 - final String apiKey = "769089bdd0363e0d0b1d20761a8d013bd"; //발급받은 api key + final String apiKey = "0096519c62100b9eea77c040a6045c"; //발급받은 api ke //테스트용