cqpCow 11 ماه پیش
والد
کامیت
99608b07cd

+ 26 - 0
app/Http/Controllers/Api/ScheduleController.php

@@ -126,4 +126,30 @@ class ScheduleController extends BaseController
             return $this->json_return(201,$data);
         }
     }
+
+    public function getSettingTotal2(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->getSettingTotal2($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
+
+    public function getSettingGetDetail2(Request $request)
+    {
+        $service = new ScheduleService();
+        $user = $request->userData->toArray();
+        list($status,$data) = $service->getSettingGetDetail2($request->all(),$user);
+
+        if($status){
+            return $this->json_return(200,'',$data);
+        }else{
+            return $this->json_return(201,$data);
+        }
+    }
 }

+ 6 - 0
app/Model/UseScopeBaseModel.php

@@ -164,6 +164,12 @@ class UseScopeBaseModel extends Model
                 $query->whereIn('id', $id);
             }
         }
+
+        if(! empty($search['get_my_top_depart_data'])){
+            $depart = ! empty($user['depart_top'][0]) ? $user['depart_top'][0]: [];
+            $depart_id = $depart['depart_id'] ?? 0;
+            $query->where('top_depart_id', $depart_id);
+        }
     }
 
     //部门和顶级部门(公司)过滤 取别名a

+ 6 - 6
app/Service/ConstructionService.php

@@ -755,12 +755,12 @@ class ConstructionService extends Service
             $data['data'][$key]['handover_time'] = $value['handover_time'] ? date("Y-m-d") : "";
             $data['data'][$key]['storehouse_title'] = $storehouse[$value['storehouse_id']] ?? '';
             $data['data'][$key]['dispatch_company'] = $dispatch[$value['sales_order_id']] ?? '';
-            $data['data'][$key]['pq_state_title'] = Construction::$pq_name[$value['pq_state']] ?? '';
-            $str = "";
-            $start_time = $value['day_start_stamp'] ? date("Y-m-d H:i",$value['day_start_stamp']) : '';
-            $end_time = $value['day_end_stamp'] ? date("Y-m-d H:i",$value['day_end_stamp']) : '';
-            if(! empty($start_time) && ! empty($end_time)) $str = $start_time . '——' . $end_time;
-            $data['data'][$key]['pq_period'] = $str;
+//            $data['data'][$key]['pq_state_title'] = Construction::$pq_name[$value['pq_state']] ?? '';
+//            $str = "";
+//            $start_time = $value['day_start_stamp'] ? date("Y-m-d H:i",$value['day_start_stamp']) : '';
+//            $end_time = $value['day_end_stamp'] ? date("Y-m-d H:i",$value['day_end_stamp']) : '';
+//            if(! empty($start_time) && ! empty($end_time)) $str = $start_time . '——' . $end_time;
+//            $data['data'][$key]['pq_period'] = $str;
         }
 
         return $data;

+ 92 - 0
app/Service/ScheduleService.php

@@ -559,4 +559,96 @@ class ScheduleService extends Service
 
         return [true, $return];
     }
+
+    public function getSettingTotal2($data,$user){
+        if(empty($data['schedule'])) return [true,""];
+        // 获取指定年月的开始日期时间戳
+        $startTimestamp = strtotime($data['schedule'] . "-01");
+        // 获取下个月的开始日期时间戳,然后减去一秒得到本月的结束日期时间戳
+        $endTimestamp = strtotime("+1 month", $startTimestamp) - 1;
+
+        $return = [];
+        for ($i = $startTimestamp; $i <= $endTimestamp; $i += 86400) { // 每天86400秒
+            $time = date("Y-m-d", $i);
+            $return[$i] = [
+                'time' => $time,
+                'num' => 0,
+                'order' => "",
+            ];
+        }
+
+        $data['get_my_top_depart_data'] = 1;
+        $model = Construction::Clear($user,$data);
+        $construction = $model->where('del_time',0)
+            ->where('start_time','<=',$endTimestamp)
+            ->where('end_time','>=',$startTimestamp)
+            ->select('id','start_time','end_time')
+            ->get()->toArray();
+
+        foreach ($construction as $value){
+            $start_t = date('Y-m-d', $value['start_time']);
+            $startOfDayTimestamp = strtotime($start_t);
+            $end_t = date('Y-m-d', $value['end_time']);
+            $endOfDayTimestamp = strtotime($end_t);
+            for ($i = $startOfDayTimestamp; $i <= $endOfDayTimestamp; $i += 86400) {
+                if(isset($return[$i])){
+                    $return[$i]['num'] += 1;
+                    $return[$i]['order'] .= $value['id'] . ',';
+                }
+            }
+        }
+
+        return [true, array_values($return)];
+    }
+
+    public function getSettingGetDetail2($data, $user){
+        if(empty($data['order'])) return [true, ""];
+        $order_id = array_filter(explode(',', $data['order']));
+        if(empty($order_id)) return [true, ""];
+
+        $construction = Construction::where('del_time',0)
+            ->whereIn('id',$order_id)
+            ->select('id','order_number','crt_id','start_time','end_time')
+            ->get()->toArray();
+        if(empty($construction)) return [true, ""];
+        $emp = Employee::whereIn('id',array_unique(array_column($construction,'crt_id')))
+            ->pluck('emp_name','id')
+            ->toArray();
+        $product_title = [];
+        $product = ConstructionProductInfo::whereIn('construction_id',array_unique(array_column($construction,'id')))
+            ->select('product_id','construction_id')
+            ->get()->toArray();
+        $product_map = Product::whereIn('id',array_unique(array_column($product,'product_id')))
+            ->pluck('title','id')
+            ->toArray();
+        foreach ($product as $value){
+            if(! isset($product_title[$value['construction_id']])){
+                $product_title[$value['construction_id']] = $product_map[$value['product_id']];
+            }else{
+                $product_title[$value['construction_id']] .= "," . $product_map[$value['product_id']];
+            }
+        }
+
+        $return = [];
+
+        //可见范围
+        $employee = (new RangeService())->RangeConstructionEmpDetail($order_id);
+        foreach ($construction as $value){
+            $str = "";
+            if(! empty($value['start_time']) && ! empty($value['end_time'])) $str = date('Y-m-d H:i',$value['start_time']) . '-' . date("Y-m-d H:i",$value['end_time']);
+
+            $emp_tmp = $employee[$value['id']] ?? [];
+            $tmp = [
+                'id' => $value['id'],
+                'employee' => $emp_tmp,
+                'order_number' => $value['order_number'],
+                'crt_name' => $emp[$value['crt_id']] ?? "",
+                'product' => $product_title[$value['id']],
+                'crt_time' => $str,
+            ];
+            $return[] = $tmp;
+        }
+
+        return [true, $return];
+    }
 }

+ 8 - 8
config/header/34.php

@@ -50,14 +50,14 @@ return [
         'key' => 'state_title',
         'value' => '订单状态',
     ],
-    [
-        'key' => 'pq_state_title',
-        'value' => '是否排期施工',
-    ],
-    [
-        'key' => 'pq_period',
-        'value' => '排期时间',
-    ],
+//    [
+//        'key' => 'pq_state_title',
+//        'value' => '是否排期施工',
+//    ],
+//    [
+//        'key' => 'pq_period',
+//        'value' => '排期时间',
+//    ],
     [
         'key' => 'crt_time',
         'value' => '创建时间',

+ 2 - 0
routes/api.php

@@ -251,6 +251,8 @@ Route::group(['middleware'=> ['checkLogin']],function ($route){
     $route->any('getScheduleSetting', 'Api\ScheduleController@getScheduleSetting');
     $route->any('getSettingTotal', 'Api\ScheduleController@getSettingTotal');
     $route->any('getSettingGetDetail', 'Api\ScheduleController@getSettingGetDetail');
+    $route->any('getSettingTotal2', 'Api\ScheduleController@getSettingTotal2');
+    $route->any('getSettingGetDetail2', 'Api\ScheduleController@getSettingGetDetail2');
 
     //现存量
     $route->any('productInventoryList', 'Api\ProductInventoryController@productInventoryList');

+ 2 - 1
routes/wx.php

@@ -98,7 +98,8 @@ Route::group(['middleware'=> ['checkWx']],function ($route){
 
     $route->any('getSettingTotal', 'Api\ScheduleController@getSettingTotal');
     $route->any('getSettingGetDetail', 'Api\ScheduleController@getSettingGetDetail');
-
+    $route->any('getSettingTotal2', 'Api\ScheduleController@getSettingTotal2');
+    $route->any('getSettingGetDetail2', 'Api\ScheduleController@getSettingGetDetail2');
     //客户
     $route->any('customerList', 'Api\CustomerController@customerList');
     $route->any('customerEdit', 'Api\CustomerController@customerEdit');