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]); + } }