|
@@ -26,7 +26,7 @@ import com.gagaframework.web.util.GagaFileUtil;
|
|
|
*/
|
|
*/
|
|
|
@Component
|
|
@Component
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
-public class TsbNaverSellEp extends TsbAbstractJob<Collection<GoodsEp>, Collection<GoodsEp>, String> {
|
|
|
|
|
|
|
+public class TsbNaverSellEp extends TsbAbstractJob<String, String, String> {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private TsbGoodsEpService naverEpService;
|
|
private TsbGoodsEpService naverEpService;
|
|
@@ -34,36 +34,60 @@ public class TsbNaverSellEp extends TsbAbstractJob<Collection<GoodsEp>, Collecti
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private Environment env;
|
|
private Environment env;
|
|
|
|
|
|
|
|
|
|
+ private static final int PAGE_SIZE = 10000;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
- public Collection<GoodsEp> read() throws Exception {
|
|
|
|
|
- // 네이버 판매지수EP 목록
|
|
|
|
|
- return naverEpService.getNaverSellEpList();
|
|
|
|
|
|
|
+ public String read() throws Exception {
|
|
|
|
|
+ return "OK";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Collection<GoodsEp> process(Collection<GoodsEp> goodsEpList) throws Exception {
|
|
|
|
|
- return goodsEpList;
|
|
|
|
|
|
|
+ public String process(String result) throws Exception {
|
|
|
|
|
+ return "OK";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public String write(Collection<GoodsEp> goodsEpList) throws Exception {
|
|
|
|
|
- if (goodsEpList != null && !goodsEpList.isEmpty()) {
|
|
|
|
|
- StringBuilder sb = new StringBuilder();
|
|
|
|
|
- this.setEpTitle(sb);
|
|
|
|
|
|
|
+ public String write(String result) throws Exception {
|
|
|
|
|
+ // 총건수
|
|
|
|
|
+ int totCnt = naverEpService.getNaverSellEpTotalCount();
|
|
|
|
|
+ log.info("totCnt: {}", totCnt);
|
|
|
|
|
|
|
|
- for (GoodsEp goodsEp : goodsEpList) {
|
|
|
|
|
- this.setEpInfo(sb, goodsEp);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (totCnt < 1) {
|
|
|
|
|
+ return "OK";
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String uploadPath = GagaFileUtil.getConcatenationPath(env.getProperty("ep.file.path"), "iStyle24ProductFeed_NaverEP_SellingIndex_new.txt");
|
|
|
|
|
+ log.info("네이버 판매지수EP 파일 경로: {}", uploadPath);
|
|
|
|
|
+
|
|
|
|
|
+ int totPage = totCnt / PAGE_SIZE;
|
|
|
|
|
+ log.info("totalPage: {}", totPage);
|
|
|
|
|
|
|
|
- String uploadPath = GagaFileUtil.getConcatenationPath(env.getProperty("ep.file.path"), "iStyle24ProductFeed_NaverEP_SellingIndex_new.txt");
|
|
|
|
|
- log.info("네이버 판매지수EP 파일 경로: {}", uploadPath);
|
|
|
|
|
|
|
+ if (totCnt % PAGE_SIZE > 0) {
|
|
|
|
|
+ totPage++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(uploadPath)), "UTF-8"));
|
|
|
|
|
+
|
|
|
|
|
+ // 타이틀 Write
|
|
|
|
|
+ bw.append(this.getEpTitle());
|
|
|
|
|
+
|
|
|
|
|
+ for (int page = 0; page < totPage; page++) {
|
|
|
|
|
+ int limitStartRow = (page * PAGE_SIZE + 1) - 1;
|
|
|
|
|
+ GoodsEp goodsEp = new GoodsEp();
|
|
|
|
|
+ goodsEp.setLimitStartRow(limitStartRow);
|
|
|
|
|
+ goodsEp.setPageSize(PAGE_SIZE);
|
|
|
|
|
|
|
|
- BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(uploadPath)), "UTF-8"));
|
|
|
|
|
- bw.write(sb.toString());
|
|
|
|
|
- bw.flush();
|
|
|
|
|
- bw.close();
|
|
|
|
|
|
|
+ // 네이버 판매지수EP 목록
|
|
|
|
|
+ Collection<GoodsEp> goodsEpList = naverEpService.getNaverSellEpList(goodsEp);
|
|
|
|
|
+
|
|
|
|
|
+ for (GoodsEp goodsEpInfo : goodsEpList) {
|
|
|
|
|
+ bw.append(this.getEpInfo(goodsEpInfo));
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("{} Page data wrote successfully!", (page + 1));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ bw.close();
|
|
|
|
|
+
|
|
|
return "OK";
|
|
return "OK";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -73,24 +97,28 @@ public class TsbNaverSellEp extends TsbAbstractJob<Collection<GoodsEp>, Collecti
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * EP 타이틀 설정
|
|
|
|
|
- * @param sb - StringBuilder
|
|
|
|
|
|
|
+ * Get EP 타이틀
|
|
|
|
|
+ * @return
|
|
|
*/
|
|
*/
|
|
|
- private void setEpTitle(StringBuilder sb) {
|
|
|
|
|
|
|
+ private String getEpTitle() {
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
sb.append("id\t").append("sale_count\t").append("sale_price\t").append("order_count\t").append("dt\n");
|
|
sb.append("id\t").append("sale_count\t").append("sale_price\t").append("order_count\t").append("dt\n");
|
|
|
|
|
+ return sb.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * EP 정보 설정
|
|
|
|
|
- * @param sb - StringBuilder
|
|
|
|
|
|
|
+ * Get EP 정보
|
|
|
* @param goodsEp - 상품EP 정보
|
|
* @param goodsEp - 상품EP 정보
|
|
|
|
|
+ * @return
|
|
|
*/
|
|
*/
|
|
|
- private void setEpInfo(StringBuilder sb, GoodsEp goodsEp) {
|
|
|
|
|
|
|
+ private String getEpInfo(GoodsEp goodsEp) {
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
sb.append(goodsEp.getId()).append("\t");
|
|
sb.append(goodsEp.getId()).append("\t");
|
|
|
sb.append(goodsEp.getSaleCount()).append("\t");
|
|
sb.append(goodsEp.getSaleCount()).append("\t");
|
|
|
sb.append(goodsEp.getSalePrice()).append("\t");
|
|
sb.append(goodsEp.getSalePrice()).append("\t");
|
|
|
sb.append(goodsEp.getOrderCount()).append("\t");
|
|
sb.append(goodsEp.getOrderCount()).append("\t");
|
|
|
sb.append(goodsEp.getDt()).append("\n");
|
|
sb.append(goodsEp.getDt()).append("\n");
|
|
|
|
|
+ return sb.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|