data["active_test"] = "active";
}
public function method(Request $request, $method)
{
try {
return call_user_func([$this, $method], $request);
}catch (\BadMethodCallException $e){
dd("方法不存在");
}
}
public function test1()
{
try {
$b = DB::connection("oracle")->select("SELECT * FROM DOC_ORDER_HEADER");
dump(count($b));
}catch (\Exception $e){
dd($e);
}catch (\Error $e1){
dd($e1);
}
dd(round(memory_get_peak_usage() / 1024 / 1024, 2));
}
public function test()
{
$b = [];
for ($i=0;$i<100000;$i++){
$b[] = $i;
}
dd(round(memory_get_peak_usage() / 1024 / 1024, 2));
$area = OwnerAreaReport::query()->find(398);
if (!$area->ownerStoragePriceModel)dd("error");
//信息提取模板
$GLOBALS["FEE_INFO"] = [
"area_id" =>$area->id,
"counting_type" =>$area->ownerStoragePriceModel->counting_type,
"using_type" =>$area->ownerStoragePriceModel->using_type,
"fee_description" =>"",
"total_fee" =>0,
"tax_rate" =>0,
];
list($money,$taxFee) = app('OwnerStoragePriceModelService')
->calculationAmount($area->ownerStoragePriceModel,$area->accounting_area,$area->owner_id,$area->counting_month);
dd($money,$taxFee);
dd(Notification::send(User::query()->where("name","zhouzhendong")->get(),new RoutineNotification(SeeLog::query()->first()->toArray())));
$user = Auth::user();
$remark = "zengjunlj";
$ownerName = 'zengjunlj' ?? '';
$clientCode = 'zengjunljljlj' ?? '';
$msg = $user["name"]."建立了新工单
".$ownerName.":".$clientCode."
".$remark;
NotificationService::SingleRegister($msg,$clientCode,"订单管理-问题件");
dd(1);
$seeLog = SeeLog::query()->find(9);
Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
dd(1);
Broadcast::channel('notification', function ($user, $id) {
return (int) $user->id === (int) $id;
});
dd(1);
Notification::send(Auth::user(),new RoutineNotification($seeLog->toArray()));
dd(1);
$username = config('database.connections.oracle.username');
$password = config('database.connections.oracle.password');
$host = config('database.connections.oracle.host');
$service_name = config('database.connections.oracle.service_name');
$conn = oci_connect($username, $password, $host . '/' . $service_name,"utf8");
$sql = <<selectOne(DB::raw("select * from DOC_ORDER_HEADER where orderno = ?"),[$no]);
dd($db->select($sql,[
]));
$db->select("CALL SPSO_HardAllocation_Process(?,'Allocation','By OrderNO',null,?,'0',null,'zhouzhendong',@code)",[
$order->warehouseid,$no
]);
//SPSO_HardAllocation_Process
dd($db->selectOne("select @code"));
$date = "2021-09-14 15:47:00";
dispatch(new TestJob("1"))->delay(Carbon::parse($date));
dispatch(new TestJob("2"))->delay(Carbon::parse($date));
dispatch(new TestJob("3"))->delay(Carbon::parse($date));
dispatch(new TestJob("4"))->delay(Carbon::parse($date));
dispatch(new TestJob("5"))->delay(Carbon::parse($date));
dispatch(new TestJob("6"))->delay(Carbon::parse($date));
dispatch(new TestJob("7"))->delay(Carbon::parse($date));
dispatch(new TestJob("8"))->delay(Carbon::parse($date));
dispatch(new TestJob("9"))->delay(Carbon::parse($date));
dispatch(new TestJob("10"))->delay(Carbon::parse($date));
dd(1);
Station::query()->where("station_type_id", 5)->update(["status" => 1]);
Cache::forget("CACHE_SHELF_AVAILABLE");
$station = ["HAIB1-01-01", "HAIB1-02-01"];
$material = ["IDE0001824", "IDE0001740", "IDE0002710"];
Station::query()->whereIn("code", $station)->update(["status" => 0]);
$stations = Station::query()->whereIn("code", $station)->get();
$materials = MaterialBox::query()->whereIn("code", $material)->get();
$dateTime = date("Y-m-d H:i:s");
$task1 = StationTaskMaterialBox::query()->create([
'station_id' => $stations[0]->id,
'material_box_id' => $materials[0]->id,
'station_task_batch_id' => 1,
'status' => '待处理'
]);
$task2 = StationTaskMaterialBox::query()->create([
'station_id' => $stations[1]->id,
'material_box_id' => $materials[1]->id,
'station_task_batch_id' => 1,
'status' => '待处理'
]);
$task3 = StationTaskMaterialBox::query()->create([
'station_id' => 6,
'material_box_id' => $materials[2]->id,
'station_task_batch_id' => 1,
'status' => '待处理'
]);
TaskTransaction::query()->insert([[
"doc_code" => "test",
"bar_code" => "test",
"to_station_id" => $stations[0]->id,
"material_box_id" => $materials[0]->id,
"task_id" => $task1->id,
"commodity_id" => 505012,//XUNI03
"amount" => 1,
"type" => "出库",
"status" => 0,
"mark" => 2,
"bin_number" => 1,
"created_at" => $dateTime,
"updated_at" => $dateTime,
], [
"doc_code" => "test",
"bar_code" => "test",
"to_station_id" => $stations[1]->id,
"material_box_id" => $materials[1]->id,
"task_id" => $task2->id,
"commodity_id" => 505012,//XUNI03
"amount" => 1,
"type" => "出库",
"status" => 0,
"mark" => 2,
"bin_number" => 1,
"created_at" => $dateTime,
"updated_at" => $dateTime,
], [
"doc_code" => "test",
"bar_code" => "test",
"to_station_id" => 6,
"material_box_id" => $materials[2]->id,
"task_id" => $task3->id,
"commodity_id" => 505012,//XUNI03
"amount" => 1,
"type" => "出库",
"status" => 3,
"mark" => 2,
"bin_number" => 1,
"created_at" => $dateTime,
"updated_at" => $dateTime,
]]);
$foreignHaiRoboticsService = new ForeignHaiRoboticsService();
$toLocation = collect($station);
$taskMaterialBoxes = collect([$task1, $task2]);
$foreignHaiRoboticsService->
fetchGroup_multiLocation($toLocation, $taskMaterialBoxes, '', '立架出至缓存架', 20, false);
foreach ($toLocation as $index => $value) {
app("CacheShelfService")->lightUp($value, '3', '0', ["title" => "机器人取箱中,禁止操作"]);
Cache::forever("CACHE_SHELF_OCCUPANCY_{$stations[$index]->id}", true);
}
app("StationService")->locationOccupyMulti($toLocation->toArray());
}
public function update_order_packages_is_manual_update()
{
$descriptions = Log::query()
->select('description')
->whereBetween('created_at', ['2021-08-31 10:30:00', '2021-08-31 10:35:00'])
->where('class', 'like', 'https://was.baoshi56.com/package/logistic/batchUpdate%')->pluck('description');
foreach ($descriptions as $description) {
$description = substr($description, 9);
$description = \Illuminate\Support\Str::before($description, "}");
$obj = json_decode($description . '}', true);
OrderPackage::query()
->whereIn('logistic_number', $obj['logistic_numbers'])
->update([
'status' => '无',
'is_manual_update' => false,
]);
}
}
public function testUpdateInv()
{
ini_set('max_execution_time', 0);
ini_set('memory_limit', '4096M');
$sql = <<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
and OPENTIME<=TO_DATE(?,'yyyy-mm-dd hh24:mi:ss')
sql;
$CUSTOMERID = 'JIANSHANG';
$FMLOCATION = 'STAGEWH02';
$OPENWHO = 'WCS';
$TASKPROCESS = '00';
$DOCTYPE = 'ASN';
$TASKTYPE = 'PA';
$LOTATT05 = 'MJ-CP';
$LOTATT08 = 'ZP';
$PLANTOID = '*';
$traceid = 'JIANSHANG03';
$start = '2021-09-02 23:59:59';
$end = '2021-09-03 11:10:00';
$res = DB::connection("oracle")->select(DB::raw($sql),
[$CUSTOMERID, $FMLOCATION, $OPENWHO, $TASKPROCESS, $DOCTYPE, $TASKTYPE, $LOTATT05, $LOTATT08, $PLANTOID, $start, $end]);
$resItems = array_chunk($res, 200);
foreach ($resItems as $res) {
DB::connection("oracle")->beginTransaction();
try {
foreach ($res as $re) {
DB::connection("oracle")->table('INV_LOT_LOC_ID')
->where([
'LOTNUM' => $re->fmlotnum,
'LOCATIONID' => $re->fmlocation,
'CUSTOMERID' => $re->customerid,
'sku' => $re->sku,
'TRACEID' => '*',
])
->update([
'TRACEID' => $traceid,
'EDITWHO' => 'WCS_',
]);
if ($re->fmlocation != $re->plantolocation) {
DB::connection("oracle")->table('INV_LOT_LOC_ID')
->where([
'LOTNUM' => $re->fmlotnum,
'LOCATIONID' => $re->plantolocation,
'CUSTOMERID' => $re->customerid,
'sku' => $re->sku,
'TRACEID' => '*',
])
->update([
'TRACEID' => $traceid,
'EDITWHO' => 'WCS_',
]);
}
DB::connection("oracle")->commit();
}
dd(true);
} catch (\Exception $e) {
DB::connection("oracle")->rollBack();
dd($e->getMessage());
}
}
}
/**
* 重置15天内的数据
*/
public function order_packages_init()
{
OrderPackage::query()
->whereBetween('created_at', [now()->subDays(15), now()])
->update([
'is_delay_deliver' => 0,
'sync_routes_flag' => 0,
'status' => 1,
'exception_status' => 0,
]);
OrderPackage::query()
->whereBetween('created_at', [now()->subDays(15), now()])
->whereNotNull('received_at')
->update([
'status' => 7,
]);
}
public function syncOrderPackage(){
ini_set('memory_limit','500M');
ini_set('max_execution_time', 0);
$orderPackingSummary = OracleDocOrderPackingSummary::query()
->where('editTime','>=','2021-09-11 12:00:00')
->where('editTime','<=','2021-09-12 12:40:00')
->get();
$orderPackingSummary_chunk = $orderPackingSummary->chunk(200);
foreach ($orderPackingSummary_chunk as $orderPackingSummarys) {
foreach ($orderPackingSummarys as $orderPackingSummary) {
$orderPackage = OrderPackage::query()->where('logistic_number',$orderPackingSummary->traceid)->first();
$orderPackage->update([
'uploaded_to_wms'=> true,
'weight'=>$orderPackingSummary->grossweight,
'length'=>$orderPackingSummary->length,
'width'=>$orderPackingSummary->width,
'height'=>$orderPackingSummary->height,
'weighed_at'=>$orderPackingSummary->edittime
]);
dispatch(new WeightUpdateInstantBill($orderPackage));
}
}
return ['success' => true];
}
public function collectUpload()
{
/** @var OrderPackageService $service */
$service = app('OrderPackageService');
return $service->collectUpload([
'75803656098638',
'75803656098612'
]);
}
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-19 14:15:58';
$diffDay = 2; // 天数
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($endDate);
$startDate = $endDate;
}
// 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()
{
$storeIds = Store::query()
->where('updated_at', '>=', '2021-09-22 10:00:0')
->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 testCarbon()
{
// ini_set('max_execution_time', 2500);
// ini_set('memory_limit', '512M');
// $ownerCodes=Owner::query()->where('is_manual_back',1)->pluck('code');//自动回传货主
// $last_order_manual_back_at=$this->getOrderManualBackAt();//上次回传时间
// $now=Carbon::now()->toDateTimeString();//当前时间
// try {
// $ordernos=$this->allocation($last_order_manual_back_at, $now, $ownerCodes);//分配是创建状态订单
// $this->manualBack($last_order_manual_back_at,$now, $ownerCodes,$ordernos);//回传
// } catch (\Exception $e) {
// app('LogService')->log(__METHOD__, __FUNCTION__, "自动回传失败" . $last_order_manual_back_at . ' || '
// .$now. ' || ' . json_encode($ownerCodes).' || ' . json_encode($e->getMessage()));
// }
// $this->setOrderManualBackAt();//回传结束时间标记
}
}