diff --git a/src/main/java/com/xit/biz/ctgy/dto/JudgeListDto.java b/src/main/java/com/xit/biz/ctgy/dto/JudgeListDto.java index 7b06c9a..74ab1d0 100644 --- a/src/main/java/com/xit/biz/ctgy/dto/JudgeListDto.java +++ b/src/main/java/com/xit/biz/ctgy/dto/JudgeListDto.java @@ -67,9 +67,13 @@ public class JudgeListDto { private LocalDate msuIndate; @Schema(required = true, title = "위반일자", example = " ", description = "위반일자") - private String scWdate; + private String msWdate; @Schema(required = true, title = "위반장소", example = " ", description = "위반장소") - private String scPos; + private String msPos; + @Schema(required = true, title = "메인코드", example = " ", description = "주정차이미지코드") + private Long rcMaincode; + @Schema(required = true, title = "심사자id", example = " ", description = "심사자id") + private String msuUserid; } diff --git a/src/main/java/com/xit/biz/ctgy/dto/ParkingImageDto.java b/src/main/java/com/xit/biz/ctgy/dto/ParkingImageDto.java new file mode 100644 index 0000000..66542e8 --- /dev/null +++ b/src/main/java/com/xit/biz/ctgy/dto/ParkingImageDto.java @@ -0,0 +1,72 @@ +package com.xit.biz.ctgy.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.springframework.web.multipart.MultipartFile; + +@Schema(name = "ParkingImageDto", description = "") +@Getter +@Setter +@AllArgsConstructor +@NoArgsConstructor +public class ParkingImageDto { + @Schema(title = "진술서파일1", example = " ", description = " ") + private String scFrecad1; + + @Schema(title = " ", example = " ", description = " ") + private String scFrecad2; + + @Schema(title = " ", example = " ", description = " ") + private String scFrecad3; + + @Schema(title = " ", example = " ", description = " ") + private String scFrecad4; + + @Schema(title = "첨부자료1", example = " ", description = " ") + private String scContad1; + + @Schema(title = " ", example = " ", description = " ") + private String scContad2; + + @Schema(title = " ", example = " ", description = " ") + private String scContad3; + + @Schema(title = " ", example = " ", description = " ") + private String scContad4; + + @Schema(title = " ", example = " ", description = " ") + private String scContad5; + + @Schema(title = " ", example = " ", description = " ") + private String scContad6; + + @Schema(title = " ", example = " ", description = " ") + private String scContad7; + + @Schema(title = " ", example = " ", description = " ") + private String scContad8; + + @Schema(title = "단속사진1", example = " ", description = " ") + private String scPicad1; + + @Schema(title = " ", example = " ", description = " ") + private String scPicad2; + + @Schema(title = " ", example = " ", description = " ") + private String scPicad3; + + @Schema(title = " ", example = " ", description = " ") + private String scPicad4; + + @Schema(required = false, title = "단속사진파일", example = " ", description = "단속사진파일") + private MultipartFile[] picadFiles; + + @Schema(required = false, title = "진술서파일", example = " ", description = "진술서파일") + private MultipartFile[] frecadFiles; + + @Schema(required = false, title = "첨부자료파일", example = " ", description = "첨부자료파일") + private MultipartFile[] contadFiles; +} 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 5119c0e..022cbef 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 @@ -115,6 +115,13 @@ public class ParkingController { return RestResponse.of(service.findByUserJudges()); } + @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)); + } + @Secured(policy = SecurityPolicy.TOKEN) @Operation(summary = "주정차 의견진술 심의 결과 저장" , description = "주정차 의견진술 심의 결과 저장") @Parameters({ 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 675cc9e..8e23e17 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 @@ -13,6 +13,8 @@ import org.springframework.stereotype.Repository; import javax.validation.constraints.NotNull; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -198,22 +200,32 @@ public class ParkingDao extends BaseMpowerDaoSupport { return selectList(DashboardJudgeListDto.class, sql, fieldStrs); } + + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- public List findByUserJudges() { final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectByUserJudgeList") .setParameter("msuUserid", HeaderUtil.getUserId()) .getQueryString(); final String fieldStrs = "msMaincode, msSeq, msCarnum, msResult, msYear, msChasu, msSdate, msStartsi, msEdate, msCdate, " + - "msClosesi, msDatgb, msuCode, msuResult, msuReason, scWdate, scPos"; + "msClosesi, msDatgb, msuCode, msuResult, msuReason, msWdate, msPos, rcMaincode, msuUserid"; return selectList(JudgeListDto.class, sql, fieldStrs); } - public void updateMsuResonAndMsuResultByMsuCode(@NotNull final Long msuCode, @NotNull final String msuResult, @NotNull final String msuReason, @NotNull final LocalDate msuIndate) { + public void updateMsuResonAndMsuResultByMsuCode(@NotNull final JudgeListDto dto) { final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "updateMsuResonAndMsuResultByMsuCode") - .setParameter("msuCode", msuCode) - .setParameter("msuResult", msuResult) - .setParameter("msuReason", msuReason) - .setParameter("msuIndate", msuIndate) + .setParameter("msuCode", dto.getMsuCode()) + .setParameter("msuUserid", dto.getMsuUserid()) + .setParameter("msuResult", dto.getMsuResult()) + .setParameter("msuReason", dto.getMsuReason()) + .setParameter("msuIndate", LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) .getQueryString(); update(sql); } + + public ParkingImageDto findImageByRcMaincode(Long rcMaincode) { + ParkingImageDto dto = getPicadImgList(String.valueOf(rcMaincode)); + return dto; + } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java index 6e83e38..20e08ba 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java +++ b/src/main/java/com/xit/biz/ctgy/v2/repository/ResidentAndDisabledDao.java @@ -16,6 +16,8 @@ import org.springframework.stereotype.Repository; import javax.validation.constraints.NotNull; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; @@ -297,23 +299,26 @@ public class ResidentAndDisabledDao extends BaseMpowerDaoSupport { - + //--------------------------------------------------------------------------------- + // 심사자 + //--------------------------------------------------------------------------------- public List findByUserJudges(@NotNull final JudgeListDto dto) { final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "selectByUserJudgeList") .setParameter("msDatagb", dto.getMsDatagb()) .setParameter("msuUserid", HeaderUtil.getUserId()) .getQueryString(); final String fieldStrs = "msMaincode, msSeq, msCarnum, msResult, msYear, msChasu, msSdate, msStartsi, msEdate, msCdate, " + - "msClosesi, msDatgb, msuCode, msuResult, msuReason, scWdate, scPos"; + "msClosesi, msDatgb, msuCode, msuResult, msuReason, scWdate, scPos, msuUserid"; return selectList(JudgeListDto.class, sql, fieldStrs); } - public void updateMsuResonAndMsuResultByMsuCode(@NotNull final Long msuCode, @NotNull final String msuResult, @NotNull final String msuReason, @NotNull final LocalDate msuIndate) { + public void updateMsuResonAndMsuResultByMsuCode(@NotNull final JudgeListDto dto) { final String sql = QueryGenerator.createNamedQuery(NAME_SPACE, "updateMsuResonAndMsuResultByMsuCode") - .setParameter("msuCode", msuCode) - .setParameter("msuResult", msuResult) - .setParameter("msuReason", msuReason) - .setParameter("msuIndate", msuIndate) + .setParameter("msuCode", dto.getMsuCode()) + .setParameter("msuUserid", dto.getMsuUserid()) + .setParameter("msuResult", dto.getMsuResult()) + .setParameter("msuReason", dto.getMsuReason()) + .setParameter("msuIndate", LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) .getQueryString(); update(sql); } 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 3b7f5f9..d8a5269 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,6 +1,8 @@ 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; @@ -34,4 +36,5 @@ public interface IParkingService { void saveJudgeResult(JudgeListDto dto); + ParkingImageDto findImageByRcMaincode(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 6b03589..484cc94 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 @@ -1,10 +1,7 @@ package com.xit.biz.ctgy.v2.service.impl; import com.xit.biz.ctgy.CtgyConstants; -import com.xit.biz.ctgy.dto.JudgeListDto; -import com.xit.biz.ctgy.dto.MinSimsaUser680Dto; -import com.xit.biz.ctgy.dto.MinUserinfoDto; -import com.xit.biz.ctgy.dto.ParkingTargetDto; +import com.xit.biz.ctgy.dto.*; import com.xit.biz.ctgy.v2.repository.ParkingDao; import com.xit.biz.ctgy.v2.repository.UserDao; import com.xit.biz.ctgy.v2.service.IParkingService; @@ -177,9 +174,11 @@ public class ParkingService implements IParkingService { @Override //@Transactional public void saveJudgeResult(JudgeListDto dto){ - parkingDao.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), - dto.getMsuResult(), - dto.getMsuReason(), - LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + parkingDao.updateMsuResonAndMsuResultByMsuCode(dto); + } + + @Override + public ParkingImageDto findImageByRcMaincode(Long rcMaincode) { + return parkingDao.findImageByRcMaincode(rcMaincode); } } diff --git a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java index 3eb7461..74743ee 100644 --- a/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/v2/service/impl/ResidentAndDisabledService.java @@ -320,9 +320,6 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { @Override //@Transactional public void saveJudgeResult(JudgeListDto dto){ - residentAndDisabledDao.updateMsuResonAndMsuResultByMsuCode(dto.getMsuCode(), - dto.getMsuResult(), - dto.getMsuReason(), - LocalDate.parse(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))); + residentAndDisabledDao.updateMsuResonAndMsuResultByMsuCode(dto); } } 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 93bf442..71294ef 100644 --- a/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java +++ b/src/main/java/com/xit/core/config/database/BaseMpowerDaoSupport.java @@ -3,11 +3,14 @@ package com.xit.core.config.database; import com.plf.client.Client; import com.xit.biz.cmm.dto.ComboCodeDto; import com.xit.biz.ctgy.CtgyConstants; +import com.xit.biz.ctgy.dto.ParkingImageDto; import com.xit.core.constant.ErrorCode; import com.xit.core.exception.MpowerException; import com.xit.core.oauth2.config.properties.IDatabaseProperties; import com.xit.core.oauth2.config.properties.MasterDatabaseProperties; import com.xit.core.oauth2.config.properties.SlaveDatabaseProperties; +import com.xit.core.util.Checks; +import com.xit.core.util.CommUtil; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.Setter; @@ -17,6 +20,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; +import org.springframework.util.ResourceUtils; import java.io.IOException; import java.lang.reflect.Field; @@ -31,9 +35,24 @@ import java.util.*; public abstract class BaseMpowerDaoSupport { private final IDatabaseProperties databaseProperties; - @Setter - @Getter - private String dbTarget = "master"; + @Value("${mpower.file.hostIp}") + private String fileHostIp; + @Value("${mpower.file.port}") + private int fileHostPort; + @Value("${mpower.file.serviceName}") + private String fileServiceName; + + // 단속사진 + @Value("${mpower.file.picadPath}") + private String picadPath; + // 진술서 + @Value("${mpower.file.frecadPath}") + private String frecadPath; + // 첨부자료 + @Value("${mpower.file.contadPath}") + private String contadPath; + @Value("${mpower.file.savedImgPath}") + private String savedImgPath; public T selectOne(Class type, String sql, String fields){ Objects.requireNonNull(type, "Class cannot be null"); @@ -353,13 +372,10 @@ public abstract class BaseMpowerDaoSupport { } private Client getConnection(){ -// Client mpowerClient = -// CtgyConstants.DB_MASTER.equals(dbTarget)? -// new Client(masterDatabaseProperties.getHostIp(), masterDatabaseProperties.getPort()) : -// new Client(slaveDatabaseProperties.getHostIp(), slaveDatabaseProperties.getPort()); - Client mpowerClient = new Client(databaseProperties.getHostIp(), databaseProperties.getPort()); - mpowerClient.setCryptEnable(false); + Client mpowerClient = null; try { + mpowerClient = new Client(databaseProperties.getHostIp(), databaseProperties.getPort()); + mpowerClient.setCryptEnable(false); mpowerClient.getConnection("MPowerXmlToQuery.xmlQuery1"); } catch (Exception e) { throw new MpowerException(ErrorCode.MPOWER_CONNECT_ERROR); @@ -462,6 +478,112 @@ public abstract class BaseMpowerDaoSupport { for(String s : strs) list.add(s.trim()); return list; } + + public void fnDownFile(String fileName, String sessionId){ + + try{ + Client mp = new Client(fileHostIp, fileHostPort); + mp.getConnection(fileServiceName); + mp.setInput("dnfile1",picadPath + fileName); //터널링에 실질 존재하는 경로,파일명 + mp.Request(); + String result = mp.getString("result", 0, 0); + + if (result.equals("true")){ + mp.getFileName("imageA"); + mp.savefile("imageA", savedImgPath); + }else{ + throw new MpowerException("MPower File download error::"+result); + } + }catch(Exception e){ + e.printStackTrace(); + throw new MpowerException(e.getLocalizedMessage()); + } + log.info("웹서버 저장되는 첨부파일 위치:"+savedImgPath); + } + + public ParkingImageDto getPicadImgList(String photocode){ + ParkingImageDto dto = new ParkingImageDto(); + + Client client = new Client(fileHostIp, fileHostPort); + + 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")){ + 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"); + }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 + * @return + */ + public String getAbsImgPath(String code){ + code = Checks.checkEmptyVal(code,"0"); + double intCode = Double.parseDouble(code); + + return getImgPath(intCode, "00001", 10000) + "/" + + getImgPath(intCode, "0001", 1000) + "/" + + getImgPath(Double.parseDouble(code.substring(code.length()-3, code.length())), "001", 100); + } + + private String getImgPath(double intCode, String baseDir, int baseValue){ + + String tmpDir = ""; + + if(intCode <= baseValue){ + tmpDir = baseDir; + }else{ + int tmpL = (int)intCode/baseValue; //나눈값 + double dtmpL = intCode/baseValue; //나눈값 + + String tmpS = String.valueOf(dtmpL); + tmpS = tmpS.substring(tmpS.indexOf(".")+1); + + int tmpM = Integer.parseInt(tmpS); + + 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; + } + } /* diff --git a/src/main/resources/config/conf.yml b/src/main/resources/config/conf.yml index a7c9a99..e79f523 100644 --- a/src/main/resources/config/conf.yml +++ b/src/main/resources/config/conf.yml @@ -38,4 +38,15 @@ mpower: hostIp: 127.0.0.1 port: 9999 dbName: gn_seconddb - + file: + hostIp: 127.0.0.1 + port: 9999 + serviceName: XitFile.XitDownload + # 단속사진 + picadPath: C:\\NewTraffic_Photo\\JUCHA_PHOTO\\ + # 진술서 + frecadPath: /picad + # 첨부자료 + contadPath: /picad + # 저장경로 + savedImgPath: d:/data/file/juchaPhoto diff --git a/src/main/resources/sql/parking-mapper.xml b/src/main/resources/sql/parking-mapper.xml index a063c30..47a9f0c 100644 --- a/src/main/resources/sql/parking-mapper.xml +++ b/src/main/resources/sql/parking-mapper.xml @@ -367,14 +367,15 @@ , MSU.msu_code , DECODE(MSU.msu_result, '1', '1', '2', '2', '0') as msuResult , MSU.msu_reason - , TM.mm_wdate as scWdate + , MS.ms_wdate + , MS.ms_pos + , TR.rc_maincode + , MSU.msu_userid FROM min_simsa680 MS , min_simsa_user680 MSU , tf680_recall TR - , tf680_main TM WHERE MS.ms_maincode = MSU.msu_maincode AND MS.ms_maincode = TR.rc_code - AND TR.rc_maincode = TM.mm_code AND MSU.msu_userid = #{msuUserid} ORDER BY MS.ms_sdate, MS.ms_edate, MS.ms_seq diff --git a/src/main/resources/sql/residentAndDisabled-mapper.xml b/src/main/resources/sql/residentAndDisabled-mapper.xml index 5ee6e5c..f2273be 100644 --- a/src/main/resources/sql/residentAndDisabled-mapper.xml +++ b/src/main/resources/sql/residentAndDisabled-mapper.xml @@ -610,13 +610,12 @@ , MSU.msu_code , DECODE(MSU.msu_result, '1', '1', '2', '2', '0') as msuResult , MSU.msu_reason - , GR.sc_wdate - , GR.sc_pos + , MS.ms_wdate + , MS.ms_pos + , MSU.msu_userid FROM min_simsa680_sc MS , min_simsa_user680_sc MSU - , gn_recall_sc GR WHERE MS.ms_maincode = MSU.msu_maincode - AND MS.ms_maincode = GR.sc_code AND MSU.msu_userid = #{msuUserid} AND MS.ms_datagb = #{msDatagb} @@ -631,6 +630,7 @@ , msu_result = #{msuResult} , msu_indate = #{msuIndate} WHERE msu_code = #{msuCode} + AND msu_userid = #{msuUserid}