|
@@ -4,6 +4,7 @@ namespace App\Service;
|
|
|
|
|
|
use App\Model\BasicType;
|
|
|
use App\Model\Construction;
|
|
|
+use App\Model\ConstructionProductInfo;
|
|
|
use App\Model\Employee;
|
|
|
use App\Model\Product;
|
|
|
use App\Model\ProductActivity;
|
|
@@ -466,4 +467,85 @@ class ScheduleService extends Service
|
|
|
|
|
|
return [true, $result];
|
|
|
}
|
|
|
+
|
|
|
+ public function getSettingTotal($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' => "",
|
|
|
+ ];
|
|
|
+ }
|
|
|
+
|
|
|
+ $model = Schedule::TopClear($user,$data);
|
|
|
+ $schedule = $model->where('del_time',0)
|
|
|
+ ->where('start_time', '>=', $startTimestamp)
|
|
|
+ ->where('end_time', '<=', $endTimestamp)
|
|
|
+ ->select('id')
|
|
|
+ ->get()->toArray();
|
|
|
+ if(empty($schedule)) return [true, $return];
|
|
|
+
|
|
|
+ $construction = Construction::where('del_time',0)
|
|
|
+ ->whereIn('schedule_id',array_column($schedule,'id'))
|
|
|
+ ->select('day_stamp','id')
|
|
|
+ ->get()->toArray();
|
|
|
+
|
|
|
+ foreach ($construction as $value){
|
|
|
+ if(isset($return[$value['day_stamp']])){
|
|
|
+ $return[$value['day_stamp']]['num'] += 1;
|
|
|
+ $return[$value['day_stamp']]['order'] .= $value['id'] . ',';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, array_values($return)];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getSettingGetDetail($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')
|
|
|
+ ->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 = [];
|
|
|
+ foreach ($construction as $value){
|
|
|
+ $tmp = [
|
|
|
+ 'order_number' => $value['order_number'],
|
|
|
+ 'crt_name' => $emp[$value['crt_id']] ?? "",
|
|
|
+ 'product' => $product_title[$value['id']],
|
|
|
+ ];
|
|
|
+ $return[] = $tmp;
|
|
|
+ }
|
|
|
+
|
|
|
+ return [true, $return];
|
|
|
+ }
|
|
|
}
|