QrdCopy.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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 QrdCopy extends Command
  12. {
  13. protected $db="";
  14. protected function configure()
  15. {
  16. // 指令配置
  17. $this->setName('qrdcopy')
  18. ->setDescription('the qrdcopy command');
  19. }
  20. protected function execute(Input $input, Output $output)
  21. {
  22. $redis = Cache::store('redis');
  23. $iscgd = $redis->get("qrdcopy");
  24. if($iscgd==0){
  25. $redis->set("qrdcopy",1,1200);
  26. }else{
  27. return;
  28. }
  29. $this->db =Db::connect("mysql2");
  30. $data = $this->GetData();
  31. $list=[];
  32. foreach ($data as $key=>$value){
  33. $temp=[];
  34. $staff1 = $value['StaffSelector1618445844046']!=""? json_decode($value['StaffSelector1618445844046'],true):"";
  35. $staff2 = $value['StaffSelector1618445850209']!="" ? json_decode($value['StaffSelector1618445850209'],true):"";
  36. $staff3 = $value['StaffSelector1619488013389']!="" ? json_decode($value['StaffSelector1619488013389'],true):"";
  37. if($staff1 !=""&&$staff1[0]['id']!=""){
  38. $user = $this->GetUserInfo($staff1[0]['id']);
  39. $value['StaffSelector1618445844046'] = array_merge($user,$staff1[0]);
  40. }
  41. if( $staff2 !="" &&$staff2[0]['id']!=""){
  42. $user = $this->GetDepart($staff2[0]['id']);
  43. $value['StaffSelector1618445850209'] = $user['name'];
  44. }
  45. if( $staff3!=""&& isset($staff3[0]) &&$staff3[0]['id']!=""){
  46. $user = $this->GetUserInfo($staff3[0]['id']);
  47. $value['StaffSelector1619488013389'] = array_merge($user,$staff3[0]);
  48. }
  49. if($value['creater']!=""){
  50. $user = $this->GetUserInfo($value['creater']);
  51. $value['creater'] =isset($user['name']) ? $user['name'] : "";
  52. }
  53. if($value['createdDeptId']!=""){
  54. $user = $this->GetDepart($value['createdDeptId']);
  55. $value['createdDeptId'] =isset($user['name']) ? $user['name'] : "";
  56. }
  57. if($value['Number1618249146997']==0){
  58. $value['ShortText1618559043560']=1;
  59. }
  60. if($value['number1618249149738']==0){
  61. $value['ShortText1618559043560']=3;
  62. }
  63. if($value['Number1618249146997']>0 && $value['number1618249149738']>0){
  64. $value['ShortText1618559043560']=2;
  65. }
  66. if($value['Number1618249202608']==0){
  67. $value['ShortText1618559274859']=1;
  68. }
  69. if($value['Number1618249205231']==0){
  70. $value['ShortText1618559274859']=3;
  71. }
  72. if($value['Number1618249202608']>0 && $value['Number1618249205231']>0){
  73. $value['ShortText1618559274859']=2;
  74. }
  75. $temp['data']=json_encode($value,JSON_UNESCAPED_UNICODE);
  76. $temp['uniqkey']=$value['id'];
  77. $temp['addtime']=date("Y-m-d H:i:s");
  78. $temp['createtime']=date("Y-m-d H:i:s");
  79. $temp['status']=1;
  80. $isT= Db::table("source_data")->where("uniqkey","=",$value['id'])->count("id");
  81. if(!$isT){
  82. Db::table("source_data")->insert($temp);
  83. }
  84. }
  85. $redis->set("qrdcopy",0);
  86. $output->writeln('CopyData');
  87. }
  88. protected function GetData(){
  89. $date = date("Y-m-d H:i:s",strtotime("-3 day"));
  90. $table = $this->db->table("biz_workflow_instance")->alias("w")->join('il150_querendanchanpin c','w.id = c.workflowInstanceId',"left")
  91. ->where("appCode = 'kefuguanlibu' AND schemaCode = 'querendanchanpin' and c.sequenceStatus='COMPLETED' and c.modifiedTime>'{$date}'")
  92. ->field("w.id,
  93. w.instanceName,
  94. w.departmentName,
  95. w.originatorName,
  96. w.finishTime,
  97. w.startTime,
  98. w.sequenceNo,
  99. w.appCode,
  100. c.`name`,
  101. c.`creater`,
  102. c.`createdDeptId`,
  103. c.sequenceStatus,
  104. c.createdTime,
  105. c.Date1617081795606,
  106. c.RelevanceForm1617022738190,
  107. c.ShortText1617081712980,
  108. c.ShortText1617022967356,
  109. c.ShortText1617023369580,
  110. c.ShortText1617111725596,
  111. c.Date1620370378620,
  112. c.ShortText1617365292699,
  113. c.text1617499162303,
  114. c.ShortText1617365495029,
  115. c.ShortText1617499192065,
  116. c.text1617365578699,
  117. c.ShortText1617499210157,
  118. c.text1617365594353,
  119. c.text1617365597522,
  120. c.text1617365646297,
  121. c.text1617365950353,
  122. c.ShortText1617366563255,
  123. c.number1617366111666,
  124. c.number1617366110639,
  125. c.ShortText1617366186330,
  126. c.ShortText1617367958909,
  127. c.Number1617365688048,
  128. c.Number1617366579767,
  129. c.Number1617366626104,
  130. c.ShortText1617650669915,
  131. c.ShortText1617650701648,
  132. c.ShortText1617670912205,
  133. c.ShortText1617874567622,
  134. c.Number1618248810624,
  135. c.Number1618248813613,
  136. c.Number1618249015661,
  137. c.Number1618249019294,
  138. c.Number1618249146997,
  139. c.number1618249149738,
  140. c.Number1618249202608,
  141. c.Number1618249205231,
  142. c.number1618249258956,
  143. c.ShortText1618267589049,
  144. c.StaffSelector1618445844046,
  145. c.StaffSelector1618445850209,
  146. c.ShortText1618446328311,
  147. c.ShortText1618446949933,
  148. c.ShortText1618446973813,
  149. c.LongText1618446982973,
  150. c.Date1618447068290,
  151. c.ShortText1618447165317,
  152. c.ShortText1618559007040,
  153. c.ShortText1618559043560,
  154. c.ShortText1618887148862,
  155. c.ShortText1618559274859,
  156. c.ShortText1619146965777,
  157. c.ShortText1619164078168,
  158. c.Date1619401771986,
  159. c.Date1619402124793,
  160. c.Number1619403905454,
  161. c.Number1619403908740,
  162. c.ShortText1619413388848,
  163. c.ShortText1619413394855,
  164. c.ShortText1619413401534,
  165. c.ShortText1619487657199,
  166. c.StaffSelector1619488013389,
  167. c.ShortText1619523689586,
  168. c.ShortText1619523693355,
  169. c.ShortText1619523892833,
  170. c.Date1619542686640,
  171. c.RelevanceForm1619542896677,
  172. c.ShortText1619542951283,
  173. c.ShortText1619543001392,
  174. c.ShortText1619610909619,
  175. c.Date1619626098213,
  176. c.ShortText1619626536464,
  177. c.Number1619626656082,
  178. c.Number1619626666450,
  179. c.Number1619632062547,
  180. c.ShortText1619743751825,
  181. c.text1619743754479,
  182. c.text1619743755335,
  183. c.text1619743756377,
  184. c.Date1620370378620,
  185. c.ShortText1620750298602,
  186. c.ShortText1620750301301,
  187. c.RelevanceForm1620750481892,
  188. c.Number1620751537737,
  189. c.Date1620751562219
  190. ")->select();
  191. // echo $this->db->table("biz_workflow_instance")->getLastSql();
  192. return $table;
  193. }
  194. protected function GetUserInfo($ksy){
  195. $userinfo = $this->db->table("h_org_user")->where("id","=",$ksy)->field("name,mobile,username")->find();
  196. return $userinfo;
  197. }
  198. protected function GetDepart($ksy){
  199. $userinfo = $this->db->table("h_org_department")->where("id","=",$ksy)->field("name")->find();
  200. return $userinfo;
  201. }
  202. }