123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace app\api\model;
- use think\Model;
- class Ccjc extends model{
- protected $table = 't_ccjc';
- protected $pk = 'id';
- function undertake()
- {
- return $this->hasMany('undertake', 'task_id', 'id');
- }
- function orgs()
- {
- return $this->hasOne('orgs', 'task_id', 'id');
- }
- public function selectCcjcAndOrgsData($task_uid,$task_class='例行监测',$pageNum=1,$pageSize=10)
- {
- $ccjc = new Ccjc();
- return $ccjc->where([['task_class', '=', $task_class],])->with([
- 'orgs'=>function ($query) use ($task_uid){
- $query->where('unit_id',$task_uid);
- }
- ])->page((int)$pageNum,(int)$pageSize)->select();
- }
- public function selectUndertakeData($task_class,$where, $pageNum, $pageSize)
- {
- $result = Ccjc::hasWhere('undertake', function ($query) use ($where){
- $query->where($where);
- })->where('task_class','=',$task_class)->select();
- return $result;
- }
- public function countUndertakeData($task_class,$where)
- {
- $Ccjc = new Ccjc();
- return $Ccjc->where('task_class','=',$task_class)
- ->with([
- 'undertake'=> function ($query) use ($where){
- $query->where($where);
- }
- ])->count();
- }
-
- public function getInfoByTaskClass($where,$pageNum=1,$pageSize=10)
- {
- return $this->where($where)->page($pageNum,$pageSize)->select();
- }
- public function getInfoListCount($where='')
- {
- return $this->where($where)->select()->count();
- }
-
- public function deleteTaskByID($id)
- {
- if (empty($id)) {
- return false;
- }
- return $this->select($id)->delete();
- }
-
- public function getReleaserById($id)
- {
- return $this->select($id)->column('releaser');
- }
-
- public function createTask($data)
- {
- return $this->insertGetId($data);
- }
- public function getTaskInfoByTaskID($task_id)
- {
- return $this->where('id','=',$task_id)->find();
- }
- public function updateInfoByTaskID($task_id, $data)
- {
- return $this->where('id', '=', $task_id)->save($data);
- }
-
- public function updateTaskByArrCondition($arr_condition)
- {
- if (empty($arr_condition)) {
- return false;
- }
- $result = $this->saveAll($arr_condition);
- return $result;
- }
- }
|