Queueu9.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  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. $this->load->_model("Model_logic_u9mgwx","logic_u9mgwx");
  18. $this->load->_model("Model_settingtest","settingtest");
  19. }
  20. //定义方法的调用规则 获取URI第二段值
  21. public function _remap($arg,$arg_array)
  22. {
  23. $api = $this->input->get('api',true);
  24. if($api != $this->api){
  25. exit('No direct script access allowed');
  26. }
  27. if($arg == 'xdls')//执行小单的流转到临时仓的队列
  28. {
  29. $this->_xdls();
  30. }
  31. else if($arg == 'ztdl')//执行在途的队列
  32. {
  33. $this->_zt();
  34. }
  35. else if($arg == 'mgxxdo'){
  36. $this->_mgxxdo();
  37. }else if($arg == 'doxcbh'){
  38. $this->_doXcBh();
  39. }
  40. else
  41. {
  42. $this->_index();
  43. }
  44. }
  45. public function _index(){
  46. // echo "<pre>";
  47. // $user_agent = $_SERVER['HTTP_USER_AGENT'];
  48. // $token = $_SERVER['HTTP_X_AUTH_TOKEN'];
  49. // $time = $this->input->get('time',true);
  50. // $check_str = "ququexd_".$time;
  51. // if(empty($user_agent)){
  52. // exit('No direct script access allowed');
  53. // }
  54. // if($user_agent != 'XuChangLongYi/1.0 (Erp)'){
  55. // exit('Illegal request');
  56. // }
  57. // if(empty($token)){
  58. // exit('No access permission');
  59. // }
  60. // $sercet_str = md5($check_str);
  61. // if($sercet_str != $token){
  62. // exit("Request permission is illegal");
  63. // }
  64. // exit("执行完毕");
  65. }
  66. //执行小单的流转到临时仓的队列
  67. public function _xdls(){
  68. var_dump("执行小单流程");
  69. $start_time = time() - 20 * 24 * 60 * 60;
  70. //第一步生成 许昌成品库的调出单
  71. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 0 and cg_status = 0 and xs_status = 0 and create_time >= ".$start_time,'*','id asc');
  72. $do_list = [];
  73. foreach($list as $k=>$v){
  74. $tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
  75. $tmp_info['zq_u9_id'] = $v['id'];
  76. $do_list[] = $tmp_info;
  77. }
  78. $this->logic_u9xg->xdlsOneStep($do_list);
  79. //新加一步 查询修改调出单的审核结果
  80. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 1 and cg_status = 0 and xs_status = 0 and create_time >= ".$start_time,'*','id asc');
  81. $this->logic_u9xg->xdlsOneExtraStep($list);
  82. //var_dump($list);
  83. //第二步 创建的采购单和销售单
  84. $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 and create_time >= ".$start_time);
  85. // var_dump($list);
  86. // die;
  87. //var_dump($list);
  88. $this->logic_u9xg->xdlsTwoStep($list);
  89. //审核销售单和采购单
  90. $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 and create_time >= ".$start_time);
  91. //var_dump($list);
  92. $this->logic_u9xg->xdlsTwoExtraStep($list);
  93. sleep(3);
  94. //第三步 查询调出单生成的调入单是否生成 如果生成了就审核 如果没生成 说明异常了 这种都是按步骤走的
  95. $list = $this->zzquque_u9->find_all("type = 10 and dc_status = 3 and cg_status = 3 and xs_status = 3 and dr_status = 0 and create_time >= ".$start_time);
  96. $this->logic_u9xg->xdlsThreeStep($list);
  97. //第四步 建立香港的销售单 标准出库单有源的需要先审核 先创建销售单
  98. $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 and create_time >= ".$start_time);
  99. $do_list = [];
  100. foreach($list as $k=>$v){
  101. $tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
  102. $tmp_info['zq_u9_id'] = $v['id'];
  103. $tmp_info['dc_no'] = $v['dc_no'];
  104. $tmp_info['dc_data'] = $v['dc_data'];
  105. $do_list[] = $tmp_info;
  106. }
  107. $this->logic_u9xg->xdlsFourStep($do_list);
  108. //执行第五步骤 审核销售单 并同时生成标准出货单
  109. $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 and create_time >= ".$start_time);
  110. if(!empty($list)){
  111. $this->logic_u9xg->xdlsFiveStep($list);
  112. }
  113. sleep(3);
  114. $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 and create_time >= ".$start_time);
  115. $this->logic_u9xg->xdlsSixStep($list);
  116. }
  117. public function _zt(){
  118. echo "<pre>";
  119. var_dump("zt...");
  120. $classid = $this->classid->sku();
  121. $tcall = $this->typeclass->find_all();
  122. foreach ($tcall as $v)
  123. {
  124. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  125. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  126. }
  127. //第一步生成 许昌成品库的调出单
  128. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 0 and cg_status = 0 and xs_status = 0 ",'*','id asc',0,5);
  129. //ZT250314172219
  130. // $list = $this->zzquque_u9->find_all("order_no = 'ZT250314173250' and cg_status = 0 and xs_status = 0 ",'*','id asc',0,1);
  131. foreach($list as $k=>$v){
  132. $this->logic_u9zt->createdDc($v,$classid,$typeclass);
  133. }
  134. //第二步查询调出但状态
  135. $list = $this->zzquque_u9->find_all("type = 1 and dc_status = 1 and cg_status = 0 and xs_status = 0 ",'*','id asc');
  136. foreach($list as $k=>$v){
  137. $this->logic_u9zt->cxDxcheck($v);
  138. }
  139. //第三步创建销售单和采购单
  140. $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');
  141. foreach($list as $k=>$v){
  142. $this->logic_u9zt->createXsAndCg($v);
  143. }
  144. sleep(2);
  145. //第四部查询调出单产生的调入单
  146. $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');
  147. foreach($list as $k=>$v){
  148. $this->logic_u9zt->cxDrByDc($v);
  149. }
  150. //第五步审核产生的销售单和采购单
  151. $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');
  152. foreach($list as $k=>$v){
  153. $this->logic_u9zt->shCgAndXs($v);
  154. }
  155. //第六步更新在途库存
  156. $list = $this->zzquque_u9->find_all("type = 2 and dc_status = 0 and dc_data_status = 0 and dr_status = 0 ",'*','id asc');
  157. foreach($list as $k=>$v){
  158. $this->logic_u9zt->createDcTwo($v);
  159. }
  160. }
  161. //定时执行美国销售
  162. private function _mgxxdo(){
  163. var_dump("定时执行美国销售");
  164. $this->logic_u9mgwx->doaction();
  165. }
  166. //执行许昌备货的调入单查询
  167. private function _doXcBh(){
  168. $this->db->select("dcd_no,status,drd_no");
  169. $this->db->from("bhdcd");
  170. $this->db->where("drd_no = '' or drd_no is null");
  171. $this->db->group_by('dcd_no');
  172. $query = $this->db->get();
  173. $rows = $query->result_array();
  174. echo "<pre>";
  175. foreach($rows as $row){
  176. $token = $this->settingtest->get_yytoken_120();
  177. $dcd_no = $row['dcd_no'];
  178. $res = $this->apiyyv1->drdcxBydcd($dcd_no,$token);
  179. if(!empty($res[0]['Data'])){
  180. if(!empty($res[0]['Data'][0]['docno']) && !empty($res[0]['Data'][0]['srcdocinfo_srcdocno'])){
  181. $u9_dcd_no = $res[0]['Data'][0]['srcdocinfo_srcdocno'];
  182. $u9_drd_no = $res[0]['Data'][0]['docno'];
  183. if($u9_dcd_no == $dcd_no){
  184. $this->db->where('dcd_no',$dcd_no);
  185. $this->db->update('bhdcd',[
  186. 'drd_no' => $u9_drd_no,
  187. //'status'=>1,
  188. ]);
  189. }
  190. usleep(100);
  191. }
  192. }
  193. }
  194. // $this->db->select("dcd_no,status,drd_no");
  195. // $this->db->from("bhdcd");
  196. // $this->db->where("status",1);
  197. // $this->db->group_by('dcd_no');
  198. // $query = $this->db->get();
  199. // $rows = $query->result_array();
  200. // foreach($rows as $row){
  201. // $drd_no = $row['drd_no'];
  202. // $token = $this->settingtest->get_yytoken_120();
  203. // $res = $this->apiyyv1->drdcxBydrd($drd_no,$token);
  204. // if(!empty($res[0]['Data'])){
  205. // if(!empty($res[0]['Data'][0])){
  206. // if(!empty($res[0]['Data'][0]['docno'])){
  207. // $u9_status = $res[0]['Data'][0]['status'];
  208. // $u9_drd_no = $res[0]['Data'][0]['docno'];
  209. // if($u9_status == 2){
  210. // if($u9_drd_no == $drd_no){
  211. // $this->db->where('drd_no',$drd_no);
  212. // $this->db->update('bhdcd',[
  213. // 'status'=>2,
  214. // ]);
  215. // }
  216. // }
  217. // }
  218. // }
  219. // }
  220. // usleep(100);
  221. // }
  222. echo "SUCCESS";
  223. }
  224. }