Advertisement
Guest User

Untitled

a guest
Jan 12th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/bin/bash
  2. files=/home/*****/ringup_good/*
  3. newfile=/home/*****/ringup_good.csv
  4. logfile=/home/******/log/pragent_first_ringup_good.log
  5.  
  6. cat $files | iconv -f CP1251 -t UTF-8 > $newfile;
  7. cat $newfile >> $logfile;
  8. rm $files;
  9. mysql -u user -ppwd --local-infile DB -e "source /home/*****/pragent_first_ringup_good.sql;";
  10. rm $newfile;
  11.  
  12. ///////////////////////////////////////
  13. ////////////////SQL FILE pragent_first_ringup_good.sql
  14.  
  15. SET @project='pragent', @ringup='noans', @type=1;
  16.  
  17. CREATE TEMPORARY TABLE autoringup_hist_tmp
  18. SELECT DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,pc_id
  19. from general.autoringup_hist
  20. where 1=2
  21. ;
  22. commit;
  23.  
  24. LOAD DATA LOCAL INFILE '/home/*****/ringup_noans.csv'
  25. INTO TABLE autoringup_hist_tmp
  26. CHARACTER SET UTF8
  27. FIELDS TERMINATED BY ';'
  28. OPTIONALLY ENCLOSED BY '\"'
  29. LINES TERMINATED BY '\n'
  30. (@dttm,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,pc_id)
  31. SET DateTime = STR_TO_DATE(@dttm,'%d.%m.%Y %H:%i:%s')
  32. ;
  33. commit;
  34.  
  35. insert into general.autoringup_hist
  36. (DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,ringup,pc_id,project,type)
  37. select
  38. DateTime,Abon,DialTime,WaitTime,AbMsgTime,MsgTime,DialSignal,@ringup,pc_id,@project,@type
  39. from autoringup_hist_tmp
  40. ;
  41. commit;
  42.  
  43. update privat.pragent_main_data t1, autoringup_hist_tmp t2
  44. set t1.date_noans = t2.DateTime,
  45. t1.cnt_noans = t1.cnt_noans+1,
  46. t1.inwork = 0,
  47. t1.date_o = now()
  48. where t1.phone = t2.Abon
  49. ;
  50. commit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement