Undertake.php 2.2 KB

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