|
|
@@ -2,15 +2,14 @@
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
-use App\Model\RevenueCostMain;
|
|
|
+use App\Model\DDEmployee;
|
|
|
+use App\Model\Record;
|
|
|
+use App\Service\U8DatabaseServerService;
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
-use Illuminate\Support\Facades\DB;
|
|
|
-use Illuminate\Support\Facades\Redis;
|
|
|
-use MongoDB\Driver\Exception\Exception;
|
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
@@ -19,47 +18,84 @@ class ProcessDataJob implements ShouldQueue
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
protected $data;
|
|
|
- protected $user;
|
|
|
- protected $type;
|
|
|
+ public $timeout = 30;
|
|
|
|
|
|
- public $timeout = 1800;
|
|
|
-
|
|
|
- public function __construct($data, $user, $type = 1)
|
|
|
+ public function __construct($data)
|
|
|
{
|
|
|
+ //record表
|
|
|
$this->data = $data;
|
|
|
- $this->user = $user;
|
|
|
- $this->type = $type;
|
|
|
}
|
|
|
|
|
|
public function handle()
|
|
|
{
|
|
|
try {
|
|
|
- $data = $this->data;
|
|
|
- $user = $this->user;
|
|
|
- $type = $this->type;
|
|
|
-
|
|
|
-
|
|
|
-// $this->finalDo($msg, $service);
|
|
|
+ list($bool, $msg) = $this->syncApprovedRecords($this->data);
|
|
|
+ if(! $bool) $this->finalDo($msg, $this->data);
|
|
|
} catch (\Throwable $e) {
|
|
|
-// $this->finalDo("异常:" . $e->getMessage(), $service);
|
|
|
+ $this->finalDo("异常:" . $e->getMessage());
|
|
|
$this->delete();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private function finalDo($msg, $service){
|
|
|
- $type = $this->type;
|
|
|
- $service->delTableKey($type);
|
|
|
- if($type == 1) $service->clearTmpTable();
|
|
|
+ private function finalDo($msg, $record){
|
|
|
+ Record::where('id', $record['id'])
|
|
|
+ ->update(['result' => $msg]);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function syncApprovedRecords($record)
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $service = new U8DatabaseServerService(['zt_database' => $record['database']]);
|
|
|
+ if ($service->error) return [false, $service->error];
|
|
|
|
|
|
- $user = $this->user;
|
|
|
- $data = $this->data;
|
|
|
+ $time = date("Y-m-d H:i:s");
|
|
|
+ $time1 = date("Y-m-d 00:00:00");
|
|
|
+
|
|
|
+ if($record['del_time'] == 2){
|
|
|
+ $type = $record['type'];
|
|
|
+ $order_number = $record['order_number'];
|
|
|
+
|
|
|
+ $system_name = "system";
|
|
|
+ $name = DDEmployee::where('userid', $record['userid'])->value('name');
|
|
|
+ if(! empty($name)) $system_name = $name;
|
|
|
+ if($type == 1){
|
|
|
+ $service->db->table("PO_Pomain")
|
|
|
+ ->where("cPOID", $order_number)
|
|
|
+ ->update([
|
|
|
+ "cVerifier" => $system_name,
|
|
|
+ "iverifystateex" => 1,
|
|
|
+ "cState" => 1,
|
|
|
+ "cAuditTime" => $time . ".000",
|
|
|
+ "cAuditDate" => $time1 . ".000",
|
|
|
+ ]);
|
|
|
+ }elseif($type == 2){
|
|
|
+ $service->db->table("PU_AppVouch")
|
|
|
+ ->where("cCode", $order_number)
|
|
|
+ ->update([
|
|
|
+ "cVerifier" => $system_name,
|
|
|
+ "cAuditTime" => $time . ".000",
|
|
|
+ "cAuditDate" => $time1 . ".000",
|
|
|
+ ]);
|
|
|
+ }else{
|
|
|
+ $service->db->table("AP_ApplyPayVouch")
|
|
|
+ ->where("cVouchID", $order_number)
|
|
|
+ ->update([
|
|
|
+ "cCheckMan" => $system_name,
|
|
|
+ "dverifysystime" => $time . ".000",
|
|
|
+ "dverifydate" => $time1 . ".000",
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新本地数据
|
|
|
+ Record::where("id", $record['id'])->update(['del_time' => 3]);
|
|
|
+
|
|
|
+ $service->close();
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ return [false, $e->getMessage()];
|
|
|
+ }
|
|
|
|
|
|
- RevenueCostMain::insert([
|
|
|
- 'result' => $msg,
|
|
|
- 'crt_id' => $user['id'],
|
|
|
- 'crt_time' => $data['operation_time'],
|
|
|
- 'order_type' => $data['type'],
|
|
|
- ]);
|
|
|
+ return [true, ''];
|
|
|
}
|
|
|
|
|
|
protected function echoMessage(OutputInterface $output)
|