#!/bin/bash #. /opt/app/bi-app/energy/dayTask/config.sh if [ -n "$2" ] ;then echo "如果是输入的日期按照取输入日期" do_date=$2 startSec=`date -d "$do_date" "+%s"` echo $startSec current_day=`date -d "@$startSec" "+%Y-%m-%d"` one_day_ago=`date -d "$current_day yesterday" +%Y%m%d` start_time=`date -d "-1 day $current_day" +%Y%m%d`000000 end_time=`date -d "0 day $current_day" +%Y%m%d`000000 energy_start_time=`date -d "-2 day $current_day" +%Y%m%d`160000 energy_end_time=`date -d "-1 day $current_day" +%Y%m%d`160000 else echo "====没有输入数据的日期,取当前时间的前一天====" start_time=`date -d "-1 day" +"%Y%m%d"`000000 end_time=`date -d "0 day" +"%Y%m%d"`000000 energy_start_time=`date -d "-2 day" +"%Y%m%d"`160000 energy_end_time=`date -d "-1 day" +"%Y%m%d"`160000 fi echo "start_time:" $start_time echo "end_time:" $end_time echo "energy_start_time:" $energy_start_time echo "energy_end_time:" $energy_end_time # # 11301 CO2 # 11401 PM2.5 # 11305 甲醛 # 11101 温度 # 11201 湿度 ## 能源数据 energy_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 10101 --start_time $energy_start_time --end_time $energy_end_time } ## CO2 co2_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 11301 --start_time $start_time --end_time $end_time } ## PM2.5 pm25_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 11401 --start_time $start_time --end_time $end_time } ## 甲醛 hcho_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 11305 --start_time $start_time --end_time $end_time } ## 温度 temperature_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 11101 --start_time $start_time --end_time $end_time } ## 湿度 humidity_hbase_to_mysql(){ /usr/local/bin/python3 /opt/app/python_transfer/start_mysql.py 11201 --start_time $start_time --end_time $end_time } case $1 in "all") energy_hbase_to_mysql co2_hbase_to_mysql pm25_hbase_to_mysql hcho_hbase_to_mysql temperature_hbase_to_mysql humidity_hbase_to_mysql ;; "energy") energy_hbase_to_mysql ;; "co2") co2_hbase_to_mysql ;; "pm25") pm25_hbase_to_mysql ;; "hcho") hcho_hbase_to_mysql ;; "temperature") temperature_hbase_to_mysql ;; "humidity") humidity_hbase_to_mysql ;; esac