通达OA批量处理没有结束但前台显示已经结束的流程
问题描述:
通达OA系统出现大量流程没有结束,系统显示结束的问题通过查询操作系统日志,数据库日志,包括程序日志没有发现异常,通过观察发现大量的流程结束时间都是在2016-02-16 17:32:XX时间的标志
通过前台可以直接恢复,这样只能一个个手动处理,对大批量的问题需要通过其他方式进行
思路:
1.查看OA的文件restore.php
源码:
<?php include_once( "inc/auth.php" ); include_once( "inc/utility_all.php" ); include_once( "../prcs_role.php" ); if ( $LOGIN_USER_PRIV != 1 ) { exit( ); } $query = "update FLOW_RUN_PRCS set PRCS_FLAG='2' where RUN_ID=".$RUN_ID." and OP_FLAG='1' ORDER BY PRCS_ID DESC,PRCS_TIME DESC LIMIT 1"; exequery( $connection, $query ); $query = "update FLOW_RUN set END_TIME=NULL where RUN_ID=".$RUN_ID." LIMIT 1"; exequery( $connection, $query ); $CONTENT = "恢复执行此工作"; run_log( $RUN_ID, $PRCS_ID, $FLOW_PRCS, $LOGIN_USER_ID, 1, $CONTENT ); ob_end_clean( ); if ( !mysql_affected_rows( ) ) { echo "您的恢复执行操作没有成功!"; } else { echo "流水号为["; echo $RUN_ID; echo "]的工作已经恢复到执行状态!"; } ?>
2.找到核心问题处理语句:
$query = "update FLOW_RUN_PRCS set PRCS_FLAG='2' where RUN_ID=".$RUN_ID." and OP_FLAG='1' ORDER BY PRCS_ID DESC,PRCS_TIME DESC LIMIT 1";$query = "update FLOW_RUN set END_TIME=NULL where RUN_ID=".$RUN_ID." LIMIT 1";
3.通过语句将这部分有问题的流程查找出来,用脚本批量处理
<?php header('content-type:text/html;charset=utf-8'); /* 批量插入用户工号脚本 1.连接数据库 2.循环有问题的流程流水号 3.循环修改数据 */ //连接数据库 $conn=mysql_connect('192.168.8.200:3306','root','pass'); if(!$conn) { print_r(mysql_error()); } //选库 $sql='use TD_OA'; mysql_query($sql) or die('select database error'); //设置字符集 $sql='set names utf8'; mysql_query($sql); //找到有问题的流水 /* //流程没有结束,但是显示结束的流程 SELECT a.* from FLOW_RUN a,FLOW_RUN_PRCS b where a.run_id=b.run_id and a.end_time like '2016-02-16 17:32%' and a.begin_time>='2016-02-01 00:00:00' and a.del_flag=0 and a.end_time is not null and (b.prcs_time is null and b.deliver_time is not null) */ $run_id=array('1956932','1957092','1957208','1957217','1957258','1957413','1957413','1957452','1957602','1957690','1957690','1957690'); foreach($run_id as $v) { $sql1 = "update FLOW_RUN_PRCS set PRCS_FLAG='2' where RUN_ID='".$v."' and OP_FLAG='1' ORDER BY PRCS_ID DESC,PRCS_TIME DESC LIMIT 1"; echo $sql1,'<br />'; mysql_query($sql1); $sql2 = "update FLOW_RUN set END_TIME=NULL where RUN_ID='".$v."' LIMIT 1"; echo $sql2,'<br />'; mysql_query($sql2); } echo 'ok';