|
|
@@ -893,6 +893,7 @@ public class TssGoodsController extends TssBaseController {
|
|
|
|
|
|
//순서 재정렬된 파일 목록
|
|
|
Collection<GoodsImg> resultGoodsImgList = new ArrayList<GoodsImg>();
|
|
|
+ Collection<GoodsImg> resultGoodsImgListDb = new ArrayList<GoodsImg>();
|
|
|
boolean procFlag = true;
|
|
|
int index = 0;
|
|
|
|
|
|
@@ -978,11 +979,22 @@ public class TssGoodsController extends TssBaseController {
|
|
|
String orgFile = goodsImg.getSysImgNm().substring(0, lastIdx);
|
|
|
String[] sysFileNmArr = orgFile.split("_");
|
|
|
String selfGoodsYn = "Y";
|
|
|
+ goodsImg.setSysImgNmChangeYn("N");
|
|
|
+
|
|
|
// 촬영업체
|
|
|
if ("G001_E000".equals(TssSession.getInfo().getRoleCd())) {
|
|
|
goodsImg.setGoodsCd(sysFileNmArr[0]);
|
|
|
goodsImg.setColorCd(sysFileNmArr[1]);
|
|
|
goodsImg.setDispOrd(index);
|
|
|
+
|
|
|
+ // 21.12.14 동일한 이미지명일 경우 파일만 덮어쓰기
|
|
|
+ GoodsImg overWriteImg = goodsService.getGoodsImage(goodsImg);
|
|
|
+ if (null != overWriteImg) {
|
|
|
+ if (!StringUtils.isBlank(overWriteImg.getSysImgNmChangePath())) {
|
|
|
+ goodsImg.setSysImgNmChangeYn("Y");
|
|
|
+ goodsImg.setSysImgNmChangePath(overWriteImg.getSysImgNmChangePath());
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
goodsImg.setGoodsCd(sysFileNmArr[0]);
|
|
|
goodsImg.setColorCd("XX");
|
|
|
@@ -1057,88 +1069,127 @@ public class TssGoodsController extends TssBaseController {
|
|
|
throw new IllegalStateException(goodsImg.getSysImgNm() + "의" + comGoodsCd + " 상품코드의 " + comGoodsColor + " 색상이 존재하지 않습니다.");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- String newFilename = goodsImg.getSysImgNm();
|
|
|
-
|
|
|
- //브랜드 폴더 확인
|
|
|
- String goodsUploadPath = GagaFileUtil.getConcatenationPath(goodsTargetPath, brandDir); // 브랜드 폴더
|
|
|
- File brandPath = new File(goodsUploadPath);
|
|
|
- if (!brandPath.exists()) {
|
|
|
- brandPath.mkdir();
|
|
|
- }
|
|
|
-
|
|
|
- goodsUploadPath = GagaFileUtil.getConcatenationPath(goodsUploadPath, GagaDateUtil.getToday()); //브랜드+/+YYYYMMDD(UPLOAD 일 )
|
|
|
- String brandYmdDir = GagaFileUtil.getConcatenationPath(brandDir, GagaDateUtil.getToday()); //디비 저장용
|
|
|
-
|
|
|
- File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(goodsUploadPath, newFilename)));
|
|
|
- File newFile = new File(GagaFileUtil.getConcatenationPath(goodsUploadPath, uniqueFile.getName()));
|
|
|
- //log.debug("newFile.getPath(): {}", newFile.getPath());
|
|
|
-
|
|
|
- // resizing 처리 시 오류가 발생할 경우 삭제하기 위해 설정
|
|
|
- errorFileList.add(newFile);
|
|
|
-
|
|
|
- File oldFile = new File(GagaFileUtil.getConcatenationPath(dextUploadPath, goodsImg.getSysImgNm()));
|
|
|
- //log.debug("oldFile.getPath(): {}", oldFile.getPath());
|
|
|
-
|
|
|
- File path = new File(goodsUploadPath);
|
|
|
- if (!path.exists()) {
|
|
|
- //log.info("mkdir ={}", goodsUploadPath);
|
|
|
- path.mkdir();
|
|
|
- }
|
|
|
-
|
|
|
- boolean copyFlag = GagaFileUtil.copyFile(oldFile, newFile);
|
|
|
- if (copyFlag) {
|
|
|
- //기존이미지 삭제
|
|
|
- GagaFileUtil.deleteFile(oldFile.getPath());
|
|
|
- }
|
|
|
-
|
|
|
- goodsImg.setDispOrd(index);
|
|
|
- goodsImg.setOrgImgNm(GagaFileUtil.getConcatenationPath(brandYmdDir, newFile.getName()));
|
|
|
- goodsImg.setSysImgNm(GagaFileUtil.getConcatenationPath(brandYmdDir, newFile.getName()));
|
|
|
- goodsImg.setDefaultImgYn("N");
|
|
|
- goodsImg.setMouseoverImgYn("N");
|
|
|
- goodsImg.setExtmallImgYn("N");
|
|
|
- goodsImg.setRegNo(TssSession.getInfo().getUserNo());
|
|
|
-
|
|
|
- // 디비저장후 재작업 20210827
|
|
|
-// // 첫번째 이미지이면 디폴트 이미지 설정
|
|
|
-// if (index == 1) {
|
|
|
-// goodsImg.setDefaultImgYn("Y");
|
|
|
-// }
|
|
|
-//
|
|
|
-// // 두번째 이미지이면 마우스오버 이미지 설정
|
|
|
-// if (index == 2) {
|
|
|
-// goodsImg.setMouseoverImgYn("Y");
|
|
|
-// }
|
|
|
-
|
|
|
- Image srcImg = getImageObject(newFile);
|
|
|
- int width = srcImg.getWidth(null);
|
|
|
- int height = srcImg.getHeight(null);
|
|
|
-
|
|
|
-//
|
|
|
- if (newFile.getName().contains("_X1")) {
|
|
|
-// if (width != height) {
|
|
|
- if (width == 1000 && height == 1000) {
|
|
|
- // 외부몰연동용 이미지로 설정
|
|
|
- goodsImg.setExtmallImgYn("Y");
|
|
|
- }else {
|
|
|
- deleteErrorFileList(errorFileList);
|
|
|
- deleteErrorFileList(errorFileDextList);
|
|
|
- throw new IllegalStateException(comGoodsCd + " 상품코드의 외부몰용 상품이미지는 정사각형(1000x1000)이 아닙니다.");
|
|
|
+
|
|
|
+ if(!"Y".equals(goodsImg.getSysImgNmChangeYn())) {
|
|
|
+
|
|
|
+ String newFilename = goodsImg.getSysImgNm();
|
|
|
+
|
|
|
+ //브랜드 폴더 확인
|
|
|
+ String goodsUploadPath = GagaFileUtil.getConcatenationPath(goodsTargetPath, brandDir); // 브랜드 폴더
|
|
|
+ File brandPath = new File(goodsUploadPath);
|
|
|
+ if (!brandPath.exists()) {
|
|
|
+ brandPath.mkdir();
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsUploadPath = GagaFileUtil.getConcatenationPath(goodsUploadPath, GagaDateUtil.getToday()); //브랜드+/+YYYYMMDD(UPLOAD 일 )
|
|
|
+ String brandYmdDir = GagaFileUtil.getConcatenationPath(brandDir, GagaDateUtil.getToday()); //디비 저장용
|
|
|
+
|
|
|
+ File uniqueFile = GagaFileUtil.getUniqueFile(new File(GagaFileUtil.getConcatenationPath(goodsUploadPath, newFilename)));
|
|
|
+ File newFile = new File(GagaFileUtil.getConcatenationPath(goodsUploadPath, uniqueFile.getName()));
|
|
|
+ //log.debug("newFile.getPath(): {}", newFile.getPath());
|
|
|
+
|
|
|
+ // resizing 처리 시 오류가 발생할 경우 삭제하기 위해 설정
|
|
|
+ errorFileList.add(newFile);
|
|
|
+
|
|
|
+ File oldFile = new File(GagaFileUtil.getConcatenationPath(dextUploadPath, goodsImg.getSysImgNm()));
|
|
|
+ //log.debug("oldFile.getPath(): {}", oldFile.getPath());
|
|
|
+
|
|
|
+ File path = new File(goodsUploadPath);
|
|
|
+ if (!path.exists()) {
|
|
|
+ //log.info("mkdir ={}", goodsUploadPath);
|
|
|
+ path.mkdir();
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean copyFlag = GagaFileUtil.copyFile(oldFile, newFile);
|
|
|
+ if (copyFlag) {
|
|
|
+ //기존이미지 삭제
|
|
|
+ GagaFileUtil.deleteFile(oldFile.getPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsImg.setDispOrd(index);
|
|
|
+ goodsImg.setOrgImgNm(GagaFileUtil.getConcatenationPath(brandYmdDir, newFile.getName()));
|
|
|
+ goodsImg.setSysImgNm(GagaFileUtil.getConcatenationPath(brandYmdDir, newFile.getName()));
|
|
|
+ goodsImg.setDefaultImgYn("N");
|
|
|
+ goodsImg.setMouseoverImgYn("N");
|
|
|
+ goodsImg.setExtmallImgYn("N");
|
|
|
+ goodsImg.setRegNo(TssSession.getInfo().getUserNo());
|
|
|
+
|
|
|
+ // 디비저장후 재작업 20210827
|
|
|
+ // // 첫번째 이미지이면 디폴트 이미지 설정
|
|
|
+ // if (index == 1) {
|
|
|
+ // goodsImg.setDefaultImgYn("Y");
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // // 두번째 이미지이면 마우스오버 이미지 설정
|
|
|
+ // if (index == 2) {
|
|
|
+ // goodsImg.setMouseoverImgYn("Y");
|
|
|
+ // }
|
|
|
+
|
|
|
+ Image srcImg = getImageObject(newFile);
|
|
|
+ int width = srcImg.getWidth(null);
|
|
|
+ int height = srcImg.getHeight(null);
|
|
|
+
|
|
|
+ //
|
|
|
+ if (newFile.getName().contains("_X1")) {
|
|
|
+ // if (width != height) {
|
|
|
+ if (width == 1000 && height == 1000) {
|
|
|
+ // 외부몰연동용 이미지로 설정
|
|
|
+ goodsImg.setExtmallImgYn("Y");
|
|
|
+ }else {
|
|
|
+ deleteErrorFileList(errorFileList);
|
|
|
+ deleteErrorFileList(errorFileDextList);
|
|
|
+ throw new IllegalStateException(comGoodsCd + " 상품코드의 외부몰용 상품이미지는 정사각형(1000x1000)이 아닙니다.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 오류가 발생했으므로
|
|
|
+ // deleteErrorFileList(errorFileList);
|
|
|
+ // deleteErrorFileList(errorFileDextList);
|
|
|
+ // throw new IllegalStateException(goodsImg.getSysImgNm() + " 상품이미지 파일의 크기(" + width + "*" + height + ")가 맞지 않습니다. (올바른 크기: 1079*1499, 750*1041, 1000*1000)");
|
|
|
+ resultGoodsImgListDb.add(goodsImg);
|
|
|
+ index++;
|
|
|
+ }else {
|
|
|
+ // 21.12.14 동일한 이미지명일 경우 파일만 덮어쓰기(db 작업 안함)
|
|
|
+
|
|
|
+ // 1. 현재 저장되어있는 이미지
|
|
|
+ String goodsUploadPath = GagaFileUtil.getConcatenationPath(goodsTargetPath+"/"+goodsImg.getSysImgNmChangePath());
|
|
|
+
|
|
|
+ // 2. 현재 저장되어있는 파일
|
|
|
+ File newFile = new File(GagaFileUtil.getConcatenationPath(goodsUploadPath));
|
|
|
+
|
|
|
+ // 3. dex 업로드된 파일
|
|
|
+ File oldFile = new File(GagaFileUtil.getConcatenationPath(dextUploadPath, goodsImg.getSysImgNm()));
|
|
|
+
|
|
|
+ // 4. 외부몰연동용 이미지 사이즈 확인
|
|
|
+ Image srcImg = getImageObject(oldFile);
|
|
|
+ int width = srcImg.getWidth(null);
|
|
|
+ int height = srcImg.getHeight(null);
|
|
|
+
|
|
|
+ if (oldFile.getName().contains("_X1")) {
|
|
|
+ if (width == 1000 && height == 1000) {
|
|
|
+ // 외부몰연동용 이미지로 설정
|
|
|
+ goodsImg.setExtmallImgYn("Y");
|
|
|
+ }else {
|
|
|
+ GagaFileUtil.deleteFile(oldFile.getPath());
|
|
|
+ throw new IllegalStateException(comGoodsCd + " 상품코드의 외부몰용 상품이미지는 정사각형(1000x1000)이 아닙니다.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 5. 기존이미지 삭제
|
|
|
+ GagaFileUtil.deleteFile(goodsUploadPath);
|
|
|
+
|
|
|
+ // 6. dex 파일 카피 & 삭제
|
|
|
+ boolean copyFlag = GagaFileUtil.copyFile(oldFile, newFile);
|
|
|
+ if (copyFlag) {
|
|
|
+ //기존이미지 삭제
|
|
|
+ GagaFileUtil.deleteFile(oldFile.getPath());
|
|
|
}
|
|
|
}
|
|
|
- // 오류가 발생했으므로
|
|
|
-// deleteErrorFileList(errorFileList);
|
|
|
-// deleteErrorFileList(errorFileDextList);
|
|
|
-// throw new IllegalStateException(goodsImg.getSysImgNm() + " 상품이미지 파일의 크기(" + width + "*" + height + ")가 맞지 않습니다. (올바른 크기: 1079*1499, 750*1041, 1000*1000)");
|
|
|
-
|
|
|
- index++;
|
|
|
}
|
|
|
|
|
|
//log.debug("resultGoodsImgList: {}", resultGoodsImgList);
|
|
|
|
|
|
// 상품이미지 저장 처리
|
|
|
- goodsService.saveGoodsImageMassList(resultGoodsImgList);
|
|
|
+ goodsService.saveGoodsImageMassList(resultGoodsImgListDb);
|
|
|
|
|
|
return super.ok(message.getMessage("SUCC_0007"));
|
|
|
}
|