|
|
@@ -1,5 +1,8 @@
|
|
|
package com.style24.scm.biz.web;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -15,9 +18,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
+import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.style24.core.support.message.TscMessageByLocale;
|
|
|
import com.style24.persistence.TssPageRequest;
|
|
|
+import com.style24.persistence.domain.Goods;
|
|
|
+import com.style24.persistence.domain.GoodsCompose;
|
|
|
+import com.style24.persistence.domain.GoodsHst;
|
|
|
+import com.style24.persistence.domain.GoodsNotiInfo;
|
|
|
import com.style24.persistence.domain.GoodsSearch;
|
|
|
+import com.style24.persistence.domain.NotiInfo;
|
|
|
import com.style24.persistence.domain.User;
|
|
|
import com.style24.scm.biz.service.TssCommonService;
|
|
|
import com.style24.scm.biz.service.TssGoodsService;
|
|
|
@@ -28,7 +38,10 @@ import com.style24.scm.support.security.session.TssSession;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
+import com.gagaframework.excel.GagaExcelUtil;
|
|
|
import com.gagaframework.web.parameter.GagaMap;
|
|
|
+import com.gagaframework.web.rest.server.GagaResponse;
|
|
|
+import com.gagaframework.web.rest.server.GagaResponseStatus;
|
|
|
import com.gagaframework.web.util.GagaDateUtil;
|
|
|
import com.gagaframework.web.util.GagaFileUtil;
|
|
|
|
|
|
@@ -75,9 +88,12 @@ public class TssGoodsController extends TssBaseController {
|
|
|
// 공급업체
|
|
|
String supplyCompCd = "";
|
|
|
String selfYn = "Y";
|
|
|
- if ("G001_B000".equals(TssSession.getInfo().getRoleCd())) {
|
|
|
+ if ("G001_B000".equals(TssSession.getInfo().getRoleCd())) { //입점업체담당자
|
|
|
supplyCompCd = TssSession.getInfo().getSupplyCompCd();
|
|
|
selfYn = "N";
|
|
|
+ }else if ("G001_E000".equals(TssSession.getInfo().getRoleCd())) { // 촬영업체
|
|
|
+ supplyCompCd = TssSession.getInfo().getSupplyCompCd();
|
|
|
+ selfYn = "Y";
|
|
|
}
|
|
|
mav.addObject("supplyCompList", rendererService.getSupplyCompanyList(supplyCompCd, selfYn));
|
|
|
// 상품상태
|
|
|
@@ -185,6 +201,386 @@ public class TssGoodsController extends TssBaseController {
|
|
|
return GagaFileUtil.writeFile(request, excelFilenameWithPath);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 상품 수정 항목 일괄변경
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 01. 17
|
|
|
+ */
|
|
|
+ @PostMapping("/state/update")
|
|
|
+ @ResponseBody
|
|
|
+ public GagaMap updateGoodsState(@RequestBody Goods goods) {
|
|
|
+
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+ result.set("status", GagaResponseStatus.SUCCESS.getCode()); // 200
|
|
|
+ result.set("procJob", goods.getProcJob());
|
|
|
+ // result.set("message", message.getMessage("SUCC_0001"));
|
|
|
+
|
|
|
+ String returnGoods = "";
|
|
|
+ String resultFlag = "SUCC";
|
|
|
+
|
|
|
+ if (!"G001_0000".equals(TssSession.getInfo().getRoleCd()) && !"G001_A000".equals(TssSession.getInfo().getRoleCd())
|
|
|
+ && !"G001_A001".equals(TssSession.getInfo().getRoleCd()) && !"G001_A100".equals(TssSession.getInfo().getRoleCd())
|
|
|
+ && !"G001_A101".equals(TssSession.getInfo().getRoleCd())) {
|
|
|
+ throw new IllegalStateException("권한이 없습니다.");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 상품 상태 변경일 경우 체크
|
|
|
+ if ("goodsStat".equals(goods.getProcJob()) && ("G008_40".equals(goods.getGoodsStat()) || "G008_90".equals(goods.getGoodsStat()))) {
|
|
|
+
|
|
|
+ // 이미지
|
|
|
+ Collection<Goods> goodsList = goodsService.getGoodsImgsYn(goods);
|
|
|
+
|
|
|
+ for (Goods tmpGoods : goodsList) {
|
|
|
+ if ("N".equals(tmpGoods.getGoodsImageYn())) {
|
|
|
+ returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+ } else {
|
|
|
+
|
|
|
+ // 택가/판매가 입력 여부 확인
|
|
|
+ Goods dataGoods = goodsService.getGoods(tmpGoods);
|
|
|
+ if (dataGoods == null) {
|
|
|
+ returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (dataGoods.getListPrice() <= 0 || dataGoods.getCurrPrice() <= 0) {
|
|
|
+ returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 사이즈 등록 여부 확인
|
|
|
+// Stock stock = new Stock();
|
|
|
+// stock.setGoodsCd(tmpGoods.getGoodsCd());
|
|
|
+// int stockCnt = goodsService.getGoodsSizeCount(stock);
|
|
|
+// if (stockCnt <= 0) {
|
|
|
+// returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+
|
|
|
+ //고시정보
|
|
|
+// GoodsNotiInfo goodsNotiInfo = new GoodsNotiInfo();
|
|
|
+// goodsNotiInfo.setGoodsCd(tmpGoods.getGoodsCd());
|
|
|
+// goodsNotiInfo.setSupplyCompCd(tmpGoods.getSupplyCompCd());
|
|
|
+// goodsNotiInfo.setNiClsfCd(tmpGoods.getNiClsfCd());
|
|
|
+// Collection<GoodsNotiInfo> goodsNotiInfoList = goodsService.getGoodsNotiInfoList(goodsNotiInfo);
|
|
|
+// if (goodsNotiInfoList == null || goodsNotiInfoList.isEmpty()) {
|
|
|
+// returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+// } else {
|
|
|
+// for (GoodsNotiInfo tmpGoodsNotiInfo : goodsNotiInfoList) {
|
|
|
+// if ("Y".equals(tmpGoodsNotiInfo.getReqYn()) || "Y".equals(tmpGoodsNotiInfo.getDispYn())) {
|
|
|
+// if (StringUtils.isEmpty(tmpGoodsNotiInfo.getNiContent())) {
|
|
|
+// returnGoods += tmpGoods.getGoodsCd() + ",";
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (returnGoods.length() > 0) {
|
|
|
+ returnGoods = returnGoods.substring(0, returnGoods.lastIndexOf(","));
|
|
|
+ returnGoods = returnGoods.replaceAll(",", ",<br/>");
|
|
|
+ resultFlag = "FAIL";
|
|
|
+ result.set("resultFlag", resultFlag);
|
|
|
+ result.set("returnGoods", returnGoods);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsService.updateGoodsState(goods);
|
|
|
+
|
|
|
+ result.set("resultFlag", resultFlag);
|
|
|
+ result.set("returnGoods", returnGoods);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 엑셀조회용 상품 저장
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 10. 20
|
|
|
+ */
|
|
|
+ @PostMapping("/search/excelupload/save")
|
|
|
+ @ResponseBody
|
|
|
+ public GagaResponse saveExceluploadGoods(@RequestBody Goods goods) throws Exception {
|
|
|
+
|
|
|
+ int cnt = 0;
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+
|
|
|
+ String targetPath = GagaFileUtil.getConcatenationPath(env.getProperty("upload.excel.target.path"), "excel");
|
|
|
+
|
|
|
+ // DB 처리 시 사용되는 파라미터명(셀명) 설정
|
|
|
+ String[] cellName = {"goodsCd", "supplyGoodsCd"};
|
|
|
+
|
|
|
+ Collection<GagaMap> ecxelGoodsList = GagaExcelUtil.getList(GagaFileUtil.getConcatenationPath(targetPath, goods.getExcelFileNm()), 0, cellName, 0);
|
|
|
+
|
|
|
+ Collection<Goods> goodsList = new ArrayList<>();
|
|
|
+ for (GagaMap map : ecxelGoodsList) {
|
|
|
+ Goods tmpGoods = mapper.convertValue(map, Goods.class);
|
|
|
+ tmpGoods.setRegNo(TssSession.getInfo().getUserNo());
|
|
|
+ tmpGoods.setProcJob(goods.getProcJob());
|
|
|
+ goodsList.add(tmpGoods);
|
|
|
+ cnt++;
|
|
|
+ }
|
|
|
+
|
|
|
+ goodsService.saveExceluploadGoods(goodsList, goods.getExcelFileNm());
|
|
|
+
|
|
|
+ // 파일 삭제
|
|
|
+ GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(targetPath, goods.getExcelFileNm()));
|
|
|
+
|
|
|
+ return super.ok("");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 엑셀 업로드 상품 조회
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return GagaMap
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 11. 02
|
|
|
+ */
|
|
|
+ @PostMapping("/excel/upload/goods/list")
|
|
|
+ @ResponseBody
|
|
|
+ public GagaMap getExcelUploadGoodsList() {
|
|
|
+ GagaMap result = new GagaMap();
|
|
|
+ GoodsSearch goodsSearch = new GoodsSearch();
|
|
|
+ goodsSearch.setSearchGb("EXCEL");
|
|
|
+ // 입점업체담당자는 업체코드 설정
|
|
|
+ if ("G001_B000".equals(TssSession.getInfo().getRoleCd())) {
|
|
|
+ goodsSearch.setSupplyCompCd(TssSession.getInfo().getSupplyCompCd());
|
|
|
+ goodsSearch.setMdNo(TssSession.getInfo().getUserNo().toString());
|
|
|
+ }
|
|
|
+ goodsSearch.setRegNo(TssSession.getInfo().getUserNo()); // 엑셀조회시 로그인 사용자의 엑셀 상품조회시 사용
|
|
|
+ result.set("goodsExcelList", goodsService.getGoodsList(goodsSearch));
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 상세 화면
|
|
|
+ *
|
|
|
+ * @param goodsCode - 상품코드
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 10. 23
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/form")
|
|
|
+ @ResponseBody
|
|
|
+ public ModelAndView detailForm(Goods goods) {
|
|
|
+ ModelAndView mav = new ModelAndView();
|
|
|
+
|
|
|
+ // 공급업체
|
|
|
+ String supplyCompCd = "";
|
|
|
+ mav.addObject("supplyCompList", rendererService.getSupplyCompanyList(supplyCompCd));
|
|
|
+// String selfYn = "Y";
|
|
|
+// if ("G001_B000".equals(TssSession.getInfo().getRoleCd())) {
|
|
|
+// supplyCompCd = TssSession.getInfo().getSupplyCompCd();
|
|
|
+// selfYn = "N";
|
|
|
+// }
|
|
|
+// mav.addObject("supplyCompList", rendererService.getSupplyCompanyList(supplyCompCd, selfYn));
|
|
|
+
|
|
|
+ String[] goodsStatExceptCds = {"G008_00"};
|
|
|
+ mav.addObject("goodsStatList", rendererService.getCommonCodeList("G008", "Y", goodsStatExceptCds));
|
|
|
+
|
|
|
+ // 정상이월
|
|
|
+ mav.addObject("formalGbList", rendererService.getAvailCommonCodeList("G009"));
|
|
|
+ // 성별
|
|
|
+ mav.addObject("sexGbList", rendererService.getAvailCommonCodeList("G007"));
|
|
|
+ // 시즌
|
|
|
+ mav.addObject("seasonList", rendererService.getAvailCommonCodeList("G006"));
|
|
|
+ // 사용여부
|
|
|
+ mav.addObject("useYnList", rendererService.getAvailCommonCodeList("G002"));
|
|
|
+ // 품목
|
|
|
+ mav.addObject("itemkindList", rendererService.getAllItemkindList());
|
|
|
+ // 정보고시 분류
|
|
|
+ mav.addObject("niClsfCdList", rendererService.getAvailCommonCodeList("G004"));
|
|
|
+ // 사용자 브랜드 조회
|
|
|
+ mav.addObject("authBrandList", rendererService.getAuthBrandList(TssSession.getInfo().getUserNo()));
|
|
|
+ // 상품타입
|
|
|
+ mav.addObject("goodsTypeList", rendererService.getAvailCommonCodeList("G056"));
|
|
|
+ // 상품구분
|
|
|
+ mav.addObject("goodsGbList", rendererService.getAvailCommonCodeList("G073"));
|
|
|
+ // 유통구분
|
|
|
+ //String[] distributionGbExceptCds = {"G065_20"};
|
|
|
+ //mav.addObject("distributionGbList", rendererService.getCommonCodeList("G065", "Y", distributionGbExceptCds));
|
|
|
+ mav.addObject("distributionGbList", rendererService.getCommonCodeList("G065", "Y"));
|
|
|
+ // 상품연령대
|
|
|
+ mav.addObject("ageGrpCdList", rendererService.getAvailCommonCodeList("G023"));
|
|
|
+ // 년도
|
|
|
+ int toYear = Integer.parseInt(GagaDateUtil.getToday("yyyy")) - 4;
|
|
|
+ mav.addObject("styleYearList", rendererService.getYearList(toYear,0,5));
|
|
|
+ // 색상
|
|
|
+// Color color = new Color();
|
|
|
+// mav.addObject("colorList", rendererService.getColorList(color));
|
|
|
+
|
|
|
+ mav.addObject("params", goods);
|
|
|
+
|
|
|
+ mav.setViewName("goods/GoodsDetailForm");
|
|
|
+
|
|
|
+ return mav;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 상세 조회
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2019. 12. 11
|
|
|
+ */
|
|
|
+ @PostMapping("/detail")
|
|
|
+ @ResponseBody
|
|
|
+ public Goods getGoodsDetail(Goods goods) {
|
|
|
+ return goodsService.getGoods(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 이력 조회
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2019. 12. 12
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/hst/list")
|
|
|
+ @ResponseBody
|
|
|
+ public Collection<GoodsHst> getGoodsDetailHstList(Goods goods) {
|
|
|
+ return goodsService.getGoodsHstList(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 컬러 옵셥 재고
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 10. 26
|
|
|
+ */
|
|
|
+ @PostMapping("/detail/sizeStock/form")
|
|
|
+ public ModelAndView getGoodsDetailSizeStockForm(Goods goods) {
|
|
|
+
|
|
|
+ ModelAndView mav = new ModelAndView();
|
|
|
+ mav.addObject("goods", goodsService.getGoods(goods));
|
|
|
+ mav.addObject("goodsSizeList", goodsService.getGoodsSizeList(goods));
|
|
|
+ mav.addObject("goodsColorList", goodsService.getGoodsColorList(goods));
|
|
|
+ // 사용여부
|
|
|
+ mav.addObject("useYnList", rendererService.getAvailCommonCodeList("G002"));
|
|
|
+
|
|
|
+ mav.setViewName("goods/GoodsDetailSizeStockForm");
|
|
|
+
|
|
|
+ return mav;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 정보고시 조회
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2019. 12. 12
|
|
|
+ */
|
|
|
+ @PostMapping("/detail/notiInfo/list")
|
|
|
+ @ResponseBody
|
|
|
+ public Collection<GoodsNotiInfo> getGoodsDetailNotiInfoList(Goods goods) {
|
|
|
+
|
|
|
+ GoodsNotiInfo goodsInfo = new GoodsNotiInfo();
|
|
|
+ goodsInfo.setGoodsCd(goods.getGoodsCd());
|
|
|
+ goodsInfo.setNiClsfCd(goods.getNiClsfCd());
|
|
|
+ goodsInfo.setSupplyCompCd(goods.getSupplyCompCd());
|
|
|
+
|
|
|
+ return goodsService.getGoodsNotiInfoList(goodsInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품의 정보고시 항목 목록
|
|
|
+ *
|
|
|
+ * @param notiInfo
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2010. 11. 18
|
|
|
+ */
|
|
|
+ @PostMapping("/noti/goodsInfo/list")
|
|
|
+ @ResponseBody
|
|
|
+ public Collection<NotiInfo> getNotiGoodsInfoList(NotiInfo notiInfo) {
|
|
|
+ return goodsService.getNotiGoodsInfoList(notiInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 상세 저장
|
|
|
+ *
|
|
|
+ * @param goods
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 10. 27
|
|
|
+ */
|
|
|
+ @PostMapping("/detail/save")
|
|
|
+ @ResponseBody
|
|
|
+ public GagaResponse saveGoodsDetail(@RequestBody Goods goods) {
|
|
|
+
|
|
|
+ // 상품상태에 따른 이미지 정보 확인 - 상품상태가 승인대기나 승인 완료일 경우
|
|
|
+ if ("G008_40".equals(goods.getGoodsStat()) || "G008_90".equals(goods.getGoodsStat())) {
|
|
|
+ Collection<Goods> goodsList = goodsService.getGoodsImgsYn(goods);
|
|
|
+ String goodsImageYn = "N";
|
|
|
+ for (Goods tmpGoods : goodsList) {
|
|
|
+ goodsImageYn = tmpGoods.getGoodsImageYn();
|
|
|
+ }
|
|
|
+ if ("N".equals(goodsImageYn)) {
|
|
|
+ throw new IllegalStateException("필수 이미지나 고시정보가 등록되지 않은 상품은 <br/>'승인대기'나 '승인완료' 상태로 변경할 수 없습니다.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Collection<GoodsNotiInfo> notiList = null;
|
|
|
+ Collection<GoodsCompose> goodComposeList = null;
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
+ try {
|
|
|
+ if (goods.getNotiList() != null) {
|
|
|
+ notiList = mapper.readValue(goods.getNotiList(), new TypeReference<Collection<GoodsNotiInfo>>() {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (goods.getGoodsComposeList() != null) {
|
|
|
+ goodComposeList = mapper.readValue(goods.getGoodsComposeList(), new TypeReference<Collection<GoodsCompose>>() {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ goods.setNotiListNew(notiList);
|
|
|
+ goods.setGoodsComposeListNew(goodComposeList);
|
|
|
+
|
|
|
+ goodsService.saveGoodsDetail(goods);
|
|
|
+ return super.ok(message.getMessage("SUCC_0001"));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 상품 이미지 보기 화면
|
|
|
+ *
|
|
|
+ * @param goodsCode - 상품코드
|
|
|
+ * @return
|
|
|
+ * @author eskim
|
|
|
+ * @since 2020. 11. 09
|
|
|
+ */
|
|
|
+ @GetMapping("/detail/img/form")
|
|
|
+ @ResponseBody
|
|
|
+ public ModelAndView detailImageForm(Goods goods) {
|
|
|
+ ModelAndView mav = new ModelAndView();
|
|
|
+
|
|
|
+// goods = goodsService.getGoods(goods);
|
|
|
+// // mav.addObject("goodsImgList", goodsService.getGoodsImgList(goods)); //이미지 - 행
|
|
|
+// mav.addObject("goodsImgInfo", goodsService.getGoodsImg(goods)); // 이미지 - 열
|
|
|
+//
|
|
|
+ mav.addObject("params", goods);
|
|
|
+ mav.setViewName("goods/GoodsDetailImageForm");
|
|
|
+ return mav;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 상품 대량 등록 화면
|
|
|
*
|