提交 fd8b98d2 authored 作者: fengzy's avatar fengzy

test

上级 87a80e07
<?php
namespace Home\Controller;
use Think\Controller;
class FkController extends Controller {
public function index(){
$sql = " select * from T_AP_PAYBILL WHERE FCREATEDATE > '2020-05-01' ";
$voList = $Model->query($sql);
var_dump($voList);die;
}
public function custmoer_submit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'SelectedPostId': 0
}";
$data = array(
'BD_Customer',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_submit($cloudUrl,$post_content,$cookie_jar);
$array = json_decode($result,true);
$end_time = microtime(true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='客户编号:'.$number.'提交接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='客户编号:'.$number.'提交接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
// $log='客户编号:'.$number.'提交接口失败 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}
$file_write = file_put_contents('test.txt',$log,FILE_APPEND);
}
public function custmoer_audit($cloudUrl,$cookie_jar,$id,$number){
$start_time = microtime(true);
$data_model ="{
'CreateOrgId': 0,
'Numbers': [],
'Ids': $id,
'InterationFlags': ''
}";
$data = array(
'BD_Customer',//业务对象标识FormId
$data_model//具体Json字串
);
$post_content = self::create_postdata($data);
$result = self::invoke_audit($cloudUrl,$post_content,$cookie_jar);
$end_time = microtime(true);
$array = json_decode($result,true);
if($array['Result']['ResponseStatus']['IsSuccess']){
$log='客户编号:'.$number.'审核接口成功 '.' 执行时间:'.($end_time-$start_time).' s'."\r\n";
}else{
$log='客户编号:'.$number.'审核接口失败 '.$array['Result']['ResponseStatus']['Errors'][0]['Message'];
// $log='客户编号:'.$number.'审核接口失败 '.' 错误信息:'.($end_time-$start_time).' s'."\r\n";
}
$file_write = file_put_contents('test.txt',$log,FILE_APPEND);
}
//登陆
static function invoke_login($cloudUrl,$post_content,$cookie_jar)
{
$loginurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
return self::invoke_post($loginurl,$post_content,$cookie_jar,TRUE);
}
//查询
static function invoke_save($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.View.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//添加
static function invoke_add($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//提交
static function invoke_submit($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
//审核
static function invoke_audit($cloudUrl,$post_content,$cookie_jar)
{
$invokeurl = $cloudUrl.'Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit.common.kdsvc';
return self::invoke_post($invokeurl,$post_content,$cookie_jar,FALSE);
}
static function invoke_post($url,$post_content,$cookie_jar,$isLogin)
{
$ch = curl_init($url);
$this_header = array(
'Content-Type: application/json',
'Content-Length: '.strlen($post_content)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_content);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if($isLogin){
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
}
else{
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
//构造Web API请求格式
static function create_postdata($args) {
$postdata = array(
'format'=>1,
'useragent'=>'ApiClient',
'rid'=>self::create_guid(),
'parameters'=>$args,
'timestamp'=>date('Y-m-d'),
'v'=>'1.0'
);
return json_encode($postdata);
}
//生成guid
static function create_guid() {
$charid = strtoupper(md5(uniqid(mt_rand(), true)));
$hyphen = chr(45);// "-"
$uuid = chr(123)// "{"
.substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12)
.chr(125);// "}"
return $uuid;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论