From 2aeddf5d098b99d28783c6a73bfa67414aa1f2fe Mon Sep 17 00:00:00 2001 From: 喻健 <喻健@Admin> Date: 星期六, 15 十二月 2018 10:11:42 +0800 Subject: [PATCH] 精选库代码优化:更新数据加入更新时间,删除无用代码 --- fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java | 172 ++------------------------------------------------------- 1 files changed, 6 insertions(+), 166 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java index 266345e..2f5e525 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/QualityFactoryServiceImpl.java @@ -70,25 +70,12 @@ @Resource private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService; - @Override - public int insert(QualityFactory record) throws QualityFactoryException { - return qualityFactoryMapper.insert(record); - } - - @Override - public int updateByPrimaryKey(QualityFactory record) throws QualityFactoryException { - return qualityFactoryMapper.updateByPrimaryKey(record); - } @Override public int updateByPrimaryKeySelective(QualityFactory record) throws QualityFactoryException { return qualityFactoryMapper.updateByPrimaryKeySelective(record); } - @Override - public int deleteByPrimaryKey(Long id) throws QualityFactoryException { - return qualityFactoryMapper.deleteByPrimaryKey(id); - } @Override public void deleteByTbAuctionId(Long auctionId) { @@ -160,16 +147,6 @@ labelGoodsMapper.deleteBatchByGoodsId(listGid); } - @Override - @Transactional - public void deleteBatchByPrimaryKey(List<String> ids) throws QualityFactoryException { - - if (ids != null) { - for (String id : ids) { - qualityFactoryMapper.deleteByPrimaryKey(Long.parseLong(id)); - } - } - } @Override @Transactional @@ -182,10 +159,6 @@ } } - @Override - public int removeStorageGoods(String doTime, Long gcids) throws QualityFactoryException { - return qualityFactoryMapper.removeStorageGoods(doTime, gcids); - } @Override public QualityFactory selectByPrimaryKey(Long id) throws QualityFactoryException { @@ -320,10 +293,10 @@ TaoBaoGoodsBrief currentGoodsBrief = taoBaoGoodsBriefList.get(0); goodsBrief.setId(currentGoodsBrief.getId()); - // 闈炵┖椤� 澶勭悊 - setTaoBaoGoodsBriefDefault(goodsBrief); + // 鏇存柊鍟嗗搧鏈�鏂颁俊鎭� - taoBaoGoodsBriefService.updateByPrimaryKey(goodsBrief); + taoBaoGoodsUpdateService.updateTaoBaoGoods(goodsBrief); + } else { // 鎻掑叆鏈湴鏁版嵁搴� @@ -361,7 +334,7 @@ // 鏇存柊鍟嗗搧 QualityFactory selectionGoods = selectionList.get(0); selectionGoods.setUpdatetime(new Date()); - qualityFactoryMapper.updateByPrimaryKey(selectionGoods); + qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods); } if (listLabs.size() > 0) { @@ -419,7 +392,7 @@ } // 淇敼鏉冮噸 - // selectionGoods.setUpdateUser(admin); + selectionGoods.setUpdateUser(admin); selectionGoods.setWeight(resultWeight); qualityFactoryMapper.updateByPrimaryKeySelective(selectionGoods); } @@ -443,7 +416,7 @@ @Override public List<Long> queryNeedUpdate(long start, int count, int hour) { - return qualityFactoryMapper.queryNeedUpdate(0, count, hour); + return qualityFactoryMapper.queryNeedUpdate(start, count, hour); } @@ -651,139 +624,6 @@ } } - @Override - @Transactional - public void updateBatchQualityFactory(List<QualityFactory> listQuality, List<Long> list9Class, - Map<String, Label> map) throws Exception { - - if (listQuality == null || listQuality.size() == 0) { - return; - } - - List<Long> listDeleteQuality = new ArrayList<Long>(); - List<QualityFactory> listUpdateQuality = new ArrayList<QualityFactory>(); - - List<Long> listGid = new ArrayList<Long>(); - List<TaoBaoGoodsBrief> listUpdateGoodsBrief = new ArrayList<TaoBaoGoodsBrief>(); - - List<Long> list9ClassDelete = new ArrayList<Long>(); - // 娣诲姞鍟嗗搧鏍囩鍒楄〃 - List<LabelGoods> listLabelAdd = new ArrayList<LabelGoods>(); - - listQuality.parallelStream().forEach(quality -> { - - TaoBaoGoodsBrief goods = quality.getTaoBaoGoodsBrief(); - if (goods == null) { - // 绉婚櫎绮鹃�夊簱 - listDeleteQuality.add(quality.getId()); - } else { - Long id = goods.getId(); - Long auctionId = goods.getAuctionId(); - - try { - // 鑾峰彇璇︽儏 - TaoBaoGoodsBrief taoBaoGoodsBrief = TaoKeApiUtil.searchGoodsDetail(auctionId); - - if (taoBaoGoodsBrief == null) { - /* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */ - listGid.add(id); - } else { - /* 鏃犲埜淇℃伅 绉婚櫎绮鹃�夊簱 */ - if (StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponInfo()) - && StringUtil.isNullOrEmpty(taoBaoGoodsBrief.getCouponActivityId())) { // 鏃犲埜淇℃伅 - // 绉婚櫎绮鹃�夊簱 - listGid.add(id); - - /* 鏇存柊鍟嗗搧淇℃伅 */ - TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService - .getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief); - updateGoods.setId(id); - taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods); - listUpdateGoodsBrief.add(updateGoods); - } else { - /* 鏇存柊鍟嗗搧淇℃伅 */ - - TaoBaoGoodsBrief updateGoods = taoBaoGoodsUpdateService - .getUpdateTaoBaoGoodsBrief(taoBaoGoodsBrief); - updateGoods.setId(id); - taoBaoGoodsBriefService.setGoodsBriefDefault(updateGoods); - listUpdateGoodsBrief.add(updateGoods); - - /* 鏇存柊绮鹃�夊簱 淇℃伅鏃堕棿 */ - Integer biz30day = updateGoods.getBiz30day(); - if (biz30day < 1000) { - // 閿�閲忓皬浜�1000 閲嶆柊璁剧疆鏉冮噸 - int weight = 10 + (int) (Math.random() * 2000); - quality.setWeight(weight); - } - quality.setUpdatetime(new Date()); - - listUpdateQuality.add(quality); - - /* 鍒ゆ柇鏄惁宸茬粡璐翠笂鏍囩 9k9鏍囩 瀵瑰簲浠锋牸鍙樺寲 */ - if (list9Class.size() > 0) { - List<LabelGoods> listGlid = labelGoodsMapper.listQuery9k9Class(id, list9Class); - if (listGlid != null && listGlid.size() > 0) { - /* 鍒犻櫎鍘熸爣绛� 9k9 */ - for (LabelGoods labelGoods : listGlid) { - list9ClassDelete.add(labelGoods.getId()); - } - - /* 璐翠笂鏂版爣绛� 9k9 */ - LabelGoods labelGds = screen9K9(updateGoods, map); - if (labelGds != null) { - listLabelAdd.add(labelGds); - } - } - } - } - } - - } catch (TaobaoGoodsDownException e1) { - // 鍟嗗搧涓嬫灦 绉婚櫎鏁版嵁搴� - taoBaoGoodsUpdateService.deleteTaoBaoGoods(auctionId); - - } catch (Exception e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); - } - } - } - - }); - - // 鏇存柊鍟嗗搧淇℃伅 - if (listUpdateGoodsBrief.size() > 0) { - taoBaoGoodsBriefService.updateBatchSelective(listUpdateGoodsBrief); - } - - // 鏇存柊绮鹃�夊簱 - if (listUpdateQuality.size() > 0) { - qualityFactoryMapper.updateBatchSelective(listUpdateQuality); - } - - // 鎵归噺绉婚櫎绮鹃�夊簱 - if (listGid.size() > 0) { - deleteBatchByTaoBaoGoodsId(listGid); - } - - // 鎵归噺鍒犻櫎绮鹃�夊簱 - if (listDeleteQuality.size() > 0) { - qualityFactoryMapper.deleteBatchByPrimaryKey(listDeleteQuality); - } - - // 娣诲姞鏍囩 - if (listLabelAdd.size() > 0) { - labelGoodsMapper.insertBatch(listLabelAdd); - } - - // 鍒犻櫎鏍囩 - if (list9ClassDelete.size() > 0) { - labelGoodsMapper.deleteBatchByPK(list9ClassDelete); - } - } @Override public void autoInsertOrUpadateStorage(List<TaoBaoGoodsBrief> goodsList, List<Label> listLabs, -- Gitblit v1.8.0