|
@@ -6,12 +6,17 @@ use App\Model\Orders;
|
|
|
use App\Model\SaleOrdersProduct;
|
|
|
use Illuminate\Support\Facades\Config;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
class FyySqlServerService extends Service
|
|
|
{
|
|
|
public $db = null;
|
|
|
public $error = null;
|
|
|
+ public $host = "";
|
|
|
+ public $port = 0;
|
|
|
+ public $database = "";
|
|
|
+ public $url = "";
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
@@ -22,6 +27,11 @@ class FyySqlServerService extends Service
|
|
|
}
|
|
|
$fyy_array = json_decode($fyy_array,true);
|
|
|
|
|
|
+ $this->host = $fyy_array['sqlserver_host'] ?? '';
|
|
|
+ $this->port = $fyy_array['sqlserver_port'] ?? 0;
|
|
|
+ $this->database = $fyy_array['sqlserver_database'] ?? '';
|
|
|
+ $this->url = empty($this->host)?: "http://" . $this->host . ":12365/U8Sys/U8API";
|
|
|
+
|
|
|
if(! $this->db){
|
|
|
$config = [
|
|
|
'driver' => 'sqlsrv',
|
|
@@ -271,4 +281,104 @@ class FyySqlServerService extends Service
|
|
|
|
|
|
return [true,$message,$product];
|
|
|
}
|
|
|
+
|
|
|
+ //产成品入库单保存接口以及审核
|
|
|
+ public function U8Rdrecord10Save($data){
|
|
|
+ if(! empty($this->error)) return [false,$this->error];
|
|
|
+ date_default_timezone_set("PRC");
|
|
|
+
|
|
|
+ list($bool,$msg) = $this->createOrderNumberAboutSCRK();
|
|
|
+ if(! $bool) return [false,$msg];
|
|
|
+
|
|
|
+ //数据
|
|
|
+ $bodys = [];
|
|
|
+ foreach ($data as $value){
|
|
|
+ $bodys[] = [
|
|
|
+ "cinvcode" => $value["product_no"],
|
|
|
+ "cposition" => "",
|
|
|
+ "cbatch" => "",
|
|
|
+ "iquantity" => $value["quantity"],
|
|
|
+ "inum" => $value["quantity"],
|
|
|
+ "iunitcost" => "0",
|
|
|
+ "iprice" => "0",
|
|
|
+ "iinvexchrate" => "1.00",
|
|
|
+ "impoids" => "",
|
|
|
+ "cmocode" => "",
|
|
|
+ "imoseq" => "",
|
|
|
+ "cbmemo" => "",
|
|
|
+ "cfree1" => "",
|
|
|
+ "cfree2" => ""
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ $post = [
|
|
|
+ "password"=>"cloud@123456",
|
|
|
+ "entity"=>"U8Rdrecord10Save",
|
|
|
+ "login"=>[
|
|
|
+ "sAccID"=> "(default)@001",
|
|
|
+ "sDate"=> date("Y-m-d"),
|
|
|
+ "sServer"=> '127.0.0.1',
|
|
|
+ "sUserID"=> "董晓磊",
|
|
|
+ "sSerial"=> "",
|
|
|
+ "sPassword"=> ""
|
|
|
+ ],
|
|
|
+ "data"=>[
|
|
|
+ "ccode"=>$msg,
|
|
|
+ "ddate"=>date("Y-m-d"),
|
|
|
+ "cmaker"=>"董晓磊",
|
|
|
+ "dnmaketime"=> date("Y-m-d"),
|
|
|
+ "IsExamine"=>true,
|
|
|
+ "bredvouch"=>"0",
|
|
|
+ "cwhcode"=>"02",
|
|
|
+ "cdepcode"=>"",
|
|
|
+ "crdcode"=>"",
|
|
|
+ "cmemo"=>"",
|
|
|
+ "bodys"=>$bodys
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+
|
|
|
+ $return = $this->post_helper($this->url,json_encode($post), ['Content-Type:application/json']);
|
|
|
+ return [$return['flag'], $return['msg']];
|
|
|
+ }
|
|
|
+
|
|
|
+ //产成品入库单单据号
|
|
|
+ public function createOrderNumberAboutSCRK(){
|
|
|
+ date_default_timezone_set("PRC");
|
|
|
+
|
|
|
+ $current_month = date('m'); // 获取当前月份
|
|
|
+ $date1 = date('y') . $current_month ; // 格式 "2307"
|
|
|
+ $date2 = date('Y') . $current_month; // 格式 "202307"
|
|
|
+
|
|
|
+ $record = $this->db->table('VoucherHistory')
|
|
|
+ ->where('CardNumber','0411')
|
|
|
+ ->whereRaw("(cSeed = '{$date1}' or cSeed = '{$date2}')")
|
|
|
+ ->select('cNumber')
|
|
|
+ ->first();
|
|
|
+ $record = (array)$record;
|
|
|
+ if(empty($record)) return [false,'未找到产成品入库当月流水号信息!'];
|
|
|
+
|
|
|
+ $tmp = $record['cNumber'] + 1;
|
|
|
+ if(strlen($tmp) > 4) return [false,'产成品入库当月流水号超过四位数!'];
|
|
|
+
|
|
|
+ $number = str_pad($tmp,4,'0',STR_PAD_LEFT);
|
|
|
+ $number = $tmp . $number;
|
|
|
+ $ccode = "SCRK" . $date2 . $number;
|
|
|
+
|
|
|
+ return [true,$ccode];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function post_helper($url, $data,$header = [],$timeout = 60){
|
|
|
+ $ch = curl_init();
|
|
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
+ curl_setopt($ch, CURLOPT_ENCODING, '');
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
|
+ if(!is_null($data)) curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
+ $r = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ return json_decode($r, true);
|
|
|
+ }
|
|
|
}
|