|
@@ -4,8 +4,10 @@ namespace App\Service;
|
|
|
|
|
|
use App\Model\DispatchSub;
|
|
|
use App\Model\Employee;
|
|
|
+use App\Model\EmployeeTeamPermission;
|
|
|
use App\Model\Equipment;
|
|
|
use App\Model\Process;
|
|
|
+use App\Model\SaleOrdersProduct;
|
|
|
use App\Model\Scrapp;
|
|
|
use App\Model\ScrappCount;
|
|
|
use App\Model\Team;
|
|
@@ -92,12 +94,12 @@ class ScrappService extends Service
|
|
|
//质检单
|
|
|
public function zjList($data, $user){
|
|
|
$model = ScrappCount::where('del_time',0)
|
|
|
- ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id')
|
|
|
+ ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id','sale_orders_product_id')
|
|
|
->groupBy('order_number');
|
|
|
|
|
|
if(! empty($data['order_number'])) {
|
|
|
$order_number = str_replace("ZJ","",$data['order_number']);
|
|
|
- if(! empty($order_number)) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
|
|
|
+ if(! empty($order_number)) $model->where('order_number', 'LIKE', '%'.$order_number.'%');
|
|
|
}
|
|
|
if(! empty($data['dispatch_no'])) {
|
|
|
$dispatch_id = DispatchSub::where('del_time',0)
|
|
@@ -107,7 +109,21 @@ class ScrappService extends Service
|
|
|
$dispatch_id = array_column($dispatch_id,'id');
|
|
|
$model->whereIn('dispatch_sub_id', $dispatch_id);
|
|
|
}
|
|
|
+ if(! empty($data['sale_order_number'])) {
|
|
|
+ $sales_id = SaleOrdersProduct::where('del_time',0)
|
|
|
+ ->where('out_order_no', 'LIKE', '%'.$data['sale_order_number'].'%')
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $sales_id = array_column($sales_id,'id');
|
|
|
+ $model->whereIn('sale_orders_product_id', $sales_id);
|
|
|
+ }
|
|
|
if(! empty($data['team_id'])) $model->where('team_id', $data['team_id']);
|
|
|
+ if(! empty($data['team_man_id'])) {
|
|
|
+ $team_id = EmployeeTeamPermission::where('employee_id',$data['team_man_id'])
|
|
|
+ ->select('team_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('team_id', array_unique(array_column($team_id,'team_id')));
|
|
|
+ }
|
|
|
if(! empty($data['finished_id'])) $model->where('finished_id', $data['finished_id']);
|
|
|
if(! empty($data['equipment_id'])) $model->where('equipment_id', $data['equipment_id']);
|
|
|
if(! empty($data['process_id'])) $model->where('process_id', $data['process_id']);
|
|
@@ -120,26 +136,48 @@ class ScrappService extends Service
|
|
|
|
|
|
public function fillZjList($data){
|
|
|
if(empty($data['data'])) return $data;
|
|
|
-
|
|
|
- $emp_map = Employee::whereIn('id',array_column($data['data'],'finished_id'))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $team_maps = Team::whereIn('id',array_column($data['data'],'team_id'))
|
|
|
+ $team_id = array_unique(array_column($data['data'],'team_id'));
|
|
|
+ $team_maps = Team::whereIn('id',$team_id)
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
+ $team_man = EmployeeTeamPermission::whereIn('team_id',$team_id)
|
|
|
+ ->select('team_id','employee_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $emp_map = Employee::whereIn('id',array_merge_recursive(array_column($data['data'],'finished_id'),array_column($team_man,'employee_id')))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $team_man_maps = [];
|
|
|
+ foreach ($team_man as $value){
|
|
|
+ $t = $emp_map[$value['employee_id']] ?? "";
|
|
|
+ if(empty($t)) continue;
|
|
|
+ if(isset($team_man_maps[$value['team_id']])){
|
|
|
+ $team_man_maps[$value['team_id']] .= ',' . $t;
|
|
|
+ }else{
|
|
|
+ $team_man_maps[$value['team_id']] = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
$equipment_map = Equipment::whereIn('id',array_column($data['data'],'equipment_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
$process_map = Process::whereIn('id',array_column($data['data'],'process_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
+ $sales_number = SaleOrdersProduct::whereIn('id',array_unique(array_column($data['data'],'sale_orders_product_id')))
|
|
|
+ ->pluck('out_order_no','id')
|
|
|
+ ->toArray();
|
|
|
+ $dispatch_no = DispatchSub::whereIn('id',array_column($data['data'], 'dispatch_sub_id'))
|
|
|
+ ->pluck('dispatch_no','id')
|
|
|
+ ->toArray();
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date("Y-m-d H:i:s", $value['crt_time']) : '';
|
|
|
$data['data'][$key]['finished_title'] = $emp_map[$value['finished_id']] ?? '';
|
|
|
$data['data'][$key]['team_title'] = $team_maps[$value['team_id']] ?? '';
|
|
|
+ $data['data'][$key]['team_man'] = $team_man_maps[$value['team_id']] ?? '';
|
|
|
$data['data'][$key]['equipment_title'] = $equipment_map[$value['equipment_id']] ?? '';
|
|
|
$data['data'][$key]['process_title'] = $process_map[$value['process_id']] ?? '';
|
|
|
$data['data'][$key]['order_number'] = "ZJ" . $value['order_number'];
|
|
|
+ $data['data'][$key]['sale_order_number'] = $sales_number[$value['sale_orders_product_id']] ?? "";
|
|
|
+ $data['data'][$key]['dispatch_no'] = $dispatch_no[$value['dispatch_sub_id']] ?? "";
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
@@ -162,7 +200,25 @@ class ScrappService extends Service
|
|
|
$order['equipment_title'] = Equipment::where('id',$first['equipment_id'])->value("title");
|
|
|
$dispatch = DispatchSub::where('id',$first['dispatch_sub_id'])->first();
|
|
|
$dispatch = empty($dispatch) ? [] : $dispatch->toArray();
|
|
|
- $order['dispatch_no'] = $dispatch['order_no'] ?? "";
|
|
|
+ $order['dispatch_no'] = $dispatch['dispatch_no'] ?? "";
|
|
|
+
|
|
|
+ $team_man = EmployeeTeamPermission::where('team_id',$first['team_id'])
|
|
|
+ ->select('team_id','employee_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $emp_map = Employee::whereIn('id',array_column($team_man,'employee_id'))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $team_man_maps = "";
|
|
|
+ foreach ($team_man as $value){
|
|
|
+ $t = $emp_map[$value['employee_id']] ?? "";
|
|
|
+ if(empty($t)) continue;
|
|
|
+ if(! empty($team_man_maps)){
|
|
|
+ $team_man_maps .= ',' . $t;
|
|
|
+ }else{
|
|
|
+ $team_man_maps = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $order['team_man'] = $team_man_maps;
|
|
|
|
|
|
$scrapp_quantity = array_sum(array_column($result, 'scrapp_num')); // 不良品数量
|
|
|
$detail = [
|
|
@@ -170,8 +226,7 @@ class ScrappService extends Service
|
|
|
'product_title' => $first['product_title'],
|
|
|
'product_size' => $first['product_size'],
|
|
|
'product_unit' => $first['product_unit'],
|
|
|
- 'technology_material' => $first['technology_material'],
|
|
|
- 'wood_name' => $first['wood_name'],
|
|
|
+ 'technology_name' => $first['technology_name'],
|
|
|
'production_quantity' => $dispatch['production_quantity'] ?? 0, // 生产数量
|
|
|
'dispatch_quantity' => $dispatch['dispatch_quantity'] ?? 0, // 派工数量
|
|
|
'quantity' => $first['quantity'], // 完工数量
|
|
@@ -188,12 +243,12 @@ class ScrappService extends Service
|
|
|
//不良品
|
|
|
public function blpList($data, $user){
|
|
|
$model = ScrappCount::where('del_time',0)
|
|
|
- ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id')
|
|
|
+ ->select('id','dispatch_sub_id','crt_time','team_id','finished_id','equipment_id','order_number','process_id','sale_orders_product_id')
|
|
|
->groupBy('order_number');
|
|
|
|
|
|
if(! empty($data['order_number'])) {
|
|
|
$order_number = str_replace("BLP","",$data['order_number']);
|
|
|
- if(! empty($order_number)) $model->where('order_number', 'LIKE', '%'.$data['order_number'].'%');
|
|
|
+ if(! empty($order_number)) $model->where('order_number', 'LIKE', '%'.$order_number.'%');
|
|
|
}
|
|
|
if(! empty($data['dispatch_no'])) {
|
|
|
$dispatch_id = DispatchSub::where('del_time',0)
|
|
@@ -203,8 +258,22 @@ class ScrappService extends Service
|
|
|
$dispatch_id = array_column($dispatch_id,'id');
|
|
|
$model->whereIn('dispatch_sub_id', $dispatch_id);
|
|
|
}
|
|
|
+ if(! empty($data['sale_order_number'])) {
|
|
|
+ $sales_id = SaleOrdersProduct::where('del_time',0)
|
|
|
+ ->where('out_order_no', 'LIKE', '%'.$data['sale_order_number'].'%')
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $sales_id = array_column($sales_id,'id');
|
|
|
+ $model->whereIn('sale_orders_product_id', $sales_id);
|
|
|
+ }
|
|
|
if(! empty($data['team_id'])) $model->where('team_id', $data['team_id']);
|
|
|
if(! empty($data['finished_id'])) $model->where('finished_id', $data['finished_id']);
|
|
|
+ if(! empty($data['team_man_id'])) {
|
|
|
+ $team_id = EmployeeTeamPermission::where('employee_id',$data['team_man_id'])
|
|
|
+ ->select('team_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $model->whereIn('team_id', array_unique(array_column($team_id,'team_id')));
|
|
|
+ }
|
|
|
if(! empty($data['equipment_id'])) $model->where('equipment_id', $data['equipment_id']);
|
|
|
if(! empty($data['process_id'])) $model->where('process_id', $data['process_id']);
|
|
|
|
|
@@ -217,25 +286,48 @@ class ScrappService extends Service
|
|
|
public function fillBLPList($data){
|
|
|
if(empty($data['data'])) return $data;
|
|
|
|
|
|
- $emp_map = Employee::whereIn('id',array_column($data['data'],'finished_id'))
|
|
|
- ->pluck('emp_name','id')
|
|
|
- ->toArray();
|
|
|
- $team_maps = Team::whereIn('id',array_column($data['data'],'team_id'))
|
|
|
+ $team_id = array_unique(array_column($data['data'],'team_id'));
|
|
|
+ $team_maps = Team::whereIn('id',$team_id)
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
+ $team_man = EmployeeTeamPermission::whereIn('team_id',$team_id)
|
|
|
+ ->select('team_id','employee_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $emp_map = Employee::whereIn('id',array_merge_recursive(array_column($data['data'],'finished_id'),array_column($team_man,'employee_id')))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $team_man_maps = [];
|
|
|
+ foreach ($team_man as $value){
|
|
|
+ $t = $emp_map[$value['employee_id']] ?? "";
|
|
|
+ if(empty($t)) continue;
|
|
|
+ if(isset($team_man_maps[$value['team_id']])){
|
|
|
+ $team_man_maps[$value['team_id']] .= ',' . $t;
|
|
|
+ }else{
|
|
|
+ $team_man_maps[$value['team_id']] = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
$equipment_map = Equipment::whereIn('id',array_column($data['data'],'equipment_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
$process_map = Process::whereIn('id',array_column($data['data'],'process_id'))
|
|
|
->pluck('title','id')
|
|
|
->toArray();
|
|
|
+ $sales_number = SaleOrdersProduct::whereIn('id',array_unique(array_column($data['data'],'sale_orders_product_id')))
|
|
|
+ ->pluck('out_order_no','id')
|
|
|
+ ->toArray();
|
|
|
+ $dispatch_no = DispatchSub::whereIn('id',array_column($data['data'], 'dispatch_sub_id'))
|
|
|
+ ->pluck('dispatch_no','id')
|
|
|
+ ->toArray();
|
|
|
foreach ($data['data'] as $key => $value){
|
|
|
$data['data'][$key]['crt_time'] = $value['crt_time'] ? date("Y-m-d H:i:s", $value['crt_time']) : '';
|
|
|
$data['data'][$key]['finished_title'] = $emp_map[$value['finished_id']] ?? '';
|
|
|
$data['data'][$key]['team_title'] = $team_maps[$value['team_id']] ?? '';
|
|
|
+ $data['data'][$key]['team_man'] = $team_man_maps[$value['team_id']] ?? '';
|
|
|
$data['data'][$key]['equipment_title'] = $equipment_map[$value['equipment_id']] ?? '';
|
|
|
$data['data'][$key]['process_title'] = $process_map[$value['process_id']] ?? '';
|
|
|
$data['data'][$key]['order_number'] = "BLP" . $value['order_number'];
|
|
|
+ $data['data'][$key]['sale_order_number'] = $sales_number[$value['sale_orders_product_id']] ?? "";
|
|
|
+ $data['data'][$key]['dispatch_no'] = $dispatch_no[$value['dispatch_sub_id']] ?? "";
|
|
|
}
|
|
|
|
|
|
return $data;
|
|
@@ -258,7 +350,25 @@ class ScrappService extends Service
|
|
|
$order['equipment_title'] = Equipment::where('id',$first['equipment_id'])->value("title");
|
|
|
$dispatch = DispatchSub::where('id',$first['dispatch_sub_id'])->first();
|
|
|
$dispatch = empty($dispatch) ? [] : $dispatch->toArray();
|
|
|
- $order['dispatch_no'] = $dispatch['order_no'] ?? "";
|
|
|
+ $order['dispatch_no'] = $dispatch['dispatch_no'] ?? "";
|
|
|
+
|
|
|
+ $team_man = EmployeeTeamPermission::where('team_id',$first['team_id'])
|
|
|
+ ->select('team_id','employee_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $emp_map = Employee::whereIn('id',array_column($team_man,'employee_id'))
|
|
|
+ ->pluck('emp_name','id')
|
|
|
+ ->toArray();
|
|
|
+ $team_man_maps = "";
|
|
|
+ foreach ($team_man as $value){
|
|
|
+ $t = $emp_map[$value['employee_id']] ?? "";
|
|
|
+ if(empty($t)) continue;
|
|
|
+ if(! empty($team_man_maps)){
|
|
|
+ $team_man_maps .= ',' . $t;
|
|
|
+ }else{
|
|
|
+ $team_man_maps = $t;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $order['team_man'] = $team_man_maps;
|
|
|
|
|
|
$scrapp = Scrapp::whereIn('id', array_unique(array_column($result,'scrapp_id')))
|
|
|
->pluck('title','id')
|
|
@@ -270,8 +380,7 @@ class ScrappService extends Service
|
|
|
'product_title' => $first['product_title'],
|
|
|
'product_size' => $first['product_size'],
|
|
|
'product_unit' => $first['product_unit'],
|
|
|
- 'technology_material' => $first['technology_material'],
|
|
|
- 'wood_name' => $first['wood_name'],
|
|
|
+ 'technology_name' => $first['technology_name'],
|
|
|
'scrapp_quantity' => $value['scrapp_num'], // 不良品数量
|
|
|
'scrapp_title' => $scrapp[$value['scrapp_id']], // 不良品原因
|
|
|
];
|