|
@@ -0,0 +1,71 @@
|
|
|
+<?php
|
|
|
+declare (strict_types=1);
|
|
|
+
|
|
|
+namespace app\command;
|
|
|
+
|
|
|
+use think\console\Command;
|
|
|
+use think\console\Input;
|
|
|
+use think\console\input\Argument;
|
|
|
+use think\console\input\Option;
|
|
|
+use think\console\Output;
|
|
|
+use think\Exception;
|
|
|
+use think\facade\Db;
|
|
|
+
|
|
|
+class UpdateProcessWaitFinallyActionData extends Command
|
|
|
+{
|
|
|
+ protected function configure()
|
|
|
+ {
|
|
|
+ // 指令配置
|
|
|
+ $this->setName('UpdateProcessWaitFinallyActionData')
|
|
|
+ ->setDescription('更新待办数据表中的字段:最终操作人');
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function execute(Input $input, Output $output)
|
|
|
+ {
|
|
|
+ Db::startTrans();
|
|
|
+ try {
|
|
|
+
|
|
|
+ Db::name('process_wait')
|
|
|
+ ->where('action_uid_finally','<>',0)
|
|
|
+ ->update(['action_uid_finally'=>0,'action_name_finally'=>'']);
|
|
|
+
|
|
|
+ $data = Db::name('process_wait')
|
|
|
+ ->field('order_code,order_type,order_id')
|
|
|
+ ->group('order_code,order_type,order_id')
|
|
|
+ ->whereIn('status', [1, 2])
|
|
|
+ ->cursor();
|
|
|
+
|
|
|
+ foreach ($data as $value) {
|
|
|
+
|
|
|
+ if($value['order_type'] == 'LZJJ') $order_code = $value['order_id'];//离职交接单,取id
|
|
|
+ else $order_code = $value['order_code'];
|
|
|
+
|
|
|
+ $action = Db::name('action_log')
|
|
|
+ ->field('id,action_id,action_name')
|
|
|
+ ->where([
|
|
|
+ 'order_code'=>$order_code,
|
|
|
+ 'order_type'=>$value['order_type']
|
|
|
+ ])
|
|
|
+ ->order('id','desc')
|
|
|
+ ->findOrEmpty();
|
|
|
+
|
|
|
+ if ($action) Db::name('process_wait')
|
|
|
+ ->where('order_code', $value['order_code'])
|
|
|
+ ->where('order_type', $value['order_type'])
|
|
|
+ ->update(['action_uid_finally' => $action['action_id'],'action_name_finally' => $action['action_name']]);
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::commit();
|
|
|
+
|
|
|
+ $output->writeln('update success');
|
|
|
+
|
|
|
+ } catch (Exception $exception) {
|
|
|
+ Db::rollback();
|
|
|
+ $output->writeln('update fail,' . $exception->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|