From 4730ad35bb6b01ebf197bff15ec518182e29e059 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 28 五月 2019 16:30:41 +0800
Subject: [PATCH] 精选库更新

---
 fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java |  500 +++++++++++++++++++++++++------------------------------
 1 files changed, 230 insertions(+), 270 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
index 14cd59a..759b35e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
+++ b/fanli/src/main/java/com/yeshi/fanli/job/QualityFactoryJob.java
@@ -8,8 +8,6 @@
 
 import javax.annotation.Resource;
 
-import net.sf.json.JSONObject;
-
 import org.quartz.Job;
 import org.quartz.JobDataMap;
 import org.quartz.JobExecutionContext;
@@ -30,6 +28,8 @@
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.taobao.TaoBaoUtil;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
+
+import net.sf.json.JSONObject;
 
 /**
  * 绮鹃�夊晢鍝佽嚜鍔ㄥ叆搴�
@@ -59,8 +59,6 @@
 
 	@Override
 	public void execute(JobExecutionContext context) throws JobExecutionException {
-		LogHelper.test("---UpdateQualityFactoryJob----execute ");
-
 		// 鐖彇鍟嗗搧淇℃伅
 		searchGoods(context);
 	}
@@ -90,7 +88,8 @@
 			}
 
 			/* 鏉ユ簮鍚嶇О */
-			if (jsonData.get("sourceCalss") != null && !StringUtil.isNullOrEmpty(jsonData.get("sourceCalss").toString())) {
+			if (jsonData.get("sourceCalss") != null
+					&& !StringUtil.isNullOrEmpty(jsonData.get("sourceCalss").toString())) {
 				String sourceCalss = jsonData.get("sourceCalss").toString();
 				autoRule.setSourceCalss(sourceCalss);
 			}
@@ -116,41 +115,34 @@
 			/* 鏍囩鍒楄〃 */
 			List<Label> listLabs = new ArrayList<Label>();
 
-			if (jsonData.get("lableNames") != null && !StringUtil.isNullOrEmpty(jsonData.get("lableNames").toString())) {
+			if (jsonData.get("lableNames") != null
+					&& !StringUtil.isNullOrEmpty(jsonData.get("lableNames").toString())) {
 
 				// 绌烘牸闅斿紑
 				String[] arrtitles = jsonData.get("lableNames").toString().split("\\s+");
 
-				/* 閬嶅巻鏍囩鍚嶇О锛氭煡璇㈡暟鎹簱涓槸鍚﹀凡瀛樺湪 */
+				// 鑾峰彇鏍囩灞炴��
 				for (String name : arrtitles) {
-					List<Label> labels = labelService.selectByTitle(name.trim());
-
-					if (labels != null && labels.size() > 0) {
-						Label label = labels.get(0);
-
-						listLabs.add(label);
-					} else {
-						// 鏂板
-						Label addLabel = addLabel(name, admin);
-						listLabs.add(addLabel);
+					Label label = labelService.getByTitleCache("labKey", name.trim());
+					if (label == null) {
+						label = insertLabel(name, admin);
 					}
-
+					listLabs.add(label);
 				}
 			}
 
 			int source = Integer.parseInt(jobDataMap.get("source").toString());
+
 			autoRule.setSource(QualityFactory.SOURCE_TAOBAO);
-
+			// 1銆佹潵婧愭窐瀹濇櫘閫氭帴鍙�
 			if (BoutiqueAutoRule.TB_OPTIONAL == source) {
-				// 鏉ユ簮娣樺疂鏅�氭帴鍙�
 				autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO);
-
 				searchTaoBao(jsonData, listLabs, autoRule);
 			}
 
+			// 2銆佹窐瀹濇帹鑽�
 			if (BoutiqueAutoRule.TB_MATERIAL == source) {
 				autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_MATERIAL);
-				// 娣樺疂鎺ㄨ崘
 				searchMaterial(jsonData, listLabs, autoRule);
 			}
 
@@ -171,7 +163,6 @@
 	 * @param jobDataMap
 	 */
 	private void searchTaoBao(JSONObject jsonData, List<Label> listLabs, BoutiqueAutoRule autoRule) {
-
 		try {
 			Date time = new Date();
 			String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(time);
@@ -205,16 +196,13 @@
 			filter.setPageSize(pageSize);
 
 			for (int page = 1; page <= pageMax; page++) {
-
 				filter.setPage(page);
-
 				TaoBaoSearchResult result = TaoKeApiUtil.searchWuLiao(filter);
-				LogHelper.test(title + "searchWuLiao 宸茬埇鍙�- " + page + "-椤�-");
 
-				// 缁撴灉涓虹┖ 鏃朵笉鍐嶈姹�
+				// 缁撴灉涓虹┖ 缁撴潫璇锋眰
 				if (result == null) {
 					LogHelper.test(title + "searchWuLiao杩斿洖 result涓虹┖");
-					return;
+					break;
 				}
 
 				// 缁撴灉鏁版嵁澶勭悊
@@ -226,8 +214,8 @@
 
 				/* 鏉冮噸鑼冨洿 */
 				if (page < 3) {
-					startWeight = 10000;
-					endWeight = 12000;
+					startWeight = 4000;
+					endWeight = 6000;
 				} else {
 					startWeight = 10;
 					endWeight = 3000;
@@ -237,14 +225,10 @@
 				autoRule.setEndWeight(endWeight);
 
 				/* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */
-				if (StringUtil.isNullOrEmpty(title)) {
-					screen(listGoods, jsonData, filter, listLabs, autoRule);
+				if (!StringUtil.isNullOrEmpty(title) && title.contains(IS_9K9)) {
+					screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
 				} else {
-					if (title.contains(IS_9K9)) {
-						screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
-					} else {
-						screen(listGoods, jsonData, filter, listLabs, autoRule);
-					}
+					screen(listGoods, jsonData, filter, listLabs, autoRule);
 				}
 
 				/* 閿�鍞噺灏忓�� */
@@ -287,50 +271,16 @@
 					break;// 缁撴潫鐖彇鏁版嵁
 				}
 			}
-			
-			// 9k9 闄愭椂鎶㈣喘  涓嶆搷浣滃垹闄�
-			if (title.contains(IS_9K9) || title.contains(FLASH_SALE)) {
+
+			// 9k9 闄愭椂鎶㈣喘 涓嶆搷浣滃垹闄�
+			if (!StringUtil.isNullOrEmpty(title) && (title.contains(IS_9K9) || title.contains(FLASH_SALE))) {
 				return;
 			}
-			
+
 			/* 鏇存柊瀹屾垚鍚庢竻鐞嗕箣鍓嶅垱寤虹殑鏁版嵁 */
 			if (jsonData.get("systemCid") != null && !StringUtil.isNullOrEmpty(jsonData.get("systemCid").toString())) {
-				
 				Long systemCid = Long.parseLong(jsonData.get("systemCid").toString());
-			
-				List<Long> list = qualityFactoryService.getAuctionIdbyClassId(systemCid, autoRule.getGoodsSource(), formatDate);
-				
-				if (list != null && list.size() > 0) {
-					if (list.size() <= 100) {
-						qualityFactoryService.deleteBatchByTaoBaoGoodsId(list);
-					} else {
-
-						int start = 0;
-						int end = 100;
-						int countRow = 100;
-
-						int count = list.size() / countRow;
-
-						if (list.size() % countRow > 0) {
-							count += 1;
-						}
-
-						for (int i = 0; i < count; i++) {
-							List<Long> sublist = new ArrayList<Long>();
-							if (i == count - 1) {
-								//System.out.println(list.subList(start, list.size()));
-								sublist = list.subList(start, list.size());
-								qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
-								break;
-							}
-							sublist = list.subList(start, end);
-							qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
-							start += countRow;
-							end += countRow;
-						}
-
-					}
-				}
+				deleteNotUpdateGoods(systemCid, formatDate, autoRule.getGoodsSource());
 			}
 
 		} catch (Exception e) {
@@ -405,14 +355,10 @@
 				}
 
 				/* 绛涢�夊晢鍝佽繘鍏ョ簿閫夊簱涓� */
-				if (StringUtil.isNullOrEmpty(title)) {
-					screen(listGoods, jsonData, filter, listLabs, autoRule);
+				if (!StringUtil.isNullOrEmpty(title) && title.contains(IS_9K9)) {
+					screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
 				} else {
-					if (title.contains(IS_9K9)) {
-						screen9K9(filter, listGoods, jsonData, listLabs, autoRule);
-					} else {
-						screen(listGoods, jsonData, filter, listLabs, autoRule);
-					}
+					screen(listGoods, jsonData, filter, listLabs, autoRule);
 				}
 
 				// 鎬婚〉鏁扮埇鍙栧畬鎴�
@@ -447,7 +393,6 @@
 	 * @return
 	 */
 	public SearchFilter getSearchFilter(JSONObject jsonData) {
-
 		SearchFilter filter = new SearchFilter();
 
 		// 鎺掑簭瀛楁 閿�閲忛珮鍒颁綆(榛樿)
@@ -536,8 +481,154 @@
 			// 閫�娆剧巼鏄惁浣庝簬琛屼笟鍧囧�� 1 鏈� 0 鏃�
 			filter.setIncludeRfdRate(true);
 		}
-
 		return filter;
+	}
+
+	/**
+	 * 9.9 19.9 29.9 39.9 鍟嗗搧绛涢��
+	 * 
+	 * @param taoBaoGoodsBriefs
+	 */
+	public void screen9K9(SearchFilter filter, List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData,
+			List<Label> listLabs, BoutiqueAutoRule autoRule) throws Exception {
+
+		/* 9k9 */
+		BigDecimal price9k9 = new BigDecimal(10);
+		List<TaoBaoGoodsBrief> list9k9 = new ArrayList<TaoBaoGoodsBrief>();
+
+		/* 19k9 */
+		BigDecimal price19k9 = new BigDecimal(20);
+		List<TaoBaoGoodsBrief> list19k9 = new ArrayList<TaoBaoGoodsBrief>();
+
+		/* 29.9 */
+		BigDecimal price29K9 = new BigDecimal(30);
+		List<TaoBaoGoodsBrief> list29k9 = new ArrayList<TaoBaoGoodsBrief>();
+
+		/* 49.9 */
+		BigDecimal price49K9 = new BigDecimal(50);
+		List<TaoBaoGoodsBrief> list49k9 = new ArrayList<TaoBaoGoodsBrief>();
+
+		/* 閿�鍞噺灏忓�� */
+		int minSales = 0;
+		if (jsonData.get("startSales") != null) {
+			minSales = (int) jsonData.get("startSales");
+		}
+
+		/* 閿�鍞噺澶у�� */
+		int maxSales = 0;
+		if (jsonData.get("endSales") != null) {
+			maxSales = (int) jsonData.get("endSales");
+		}
+
+		// 楠岃瘉鏄惁绗﹀悎瑕佹眰鍏ュ簱
+		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
+
+			/* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */
+			if (filter.getQuan() > 0) {
+				String couponInfo = goodsBrief.getCouponInfo();
+				if (StringUtil.isNullOrEmpty(couponInfo)) {
+					continue;
+				}
+			}
+
+			/* 楠岃瘉閿�鍞噺 */
+			int biz30day = goodsBrief.getBiz30day();
+			if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) {
+				continue;
+			} else if (maxSales > 0 && biz30day > maxSales) {
+				continue;
+			} else if (minSales > 0 && biz30day < minSales) {
+				continue;
+			}
+
+			/* 楠岃瘉姣斾緥 */
+			if (BoutiqueAutoRule.TB_MATERIAL == autoRule.getSource()) {
+				int startTkRate = filter.getStartTkRate();
+				int endTkRate = filter.getEndTkRate();
+				BigDecimal tkRate = goodsBrief.getTkRate();
+				if (startTkRate > 0 && endTkRate > 0 && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0
+						|| tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) {
+					continue;
+				} else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) {
+					continue;
+				} else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) {
+					continue;
+				}
+			}
+
+			/* 鍒稿悗浠�--璁$畻 */
+			BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief);
+			if (couponPrice.compareTo(price9k9) < 0) {
+				list9k9.add(goodsBrief);
+			} else if (couponPrice.compareTo(price19k9) < 0) {
+				list19k9.add(goodsBrief);
+			} else if (couponPrice.compareTo(price29K9) < 0) {
+				list29k9.add(goodsBrief);
+			} else if (couponPrice.compareTo(price49K9) < 0) {
+				list49k9.add(goodsBrief);
+			}
+		}
+		autoRule.setCalss9k9(true);
+		AdminUser admin = autoRule.getAdminUser();
+
+		if (list9k9.size() > 0) {
+			Label label = labelService.getByTitleCache("labKey", "9.9");
+			if (label == null) {
+				label = insertLabel("9.9", admin);
+			}
+			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list9k9, listLabs, label);
+		}
+
+		if (list19k9.size() > 0) {
+			Label label = labelService.getByTitleCache("labKey", "19.9");
+			if (label == null) {
+				label = insertLabel("9.9", admin);
+			}
+			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list19k9, listLabs, label);
+		}
+
+		if (list29k9.size() > 0) {
+			Label label = labelService.getByTitleCache("labKey", "29.9");
+			if (label == null) {
+				label = insertLabel("9.9", admin);
+			}
+			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list29k9, listLabs, label);
+		}
+
+		if (list49k9.size() > 0) {
+			Label label = labelService.getByTitleCache("labKey", "49.9");
+			if (label == null) {
+				label = insertLabel("9.9", admin);
+			}
+			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, list49k9, listLabs, label);
+		}
+	}
+
+	/**
+	 * 绛涢�夌鍚堟潯浠剁殑鍟嗗搧
+	 * 
+	 * @param taoBaoGoodsBriefs
+	 * @param jsonData
+	 * @param filter
+	 * @param listLabs
+	 * @param autoRule
+	 * @throws Exception
+	 */
+	public void screen(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, SearchFilter filter,
+			List<Label> listLabs, BoutiqueAutoRule autoRule) throws Exception {
+
+		List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
+		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
+			// 楠岃瘉鏄惁绗﹀悎瑕佹眰
+			if (validate(filter, jsonData, goodsBrief, 1)) {
+				listGoods.add(goodsBrief);
+			}
+		}
+
+		if (listGoods.size() > 0) {
+			autoRule.setCalss9k9(false);
+			qualityFactoryService.autoInsertOrUpadateStorage(autoRule, listGoods, listLabs, null);
+		}
 	}
 
 	/**
@@ -546,7 +637,6 @@
 	 * @return
 	 */
 	public boolean validate(SearchFilter filter, JSONObject jsonData, TaoBaoGoodsBrief goodsBrief, int source) {
-
 		/* 閿�鍞噺灏忓�� */
 		int minSales = 0;
 		if (jsonData.get("startSales") != null) {
@@ -578,8 +668,8 @@
 
 			BigDecimal tkRate = goodsBrief.getTkRate();
 
-			if (startTkRate > 0 && endTkRate > 0
-					&& (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0 || tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) {
+			if (startTkRate > 0 && endTkRate > 0 && (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0
+					|| tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) {
 				return false;
 			} else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) {
 				return false;
@@ -604,7 +694,8 @@
 		BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief);
 
 		/* 楠岃瘉鍦ㄥ埜鍚庝环 */
-		if (startPrice != null && endPrice != null && (couponPrice.compareTo(startPrice) < 0 || couponPrice.compareTo(endPrice) > 0)) {
+		if (startPrice != null && endPrice != null
+				&& (couponPrice.compareTo(startPrice) < 0 || couponPrice.compareTo(endPrice) > 0)) {
 			return false;
 		} else if (endPrice != null && couponPrice.compareTo(endPrice) > 0) {
 			return false;
@@ -624,188 +715,14 @@
 	}
 
 	/**
-	 * 9.9 19.9 29.9 39.9 鍟嗗搧绛涢��
+	 * 鎻掑叆鏂扮殑鏍囩
 	 * 
-	 * @param taoBaoGoodsBriefs
+	 * @param title
+	 * @param admin
+	 * @return
+	 * @throws Exception
 	 */
-	public void screen9K9(SearchFilter filter, List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, List<Label> listLabs,
-			BoutiqueAutoRule autoRule) throws Exception {
-
-		// 9k9鏁版嵁-
-		List<TaoBaoGoodsBrief> list9k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		// 19k9鏁版嵁-
-		List<TaoBaoGoodsBrief> list19k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		// 29k9鏁版嵁-
-		List<TaoBaoGoodsBrief> list29k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		// 49k9鏁版嵁-
-		List<TaoBaoGoodsBrief> list49k9 = new ArrayList<TaoBaoGoodsBrief>();
-
-		// 楠岃瘉鏄惁绗﹀悎瑕佹眰鍏ュ簱
-		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
-
-			/* 閿�鍞噺灏忓�� */
-			int minSales = 0;
-			if (jsonData.get("startSales") != null) {
-				minSales = (int) jsonData.get("startSales");
-			}
-
-			/* 閿�鍞噺澶у�� */
-			int maxSales = 0;
-			if (jsonData.get("endSales") != null) {
-				maxSales = (int) jsonData.get("endSales");
-			}
-
-			int biz30day = goodsBrief.getBiz30day();
-
-			/* 楠岃瘉閿�鍞噺 */
-			if (maxSales > 0 && minSales > 0 && (biz30day < minSales || biz30day > maxSales)) {
-				continue;
-			} else if (maxSales > 0 && biz30day > maxSales) {
-				continue;
-			} else if (minSales > 0 && biz30day < minSales) {
-				continue;
-			}
-
-			/* 楠岃瘉鍦ㄦ槸鍚︽湁鍒� */
-			if (filter.getQuan() > 0) {
-				String couponInfo = goodsBrief.getCouponInfo();
-				if (StringUtil.isNullOrEmpty(couponInfo)) {
-					continue;
-				}
-			}
-
-			/* 楠岃瘉姣斾緥 */
-			if (BoutiqueAutoRule.TB_MATERIAL == autoRule.getSource()) {
-
-				int startTkRate = filter.getStartTkRate();
-				int endTkRate = filter.getEndTkRate();
-
-				BigDecimal tkRate = goodsBrief.getTkRate();
-
-				if (startTkRate > 0 && endTkRate > 0
-						&& (tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0 || tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0)) {
-					continue;
-				} else if (endTkRate > 0 && tkRate.compareTo(new BigDecimal(endTkRate / 100)) > 0) {
-					continue;
-				} else if (startTkRate > 0 && tkRate.compareTo(new BigDecimal(startTkRate / 100)) < 0) {
-					continue;
-				}
-			}
-
-			/* 9k9 */
-			BigDecimal price9k9 = new BigDecimal(10);
-
-			/* 19k9 */
-			BigDecimal price19k9 = new BigDecimal(20);
-
-			/* 29.9 */
-			BigDecimal price29K9 = new BigDecimal(30);
-
-			/* 49.9 */
-			BigDecimal price49K9 = new BigDecimal(50);
-			/* 鍒稿悗浠�--璁$畻 */
-			BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(goodsBrief);
-
-			if (couponPrice.compareTo(price9k9) < 0) {
-				list9k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price19k9) < 0) {
-				list19k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price29K9) < 0) {
-				list29k9.add(goodsBrief);
-			} else if (couponPrice.compareTo(price49K9) < 0) {
-				list49k9.add(goodsBrief);
-			}
-		}
-
-		autoRule.setCalss9k9(true);
-		AdminUser admin = autoRule.getAdminUser();
-
-		if (list9k9.size() > 0) {
-			List<Label> labs9K9 = new ArrayList<Label>();
-			labs9K9.addAll(listLabs);
-
-			List<Label> list = labelService.selectByTitleCache("labKey", "9.9");
-
-			if (list == null || list.size() == 0) {
-				// 鏂板
-				Label addLabel = addLabel("9.9", admin);
-				labs9K9.add(addLabel);
-			} else {
-				labs9K9.add(list.get(0));
-			}
-
-			qualityFactoryService.autoInsertOrUpadateStorage(list9k9, labs9K9, autoRule);
-		}
-
-		if (list19k9.size() > 0) {
-			List<Label> labs19K9 = new ArrayList<Label>();
-			labs19K9.addAll(listLabs);
-			List<Label> list = labelService.selectByTitleCache("labKey", "19.9");
-			if (list == null || list.size() == 0) {
-				// 鏂板
-				Label addLabel = addLabel("19.9", admin);
-				labs19K9.add(addLabel);
-			} else {
-				labs19K9.add(list.get(0));
-			}
-			qualityFactoryService.autoInsertOrUpadateStorage(list19k9, labs19K9, autoRule);
-		}
-
-		if (list29k9.size() > 0) {
-			List<Label> labs29K9 = new ArrayList<Label>();
-			labs29K9.addAll(listLabs);
-			List<Label> list = labelService.selectByTitleCache("labKey", "29.9");
-			if (list == null || list.size() == 0) {
-				// 鏂板
-				Label addLabel = addLabel("29.9", admin);
-				labs29K9.add(addLabel);
-			} else {
-				labs29K9.add(list.get(0));
-			}
-
-			qualityFactoryService.autoInsertOrUpadateStorage(list29k9, labs29K9, autoRule);
-		}
-
-		if (list49k9.size() > 0) {
-			List<Label> labs49K9 = new ArrayList<Label>();
-			labs49K9.addAll(listLabs);
-			List<Label> list = labelService.selectByTitleCache("labKey", "49.9");
-			if (list == null || list.size() == 0) {
-				// 鏂板
-				Label addLabel = addLabel("49.9", admin);
-				labs49K9.add(addLabel);
-			} else {
-				labs49K9.add(list.get(0));
-			}
-
-			qualityFactoryService.autoInsertOrUpadateStorage(list49k9, labs49K9, autoRule);
-		}
-
-	}
-
-	public void screen(List<TaoBaoGoodsBrief> taoBaoGoodsBriefs, JSONObject jsonData, SearchFilter filter, List<Label> listLabs,
-			BoutiqueAutoRule autoRule) throws Exception {
-
-		// 閬嶅巻杩斿洖鏁版嵁-
-		List<TaoBaoGoodsBrief> listGoods = new ArrayList<TaoBaoGoodsBrief>();
-
-		for (TaoBaoGoodsBrief goodsBrief : taoBaoGoodsBriefs) {
-			// 楠岃瘉鏄惁绗﹀悎瑕佹眰
-			if (validate(filter, jsonData, goodsBrief, 1)) {
-				listGoods.add(goodsBrief);
-			}
-		}
-
-		if (listGoods.size() > 0) {
-			autoRule.setCalss9k9(false);
-			qualityFactoryService.autoInsertOrUpadateStorage(listGoods, listLabs, autoRule);
-		}
-	}
-
-	public Label addLabel(String title, AdminUser admin) throws Exception {
+	public Label insertLabel(String title, AdminUser admin) throws Exception {
 		// 鏂板
 		Label label = new Label();
 		label.setTitle(title);// 鍚嶇О
@@ -816,8 +733,51 @@
 		label.setIosClick(0l);
 		label.setAndroidClick(0l);
 		labelService.insertSelective(label);
-
 		return label;
 	}
 
+	/**
+	 * 鍒犻櫎鏈洿鏂扮殑鍟嗗搧
+	 * 
+	 * @param systemCid
+	 * @param formatDate
+	 * @param source
+	 */
+	public void deleteNotUpdateGoods(Long systemCid, String formatDate, int source) {
+		List<Long> list = qualityFactoryService.getAuctionIdbyClassId(systemCid, source, formatDate);
+		if (list == null || list.size() == 0) {
+			return;
+		}
+
+		// 灏忎簬100鏉$洿鎺ュ垹闄�
+		if (list.size() <= 100) {
+			qualityFactoryService.deleteBatchByTaoBaoGoodsId(list);
+			return;
+		} 
+		
+		
+		// 澶т簬100闇�瑕佸垎娈靛垹闄�
+		int start = 0;
+		int end = 100;
+		int countRow = 100;
+
+		int count = list.size() / countRow;
+		if (list.size() % countRow > 0) {
+			count += 1;
+		}
+
+		for (int i = 0; i < count; i++) {
+			List<Long> sublist = new ArrayList<Long>();
+			if (i == count - 1) {
+				sublist = list.subList(start, list.size());
+				qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
+				break;
+			}
+			sublist = list.subList(start, end);
+			qualityFactoryService.deleteBatchByTaoBaoGoodsId(sublist);
+			start += countRow;
+			end += countRow;
+		}
+
+	}
 }

--
Gitblit v1.8.0