#!/bin/bashsource/etc/profile;################################################### Author:ouyangyewei # # # # Content:combineorder algorithm ############## ###################################### Change Workspace to herecd/cd/home/deploy/recsys/workspace/ouyangyewei# Generate Product_sell datayesterday=$ (date-d '-1 day ' +%y-%m-%d ') lastweek=$ (date-d '-1 week ' +%y-%m-%d ')/usr/local/ cloud/hive/bin/hive<<eof CREATE EXTERNAL TABLE IF not EXISTS Product_sell (category_id bigint,province_id bigint, product_id bigint,price double,sell_num bigint) partitioned by (DS string) ROW FORMAT delimitedfields TERMINATED by ' \ t ' LIN ES TERMINATED by ' \ n ' STORED as Textfile;insert OVERWRITE TABLE Product_sell PARTITION (ds= ' $yesterday ') Select A.category_ ID, b.good_receiver_province_id as province_id, a.id as product_id, (b.sell_amount/b.sell_num) as Price, b.sell_num from P Roduct A Join (select si.product_id, S.good_receiver_province_id, sum (si.order_item_amount) sell_amount, sum (si.order_item_num) sell_num from So_item si join so s on (si.order_id=s.id) where si.is_gift=0 and si.is_hidden=0 and si.ds between ' $lastweek ' and ' $yesterday ' GROUP by S.go OD_RECEIVER_PROVINCE_ID, si.product_id) b on (a.id=b.product_id); eof# Generate Yhd_gmv_month datayesterday=$ (date-d '-1 day ' +%y-%m-%d ') lastmonth=$ (date-d '-1 month ' +%y-%m-%d ')/usr/ local/cloud/hive/bin/hive<<eof CREATE EXTERNAL TABLE IF not EXISTS yhd_gmv_month (province_id Bigint,price_area int,product_id bigint,sell_num bigint) partitioned by (DS string) ROW FORMAT delimitedfields TERMINATED by ' \ t ' LINES termin ATED by ' \ n ' STORED as Textfile;insert OVERWRITE TABLE yhd_gmv_month PARTITION (ds= ' $yesterday ') select ssi.province_id, (c ASE when price>0.0 and price<=10.0 then 0 if price>10.0 and price<=20.0 then 1 when price>20.0 and price& lt;=30.0 then 2 while price>30.0 then 3 end) as Price_area, ssi.product_id, Ssi.sell_num From (select s.good_receiver_province_id as province_id, si.product_id, sum (si.order_item_num) as Sell_num, sum ( Si.order_item_amount)/sum (si.order_item_num) as price from So_item Si joins so s on (si.order_id=s.id) where si.is_hidden=0 and si.is_gift=0 and si.ds between ' $lastmonth ' and ' $yesterday ' GROUP by s.good_receiver_province_id, si.product_id) SSI ; eof# Exit hiveexit;# Execute the Combineorder algorithm jobcd/cd/home/deploy/recsys/workspace/ouyangyewei/schedule/ Pms_category_rec_prodhadoop jar/home/deploy/recsys/workspace/ouyangyewei/schedule/pms_category_rec_prod/ Recommender-dm-1.0-snapshot.jar com.yhd.recommender.combineorder.schedule.combineorderrecommendscheduler# Export "Pms_category_rec_prod" Data to Mysqlcd/cd/home/deploy/recsys/workspace/ouyangyewei/schedule/pms_category_rec_ Prodhadoop jar/home/deploy/recsys/workspace/ouyangyewei/schedule/pms_category_rec_prod/ Recommender-merchantrank.jar com.yhd.recommender.exporter.db.hdfstodbprocessor# Export "Yhd_gmv_month" data To Mysqlcd/cd/home/deploy/recsys/workspace/ouyangyewei/schedule/yhd_gmv_monthhadoop jar/home/deploy/recsys/ Workspace/ouyangyewei/schedule/yhd_gmv_month/recommender-merchantrank.jar Com.yhd.recommender.exporter.db.HdfsToDBProcessor