1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- /**
- *
- *User:Administrator
- *Date:2021/10/14
- */
- namespace app\api\model;
- use think\Model;
- class Cyd extends Model
- {
- function unitProduction()
- {
- return $this->belongsTo('unitProduction', 'product_unit','id');
- }
- function unitTest()
- {
- return $this->belongsTo('unitTest', 'units_id', 'id');
- }
- function unitSample()
- {
- return $this->belongsTo('unitSample', 'sample_unit', 'id');
- }
- public function getCydDetailBySampleID($sample_id)
- {
- $cyd = (new Cyd());
- $data = $cyd->with(['unitProduction', 'unitTest','unitSample'])
- ->where('sample_id','=',$sample_id)
- ->select();
- return $data;
- }
- public function selectCydInfoByTaskID($task_id)
- {
- return $this->where([
- 'task_id' => $task_id,
- 'status'=>1
- ])->select();
- }
- public function countCydInfoByTaskID($task_id)
- {
- return $this->where([
- 'task_id' => $task_id,
- 'status'=>1
- ])->count();
- }
- public function selectSampleListByTaskIdAndUid($where,$pageNum=1,$pageSize=null)
- {
- $cyd = (new Cyd());
- $data = $cyd->with(['unitProduction', 'unitTest','unitSample'])->where($where)->page($pageNum,$pageSize)->select();
- return $data;
- }
- public function countSampleListByTaskIdAndUid($where)
- {
- $cyd = (new Cyd());
- $count = $cyd->with(['unitProduction', 'unitTest','unitSample'])->where($where)->count();
- return $count;
- }
- public function createSample($cyd_data)
- {
- $result = $this->insertGetId($cyd_data);
- return $result;
- }
- public function updateCydDataByID($id, $data)
- {
- $result = $this->where('id','=',$id)->save($data);
- return $result;
- }
- //用于生成抽样单编号的
- public function countSampleCreateID()
- {
- return $this->whereDay('createtime','today')->count();
- }
- }
|