#!/bin/bash . /opt/app/bi-app/energy/dayTask/config.sh . ./config.sh if [ -n "$2" ] ;then echo "如果是输入的日期按照取输入日期" do_date=$2 else echo "====没有输入数据的日期,取当前时间的前一天====" do_date=$(date -d yesterday +"%Y-%m-%d") fi SAGA_DATABASE=sagacloud_customization url=$SAGA_URL_PRE$SAGA_DATABASE$SAGA_URL_SUF username=$SAGA_USER password=$SAGA_PASSWORD echo "$do_date" mysql_to_hdfs_lzo() { sqoop import \ -D mapred.job.queue.name=default \ --connect "$1" \ --username "$2" \ --password "$3" \ --target-dir "$4""$7"/"$do_date" \ --delete-target-dir \ --columns "$5" \ --query "$6 and \$CONDITIONS" \ --num-mappers 1 \ --hive-drop-import-delims \ --fields-terminated-by '\001' \ --compress \ --compression-codec lzo \ --hive-import \ --hive-database saga_dw \ --hive-table "$7" \ --hive-overwrite \ --hive-partition-key dt \ --hive-partition-value "$do_date" \ --null-string '\\N' \ --null-non-string '\\N' } ## 空调操作记录表 ods_feedback(){ mysql_to_hdfs_lzo "$url" "$username" "$password" /warehouse/saga_dw/ods/tmp/ \ "id, project_id, object_id, source_type, user_id, user_phone, user_name, value_type, item_id, value, create_time, next_open_time, model, duration_type, custom_plan, curr_temp, nick_name, result, exe_result, fb_temp, remark" \ "select id, project_id, object_id, source_type, user_id, user_phone, user_name, value_type, item_id, value, create_time, next_open_time, model, duration_type, custom_plan, curr_temp, nick_name, result, exe_result, fb_temp, remark from feedback where date_format(create_time, '%Y-%m-%d') = $do_date and 1 = 1 " \ ods_bus_feedback } case $1 in "all") ods_feedback ;; "ods_feedback") ods_feedback ;; esac