eskim 5 years ago
parent
commit
bb5c2eadde

+ 117 - 0
src/main/java/com/style24/batch/biz/dao/TsbGoodsEPDao.java

@@ -0,0 +1,117 @@
+package com.style24.batch.biz.dao;
+
+import java.util.Collection;
+
+import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.Goods;
+import com.style24.persistence.domain.GoodsEP;
+
+/**
+ * 네이버EP Dao
+ *
+ * @author eskim
+ * @since 2020. 08. 23
+ */
+@ShopDs
+public interface TsbGoodsEPDao {
+
+	/**
+	 * TB_NAVER_EP 삭제
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 23
+	 */
+	void deleteTbNaverEp();
+
+	/**
+	 * TB_NAVER_EP 생성
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 23
+	 */
+	void createTbNaverEp(Goods goods);
+
+	/**
+	 * TB_NAVER_EP_TEMP 생성
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 23
+	 */
+	void createTbNaverEpTemp(Goods goods);
+
+	/**
+	 * 네이버 전체 EP 상품 리스트 조회
+	 *
+	 * @return
+	 * @author eskim
+	 * @since 2020. 8. 23.
+	 */
+	Collection<GoodsEP> getNaverAllEPList(Goods goods);
+
+	/**
+	 * 네이버 요약 EP 상품 리스트 조회
+	 *
+	 * @return
+	 * @author eskim
+	 * @since 2020. 8. 23.
+	 */
+	Collection<GoodsEP> getNaverEPList(Goods goods);
+
+	/**
+	 * TB_NAVER_EP_TEMP 삭제
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 23
+	 */
+	void deleteTbNaverEpTemp();
+
+	/**
+	 * 네이버 전체 EP 상품 정보 변경건 저장
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 23
+	 */
+	void createTbNaverEpTempOfGoods(Goods goods);
+
+	/**
+	 * TB_NAVER_EP_MARKETING 삭제
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 30
+	 */
+	void deleteTbNaverEpMarketing();
+
+	/**
+	 * TB_NAVER_EP_MARKETING 생성
+	 *
+	 * @param
+	 * @author eskim
+	 * @since 2020. 08. 30
+	 */
+	void createTbNaverEpMarketing(Goods goods);
+
+	/**
+	 * 마케팅 전체 상품 리스트 조회
+	 *
+	 * @return
+	 * @author eskim
+	 * @since 2020. 8. 30.
+	 */
+	Collection<GoodsEP> getNaverMarketingAllEPList(Goods goods);
+
+	/**
+	 * 리얼클릭용 상품
+	 *
+	 * @return
+	 * @author eskim
+	 * @since 2020. 8. 30.
+	 */
+	Collection<GoodsEP> getRealClickEPList(Goods goods);
+
+}

+ 59 - 0
src/main/java/com/style24/batch/biz/job/goods/TsbGoodsEpNaverGoods.java

@@ -0,0 +1,59 @@
+package com.style24.batch.biz.job.goods;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.style24.batch.biz.job.TsbAbstractJob;
+import com.style24.batch.biz.service.TsbCommonService;
+import com.style24.batch.biz.service.TsbGoodsEPService;
+import com.style24.persistence.domain.GoodsEP;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 네이버 상품
+ *
+ * @author eskim
+ * @since 2021. 01. 25
+ */
+@Component
+@Slf4j
+public class TsbGoodsEpNaverGoods extends TsbAbstractJob<GoodsEP, GoodsEP, GoodsEP> {
+
+	@Autowired
+	private TsbGoodsEPService goodsEPService;
+
+	@Autowired
+	private TsbCommonService commonService;
+
+	private int succCnt = 0;
+	private int failCnt = 0;
+	private String jobdate = "";
+
+	@Override
+	public GoodsEP read() throws Exception {
+
+		GoodsEP goodsEP = new GoodsEP();
+		return goodsEP;
+	}
+
+	@Override
+	public GoodsEP process(GoodsEP goodsEP) throws Exception {
+
+		goodsEPService.createNaverEP();
+
+		return goodsEP;
+	}
+
+	@Override
+	public GoodsEP write(GoodsEP goodsEP) throws Exception {
+
+		return goodsEP;
+	}
+
+	@Override
+	public void notify(GoodsEP goodsEP) throws Exception {
+		super.printResult(succCnt, failCnt);
+	}
+
+}

+ 1 - 1
src/main/java/com/style24/batch/biz/job/goods/TsbGoodsWmsProductJob.java → src/main/java/com/style24/batch/biz/job/goods/TsbGoodsWmsGoodsJob.java

@@ -20,7 +20,7 @@ import com.gagaframework.web.util.GagaDateUtil;
  */
 @Component
 @Slf4j
-public class TsbGoodsWmsProductJob extends TsbAbstractJob<IfProduct, IfProduct, IfProduct> {
+public class TsbGoodsWmsGoodsJob extends TsbAbstractJob<IfProduct, IfProduct, IfProduct> {
 
 	@Autowired
 	private TsbWmsGoodsService wmsGoodsService;

+ 1 - 1
src/main/java/com/style24/batch/biz/job/goods/TsbGoodsWmsProductStockJob.java → src/main/java/com/style24/batch/biz/job/goods/TsbGoodsWmsGoodsStockJob.java

@@ -21,7 +21,7 @@ import com.gagaframework.web.util.GagaDateUtil;
  */
 @Component
 @Slf4j
-public class TsbGoodsWmsProductStockJob extends TsbAbstractJob<IfProductSku, IfProductSku, IfProductSku> {
+public class TsbGoodsWmsGoodsStockJob extends TsbAbstractJob<IfProductSku, IfProductSku, IfProductSku> {
 
 	@Autowired
 	private TsbGoodsService goodsService;

+ 240 - 0
src/main/java/com/style24/batch/biz/service/TsbGoodsEPService.java

@@ -0,0 +1,240 @@
+package com.style24.batch.biz.service;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.style24.batch.biz.dao.TsbGoodsEPDao;
+import com.style24.persistence.domain.Goods;
+import com.style24.persistence.domain.GoodsEP;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.gagaframework.web.util.GagaDateUtil;
+import com.gagaframework.web.util.GagaStringUtil;
+
+/**
+ * 네이버 EP Service
+ *
+ * @author eskim
+ * @since 2020. 01. 25
+ */
+@Service
+@Slf4j
+public class TsbGoodsEPService {
+
+	@Autowired
+	private Environment env;
+
+	@Autowired
+	private TsbGoodsEPDao goodsEPDao;
+
+//	@Autowired
+//	private TsbPolicyService policyService;
+
+	/**
+	 * 네이버 EP 작업
+	 *
+	 * @param
+	 * @return
+	 * @author eskim
+	 * @throws IOException
+	 * @since 2020. 08. 23
+	 */
+	@Transactional("shopTxnManager")
+	public void createNaverEP() throws IOException {
+
+		/**
+		 * 1. 네이버
+		 * 01 시: 전체 EP
+		 * 08 시~ 20 시: 요약 EP (두시간 단위, 전체EP 기준의 )
+		 * 2. 마케팅 EP
+		 * 01:00/10:00/12:00/14:00/16:00/18:00/20:00 : 전체 EP
+		 * 요약 EP 없음
+		 */
+
+		/*
+		 * 전체 : 데이터는 0시 30분 생성
+		 * 변경 : 07시 30분 ~ 19시 30분 사이에 2시간 단위로 생성
+		 */
+		int jobHH = Integer.parseInt(GagaDateUtil.getToday("HH"));
+		log.info("[createNaverEp] jobHH=> {}", jobHH);
+		if (jobHH == 0) {
+
+//			int floorUnit = policyService.getPointUnit(TsbConstants.SiteCd.STYLE24);
+			Goods goodsParams = new Goods();
+//			goodsParams.setKind("all");
+//			goodsParams.setFloorUnit(floorUnit);
+
+			// TB_NAVER_EP삭제
+			goodsEPDao.deleteTbNaverEp();
+
+			// TB_NAVER_EP 생성
+			goodsEPDao.createTbNaverEp(goodsParams);
+
+			createNaverEPFile("all", "");
+		}
+
+		if (jobHH >= 7 && jobHH <= 19) {
+
+			if (jobHH % 2 == 1) {
+
+				// 요약 start
+				// 01 시 전체EP 기준 변경분
+//				int floorUnit = policyService.getPointUnit(TsbConstants.SiteCd.STYLE24);
+				Goods goodsParams = new Goods();
+//				goodsParams.setKind("brief");
+//				goodsParams.setFloorUnit(floorUnit);
+
+				// 직영공식몰도 입점사로 정책상 요약EP 사용이 불가하여 미작업 처리
+				//				createNaverEPTemp(goodsParams);
+				//				createNaverEPFile("brief", "");
+				// 요약 end
+
+				// 마케팅 전체
+				goodsEPDao.deleteTbNaverEpMarketing();
+				goodsEPDao.createTbNaverEpMarketing(goodsParams);
+				createNaverEPFile("all", "Y");
+
+			}
+
+		}
+	}
+
+	/**
+	 * 네이버 EP 생성 작업
+	 *
+	 * @param
+	 * @return
+	 * @author eskim
+	 * @throws IOException
+	 * @since 2020. 08. 23
+	 */
+	private void createNaverEPFile(String kind, String marketYn) throws IOException {
+
+		Goods goodsParams = new Goods();
+//		goodsParams.setKind(kind);
+		Collection<GoodsEP> goodsList = new ArrayList<GoodsEP>();
+		if ("all".equals(kind)) {
+			if ("Y".equals(marketYn)) {
+				goodsList = goodsEPDao.getNaverMarketingAllEPList(goodsParams);
+				if (goodsList == null || goodsList.isEmpty()) {
+					goodsList = goodsEPDao.getNaverAllEPList(goodsParams);
+				}
+			} else {
+				goodsList = goodsEPDao.getNaverAllEPList(goodsParams);
+			}
+
+		} else {
+			goodsList = goodsEPDao.getNaverEPList(goodsParams);
+		}
+
+		StringBuffer sb = new StringBuffer();
+
+		sb.append("id	title	price_pc	link	image_link	category_name1	category_name2	category_name3	brand	maker	origin	shipping	point");
+		if ("brief".equals(kind)) {
+			sb.append("	class	update_time");
+		}
+		sb.append("\n");
+
+		for (GoodsEP goods : goodsList) { //row
+
+			sb.append(goods.getId());
+			sb.append("\t").append("[공식판매처]").append(goods.getTitle());
+			sb.append("\t").append(goods.getPricePc());
+			sb.append("\t").append("https://www.pastelmall.com/goods/detail/form?goodsCd=" + goods.getId() + "&af=AF007");
+			if ("A".equals(goods.getImgType())) {
+				sb.append("\t").append("https:" + env.getProperty("upload.goods.view") + goods.getImageLink());
+			} else {
+				sb.append("\t").append(goods.getImageLink());
+			}
+
+			if (!StringUtils.isEmpty(goods.getCategoryName1())) {
+				String[] arrCategoryNm = goods.getCategoryName1().split(">");
+				for (int i = 0; i < 3; i++) {
+					if (arrCategoryNm.length > i) {
+						sb.append("\t").append(arrCategoryNm[i]);
+					} else {
+						sb.append("\t").append("");
+					}
+				}
+			} else {
+				sb.append("\t").append("");
+				sb.append("\t").append("");
+				sb.append("\t").append("");
+			}
+
+			sb.append("\t").append(goods.getBrand());
+			sb.append("\t").append(goods.getMaker());
+			sb.append("\t").append(GagaStringUtil.convNull(goods.getOrigin(), ""));
+			if (Integer.parseInt(goods.getPricePc()) >= goods.getMinOrdAmt()) {
+				sb.append("\t").append("0");
+			} else {
+				sb.append("\t").append(goods.getShipping());
+			}
+			sb.append("\t").append(goods.getPoint());
+			if ("brief".equals(kind)) {
+				sb.append("\t").append(goods.getJobgbn());	// I:신규, U:업데이트상품,   D: 품절상품
+				sb.append("\t").append(GagaDateUtil.getToday("yyyy-MM-dd HH:mm:ss"));
+			}
+
+			sb.append("\n");
+
+		}
+
+		//폴더 없으면 만들어줍니다.
+		if (!new File(env.getProperty("naverEP.path")).exists()) {
+			new File(env.getProperty("naverEP.path")).mkdirs();
+		}
+
+		String uploadPath = env.getProperty("naverEP.path") + "/" + kind + ".txt";
+		//BufferedWriter bwr = new BufferedWriter(new FileWriter(new File(uploadPath)));
+		BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(uploadPath)), "UTF8"));
+		bwr.write(sb.toString());
+		bwr.flush();
+		bwr.close();
+
+		//		GagaFtpUtil ftpUtil = new GagaFtpUtil(env.getProperty("speedy.ftp.host"), env.getProperty("speedy.ftp.port"), env.getProperty("speedy.ftp.username"), env.getProperty("speedy.ftp.pwd"));
+		//
+		//		File srcFile = new File(GagaFileUtil.getConcatenationPath(env.getProperty("upload.goods.target.path"), "navernewopen_new.html"));
+		//		ftpUtil.upload(srcFile, "/ep/naver");
+		//		ftpUtil.close();
+		//
+		//		if (srcFile.exists()) {
+		//			srcFile.delete();
+		//		}
+	}
+
+	/**
+	 * 네이버 요약 EP 생성 작업
+	 *
+	 * @param
+	 * @return
+	 * @author eskim
+	 * @throws IOException
+	 * @since 2020. 08. 23
+	 */
+	private void createNaverEPTemp(Goods goodsParams) {
+
+		// TB_NAVER_EP_TEMP 삭제
+		goodsEPDao.deleteTbNaverEpTemp();
+
+		// TB_NAVER_EP_TEMP 생성 - 당일 신규 등록건
+		goodsEPDao.createTbNaverEpTemp(goodsParams);
+
+		// 전체 EP의수정건
+		goodsEPDao.createTbNaverEpTempOfGoods(goodsParams);
+
+	}
+
+}

+ 26 - 10
src/main/java/com/style24/batch/biz/task/TsbGoodsTask.java

@@ -6,6 +6,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import com.style24.batch.biz.job.goods.TsbGoodsBenefitPriceJob;
+import com.style24.batch.biz.job.goods.TsbGoodsEpNaverGoods;
 import com.style24.batch.biz.job.goods.TsbGoodsInfantsSafeNoJob;
 import com.style24.batch.biz.job.goods.TsbGoodsPriceJob;
 import com.style24.batch.biz.job.goods.TsbGoodsRelateScoreJob;
@@ -13,10 +14,10 @@ import com.style24.batch.biz.job.goods.TsbGoodsSnmJob;
 import com.style24.batch.biz.job.goods.TsbGoodsSummaryJob;
 import com.style24.batch.biz.job.goods.TsbGoodsTnmJob;
 import com.style24.batch.biz.job.goods.TsbGoodsWmsBrandproviderJob;
+import com.style24.batch.biz.job.goods.TsbGoodsWmsGoodsJob;
+import com.style24.batch.biz.job.goods.TsbGoodsWmsGoodsStockJob;
 import com.style24.batch.biz.job.goods.TsbGoodsWmsIncomelotJob;
 import com.style24.batch.biz.job.goods.TsbGoodsWmsMeasurementJob;
-import com.style24.batch.biz.job.goods.TsbGoodsWmsProductJob;
-import com.style24.batch.biz.job.goods.TsbGoodsWmsProductStockJob;
 
 import lombok.extern.slf4j.Slf4j;
 
@@ -60,10 +61,13 @@ public class TsbGoodsTask {
 	private TsbGoodsWmsBrandproviderJob goodsWmsBrandproviderJob;
 
 	@Autowired
-	private TsbGoodsWmsProductJob goodsWmsProductJob;
+	private TsbGoodsWmsGoodsJob goodsWmsGoodsJob;
 
 	@Autowired
-	private TsbGoodsWmsProductStockJob goodsWmsProductStockJob;
+	private TsbGoodsWmsGoodsStockJob goodsWmsGoodsStockJob;
+
+	@Autowired
+	private TsbGoodsEpNaverGoods goodsEpNaverGoods;
 
 
 
@@ -216,11 +220,23 @@ public class TsbGoodsTask {
 	 *
 	 * @throws Exception
 	 */
-	@Scheduled(cron = "${cron.goods.wms.product}")
+	@Scheduled(cron = "${cron.goods.wms.goods}")
+	//@Scheduled(fixedDelay = 3500000)
+	@Async
+	public void tsbGoodsWmsGoodsJob() throws Exception {
+		goodsWmsGoodsJob.runById("cron.goods.wms.goods");
+	}
+
+	/**
+	 * WMS 상품 재고 수신 적용 주기 : 시간배치 - 01분
+	 *
+	 * @throws Exception
+	 */
+	@Scheduled(cron = "${cron.goods.wms.goods.stock}")
 	//@Scheduled(fixedDelay = 3500000)
 	@Async
-	public void tsbGoodsWmsProductJob() throws Exception {
-		goodsWmsProductJob.runById("cron.goods.wms.product");
+	public void tsbGoodsWmsGoodsStockJob() throws Exception {
+		goodsWmsGoodsStockJob.runById("cron.goods.wms.goods.stock");
 	}
 
 	/**
@@ -228,11 +244,11 @@ public class TsbGoodsTask {
 	 *
 	 * @throws Exception
 	 */
-	@Scheduled(cron = "${cron.goods.wms.product.stock}")
+	@Scheduled(cron = "${cron.goods.ep.naver.goods}")
 	//@Scheduled(fixedDelay = 3500000)
 	@Async
-	public void tsbGoodsWmsProductStockJob() throws Exception {
-		goodsWmsProductStockJob.runById("cron.goods.wms.product.stock");
+	public void tsbGoodsEpNaverGoods() throws Exception {
+		goodsEpNaverGoods.runById("cron.goods.ep.naver.goods");
 	}
 
 }

+ 79 - 0
src/main/java/com/style24/persistence/domain/GoodsEP.java

@@ -0,0 +1,79 @@
+package com.style24.persistence.domain;
+
+import com.style24.persistence.TscBaseDomain;
+
+import lombok.Data;
+
+
+/**
+ * EP 상품도메인
+ *
+ * @author mcLee
+ */
+@SuppressWarnings("serial")
+@Data
+public class GoodsEP extends TscBaseDomain {
+
+	private String id;
+	private String title;
+	private String pricePc;
+	private String priceMobile;
+	private String normalPrice;
+	private String link;
+	private String mobileLink;
+	private String imageLink;
+	private String addImageLink;
+	private String imgType;
+	private String videoUrl;
+	private String categoryName1;
+	private String categoryName2;
+	private String categoryName3;
+	private String categoryName4;
+	private String naverCategory;
+	private String naverProductId;
+	private String condition;
+	private String importFlag;
+	private String parallelImport;
+	private String orderMade;
+	private String productFlag;
+	private String adult;
+	private String goodsType;
+	private String goodsStat;
+	private String selfMallYn;
+	private String barcode;
+	private String manufactureDefineNumber;
+	private String modelNumber;
+	private String brand;
+	private String maker;
+	private String origin;
+	private String cardEvent;
+	private String eventWords;
+	private String coupon;
+	private String partnerCouponDownload;
+	private String interestFreeEvent;
+	private double point;
+	private String installationCosts;
+	private String preMatchCode;
+	private String searchTag;
+	private String groupId;
+	private String vendorId;
+	private String coordiId;
+	private String minimumPurchaseQuantity;
+	private String reviewCount;
+	private String shipping;
+	private String deliveryGrade;
+	private String deliveryDetail;
+	private String attribute;
+	private String optionDetail;
+	private String sellerId;
+	private String ageGroup;
+	private String gender;
+	private String className;
+	private String updateTime;
+
+	private int minOrdAmt;
+	private String jobgbn;
+	private int stockQty;
+	private int skipCnt;
+
+}