Queueu9.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. /**
  3. * 该类执行队列使用
  4. */
  5. class Queueu9 extends Start_Controller {
  6. private $url = "http://git.wepolicy.cn/";
  7. private $api = 20250217;
  8. public function __construct(){
  9. parent::__construct();
  10. $this->load->_model("Model_zzquque_u9",'zzquque_u9');
  11. $this->load->_model("Model_aaconf","aaconf");
  12. $this->load->_model("Model_logic_u9xg",'logic_u9xg');
  13. $this->load->_model("Model_logic_order","logic_order");
  14. }
  15. //定义方法的调用规则 获取URI第二段值
  16. public function _remap($arg,$arg_array)
  17. {
  18. $api = $this->input->get('api',true);
  19. if($api != $this->api){
  20. exit('No direct script access allowed');
  21. }
  22. if($arg == 'xdls')//执行小单的流转到临时仓的队列
  23. {
  24. $this->xdls();
  25. }
  26. if($arg == 'xdlsbe')//执行小单的流转到临时仓的队列
  27. {
  28. $this->xdlsBeforeSh();
  29. }
  30. if($arg == 'xdlsaf')//执行小单的流转到临时仓的队列
  31. {
  32. $this->xdlsAfterSh();
  33. }
  34. else
  35. {
  36. $this->_index();
  37. }
  38. }
  39. public function _index(){
  40. //执行第一步的参数
  41. // $list = $this->zzquque_u9->find_all();
  42. // $do_list = [];
  43. // foreach($list as $k=>$v){
  44. // $tmp_info = $this->logic_order->getInfoByType($v['platform'],$v['order_no']);
  45. // $tmp_info['zq_u9_id'] = $v['id'];
  46. // $do_list[] = $tmp_info;
  47. // }
  48. // $this->logic_u9xg->xdlsOneStep($do_list);
  49. //执行第二步的参数
  50. // $list = $this->zzquque_u9->find_all("dc_status = 1 and xs_status = 1 and cg_status = 1 and type = 10 and update_time <=".(time() - 300));
  51. // $this->logic_u9xg->xdlsTwoStep($list);
  52. //执行第三部参数
  53. // $list = $this->zzquque_u9->find_all();
  54. // $this->logic_u9xg->xdlsThreeStep($list);
  55. //执行第四部的参数 生成销售单
  56. // $list = $this->zzquque_u9->find_all();
  57. // $do_list = [];
  58. // foreach($list as $k=>$v){
  59. // $tmp_info = $this->logic_order->getInfoByType($v['platform'],$v['order_no']);
  60. // $tmp_info['zq_u9_id'] = $v['id'];
  61. // $do_list[] = $tmp_info;
  62. // }
  63. // $this->logic_u9xg->xdlsFourStep($do_list);
  64. //执行第五步骤 审核销售单 并同时生成标准出货单
  65. // $list = $this->zzquque_u9->find_all();
  66. // $this->logic_u9xg->xdlsFivestep($list);
  67. $list = $this->zzquque_u9->find_all("bzch_status = 1");
  68. $this->logic_u9xg->xdlsSixStep($list);
  69. exit('No direct script access allowed index'."<br/>");
  70. }
  71. //执行小单的流转到临时仓的队列 计划10分钟一次
  72. public function xdls(){
  73. $mh = curl_multi_init();
  74. // 创建多个 cURL 资源
  75. $ch1 = curl_init();
  76. curl_setopt($ch1, CURLOPT_URL, $this->url."queueu9/xdlsbe?api=".$this->api."&rqyz1=".date("Ymd"));
  77. curl_multi_add_handle($mh, $ch1);
  78. $ch2 = curl_init();
  79. curl_setopt($ch2, CURLOPT_URL, $this->url."queueu9/xdlsaf?api=".$this->api."&rqyz1=".date("Ymd"));
  80. curl_multi_add_handle($mh, $ch2);
  81. // 执行句柄
  82. $running = null;
  83. do {
  84. $mrc = curl_multi_exec($mh, $running);
  85. } while ($mrc == CURLM_OK && $running > 0);
  86. // 关闭句柄
  87. curl_multi_remove_handle($mh, $ch1);
  88. curl_multi_remove_handle($mh, $ch2);
  89. curl_multi_close($mh);
  90. exit("Queue execution completed"."<br/>");
  91. }
  92. public function xdlsBeforeSh(){
  93. $rqyz = $this->input->get('rqyz',true);
  94. if($rqyz != date("Ymd")){
  95. exit('No direct script access allowed before'."<br/>");
  96. }
  97. if(!$this->aaconf->u9xg()){
  98. exit('This feature is not available <br/>');
  99. }
  100. //10 代表了是小单 type类型可在model中的getType()查看到
  101. $list = $this->zzquque_u9->find_all("type = 10 and status = 0 and sh_flag = 0","*",null,0,100);
  102. if(empty($list)){
  103. exit("No data to be executed at the moment <br/>");
  104. }
  105. foreach($list as $k=>$v){
  106. $this->xdlsBeforeShDetail($v);
  107. }
  108. exit("Data execution completed <br/>");
  109. }
  110. public function xdlsBeforeShDetail($info){
  111. }
  112. public function xdlsAfterSh(){
  113. $rqyz = $this->input->get('rqyz',true);
  114. if($rqyz != date("Ymd")){
  115. exit('No direct script access allowed after'."<br/>");
  116. }
  117. if(!$this->aaconf->u9xg()){
  118. exit('This feature is not available');
  119. }
  120. //10 代表了是小单 type类型可在model中的getType()查看到
  121. $list = $this->zzquque_u9->find_all("type = 10 and status = 1 and sh_flag = 1 and sh_status = 0","*",null,0,100);
  122. if(empty($list)){
  123. exit("No data to be executed at the moment");
  124. }
  125. }
  126. }