|
|
|
@ -1,9 +1,5 @@
|
|
|
|
|
package cokr.xit.adds.biz.nims.service.bean;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -38,7 +34,6 @@ import cokr.xit.base.file.web.FileInfoFactory;
|
|
|
|
|
import cokr.xit.foundation.component.AbstractServiceBean;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import lombok.val;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
@ -377,9 +372,6 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
|
|
|
|
|
|
|
|
|
|
if(bizNimsMapper.insertDsuseMgtReceipt(dto) == 1){
|
|
|
|
|
int dtlCnt = 0;
|
|
|
|
|
String dirPath = dsuseImgPath + Constants.FILE_DLMTR + dto.getDscdmngId();
|
|
|
|
|
File f = new File(dirPath);
|
|
|
|
|
if(!f.exists()) f.mkdirs();
|
|
|
|
|
|
|
|
|
|
for (BizNimsRequest.DsuseMgtDtl d : dtls) {
|
|
|
|
|
String sn = StringUtils.leftPad(dtlCnt + 1 + "", 3, "0");
|
|
|
|
@ -388,7 +380,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
|
|
|
|
|
d.setRgtr(dto.getUserId());
|
|
|
|
|
dtlCnt = dtlCnt + bizNimsMapper.insertDsuseMgtDtl(d);
|
|
|
|
|
|
|
|
|
|
uploadFileAndSave("100", dto.getDscdmngId(), sn, files.get(dtlCnt-1), dirPath);
|
|
|
|
|
d.setFileId(uploadFileAndSave(Constants.FILE_INF_TYPE.DSUSE_PRD_IMG.getCode(), dto.getDscdmngId(), sn, files.get(dtlCnt-1)));
|
|
|
|
|
}
|
|
|
|
|
if(dtls.size() != dtlCnt) throw ApiCustomException.create("폐기 관리 상세 등록 실패");
|
|
|
|
|
} else {
|
|
|
|
@ -409,13 +401,9 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
|
|
|
|
|
dto.setRgtr(dto.getUserId());
|
|
|
|
|
|
|
|
|
|
if(bizNimsMapper.updateDsuseMgtRslt(dto) == 1){
|
|
|
|
|
String dirPath = dsuseImgPath + Constants.FILE_DLMTR + dto.getDscdmngId();
|
|
|
|
|
File f = new File(dirPath);
|
|
|
|
|
if(!f.exists()) f.mkdirs();
|
|
|
|
|
|
|
|
|
|
int idx = 1;
|
|
|
|
|
for (MultipartFile mf : files) {
|
|
|
|
|
uploadFileAndSave("110", dto.getDscdmngId(), String.valueOf(idx), mf, dirPath);
|
|
|
|
|
uploadFileAndSave(Constants.FILE_INF_TYPE.DSUSE_IMG.getCode(), dto.getDscdmngId(), String.valueOf(idx), mf);
|
|
|
|
|
idx++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -909,25 +897,24 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void uploadFileAndSave(String infoType, String infoKey, String subType, MultipartFile mf, String dirPath) {
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* file 저장 처리
|
|
|
|
|
* @param infoType : 파일 정보 타입 : Constants.FILE_INFO_TYPE
|
|
|
|
|
* @param infoKey : 파일 정보 키 - 폐기관리ID
|
|
|
|
|
* @param subType : 파일 정보 서브 타입
|
|
|
|
|
* -> 폐기제품이미지 : 폐기관리상세의 순번
|
|
|
|
|
* -> 폐기이미지 : 이미지 순서
|
|
|
|
|
* @param mf : MultipartFile
|
|
|
|
|
* @return fileId
|
|
|
|
|
* </pre>
|
|
|
|
|
*/
|
|
|
|
|
private String uploadFileAndSave(String infoType, String infoKey, String subType, MultipartFile mf) {
|
|
|
|
|
MultipartFile[] uploads = Arrays.asList(mf).toArray(new MultipartFile[0]);
|
|
|
|
|
List<FileInfo> files = (new FileInfoFactory()).makeFileInfos((new FileInfo.Relation()).setInfoType(infoType).setInfoKey(infoKey).setSubType(subType), uploads);
|
|
|
|
|
int affected = fileService.create(files);
|
|
|
|
|
fileService.create(files);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val name = mf.getOriginalFilename();
|
|
|
|
|
val ext = name.substring(name.lastIndexOf("."));
|
|
|
|
|
val filename = name.substring(0, name.lastIndexOf("."));
|
|
|
|
|
|
|
|
|
|
Path path = Paths.get(dirPath + Constants.FILE_DLMTR, name);
|
|
|
|
|
|
|
|
|
|
// FIXME : file upload
|
|
|
|
|
try {
|
|
|
|
|
mf.transferTo(path);
|
|
|
|
|
//FileCopyUtils.copy(mf.getInputStream(), Files.newOutputStream(path));
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw ApiCustomException.create(String.format("폐기 통보[결과] 처리:파일 업로드 실패[%s]", e.getMessage()));
|
|
|
|
|
}
|
|
|
|
|
return files.get(0).getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|