fix: 주정차 심사 반영 완료

main
minuk926 2 years ago
parent e8a3349faf
commit bf753051e6

@ -102,6 +102,12 @@ public class CmmFileController {
download(absFile, fileName, response);
}
@Operation(summary = "주정차 심사자료 파일 다운로드" , description = "주정차 심사자료 파일 다운로드")
@GetMapping("/download/park")
public void download(@Nonnull final String absFileName, HttpServletResponse response) {
download(absFileName, absFileName.substring(absFileName.lastIndexOf("/")), response);
}
private void download(String absFile, String fileName, HttpServletResponse response) {
Path path = Paths.get(absFile);

@ -223,14 +223,14 @@ public class ParkingDao extends BaseMpowerDaoSupport {
}
public List<Map<String,Object>> findPicadImageByRcMaincode(@NotNull final Long rcMaincode) {
return getPicadImgList(String.valueOf(rcMaincode));
return getParkingJudgeImgList(String.valueOf(rcMaincode), "picad");
}
public List<Map<String, Object>> findFrecadImageByRcMaincode(@NotNull final Long rcMaincode) {
return getPicadImgList(String.valueOf(rcMaincode));
return getParkingJudgeImgList(String.valueOf(rcMaincode), "frecad");
}
public List<Map<String, Object>> findContadImageByRcMaincode(@NotNull final Long rcMaincode) {
return getPicadImgList(String.valueOf(rcMaincode));
return getParkingJudgeImgList(String.valueOf(rcMaincode), "contad");
}
}

@ -1,27 +1,19 @@
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;
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;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.File;
import java.io.IOException;
@ -481,106 +473,207 @@ public abstract class BaseMpowerDaoSupport {
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 List<Map<String,Object>> getPicadImgList(String photocode){
public List<Map<String,Object>> getParkingJudgeImgList(String photocode, String imgDiv){
List<Map<String,Object>> list = new ArrayList<>();
Client client = new Client(fileHostIp, fileHostPort);
String filePath = getAbsImgPath(photocode);
String svrImgPath = picadPath + filePath; //터널링에 저장된 단속사진 경로
String svrSavedPhotoPath = savedImgPath + "/" + filePath;
log.info("Mpower 이미지경로:::::" + svrImgPath);
log.info("서버 download file path :::::" + svrSavedPhotoPath);
try{
client.getConnection(fileServiceName);
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");
String mpowerFilePre = String.format("%s%s%s", svrImgPath, "picad".equals(imgDiv)? "/P" : "/R", CommUtil.lpad(photocode, '0', 10));
List<String> fileNames = Arrays.asList("A.jpg", "B.jpg", "C.jpg", "D.jpg", "E.jpg", "F.jpg", "G.jpg", "H.jpg", "I.jpg", "J.jpg", "K.jpg", "L.jpg", "M.jpg");
int index = 1;
if("picad".equals(imgDiv)){
log.info("<<< ==== Mpower picad 이미지 file name ====>>>");
// A, B, C, D
for(int idx = 0; idx <=3; idx++) client.setInput("dnfile"+index++,mpowerFilePre + fileNames.get(idx));
}else if("frecad".equals(imgDiv)) {
log.info("<<< ==== Mpower frecad 이미지 file name ====>>>");
index = 1;
// A, B, C, D
for (int idx = 0; idx <= 3; idx++) client.setInput("dnfile" + index++, mpowerFilePre + fileNames.get(idx));
}else {
log.info("<<< ==== Mpower contad 이미지 file name ====>>>");
index = 1;
// F, G, H, I
for (int idx = 5; idx <= 8; idx++) client.setInput("dnfile" + index++, mpowerFilePre + fileNames.get(idx));
}
client.Request();
String result = client.getString("result", 0, 0);
File file = new File(svrSavedPhotoPath);
if (result.equals("true")){
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");
fileDownAndSet(list, client, svrSavedPhotoPath, file);
File file = new File(svrSavedPhotoPath);
}else{
throw new MpowerException("MPower File download error::"+result);
}
//-----------------------------------------------------------------
// 단속사진 return
//-----------------------------------------------------------------
if("picad".equals(imgDiv)) return list;
disConnection(client);
client.getConnection(fileServiceName);
//-----------------------------------------------------------------
// 진술서 return
//-----------------------------------------------------------------
if("frecad".equals(imgDiv)) {
log.info("<<< ==== Mpower frecad 이미지 file name ====>>>");
// E
client.setInput("dnfile1", mpowerFilePre + "E.jpg");
client.Request();
result = client.getString("result", 0, 0);
if (result.equals("true")) {
if (Checks.isNotEmpty(client.getFileName("imageA"))) {
if (!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageA")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageA"));
client.savefile("imageA", svrSavedPhotoPath);
setFileInfo(list, client.getFileName("imageA"), strpath);
log.info("서버 file name :::::" + strpath + client.getFileName("imageA"));
}
setFileInfo(list, client.getFileName("imageA"), svrSavedPhotoPath);
} else {
setNoFileInfo(list);
};
}
}
return list;
}
disConnection(client);
client.getConnection(fileServiceName);
//-----------------------------------------------------------------
// 참고자료 return
//-----------------------------------------------------------------
log.info("<<< ==== Mpower contad 이미지 file name ====>>>");
index = 1;
// J, K, L, M
for (int idx = 9; idx <= 12; idx++) client.setInput("dnfile" + index++, mpowerFilePre + fileNames.get(idx));
client.Request();
result = client.getString("result", 0, 0);
if (result.equals("true")){
fileDownAndSet(list, client, svrSavedPhotoPath, file);
}else{
throw new MpowerException("MPower File download error::"+result);
}
disConnection(client);
client.getConnection(fileServiceName);
client.setInput("dnfile1", mpowerFilePre + "N.jpg");
client.setInput("dnfile2", mpowerFilePre + "O.jpg");
client.Request();
result = client.getString("result", 0, 0);
if (result.equals("true")){
if(Checks.isNotEmpty(client.getFileName("imageA"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageA")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageA"));
client.savefile("imageA", svrSavedPhotoPath);
}
setFileInfo(list, client.getFileName("imageA"), svrSavedPhotoPath);
}
// else{
// setNoFileInfo(list);
// }
if(Checks.isNotEmpty(client.getFileName("imageB"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageB")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageB"));
client.savefile("imageB", svrSavedPhotoPath);
setFileInfo(list, client.getFileName("imageB"), strpath);
log.info("서버 file name :::::" + strpath + client.getFileName("imageB"));
}
setFileInfo(list, client.getFileName("imageB"), svrSavedPhotoPath);
}
// else{
// setNoFileInfo(list);
// }
}else{
setNoFileInfo(list);;
};
throw new MpowerException("MPower File download error::"+result);
}
client = null;
return list;
}catch(Exception e){
throw new MpowerException("MPower File download error::"+e.getLocalizedMessage());
}
}
private void fileDownAndSet(List<Map<String, Object>> list, Client client, String svrSavedPhotoPath, File file) throws IOException {
if(Checks.isNotEmpty(client.getFileName("imageA"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageA")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageA"));
client.savefile("imageA", svrSavedPhotoPath);
}
setFileInfo(list, client.getFileName("imageA"), svrSavedPhotoPath);
}
// else{
// setNoFileInfo(list);
// }
if(Checks.isNotEmpty(client.getFileName("imageB"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageB")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageB"));
client.savefile("imageB", svrSavedPhotoPath);
}
setFileInfo(list, client.getFileName("imageB"), svrSavedPhotoPath);
}
// else{
// setNoFileInfo(list);
// }
if(Checks.isNotEmpty(client.getFileName("imageC"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageC")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + client.getFileName("imageC"));
client.savefile("imageC", svrSavedPhotoPath);
setFileInfo(list, client.getFileName("imageC"), strpath);
log.info("서버 file name :::::" + strpath + client.getFileName("imageC"));
}else{
setNoFileInfo(list);;
};
}
setFileInfo(list, client.getFileName("imageC"), svrSavedPhotoPath);
}
// else{
// setNoFileInfo(list);
// }
if(Checks.isNotEmpty(client.getFileName("imageD"))){
if(!file.exists()) file.mkdirs();
if(!new File(svrSavedPhotoPath + "/" + client.getFileName("imageD")).exists()){
log.info("file download ::: {}", svrSavedPhotoPath + "/" + 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);
}
}catch(Exception e){
throw new MpowerException("MPower File download error::"+e.getLocalizedMessage());
setFileInfo(list, client.getFileName("imageD"), svrSavedPhotoPath);
}
//logger.debug(fph);
return list;
// else{
// setNoFileInfo(list);
// }
}
private void setFileInfo(List<Map<String, Object>> list, String imgName, String strpath) {
Map<String, Object> map = new HashMap<>();
map.put("imgName", imgName);
map.put("url", strpath + imgName);
map.put("url", strpath + "/" + imgName);
list.add(map);
}

Loading…
Cancel
Save