load->_model("Model_zzquque_u9",'zzquque_u9'); $this->load->_model("Model_aaconf","aaconf"); $this->load->_model("Model_logic_u9xg",'logic_u9xg'); $this->load->_model("Model_logic_order","logic_order"); $this->load->_model("Model_logic_u9zt","logic_u9zt"); $this->load->_model('Model_classid','classid'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model("Model_logic_u9mgwx","logic_u9mgwx"); $this->load->_model("Model_settingtest","settingtest"); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { $api = $this->input->get('api',true); if($api != $this->api){ exit('No direct script access allowed'); } if($arg == 'xdls')//执行小单的流转到临时仓的队列 { $this->_xdls(); } else if($arg == 'ztdl')//执行在途的队列 { $this->_zt(); } else if($arg == 'mgxxdo'){ $this->_mgxxdo(); }else if($arg == 'doxcbh'){ $this->_doXcBh(); } else { $this->_index(); } } public function _index(){ // echo "
";
// $user_agent = $_SERVER['HTTP_USER_AGENT'];
// $token = $_SERVER['HTTP_X_AUTH_TOKEN'];
// $time = $this->input->get('time',true);
// $check_str = "ququexd_".$time;
// if(empty($user_agent)){
// exit('No direct script access allowed');
// }
// if($user_agent != 'XuChangLongYi/1.0 (Erp)'){
// exit('Illegal request');
// }
// if(empty($token)){
// exit('No access permission');
// }
// $sercet_str = md5($check_str);
// if($sercet_str != $token){
// exit("Request permission is illegal");
// }
// exit("执行完毕");
}
//执行小单的流转到临时仓的队列
public function _xdls(){
$start_time = time() - 20 * 24 * 60 * 60;
//第一步生成 许昌成品库的调出单
$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');
$do_list = [];
foreach($list as $k=>$v){
$tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
$tmp_info['zq_u9_id'] = $v['id'];
$do_list[] = $tmp_info;
}
$this->logic_u9xg->xdlsOneStep($do_list);
//新加一步 查询修改调出单的审核结果
$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');
$this->logic_u9xg->xdlsOneExtraStep($list);
//var_dump($list);
//第二步 创建的采购单和销售单
$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);
// var_dump($list);
// die;
//var_dump($list);
$this->logic_u9xg->xdlsTwoStep($list);
//审核销售单和采购单
$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);
//var_dump($list);
$this->logic_u9xg->xdlsTwoExtraStep($list);
sleep(3);
//第三步 查询调出单生成的调入单是否生成 如果生成了就审核 如果没生成 说明异常了 这种都是按步骤走的
$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);
$this->logic_u9xg->xdlsThreeStep($list);
//第四步 建立香港的销售单 标准出库单有源的需要先审核 先创建销售单
$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);
$do_list = [];
foreach($list as $k=>$v){
$tmp_info = $this->logic_order->getInfoByPlat($v['platform'],$v['order_no']);
$tmp_info['zq_u9_id'] = $v['id'];
$tmp_info['dc_no'] = $v['dc_no'];
$tmp_info['dc_data'] = $v['dc_data'];
$do_list[] = $tmp_info;
}
$this->logic_u9xg->xdlsFourStep($do_list);
//执行第五步骤 审核销售单 并同时生成标准出货单
$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);
if(!empty($list)){
$this->logic_u9xg->xdlsFiveStep($list);
}
sleep(3);
$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);
$this->logic_u9xg->xdlsSixStep($list);
}
public function _zt(){
echo "";
$classid = $this->classid->sku();
$tcall = $this->typeclass->find_all();
foreach ($tcall as $v)
{
$tcjm[$v['id']] = array($v['jm'],$v['classid']);
$typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
}
//第一步生成 许昌成品库的调出单
$list = $this->zzquque_u9->find_all("type = 1 and dc_status = 0 and cg_status = 0 and xs_status = 0 ",'*','id asc',0,5);
//ZT250314172219
// $list = $this->zzquque_u9->find_all("order_no = 'ZT250314173250' and cg_status = 0 and xs_status = 0 ",'*','id asc',0,1);
foreach($list as $k=>$v){
$this->logic_u9zt->createdDc($v,$classid,$typeclass);
}
//第二步查询调出但状态
$list = $this->zzquque_u9->find_all("type = 1 and dc_status = 1 and cg_status = 0 and xs_status = 0 ",'*','id asc');
foreach($list as $k=>$v){
$this->logic_u9zt->cxDxcheck($v);
}
//第三步创建销售单和采购单
$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');
foreach($list as $k=>$v){
$this->logic_u9zt->createXsAndCg($v);
}
sleep(2);
//第四部查询调出单产生的调入单
$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');
foreach($list as $k=>$v){
$this->logic_u9zt->cxDrByDc($v);
}
//第五步审核产生的销售单和采购单
$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');
foreach($list as $k=>$v){
$this->logic_u9zt->shCgAndXs($v);
}
//第六步更新在途库存
$list = $this->zzquque_u9->find_all("type = 2 and dc_status = 0 and dc_data_status = 0 and dr_status = 0 ",'*','id asc');
foreach($list as $k=>$v){
$this->logic_u9zt->createDcTwo($v);
}
}
//定时执行美国销售
private function _mgxxdo(){
$this->logic_u9mgwx->doaction();
}
//执行许昌备货的调入单查询
private function _doXcBh(){
$this->db->select("dcd_no,status");
$this->db->from("bhdcd");
$this->db->where("status",0);
$this->db->group_by('dcd_no');
$query = $this->db->get();
$rows = $query->result_array();
echo "";
foreach($rows as $row){
$token = $this->settingtest->get_yytoken_120();
$dcd_no = $row['dcd_no'];
$res = $this->apiyyv1->drdcxBydcd($dcd_no,$token);
if(!empty($res[0]['Data'])){
if(!empty($res[0]['Data'][0]['docno']) && !empty($res[0]['Data'][0]['srcdocinfo_srcdocno'])){
$u9_dcd_no = $res[0]['Data'][0]['srcdocinfo_srcdocno'];
$u9_drd_no = $res[0]['Data'][0]['docno'];
if($u9_dcd_no == $dcd_no){
$this->db->where('dcd_no',$dcd_no);
$this->db->update('bhdcd',[
'drd_no' => $u9_drd_no,
'status'=>1,
]);
}
usleep(100);
}
}
}
$this->db->select("dcd_no,status,drd_no");
$this->db->from("bhdcd");
$this->db->where("status",1);
$this->db->group_by('dcd_no');
$query = $this->db->get();
$rows = $query->result_array();
foreach($rows as $row){
$drd_no = $row['drd_no'];
$token = $this->settingtest->get_yytoken_120();
$res = $this->apiyyv1->drdcxBydrd($drd_no,$token);
if(!empty($res[0]['Data'])){
if(!empty($res[0]['Data'][0])){
if(!empty($res[0]['Data'][0]['docno'])){
$u9_status = $res[0]['Data'][0]['status'];
$u9_drd_no = $res[0]['Data'][0]['docno'];
if($u9_status == 2){
if($u9_drd_no == $drd_no){
$this->db->where('drd_no',$drd_no);
$this->db->update('bhdcd',[
'status'=>2,
]);
}
}
}
}
}
usleep(100);
}
echo "SUCCESS";
}
}