|
@@ -95,28 +95,25 @@ class SortingController extends Controller
|
|
|
$start = (($childIndex-1)*$batch->split_size)+1;
|
|
$start = (($childIndex-1)*$batch->split_size)+1;
|
|
|
$end = $childIndex*$batch->split_size;
|
|
$end = $childIndex*$batch->split_size;
|
|
|
$sql = <<<SQL
|
|
$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}
|
|
|
|
|
|
|
+SELECT ORDERNO FROM DOC_WAVE_DETAILS WHERE WAVENO = '{$batch_id}' AND SEQNO BETWEEN {$start} AND {$end};
|
|
|
SQL;
|
|
SQL;
|
|
|
$waves = DB::connection("oracle")->select(DB::raw($sql));
|
|
$waves = DB::connection("oracle")->select(DB::raw($sql));
|
|
|
$codes = array_column($waves,'orderno');
|
|
$codes = array_column($waves,'orderno');
|
|
|
- $orders = Order::query()->whereIn("code",$codes)->get();
|
|
|
|
|
- }else $orders = $batch->orders()->get();
|
|
|
|
|
|
|
+ $orders = Order::query()->with(["bin","owner","orderCommodities.commodity.barcodes"])->whereIn("code",$codes)->get();
|
|
|
|
|
+ }else $orders = $batch->orders()->with(["bin","owner","orderCommodities.commodity.barcodes"])->get();
|
|
|
|
|
|
|
|
$ordersSorted=$orders->sortBy(function(Order $order){
|
|
$ordersSorted=$orders->sortBy(function(Order $order){
|
|
|
- return $order->bin()->first()['number'];
|
|
|
|
|
|
|
+ return $order->bin->number;
|
|
|
});
|
|
});
|
|
|
$ordersSorted->each(function(Order $order)use(&$data,$request,$childIndex,$batch){
|
|
$ordersSorted->each(function(Order $order)use(&$data,$request,$childIndex,$batch){
|
|
|
if($order['status']=='取消')return;
|
|
if($order['status']=='取消')return;
|
|
|
$orderData=[
|
|
$orderData=[
|
|
|
'order_id'=>$order['code'],
|
|
'order_id'=>$order['code'],
|
|
|
- 'owner'=>$order->owner()->first()['code'],
|
|
|
|
|
|
|
+ 'owner'=>$order->owner->code,
|
|
|
'status'=>$order['status']=='未处理'?'available':$order['status'],
|
|
'status'=>$order['status']=='未处理'?'available':$order['status'],
|
|
|
'created_at'=>$order['created_at']->toDateTimeString(),
|
|
'created_at'=>$order['created_at']->toDateTimeString(),
|
|
|
'bin'=>(function()use($order,$childIndex,$batch){
|
|
'bin'=>(function()use($order,$childIndex,$batch){
|
|
|
- $bin=$order->bin()->first()['number']??'';
|
|
|
|
|
|
|
+ $bin=$order->bin->number??'';
|
|
|
if(!$bin){
|
|
if(!$bin){
|
|
|
$bin=OracleDOCWaveDetails::query()->where('orderno', 'SO201230003574')->get('seqno')->first()['seqno']??'';
|
|
$bin=OracleDOCWaveDetails::query()->where('orderno', 'SO201230003574')->get('seqno')->first()['seqno']??'';
|
|
|
LogService::log(__METHOD__,__FUNCTION__,'bin缺失补查:'.$bin.'. order:'.$order->toJson());
|
|
LogService::log(__METHOD__,__FUNCTION__,'bin缺失补查:'.$bin.'. order:'.$order->toJson());
|
|
@@ -126,13 +123,13 @@ SQL;
|
|
|
})(),
|
|
})(),
|
|
|
'barcodes'=>[]
|
|
'barcodes'=>[]
|
|
|
];
|
|
];
|
|
|
- $order->orderCommodities()->each(function(OrderCommodity $orderCommodity)use(&$orderData,$request){
|
|
|
|
|
- $commodity=$orderCommodity->commodity()->first();
|
|
|
|
|
|
|
+ $order->orderCommodities->each(function(OrderCommodity $orderCommodity)use(&$orderData,$request){
|
|
|
|
|
+ $commodity=$orderCommodity->commodity;
|
|
|
if(!$commodity){
|
|
if(!$commodity){
|
|
|
app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, '播种位数据准备出错,找不到订单对应的Commodity id的对象'.$orderCommodity['commodity_id'].',是否表数据在波次生成后丢失?'.json_encode($request->all()));
|
|
app('LogService')->log(__METHOD__, 'error' . __FUNCTION__, '播种位数据准备出错,找不到订单对应的Commodity id的对象'.$orderCommodity['commodity_id'].',是否表数据在波次生成后丢失?'.json_encode($request->all()));
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- $barcodeStr=$commodity->barcodes()->get()->map(function(CommodityBarcode $barcode){
|
|
|
|
|
|
|
+ $barcodeStr=$commodity->barcodes->map(function(CommodityBarcode $barcode){
|
|
|
return $barcode['code'];
|
|
return $barcode['code'];
|
|
|
})->filter(function($code){
|
|
})->filter(function($code){
|
|
|
return $code&&(!preg_match('/[\x{4e00}-\x{9fa5}]/u',$code));
|
|
return $code&&(!preg_match('/[\x{4e00}-\x{9fa5}]/u',$code));
|