UndertakerTaskBus.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 UndertakerTaskBus
  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=[['bear_id','=',$this->uid],['task_class','=',$task_class]];
  58. $where=[['bear_id','=',$this->uid]];
  59. if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
  60. //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
  61. if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
  62. //任务开始时间
  63. if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
  64. //任务结束时间
  65. if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
  66. //任务名称:模糊查询
  67. if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
  68. //$data = (new Undertake())->selectCcjcData($where,$pageNum,$pageSize);
  69. $data = (new Ccjc())->selectUndertakeData($task_class,$where,$pageNum,$pageSize);
  70. $count = (new Ccjc())->countUndertakeData($task_class,$where);
  71. // $count =(new Undertake())->countCcjcData($where);
  72. return ['rows'=>$data,'total'=>$count];
  73. }
  74. }