From 3824cbcaec6e6c67418d5280a53e9c2fedeef6f9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 11 七月 2019 16:34:13 +0800 Subject: [PATCH] 订单bug,分享爆款自购修改 --- fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java | 150 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 135 insertions(+), 15 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java b/fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java index b69a1d4..71546a4 100644 --- a/fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java +++ b/fanli/src/main/java/com/yeshi/fanli/job/UpdateDaTaoKeJob.java @@ -1,5 +1,8 @@ package com.yeshi.fanli.job; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.annotation.Resource; @@ -11,10 +14,14 @@ import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.common.AdminUser; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetail; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.lable.QualityFactoryService; +import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService; +import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.taobao.DaTaoKeUtil; +import com.yeshi.fanli.util.taobao.TaoBaoUtil; /** * 鏇存柊澶ф窐瀹㈡暟鎹� @@ -23,22 +30,45 @@ @Component public class UpdateDaTaoKeJob { - @Resource private QualityFactoryService qualityFactoryService; - // 涓ゅ皬鏃舵墽琛屼竴娆� 瀵瑰晢鍝佷俊鎭繘琛屾洿鏂� + @Resource + private DaTaoKeGoodsDetailService daTaoKeGoodsService; + + @Resource + private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service; + + /** + * 闄愭椂绉掓潃 鏁版嵁鏇存柊 + */ @Scheduled(cron = "0 0 0/2 * * ?") public void doUpdateJob() { - + if (!Constant.IS_TASK) return; - - List<TaoBaoGoodsBrief> listgoods = DaTaoKeUtil.getDingDongQiang(); - if (listgoods == null || listgoods.size() == 0) { + + List<DaTaoKeDetail> listTaoKe = DaTaoKeUtil.getDingDongQiang(); + if (listTaoKe == null || listTaoKe.size() == 0) { return; } - + + List<Long> listDaoKeId = new ArrayList<Long>(); + for (DaTaoKeDetail daTaoKeDetail : listTaoKe) { + listDaoKeId.add(daTaoKeDetail.getId()); + } + + List<DaTaoKeDetail> listDetail = daTaoKeGoodsService.listByIds(listDaoKeId); + if (listDetail == null || listDetail.size() == 0) { + return; + } + + List<TaoBaoGoodsBrief> listgoods = new ArrayList<TaoBaoGoodsBrief>(); + for (DaTaoKeDetail daTaoKeDetail : listDetail) { + listgoods.add(TaoBaoUtil.convert(daTaoKeDetail)); + } + + String formatDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()); try { /* 鎿嶄綔浜猴細 寮�鍙戣处鍙� */ AdminUser admin = new AdminUser(2L); @@ -49,16 +79,106 @@ autoRule.setStartWeight(1); autoRule.setEndWeight(3000); autoRule.setGoodsSource(QualityFactory.SOURCE_TAOBAO_DATAOKE); - qualityFactoryService.autoInsertOrUpadateStorage(listgoods, null, autoRule); - + qualityFactoryService.autoInsertOrUpadateStorage(autoRule, listgoods, null); + + // 鍒犻櫎涔嬪墠鐨� + qualityFactoryService.deleteNotUpdateGoods(null, formatDate, autoRule.getGoodsSource()); } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } + LogHelper.errorDetailInfo(e); } - + } + + // 1涓皬鏃舵洿鏂颁竴娆� + @Scheduled(cron = "0 0 0/1 * * ? ") + public void doSyncJob() { + if (!Constant.IS_TASK) + return; + try { + new Thread(new Runnable() { + + @Override + public void run() { + daTaoKeGoodsService.startSyncGoods(); + } + }).start(); + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + // 姣忓ぉ鏃╀笂鍚屾涓�娆� + @Scheduled(cron = "0 0 6 * * ? ") + public void doSyncJobNew() { + if (!Constant.IS_TASK) + return; + try { + new Thread(new Runnable() { + + @Override + public void run() { + daTaoKeGoodsDetailV2Service.startSyncGoods(); + } + }).start(); + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + @Scheduled(cron = "0 0/10 * * * ? ") + public void doUpdateJobNew() { + if (!Constant.IS_TASK) + return; + try { + new Thread(new Runnable() { + + @Override + public void run() { + daTaoKeGoodsDetailV2Service.updateNewGoods(); + } + }).start(); + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + @Scheduled(cron = "0 0/10 * * * ? ") + public void doDeleteJobNew() { + if (!Constant.IS_TASK) + return; + try { + new Thread(new Runnable() { + + @Override + public void run() { + daTaoKeGoodsDetailV2Service.deleteInvalid(); + } + }).start(); + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } + + // 姣忓ぉ鐨�8鐐癸紝11鐐癸紝19鐐癸紝23鐐规墽琛屼竴娆� + @Scheduled(cron = "0 0 8,11,19,23 * * ? ") + public void doUpdateInfoJobNew() { + if (!Constant.IS_TASK) + return; + try { + new Thread(new Runnable() { + + @Override + public void run() { + daTaoKeGoodsDetailV2Service.updateData(); + } + }).start(); + + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } } } -- Gitblit v1.8.0