|
@@ -7,10 +7,12 @@ use App\Model\ApplyOrderDetail;
|
|
use App\Model\Box;
|
|
use App\Model\Box;
|
|
use App\Model\DispatchSub;
|
|
use App\Model\DispatchSub;
|
|
use App\Model\Employee;
|
|
use App\Model\Employee;
|
|
|
|
+use App\Model\EmployeeTeamPermission;
|
|
use App\Model\InOutRecord;
|
|
use App\Model\InOutRecord;
|
|
use App\Model\Process;
|
|
use App\Model\Process;
|
|
use App\Model\ReportWorking;
|
|
use App\Model\ReportWorking;
|
|
use App\Model\ReportWorkingDetail;
|
|
use App\Model\ReportWorkingDetail;
|
|
|
|
+use App\Model\Team;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class ApplyOrderService extends Service
|
|
class ApplyOrderService extends Service
|
|
@@ -480,7 +482,7 @@ class ApplyOrderService extends Service
|
|
|
|
|
|
//报工
|
|
//报工
|
|
public function reportWorkingEdit($data, $user){
|
|
public function reportWorkingEdit($data, $user){
|
|
- list($status,$msg) = $this->MaterialRule($data,false);
|
|
|
|
|
|
+ list($status,$msg) = $this->reportWorkingRule($data,false);
|
|
if(!$status) return [$status,$msg];
|
|
if(!$status) return [$status,$msg];
|
|
|
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|
|
@@ -497,17 +499,30 @@ class ApplyOrderService extends Service
|
|
'del_time' => $time
|
|
'del_time' => $time
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
+ //班组下的人
|
|
|
|
+ $team_man = [];
|
|
|
|
+ $model_t = new EmployeeTeamPermission();
|
|
|
|
+ $team_array = $model_t->select('employee_id', 'team_id')->get()->toArray();
|
|
|
|
+ foreach ($team_array as $v){
|
|
|
|
+ $team_man[$v['team_id']][] = $v['employee_id'];
|
|
|
|
+ }
|
|
|
|
+
|
|
$detail_insert = [];
|
|
$detail_insert = [];
|
|
foreach ($data['order_data'] as $v){
|
|
foreach ($data['order_data'] as $v){
|
|
- $detail_insert[] = [
|
|
|
|
- 'report_working_id' => $id,
|
|
|
|
- 'data_id' => $v['id'],
|
|
|
|
- 'quantity' => $v['quantity'] ?? 0,
|
|
|
|
- 'process_id' => $v['process_id'] ?? 0,
|
|
|
|
- 'finished_id' => $v['finished_id'] ?? 0,
|
|
|
|
- 'crt_time' => $time,
|
|
|
|
- ];
|
|
|
|
|
|
+ $t = $team_man[$v['team_id']] ?? [];
|
|
|
|
+ foreach ($t as $t_v){
|
|
|
|
+ $detail_insert[] = [
|
|
|
|
+ 'report_working_id' => $id,
|
|
|
|
+ 'data_id' => $v['id'],
|
|
|
|
+ 'quantity' => $v['quantity'] ?? 0,
|
|
|
|
+ 'process_id' => $v['process_id'] ?? 0,
|
|
|
|
+ 'finished_id' => $t_v,
|
|
|
|
+ 'team_id' => $v['team_id'],
|
|
|
|
+ 'crt_time' => $time,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
ReportWorkingDetail::insert($detail_insert);
|
|
ReportWorkingDetail::insert($detail_insert);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -533,17 +548,30 @@ class ApplyOrderService extends Service
|
|
$model->save();
|
|
$model->save();
|
|
$id = $model->id;
|
|
$id = $model->id;
|
|
|
|
|
|
|
|
+ //班组下的人
|
|
|
|
+ $team_man = [];
|
|
|
|
+ $model_t = new EmployeeTeamPermission();
|
|
|
|
+ $team_array = $model_t->select('employee_id', 'team_id')->get()->toArray();
|
|
|
|
+ foreach ($team_array as $v){
|
|
|
|
+ $team_man[$v['team_id']][] = $v['employee_id'];
|
|
|
|
+ }
|
|
|
|
+
|
|
$detail_insert = [];
|
|
$detail_insert = [];
|
|
foreach ($data['order_data'] as $v){
|
|
foreach ($data['order_data'] as $v){
|
|
- $detail_insert[] = [
|
|
|
|
- 'report_working_id' => $id,
|
|
|
|
- 'data_id' => $v['id'],
|
|
|
|
- 'quantity' => $v['quantity'] ?? 0,
|
|
|
|
- 'process_id' => $v['process_id'] ?? 0,
|
|
|
|
- 'finished_id' => $v['finished_id'] ?? 0,
|
|
|
|
- 'crt_time' => $time,
|
|
|
|
- ];
|
|
|
|
|
|
+ $t = $team_man[$v['team_id']] ?? [];
|
|
|
|
+ foreach ($t as $t_v){
|
|
|
|
+ $detail_insert[] = [
|
|
|
|
+ 'report_working_id' => $id,
|
|
|
|
+ 'data_id' => $v['id'],
|
|
|
|
+ 'quantity' => $v['quantity'] ?? 0,
|
|
|
|
+ 'process_id' => $v['process_id'] ?? 0,
|
|
|
|
+ 'finished_id' => $t_v,
|
|
|
|
+ 'team_id' => $v['team_id'],
|
|
|
|
+ 'crt_time' => $time,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
ReportWorkingDetail::insert($detail_insert);
|
|
ReportWorkingDetail::insert($detail_insert);
|
|
|
|
|
|
DB::commit();
|
|
DB::commit();
|
|
@@ -632,32 +660,37 @@ class ApplyOrderService extends Service
|
|
//派工单
|
|
//派工单
|
|
$d = DispatchSub::where('del_time',0)
|
|
$d = DispatchSub::where('del_time',0)
|
|
->whereIn('id', $apply_id)
|
|
->whereIn('id', $apply_id)
|
|
- ->select('id', 'dispatch_no as order_no', 'product_title','technology_material','wood_name','product_no','process_id','product_unit','price')
|
|
|
|
|
|
+ ->select('id', 'dispatch_no as order_no', 'product_title','technology_material','wood_name','product_no','process_id','product_unit','price','product_size')
|
|
->get()->toArray();
|
|
->get()->toArray();
|
|
$d_tmp = array_column($d,null,'id');
|
|
$d_tmp = array_column($d,null,'id');
|
|
|
|
|
|
$process_map = Process::whereIn('id',array_unique(array_column($d,'process_id')))
|
|
$process_map = Process::whereIn('id',array_unique(array_column($d,'process_id')))
|
|
->pluck('title','id')
|
|
->pluck('title','id')
|
|
->toArray();
|
|
->toArray();
|
|
|
|
+ $team_map = Team::pluck('title','id')->toArray();
|
|
|
|
+
|
|
$return = [];
|
|
$return = [];
|
|
foreach ($apply_d as $t){
|
|
foreach ($apply_d as $t){
|
|
$tmp = $d_tmp[$t['data_id']] ?? [];
|
|
$tmp = $d_tmp[$t['data_id']] ?? [];
|
|
|
|
|
|
- $return[] = [
|
|
|
|
- 'id' => $t['data_id'] ?? 0,
|
|
|
|
- 'quantity' => $t['quantity'] ?? 0,
|
|
|
|
- 'product_no' => $tmp['product_no'] ?? "",
|
|
|
|
- 'product_title' => $tmp['product_title'] ?? "",
|
|
|
|
- 'product_size' => $tmp['product_size'] ?? "",
|
|
|
|
- 'product_unit' => $tmp['product_unit'] ?? "",
|
|
|
|
- 'technology_material' => $tmp['technology_material'] ?? "",
|
|
|
|
- 'wood_name' => $tmp['wood_name'] ?? "",
|
|
|
|
- 'order_no' => $tmp['order_no'] ?? "",
|
|
|
|
- 'process_id' => $tmp['process_id'] ?? 0,
|
|
|
|
- 'process_title' => $process_map[$tmp['process_id']] ?? "",
|
|
|
|
- 'price' => $tmp['price'] ?? 0,
|
|
|
|
- 'total' => bcmul(($tmp['price'] ?? 0),$t['quantity'],2)
|
|
|
|
- ];
|
|
|
|
|
|
+ $str = $t['data_id'] . $t['process_id'];
|
|
|
|
+ if(! isset($return[$str])){
|
|
|
|
+ $return[$str] = [
|
|
|
|
+ 'id' => $t['data_id'] ?? 0,
|
|
|
|
+ 'quantity' => $t['quantity'] ?? 0,
|
|
|
|
+ 'product_no' => $tmp['product_no'] ?? "",
|
|
|
|
+ 'product_title' => $tmp['product_title'] ?? "",
|
|
|
|
+ 'product_size' => $tmp['product_size'] ?? "",
|
|
|
|
+ 'product_unit' => $tmp['product_unit'] ?? "",
|
|
|
|
+ 'technology_material' => $tmp['technology_material'] ?? "",
|
|
|
|
+ 'wood_name' => $tmp['wood_name'] ?? "",
|
|
|
|
+ 'order_no' => $tmp['order_no'] ?? "",
|
|
|
|
+ 'process_id' => $tmp['process_id'] ?? 0,
|
|
|
|
+ 'process_name' => $process_map[$tmp['process_id']] ?? "",
|
|
|
|
+ 'team_id' => $t['team_id'] ?? 0,
|
|
|
|
+ 'team_title' => $team_map[$t['team_id']] ?? '',
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
$detail['order_data'] = $return;
|
|
$detail['order_data'] = $return;
|
|
@@ -666,13 +699,13 @@ class ApplyOrderService extends Service
|
|
}
|
|
}
|
|
|
|
|
|
public function reportWorkingRule(&$data,$is_add = true){
|
|
public function reportWorkingRule(&$data,$is_add = true){
|
|
- if($this->isEmpty($data,'apply_id')) return [false,'申请人不能为空'];
|
|
|
|
if($this->isEmpty($data,'report_time')) return [false,'报工时间不能为空'];
|
|
if($this->isEmpty($data,'report_time')) return [false,'报工时间不能为空'];
|
|
if(empty($data['order_data'])) return [false, '报工单详细信息不能为空'];
|
|
if(empty($data['order_data'])) return [false, '报工单详细信息不能为空'];
|
|
foreach ($data['order_data'] as $value){
|
|
foreach ($data['order_data'] as $value){
|
|
if(empty($value['id'])) return [false, '报工单详细信息ID不能为空'];
|
|
if(empty($value['id'])) return [false, '报工单详细信息ID不能为空'];
|
|
if(empty($value['quantity'])) return [false, '报工单详细信息数量不能为空'];
|
|
if(empty($value['quantity'])) return [false, '报工单详细信息数量不能为空'];
|
|
if(empty($value['process_id'])) return [false, '报工单详细信息工序不能为空'];
|
|
if(empty($value['process_id'])) return [false, '报工单详细信息工序不能为空'];
|
|
|
|
+ if(empty($value['team_id'])) return [false, '报工单详细信息班组不能为空'];
|
|
}
|
|
}
|
|
|
|
|
|
$id = array_unique(array_column($data['order_data'],'id'));
|
|
$id = array_unique(array_column($data['order_data'],'id'));
|