|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
+use App\Order;
|
|
|
+use App\OrderBin;
|
|
|
use App\Services\BatchService;
|
|
|
use App\Services\CacheService;
|
|
|
use App\Services\common\BatchUpdateService;
|
|
|
@@ -99,14 +101,51 @@ class SyncBatchTask extends Command
|
|
|
$valueStore = ValueStore::query()->where("name","wave_detail_last_sync_date")->first();
|
|
|
return $valueStore->value ?? Carbon::now()->subSeconds(65)->toDateTimeString();
|
|
|
});
|
|
|
- $sql = "SELECT WM_CONCAT(ORDERNO) orderno,WAVENO FROM DOC_WAVE_DETAILS WHERE EDITTIME > TO_DATE(?,'yyyy-mm-dd hh24:mi:ss') GROUP BY WAVENO";
|
|
|
+ $sql = "SELECT ORDERNO,WAVENO,SEQNO FROM DOC_WAVE_DETAILS WHERE EDITTIME > TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')";
|
|
|
$details = DB::connection("oracle")->select(DB::raw($sql),[$date]);
|
|
|
if (count($details) < 1)return;
|
|
|
$map = [];
|
|
|
$nos = [];
|
|
|
+ $orderCodes = [];
|
|
|
+ $seqnos = [];
|
|
|
foreach ($details as $detail){
|
|
|
- $map[$detail->waveno] = explode(",",$detail->orderno);
|
|
|
- $nos[] = $detail->waveno;
|
|
|
+ if (isset($map[$detail->waveno]))$map[$detail->waveno][] = $detail->orderno;
|
|
|
+ else {
|
|
|
+ $map[$detail->waveno] = [$detail->orderno];
|
|
|
+ $nos[] = $detail->waveno;
|
|
|
+ }
|
|
|
+ $orderCodes[] = $detail->orderno;
|
|
|
+ $seqnos[$detail->orderno] = $detail->seqno;
|
|
|
+ }
|
|
|
+ $orders = Order::query()->select("id","code")->whereIn("code",$orderCodes)->get();
|
|
|
+ if (count($orderCodes) != count($orders)){
|
|
|
+ $orderIds = [];
|
|
|
+ $orderMap = [];
|
|
|
+ foreach ($orders as $order){
|
|
|
+ $orderIds[] = $order->id;
|
|
|
+ $orderMap[$order->id] = $seqnos[$order->code];
|
|
|
+ }
|
|
|
+ $updateBin = [["id","number"]];
|
|
|
+ $insertBin = [];
|
|
|
+ $orderBins = OrderBin::query()->select("id","order_id","number")->whereIn("order_id",$orderIds)->get();
|
|
|
+ foreach ($orderBins as $orderBin){
|
|
|
+ if ($orderBin->number != $orderMap[$orderBin->order_id])$updateBin[]=["id"=>$orderBin->id,"number"=>$orderMap[$orderBin->order_id]];
|
|
|
+ unset($orderMap[$orderBin->order_id]);
|
|
|
+ }
|
|
|
+ foreach ($orderMap as $orderId=>$binNumber){
|
|
|
+ $insertBin[]=[
|
|
|
+ "order_id"=>$orderId,
|
|
|
+ "number"=>$binNumber
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ if (count($updateBin)>1){
|
|
|
+ app(BatchUpdateService::class)->batchUpdate("order_bins",$updateBin);
|
|
|
+ LogService::log(__METHOD__,"波次同步-更新订单格口号",json_encode($updateBin));
|
|
|
+ }
|
|
|
+ if ($insertBin){
|
|
|
+ OrderBin::query()->insert($insertBin);
|
|
|
+ LogService::log(__METHOD__,"波次同步-录入订单格口号",json_encode($insertBin));
|
|
|
+ }
|
|
|
}
|
|
|
$batches = $this->batchService->get(["code"=>$nos]);
|
|
|
foreach ($batches as $batch){
|
|
|
@@ -141,7 +180,7 @@ class SyncBatchTask extends Command
|
|
|
// $this->batchService->assignTasks($batches);
|
|
|
|
|
|
|
|
|
- ValueStore::query()->where("name","wave_last_sync_date")->update(["value"=>Carbon::now()->subSeconds(1)->toDateTimeString()]);
|
|
|
+ ValueStore::query()->where("name","wave_detail_last_sync_date")->update(["value"=>Carbon::now()->subSeconds(1)->toDateTimeString()]);
|
|
|
}
|
|
|
|
|
|
/**
|