From ecc70039357e98d2b0e42c18c2b8fcc78a58afb7 Mon Sep 17 00:00:00 2001 From: minuk926 Date: Thu, 28 Apr 2022 19:29:53 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B1=B0=EC=A3=BC=EC=9E=90/=EC=9E=A5?= =?UTF-8?q?=EC=95=A0=EC=9D=B8=20=EC=9E=90=EB=A3=8C=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/cmm/controller/CmmFileController.java | 9 +++- .../ResidentAndDisabledController.java | 2 - .../impl/ResidentAndDisabledService.java | 48 +++++++++++-------- 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/xit/biz/cmm/controller/CmmFileController.java b/src/main/java/com/xit/biz/cmm/controller/CmmFileController.java index c62f00a..d800950 100644 --- a/src/main/java/com/xit/biz/cmm/controller/CmmFileController.java +++ b/src/main/java/com/xit/biz/cmm/controller/CmmFileController.java @@ -85,10 +85,15 @@ public class CmmFileController { String absFile = ""; + // TODO : 운영환경에 맞게 적용 필요 if (Arrays.asList(env.getActiveProfiles()).contains("prod")) - absFile = "entity.getInFileurl()" + File.separator + fileName; + absFile = String.format("%s%s%s", "entity.getInFileurl()", File.separator, fileName); else - absFile = rootPath + (CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(scDatagb)? judgeUploadPath[0] : judgeUploadPath[1]) + fileName; + absFile = String.format( + "%s%s%s%s", + rootPath, + (CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(scDatagb)? judgeUploadPath[0] : judgeUploadPath[1]), + File.separator, fileName); download(absFile, fileName, response); } diff --git a/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java b/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java index 8695747..bada9c7 100644 --- a/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java +++ b/src/main/java/com/xit/biz/ctgy/controller/ResidentAndDisabledController.java @@ -64,9 +64,7 @@ public class ResidentAndDisabledController { AssertUtils.isTrue(!Checks.isEmpty(dto.getScDatagb()), "데이타구분 값은 필수입니다(1-거주자,2-장애인)"); service.saveJudgeData(dto); - //service.saveResidentData(mapstruct.toEntity(dto), dto.getPicadFiles(), dto.getFrecadFiles(), dto.getContadFiles()); return RestResponse.of(HttpStatus.OK); - // return RestResponse.of(HttpStatus.OK); } @Operation(summary = "거주자/장애인 의견진술 자료 상세" , description = "거주자/장애인 의견진술 자료 상세") diff --git a/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java b/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java index 33fe2d0..dec4437 100644 --- a/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java +++ b/src/main/java/com/xit/biz/ctgy/service/impl/ResidentAndDisabledService.java @@ -33,7 +33,6 @@ import org.springframework.web.multipart.MultipartFile; import javax.persistence.EntityManager; import javax.validation.constraints.NotNull; -import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.HashMap; @@ -83,22 +82,26 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { @Override @Transactional public void saveJudgeData(GnRecallScDto dto) { + boolean isNew = Checks.isEmpty(dto.getScCode()) || dto.getScCode() == 0L; if(dto.getPicadFiles() != null) { - setFileInfoAndFileUpload(dto, dto.getPicadFiles(), "setScPicad"); + if(!isNew) changeFileUpload(dto, dto.getPicadFiles()); + else setFileInfoAndFileUpload(dto, dto.getPicadFiles(), "setScPicad"); } if(dto.getFrecadFiles() != null) { - setFileInfoAndFileUpload(dto, dto.getFrecadFiles(), "setScFrecad"); + if(!isNew) changeFileUpload(dto, dto.getFrecadFiles()); + else setFileInfoAndFileUpload(dto, dto.getFrecadFiles(), "setScFrecad"); } if(dto.getContadFiles() != null) { - setFileInfoAndFileUpload(dto, dto.getContadFiles(), "setScContad"); + if(!isNew) changeFileUpload(dto, dto.getContadFiles()); + else setFileInfoAndFileUpload(dto, dto.getContadFiles(), "setScContad"); } GnRecallSc entity = null; // 신규 - if (Checks.isEmpty(dto.getScCode()) || dto.getScCode() == 0L) { + if (isNew) { // 접수번호 채번 : 년도 + seq 10자리 dto.setScSeq(gnReacallRepository.getGnRecallScMaxScSeq(String.valueOf(DateUtil.getCurrentYear()), CtgyConstants.Judge.DATAGB_RESIDENT.getCode())); entity = mapstruct.toEntity(dto); @@ -116,21 +119,6 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { gnReacallRepository.deleteById(scCode); } - private void setFileInfoAndFileUpload(GnRecallScDto dto, MultipartFile[] mfs, String setMethodName) { - String makePath = fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); - makePath = makePath + File.separator; - - for(int idx = 0; idx < mfs.length; idx++){ - MultipartFile mf = mfs[idx]; - try { - Method method = GnRecallScDto.class.getMethod(setMethodName + (idx+1), String.class); - method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); - } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - } - } - @Override @Transactional(readOnly = true) public List findJudgeTargets(JudgeTargetDto dto) { @@ -268,4 +256,24 @@ public class ResidentAndDisabledService implements IResidentAndDisabledService { judgeRepository.deleteById(msMaincode); }); } + + private void setFileInfoAndFileUpload(GnRecallScDto dto, MultipartFile[] mfs, String setMethodName) { + String makePath = fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); + //makePath = makePath + File.separator; + + for(int idx = 0; idx < mfs.length; idx++){ + MultipartFile mf = mfs[idx]; + try { + Method method = GnRecallScDto.class.getMethod(setMethodName + (idx+1), String.class); + method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); + //method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename())); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + } + } + + private void changeFileUpload(GnRecallScDto dto, MultipartFile[] mfs) { + fileService.uploadFiles(mfs, rootPath, CtgyConstants.Judge.DATAGB_RESIDENT.getCode().equals(dto.getScDatagb())? uploadPath[0] : uploadPath[1]); + } }