Pārlūkot izejas kodu

샵링커수정

jmh 4 gadi atpakaļ
vecāks
revīzija
dd78c99a12

+ 22 - 69
src/main/java/com/style24/admin/biz/service/TsaShoplinkerService.java

@@ -62,49 +62,31 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	public GagaMap createShoplinkerXml(Collection<GagaMap> ecxelGoodsList, ShoplinkerGoods shoplinkerGoods)throws IOException {
+	public void createShoplinkerXml(Collection<GagaMap> ecxelGoodsList, ShoplinkerGoods shoplinkerGoods) {
 		// 파일명 추가 네이밍 규칙
 		fileAddNm = shoplinkerGoods.getRegNo() +"_"+ GagaDateUtil.getToday("yyMMddHHmmss");
 
-		GagaMap rtnMap = new GagaMap();
-		int optionAll=0, optionSucc=0;
-		int excelCnt= ecxelGoodsList.size();
-		int tProdSucc = 0, productSucc=0, goodsNotiSucc=0, certSucc=0, imageSucc=0;
-		log.info(" #### SHOPLINKER CHK3 - "+excelCnt);
+		log.info(" #### SHOPLINKER CHK3 - "+ecxelGoodsList.size());
 		for (GagaMap gagaMap : ecxelGoodsList) {
 			if( !"".equals(gagaMap.getString("goodsCd").trim())) {
 				shoplinkerGoods.setGoodsCd(gagaMap.getString("goodsCd"));
 
 				// 1. 단품생성
-				rtnMap = createOptionRegisterXml(shoplinkerGoods);
-				optionAll += rtnMap.getInt("allCnt");
-				optionSucc += rtnMap.getInt("succCnt");
+				createOptionRegisterXml(shoplinkerGoods);
 
 				// 2. 상품생성
-				tProdSucc = createGoodsRegisterXml(shoplinkerGoods);
-				productSucc += tProdSucc;
+				createGoodsRegisterXml(shoplinkerGoods);
 
 				// 3. 고시정보(품목정보)
-				goodsNotiSucc += createGoodsNotiRegisterXml(shoplinkerGoods);
+				createGoodsNotiRegisterXml(shoplinkerGoods);
 
 				// 4. 인증정보
-				certSucc += createCertRegisterXml(shoplinkerGoods);
+				createCertRegisterXml(shoplinkerGoods);
 
 				// 5. 상품이미지정보
-				imageSucc += createImageRegisterXml(shoplinkerGoods);
+				createImageRegisterXml(shoplinkerGoods);
 			}
 		}
-
-		rtnMap = new GagaMap();
-		rtnMap.setInt("excelCnt", excelCnt);
-		rtnMap.setInt("optionAll", optionAll);
-		rtnMap.setInt("optionSucc", optionSucc);
-		rtnMap.setInt("productSucc", productSucc);
-		rtnMap.setInt("goodsNotiSucc", goodsNotiSucc);
-		rtnMap.setInt("certSucc", certSucc);
-		rtnMap.setInt("imageSucc", imageSucc);
-
-		return rtnMap;
 	}
 
 	/**
@@ -115,9 +97,8 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	private GagaMap createOptionRegisterXml(ShoplinkerGoods shoplinkerGoods) throws IOException {
+	private void createOptionRegisterXml(ShoplinkerGoods shoplinkerGoods) {
 
-		GagaMap returnMap = new GagaMap();
 		ShoplinkerGoods regMap = new ShoplinkerGoods();
 		regMap.setApiType("OPTION");
 		regMap.setApiSubUrl(env.getProperty("shoplinker.url.option"));
@@ -126,14 +107,10 @@ public class TsaShoplinkerService {
 		regMap.setXmlPath(shoplinkerGoods.getXmlPath());
 		regMap.setDomainUrl(shoplinkerGoods.getDomainUrl());
 
-		int succCnt = 0;
-		int allCnt = 0;
-
 		try {
 			// 옵션 목록조회
 			Collection<ShoplinkerGoods> list = admShoplinkerDao.getOptionList(shoplinkerGoods);
 			if( null != list && !list.isEmpty()) {
-				allCnt = list.size();
 
 				StringBuilder sbRequest;
 				int opCnt = 0;
@@ -166,7 +143,7 @@ public class TsaShoplinkerService {
 					regMap.setQuantity(map.getQuantity());		// 재고 기록은 실재고 기록 0일경우 샵링커에 전송하지 않기위함.(md가 샵링커에서 몰로 수동전송시 재고가 0일경우 몰에 등록안된다 함)
 
 					// api 호출 및 결과 history 저장
-					succCnt += callGoodsRegApi(regMap , sbRequest, "option_"+opCnt);
+					callGoodsRegApi(regMap , sbRequest, "option_"+opCnt);
 				}
 			}
 		}catch(Exception e) {
@@ -175,11 +152,6 @@ public class TsaShoplinkerService {
 			regMap.setApiMessage("xml 생성오류");
 			tscShoplinkerDao.insertShoplinerApiHst(regMap);
 		}
-
-		returnMap.setInt("allCnt", allCnt);
-		returnMap.setInt("succCnt", succCnt);
-
-		return returnMap;
 	}
 
 	/**
@@ -190,7 +162,7 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	public int createGoodsRegisterXml(ShoplinkerGoods shoplinkerGoods) throws IOException {
+	public void createGoodsRegisterXml(ShoplinkerGoods shoplinkerGoods) {
 
 		ShoplinkerGoods regMap = new ShoplinkerGoods();
 		regMap.setApiType("PRODUCT");
@@ -200,8 +172,6 @@ public class TsaShoplinkerService {
 		regMap.setXmlPath(shoplinkerGoods.getXmlPath());
 		regMap.setDomainUrl(shoplinkerGoods.getDomainUrl());
 
-		int succCnt = 0;
-
 		try {
 			// 상품기본정보
 			ShoplinkerGoods goodsMap = admShoplinkerDao.getGoods(shoplinkerGoods);
@@ -265,7 +235,7 @@ public class TsaShoplinkerService {
 
 			if( null != goodsMap.getShoplinkerItemkindNm()) {
 				// api 호출 및 결과 history 저장
-				succCnt = callGoodsRegApi(regMap , sbRequest, "product");
+				callGoodsRegApi(regMap , sbRequest, "product");
 
 			}else {
 				// 품목매핑정보 없음. 전송 안함
@@ -281,8 +251,6 @@ public class TsaShoplinkerService {
 			regMap.setApiMessage("xml 생성오류");
 			tscShoplinkerDao.insertShoplinerApiHst(regMap);
 		}
-
-		return succCnt;
 	}
 
 	/**
@@ -590,7 +558,7 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	private int createGoodsNotiRegisterXml(ShoplinkerGoods shoplinkerGoods) throws IOException {
+	private void createGoodsNotiRegisterXml(ShoplinkerGoods shoplinkerGoods) {
 
 		ShoplinkerGoods regMap = new ShoplinkerGoods();
 		regMap.setApiType("NOTI");
@@ -600,8 +568,6 @@ public class TsaShoplinkerService {
 		regMap.setXmlPath(shoplinkerGoods.getXmlPath());
 		regMap.setDomainUrl(shoplinkerGoods.getDomainUrl());
 
-		int succCnt = 0;
-
 		try {
 
 			Collection<ShoplinkerGoods> list = admShoplinkerDao.getGoodsNotiList(shoplinkerGoods);
@@ -636,7 +602,7 @@ public class TsaShoplinkerService {
 					sbRequest.append("</openMarket>\n");
 
 					// api 호출 및 결과 history 저장
-					succCnt = callGoodsRegApi(regMap , sbRequest, "goods");
+					callGoodsRegApi(regMap , sbRequest, "goods");
 				}
 			}
 
@@ -646,7 +612,6 @@ public class TsaShoplinkerService {
 			regMap.setApiMessage("xml 생성오류");
 			tscShoplinkerDao.insertShoplinerApiHst(regMap);
 		}
-		return succCnt;
 	}
 
 	/**
@@ -657,7 +622,7 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	private int createCertRegisterXml(ShoplinkerGoods shoplinkerGoods) throws IOException {
+	private void createCertRegisterXml(ShoplinkerGoods shoplinkerGoods) {
 
 		ShoplinkerGoods regMap = new ShoplinkerGoods();
 		regMap.setApiType("CERT");
@@ -667,8 +632,6 @@ public class TsaShoplinkerService {
 		regMap.setXmlPath(shoplinkerGoods.getXmlPath());
 		regMap.setDomainUrl(shoplinkerGoods.getDomainUrl());
 
-		int succCnt = 0;
-
 		try {
 
 			ShoplinkerGoods map = admShoplinkerDao.getCert(shoplinkerGoods);
@@ -706,7 +669,7 @@ public class TsaShoplinkerService {
 			sbRequest.append("</shoplinker>\n");
 
 			// api 호출 및 결과 history 저장
-			succCnt = callGoodsRegApi(regMap , sbRequest, "cert");
+			callGoodsRegApi(regMap , sbRequest, "cert");
 
 		}catch(Exception e) {
 			log.error("xml 생성오류 ", e);
@@ -714,8 +677,6 @@ public class TsaShoplinkerService {
 			regMap.setApiMessage("xml 생성오류");
 			tscShoplinkerDao.insertShoplinerApiHst(regMap);
 		}
-
-		return succCnt;
 	}
 
 	/**
@@ -726,7 +687,7 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	private int createImageRegisterXml(ShoplinkerGoods shoplinkerGoods) throws IOException {
+	private void createImageRegisterXml(ShoplinkerGoods shoplinkerGoods) {
 
 		ShoplinkerGoods regMap = new ShoplinkerGoods();
 		regMap.setApiType("IMAGE");
@@ -736,8 +697,6 @@ public class TsaShoplinkerService {
 		regMap.setXmlPath(shoplinkerGoods.getXmlPath());
 		regMap.setDomainUrl(shoplinkerGoods.getDomainUrl());
 
-		int succCnt = 0;
-
 		try {
 
 			// 상품이미지정보
@@ -780,7 +739,7 @@ public class TsaShoplinkerService {
 				sbRequest.append("</Shoplinker>\n");
 
 				// api 호출 및 결과 history 저장
-				succCnt = callGoodsRegApi(regMap , sbRequest, "image");
+				callGoodsRegApi(regMap , sbRequest, "image");
 			}
 
 		}catch(Exception e) {
@@ -789,8 +748,6 @@ public class TsaShoplinkerService {
 			regMap.setApiMessage("xml 생성오류");
 			tscShoplinkerDao.insertShoplinerApiHst(regMap);
 		}
-
-		return succCnt;
 	}
 
 	/**
@@ -801,13 +758,13 @@ public class TsaShoplinkerService {
 	 * @author jmh
 	 * @since 2021. 5. 20
 	 */
-	private int callGoodsRegApi(ShoplinkerGoods map, StringBuilder sbRequest, String fileNm) throws IOException {
+	private void callGoodsRegApi(ShoplinkerGoods map, StringBuilder sbRequest, String fileNm) throws Exception {
 
-		int succCnt = 0;
 		map.setApiProductId(null);
 		com.gagaframework.shoplinker.domain.goods.result.Shoplinker shoplinkerResult;
 		com.gagaframework.shoplinker.domain.goods.result.ResultMessage resultMsg;
 
+		String responseXmlData = "";
 		StringBuilder xmlFileName = new StringBuilder();
 
 		try {
@@ -824,7 +781,7 @@ public class TsaShoplinkerService {
 			String apiUrl = GagaShoplinkerConstants.API_DOMAIN + map.getApiSubUrl() + URLEncoder.encode(xmlUrl);
 
 			// API 호출결과
-			String responseXmlData = shoplinkerUtil.callShoplinkerApiByGet(apiUrl, "");
+			responseXmlData = shoplinkerUtil.callShoplinkerApiByGet(apiUrl, "");
 
 			// response 결과
 			shoplinkerResult = (com.gagaframework.shoplinker.domain.goods.result.Shoplinker)shoplinkerUtil.unmarshal(com.gagaframework.shoplinker.domain.goods.result.Shoplinker.class, responseXmlData);
@@ -836,8 +793,6 @@ public class TsaShoplinkerService {
 			map.setApiMessage(StringUtils.abbreviate(resultMsg.getMessage(), 0 , 120));
 
 			if( "true".equals(resultMsg.getResult())){
-				succCnt = 1;
-
 				// 재고 단품 생성
 				if( "OPTION".equals(map.getApiType())) {
 					admShoplinkerDao.insertStockOption(map);
@@ -845,10 +800,10 @@ public class TsaShoplinkerService {
 			}
 
 		} catch (Exception e) {
-			log.error("error", e);
+			log.error(" callGoodsRegApi error", e);
 			map.setXmlTxt(sbRequest.toString());
 			map.setApiResult("error");
-			map.setApiMessage("API 오류");
+			map.setApiMessage("API 오류 "+StringUtils.abbreviate(responseXmlData, 0 , 120));
 		}
 
 		// 전송이력 저장
@@ -856,8 +811,6 @@ public class TsaShoplinkerService {
 
 		// 생성 파일삭제
 		GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(map.getXmlPath(), xmlFileName.toString()));
-
-		return succCnt;
 	}
 
 	/**

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

@@ -209,7 +209,7 @@ log.info(" #### SHOPLINKER CHK1 - "+runMap.getRunCnt() +" || "+GagaDateUtil.getT
 				shoplinkerGoods.setCustomerId(env.getProperty("shoplinker.customer_id"));
 				shoplinkerGoods.setRegNo(TsaSession.getInfo().getUserNo());
 				log.info(" #### SHOPLINKER CHK2 ");
-				rtnMap = admShoplinkerService.createShoplinkerXml(ecxelGoodsList, shoplinkerGoods);
+				admShoplinkerService.createShoplinkerXml(ecxelGoodsList, shoplinkerGoods);
 
 				// 4. 파일 삭제
 				GagaFileUtil.deleteFile(GagaFileUtil.getConcatenationPath(targetPath, shoplinkerGoods.getExcelFileNm()));

+ 1 - 1
src/main/webapp/WEB-INF/views/shoplinker/ShoplinkerOrderForm.html

@@ -29,7 +29,7 @@
 
 			<div class="panelStyle">
 				<div class="panelTitle">
-					<h3><i class="fa fa-info-circle"></i>[배치주기] 평일: 5시~15시 한시간 단위 | (월) 5시: 전주 금요일 15 ~ 금일 5시 / (화~금) 5시: 전날 15 ~ 금일 5시 -T1</h3>
+					<h3><i class="fa fa-info-circle"></i>[배치주기] 평일: 5시~15시 한시간 단위 | (월) 5시: 전주 금요일 15 ~ 금일 5시 / (화~금) 5시: 전날 15 ~ 금일 5시 -v1</h3>
 					<span class="panelControl">
 						<i class="fa fa-chevron-up"></i>
 					</span>