123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <?php
- /**
- *
- *User:Administrator
- *Date:2021/10/13
- */
- namespace app\api\business;
- use app\api\exception\ApiException;
- use app\api\model\Ccjc;
- use app\api\model\Jcdw;
- use app\api\model\Undertake;
- use app\common\lib\auth\JwtAuth;
- class UndertakerTaskBus
- {
- private $uid;
- public function __construct()
- {
- $jwtAuth = JwtAuth::getInstance();
- $this->uid = $jwtAuth->getUid();
- }
- public function deleteUnderTaker($del_arr)
- {
- $result=(new Undertake())->deleteInfoByID($del_arr);
- if ($result == 0) {
- throw new ApiException(config('status.none_data'));
- }
- return $result;
- }
- public function createUnderTakerInfo($data)
- {
- $uid = $this->uid;
- $bear_name = (new Jcdw())->getInfoById($data['bear_id'])['name'];
- $check_name = (new Jcdw())->getInfoById($data['check_id'])['name'];
- $report_name = (new Jcdw())->getInfoById($data['report_id'])['name'];
- $save_data=[
- 'task_id' => $data['task_id'],
- 'unit_id' => $uid,
- 'bear_id' => $data['bear_id'],
- 'check_id' => $data['check_id'],
- 'report_id' => $data['report_id'],
- 'bear_name' => $bear_name,
- 'check_name' => $check_name,
- 'report_name' => $report_name,
- 'sample_number' => $data['sample_number'],
- 'address' => $data['address'],
- 'uploadtime' => $data['upload_time'],
- ];
- $result = (new Undertake())->insert($save_data,true);
- if ($result == null) {
- throw new ApiException(config('status.err_data_upload'));
- }
- return true;
- }
- //查询任务列表数据
- public function selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data)
- {
- $where=[
- ['bear_id', '=', $this->uid],
- ];
- if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
- //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
- if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
- //任务开始时间
- if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
- //任务结束时间
- if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
- //任务名称:模糊查询
- if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
- $data = (new Ccjc())->selectUndertakeData($task_class,$where,$pageNum,$pageSize);
- $count = (new Ccjc())->countUndertakeData($task_class,$where);
- // $count =(new Undertake())->countCcjcData($where);
- return ['rows'=>$data,'total'=>$count];
- }
- }
|