QianTouBus.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/12
  6. */
  7. namespace app\api\business;
  8. use app\api\model\Ccjc;
  9. use app\api\model\Jgry;
  10. use app\api\model\Orgs;
  11. use app\api\model\TestModel;
  12. use app\api\model\Undertake;
  13. use app\common\lib\Arr;
  14. use app\common\lib\auth\JwtAuth;
  15. class QianTouBus
  16. {
  17. private $uid;
  18. public function __construct()
  19. {
  20. $jwtAuth=JwtAuth::getInstance(); //实例化jwtAuth
  21. $this->uid = $jwtAuth->getUid(); //setRybh是在middleware/jwtAuth中完成的
  22. }
  23. //获取机构与地域信息
  24. public function getUndertakeList($data)
  25. {
  26. $result = (new Undertake())->getItemByTaskId($data['task_id'],$data['pageNum'],$data['pageSize']);
  27. $total = (new Undertake())->countItemByTaskId($data['task_id']);
  28. return ['rows' => $result, 'total' => $total];
  29. }
  30. //查询任务列表数据
  31. public function selectTaskList($data)
  32. {
  33. $where=[
  34. ['unit_id','=',$this->uid],
  35. ['task_class','=',$data['task_class']]
  36. ];
  37. if ($data['task_name'] != '' ) $where[] = ['task_name', 'LIKE', '%' . $data['task_name'] . '%'];
  38. if ($data['ispublic'] != '') $where[] = ['ispublic', '=', $data['ispublic']];
  39. if ($data['year']!='') $where[] = ['year', '=', $data['year']];
  40. if ($data['starttime'] != '') $where[] = ['starttime', '>=', $data['starttime']];
  41. if ($data['endtime'] != '') $where[] = ['endtime', '<=', $data['endtime']];
  42. $data = (new Orgs())->selectCcjcData($where,$data['pageNum'],$data['pageSize']);
  43. $count =(new Orgs())->countCcjcData($where);
  44. return ['rows'=>$data,'total'=>$count];
  45. }
  46. //牵头单位发布任务
  47. public function releaseTask($task_id)
  48. {
  49. $data=['ispublic' => 5];//发布任务
  50. $result = (new Ccjc())->updateInfoByTaskID($task_id, $data);
  51. return $result;
  52. }
  53. //获取任务基本信息
  54. public function getTaskInfo($tmp_data)
  55. {
  56. $task_id = $tmp_data['task_id'];
  57. $pageNum = $tmp_data['pageNum'];
  58. $pageSize = $tmp_data['pageSize'];
  59. $uid=$this->uid;
  60. // //判断 在orgs表中的当前任务的id所对应的unit_id是否等于uid
  61. // $unit_id = (new Orgs())->getUnitIdByTaskID($task_id)['unit_id'];
  62. // if ($unit_id != $uid) {
  63. // throw new ApiException(config('status.err_task_auth'));
  64. // }
  65. //任务信息
  66. $task_info = (new Ccjc())->getTaskInfoByTaskID($task_id);
  67. $task_releaser_info = (new Jgry())->getJgryInfoByRymc($task_info['releaser']);
  68. //获取uid下创建的所有模型信息
  69. if (isset($task_info['test_model_id'])) {
  70. $task_product_info = (new TestModel())->getProductInfo($task_info['test_model_id']);
  71. $task_pesticides_info = (new TestModel())->getPesticidesInfo($task_info['test_model_id']);
  72. $task_model_info=(new TestModel())->getModelInfoByModelID($task_info['test_model_id']);
  73. }else{
  74. $task_product_info ='';
  75. $task_pesticides_info='';
  76. $task_model_info='';
  77. }
  78. //牵头的任务列表的信息(抽样)
  79. $unitTaskList_info=(new Undertake())->selectTaskListByTaskIdAndUid($task_id,$uid,'','',$pageNum,$pageSize);
  80. $unitTaskList_total = (new Undertake())->countTaskListByTaskIdAndUid($task_id, $uid);
  81. //承担的任务列表的信息(检测)
  82. $underTaskList_info=(new Undertake())->selectTaskListByTaskIdAndUid($task_id,'',$uid,'',$pageNum,$pageSize);
  83. $underTaskList_total = (new Undertake())->countTaskListByTaskIdAndUid($task_id, '',$uid);
  84. //报告上传的任务列表信息(报告上传)
  85. $reportTaskList_info=(new Undertake())->selectTaskListByTaskIdAndUid($task_id,'','',$uid,$pageNum,$pageSize);
  86. $reportTaskList_total = (new Undertake())->countTaskListByTaskIdAndUid($task_id, '','',$uid);
  87. $data=[
  88. 'taskInfo'=>$task_info,
  89. 'releaserInfo'=>$task_releaser_info,
  90. 'product'=>$task_product_info,
  91. 'pesticides'=>$task_pesticides_info,
  92. 'unitTaskList'=>['rows'=>$unitTaskList_info,'total'=>$unitTaskList_total],
  93. 'underTaskList'=>['rows'=>$underTaskList_info,'total'=>$underTaskList_total],
  94. 'reportTaskList'=>['rows'=>$reportTaskList_info,'total'=>$reportTaskList_total],
  95. 'modelInfo'=>$task_model_info,
  96. ];
  97. return $data;
  98. }
  99. //获取任务基本信息
  100. public function getTaskBaseInfo($data)
  101. {
  102. $task_info = (new Ccjc())->getTaskInfoByTaskID($data['task_id'])->toArray();
  103. return $task_info;
  104. }
  105. }