Cyd.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. *
  4. *User:Administrator
  5. *Date:2021/10/14
  6. */
  7. namespace app\api\model;
  8. use think\Model;
  9. class Cyd extends Model
  10. {
  11. function production()
  12. {
  13. return $this->belongsTo('production', 'product_unit','id');
  14. }
  15. function unitsTest()
  16. {
  17. return $this->belongsTo('unitsTest', 'units_id', 'id');
  18. }
  19. public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null)
  20. {
  21. $cyd = (new Cyd());
  22. $data = $cyd->with(['Production', 'UnitsTest'])->where($where)->page($pageNum,$pageSize)->select();
  23. return $data;
  24. }
  25. public function countSampleListByTaskIdAndUid($where)
  26. {
  27. $cyd = (new Cyd());
  28. $count = $cyd->with(['Production', 'UnitsTest'])->where($where)->count();
  29. return $count;
  30. }
  31. public function createSample($cyd_data)
  32. {
  33. $result = $this->insertGetId($cyd_data);
  34. return $result;
  35. }
  36. public function updateCydDataByID($id, $data)
  37. {
  38. $result = $this->where('id','=',$id)->save($data);
  39. return $result;
  40. }
  41. //用于生成抽样单编号的
  42. public function countSampleCreateID()
  43. {
  44. return $this->whereDay('createtime','today')->count();
  45. }
  46. }