setName('datacopy') ->setDescription('the datacopy command'); } protected function execute(Input $input, Output $output) { $redis = Cache::store('redis'); $iscgd = $redis->get("diffprice"); if($iscgd==0){ $redis->set("diffprice",1,1200); }else{ return; } try { $data = $this->GetData(); foreach ($data as $value) { $ist = Db::table("diff_price")->where('sequenceNo', "=", $value['sequenceNo'])->find(); if (!$ist) { Db::table("diff_price")->insert($value); } } $redis->set("diffprice",0); $output->writeln('diff'); }catch (\Exception $e){ $redis->set("diffprice",0); $output->writeln('diff'); } } public function getdata() { $this->db =Db::connect("mysql2"); $date = date("Y-m-d H:i:s", strtotime("-11 day")); $sql = " SELECT NAME as name, ( SELECT `b_`.`name` FROM `h_org_user` `b_` WHERE ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`owner` )) AS ownername, ( SELECT `b_`.`name` FROM `h_org_department` `b_` WHERE ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`ownerDeptId` )) AS ownerDept, createdTime AS addtime, ( SELECT `b_`.`name` FROM `h_org_user` `b_` WHERE ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`modifier` )) AS modifier, modifiedTime AS updatetime, sequenceNo, sequenceStatus, ShortText1618324616212 'cgdNo', Date1618324623113 'cgdtime', ( SELECT `b_`.`name` FROM `il150_Customer_info` `b_` WHERE ( CONVERT ( `b_`.`id` USING utf8mb4 ) = `b`.`RelevanceForm1618324639751` )) as khName, ShortText1618324650659 'khNo', ShortText1618324668256 'goodName', ShortText1618324670141 'goodNo', ShortText1618324697504 'materal', Number1618324752186 'good_weight', Number1618324771668 'goodNum', Number1618324774208 'diff_weight', Number1618325048841 'diff_fee', number1619456487393 'qrd_weight', number1619456505633 'qrd_fee', ShortText1619631384425 'qrdNo', if(ifnull(ShortText1625201144504,'否')='是',1,0) 'is_qrd' FROM iw48m_gongchadengji b where sequenceStatus= 'COMPLETED' and modifiedTime >='{$date}'"; $data = $this->db->query($sql); return $data; } }