123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <?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 QrdCopy extends Command
- {
- protected $db="";
- protected function configure()
- {
- // 指令配置
- $this->setName('qrdcopy')
- ->setDescription('the qrdcopy command');
- }
- protected function execute(Input $input, Output $output)
- {
- $redis = Cache::store('redis');
- $iscgd = $redis->get("qrdcopy");
- if($iscgd==0){
- $redis->set("qrdcopy",1,1200);
- }else{
- return;
- }
- $this->db =Db::connect("mysql2");
- $data = $this->GetData();
- $list=[];
- foreach ($data as $key=>$value){
- $temp=[];
- $staff1 = $value['StaffSelector1618445844046']!=""? json_decode($value['StaffSelector1618445844046'],true):"";
- $staff2 = $value['StaffSelector1618445850209']!="" ? json_decode($value['StaffSelector1618445850209'],true):"";
- $staff3 = $value['StaffSelector1619488013389']!="" ? json_decode($value['StaffSelector1619488013389'],true):"";
- if($staff1 !=""&&$staff1[0]['id']!=""){
- $user = $this->GetUserInfo($staff1[0]['id']);
- $value['StaffSelector1618445844046'] = array_merge($user,$staff1[0]);
- }
- if( $staff2 !="" &&$staff2[0]['id']!=""){
- $user = $this->GetDepart($staff2[0]['id']);
- $value['StaffSelector1618445850209'] = $user['name'];
- }
- if( $staff3!=""&& isset($staff3[0]) &&$staff3[0]['id']!=""){
- $user = $this->GetUserInfo($staff3[0]['id']);
- $value['StaffSelector1619488013389'] = array_merge($user,$staff3[0]);
- }
- if($value['creater']!=""){
- $user = $this->GetUserInfo($value['creater']);
- $value['creater'] =isset($user['name']) ? $user['name'] : "";
- }
- if($value['createdDeptId']!=""){
- $user = $this->GetDepart($value['createdDeptId']);
- $value['createdDeptId'] =isset($user['name']) ? $user['name'] : "";
- }
- if($value['Number1618249146997']==0){
- $value['ShortText1618559043560']=1;
- }
- if($value['number1618249149738']==0){
- $value['ShortText1618559043560']=3;
- }
- if($value['Number1618249146997']>0 && $value['number1618249149738']>0){
- $value['ShortText1618559043560']=2;
- }
- if($value['Number1618249202608']==0){
- $value['ShortText1618559274859']=1;
- }
- if($value['Number1618249205231']==0){
- $value['ShortText1618559274859']=3;
- }
- if($value['Number1618249202608']>0 && $value['Number1618249205231']>0){
- $value['ShortText1618559274859']=2;
- }
- $temp['data']=json_encode($value,JSON_UNESCAPED_UNICODE);
- $temp['uniqkey']=$value['id'];
- $temp['addtime']=date("Y-m-d H:i:s");
- $temp['createtime']=date("Y-m-d H:i:s");
- $temp['status']=1;
- $isT= Db::table("source_data")->where("uniqkey","=",$value['id'])->count("id");
- if(!$isT){
- Db::table("source_data")->insert($temp);
- }
- }
- $redis->set("qrdcopy",0);
- $output->writeln('CopyData');
- }
- protected function GetData(){
- $date = date("Y-m-d H:i:s",strtotime("-3 day"));
- $table = $this->db->table("biz_workflow_instance")->alias("w")->join('il150_querendanchanpin c','w.id = c.workflowInstanceId',"left")
- ->where("appCode = 'kefuguanlibu' AND schemaCode = 'querendanchanpin' and c.sequenceStatus='COMPLETED' and c.modifiedTime>'{$date}'")
- ->field("w.id,
- w.instanceName,
- w.departmentName,
- w.originatorName,
- w.finishTime,
- w.startTime,
- w.sequenceNo,
- w.appCode,
- c.`name`,
- c.`creater`,
- c.`createdDeptId`,
- c.sequenceStatus,
- c.createdTime,
- c.Date1617081795606,
- c.RelevanceForm1617022738190,
- c.ShortText1617081712980,
- c.ShortText1617022967356,
- c.ShortText1617023369580,
- c.ShortText1617111725596,
- c.Date1620370378620,
- c.ShortText1617365292699,
- c.text1617499162303,
- c.ShortText1617365495029,
- c.ShortText1617499192065,
- c.text1617365578699,
- c.ShortText1617499210157,
- c.text1617365594353,
- c.text1617365597522,
- c.text1617365646297,
- c.text1617365950353,
- c.ShortText1617366563255,
- c.number1617366111666,
- c.number1617366110639,
- c.ShortText1617366186330,
- c.ShortText1617367958909,
- c.Number1617365688048,
- c.Number1617366579767,
- c.Number1617366626104,
- c.ShortText1617650669915,
- c.ShortText1617650701648,
- c.ShortText1617670912205,
- c.ShortText1617874567622,
- c.Number1618248810624,
- c.Number1618248813613,
- c.Number1618249015661,
- c.Number1618249019294,
- c.Number1618249146997,
- c.number1618249149738,
- c.Number1618249202608,
- c.Number1618249205231,
- c.number1618249258956,
- c.ShortText1618267589049,
- c.StaffSelector1618445844046,
- c.StaffSelector1618445850209,
- c.ShortText1618446328311,
- c.ShortText1618446949933,
- c.ShortText1618446973813,
- c.LongText1618446982973,
- c.Date1618447068290,
- c.ShortText1618447165317,
- c.ShortText1618559007040,
- c.ShortText1618559043560,
- c.ShortText1618887148862,
- c.ShortText1618559274859,
- c.ShortText1619146965777,
- c.ShortText1619164078168,
- c.Date1619401771986,
- c.Date1619402124793,
- c.Number1619403905454,
- c.Number1619403908740,
- c.ShortText1619413388848,
- c.ShortText1619413394855,
- c.ShortText1619413401534,
- c.ShortText1619487657199,
- c.StaffSelector1619488013389,
- c.ShortText1619523689586,
- c.ShortText1619523693355,
- c.ShortText1619523892833,
- c.Date1619542686640,
- c.RelevanceForm1619542896677,
- c.ShortText1619542951283,
- c.ShortText1619543001392,
- c.ShortText1619610909619,
- c.Date1619626098213,
- c.ShortText1619626536464,
- c.Number1619626656082,
- c.Number1619626666450,
- c.Number1619632062547,
- c.ShortText1619743751825,
- c.text1619743754479,
- c.text1619743755335,
- c.text1619743756377,
- c.Date1620370378620,
- c.ShortText1620750298602,
- c.ShortText1620750301301,
- c.RelevanceForm1620750481892,
- c.Number1620751537737,
- c.Date1620751562219
- ")->select();
- // echo $this->db->table("biz_workflow_instance")->getLastSql();
- return $table;
- }
- protected function GetUserInfo($ksy){
- $userinfo = $this->db->table("h_org_user")->where("id","=",$ksy)->field("name,mobile,username")->find();
- return $userinfo;
- }
- protected function GetDepart($ksy){
- $userinfo = $this->db->table("h_org_department")->where("id","=",$ksy)->field("name")->find();
- return $userinfo;
- }
- }
|