Undertake.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/13
  6. */
  7. namespace app\api\model;
  8. use think\Model;
  9. class Undertake extends Model
  10. {
  11. public function insert(array $data = [], bool $getLastInsID = false)
  12. {
  13. return parent::insert($data, $getLastInsID); // TODO: Change the autogenerated stub
  14. }
  15. public function deleteInfoByID($id_arr)
  16. {
  17. return $this->select($id_arr)->delete();
  18. }
  19. //获取抽样任务列表
  20. public function selectByTaskIdAndWhere($task_id, $where='',$pageNum=1,$pageSize=null)
  21. {
  22. if ($task_id == '' || $where == '') {
  23. return false;
  24. }
  25. return $this->where([
  26. ['task_id', '=', $task_id],
  27. [$where]
  28. ])
  29. ->page($pageNum,$pageSize)
  30. ->select();
  31. }
  32. //获取抽样任务列表数量
  33. public function countByTaskIdAndWhere($task_id, $where='')
  34. {
  35. if ($task_id == '' || $where == '') {
  36. return false;
  37. }
  38. return $this->where([
  39. ['task_id', '=', $task_id],
  40. [$where]
  41. ])
  42. ->count();
  43. }
  44. public function selectTaskListByTaskIdAndUid($task_id,$unit_id='',$bear_id='',$report_id='',$pageNum=1,$pageSize=null)
  45. {
  46. $where=[
  47. ['task_id', '=', $task_id],
  48. ];
  49. if ($unit_id!='') {
  50. array_push($where, ['unit_id', '=', $unit_id]);
  51. }
  52. if ($bear_id!='') {
  53. array_push($where, ['bear_id', '=', $bear_id]);
  54. }
  55. if ($report_id!='') {
  56. array_push($where,['report_id', '=', $report_id]);
  57. }
  58. return $this->where($where)->page($pageNum,$pageSize)->select();
  59. }
  60. public function countTaskListByTaskIdAndUid($task_id,$unit_id='',$bear_id='',$report_id='')
  61. {
  62. $where=[
  63. ['task_id', '=', $task_id],
  64. ];
  65. if ($unit_id != '') {
  66. array_push($where, ['unit_id', '=', $unit_id]);
  67. }
  68. if ($bear_id != '') {
  69. array_push($where, ['bear_id', '=', $bear_id]);
  70. }
  71. if ($report_id != '') {
  72. array_push($where,['report_id', '=', $report_id]);
  73. }
  74. return $this->where($where)->count();
  75. }
  76. }