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

namespace app\api\business;


use app\api\model\Cyd;

class CydBus
{
    public function getCydList($task_id)
    {
        $data = (new Cyd())->selectCydInfoByTaskID($task_id);
        $count = (new Cyd())->countCydInfoByTaskID($task_id);
        return ['rows'=>$data,'total'=>$count];
    }


    //修改抽样单状态，status=1已上报，0未上报
    public function upCydItem($sample_id)
    {
        $cyd_status = ['sample_status' => '1'];
        $result = (new Cyd())->updateCydDataBySampleID($sample_id, $cyd_status);
        return $result;
    }

    public function getCydItemBySampleId($sample_id)
    {
        $cyd_item = (new Cyd())->getCydDetailBySampleID($sample_id);
        return $cyd_item;
    }

    public function getCydByTaskIdAndUnitId($data,$page)
    {
        $where = [
            ['cyd.task_id','=',$data['task_id']],
            ['unit_id','=',$data['unit_id']]
        ];

        $jg_cyd_list = (new Cyd())->getCydListDetail($where,$page['pageNum'],$page['pageSize']);
        return $jg_cyd_list;
    }

}