|
@@ -14,6 +14,7 @@ use App\Model\Equipment;
|
|
|
use App\Model\InOutRecord;
|
|
|
use App\Model\OrdersProduct;
|
|
|
use App\Model\Process;
|
|
|
+use App\Model\ReportMessage;
|
|
|
use App\Model\ReportWorking;
|
|
|
use App\Model\ReportWorkingDetail;
|
|
|
use App\Model\SaleOrdersProduct;
|
|
@@ -799,8 +800,25 @@ class ApplyOrderService extends Service
|
|
|
$team_man[$v['team_id']][] = $v['employee_id'];
|
|
|
}
|
|
|
|
|
|
+ $process = Process::where('del_time',0)
|
|
|
+ ->where('is_need_remain',1)
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $process_id = array_column($process,'id');
|
|
|
+
|
|
|
$detail_insert = [];
|
|
|
foreach ($data['order_data'] as $v){
|
|
|
+
|
|
|
+ if(in_array($v['process_id'], $process_id)){
|
|
|
+ ReportMessage::insert([
|
|
|
+ 'order_id' => $v['id'],
|
|
|
+ 'quantity' => $v['quantity'] ?? 0,
|
|
|
+ 'opt_case' => ReportMessage::type_one,
|
|
|
+ 'crt_time' => $time,
|
|
|
+ 'user_id' => $user['id'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
$t = $team_man[$v['team_id']] ?? [];
|
|
|
if(! empty($t)){
|
|
|
foreach ($t as $t_v){
|
|
@@ -1986,7 +2004,7 @@ class ApplyOrderService extends Service
|
|
|
if (!empty($first)) {
|
|
|
$first = $first->toArray();
|
|
|
$box_detail = new BoxDetail(['channel' => $first['top_order_no']]);
|
|
|
- $result = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
|
|
|
+ $result = $box_detail->where('order_no', $first['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
}
|
|
|
} elseif ($data['type'] == 7) {
|
|
|
$result = ScrappCount::where('del_time', 0)
|
|
@@ -2032,7 +2050,7 @@ class ApplyOrderService extends Service
|
|
|
if (!empty($first)) {
|
|
|
foreach ($first as $value) {
|
|
|
$box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
|
|
|
- $t = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
|
|
|
+ $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
$result = array_merge($result, $t);
|
|
|
}
|
|
|
}
|
|
@@ -2049,7 +2067,7 @@ class ApplyOrderService extends Service
|
|
|
if (!empty($first)) {
|
|
|
foreach ($first as $value) {
|
|
|
$box_detail = new BoxDetail(['channel' => $value['top_order_no']]);
|
|
|
- $t = $box_detail->where('order_no', $first['order_no'])->selct('top_id as id')->get()->toArray();
|
|
|
+ $t = $box_detail->where('order_no', $value['order_no'])->select('top_id as id')->get()->toArray();
|
|
|
$result = array_merge($result, $t);
|
|
|
}
|
|
|
}
|
|
@@ -2116,7 +2134,7 @@ class ApplyOrderService extends Service
|
|
|
|
|
|
foreach ($sale as $value){
|
|
|
$box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
- $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
|
|
|
$tmp = Box::where('del_time',0)
|
|
|
->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
->select("id","order_no")
|
|
@@ -2167,7 +2185,7 @@ class ApplyOrderService extends Service
|
|
|
$ids = [];
|
|
|
foreach ($sale as $value){
|
|
|
$box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
- $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
|
|
|
$tmp = Box::where('del_time',0)
|
|
|
->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
->select("id")
|
|
@@ -2189,7 +2207,7 @@ class ApplyOrderService extends Service
|
|
|
$ids = [];
|
|
|
foreach ($sale as $value){
|
|
|
$box_detail = new BoxDetail(['channel'=> $value['order_no']]);
|
|
|
- $box_detail_order = $box_detail->where('top_id',$data['data_id'])->selct('order_no')->get()->toArray();
|
|
|
+ $box_detail_order = $box_detail->where('top_id',$data['data_id'])->select('order_no')->get()->toArray();
|
|
|
$tmp = Box::where('del_time',0)
|
|
|
->whereIn('order_no',array_unique(array_column($box_detail_order, 'order_no')))
|
|
|
->select("id")
|
|
@@ -2225,4 +2243,64 @@ class ApplyOrderService extends Service
|
|
|
|
|
|
return [true, $result];
|
|
|
}
|
|
|
+
|
|
|
+ public function reportList($data){
|
|
|
+ $model = ReportMessage::where('del_time',0)
|
|
|
+ ->select('id','order_id','opt_case','quantity','crt_time','user_id','is_use')
|
|
|
+ ->orderBy('id','desc');
|
|
|
+
|
|
|
+ $list = $this->limit($model,'',$data);
|
|
|
+ $list = $this->fillRData($list);
|
|
|
+
|
|
|
+ $count = ReportMessage::where('del_time',0)
|
|
|
+ ->where('is_use',0)
|
|
|
+ ->count();
|
|
|
+
|
|
|
+ return [true, ['list'=> $list, 'count' => $count]];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function fillRData($data){
|
|
|
+ if(empty($data['data'])) return $data;
|
|
|
+
|
|
|
+ $dispatch = DispatchSub::whereIn('id',array_unique(array_column($data['data'],'order_id')))
|
|
|
+ ->select('id','dispatch_no','process_id')
|
|
|
+ ->get()->toArray();
|
|
|
+ $process = Process::where('del_time',0)
|
|
|
+ ->whereIn('id',array_unique(array_column($dispatch,'process_id')))
|
|
|
+ ->pluck('title','id')
|
|
|
+ ->toArray();
|
|
|
+ $map = [];
|
|
|
+ foreach ($dispatch as $value){
|
|
|
+ $map[$value['id']] = $value;
|
|
|
+ }
|
|
|
+ $emp_map = Employee::whereIn('id',array_unique(array_column($data['data'],'user_id')))
|
|
|
+ ->pluck("emp_name",'id')
|
|
|
+ ->toArray();
|
|
|
+ foreach ($data['data'] as $key => $value){
|
|
|
+ $time = $value['crt_time'] ? date('Y-m-d H:i:s',$value['crt_time']) : '';
|
|
|
+ $data['data'][$key]['crt_time'] = $time;
|
|
|
+ $t = $map[$value['order_id']] ?? [];
|
|
|
+ $e = $emp_map[$value['user_id']] ?? "";
|
|
|
+ $p = $process[$t['process_id']] ?? "";
|
|
|
+ $data['data'][$key]['message'] = "派工单:" . $t['dispatch_no'] . "于" . $time . "由($e)完成工序($p)报工,请及时处理";
|
|
|
+ }
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function reportRemainUpdate($data){
|
|
|
+ if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
+ if(empty($data['type'])) return [false, 'type不能为空'];
|
|
|
+ $type = $data['type'];
|
|
|
+
|
|
|
+ if($type == 1){
|
|
|
+ ReportMessage::where('id', $data['id'])
|
|
|
+ ->update(['is_use' => 1]);
|
|
|
+ }else{
|
|
|
+ ReportMessage::where('id', $data['id'])
|
|
|
+ ->update(['del_time' => time()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, ''];
|
|
|
+ }
|
|
|
}
|