|
@@ -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];
|
|
|
+ }
|
|
|
}
|