|
|
@@ -156,286 +156,36 @@ class TestController extends Controller
|
|
|
dd("方法不存在");
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * @param $wave
|
|
|
- * @return string
|
|
|
- */
|
|
|
- private function wms_status($wave): string
|
|
|
- {
|
|
|
- switch ($wave->wavestatus) {
|
|
|
- case 00:
|
|
|
- $wms_status = '创建';
|
|
|
- break;
|
|
|
- case 40:
|
|
|
- $wms_status = '部分收货';
|
|
|
- break;
|
|
|
- case 90:
|
|
|
- $wms_status = '取消';
|
|
|
- break;
|
|
|
- case 99:
|
|
|
- $wms_status = '完成';
|
|
|
- break;
|
|
|
- case 62:
|
|
|
- $wms_status = '部分装箱';
|
|
|
- break;
|
|
|
- default:
|
|
|
- $wms_status = (string)$wave->wavestatus;
|
|
|
- }
|
|
|
- return $wms_status;
|
|
|
- }
|
|
|
- public function assignBatch()
|
|
|
- {
|
|
|
- $code = \request("code");
|
|
|
- $batches = Batch::query()->where("code",$code)->get();
|
|
|
- if (!$batches->count()){
|
|
|
- $wave = DB::connection("oracle")->selectOne(DB::raw("select * from DOC_WAVE_HEADER where WAVENO = ?"),[$code]);
|
|
|
- if (!$wave){
|
|
|
- dd("FLUX无波次");
|
|
|
- }
|
|
|
- $owner = app("OwnerService")->codeGetOwner($wave->customerid);
|
|
|
- $obj = [
|
|
|
- "wms_status" => $this->wms_status($wave),
|
|
|
- "wms_type"=>$wave->descr,
|
|
|
- "created_at"=>date("Y-m-d H:i:s"),
|
|
|
- "wms_created_at"=>$wave->addtime,
|
|
|
- "updated_at"=>$wave->edittime,
|
|
|
- "owner_id"=>$owner->id,
|
|
|
- ];
|
|
|
- $wave = Batch::query()->where("code",$code)->first();
|
|
|
- if (!$wave){
|
|
|
- $obj["code"] = $code;
|
|
|
- $wave = Batch::query()->create($obj);
|
|
|
- }else{
|
|
|
- Batch::query()->where("code",$code)->update($obj);
|
|
|
- }
|
|
|
- $ordernos = array_column(DB::connection("oracle")->select(DB::raw("select orderno from DOC_WAVE_DETAILS where WAVENO = ?"),[$code]),"orderno");
|
|
|
- Order::query()->whereIn("code",$ordernos)->update([
|
|
|
- "batch_id"=>$wave->id
|
|
|
- ]);
|
|
|
- Order::query()->with(["batch","bin"])->whereIn("code",$ordernos)->get()->each(function ($order){
|
|
|
- if (!$order->bin){
|
|
|
- $bin = DB::connection("oracle")->selectOne(DB::raw("select seqno from DOC_WAVE_DETAILS where waveno = ? and orderno = ?"),[$order->batch->code,$order->code]);
|
|
|
- if ($bin){
|
|
|
- OrderBin::query()->create([
|
|
|
- 'order_id' => $order->id,
|
|
|
- 'number' => $bin->seqno,
|
|
|
- ]);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- $batches = Batch::query()->where("code",$code)->get();
|
|
|
- }
|
|
|
- app("BatchService")->assignTasks($batches);
|
|
|
- }
|
|
|
- private function i3()
|
|
|
- {
|
|
|
- $taskItem = new TaskItem();
|
|
|
- $taskItem->name = "测试衣服商品名3";
|
|
|
- $taskItem->barcode = "TEST-014";
|
|
|
- $taskItem->quantity = (int)1;
|
|
|
- $taskItem->binLocations = [
|
|
|
- "G04-039-1",
|
|
|
- ];
|
|
|
- $taskItem->attributes = [
|
|
|
- "orderLineNo" => "1",
|
|
|
- "skuLineNo" => "1",
|
|
|
- "sku" => "TEST3",
|
|
|
- "lotNum" => "LOT1792011",
|
|
|
- "logisticNumber"=> "极兔",
|
|
|
- ];
|
|
|
- return (array)$taskItem->get();
|
|
|
- }
|
|
|
- private function i2()
|
|
|
- {
|
|
|
- $taskItem = new TaskItem();
|
|
|
- $taskItem->name = "测试衣服商品名2";
|
|
|
- $taskItem->barcode = "TEST-013";
|
|
|
- $taskItem->quantity = (int)1;
|
|
|
- $taskItem->binLocations = [
|
|
|
- "G04-056-1",
|
|
|
- ];
|
|
|
- $taskItem->attributes = [
|
|
|
- "orderLineNo" => "1",
|
|
|
- "skuLineNo" => "1",
|
|
|
- "sku" => "TEST1",
|
|
|
- "lotNum" => "LOT179201",
|
|
|
- "logisticNumber"=> "圆通",
|
|
|
- ];
|
|
|
- return (array)$taskItem->get();
|
|
|
- }
|
|
|
- private function i1()
|
|
|
- {
|
|
|
- $taskItem = new TaskItem();
|
|
|
- $taskItem->name = "测试衣服 商品名";
|
|
|
- $taskItem->barcode = "TEST-012";
|
|
|
- $taskItem->quantity = (int)1;
|
|
|
- $taskItem->binLocations = [
|
|
|
- "G04-046-0",
|
|
|
- ];
|
|
|
- $taskItem->attributes = [
|
|
|
- "orderLineNo" => "1",
|
|
|
- "skuLineNo" => "1",
|
|
|
- "sku" => "TEST",
|
|
|
- "lotNum" => "LOT17920",
|
|
|
- "logisticNumber"=> "顺丰",
|
|
|
- ];
|
|
|
- return (array)$taskItem->get();
|
|
|
- }
|
|
|
- private function t1()
|
|
|
- {
|
|
|
- $task = new Task();
|
|
|
- $task->id = "TEST0010";
|
|
|
- $task->batchId = "WTEST0002";
|
|
|
- $task->warehouseId = "101";
|
|
|
- $task->attributes = [
|
|
|
- "customer" => "幼岚",
|
|
|
- ];
|
|
|
- $task->type = Task::TOTAL_PICKING;
|
|
|
- $task->storages = [["type"=>"1A_container"]];
|
|
|
- $task->items = [
|
|
|
- $this->i1(),
|
|
|
- $this->i2(),
|
|
|
- $this->i3(),
|
|
|
- ];
|
|
|
- return $task->get();
|
|
|
- }
|
|
|
- use Signature;
|
|
|
- private static $delayedHour = 48;
|
|
|
- function process(Request $request): array
|
|
|
- {
|
|
|
- $station_id = $request->input('station_id');
|
|
|
- $batch_id = $request->input('batch_id');
|
|
|
- $childIndex = null;
|
|
|
- $arr = explode('-',$batch_id);
|
|
|
- if (count($arr)==2){
|
|
|
- $batch_id = $arr[0];
|
|
|
- $childIndex = (int)$arr[1];
|
|
|
- }
|
|
|
|
|
|
- $s = new SortingController();
|
|
|
- // 同步orderCommodity
|
|
|
- $s->syncOrder($batch_id);
|
|
|
-
|
|
|
- /** @var Batch|\stdClass $batch */
|
|
|
- $batch=Batch::query()->where('code',$batch_id)->orderBy('id','desc')->first();
|
|
|
- $data=[
|
|
|
- 'result'=>'success',
|
|
|
- 'station_id'=>$station_id,
|
|
|
- 'batch_id'=>$batch_id,
|
|
|
- 'orders'=>[]
|
|
|
- ];
|
|
|
- if ($childIndex!==null && $batch->split_size){
|
|
|
- $start = (($childIndex-1)*$batch->split_size)+1;
|
|
|
- $end = $childIndex*$batch->split_size;
|
|
|
- $sql = <<<SQL
|
|
|
-SELECT ORDERNO
|
|
|
-FROM (SELECT T.ORDERNO, ROWNUM AS NO
|
|
|
-FROM (SELECT ORDERNO FROM DOC_WAVE_DETAILS WHERE WAVENO = '{$batch_id}' ORDER BY SEQNO) T)
|
|
|
-WHERE NO BETWEEN {$start} AND {$end}
|
|
|
-SQL;
|
|
|
- $waves = DB::connection("oracle")->select(DB::raw($sql));
|
|
|
- $codes = array_column($waves,'orderno');
|
|
|
- $orders = Order::query()->whereIn("code",$codes)->get();
|
|
|
- }else $orders = $batch->orders()->get();
|
|
|
-
|
|
|
- $ordersSorted=$orders->sortBy(function(Order $order){
|
|
|
- return $order->bin()->first()['number'];
|
|
|
- });
|
|
|
- $ordersSorted->each(function(Order $order)use(&$data,$request){
|
|
|
- if($order['status']=='取消')return;
|
|
|
- $orderData=[
|
|
|
- 'order_id'=>$order['code'],
|
|
|
- 'owner'=>$order->owner()->first()['code'],
|
|
|
- 'status'=>$order['status']=='未处理'?'available':$order['status'],
|
|
|
- 'created_at'=>$order['created_at']->toDateTimeString(),
|
|
|
- 'bin'=>(function()use($order){
|
|
|
- $bin=$order->bin()->first()['number']??'';
|
|
|
- if(!$bin){
|
|
|
- $bin=OracleDOCWaveDetails::query()->where('orderno', 'SO201230003574')->get('seqno')->first()['seqno']??'';
|
|
|
- dump('BIN 缺失');
|
|
|
- return $bin;
|
|
|
- }
|
|
|
- return $bin;
|
|
|
- })(),
|
|
|
- 'barcodes'=>[]
|
|
|
- ];
|
|
|
- $order->orderCommodities()->each(function(OrderCommodity $orderCommodity)use(&$orderData,$request){
|
|
|
- $commodity=$orderCommodity->commodity()->first();
|
|
|
- if(!$commodity){
|
|
|
- dump("没订单");
|
|
|
- return;
|
|
|
- }
|
|
|
- $barcodeStr=$commodity->barcodes()->get()->map(function(CommodityBarcode $barcode){
|
|
|
- return $barcode['code'];
|
|
|
- })->filter(function($code){
|
|
|
- return $code&&(!preg_match('/[\x{4e00}-\x{9fa5}]/u',$code));
|
|
|
- })->join(',');
|
|
|
- $orderData['barcodes'][]=[
|
|
|
- 'id'=>$orderCommodity['id']??'',
|
|
|
- 'barcode_id'=>$barcodeStr??'',
|
|
|
- 'name'=>$commodity['name']??'',
|
|
|
- 'sku'=>$commodity['sku']??'',
|
|
|
- 'amount'=>$orderCommodity['amount']??'',
|
|
|
- 'location'=>$orderCommodity['location']??'',
|
|
|
- ];
|
|
|
- });
|
|
|
- $data['orders'][]=$orderData;
|
|
|
- });
|
|
|
- return $data;
|
|
|
- }
|
|
|
+
|
|
|
public function test(Request $request)
|
|
|
{
|
|
|
- dd((int)ceil(101/8));
|
|
|
- $codes = ['W123','W124'];
|
|
|
- $no = "";
|
|
|
- foreach ($codes as $code){
|
|
|
- $no .= "'".$code."',";
|
|
|
+ $path = '';
|
|
|
+ $id = 109;
|
|
|
+
|
|
|
+ $file = fopen($path, "r");
|
|
|
+ $user=array();
|
|
|
+ $i=0;
|
|
|
+ //输出文本中所有的行,直到文件结束为止。
|
|
|
+ while(! feof($file)){
|
|
|
+ $user[$i]= trim(fgets($file));//fgets()函数从文件指针中读取一行
|
|
|
+ $i++;
|
|
|
}
|
|
|
- $no = rtrim($no,',');
|
|
|
- $sql = <<<SQL
|
|
|
-SELECT WAVENO,COUNT(*) count from DOC_WAVE_DETAILS WHERE WAVENO IN ({$no}) GROUP BY WAVENO
|
|
|
-SQL;
|
|
|
- dd($sql);
|
|
|
- $code = 'W211108000002';
|
|
|
- $batch = null;
|
|
|
- if (!$code || !$batch = Batch::query()->select("id","split_size")->where("code",$code)->first())$this->error("无记录");
|
|
|
- $sql = <<<SQL
|
|
|
-SELECT a.ORDERNO,a.QTY,s.ALTERNATE_SKU1 FROM ACT_ALLOCATION_DETAILS a
|
|
|
- LEFT JOIN DOC_ORDER_HEADER o ON a.ORDERNO = o.ORDERNO
|
|
|
- LEFT JOIN DOC_WAVE_DETAILS w ON o.ORDERNO = w.ORDERNO
|
|
|
- LEFT JOIN BAS_SKU s ON a.SKU = s.SKU
|
|
|
-WHERE w.WAVENO = '{$code}' ORDER BY w.SEQNO
|
|
|
-SQL;
|
|
|
- $orders = DB::connection("oracle")->select(DB::raw($sql));
|
|
|
- $result = [];
|
|
|
- $currentList = [];
|
|
|
- $slowPointer = 0;
|
|
|
- $nodeSign = "";
|
|
|
- foreach ($orders as $order){
|
|
|
- if ($order->orderno!=$nodeSign){
|
|
|
- if ($slowPointer==$batch->split_size){
|
|
|
- $result[] = $currentList;
|
|
|
- $currentList = [];
|
|
|
- $slowPointer = 0;
|
|
|
- }
|
|
|
- $slowPointer++;
|
|
|
- $nodeSign = $order->orderno;
|
|
|
+ fclose($file);
|
|
|
+ foreach ($user as $item){
|
|
|
+ $arr = explode(",",$item);
|
|
|
+ if (count($arr)!=2){
|
|
|
+ dump($item);
|
|
|
+ continue;
|
|
|
}
|
|
|
- $currentList[] = ["barcode"=>$order->alternate_sku1,"qty"=>$order->qty];
|
|
|
+ DB::table("details")->insert([
|
|
|
+ "name" => $arr[0],
|
|
|
+ "size" => $arr[1],
|
|
|
+ "created_at" => date("Y-m-d H:i:s"),
|
|
|
+ "updated_at" => date("Y-m-d H:i:s"),
|
|
|
+ "header_id" => $id
|
|
|
+ ]);
|
|
|
}
|
|
|
- if ($currentList)$result[] = $currentList;
|
|
|
- dd($result);
|
|
|
- $request->offsetSet("station_id",'123456789');
|
|
|
- dd($this->process($request));
|
|
|
- echo 'Now memory_get_usage: ' . memory_get_usage() . '<br />';
|
|
|
- $t1 = microtime(true);
|
|
|
-// ... 执行代码 ...
|
|
|
- $t2 = microtime(true);
|
|
|
- echo '耗时'.round($t2-$t1,3).'秒<br>';
|
|
|
- echo 'Now memory_get_usage: ' . memory_get_usage() . '<br />';
|
|
|
- return;
|
|
|
- $a = new \App\Http\Controllers\api\thirdPart\syrius\producer\OrderController();
|
|
|
- dd($a->createOrder($this->t1())->body());
|
|
|
}
|
|
|
public function test1()
|
|
|
{
|