12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #! /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
- echo $do_date
- host=$MYSQL_HOST
- username=$MYSQL_USER
- password=$MYSQL_PASSWORD
- database=saga_dev
- del_energy_15_min="truncate table energy_15_min;"
- del_co2_15_min="truncate table co2_15_min;"
- del_pm25_15_min="truncate table pm25_15_min;"
- del_hcho_15_min="truncate table hcho_15_min;"
- del_temperature_15_min="truncate table temperature_15_min;"
- del_humidity_15_min="truncate table humidity_15_min;"
- ## 历史数据一次性导入后,需要删除 mysql 中的冗余数据
- clean_energy_15(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_energy_15_min}"
- }
- clean_co2_15_min(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_co2_15_min}"
- }
- clean_pm25_15_min(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_pm25_15_min}"
- }
- clean_hcho_15_min(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_hcho_15_min}"
- }
- clean_temperature_15_min(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_temperature_15_min}"
- }
- clean_humidity_15_min(){
- mysql -h${host} -P3306 -u${username} -p${password} ${database} -e "${del_humidity_15_min}"
- }
- case $1 in
- "all")
- clean_energy_15
- clean_co2_15_min
- clean_pm25_15_min
- clean_hcho_15_min
- clean_temperature_15_min
- clean_humidity_15_min
- ;;
- "clean_energy_15")
- clean_energy_15
- ;;
- "clean_co2_15_min")
- clean_co2_15_min
- ;;
- "clean_pm25_15_min")
- clean_pm25_15_min
- ;;
- "clean_hcho_15_min")
- clean_hcho_15_min
- ;;
- "clean_temperature_15_min")
- clean_temperature_15_min
- ;;
- "clean_humidity_15_min")
- clean_humidity_15_min
- ;;
- esac
|