<?php

namespace app\api\controller\v1;

use app\api\business\ChengDanBus;
use app\api\business\TaskInformationBus;

class ChengDan
{

    //获取承担的任务列表
    public function selectUndertakerTaskList()
    {
        $task_class = request()->param('task_class','例行监测','trim');
        $pageNum = request()->param('pageNum',1,'int');
        $pageSize = request()->param('pageSize',10,'int');
        $data=[
            'year'=>request()->param('year','','trim'),//年度
            'ispublic'=>request()->param('ispublic','','trim'),//任务状态：0：未发布，1：执行中，2：已结束未完成，3：已结束已完成
            'starttime' => request()->param('starttime','','trim'),//任务开始时间
            'endtime' => request()->param('endtime','','trim'),//任务结束时间
            'task_name' => request()->param('task_name','','trim'),//任务名称
        ];
        $result = (new ChengDanBus())->selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data);
        return showSuccess($result);
    }

    //获取任务信息（执行检测）
    public function getTaskDetail()
    {
        $data = [
            'pageNum' => request()->param('pageNum', 1, 'int'),
            'pageSize' => request()->param('pageSize', null, 'int'),
            'task_id' => request()->param('task_id', null, 'int'),
        ];
        $result = (new TaskInformationBus())->getTaskDetail($data['task_id'], $data['pageNum'], $data['pageSize']);
        return showSuccess($result);
    }

    //获取抽样任务列表
    public function getSampleTaskList()
    {
        $data = [
            'pageNum' => request()->param('pageNum', 1, 'int'),
            'pageSize' => request()->param('pageSize', null, 'int'),
            'task_id' => request()->param('task_id', null, 'int'),
        ];
        $result = (new TaskInformationBus())->getSampleTaskList($data['task_id'], $data['pageNum'], $data['pageSize']);
        return showSuccess($result);
    }

    //获取检测任务列表
    public function getCheckTaskList()
    {
        $data = [
            'pageNum' => request()->param('pageNum', 1, 'int'),
            'pageSize' => request()->param('pageSize', null, 'int'),
            'task_id' => request()->param('task_id', null, 'int'),
        ];
        $result = (new TaskInformationBus())->getCheckTaskList($data['task_id'], $data['pageNum'], $data['pageSize']);
        return showSuccess($result);

    }

    //获取报告上传任务列表
    public function getReportTaskList()
    {
        $data = [
            'pageNum' => request()->param('pageNum', 1, 'int'),
            'pageSize' => request()->param('pageSize', null, 'int'),
            'task_id' => request()->param('task_id', null, 'int'),
        ];
        $result = (new TaskInformationBus())->getReportTaskList($data['task_id'], $data['pageNum'], $data['pageSize']);
        return showSuccess($result);
    }
}