Kaynağa Gözat

上传erp的备货流转过程

lvhao 1 hafta önce
ebeveyn
işleme
cd240daded

+ 304 - 107
core/CoreApp/controllers/Whlabel_bh.php

@@ -38,6 +38,10 @@ class Whlabel_bh extends Start_Controller {
 		$this->load->_model('Model_transfer','transfer');
 		$this->load->_model("Model_logic_u9tools","logic_u9tools");
 		$this->load->_model("Model_logic_ding","logic_ding");
+		$this->load->_model("Model_apiyyv1","apiyyv1");
+		$this->load->_model('Model_settingtest','settingtest');
+		$this->load->_model("Model_whlabel_bh_transfer_cr","whlabel_bh_transfer_cr");
+		$this->load->_model("Model_zzquque_u9","zzquque_u9");
 	}
 	//定义方法的调用规则 获取URI第二段值
     public function _remap($arg,$arg_array)
@@ -93,6 +97,14 @@ class Whlabel_bh extends Start_Controller {
 		else if($arg == 'bdbb')
         {
              $this->_bdbb();
+        }
+		else if($arg == 'rk')
+        {
+             $this->_rk();
+        }
+		else if($arg == 'ck')
+        {
+             $this->_ck();
         }
 		else
 		{
@@ -1534,34 +1546,228 @@ class Whlabel_bh extends Start_Controller {
 				$post['number'] = $data['number'];
 				$post['title'] = $data['title'];
 				$post['printtime'] = $time;
-				$post['ts'] = $n;
-				$post['rk'] = "|15|";//默认订单中心 打印后直接入库
-				$post['rktime'] = "|".$time."|";
-				$post['ctime15'] = $time;
+				$post['ts'] = 1;
+				// $post['rk'] = "";//默认订单中心 打印后直接入库
+				// $post['rktime'] = "";
+				// $post['ctime15'] = $time;
 				$post['time'] = $time;
 				$post['gtime'] = date('Yms',$time);
 				$rows = array();
-				$label = substr($time,1).rand(10,99);
+				$label = date("ymdHis").rand(1000,9999);
 				$post['label'] = $label;
-				$rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>$n);
-				if($this->whlabel_bh_transfer->insert($post))
+				
+
+				// if($this->whlabel_bh_transfer->insert($post))
+				// {
+				// 	echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
+			    // }
+			    // else
+			    // {
+				// 	$this->db->trans_rollback();
+				//     echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
+			    // }
+
+
+				if(stripos($post['features'],'-126-') !== false)
+				{
+					$drck = '12003';//进入发条库
+				}
+				else if(stripos($post['features'],'-127-') !== false)
+				{
+					$drck = '12004';//进入发块库
+				}
+				else
+				{
+					$drck = '12006';//其它进入完成库
+				}
+				//创建u9的生产单
+				$token = $this->settingtest->get_yytoken_120();
+				$params = [
+					'org_code'=>"120",
+					'djhlx'=>'2000',
+					'scbm_code'=>"12008",
+					"time"=>time(),
+					'owner_org_code'=>"120",
+					'title'=>$post['orderinfo'],
+					'shipremarks'=>$data['shipremarks'],
+					'list'=>[
+						[
+							'drck'=>$drck,
+							'jm'=>$post['jm'],
+							'sl'=>$n,
+							'drck'=>$drck,
+						]
+					]
+				];
+				
+				$res = $this->apiyyv1->scdCreate($params,$token);
+				$this->logic_ding->sendToDing("【".$post['orderinfo']."-".$data['id']."】生产备货同步u9||".json_encode($res,JSON_UNESCAPED_UNICODE));
+				if(!isset($res[0]['Data'])){
+					echo json_encode(array('msg'=>'u9同步返回异常,请重试!','success'=>false));exit;
+				}
+				if(!$res[0]['Data'][0]['m_isSucess']){
+					echo json_encode(array('msg'=>'u9同步失败,请重试!','success'=>false));exit;
+				}
+				$scid = $res[0]['Data'][0]['m_iD']."~".$res[0]['Data'][0]['m_code']."~".$drck;
+				$post['scid'] = $scid;
+				$post['scapi'] = 1;
+				$post['dbapi'] = 0;
+				$this->db->trans_begin();
+				$post['shipremarks'] = $data['shipremarks'];
+				for($i = 0;$i < $n;$i++){
+					$post['label'] = $label.$i;
+					$rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['pm'],'n'=>1);
+					$this->whlabel_bh_transfer->insert($post);
+				}
+				
+				if ($this->db->trans_status() === TRUE)
 				{
+					$this->db->trans_commit();
 					echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
-			    }
-			    else
-			    {
+				}else{
 					$this->db->trans_rollback();
-				    echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
-			    }
+					echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
+				}
+
+				
+
+
+				
 			}
 	}
+
 	
-	public function _operate()
+	public function _bdbb()
 	{
 		$post = $this->input->post(NULL, TRUE);
-	    if(isset($post['page']))  
+		if(isset($post['s']))  
+		{
+            $id_arr = $this->input->post('s');
+            $id_arr =  explode(',',trim($id_arr,','));
+            if(!$id_arr)
+            {
+                echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
+            }
+            //循环删除记录
+            foreach ($id_arr as $v) 
+		    {
+                $t = $this->whlabel_bh_transfer->read($v);
+				if(!isset($t['number']))
+				{
+					echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
+				}
+				$rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
+            }
+            echo json_encode(array('rows'=>($rows),'success'=>true));exit;
+		}
+    }
+	public function _out()
+	{
+		$post = $this->input->post(NULL, TRUE);
+		if(isset($post['label']))
 		{
-			$api = $this->input->post('api',true);
+			$time = time();
+			$label = $this->input->post('label',true);
+			$cz = $this->input->post('cz',true);
+			$transfer = $this->input->post('transfer',true);
+			if(!$label)
+			{
+				echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
+			}
+			if(!$transfer)
+			{
+				echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
+			}
+			$lb = $this->whlabel_bh_transfer->get_label($label);
+			if(!$lb)
+			{
+				echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
+			}
+			$lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
+			$lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
+			$tdata = $this->transfer->find_all();
+			$t = array();
+			foreach ($tdata as $v)
+		    {
+				$t[$v['id']] = $v['title'];
+			}
+			if($cz == 1)
+			{
+				if($lb['rk'] != $lb['ck'])//判断是否没走完流程就拿到下一步奏
+				{
+					echo json_encode(array('msg'=>$t[$lbrk[0]].'还未出库,无法入库!','success'=>false));exit;
+				}
+			}
+			if($cz == 2 && $lbrk[0] != $transfer)//判断是否没走完流程就拿到下一步奏
+			{
+				echo json_encode(array('msg'=>$t[$transfer].'还未入库,无法出库!','success'=>false));exit;
+			}
+			if($cz == 1)
+			{
+				$lb['rk'] .= $transfer.'|';
+				$lb['rktime'] .= $time.'|';
+				if($lbrk[0] == $transfer)
+				{
+					echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
+				}
+			}
+			else if($cz == 2)
+			{
+				$lb['ck'] .= $transfer.'|';
+				$lb['cktime'] .= $time.'|';
+				if($lbck[0] == $transfer)
+				{
+					echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
+				}
+			}
+			$cztime = 'ctime'.$transfer;
+			//如果是完成扫出 这样会通知erp生成一个调出单
+			if($transfer == 3 && $cz == 2 && $lb['dbapi'] < 99){
+
+				$this->db->trans_begin();
+				$this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time,'dbapi'=>99),$lb['id']);
+				$this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time()]);
+				$this->zzquque_u9->insert([
+					'platform'=>'',
+					'warehouse'=>0,
+					'type'=>21,     
+					'order_no'=>$lb['orderinfo'],
+					'child_order_no'=>$lb['id'],
+					'status'=>0,
+					'create_time'=>time(),
+					'update_time'=>time(),
+				]);
+				if ($this->db->trans_status() === TRUE){
+					$this->db->trans_commit();
+					echo json_encode(array('music'=>'1','success'=>true));exit;
+				}else{
+					$this->db->trans_rollback();
+					echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+				}
+				
+			}
+
+			
+			//if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
+			if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false &&  stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
+			{
+				echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
+			}
+
+			$this->db->trans_begin();
+			$this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']);
+			$this->whlabel_bh_transfer_cr->insert(['fid'=>$lb['id'],'lx'=>$transfer,'type'=>$cz,'time'=>time()]);
+			if ($this->db->trans_status() === TRUE){
+				$this->db->trans_commit();
+				echo json_encode(array('music'=>'1','success'=>true));exit;
+			}else{
+				$this->db->trans_rollback();
+				echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+			}
+		}
+	}
+	protected function getOperateList(){
+		    $api = $this->input->post('api',true);
 		    $page = $this->input->post('page',true);
 		    $perpage = $this->input->post('perpage',true);
 			$orderinfo = $this->input->post('number',true);
@@ -1627,35 +1833,28 @@ class Whlabel_bh extends Start_Controller {
 			 //格式化数据
             foreach ($info_list as $key=>$value)
 		    {
-				$dd = $this->whlabel_bh_transfer->read($value['id']);
 				$info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
-				$rk = explode('|',trim($dd['rk'],'|'));
-				$rktime = explode('|',trim($dd['rktime'],'|'));
-				$ck = explode('|',trim($dd['ck'],'|'));
-				$cktime = explode('|',trim($dd['cktime'],'|'));
-				$info_list[$key]['time'] = '';
-				for($i=0;$i<count($rk);$i++)
-		        {
-					if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
-					{
-						$d = '<em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br>';
-					}
-					else
-					{
-						$d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
-					}
-					$info_list[$key]['time'] .= $d;
-					if(isset($ck[$i]) && $ck[$i] != '')
-					{
-						$info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
-					}
+				$log_list= $this->whlabel_bh_transfer_cr->find_all("fid = ".$value['id']);
+				$tmp_operate_str = "";
+				foreach($log_list as $k=>$v){
+					$tmp_operate_str.= $t[$v['lx']]."".($v['type']==1?'入库':'出库').":".date('Y-m-d H:i:s',$v['time'])."<br>";
 				}
-				$info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
+
+				$info_list[$key]['time'] = trim($tmp_operate_str,'<br>');
             }
 		    $total = $this->whlabel_bh_transfer->find_count($where);
 		    $pagenum = ceil($total/$perpage);
 		    $over = $total-($start+$perpage);
-		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
+		    $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list),'where'=>$where);
+		    return $rows;
+	}
+	
+	public function _operate()
+	{
+		$post = $this->input->post(NULL, TRUE);
+	    if(isset($post['page']))  
+		{
+			$rows = $this->getOperateList();
 		    echo json_encode($rows);exit;
 		}
 		if(isset($_SESSION['api']))
@@ -1694,87 +1893,85 @@ class Whlabel_bh extends Start_Controller {
 		$this->_Template('whlabel_bh_operate',$this->data);
 	}
 	
-	public function _out()
+
+
+	public function _rk()
 	{
 		$post = $this->input->post(NULL, TRUE);
-		if(isset($post['label']))
+	    if(isset($post['page']))  
 		{
-			$time = time();
-			$label = $this->input->post('label',true);
-			$cz = $this->input->post('cz',true);
-			$transfer = $this->input->post('transfer',true);
-			if(!$label)
-			{
-				echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
-			}
-			if(!$transfer)
-			{
-				echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
-			}
-			$lb = $this->whlabel_bh_transfer->get_label($label);
-			if(!$lb)
-			{
-				echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
-			}
-			$lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
-			$lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
-			if($cz == 1)
-			{
-				$lb['rk'] .= $transfer.'|';
-				$lb['rktime'] .= $time.'|';
-				if($lbrk[0] == $transfer)
-				{
-					echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
-				}
-			}
-			else if($cz == 2)
-			{
-				$lb['ck'] .= $transfer.'|';
-				$lb['cktime'] .= $time.'|';
-				if($lbck[0] == $transfer)
-				{
-					echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
-				}
-			}
-			$cztime = 'ctime'.$transfer;
-			//if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
-			if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false &&  stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
-			{
-				echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
+			$res = $this->getOperateList();
+		    $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
+		    echo json_encode($rows);exit;
+		}
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $pid = "";$tid="";$sid="";$wid="";
+		    $purchase = explode('|',trim($user['purchase'],'|'));
+			$transfer = explode('|',trim($user['transfer'],'|'));
+			$warehouse = explode('|',trim($user['warehouse'],'|'));
+			foreach ($purchase as $value) 
+		    {
+				$pid .= " id = ".$value." or";
 			}
-			if($this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']))
-			{
-				echo json_encode(array('music'=>'1','success'=>true));exit;
+			foreach ($transfer as $value) 
+		    {
+				$tid .= " id = ".$value." or";
 			}
-			else
-			{
-				echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
+			foreach ($warehouse as $value) 
+		    {
+				$wid .= " id = ".$value." or";
 			}
 		}
+		else
+		{
+			header('Location: /');exit;
+		}
+		$transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
+		$this->data['transfer'] = $transfer;
+		$this->_Template('whlabel_bh_rk',$this->data);
 	}
 	
-	public function _bdbb()
+	
+	public function _ck()
 	{
 		$post = $this->input->post(NULL, TRUE);
-		if(isset($post['s']))  
+	    if(isset($post['page']))  
 		{
-            $id_arr = $this->input->post('s');
-            $id_arr =  explode(',',trim($id_arr,','));
-            if(!$id_arr)
-            {
-                echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
-            }
-            //循环删除记录
-            foreach ($id_arr as $v) 
+			$res = $this->getOperateList();
+		    $rows = array('total'=>$res['total'],'over'=>$res['over'],'pagenum'=>$res['pagenum'],'rows'=>($res['rows']),'cs'=>$res['where']);
+		    echo json_encode($rows);exit;
+		}
+		if(isset($_SESSION['api']))
+		{
+			$user = $this->user->get_api($_SESSION['api']);
+			$usp = $user;
+		    $pid = "";$tid="";$sid="";$wid="";
+		    $purchase = explode('|',trim($user['purchase'],'|'));
+			$transfer = explode('|',trim($user['transfer'],'|'));
+			$warehouse = explode('|',trim($user['warehouse'],'|'));
+			foreach ($purchase as $value) 
 		    {
-                $t = $this->whlabel_bh_transfer->read($v);
-				if(!isset($t['number']))
-				{
-					echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
-				}
-				$rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
-            }
-            echo json_encode(array('rows'=>($rows),'success'=>true));exit;
+				$pid .= " id = ".$value." or";
+			}
+			foreach ($transfer as $value) 
+		    {
+				$tid .= " id = ".$value." or";
+			}
+			foreach ($warehouse as $value) 
+		    {
+				$wid .= " id = ".$value." or";
+			}
 		}
-    }
+		else
+		{
+			header('Location: /');exit;
+		}
+		$transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
+		$this->data['transfer'] = $transfer;
+		$this->_Template('whlabel_bh_ck',$this->data);
+	}
+	
 }

+ 13 - 1
core/CoreApp/models/Model_apiyyv1.php

@@ -278,6 +278,18 @@ class Model_apiyyv1 extends Lin_Model
 
 	}
 	
+	/**
+	 * 创建生产单
+	 */
+	public function scdCreate($params,$token){
+		$list = $this->scdDataTrans($params);
+		$url = '/U9C/webapi/MODoc/Create';
+		$url = $this->base_url.$url;
+		$header[] = "Content-Type: application/json";
+        $header[] = "Token: ".$token;
+		$res = $this->sendReq($url,$header,json_encode($list));
+		return array($res,$list);
+	}
 
 	/**
 	 * 标准出货单提交并审核
@@ -916,7 +928,7 @@ class Model_apiyyv1 extends Lin_Model
 			"DocNo"=>"",//
 			"CompleteList"=>$list,
 			"DescFlexField"=>[
-				"PubDescSeg2"=>$params['yyid'],//kh
+				//"PubDescSeg2"=>$params['yyid'],//kh
 				"PubDescSeg4"=>$params['number'],//订单编码
 				"PubDescSeg5"=>$params['shipremarks'],//备注
 			],

+ 220 - 0
core/CoreApp/models/Model_logic_u9bh.php

@@ -0,0 +1,220 @@
+<?php
+/**
+ * 系统自动处理在途库存的香港问题
+ */
+class Model_logic_u9bh extends Lin_Model {
+   
+    //切记要修改token_120的token真正的token!!!!
+    function __construct(){
+        parent::__construct();
+        $this->load->_model('Model_settingtest','settingtest');
+        $this->load->_model("Model_apiyyv1","apiyyv1");
+        $this->load->_model("Model_logic_ding","logic_ding");
+        $this->load->_model("Model_zzquque_u9","zzquque_u9");
+        $this->load->_model("Model_zzququeu9_logs","zzququeu9_logs");
+        $this->load->_model('Model_logic_tools','logic_tools');
+        $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
+    }
+    public function getToken($type){
+        $name = "get_yytoken_".$type;
+        $token = $this->settingtest->$name();
+        return $token;
+    }
+    public function doAction(){
+        $list = $this->zzquque_u9->find_all("type = 21 and bzsh_status= 0 and dc_status = 0 and dr_status = 0");
+        foreach ($list as $key => $value) {
+            $this->dpCprk($value);
+        }
+        sleep(3);
+        $list = $this->zzquque_u9->find_all("type = 21 and bzsh_status= 1 and dc_status = 0 and dr_status = 0");
+        foreach ($list as $key => $value) {
+            $this->checkCprk($value);
+        }
+        $list =  $this->zzquque_u9->find_all("type = 21 and bzsh_status= 3 and dc_status = 0 and dr_status = 0");
+        foreach ($list as $key => $value) {
+            $this->doDcd($value);
+        }
+        $list =  $this->zzquque_u9->find_all("type = 21 and bzsh_status= 3 and dc_status = 1 and dr_status = 0");
+        foreach ($list as $key => $value) {
+            $this->cxDrd($value);
+        }
+        $list =  $this->zzquque_u9->find_all("type = 21 and bzsh_status= 3 and dc_status = 3 and dr_status = 0");
+        foreach ($list as $key => $value) {
+            $this->checkDrd($value);
+        }
+    }
+    public function dpCprk($data){
+        $token = $this->getToken(120);
+        if(empty($data['child_order_no'])){
+            $this->editData($data['id'],['bzsh_status'=>-1,'update_time'=>time()],$data['order_no'],20,1,'scrk_cj',$data,[
+                'code'=>-1,
+                'msg'=>'没有找到子订单号'
+            ]);
+            return $this->logic_tools->ret_arr(-1,"没有找到子订单号");
+        }
+
+        $info = $this->whlabel_bh_transfer->read($data['child_order_no']);
+        $sc = explode('~',$info['scid']);
+        $info['rkid'] = $sc[0];//配货的生产id
+        $info['rkcode'] = $sc[1];//配货的生产单号
+        $params = [
+            'org_code'=>'120',
+            "org_wh_code"=>'02',
+            'rec_code'=>'120',
+            'rev_wh_code'=>'02',
+            'rkid'=>$info['rkid'],
+            'rkcode'=>$info['rkcode'],
+            'number'=>$info['number'],
+            'shipremarks'=>$info['shipremarks'],
+            'list'=>[
+                [
+                    'sl'=>1,
+                    'jm'=>$info['jm'],
+                ]
+               
+            ]
+        ];
+        $res = $this->apiyyv1->cprkCreate($params,$token);
+        if(isset($res[0]['Data'][0]['m_isSucess'])&& $res[0]['Data'][0]['m_isSucess'] == 1){
+            $this->editData($data['id'],['bzsh_no'=>$res[0]['Data'][0]['m_code'],'bzsh_status'=>1,'update_time'=>time()],$info['number'],20,1,'scrk_cj',$res[1],$res[0]);
+            return $this->logic_tools->ret_arr(1,"成品入库单创建成功");
+        }else{
+            $this->editData($data['id'],['bzsh_status'=>-1,'update_time'=>time()],$info['number'],20,1,'scrk_cj',$res[1],$res[0]);
+            return $this->logic_tools->ret_arr(-1,"成品入库单创建失败");
+        }
+        
+
+
+    }
+    public function checkCprk($info){
+        $token = $this->getToken(120);
+        $params = [
+            [
+                "DocNo"=>$info['bzsh_no']
+            ]
+        ];
+        $res = $this->apiyyv1->cprkApprove($params,$token);
+      
+        //如果入库审核失败 先查询 如果不存在就标记 存在就再次审核
+        if(!(isset($res[0]['Data'][0]['m_isSucess']) && $res[0]['Data'][0]['m_isSucess'] == 1)){
+            //查询单子是否存在
+            sleep(1);
+            $res = $this->apiyyv1->cprkCx($params,$token);
+            if(!(isset($res[0]['Data'][0]['m_isSucess']) && $res[0]['Data'][0]['m_isSucess'] == 1)){
+                //查询失败  这里不做状态变更  只是做记录
+                $this->editData($info['id'],['update_time'=>time()],$info['order_no'],20,2,'scrk_ck',$res[1],$res[0]);
+                return $this->logic_tools->ret_arr(-1,"成品入库单还未审核,请稍后审核");
+            }
+            $res = $this->apiyyv1->cprkApprove($params,$token);
+        }
+        //如果再错误就 没办法了
+        if(isset($res[0]['Data'][0]['m_isSucess']) && $res[0]['Data'][0]['m_isSucess'] == 1){
+            $this->editData($info['id'],['bzsh_status'=>3,'update_time'=>time()],$info['order_no'],20,3,'scrk_sh',$res[1],$res[0]);
+            return $this->logic_tools->ret_arr(-1,"成品入库单还未审核,请联系到u9核对成品入库单的状态");
+        }
+
+    }
+    public function doDcd($data){
+
+        $info = $this->whlabel_bh_transfer->read($data['child_order_no']);
+        $time = time();
+        $list = [
+            [
+                'jm'=>$info['jm'],
+                'bm'=>$info['bm'],
+                'zh'=>$info['pm'],
+                'final_price'=>1,//目前先不设置 等后期财务说了再说
+                'title'=>$info['title'],
+                'dcsl'=>1,
+                'is_register'=>0,//商品是否被注册  先都当没注册  后面会先确认下
+            ]
+           
+        ];
+        $sc = explode('~',$info['scid']);
+        $info['rkid'] = $sc[0];//配货的生产id
+        $info['rkcode'] = $sc[1];//配货的生产单号
+        $dcck = $sc[2];
+        $dc_params = [
+            'gys'=>'98001',//供应商  龙盈
+            'number'=>$info['orderinfo'],//erp订单编码
+            "TransOutDocType_Code"=>"TransOut001",//组织间调拨
+            "time"=>$time,
+            'TransferDirection'=>0,//普通
+            'yyid'=>'98001',//备货都是卖给了龙熠
+            'shipremarks'=>$info['shipremarks'],//订单的备注
+            'dcckbm'=>$dcck,//调出仓库编码     完成库
+            'drckbm'=>"13001",//调入仓库编码     成品库
+            'drzz_code'=>"130",//调入组织Code   
+            'owner_code'=>"120",//货主组织Code
+            //'ztcode'=>$this->ztcode,//账套
+            //'tb_org_arr'=>$this->tb_org_arr,//要同步的组织列表
+            'list'=>$list
+       ];
+       //创建调出单
+       $dcd_res = $this->apiyyv1->dcdCrate($dc_params,$this->getToken(120));
+       if(empty($dcd_res[0]['Data'][0]["Code"])){
+              $this->editData($data['id'],['dc_status'=>-1,'update_time'=>time()],$info['orderinfo'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
+              return ;
+       }
+       //更新
+       $dcd_no =  $dcd_res[0]['Data'][0]["Code"];
+       $this->editData($data['id'],['dc_no'=>$dcd_no,'dc_status'=>1,'update_time'=>time()],$info['orderinfo'],1,1,'dc',$dcd_res[1],$dcd_res[0]);
+    }
+   
+    public function cxDrd($info){
+        $r = $this->apiyyv1->xdlsCxDcd($info['dc_no'],$this->getToken(130));
+        if(empty($r[0]['Data'])){
+            return ;
+        }
+        //更新销售单数据
+        //$xs_no = json_encode($r[0]['Data']);
+        $this->editData($info['id'],['dc_status'=>3,'update_time'=>time()],$info['order_no'],8,1,'dc_xc',$r[1],$r[0]);
+    }
+    
+    public function checkDrd($info){
+        $r = $this->apiyyv1->drdcxBydcd($info['dc_no'],$this->getToken(130));
+        
+        //如果获取对应调入单没有成功 
+        if(empty($r[0]['Data'][0]['docno'])){
+            $this->editData($info['id'],['dr_status'=>-1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
+            return ;
+        }
+        $dr_no = $r[0]['Data'][0]["docno"];
+       
+        $this->editData($info['id'],['dr_no'=>$dr_no,'dr_status'=>1,'update_time'=>time()],$info['order_no'],6,1,'dr',$r[1],$r[0]);
+        
+        //提交调入单 
+        $rr = $this->apiyyv1->drdSubmit(['number'=>$dr_no],$this->getToken(130));
+        if(!$rr[0]['Data'][0]['IsSucess']){
+            $this->editData($info['id'],['dr_status'=>-2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
+            return;
+        }
+        $this->editData($info['id'],['dr_status'=>2,'update_time'=>time()],$info['order_no'],6,2,'dr',$rr[1],$rr[0]);
+
+        //审核调入单
+        $rrr = $this->apiyyv1->drdApprove(['number'=>$dr_no],$this->getToken(130));
+        if(!$rrr[0]['Data'][0]['IsSucess']){
+            $this->editData($info['id'],['dr_status'=>-3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
+            return;
+        }
+        $this->editData($info['id'],['dr_status'=>3,'update_time'=>time()],$info['order_no'],6,3,'dr',$rrr[1],$rrr[0]);
+    }
+
+
+
+
+    protected function editData($zq_u9_id,$z_qu_arr,$number,$one_type,$two_type,$apply_api,$apply_data,$ret_data){
+        $this->zzquque_u9->save($z_qu_arr,$zq_u9_id);
+        $this->zzququeu9_logs->insert([
+            'oid'=>$zq_u9_id,
+            'number'=>$number,
+            'one_type'=>$one_type,
+            'two_type'=>$two_type,
+            'apply_api'=>$apply_api,
+            'apply_data'=>json_encode($apply_data,JSON_UNESCAPED_UNICODE),
+            'ret_data'=>json_encode($ret_data,JSON_UNESCAPED_UNICODE),
+            'create_time'=>time(),
+            'read_time'=>date("Y-m-d H:i:s")
+        ]);
+    }
+}

+ 11 - 0
core/CoreApp/models/Model_whlabel_bh_transfer_cr.php

@@ -0,0 +1,11 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
+class Model_whlabel_bh_transfer_cr extends Lin_Model 
+{
+	function __construct(){
+		parent::__construct();
+		$this->load->database();
+		$this->table = 'whlabel_bh_transfer_cr';
+		$this->load_table('whlabel_bh_transfer_cr');
+	}
+    
+}  //end class

+ 2 - 1
core/CoreApp/models/Model_zzquque_u9.php

@@ -15,7 +15,8 @@ class Model_zzquque_u9 extends Lin_Model
 			2=>"备货流转-美仓",//实际就是在途库存的完成过程 需要在香港组织留痕
 			10=>"小单临时",//实际就是小单从许昌仓发出后 需要在香港组织留痕
 			11=>"小单美仓",//实际就是香港仓出货了
-			20=>"工厂外销单"
+			20=>"工厂外销单",
+			21=>"工厂备货单",
 		];
 	}
 }  

+ 1 - 1
template/erp/js/print.js

@@ -1699,7 +1699,7 @@ if ($("select[name='printer']").children("option:selected").val() == "") {
 			$(".systemwindow").hide();
 			layx.destroy('loadId');
             if (a && a.success) {
-                wprinter.bhbubiao(a['rows']);
+                wprinter.newbhbubiao(a['rows']);
 				 $(".express p:eq(0)").html('打印完成');
 				$(".express p:eq(1)").html("<font class='printfh' data-id='"+a.id+"'>确 定</font>");
                 $(".express").show();

+ 1 - 1
template/erp/whlabel_bh.html

@@ -205,5 +205,5 @@ if(typeof $("select[name='printer']").length < 1) return;
 setTimeout(function(){ wprinter.printer()},1000);};
 </script>
 <script type="text/javascript" src="{$theme}js/laydate.js"></script>
-<script type="text/javascript" src="{$theme}js/print.js?v=202403050002"></script>
+<script type="text/javascript" src="{$theme}js/print.js?v={time()}"></script>
 {Template footer}

+ 1 - 1
template/erp/whlabel_bh_add.html

@@ -487,7 +487,7 @@
 </li>
 
 <li>
-<em>生产/外购:</em>
+<em>生产/外购数量:</em>
 <input class="must" value="" name="num" type="text">
 </li>
 

+ 144 - 0
template/erp/whlabel_bh_ck.html

@@ -0,0 +1,144 @@
+{Template header}
+<body>
+<div class="warp">
+<div class="fixed">
+<div class="numberprint">
+<ul class="searchtop search" style="text-align: center;padding: 10px 0;margin-top:80px;">
+<li>
+<select name="transfer" class="select"  style="height: 56px;font-size: 20px;text-align: center;">
+{if $vip == 1}
+<option value="">查看所有</option>
+{/if}
+{loop $transfer as $val}
+<option value="{$val['id']}">{$val['title']}</option>
+{/loop}
+</select>
+</li>
+<li style="display: none;"><select name="cz" class="select" style="font-size: 18px;">
+<option value="2">出库</option>
+</select></li>
+<li style="height: 56px;line-height: 56px;padding: 0 88px;font-size: 26px;color: #fff;background-color: #2ca8a1;margin-right: 50px;border-radius: 5px; display: inline-block;;cursor: pointer;">请扫码出库</li>
+<li style="height: 56px;line-height: 56px;"><input value="" name="transferout" id="transferout" placeholder="点此处扫码" type="text" style="width:500px;height: 50px;line-height: 50px;"></li>
+<li style="display: none;">扫描时间:<input id="timetk"  value="{date('Y-m-d',time()-1*24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="timetj" value="{date('Y-m-d',time()+24*3600)} 0:00" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})"></li>
+<li style="display: none;"><span>确 定</span></li>
+</ul>
+</div>
+<table class="datatitle data" border="0" style="border-collapse:collapse;">
+<tr>
+<td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
+<td>编号</td>
+<td>品名</td>
+<td>备注</td>
+<td>数量</td>
+<td>打印时间</td>
+<td>操作时间</td>
+</tr>
+</table>
+</div>
+<table class="datatext data" border="0" style="border-collapse:collapse;">
+</table>
+<div class="bomf"></div>
+</div>
+<div class="print none"></div>
+<div class="ts"><p class="tsn"></p></div>
+<div class="systemwindow">
+<div>
+<p></p>
+<p><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
+<div class="boundtj">
+<div>
+<p></p>
+<p><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
+<div class="tyrows"><div><p></p><p></p></div></div>
+<audio id="music_d">
+<source src="{$theme}music/d.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_c">
+<source src="{$theme}music/c.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print">
+<source src="{$theme}music/print.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_error">
+<source src="{$theme}music/print_error.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_ok">
+<source src="{$theme}music/print_ok.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_jiaji">
+    <source src="{$theme}music/jiaji.mp3" type="audio/mpeg">
+</audio>
+<script>
+var sysprint = 1;var transfer = 1;
+var dataurl = "/whlabel_bh/ck/";var fdataurl = "/whlabel_bh/ck/";
+
+$(document).ready(function() {
+$("#transferout").focus();
+});
+
+$("select[name='transfer']").on("change", function() {
+    $(".search span").click();
+});
+$(".xz").click(function() {
+	 var f = "";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+  window.location.href = "/transfer/excel/?fexcel=1&"+f;
+});
+$(document).keyup(function(event) {
+    if (event.keyCode == 13) {
+		if (typeof transfer != "undefined") {
+			var f = "";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+            $(".search .number").val("");
+            $(".search .waybill").val("");
+            $.ajax({
+                url: "/whlabel_bh/out",
+                data: "label=" + $("input[name='transferout']").val() + "&"+f,
+                type: "POST",
+                dataType: "json",
+                success: function(b) {
+                    $(".systemwindow").hide();
+                    if (b && b.success) {
+                        $("#music_d")[0].play();
+                    
+                        $("#transferout").val("");
+                        $("#transferout").focus();
+                        $(".search span").click();
+                    } else {
+                        $("#wigsout").blur();
+                        $("#music_c")[0].play();
+                        $(".express div p:eq(0)").html(b.msg);
+                        $(".express div p:eq(1)").html("<font class='esc'>确 定</font>");
+                        $(".express").show();
+                        $("#transferout").val("");
+						$("#transferout").focus();
+                    }
+                }
+            });
+        }
+	}
+})
+</script>
+<script type="text/javascript" src="{$theme}js/laydate.js"></script>
+{Template footer}

+ 1 - 1
template/erp/whlabel_bh_edit.html

@@ -492,7 +492,7 @@
 </li>
 
 <li>
-<em>生产/外购:</em>
+<em>生产/外购数量:</em>
 <input class="must" value="{$whlabel_bh['num']}" name="num" type="text">
 </li>
 

+ 5 - 7
template/erp/whlabel_bh_operate.html

@@ -3,13 +3,11 @@
 <div class="warp">
 <div class="fixed">
 <div class="numberprint">
-<ul class="searchtop" style="text-align: center;padding: 10px 0;">
-<li><select name="cz" class="select" style="font-size: 18px;">
-<option value="1">入库</option>
-<!--<option value="2">出库</option> -->
-</select></li>
-<li><input value="" name="transferout" id="transferout" placeholder="点此处扫码" type="text"></li>
-</ul>
+<ul class="searchtop" style="text-align: center;padding: 10px 0;" style="font-size: 18px;">
+    <ul class="searchtop" style="text-align: center;padding: 10px 0;">
+        <li><a href="/whlabel_bh/rk/" style="height: 56px;line-height: 56px;padding: 0 88px;font-size: 26px;color: #fff;background-color: #2084db;float: left;margin-right: 50px;border-radius: 5px;display: block;cursor: pointer;">入库</a></li>
+        <li><a href="/whlabel_bh/ck/"  style="height: 56px;line-height: 56px;padding: 0 88px;font-size: 26px;color: #fff;background-color: #2ca8a1;float: left;margin-left: 50px;border-radius: 5px;display: block;cursor: pointer;">出库</a></li>
+        </ul>
 </div>
 <ul class="search">
 <li>

+ 149 - 0
template/erp/whlabel_bh_rk.html

@@ -0,0 +1,149 @@
+{Template header}
+<body>
+<div class="warp">
+<div class="fixed">
+<div class="numberprint">
+<ul class="searchtop search" style="text-align: center;padding: 10px 0;margin-top:80px;">
+<li>
+<select name="transfer" class="select"  style="height: 56px;font-size: 20px;text-align: center;">
+{if $vip == 1}
+<option value="">查看所有</option>
+{/if}
+{loop $transfer as $val}
+<option value="{$val['id']}">{$val['title']}</option>
+{/loop}
+</select>
+</li>
+<li style="display: none;"><select name="cz" class="select" style="font-size: 18px;">
+<option value="1">入库</option>
+</select></li>
+<li style="height: 56px;line-height: 56px;padding: 0 88px;font-size: 26px;color: #fff;background-color: #2084db;margin-right: 50px;border-radius: 5px; display: inline-block;;cursor: pointer;">请扫码入库</li>
+<li style="height: 56px;line-height: 56px;"><input value="" name="transferout" id="transferout" placeholder="点此处扫码" type="text" style="width:500px;height: 50px;line-height: 50px;"></li>
+<li style="display: none;">扫描时间:<input id="timetk"  value="{date('Y-m-d',time()-1*24*3600)} 0:00" name="timetk" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})">
+至&nbsp;&nbsp;&nbsp;&nbsp; <input id="timetj" value="{date('Y-m-d',time()+24*3600)} 0:00" name="timetj" type="text" onClick="laydate({istime: true,format:'YYYY-MM-DD hh:mm'})"></li>
+<li style="display: none;"><span>确 定</span></li>
+</ul>
+</div>
+<table class="datatitle data" border="0" style="border-collapse:collapse;">
+<tr>
+<td><label onClick="swapCheck()"><input name="checkbox" type="checkbox" class="regular-checkbox"></label></td>
+<td>编号</td>
+<td>品名</td>
+<td>备注</td>
+<td>数量</td>
+<td>打印时间</td>
+<td>操作时间</td>
+</tr>
+</table>
+</div>
+<table class="datatext data" border="0" style="border-collapse:collapse;">
+</table>
+<div class="bomf"></div>
+</div>
+<div class="print none"></div>
+<div class="ts"><p class="tsn"></p></div>
+<div class="systemwindow">
+<div>
+<p></p>
+<p><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
+<div class="boundtj">
+<div>
+<p></p>
+<p><font class="button">确 定</font><font class="esc">取 消</font></p>
+</div>
+</div>
+<div class="tyrows"><div><p></p><p></p></div></div>
+<audio id="music_d">
+<source src="{$theme}music/d.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_c">
+<source src="{$theme}music/c.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print">
+<source src="{$theme}music/print.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_error">
+<source src="{$theme}music/print_error.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_print_ok">
+<source src="{$theme}music/print_ok.mp3" type="audio/mpeg">
+</audio>
+<audio id="music_jiaji">
+    <source src="{$theme}music/jiaji.mp3" type="audio/mpeg">
+</audio>
+<script>
+var sysprint = 1;var transfer = 1;
+var dataurl = "/whlabel_bh/rk/";var fdataurl = "/whlabel_bh/rk/";
+
+
+$(document).ready(function() {
+$("#transferout").focus();
+});
+
+$("select[name='transfer']").on("change", function() {
+    
+    $(".search span").click();
+});
+
+
+$(".xz").click(function() {
+	 var f = "";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+  window.location.href = "/transfer/excel/?fexcel=1&"+f;
+});
+$(document).keyup(function(event) {
+    if (event.keyCode == 13) {
+		if (typeof transfer != "undefined") {
+			var f = "";
+    $(".select").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).children("option:selected").val() + "&";
+    });
+    $("input:text").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+	$("input:hidden").each(function() {
+        f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+    });
+            $(".search .number").val("");
+            $(".search .waybill").val("");
+            $.ajax({
+                url: "/whlabel_bh/out",
+                data: "label=" + $("input[name='transferout']").val() + "&"+f,
+                type: "POST",
+                dataType: "json",
+                success: function(b) {
+                    $(".systemwindow").hide();
+                    if (b && b.success) {
+                        $("#music_d")[0].play();
+                    
+                        $("#transferout").val("");
+                        $("#transferout").focus();
+                        $(".search span").click();
+                    } else {
+                        $("#wigsout").blur();
+                        $("#music_c")[0].play();
+                        $(".express div p:eq(0)").html(b.msg);
+                        $(".express div p:eq(1)").html("<font class='esc'>确 定</font>");
+                        $(".express").show();
+                        $("#transferout").val("");
+						$("#transferout").focus();
+                    }
+                }
+            });
+        }
+	}
+})
+
+</script>
+<script type="text/javascript" src="{$theme}js/laydate.js"></script>
+{Template footer}