|
|
@@ -68,6 +68,7 @@ use App\Station;
|
|
|
use App\StationTask;
|
|
|
use App\StationTaskMaterialBox;
|
|
|
use App\Store;
|
|
|
+use App\StoreItem;
|
|
|
use App\TaskTransaction;
|
|
|
use App\Unit;
|
|
|
use App\User;
|
|
|
@@ -523,8 +524,122 @@ sql;
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
- public function teset12313(){
|
|
|
- dd(route("discharge.storeApi"));
|
|
|
+ public function init_在途异常()
|
|
|
+ {
|
|
|
+ $logistic_numbers = OrderPackage::query()
|
|
|
+ ->select('logistic_number')
|
|
|
+ ->where('exception_status', 5)
|
|
|
+ ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
|
|
|
+ ->pluck('logistic_number');
|
|
|
+ /** @var OrderPackageReceivedSyncService $service */
|
|
|
+ $service = app('OrderPackageReceivedSyncService');
|
|
|
+ $service->syncLogisticRoute(false, $logistic_numbers);
|
|
|
+
|
|
|
+
|
|
|
+// $logistic_numbers = OrderPackage::query()
|
|
|
+// ->select(['logistic_number', 'order_id', 'id'])
|
|
|
+// ->whereIn('order_id', function ($query) {
|
|
|
+// $query->from('orders')->selectRaw('id')->whereIn('logistic_id', function ($builder) {
|
|
|
+// $builder->from('logistics')->selectRaw('id')->where('type', '=', '快递')->whereNotIn('belong_company', ['顺丰', '中通', '韵达', '圆通', '京东']);
|
|
|
+// });
|
|
|
+// })
|
|
|
+// ->where('exception_status', 5)
|
|
|
+// ->where('created_at', '>=', now()->subDays(20)->toDateTimeString())
|
|
|
+// ->pluck('logistic_number');
|
|
|
+// $service->syncLogisticRouteByAliJiSu($logistic_numbers);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function store()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 0);
|
|
|
+ ini_set('memory_limit', '1024M');
|
|
|
+// $now = Carbon::now();
|
|
|
+// $startDate = $this->getDate();
|
|
|
+ $startDate = '2021-09-25 13:23:14';
|
|
|
+ $diffDay = 1; // 天数
|
|
|
+ for($i = 0;$i<=$diffDay;$i++){
|
|
|
+ $endDate = Carbon::parse($startDate)->addDays(1)->toDateTimeString();
|
|
|
+ $doc_asn_headers = $this->getDocAsnHeader($startDate,$endDate);
|
|
|
+// if (count($doc_asn_headers)>0){
|
|
|
+// $this->syncStores($doc_asn_headers);
|
|
|
+// $this->syncDate($endDate);
|
|
|
+// }
|
|
|
+ dump($startDate,$endDate);
|
|
|
+ $startDate = $endDate;
|
|
|
+ }
|
|
|
+ $this->clearCache();
|
|
|
+// ValueStore::query()->updateOrCreate([
|
|
|
+// 'name' => 'last_asn_sync_task_end_at',
|
|
|
+// ], [
|
|
|
+// 'name' => 'last_asn_sync_task_end_at',
|
|
|
+// 'value' => $now,
|
|
|
+// ]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function getDocAsnHeader($startDate,$endDate)
|
|
|
+ {
|
|
|
+ return OracleDOCASNHeader::query()
|
|
|
+ ->with(['asnType', 'asnStatus'])
|
|
|
+ ->select('asnno','asnstatus','asntype','addtime','edittime','customerid','notes','warehouseid','asnreference3','asnreference2')
|
|
|
+ ->where('EditTime', '>=', $startDate)
|
|
|
+ ->where('EditTime', '<=', $endDate)
|
|
|
+ ->whereColumn('EditTime', '<>', 'addTime')
|
|
|
+ ->orderByDesc('EditTime')
|
|
|
+ ->get();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getDate(){
|
|
|
+ return ValueStore::query()->where('name','asn_last_updated_sync_at')->value('value');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function syncStores($doc_asn_headers){
|
|
|
+ $service = new StoreService();
|
|
|
+ $service->createStore($doc_asn_headers,"update");
|
|
|
+ $service->updateStore($doc_asn_headers);
|
|
|
+ $service->createStoreRejected($doc_asn_headers);
|
|
|
+ unset($doc_asn_headers);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function syncDate($date)
|
|
|
+ {
|
|
|
+ // 同步更新时间
|
|
|
+ ValueStore::query()->updateOrCreate([
|
|
|
+ 'name' => 'asn_last_updated_sync_at',
|
|
|
+ ], [
|
|
|
+ 'name' => 'asn_last_updated_sync_at',
|
|
|
+ 'value' => $date,
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ public function clearCache()
|
|
|
+ {
|
|
|
+ $service = new StoreService();
|
|
|
+ $update_set = config('sync.asn_sync.cache_prefix.update_set');
|
|
|
+ $update_keys = config('sync.asn_sync.cache_prefix.update_keys');
|
|
|
+ $service->deleteCacheKey($update_set, $update_keys);
|
|
|
+ // 清空保存 ans 号的栈
|
|
|
+ // 清除 更新时间 开始 结束
|
|
|
+ }
|
|
|
+ public function updateStoreItem()
|
|
|
+ {
|
|
|
+ ini_set('max_execution_time', 0);
|
|
|
+ ini_set('memory_limit', '1024M');
|
|
|
+ $storeIds = Store::query()
|
|
|
+ ->where('updated_at', '>=', '2021-09-25 13:21:26')
|
|
|
+ ->whereColumn('updated_at', '<>', 'created_at')
|
|
|
+ ->pluck('id');
|
|
|
+
|
|
|
+ $storeItemMaxIds = StoreItem::query()
|
|
|
+ ->selectRaw('max(id) as max_id')
|
|
|
+ ->whereIn('store_id', $storeIds)
|
|
|
+ ->groupBy(['store_id', 'asn_line_code'])
|
|
|
+ ->get();
|
|
|
+// dd($storeItemMaxIds->count());
|
|
|
+ $storeItems = StoreItem::query()
|
|
|
+ ->whereIn('store_id', $storeIds)
|
|
|
+ ->whereNotIn('id', $storeItemMaxIds)
|
|
|
+ ->delete();
|
|
|
}
|
|
|
|
|
|
public function init_SettlementBillReportTask()
|