TIPTOP对接通达OA工作流解析

思路:

      1、从OA中读取流程基本资料到TIPTOP(XML),在TIPTOP中开发程序维护表单字段对应关系。

      2、tiptop中依基本资料从表中取出数据打包成XML格式传送到OA处理。

      3、OA处理完流程后调用TIPTOP接口回写状态

详细请看代码

1、OA接口段

<?php
// Descriptions...: 通达工作流webservice接口
// Date & Author..: 2016/07 By 老万 
// QQ:460048964
// 声明:抛砖引玉  只可用于研究,不可用于商业用途!
include_once("inc/conn.php");
include_once 'inc/utility_flow.php';
include_once 'inc/utility_sms1.php';
include_once 'inc/workflow/inc/workflow.inc.php';

Class Workflow { 

  /**  
  * 传送表单资料到通达工作流并发起工作流
  * @param string $num1  
  * @return string  
  */     
   public function Sendingfromdata($str1){ 
       $dom = new DOMDocument();
       $dom->loadXML($str1);
       $xml = new DOMDocument();
   	   $xml->formatOutput = true;
   	   $response = $xml -> createElement('Response');//新建节点
   	   $status = $xml -> createElement('Status');
   	   //$code = $xml -> createAttribute('code');//新建属性
       //$code_value = $xml -> createTextNode('0');//新建TEXT值
       //$code -> appendChild($code_value);//将$code_value文本设为$code属性的值
       
       $sqlcode = $xml -> createAttribute('sqlcode');//新建属性
       $sqlcode_value = $xml -> createTextNode('0');//新建TEXT值
       $sqlcode -> appendChild($sqlcode_value);//将$code_value文本设为$code属性的值
       
       $description = $xml -> createAttribute('description');//新建属性
       $description_value = $xml -> createTextNode('OK');//新建TEXT值
       $description -> appendChild($description_value);//将$code_value文本设为$code属性的值
       
       //$status -> appendChild($code);//设置$code为$execution字节点
       $status -> appendChild($sqlcode);//设置$sqlcode为$execution字节点
       $status -> appendChild($description);//设置$description为$execution字节点
       $response -> appendChild($status);//设置$description为$execution字节点
       $xml -> appendChild($response);//设置根节点
       
       //处理flow_run,读Head节点
       $Root=$dom->getElementsByTagName('Head');
       db_query('START TRANSACTION',TD::conn()) or exit(mysql_error()); //开启事物处理
       foreach ($Root AS $item)
         {
         $Flow_id = $item->getAttribute('Flow_id');  //流程ID
         $Flow_name = $item->getAttribute('Flow_name'); //流程名称
         //$Promoter = $item->getAttribute('Promoter'); //流程发起人
         $Promoter = '75';
         //$Gem01 = $item->getAttribute('Gem01'); //流程发起人
         $Gem01 = '1';
         $Stime = $item->getAttribute('Stime');  //发起时间
         $Etime = $item->getAttribute('Etime');  //接收时间
         $Stime = date("Y-m-d").' '.date("H:i:s");
         $Etime = date("Y-m-d").' '.date("H:i:s");
         //$aa = iconv("utf-8",MYOA_CHARSET,'->TIPTOP');
         $Wenhao = "{$Flow_name}({$Stime})->TIPTOP";
         $Nuser = $item->getAttribute('Nuser');  //下一步接收人
         $rid=mysql_fetch_array(db_query("select max(run_id) from `flow_run` ",TD::conn( )));
         $run_id=$rid[0]+1;//run_id
         //return $Wenhao;
         $l_sql = "INSERT INTO flow_run VALUES (null,'{$run_id}', '{$Wenhao}', '{$Flow_id}', '{$Promoter}','{$Gem01}', '{$Stime}', null,
                   '', '', '0', '', '0', '', '', '', '', '0', '', '0','0000-00-00 00:00:00')";
         $l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql);
         //exequery(TD::conn(), $l_sql); 
         $result = @db_query($l_sql,TD::conn());
         if (!$result){
            echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
            //$status -> setAttribute('code','-1');
            $status -> setAttribute('sqlcode',mysql_errno());
            $status -> setAttribute('description',"insert flow_run error:".mysql_error());
            $str = $xml-> saveXML();//转换为字符串
            //截取XML档前面的头信息进行输出
            $e1 = strpos($str,'?>',0); //>出现的位置
            $e2 = $e1+strlen('?>');  //包含本身的位置
            $str1 = substr($str,$e2); // 取消utf-8
   	        db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	        return iconv(MYOA_CHARSET,"utf-8",$str1);
            exit;
         } else {
            print $l_sql."<br />";
         }       
         }
       //写入表单单头
       $Masters=$dom->getElementsByTagName('Master');
       foreach ($Masters AS $Master)
         {
         $Mname = $Master->getAttribute('Tname'); //单头表名
         $Fileds = $Master->getElementsByTagName('Filed');
         foreach ($Fileds AS $Filed) {
           $MCname = $Filed->getAttribute('Cname'); //字段名
	         $MValue = $Filed->getAttribute('Value'); //值
	         $MCname = str_replace('`',",",$MCname);
	       	 $MValue = str_replace('`',"','",$MValue);
	       	 
	         $l_sql = "INSERT INTO {$Mname} (id,run_id,run_name,begin_user,begin_time,flow_auto_num,flow_auto_num_year,flow_auto_num_month,
	                   $MCname) VALUES (null,'{$run_id}', '{$Wenhao}','{$Promoter}','{$Stime}','0','0','0','{$MValue}')";
	         $l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql); 
	         $result = @db_query($l_sql,TD::conn());
           if (!$result){
              echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
              $status -> setAttribute('sqlcode',mysql_errno());
              $status -> setAttribute('description',"insert {$Mname} error:".mysql_error());
              $str = $xml-> saveXML();//转换为字符串
              //截取XML档前面的头信息进行输出
              $e1 = strpos($str,'?>',0); //>出现的位置
              $e2 = $e1+strlen('?>');  //包含本身的位置
              $str1 = substr($str,$e2); // 取消utf-8
   	          
   	          db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	          return iconv(MYOA_CHARSET,"utf-8",$str1);
              exit;
           } else {
              print $l_sql."<br />";	
           }
         }
         }
       $mid=mysql_fetch_array(db_query("select max(id) from $Mname",TD::conn( )));
       $Tname_id=$mid[0];//表头id
       //写入表单单身  
       $Details=$dom->getElementsByTagName('Detail');
       foreach ($Details AS $Detail) {
         $Dname = $Detail->getAttribute('Tname'); //单身表名 
         $Fname = $Detail->getAttribute('Fname'); //对应单身字段 
         $Fileds = $Detail->getElementsByTagName('Filed');
         $l_cnt=1;
         foreach ($Fileds AS $Filed) {
           $DCname = $Filed->getAttribute('Cname'); //字段名
	         $DValue = $Filed->getAttribute('Value'); //值
	         if (!empty($Fname)) {
	         	if ($l_cnt == 1) {
	  		       $Uvalue = "{$DValue}`\r\n";
	  	       } else {
	  	       	$Uvalue = "{$Uvalue}{$DValue}`\r\n";
	  	       }
	         }
	         $DCname = str_replace('`',",",$DCname);
		       $DValue = str_replace('`',"','",$DValue);
	         $l_sql = "INSERT INTO {$Dname} (id,run_id,main_table,main_id,$DCname ) 
	                   VALUES (null,'$run_id','$Mname','$Tname_id','$DValue' )";
	         $l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql);
	         $result = @db_query($l_sql,TD::conn());
           if (!$result){
              echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
              $status -> setAttribute('sqlcode',mysql_errno());
              $status -> setAttribute('description',"insert {$Dname} error:".mysql_error());
              $str = $xml-> saveXML();//转换为字符串
              //截取XML档前面的头信息进行输出
              $e1 = strpos($str,'?>',0); //>出现的位置
              $e2 = $e1+strlen('?>');  //包含本身的位置
              $str1 = substr($str,$e2); // 取消utf-8
   	          db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	          return iconv(MYOA_CHARSET,"utf-8",$str1);
              exit;
           } else {
              print $l_sql."<br />";	
           }
	         $l_cnt = $l_cnt+1;
         }
  
         //更新单身栏位
         if (!empty($Fname)) {
         	$l_sql = "update $Mname set $Fname='$Uvalue' where run_id=$run_id and id=$Tname_id";
         	$l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql);
         	$result = @db_query($l_sql,TD::conn());
          if (!$result){
             echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
             $status -> setAttribute('sqlcode',mysql_errno());
             $status -> setAttribute('description',"update {$Mname} error:".mysql_error());
             $str = $xml-> saveXML();//转换为字符串
             //截取XML档前面的头信息进行输出
             $e1 = strpos($str,'?>',0); //>出现的位置
             $e2 = $e1+strlen('?>');  //包含本身的位置
             $str1 = substr($str,$e2); // 取消utf-8
   	         
   	         db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	         return iconv(MYOA_CHARSET,"utf-8",$str1);
             exit;
          } else {
             print $l_sql."<br />";	
          }
         }
  
       }
       //发起
       $l_sql="INSERT INTO flow_run_prcs VALUES (null, '$run_id', '1', '$Promoter', '$Stime', '$Etime', '3', '1', '1', '0', '0', '0', '',
               '', '', '', '0', '$Stime', '', '0000-00-00 00:00:00', '', '1', '0', '0', '0', '0', '0', '', '', '0', '0', '0')";
       $l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql);
       $result = @db_query($l_sql,TD::conn());
       if (!$result){
          echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
          $status -> setAttribute('sqlcode',mysql_errno());
          $status -> setAttribute('description',"insert flow_run_prcs error:".mysql_error());
          $str = $xml-> saveXML();//转换为字符串
          //截取XML档前面的头信息进行输出
          $e1 = strpos($str,'?>',0); //>出现的位置
          $e2 = $e1+strlen('?>');  //包含本身的位置
          $str1 = substr($str,$e2); // 取消utf-8
   	      
   	      db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	      return iconv(MYOA_CHARSET,"utf-8",$str1);
          exit;
       } else {
          print $l_sql."<br />";	
       }
       
       //下一步
       $l_sql="INSERT INTO flow_run_prcs VALUES (null, '$run_id', '2', '$Promoter', '0000-00-00 00:00:00', '0000-00-00 00:00:00', '1', '2',
               '1', '0', '1','0', '', '', '', ',', '0', '$Stime', '', '0000-00-00 00:00:00', '', '1', '1', '0', '0', '0', '0', '', '', '0', '0', '0')";
       $l_sql = iconv("utf-8",MYOA_CHARSET,$l_sql);
       
       $prcs_id = mysql_fetch_array(db_query("select max(id) from flow_run_prcs where run_id={$run_id} and prcs_id=2",TD::conn( )));
       $prcs_keyid = $prcs_id[0];//id
       $result = @db_query($l_sql,TD::conn());
       if (!$result){
          echo $l_sql.mysql_errno().":".mysql_error()."<br>"; 
          $status -> setAttribute('sqlcode',mysql_errno());
          $status -> setAttribute('description',"insert flow_run_prcs error:".mysql_error());
          $str = $xml-> saveXML();//转换为字符串
          //截取XML档前面的头信息进行输出
          $e1 = strpos($str,'?>',0); //>出现的位置
          $e2 = $e1+strlen('?>');  //包含本身的位置
          $str1 = substr($str,$e2); // 取消utf-8
          db_query('ROLLBACK',TD::conn()) or exit(mysql_error()); //判断当执行失败时回滚 
   	      return iconv(MYOA_CHARSET,"utf-8",$str1);
          exit;
       } else {
          print $l_sql."<br />";	
       }
       $str = $xml-> saveXML();//转换为字符串
       $e1 = strpos($str,'?>',0); //>出现的位置
       $e2 = $e1+strlen('?>');  //包含本身的位置
       $str1 = substr($str,$e2); // 取消utf-8
       db_query('COMMIT',TD::conn()) or exit(mysql_error());//提交事务
       //此处不能执行消息推送,会导致接口返回错误
       //$REMIND_URL =  "1:workflow/list/input_form/?RUN_ID={$run_id}&FLOW_ID={$Flow_id}&PRCS_ID=2&FLOW_PRCS=2&PRCS_KEY_ID={$prcs_keyid}";
       //$SMS_CONTENT = "您有新的工作需要办理,流水号:{$run_id},工作名称/文号:".iconv("utf-8",MYOA_CHARSET,$Wenhao);
       //@send_sms($Stime, $Promoter, $Promoter.',', '7', $SMS_CONTENT, $REMIND_URL);
   	   return iconv(MYOA_CHARSET,"utf-8",$str1);  
   } 
      
   public function Getformdata($str1){
   	   //取出流程资料
   	   if (!$str1) {
   	   	  $str1='1=1';
   	   }
   	   $query = "select * from flow_type where ".$str1;
   	   $cursor = exequery(TD::conn(), $query);
   	   $xml = new DOMDocument('1.0', 'utf-8');
   	   $xml->formatOutput = true;
   	   $response = $xml -> createElement('Response');//新建节点
   	   $execution = $xml -> createElement('Execution');//新建节点
   	   $data = $xml -> createElement('Document');//新建节点
   	   //$flist = $xml -> createElement('FLOWLIST');//新建节点
   	   $status = $xml -> createElement('Status');
   	   if (!mysql_num_rows($cursor)){
   	   	  $a1='-1';
   	   	  $a2='0';
   	   	  $a3='错误:无资料!';
   	   } else {
   	   	  $a1='0';
   	   	  $a2='0';
   	   	  $a3='';
   	   }
   	   $code = $xml -> createAttribute('code');//新建属性
       $code_value = $xml -> createTextNode($a1);//新建TEXT值
       $code -> appendChild($code_value);//将$code_value文本设为$code属性的值
       
       $sqlcode = $xml -> createAttribute('sqlcode');//新建属性
       $sqlcode_value = $xml -> createTextNode($a2);//新建TEXT值
       $sqlcode -> appendChild($sqlcode_value);//将$code_value文本设为$code属性的值
       
       $description = $xml -> createAttribute('description');//新建属性
       $description_value = $xml -> createTextNode($a3);//新建TEXT值
       $description -> appendChild($description_value);//将$code_value文本设为$code属性的值
       
   	   //循环取出资料
   	   $id=0;
   	   while($ROW = mysql_fetch_array($cursor)){  
   	   	  $id=$id+1;
   	   	  $RecordSet = $xml -> createElement('RecordSet');//新建节点(流程明细表)
   	   	  $id_n=$xml -> createAttribute('id');
          $cnt=$xml -> createTextNode($id);
          $id_n->appendChild($cnt);
          $RecordSet -> appendChild($id_n);
          
   	   	  $Master = $xml -> createElement('Master');//新建节点
   	   	          
          $flow_id=$xml -> createAttribute('FLOW_ID');
          $flow_id_value=$xml -> createTextNode($ROW['FLOW_ID']);
          $flow_id->appendChild($flow_id_value);         
          $Master -> appendChild($flow_id);
          $RecordSet -> appendChild($Master);
          
          $flow_name=$xml -> createAttribute('FLOW_NAME');
          $flow_name_value=$xml -> createTextNode($ROW['FLOW_NAME']);
          $flow_name->appendChild($flow_name_value);         
          $Master -> appendChild($flow_name);
          $RecordSet -> appendChild($Master);
          
          $table=$xml -> createAttribute('TABLE');
          $table_value=$xml -> createTextNode('flow_data_'.$ROW['FLOW_ID']);
          $table->appendChild($table_value);         
          $Master -> appendChild($table);
          $RecordSet -> appendChild($Master);
          
          $form_id=$xml -> createAttribute('FORM_ID');
          $form_id_value=$xml -> createTextNode($ROW['FORM_ID']);
          $form_id->appendChild($form_id_value);
          $Master -> appendChild($form_id);
          $RecordSet -> appendChild($Master);
          /*
          $flow_field=$xml -> createAttribute('FLOW_FIELD');
          $flow_field_value=$xml -> createTextNode('');
          $flow_field->appendChild($flow_field_value);         
          $Master -> appendChild($flow_field);
          $RecordSet -> appendChild($Master);
          */
          处理表结构与表单对应资料(表头) start
          $Record = $xml -> createElement('Record');//新建节点(表单表结构字段资料【单头】)
          $query1 = "select print_model from flow_form_type where form_id=".$ROW['FORM_ID'];
   	      $cursor1 = exequery(TD::conn(), $query1);
   	      if ($ROW1 = mysql_fetch_array($cursor1)) {
   	   		   $RELATION = $ROW1['print_model'];
   	      }
   	      //取表单中控件总数
   	      $input = substr_count($RELATION,'input name="');
   	      $img = substr_count($RELATION,'img name="');
   	      $textarea = substr_count($RELATION,'textarea name="');
   	      $select= substr_count($RELATION,'select name="');
   	      $button= substr_count($RELATION,'button name="');
   	      $fieldcount = $input + $img + $textarea;
   	      //取总个数,按个数取实际位置进行截取字符串
   	      $n=0;
   	      //$field=array();
   	      $filelen_a = strlen('input name="');
   	      $filelen_b = strlen('img name="');
   	      $filelen_c = strlen('textarea name="');
   	      $filelen_d = strlen('select name="');
   	      $filelen_e = strlen('button name="');
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $input ; $i++ ) {   	   	 
   	   		   $a = strpos($RELATION,'input name="',$b);
   	      	 $b = $a + $filelen_a;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 $n=$n+1;
   	      	 $d = strpos($RELATION,'" title="',$b) + strlen('" title="');
   	      	 $e = strpos($RELATION,'"',$d);
   	      	 $text1 = substr($RELATION,$d,$e-$d);
   	      	 $Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	 $tname=$xml -> createAttribute('tname');
             $tname_value=$xml -> createTextNode($text);
             $tname->appendChild($tname_value);         
             $Field -> appendChild($tname);
             $Record -> appendChild($Field);
             
             $fname=$xml -> createAttribute('fname');
             $fname_value=$xml -> createTextNode($text1);
             $fname->appendChild($fname_value);         
             $Field -> appendChild($fname);
             $Record -> appendChild($Field);
   	      }
   	      
   	      //img name需进行判断,有的不存在表结构,有的是明细表
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $img ; $i++ ) {
   	      	 $a = strpos($RELATION,'img name="',$b);
   	      	 $b = $a + $filelen_b;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 
   	      	 if(substr($text,0,4) == 'DATA')
   	         {
   	         	  //将单身排除出去
   	         	  $a1 = strpos($RELATION,'/>',$b); //找出<img标签对应结束标签的位置
   	         	  $Detail_text=substr($RELATION,$b,$a1-$b); //截取单身HTML的代码块
   	         	  if(strstr($Detail_text,"lv_field")) { //判断是否包含字符,确定是否为单身
   	         	  	continue; //退出
   	         	  } else {
   	         	      $n=$n+1;
   	      	        $d = strpos($RELATION,'" title="',$b) + strlen('" title="');
   	      	        $e = strpos($RELATION,'"',$d);
   	      	        $text1 = substr($RELATION,$d,$e-$d);
   	      	        $Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	        $tname=$xml -> createAttribute('tname');
                    $tname_value=$xml -> createTextNode($text);
                    $tname->appendChild($tname_value);         
                    $Field -> appendChild($tname);
                    $Record -> appendChild($Field);
             
                    $fname=$xml -> createAttribute('fname');
                    $fname_value=$xml -> createTextNode($text1);
                    $fname->appendChild($fname_value);         
                    $Field -> appendChild($fname);
                    $Record -> appendChild($Field);
                }    
   	      	 }
   	      }
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $textarea ; $i++ ) {
   	      	 $a = strpos($RELATION,'textarea name="',$b);
   	      	 $b = $a + $filelen_c;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 $n=$n+1;
   	      	 $d = strpos($RELATION,'" title="',$b) + strlen('" title="');
   	      	 $e = strpos($RELATION,'"',$d);
   	      	 $text1 = substr($RELATION,$d,$e-$d);
   	      	 $Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	 $tname=$xml -> createAttribute('tname');
             $tname_value=$xml -> createTextNode($text);
             $tname->appendChild($tname_value);         
             $Field -> appendChild($tname);
             $Record -> appendChild($Field);
             
             $fname=$xml -> createAttribute('fname');
             $fname_value=$xml -> createTextNode($text1);
             $fname->appendChild($fname_value);         
             $Field -> appendChild($fname);
             $Record -> appendChild($Field);
   	      }
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $select ; $i++ ) {
   	      	 $a = strpos($RELATION,'select name="',$b);
   	      	 $b = $a + $filelen_d;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 $n=$n+1;
   	      	 $d = strpos($RELATION,'" title="',$b) + strlen('" title="');
   	      	 $e = strpos($RELATION,'"',$d);
   	      	 $text1 = substr($RELATION,$d,$e-$d);
   	      	 $Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	 $tname=$xml -> createAttribute('tname');
             $tname_value=$xml -> createTextNode($text);
             $tname->appendChild($tname_value);         
             $Field -> appendChild($tname);
             $Record -> appendChild($Field);
             
             $fname=$xml -> createAttribute('fname');
             $fname_value=$xml -> createTextNode($text1);
             $fname->appendChild($fname_value);         
             $Field -> appendChild($fname);
             $Record -> appendChild($Field);
   	      }
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $button ; $i++ ) {
   	      	 $a = strpos($RELATION,'button name="',$b);
   	      	 $b = $a + $filelen_e;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 $n=$n+1;
   	      	 $d = strpos($RELATION,'" title="',$b) + strlen('" title="');
   	      	 $e = strpos($RELATION,'"',$d);
   	      	 $text1 = substr($RELATION,$d,$e-$d);
   	      	 $Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	 $tname=$xml -> createAttribute('tname');
             $tname_value=$xml -> createTextNode($text);
             $tname->appendChild($tname_value);         
             $Field -> appendChild($tname);
             $Record -> appendChild($Field);
             
             $fname=$xml -> createAttribute('fname');
             $fname_value=$xml -> createTextNode($text1);
             $fname->appendChild($fname_value);         
             $Field -> appendChild($fname);
             $Record -> appendChild($Field);
   	      }
   	      
   	      $Master -> appendChild($Record);
          //处理表结构与表单对应资料 end 
          
          处理表结构与表单对应资料(表身) start 
          
          //img name需进行判断,有的不存在表结构,有的是明细表
   	      $b = 0;
   	      for ( $i = 1 ; $i <= $img ; $i++ ) {
   	      	 $a = strpos($RELATION,'img name="',$b);
   	      	 $b = $a + $filelen_b;
   	      	 $d = strpos($RELATION,'"',$b);
   	      	 $text = substr($RELATION,$b,$d-$b);
   	      	 
   	      	 if(substr($text,0,4) == 'DATA') 
   	         {                
   	         	  $a1 = strpos($RELATION,'/>',$b); //找出<img标签对应结束标签的位置
   	         	  $Detail_text=substr($RELATION,$b,$a1-$b); //截取单身HTML的代码块
   	         	  if(strstr($Detail_text,"lv_field")) { //判断是否包含字符,确定是否为单身
   	         	  	//处理单身对应的资料
   	         	  	$Detail = $xml -> createElement('Detail');//新建节点(表单表结构字段资料【单身】)
   	         	  	$Record1 = $xml -> createElement('Record');//新建节点
   	         	  	//$Field = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	   	          
                  $flow_id=$xml -> createAttribute('FLOW_ID');
                  $flow_id_value=$xml -> createTextNode($ROW['FLOW_ID']);
                  $flow_id->appendChild($flow_id_value);         
                  $Detail -> appendChild($flow_id);
                  
                  $t1=strpos($Detail_text,'title="',0)+strlen('title="');
                  $t2=strpos($Detail_text,'"',$t1);
                  $t_name=substr($Detail_text,$t1,$t2-$t1);
                  $tablen=$xml -> createAttribute('TABLE_NAME');
                  $tablen_value=$xml -> createTextNode($t_name);
                  $tablen->appendChild($tablen_value);         
                  $Detail -> appendChild($tablen);
                  
                  $tn=substr($text,5); //取出控件名称后数值
                  //取出控件名称作为table名title="
                  $table=$xml -> createAttribute('TABLE');
                  $table_value=$xml -> createTextNode('flow_data_'.$ROW['FLOW_ID'].'_list_'.$tn);
                  $table->appendChild($table_value);         
                  $Detail -> appendChild($table);
                  
                  $flow_field=$xml -> createAttribute('FLOW_FIELD');
                  $flow_field_value=$xml -> createTextNode('');
                  $flow_field->appendChild($flow_field_value);         
                  $Detail -> appendChild($flow_field);
                  $RecordSet -> appendChild($Detail);
                  
                  //修改属性-Master节点FLOW_FIELD
#                  $Master1=$xml->getElementsByTagName("Master")->item(4);
                  $Detail -> setAttribute('FLOW_FIELD','DATA_'.$tn);
                  
                  //截取字符进行处理单身字段资料lv_title  lv_field
                  $d1 = strpos($Detail_text,'lv_field="',0); //lv_field出现的位置
                  $d2 = $d1+strlen('lv_field="');  //包含本身的位置
                  $d3 = strpos($Detail_text,'"',$d2);  //“出现的位置
                  $lv_field = substr($Detail_text,$d2,$d3-$d2); // lv_field的值
                  //$lv_field = substr($lv_field,0,strlen($lv_field)-1); //截取掉最后一个`
                  
                  $d1 = strpos($Detail_text,'lv_title="',0); //lv_field出现的位置
                  $d2 = $d1+strlen('lv_title="');  //包含本身的位置
                  $d3 = strpos($Detail_text,'"',$d2);  //“出现的位置
                  $lv_title = substr($Detail_text,$d2,$d3-$d2); // lv_field的值
                  //$lv_title = substr($lv_title,0,strlen($lv_title)-1); //截取掉最后一个`
                  //$filelen_e = strlen('button name="');
                  //字符串拆解
                  $d4 = substr_count($lv_field,'`');//取出有多少个值
                  $character1 = explode('`', $lv_field, $d4);//分割到数组
                  $character2 = explode('`', $lv_title, $d4);//分割到数组
                  for ($ii=0;$ii<count($character1);$ii++) {
                  	 $Field1 = $xml -> createElement('Field');//新建节点(表单和表结构栏位资料)
   	      	         $tname1=$xml -> createAttribute('tname');
   	      	         if ($ii==count($character1)-1) {   //为最后一项时截取字符后一位的`字符
   	      	         	  $filed_v1=substr($character1[$ii],0,strlen($character1[$ii])-1);
   	      	         	  $filed_v2=substr($character2[$ii],0,strlen($character2[$ii])-1);
   	      	         } else {
   	      	         	  $filed_v1=$character1[$ii];
   	      	         	  $filed_v2=$character2[$ii];
   	      	         }
                     $tname1_value=$xml -> createTextNode('item_'.$filed_v1);
                     $tname1->appendChild($tname1_value);         
                     $Field1 -> appendChild($tname1);
                     $Record -> appendChild($Field1);
                     
                     $fname1=$xml -> createAttribute('fname');
                     $fname1_value=$xml -> createTextNode($filed_v2);
                     $fname1->appendChild($fname1_value);         
                     $Field1 -> appendChild($fname1);
                     $Record1 -> appendChild($Field1);
                  }
                  $Detail -> appendChild($Record1); 
                  $RecordSet -> appendChild($Detail); 
   	         	  } else {
                    continue; //退出
                }    
   	      	 }
   	      }
   	      //$Detail -> appendChild($Record1); 
   	      //$RecordSet -> appendChild($Detail); 
          //处理表结构与表单对应资料 end      
          
          $data -> appendChild($RecordSet);
       }
       //$data -> appendChild($RecordSet);
       $status -> appendChild($code);//设置$code为$execution字节点
       $status -> appendChild($sqlcode);//设置$sqlcode为$execution字节点
       $status -> appendChild($description);//设置$description为$execution字节点
       $execution -> appendChild($status);//设置$description为$execution字节点
       $response -> appendChild($execution);//设置execution为response字节点
       $response -> appendChild($data);//设置data为response字节点
       $xml -> appendChild($response);//设置根节点
       $str = $xml-> saveXML();//转换为字符串
       //截取XML档前面的头信息进行输出
       $e1 = strpos($str,'?>',0); //>出现的位置
       $e2 = $e1+strlen('?>');  //包含本身的位置
       $str1 = substr($str,$e2); // lv_field的值
   	   return iconv(MYOA_CHARSET,"utf-8",$str1); 
   } 
   
   public function Getwfexecution($str1){
   	   
   	   return iconv(MYOA_CHARSET,"utf-8","成功!");
   }
   
   public function Upworkflowstate($str1){
   	   
   	   return iconv(MYOA_CHARSET,"utf-8","成功!");
   }
   
}  
?>
2、回写状态

<?php
include_once("inc/conn.php");
include_once 'inc/auth.inc.php';
//include_once 'inc/utility_sms1.php';
//include_once("inc/utility_flow.php");
include_once( "general/workflow/plugin/plugin.inc.php" );
ob_end_clean();
//include_once '../plugin.inc.php';

//取出工作流表单中的关键值
$data=getRunData($RUN_ID);  
//$data=getRunData('26');  
//var_dump($data);
$prog_id = $data["prog_id"];
$arg1 = $data["单据编号"];
if (array_key_exists("序号",$data))
  {
  $arg2 = $data["序号"];
  }
else
  {
  $arg2 = NULL;
  }  

//$prog_id="csft001";
//$arg1="RBB-2015100009";
//$arg2=11;
echo $prog_id;
echo $arg1;
echo $arg2;
try {
    $client = new SoapClient("http://192.168.1.2/cgi-bin/fglccgi/ws/r/aws_ttsrv2_toptest?WSDL"); 
    if ($arg2==NULL) {
    	$xml = "<Access>
              <Authentication user=\"tiptop\" password=\"tiptop\"/>
              <Connection application=\"test\" source=\"192.168.1.2\"/>
              <Organization name=\"DICOLOR\"/><Locale language=\"zh_cn\"/>
              <RequestContent>
              <Parameter>
              <Record>
              <Field name=\"command\" value=\"exe2 {$prog_id} '{$arg1}' 'efconfirm'  \"/>
              </Record>
              </Parameter>
              </RequestContent>
              </Access>
              ";
    } else {
    	$xml = "<Access>
              <Authentication user=\"tiptop\" password=\"tiptop\"/>
              <Connection application=\"test\" source=\"192.168.1.2\"/>
              <Organization name=\"DICOLOR\"/><Locale language=\"zh_cn\"/>
              <RequestContent>
              <Parameter>
              <Record>
              <Field name=\"command\" value=\"exe2 {$prog_id} '{$arg1}' {$arg2} 'efconfirm'  \"/>
              </Record>
              </Parameter>
              </RequestContent>
              </Access>
             ";
    }
    $xml=iconv(MYOA_CHARSET,"utf-8",$xml);
    print_r("14");
    print_r($xml)."<br />";
    $return = $client->Exe2Command(array('request' => $xml));
} catch (SOAPFault $e) {
    print_r('Exception:'.$e);
}

?>


相关资料请到http://download.csdn.net/detail/wanjin6666/9606425下载!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值