UndertakerTaskBus.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. public function selectUnterTakerListByTaskID($task_id,$pageNum=1,$pageSize=10)
  55. {
  56. $bear = $this->uid;
  57. $result = (new Undertake())->selectUndertakeInfoByTaskIdAndUnitId($task_id,'',$bear,'',$pageNum=1,$pageSize=null);
  58. $count = (new Undertake())->countUndertakeInfoByTaskIdAndUnitId($task_id,'',$bear);
  59. return ['rows'=>$result, 'total' => $count,];
  60. }
  61. //查询任务列表数据
  62. public function selectUndertakerTaskList($task_class,$pageNum,$pageSize,$data)
  63. {
  64. //$where=[['bear_id','=',$this->uid],['task_class','=',$task_class]];
  65. $where=[['bear_id','=',$this->uid]];
  66. if ($data['year']!='') array_push($where, ['year', '=', $data['year']]);
  67. //任务状态:0:未发布,1:执行中,2:已结束未完成,3:已结束已完成
  68. if ($data['ispublic'] != '') array_push($where, ['ispublic', '=', $data['ispublic']]);
  69. //任务开始时间
  70. if ($data['starttime'] != '') array_push($where, ['starttime', '>=', $data['starttime']]);
  71. //任务结束时间
  72. if ($data['endtime'] != '') array_push($where, ['endtime', '<=', $data['endtime']]);
  73. //任务名称:模糊查询
  74. if ($data['task_name'] != '' ) array_push($where, ['task_name', 'LIKE', '%'.$data['task_name'].'%']);
  75. //$data = (new Undertake())->selectCcjcData($where,$pageNum,$pageSize);
  76. $data = (new Ccjc())->selectUndertakeData($task_class,$where,$pageNum,$pageSize);
  77. $count = (new Ccjc())->countUndertakeData($task_class,$where);
  78. // $count =(new Undertake())->countCcjcData($where);
  79. return ['rows'=>$data,'total'=>$count];
  80. }
  81. }