Queueu9.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. $this->load->_model("Model_logic_u9zt","logic_u9zt");
  15. $this->load->_model('Model_classid','classid');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. }
  18. //定义方法的调用规则 获取URI第二段值
  19. public function _remap($arg,$arg_array)
  20. {
  21. $api = $this->input->get('api',true);
  22. if($api != $this->api){
  23. exit('No direct script access allowed');
  24. }
  25. if($arg == 'xdls')//执行小单的流转到临时仓的队列
  26. {
  27. $this->_xdls();
  28. }
  29. if($arg == 'ztdl')//执行在途的队列
  30. {
  31. $this->_zt();
  32. }
  33. else
  34. {
  35. $this->_index();
  36. }
  37. }
  38. public function _index(){
  39. echo "<pre>";
  40. $user_agent = $_SERVER['HTTP_USER_AGENT'];
  41. $token = $_SERVER['HTTP_X_AUTH_TOKEN'];
  42. $time = $this->input->get('time',true);
  43. $check_str = "ququexd_".$time;
  44. if(empty($user_agent)){
  45. exit('No direct script access allowed');
  46. }
  47. if($user_agent != 'XuChangLongYi/1.0 (Erp)'){
  48. exit('Illegal request');
  49. }
  50. if(empty($token)){
  51. exit('No access permission');
  52. }
  53. $sercet_str = md5($check_str);
  54. if($sercet_str != $token){
  55. exit("Request permission is illegal");
  56. }
  57. exit("执行完毕");
  58. }
  59. //执行小单的流转到临时仓的队列
  60. public function _xdls(){
  61. //第一步生成 许昌成品库的调出单
  62. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 0 and cg_status = 0 and xs_status = 0 ",'*','id asc');
  63. $do_list = [];
  64. foreach($list as $k=>$v){
  65. $tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
  66. $tmp_info['zq_u9_id'] = $v['id'];
  67. $do_list[] = $tmp_info;
  68. }
  69. $this->logic_u9xg->xdlsOneStep($do_list);
  70. //新加一步 查询修改调出单的审核结果
  71. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 1 and cg_status = 0 and xs_status = 0 ",'*','id asc');
  72. $this->logic_u9xg->xdlsOneExtraStep($list);
  73. //var_dump($list);
  74. //第二步 创建的采购单和销售单
  75. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and dc_data_status = 1 and cg_status = 0 and xs_status = 0 ");
  76. // var_dump($list);
  77. // die;
  78. //var_dump($list);
  79. $this->logic_u9xg->xdlsTwoStep($list);
  80. //审核销售单和采购单
  81. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and dc_data_status = 1 and cg_status = 1 and xs_status = 1");
  82. //var_dump($list);
  83. $this->logic_u9xg->xdlsTwoExtraStep($list);
  84. sleep(3);
  85. //第三步 查询调出单生成的调入单是否生成 如果生成了就审核 如果没生成 说明异常了 这种都是按步骤走的
  86. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and cg_status = 3 and xs_status = 3 and dr_status = 0");
  87. $this->logic_u9xg->xdlsThreeStep($list);
  88. //第四步 建立香港的销售单 标准出库单有源的需要先审核 先创建销售单
  89. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and cg_status = 3 and xs_status = 3 and dr_status = 3 and xs_two_status = 0 ");
  90. $do_list = [];
  91. foreach($list as $k=>$v){
  92. $tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
  93. $tmp_info['zq_u9_id'] = $v['id'];
  94. $tmp_info['dc_no'] = $v['dc_no'];
  95. $tmp_info['dc_data'] = $v['dc_data'];
  96. $do_list[] = $tmp_info;
  97. }
  98. $this->logic_u9xg->xdlsFourStep($do_list);
  99. //执行第五步骤 审核销售单 并同时生成标准出货单
  100. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and cg_status = 3 and xs_status = 3 and dr_status = 3 and xs_two_status = 1 and bzch_status = 0 ");
  101. if(!empty($list)){
  102. $this->logic_u9xg->xdlsFiveStep($list);
  103. }
  104. sleep(3);
  105. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and cg_status = 3 and xs_status = 3 and dr_status = 3 and xs_two_status = 3 and bzch_status = 1 ");
  106. $this->logic_u9xg->xdlsSixStep($list);
  107. }
  108. public function _zt(){
  109. echo "<pre>";
  110. $classid = $this->classid->sku();
  111. $tcall = $this->typeclass->find_all();
  112. foreach ($tcall as $v)
  113. {
  114. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  115. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  116. }
  117. //第一步生成 许昌成品库的调出单
  118. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 0 and cg_status = 0 and xs_status = 0 ",'*','id asc',0,5);
  119. //ZT250314172219
  120. // $list = $this->zzquque_u9->find_all("order_no = 'ZT250314173250' and cg_status = 0 and xs_status = 0 ",'*','id asc',0,1);
  121. foreach($list as $k=>$v){
  122. $this->logic_u9zt->createdDc($v,$classid,$typeclass);
  123. }
  124. //第二步查询调出但状态
  125. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 1 and cg_status = 0 and xs_status = 0 ",'*','id asc');
  126. foreach($list as $k=>$v){
  127. $this->logic_u9zt->cxDxcheck($v);
  128. }
  129. //第三步创建销售单和采购单
  130. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 3 and dc_data_status = 1 and cg_status = 0 and xs_status = 0 ",'*','id asc');
  131. foreach($list as $k=>$v){
  132. $this->logic_u9zt->createXsAndCg($v);
  133. }
  134. sleep(2);
  135. //第四部查询调出单产生的调入单
  136. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 3 and dc_data_status = 1 and cg_status = 1 and xs_status = 1 and dr_status = 0 ",'*','id asc');
  137. foreach($list as $k=>$v){
  138. $this->logic_u9zt->cxDrByDc($v);
  139. }
  140. //第五步审核产生的销售单和采购单
  141. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 3 and dc_data_status = 1 and cg_status = 1 and xs_status = 1 and dr_status = 3 ",'*','id asc');
  142. foreach($list as $k=>$v){
  143. $this->logic_u9zt->shCgAndXs($v);
  144. }
  145. //第六步更新在途库存
  146. $list = $this->zzquque_u9->find_all("type = 2 and dc_status = 0 and dc_data_status = 0 and dr_status = 0 ",'*','id asc');
  147. foreach($list as $k=>$v){
  148. $this->logic_u9zt->createDcTwo($v);
  149. }
  150. }
  151. }