12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- use think\facade\Cache;
- use think\facade\Db;
- class fhsource extends Command
- {
- protected $db="";
- protected function configure()
- {
- // 指令配置
- $this->setName('fhsource')
- ->setDescription('the fhsource command');
- }
- protected function execute(Input $input, Output $output)
- {
- $redis = Cache::store('redis');
- $iscgd = $redis->get("fhsource");
- if($iscgd==0){
- $redis->set("fhsource",1,1200);
- }else{
- return;
- }
- // 指令输出
- $this->db =Db::connect("mysql2");
- $data = $this->GetData();
- foreach ($data as $value){
- $ist = Db::table("fh_source")->where('fhNo',"=",$value['fhNo'])->find();
- if($ist){
- Db::table("fh_source")->where('id',"=",$ist['id'])->save($value);
- }else{
- Db::table("fh_source")->insert($value);
- }
- }
- $redis->set("fhsource",0);
- $output->writeln('fhsource');
- }
- public function getdata(){
- $date=date("Y-m-d H:i:s",strtotime("-3 day"));
- $sql="SELECT
- name,
- if(sequenceStatus='COMPLETED',1,2 )as status,
- sequenceNo as fhNo,
- ShortText1618317462280 as cgdNo,
- ShortText1618317471119 as qrdNo,
- ShortText1618317496943 as good_name,
- Number1618317523885 as total_num,
- Number1618317560314 as wsendnum,
- Number1618858962761 as send,
- Number1618914618800 as bala,
- ShortText1619009205937 as contacter,
- ShortText1619009211201 as addr,
- ShortText1619009234439 as mobile,
- Date1619009333616 as todate,
- ShortText1619177902654 send_mobile,
- ShortText1619177908085 send_addr,
- ShortText1619177899085 as send_p,
- ShortText1619178039231 as send_remark,
- ShortText1619463486677 as post_company,
- ShortText1619463494497 as post_code,
- Date1620559261053 as send_date,
- if(ShortText1621883082623='已发',1,0) as sendstatus,
- createdTime as addtime,
- modifiedTime as updatetime
- FROM
- iw48m_FSDJ
- where
- 1=1
- and
- modifiedTime >='{$date}'";
- $data=$this->db->query($sql);
- return $data;
- }
- }
|