ChengDanBus.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/13
  6. */
  7. namespace app\api\business;
  8. use app\api\exception\ApiException;
  9. use app\api\model\Ccjc;
  10. use app\api\model\Jcdw;
  11. use app\api\model\Undertake;
  12. use app\common\lib\auth\JwtAuth;
  13. class ChengDanBus
  14. {
  15. private $uid;
  16. public function __construct()
  17. {
  18. $jwtAuth = JwtAuth::getInstance();
  19. $this->uid = $jwtAuth->getUid();
  20. }
  21. public function deleteUnderTaker($del_arr)
  22. {
  23. $result=(new Undertake())->deleteInfoByID($del_arr);
  24. if ($result == 0) {
  25. throw new ApiException(config('status.none_data'));
  26. }
  27. return $result;
  28. }
  29. public function createUnderTakerInfo($data)
  30. {
  31. $uid = $this->uid;
  32. $bear_name = (new Jcdw())->getInfoById($data['bear_id'])['name'];
  33. $check_name = (new Jcdw())->getInfoById($data['check_id'])['name'];
  34. $report_name = (new Jcdw())->getInfoById($data['report_id'])['name'];
  35. $save_data=[
  36. 'task_id' => $data['task_id'],
  37. 'unit_id' => $uid,
  38. 'bear_id' => $data['bear_id'],
  39. 'check_id' => $data['check_id'],
  40. 'report_id' => $data['report_id'],
  41. 'bear_name' => $bear_name,
  42. 'check_name' => $check_name,
  43. 'report_name' => $report_name,
  44. 'sample_number' => $data['sample_number'],
  45. 'address' => $data['address'],
  46. 'uploadtime' => $data['upload_time'],
  47. ];
  48. $result = (new Undertake())->insert($save_data,true);
  49. if ($result == null) {
  50. throw new ApiException(config('status.err_data_upload'));
  51. }
  52. return true;
  53. }
  54. //查询任务列表数据
  55. public function selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data)
  56. {
  57. $where_undertake = [['bear_id|check_id|report_id', '=', $this->uid],];
  58. $where = [
  59. ['task_class','=',$task_class],
  60. ];
  61. if ($data['year']!='') $where[] = ['year', '=', $data['year']];
  62. if ($data['ispublic'] != '') $where[] = ['ispublic', '=', $data['ispublic']]; //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
  63. if ($data['starttime'] != '') $where[]=['starttime', '>=', $data['starttime']]; //任务开始时间
  64. if ($data['endtime'] != '') $where[] = ['endtime', '<=', $data['endtime']]; //任务结束时间
  65. if ($data['task_name'] != '' ) $where[] = ['task_name', 'LIKE', '%' . $data['task_name'] . '%']; //任务名称:模糊查询
  66. $data = (new Ccjc())->selectUndertakeData($where_undertake,$where,$pageNum,$pageSize);
  67. $total = (new Ccjc())->countUndertakeData($where_undertake,$where);
  68. return ['rows'=>$data,'total'=>$total];
  69. }
  70. }