|
@@ -4573,24 +4573,35 @@ class ApplyOrderService extends Service
|
|
|
}
|
|
|
|
|
|
public function reportList($data){
|
|
|
- $model = ReportMessage::where('del_time',0)
|
|
|
+ $result = ReportMessage::where('del_time',0)
|
|
|
+ ->where('crt_time',">=",strtotime(date('Y-m-01 00:00:00')))
|
|
|
->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use','report_working_id')
|
|
|
- ->orderBy('id','desc');
|
|
|
+ ->orderBy('id','asc')
|
|
|
+ ->get()->toArray();
|
|
|
+ $list = $this->fillRData($result, $data);
|
|
|
|
|
|
- $list = $this->limit($model,'',$data);
|
|
|
- $list = $this->fillRData($list, $data);
|
|
|
+ $page_index = intval(request('page_index', 1)); // 当前页
|
|
|
+ $page_size = intval(request('page_size', 40)); // 每页数量
|
|
|
+
|
|
|
+ $total = count($list);
|
|
|
+ $offset = ($page_index - 1) * $page_size;
|
|
|
+ $pagedData = array_slice($list, $offset, $page_size);
|
|
|
+ $result = [
|
|
|
+ 'total' => $total,
|
|
|
+ 'data' => $pagedData,
|
|
|
+ ];
|
|
|
|
|
|
$count = ReportMessage::where('del_time',0)
|
|
|
->where('is_use',0)
|
|
|
->count();
|
|
|
|
|
|
- return [true, ['list'=> $list, 'count' => $count]];
|
|
|
+ return [true, ['list'=> $result, 'count' => $count]];
|
|
|
}
|
|
|
|
|
|
public function fillRData($data, $erg){
|
|
|
- if(empty($data['data'])) return $data;
|
|
|
+ if(empty($data)) return $data;
|
|
|
|
|
|
- $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
|
|
|
+ $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data,'order_id')))
|
|
|
->select('id','dispatch_no','process_id')
|
|
|
->get()->toArray();
|
|
|
$process = Process::where('del_time',0)
|
|
@@ -4602,54 +4613,81 @@ class ApplyOrderService extends Service
|
|
|
foreach ($dispatch as $value){
|
|
|
$map[$value['id']] = $value;
|
|
|
}
|
|
|
- $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
|
|
|
+ $emp_map = Employee::whereIn('id',array_unique(array_column($data,'user_id')))
|
|
|
->pluck("emp_name",'id')
|
|
|
->toArray();
|
|
|
- $order_map = ReportWorking::whereIn('id',array_filter(array_column($data['data'],'report_working_id')))
|
|
|
+ $order_map = ReportWorking::whereIn('id',array_filter(array_column($data,'report_working_id')))
|
|
|
->pluck('order_number','id')
|
|
|
->toArray();
|
|
|
- $no_need = isset($erg['not_need']) ? 1 : 0;
|
|
|
- foreach ($data['data'] as $key => $value){
|
|
|
+
|
|
|
+ $map_2 = [];
|
|
|
+ $map_3 = [];
|
|
|
+ foreach ($data as $key => $value){
|
|
|
$time = $value['crt_time'] ? date('Y-m-d',$value['crt_time']) : '';
|
|
|
- $data['data'][$key]['crt_time'] = $time;
|
|
|
+ $data[$key]['crt_time'] = $time;
|
|
|
$t = $map[$value['order_id']] ?? [];
|
|
|
$e = $emp_map[$value['user_id']] ?? "";
|
|
|
$p = $process[$t['process_id']] ?? [];
|
|
|
$p_t = $p['title'] ?? "";
|
|
|
- if($p['zj_type'] == 0){
|
|
|
- $p_t .= ":无需质检";
|
|
|
- }elseif($p['zj_type'] == 1){
|
|
|
- $p_t .= ":全检";
|
|
|
- }else{
|
|
|
- $p_t .= ":抽检";
|
|
|
+ $type = Process::$type[$p['zj_type']] ?? "";
|
|
|
+ if(! empty($type)){
|
|
|
+ $p_t .= ":" . $type;
|
|
|
}
|
|
|
- if(! $no_need){
|
|
|
- if(empty($value['report_working_id'])){
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
- }else{
|
|
|
- $tmp = $order_map[$value['report_working_id']] ?? "";
|
|
|
- if(empty($tmp)){
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
+
|
|
|
+ if($t['process_id'] == 14){
|
|
|
+ if(isset($map_2[$value['order_id']])){
|
|
|
+ $tmp = bcadd(0.75, $map_2[$value['order_id']],3);
|
|
|
+ $map_2[$value['order_id']] = $tmp;
|
|
|
+ if($tmp == 9){
|
|
|
+ $title = "中检";
|
|
|
+ }elseif($tmp >= 12){
|
|
|
+ $title = "尾检";
|
|
|
+ unset($map_2[$value['order_id']]);
|
|
|
}else{
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
|
|
|
+ unset($data[$key]);
|
|
|
+ continue;
|
|
|
}
|
|
|
+ }else{
|
|
|
+ $title = "首检";
|
|
|
+ $map_2[$value['order_id']] = 0.75;
|
|
|
}
|
|
|
+
|
|
|
+ $p_t .= $title;
|
|
|
}else{
|
|
|
- if(empty($value['report_working_id'])){
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
- }else{
|
|
|
- $tmp = $order_map[$value['report_working_id']] ?? "";
|
|
|
- if(empty($tmp)){
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
+ if(isset($map_3[$value['order_id']])){
|
|
|
+ $tmp = bcadd(0.75, $map_3[$value['order_id']],3);
|
|
|
+ $map_3[$value['order_id']] = $tmp;
|
|
|
+ if($tmp == 9){
|
|
|
+ }elseif($tmp >= 15){
|
|
|
+ unset($map_3[$value['order_id']]);
|
|
|
}else{
|
|
|
- $str = "派工单:" . $t['dispatch_no'] . "由($e)完成工序报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
|
|
|
+ unset($data[$key]);
|
|
|
+ continue;
|
|
|
}
|
|
|
+ }else{
|
|
|
+ $map_3[$value['order_id']] = 0.75;
|
|
|
}
|
|
|
}
|
|
|
- $data['data'][$key]['message'] = $str;
|
|
|
+ if(empty($value['report_working_id'])){
|
|
|
+ $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
+ }else{
|
|
|
+ $tmp = $order_map[$value['report_working_id']] ?? "";
|
|
|
+ if(empty($tmp)){
|
|
|
+ $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工,数量{$value['quantity']}吨,请及时处理";
|
|
|
+ }else{
|
|
|
+ $str = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p_t)报工({$tmp}),数量{$value['quantity']}吨,请及时处理";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $data[$key]['message'] = $str;
|
|
|
+ $data[$key]['process_id'] = $t['process_id'];
|
|
|
}
|
|
|
|
|
|
- return $data;
|
|
|
+ $data = array_values($data);
|
|
|
+ usort($data, function($a, $b) {
|
|
|
+ return $b['id'] <=> $a['id'];
|
|
|
+ });
|
|
|
+
|
|
|
+ return array_values($data);
|
|
|
}
|
|
|
|
|
|
public function reportRemainUpdate($data){
|