diff --git a/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java index 022cbef..318e91b 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java +++ b/src/main/java/com/xit/biz/ctgy/v2/controller/ParkingController.java @@ -116,10 +116,24 @@ public class ParkingController { } @Secured(policy = SecurityPolicy.TOKEN) - @Operation(summary = "주정차 이미지 조회" , description = "주정차 이미지 조회") - @GetMapping(value = "/judge/{rcMaincode}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity findImageByRcMaincode(@PathVariable final Long rcMaincode) { - return RestResponse.of(service.findImageByRcMaincode(rcMaincode)); + @Operation(summary = "주정차 단속 이미지 조회" , description = "주정차 단속 이미지 조회") + @GetMapping(value = "/judge/picad/{rcMaincode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findPicadImageByRcMaincode(@PathVariable final Long rcMaincode) { + return RestResponse.of(service.findPicadImageByRcMaincode(rcMaincode)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 진술서 이미지 조회" , description = "주정차 진술서 이미지 조회") + @GetMapping(value = "/judge/frecad/{rcMaincode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findFrecadImageByRcMaincode(@PathVariable final Long rcMaincode) { + return RestResponse.of(service.findFrecadImageByRcMaincode(rcMaincode)); + } + + @Secured(policy = SecurityPolicy.TOKEN) + @Operation(summary = "주정차 첨부자료 이미지 조회" , description = "주정차 첨부자료 이미지 조회") + @GetMapping(value = "/judge/contad/{rcMaincode}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findContadImageByRcMaincode(@PathVariable final Long rcMaincode) { + return RestResponse.of(service.findContadImageByRcMaincode(rcMaincode)); } @Secured(policy = SecurityPolicy.TOKEN) diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java index 8e23e17..4ca3c5e 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ParkingDao.java @@ -3,10 +3,8 @@ package com.xit.biz.ctgy.v2.repository; import com.xit.biz.ctgy.dto.*; import com.xit.core.config.database.BaseMpowerDaoSupport; import com.xit.core.oauth2.config.properties.MasterDatabaseProperties; -import com.xit.core.oauth2.config.properties.SlaveDatabaseProperties; import com.xit.core.oauth2.utils.HeaderUtil; import com.xit.core.support.sql.parser.QueryGenerator; -import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Repository; @@ -224,8 +222,15 @@ public class ParkingDao extends BaseMpowerDaoSupport { update(sql); } - public ParkingImageDto findImageByRcMaincode(Long rcMaincode) { - ParkingImageDto dto = getPicadImgList(String.valueOf(rcMaincode)); - return dto; + public List> findPicadImageByRcMaincode(@NotNull final Long rcMaincode) { + return getPicadImgList(String.valueOf(rcMaincode)); + } + + public List> findFrecadImageByRcMaincode(@NotNull final Long rcMaincode) { + return getPicadImgList(String.valueOf(rcMaincode)); + } + + public List> findContadImageByRcMaincode(@NotNull final Long rcMaincode) { + return getPicadImgList(String.valueOf(rcMaincode)); } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java index d8a5269..4e54cb4 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/IParkingService.java @@ -1,12 +1,12 @@ package com.xit.biz.ctgy.v2.service; -import com.xit.biz.ctgy.dto.GnRecallScDto; import com.xit.biz.ctgy.dto.JudgeListDto; import com.xit.biz.ctgy.dto.ParkingImageDto; import com.xit.biz.ctgy.dto.ParkingTargetDto; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import javax.validation.constraints.NotNull; import java.util.List; import java.util.Map; @@ -36,5 +36,8 @@ public interface IParkingService { void saveJudgeResult(JudgeListDto dto); - ParkingImageDto findImageByRcMaincode(Long rcMaincode); + List> findPicadImageByRcMaincode(@NotNull final Long rcMaincode); + + List> findFrecadImageByRcMaincode(@NotNull final Long rcMaincode); + List> findContadImageByRcMaincode(@NotNull final Long rcMaincode); } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java index 484cc94..ccba808 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ParkingService.java @@ -12,11 +12,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; +import javax.validation.constraints.NotNull; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -178,7 +175,17 @@ public class ParkingService implements IParkingService { } @Override - public ParkingImageDto findImageByRcMaincode(Long rcMaincode) { - return parkingDao.findImageByRcMaincode(rcMaincode); + public List> findPicadImageByRcMaincode(@NotNull final Long rcMaincode) { + return parkingDao.findPicadImageByRcMaincode(rcMaincode); + } + + @Override + public List> findFrecadImageByRcMaincode(@NotNull final Long rcMaincode) { + return parkingDao.findFrecadImageByRcMaincode(rcMaincode); + } + + @Override + public List> findContadImageByRcMaincode(@NotNull final Long rcMaincode) { + return parkingDao.findContadImageByRcMaincode(rcMaincode); } } diff --git a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java index 71294ef..2141c92 100644 --- a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java +++ b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java @@ -1,6 +1,7 @@ package com.xit.core.config.database; import com.plf.client.Client; +import com.xit.Application; import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.ctgy.CtgyConstants; import com.xit.biz.ctgy.dto.ParkingImageDto; @@ -22,6 +23,7 @@ import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.util.ResourceUtils; +import java.io.File; import java.io.IOException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -501,41 +503,66 @@ public abstract class BaseMpowerDaoSupport { log.info("웹서버 저장되는 첨부파일 위치:"+savedImgPath); } - public ParkingImageDto getPicadImgList(String photocode){ - ParkingImageDto dto = new ParkingImageDto(); - + public List> getPicadImgList(String photocode){ + List> list = new ArrayList<>(); + Client client = new Client(fileHostIp, fileHostPort); - - String imgPath = picadPath + getAbsImgPath(photocode); //터널링에 저장된 단속사진 경로 - log.info("최종이미지경로:::::" + imgPath); + String filePath = getAbsImgPath(photocode); + String svrImgPath = picadPath + filePath; //터널링에 저장된 단속사진 경로 + log.info("Mpower 이미지경로:::::" + svrImgPath); try{ client.getConnection(fileServiceName); - client.setInput("dnfile1",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "A.jpg"); //터널링에 실질 존재하는 경로,파일명 - log.info("사진이름:" + CommUtil.lpad(photocode, '0', 10)); - client.setInput("dnfile2",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "B.jpg"); - client.setInput("dnfile3",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "C.jpg"); - client.setInput("dnfile4",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "D.jpg"); + + String mpowerFilePre = svrImgPath + "/P" + CommUtil.lpad(photocode, '0', 10); + log.info("Mpower 이미지 file name :::::" + mpowerFilePre + "A, B, C, D.jpg"); + client.setInput("imageA",mpowerFilePre + "A.jpg"); //터널링에 실질 존재하는 경로,파일명 + client.setInput("imageB",mpowerFilePre + "B.jpg"); + client.setInput("imageC",mpowerFilePre + "C.jpg"); + client.setInput("imageD",mpowerFilePre + "D.jpg"); client.Request(); String result = client.getString("result", 0, 0); if (result.equals("true")){ - client.getFileName("imageA"); - client.getFileName("imageB"); - client.getFileName("imageC"); - client.getFileName("imageD"); - client.savefile("imageA", savedImgPath); - client.savefile("imageB", savedImgPath); - client.savefile("imageC", savedImgPath); - client.savefile("imageD", savedImgPath); - - //String strpath = "/vioPhoto/"+sessionId+"/P" + CommUtil.lpad(photocode, '0', 10); - String strpath = savedImgPath + "/P" + CommUtil.lpad(photocode, '0', 10); - log.info("strPath ::: " + strpath); - dto.setScPicad1(strpath + "A.jpg"); - dto.setScPicad1(strpath + "B.jpg"); - dto.setScPicad1(strpath + "C.jpg"); - dto.setScPicad1(strpath + "D.jpg"); + String svrSavedPhotoPath = savedImgPath + "/" + filePath; + String strpath = svrSavedPhotoPath + "/P" + CommUtil.lpad(photocode, '0', 10); + log.info("서버 download file path :::::" + svrSavedPhotoPath); + log.info("서버 download file name :::::" + strpath + "A, B, C, D.jpg"); + + File file = new File(svrSavedPhotoPath); + if(!file.exists()) file.mkdirs(); + + if(Checks.isNotEmpty(client.getFileName("imageA"))){ + client.savefile("imageA", svrSavedPhotoPath); + setFileInfo(list, client.getFileName("imageA"), strpath); + log.info("서버 file name :::::" + strpath + client.getFileName("imageA")); + }else{ + setNoFileInfo(list); + }; + + if(Checks.isNotEmpty(client.getFileName("imageB"))){ + client.savefile("imageB", svrSavedPhotoPath); + setFileInfo(list, client.getFileName("imageB"), strpath); + log.info("서버 file name :::::" + strpath + client.getFileName("imageB")); + }else{ + setNoFileInfo(list);; + }; + if(Checks.isNotEmpty(client.getFileName("imageC"))){ + client.savefile("imageC", svrSavedPhotoPath); + setFileInfo(list, client.getFileName("imageC"), strpath); + log.info("서버 file name :::::" + strpath + client.getFileName("imageC")); + }else{ + setNoFileInfo(list);; + }; + if(Checks.isNotEmpty(client.getFileName("imageD"))){ + client.savefile("imageD", svrSavedPhotoPath); + setFileInfo(list, client.getFileName("imageD"), strpath); + log.info("서버 file name :::::" + strpath + client.getFileName("imageD")); + }else{ + setNoFileInfo(list);; + }; + log.info("서버로 다운로드된 file ::: {}{}{}{}", client.getFileName("imageA"), client.getFileName("imageB"), client.getFileName("imageC"), client.getFileName("imageD")); + }else{ throw new MpowerException("MPower File download error::"+result); } @@ -543,9 +570,83 @@ public abstract class BaseMpowerDaoSupport { throw new MpowerException("MPower File download error::"+e.getLocalizedMessage()); } //logger.debug(fph); - return dto; + return list; } + private void setFileInfo(List> list, String imgName, String strpath) { + Map map = new HashMap<>(); + map.put("imgName", imgName); + map.put("url", strpath + imgName); + list.add(map); + } + + private void setNoFileInfo(List> list) { + Map map = new HashMap<>(); + map.put("imgName", ""); + map.put("url", "/images/noFile.png"); + list.add(map); + } + +// public ParkingImageDto getPicadImgList2(String photocode){ +// ParkingImageDto dto = new ParkingImageDto(); +// +// Client client = new Client(fileHostIp, fileHostPort); +// +// String path = Application.class.getResource("").getPath(); +// path = path.replace("WEB-INF/classes/com/xit", "vioPhoto/picad/"); +// if(path.substring(0,1).equals("/")){ +// path = path.substring(1); +// } +// File file = new File(path); +// if(!file.exists()) file.mkdirs(); +// +// String imgPath = picadPath + getAbsImgPath(photocode); //터널링에 저장된 단속사진 경로 +// log.info("최종이미지경로:::::" + imgPath); +// +// try{ +// client.getConnection(fileServiceName); +// client.setInput("dnfile1",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "A.jpg"); //터널링에 실질 존재하는 경로,파일명 +// log.info("사진이름:" + CommUtil.lpad(photocode, '0', 10)); +// +// client.setInput("dnfile2",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "B.jpg"); +// client.setInput("dnfile3",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "C.jpg"); +// client.setInput("dnfile4",imgPath+ "/P" + CommUtil.lpad(photocode, '0', 10) + "D.jpg"); +// +// client.Request(); +// String result = client.getString("result", 0, 0); +// +// if (result.equals("true")){ +// log.info("{}{}{}{}", client.getFileName("dnfile1"), client.getFileName("dnfile2"), client.getFileName("dnfile3"), client.getFileName("dnfile4")); +// log.info("{}{}{}{}", client.getFileName("imageA"), client.getFileName("imageB"), client.getFileName("imageC"), client.getFileName("imageD")); +// +// client.getFileName("imageA"); +// client.getFileName("imageB"); +// client.getFileName("imageC"); +// client.getFileName("imageD"); +// client.savefile("imageA", path); +// client.savefile("imageB", path); +// client.savefile("imageC", path); +// client.savefile("imageD", path); +// log.info("{}{}{}{}", client.getFileName("dnfile1"), client.getFileName("dnfile2"), client.getFileName("dnfile3"), client.getFileName("dnfile4")); +// log.info("{}{}{}{}", client.getFileName("imageA"), client.getFileName("imageB"), client.getFileName("imageC"), client.getFileName("imageD")); +// +// //String strpath = "/vioPhoto/"+sessionId+"/P" + CommUtil.lpad(photocode, '0', 10); +// String strpath = "/vioPhoto/picad" + "/P" + CommUtil.lpad(photocode, '0', 10); +// log.info("strPath ::: " + strpath); +// dto.setScPicad1(strpath + "A.jpg"); +// dto.setScPicad2(strpath + "B.jpg"); +// dto.setScPicad3(strpath + "C.jpg"); +// dto.setScPicad4(strpath + "D.jpg"); +// }else{ +// throw new MpowerException("MPower File download error::"+result); +// } +// }catch(Exception e){ +// throw new MpowerException("MPower File download error::"+e.getLocalizedMessage()); +// } +// //logger.debug(fph); +// return dto; +// } + /** * Mpower 단속사진 저장 경로 * @param code @@ -562,26 +663,22 @@ public abstract class BaseMpowerDaoSupport { private String getImgPath(double intCode, String baseDir, int baseValue){ - String tmpDir = ""; + if(intCode <= baseValue) return baseDir; - if(intCode <= baseValue){ - tmpDir = baseDir; - }else{ - int tmpL = (int)intCode/baseValue; //나눈값 - double dtmpL = intCode/baseValue; //나눈값 + int tmpL = (int)intCode/baseValue; //나눈값 + double dtmpL = intCode/baseValue; //나눈값 - String tmpS = String.valueOf(dtmpL); - tmpS = tmpS.substring(tmpS.indexOf(".")+1); + String tmpS = String.valueOf(dtmpL); + tmpS = tmpS.substring(tmpS.indexOf(".")+1); - int tmpM = Integer.parseInt(tmpS); + int tmpM = Integer.parseInt(tmpS); - if(tmpM > 0) tmpL = tmpL+1; + if(tmpM > 0) tmpL = tmpL+1; - StringBuilder stmpL = new StringBuilder(String.valueOf(tmpL)); - int tmpCnt = baseDir.length() - stmpL.length(); - for(int i = 0; i < tmpCnt; i++) stmpL.insert(0, "0"); - } - return tmpDir; + StringBuilder stmpL = new StringBuilder(String.valueOf(tmpL)); + int tmpCnt = baseDir.length() - stmpL.length(); + for(int i = 0; i < tmpCnt; i++) stmpL.insert(0, "0"); + return stmpL.toString(); } }