Undertake.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. public function getItemByTaskId($task_id,$pageNum,$pageSize)
  20. {
  21. return $this->where('task_id', '=', $task_id)->page((int)$pageNum,(int)$pageSize)->select();
  22. }
  23. public function countItemByTaskId($task_Id)
  24. {
  25. return $this->where('task_id', '=', $task_Id)->count();
  26. }
  27. //获取抽样任务列表
  28. public function selectByTaskIdAndWhere($task_id, $where='',$pageNum=1,$pageSize=null)
  29. {
  30. if ($task_id == '' || $where == '') {
  31. return false;
  32. }
  33. return $this->where([
  34. ['task_id', '=', $task_id],
  35. [$where]
  36. ])
  37. ->page($pageNum,$pageSize)
  38. ->select();
  39. }
  40. //获取抽样任务列表数量
  41. public function countByTaskIdAndWhere($task_id, $where='')
  42. {
  43. if ($task_id == '' || $where == '') {
  44. return false;
  45. }
  46. return $this->where([
  47. ['task_id', '=', $task_id],
  48. [$where]
  49. ])
  50. ->count();
  51. }
  52. public function selectTaskListByTaskIdAndUid($task_id,$unit_id='',$bear_id='',$report_id='',$pageNum=1,$pageSize=null)
  53. {
  54. $where=[
  55. ['task_id', '=', $task_id],
  56. ];
  57. if ($unit_id!='') {
  58. array_push($where, ['unit_id', '=', $unit_id]);
  59. }
  60. if ($bear_id!='') {
  61. array_push($where, ['bear_id', '=', $bear_id]);
  62. }
  63. if ($report_id!='') {
  64. array_push($where,['report_id', '=', $report_id]);
  65. }
  66. return $this->where($where)->page($pageNum,$pageSize)->select();
  67. }
  68. public function countTaskListByTaskIdAndUid($task_id,$unit_id='',$bear_id='',$report_id='')
  69. {
  70. $where=[
  71. ['task_id', '=', $task_id],
  72. ];
  73. if ($unit_id != '') {
  74. array_push($where, ['unit_id', '=', $unit_id]);
  75. }
  76. if ($bear_id != '') {
  77. array_push($where, ['bear_id', '=', $bear_id]);
  78. }
  79. if ($report_id != '') {
  80. array_push($where,['report_id', '=', $report_id]);
  81. }
  82. return $this->where($where)->count();
  83. }
  84. public function getItemByUndertakeId($undertake_id)
  85. {
  86. return $this->where('id','=',$undertake_id)->find();
  87. }
  88. }