fix: 폐기결과[통보] 변경 파일 처리 변경

-> 모든 파일 삭제후 insert
dev
Jonguk. Lim 5 months ago
parent 556c829aec
commit 186fb31d4c

@ -288,7 +288,8 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
dtlCnt = dtlCnt + bizNimsMapper.insertDsuseMgtDtl(d); dtlCnt = dtlCnt + bizNimsMapper.insertDsuseMgtDtl(d);
// FIXME: 파일 갯수 확인 - 프론트 파일 처리 완료시 까지 comment 처리 // FIXME: 파일 갯수 확인 - 프론트 파일 처리 완료시 까지 comment 처리
d.setFileId(uploadFileAndSave(Constants.FILE_INF_TYPE.DSUSE_PRD_IMG.getCode(), reqDto.getDscdmngId(), sn, files.get(dtlCnt-1))); d.setFileId(
uploadFileDeleteAndSave(Constants.FILE_INF_TYPE.DSUSE_PRD_IMG.getCode(), reqDto.getDscdmngId(), sn, files.get(dtlCnt-1)));
} }
if(dtls.size() != dtlCnt) throw ApiCustomException.create("폐기 관리 상세 등록 실패"); if(dtls.size() != dtlCnt) throw ApiCustomException.create("폐기 관리 상세 등록 실패");
} else { } else {
@ -309,9 +310,15 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
reqDto.setRgtr(reqDto.getUserId()); reqDto.setRgtr(reqDto.getUserId());
if(bizNimsMapper.updateDsuseMgtRslt(reqDto) == 1){ if(bizNimsMapper.updateDsuseMgtRslt(reqDto) == 1){
// 파일 삭제
List<String> fileIds = bizNimsMapper.selectFileId(Map.of("infType", Constants.FILE_INF_TYPE.DSUSE_IMG.getCode(), "infKey", reqDto.getDscdmngId()));
if(!fileIds.isEmpty()){
fileService.delete(fileIds.toArray(new String[0]));
}
int idx = 1; int idx = 1;
for (MultipartFile mf : files) { for (MultipartFile mf : files) {
uploadFileAndSave(Constants.FILE_INF_TYPE.DSUSE_IMG.getCode(), reqDto.getDscdmngId(), String.valueOf(idx), mf); uploadFileSave(Constants.FILE_INF_TYPE.DSUSE_IMG.getCode(), reqDto.getDscdmngId(), String.valueOf(idx), mf);
idx++; idx++;
} }
@ -894,12 +901,28 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
* @return fileId * @return fileId
* </pre> * </pre>
*/ */
private String uploadFileAndSave(String infType, String infKey, String subType, MultipartFile mf) { private String uploadFileDeleteAndSave(String infType, String infKey, String subType, MultipartFile mf) {
List<String> fileIds = bizNimsMapper.selectFileId(Map.of("infType", infType, "infKey", infKey, "subType", subType)); List<String> fileIds = bizNimsMapper.selectFileId(Map.of("infType", infType, "infKey", infKey, "subType", subType));
if(!fileIds.isEmpty()){ if(!fileIds.isEmpty()){
fileService.delete(fileIds.toArray(new String[0])); fileService.delete(fileIds.toArray(new String[0]));
} }
return uploadFileSave(infType, infKey, subType, mf);
}
/**
* <pre>
* file
* @param infType : : Constants.FILE_INFO_TYPE
* @param infKey : - ID
* @param subType :
* -> :
* -> :
* @param mf : MultipartFile
* @return fileId
* </pre>
*/
private String uploadFileSave(String infType, String infKey, String subType, MultipartFile mf) {
MultipartFile[] uploads = Collections.singletonList(mf).toArray(new MultipartFile[0]); MultipartFile[] uploads = Collections.singletonList(mf).toArray(new MultipartFile[0]);
List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infType).setInfoKey(infKey).setSubType(subType), uploads); List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infType).setInfoKey(infKey).setSubType(subType), uploads);
fileService.create(files); fileService.create(files);

@ -725,7 +725,9 @@
FROM tb_file FROM tb_file
WHERE INF_TYPE = #{infType} WHERE INF_TYPE = #{infType}
AND INF_KEY = #{infKey} AND INF_KEY = #{infKey}
<if test="subType != null and subType != ''">
AND SUB_TYPE = #{subType} AND SUB_TYPE = #{subType}
</if>
</select> </select>

Loading…
Cancel
Save