fhsource.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Cache;
  10. use think\facade\Db;
  11. class fhsource extends Command
  12. {
  13. protected $db="";
  14. protected function configure()
  15. {
  16. // 指令配置
  17. $this->setName('fhsource')
  18. ->setDescription('the fhsource command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. $redis = Cache::store('redis');
  23. $iscgd = $redis->get("fhsource");
  24. if($iscgd==0){
  25. $redis->set("fhsource",1,1200);
  26. }else{
  27. return;
  28. }
  29. // 指令输出
  30. $this->db =Db::connect("mysql2");
  31. $data = $this->GetData();
  32. foreach ($data as $value){
  33. $ist = Db::table("fh_source")->where('fhNo',"=",$value['fhNo'])->find();
  34. if($ist){
  35. Db::table("fh_source")->where('id',"=",$ist['id'])->save($value);
  36. }else{
  37. Db::table("fh_source")->insert($value);
  38. }
  39. }
  40. $redis->set("fhsource",0);
  41. $output->writeln('fhsource');
  42. }
  43. public function getdata(){
  44. $date=date("Y-m-d H:i:s",strtotime("-3 day"));
  45. $sql="SELECT
  46. name,
  47. if(sequenceStatus='COMPLETED',1,2 )as status,
  48. sequenceNo as fhNo,
  49. ShortText1618317462280 as cgdNo,
  50. ShortText1618317471119 as qrdNo,
  51. ShortText1618317496943 as good_name,
  52. Number1618317523885 as total_num,
  53. Number1618317560314 as wsendnum,
  54. Number1618858962761 as send,
  55. Number1618914618800 as bala,
  56. ShortText1619009205937 as contacter,
  57. ShortText1619009211201 as addr,
  58. ShortText1619009234439 as mobile,
  59. Date1619009333616 as todate,
  60. ShortText1619177902654 send_mobile,
  61. ShortText1619177908085 send_addr,
  62. ShortText1619177899085 as send_p,
  63. ShortText1619178039231 as send_remark,
  64. ShortText1619463486677 as post_company,
  65. ShortText1619463494497 as post_code,
  66. Date1620559261053 as send_date,
  67. if(ShortText1621883082623='已发',1,0) as sendstatus,
  68. createdTime as addtime,
  69. modifiedTime as updatetime
  70. FROM
  71. iw48m_FSDJ
  72. where
  73. 1=1
  74. and
  75. modifiedTime >='{$date}'";
  76. $data=$this->db->query($sql);
  77. return $data;
  78. }
  79. }