<?php
/**
 *
 *User:Administrator
 *Date:2021/10/14
 */

namespace app\api\controller\v1;

use app\api\business\SampleBus;

class Sample
{

    public function selectSampleList()
    {
        $task_id = request()->param('task_id', '', 'int');
        $pageNum = request()->param('pageNum', '1', 'int');
        $pageSize = request()->param('pageSize', '10', 'int');
        $result = (new SampleBus())->selectSampleList($task_id, $pageNum, $pageSize);
        return showSuccess($result);
    }

    public function getSampleObj()
    {
        $task_id = request()->param('task_id','','int');
        $under_task_id = request()->param('under_id', '', 'int');
        $result = (new SampleBus())->getSampleObj($task_id,$under_task_id);
        return showSuccess($result);
    }

    public function createSampleId()
    {
        $task_id = request()->param('task_id', '', 'int');
        $result = (new SampleBus())->createSampleId($task_id);
        return showSuccess($result);
    }

    public function createSample()
    {

        //受检单位信息
        $unit_test = [
            'unit_name' => request()->param('units.units_name','','trim'),//单位名称
            'address' => request()->param('units.address'),//通讯地址
            'represent_name' => request()->param('units.corporation','','trim'),//法定代表人
            'user_name' => request()->param('units.user_name','','trim'),//*受检人
            'phone' => request()->param('units.phone','','trim'),//电话
            'fax' => request()->param('units.fax','','trim'),//传真
        ];

        //生产单位信息
        $unit_production = [
            'production_name' =>request()->param('production.production_name','','trim'),//单位名称
            'address' =>request()->param('production.p_address','','trim'),//通讯地址
            'postcode' =>request()->param('production.p_postcode','','trim'),//邮编
            'user_name' =>request()->param('production.p_user_name','','trim'),//联系人
            'phone' =>request()->param('production.p_phone','','trim'),//电话
            'fax' =>request()->param('production.p_fax','','trim'),//传真
            'production_class' =>request()->param('production.production_class','','trim'),//生产方式
        ];

        //抽样单位信息
        $unit_sample = [
            'unit_name' => request()->param('sampleUnit.sample_unit_name','','trim'),//单位名称
            'unit_user' => request()->param('sampleUnit.sample_unit_user','','trim'),//联系人
            'address' => request()->param('sampleUnit.sample_unit_address','','trim'),//通讯地址
            'postcode' => request()->param('sampleUnit.sample_unit_postcode','','trim'),//邮编
            'phone' => request()->param('sampleUnit.sample_unit_phone','','trim'),//联系电话
            'fax' => request()->param('sampleUnit.sample_unit_fax','','trim'),//传真
            'email' => request()->param('sampleUnit.sample_unit_email','','trim'),//Email
        ];

//抽样单cyd信息
        $cyd_data = [
            'sample_id' => request()->param('sample_id','','trim'),//抽样单的id
            'task_id' => request()->param('task_id','','trim'),//关联任务id
            'test_id' => request()->param('test_id','','trim'),//检测单位id-------todo 这个怎么填！！！！！！！！！！！！

            'units_id' => request()->param('units_id','','trim'),//受检单位id
            'product_unit' => request()->param('product_unit','','trim'),//生产单位id
            'sample_unit' => request()->param('sample_unit','','trim'),//抽样单位id

            'sample_name' => request()->param('sample_name','','trim'),//样品名称
            'brand' => request()->param('brand','','trim'),//商标
            'ispack' => request()->param('ispack','','trim'),//包装
            'type' => request()->param('type','','trim'),//型号规格
            'standard' => request()->param('standard','','trim'),//执行标准
            'production_date' => request()->param('production_date','','trim'),//生产日期或批号
            'place' => request()->param('place','','trim'),//	产地
            'certicfie' => request()->param('certicfie','','trim'),//*产品认证情况
            'certifie_num' => request()->param('certifie_num','','trim'),//证书编号
            'sample_num' => request()->param('sample_num','','trim'),//*抽样数量
            'sample_num_unit' => request()->param('sample_num_unit','','trim'),//*抽样数量单位
            'sample_base' => request()->param('sample_base','','trim'),//抽样基数
            'sample_base_unit' => request()->param('sample_base_unit','','trim'),//抽样基数单位
            'sample_ground' => request()->param('sample_ground','','trim'),//*抽样场所
            'base' => request()->param('base', '', 'trim'),//检测任务依据
            'sample_date'=>request()->param('sample_date','','trim'),//抽样时间
            'file_name' => request()->param('file_name','','trim'),//文件名
            'file_url' => request()->param('file_url','','trim'),//文件链接
        ];

        $result = (new SampleBus())->createSample($unit_test, $unit_production, $unit_sample, $cyd_data);
        return showSuccess($result);
    }

}