123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #!/bin/bash
- . /opt/app/bi-app/energy/dayTask/config.sh
- if [ -n "$2" ] ;then
- echo "如果是输入的日期按照取输入日期"
- do_date=$2
- else
- echo "====没有输入数据的日期,取当前时间的前一天===="
- do_date=`date -d yesterday +"%Y-%m-%d"`
- fi
- url=$MYSQL_URL
- username=$MYSQL_USER
- password=$MYSQL_PASSWORD
- 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'
- }
- ## 能源 15 分钟差值
- ods_energy_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from energy_15_min where 1 = 1 " ods_energy_15_min
- }
- ## 能源 15 分钟分精度
- ods_energy_15_min_fjd(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from energy_15_min_fjd where dt = '$do_date'" ods_energy_15_min_fjd
- }
- ## CO2 15 分钟分精度
- ods_co2_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from co2_15_min where dt = '$do_date'" ods_co2_15_min
- }
- ## PM2.5 15 分钟分精度
- ods_pm25_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from pm25_15_min where dt = '$do_date'" ods_pm25_15_min
- }
- ## 甲醛 15 分钟分精度
- ods_hcho_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from hcho_15_min where dt = '$do_date'" ods_hcho_15_min
- }
- ## 温度 15 分钟分精度
- ods_temperature_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from temperature_15_min where dt = '$do_date'" ods_temperature_15_min
- }
- ## 湿度 15 分钟分精度
- ods_humidity_15_min(){
- mysql_to_hdfs_lzo $url $username $password /warehouse/saga_dw/ods/tmp/ "building, func_id, meter, data_time, data_value" "select building, func_id, meter, data_time, data_value from humidity_15_min where dt = '$do_date'" ods_humidity_15_min
- }
- case $1 in
- "all")
- ods_energy_15_min
- ods_co2_15_min
- ods_pm25_15_min
- ods_hcho_15_min
- ods_temperature_15_min
- ods_humidity_15_min
- ;;
- "ods_energy_15_min")
- ods_energy_15_min
- ;;
- "ods_energy_15_min_fjd")
- ods_energy_15_min_fjd
- ;;
- "ods_co2_15_min")
- ods_co2_15_min
- ;;
- "ods_pm25_15_min")
- ods_pm25_15_min
- ;;
- "ods_hcho_15_min")
- ods_hcho_15_min
- ;;
- "ods_temperature_15_min")
- ods_temperature_15_min
- ;;
- "ods_humidity_15_min")
- ods_humidity_15_min
- ;;
- esac
|