Ver código fonte

[ST24PRJ-482][MD개선][제휴몰] 샵링커 기획전용 데이터 생성

jmh 4 anos atrás
pai
commit
3142987403

+ 10 - 0
src/main/java/com/style24/admin/biz/dao/TsaShoplinkerDao.java

@@ -109,6 +109,16 @@ public interface TsaShoplinkerDao {
 	 */
 	Collection<GagaMap> getGoodsSendExcelList(ShoplinkerSearch shoplinkerSearch);
 
+	/**
+	 * 상품등록-기획전 엑셀 다운로드
+	 *
+	 * @param shoplinkerSearch
+	 * @return
+	 * @author jmh
+	 * @since 2021. 11. 16
+	 */
+	Collection<GagaMap> getGoodsSendExcelPlanning(ShoplinkerSearch shoplinkerSearch);
+
 	/**
 	 * 재고-단품 등록
 	 *

+ 31 - 0
src/main/java/com/style24/admin/biz/service/TsaShoplinkerService.java

@@ -937,6 +937,37 @@ public class TsaShoplinkerService {
 			throw new IllegalStateException(e);
 		}
 	}
+	
+	/**
+	 * 상품등록-기획전 엑셀 다운로드
+	 *
+	 * @param shoplinkerSearch
+	 * @param excelFilenameWithPath - 경로를 포함한 엑셀파일명
+	 * @return
+	 * @author jmh
+	 * @since 2021. 11. 16
+	 */
+	public void getGoodsSendExcelPlanning(ShoplinkerSearch shoplinkerSearch, String excelFilenameWithPath) {
+
+		// 헤더 title 설정
+		String[] listTitles = {"샵링커 상품코드\n(단품아님.상품기준)", "sku코드", "선택1", "선택2"};
+
+		// DB 처리 시 사용되는 파라미터명(셀명) 설정
+		String[] cellNames = {"API_PRODUCT_ID", "OPT_CD", "OPT_CD1", "OPT_CD2"};
+
+		String[] cellTypes = {
+			GagaExcelConstants.CellType.CHAR_LEFT.name(), GagaExcelConstants.CellType.CHAR_LEFT.name(),
+			GagaExcelConstants.CellType.CHAR_LEFT.name(), GagaExcelConstants.CellType.CHAR_LEFT.name()};
+
+		Collection<GagaMap> dataList = admShoplinkerDao.getGoodsSendExcelPlanning(shoplinkerSearch);
+
+		try {
+
+			GagaExcelUtil.createExcel(excelFilenameWithPath, dataList, listTitles, cellNames, cellTypes);
+		} catch (Exception e) {
+			throw new IllegalStateException(e);
+		}
+	}
 
 
 	/**

+ 27 - 0
src/main/java/com/style24/admin/biz/web/TsaShoplinkerController.java

@@ -287,6 +287,33 @@ log.info(" #### SHOPLINKER CHKE 1 - "+runMap.getRunCnt()+" | "+runMap.getSidOver
 
 		return GagaFileUtil.writeFile(request, excelFilenameWithPath);
 	}
+	
+	/**
+	 * 샵링커상품등록- 엑셀다운로드
+	 *
+	 * @param shoplinkerSearch
+	 * @return
+	 * @author jmh
+	 * @since 2021. 06. 29
+	 */
+	@GetMapping("/goods/excel/planning")
+	public ResponseEntity<InputStreamResource> downloadGoodsPlanningExcel(HttpServletRequest request, ShoplinkerSearch shoplinkerSearch) throws Exception {
+		String excelfileName = "샵링커_기획전_" + GagaDateUtil.getTodayDateTime() + ".xlsx";
+		String excelFilenameWithPath = GagaFileUtil.getConcatenationPath(env.getProperty("download.path"), "excel", excelfileName);
+
+		// multi row 검색관련 처리
+		if (!StringUtils.isBlank(shoplinkerSearch.getCondition())) {
+			shoplinkerSearch.setConditionList(shoplinkerSearch.getCondition().replaceAll("\r", "").trim().split("\n"));
+		}
+
+		if( 500 < shoplinkerSearch.getConditionList().length ) {
+			throw new IllegalStateException("상품코드를 500개 이하로 입력해주세요.");
+		}
+		
+		admShoplinkerService.getGoodsSendExcelPlanning(shoplinkerSearch, excelFilenameWithPath);
+
+		return GagaFileUtil.writeFile(request, excelFilenameWithPath);
+	}
 
 
 	/**

+ 22 - 1
src/main/java/com/style24/persistence/mybatis/shop/TsaShoplinker.xml

@@ -272,7 +272,28 @@
 
 		ORDER BY REG_DT DESC
 	</select>
-
+	
+	<!-- 상품등록-기획전 엑셀 다운로드 -->
+	<select id="getGoodsSendExcelPlanning" parameterType="ShoplinkerSearch" resultType="paramMap">
+		/* TsaShoplinker.getGoodsSendExcelPlanning */
+		SELECT
+			A.API_PRODUCT_ID
+			, A.GOODS_CD
+			, OP.OPT_CD
+			, OP.OPT_CD1
+			, OP.OPT_CD2
+		FROM SHOPLINKER_SYNC_HST A
+		LEFT OUTER JOIN TB_OPTION OP ON A.GOODS_CD = OP.GOODS_CD
+		WHERE A.GOODS_CD IN
+            <foreach collection="conditionList" item="item" index="index"  open="(" close=")" separator=",">
+       		UPPER(#{item})
+            </foreach>
+		AND A.API_TYPE = 'PRODUCT'
+		AND A.API_PRODUCT_ID IS NOT NULL
+		GROUP BY A.API_PRODUCT_ID, A.GOODS_CD, OP.OPT_CD, OP.OPT_CD1, OP.OPT_CD2
+		ORDER BY A.API_PRODUCT_ID, OP.DISP_ORD, OP.OPT_CD1, OP.OPT_CD2
+	</select>
+	
 	<!-- 재고-단품 등록 -->
 	<insert id="insertStockOption" parameterType="ShoplinkerGoods">
 		/* TsaShoplinker.insertStockOption */

+ 21 - 0
src/main/webapp/WEB-INF/views/shoplinker/ShoplinkerGoodsSendForm.html

@@ -94,6 +94,7 @@
 							<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
 							<button type="button" class="btn btn-gray btn-lg" id="btnInit">초기화</button>
 							<button type="button" class="btn btn-primary btn-lg" id="btnGoodsUpload">엑셀업로드</button>
+							<button type="button" class="btn btn-primary btn-lg" id="btnGoodsPlanning">샵링커기획전생성엑셀</button>
 							<!-- <button th:if="${sessionInfo.userId == 'jmh'}" type="button" class="btn btn-default btn-lg" onclick="fnTest();">테스트</button> -->
 						</li>
 					</ul>
@@ -406,6 +407,26 @@
 	}
 	/**************** 엑셀다운로드 // *****************************************************/
 
+	/**************** 샵링커기획전생성엑셀 *****************************************************/
+	$('#btnGoodsPlanning').on('click', function() {
+		var formId = '#searchForm';
+		if (gagajf.isNull($("#searchForm textarea[name=condition]").val()) ){
+			
+			mcxDialog.alertC("상품 코드를 입력하세요", {
+				sureBtnText: "확인",
+				sureBtnClick: function() {
+					$("#searchForm textarea[name=condition]").focus();
+				}
+			});
+			return false;
+		}
+		
+		var params =  $(formId).serialize();
+		$('#ExcelList').attr({ href : '/shoplinker/goods/excel/planning?' + params }).get(0).click();
+		
+	});
+	/**************** 샵링커기획전생성엑셀 // *****************************************************/
+	
 	/**************** 테스트용  *******************************************************/
     // 테스트- 실제 샵링커 호출
 	var fnTest = function(){