| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 | 
							- <?php
 
- namespace App\Service;
 
- use App\Model\BasicProcess;
 
- use App\Model\Process;
 
- use App\Model\Technology;
 
- /**
 
-  * 工艺相关
 
-  * @package App\Models
 
-  */
 
- class TechnologyService extends Service
 
- {
 
-     public function technologyEdit($data){
 
-         list($status,$msg) = $this->technologyRule($data);
 
-         if(!$status) return [$status,$msg];
 
-         if($this->isEmpty($data,'id')) return [false,'ID不存在'];
 
-         $first = Technology::where('title',$data['title'])->where('id','<>',$data['id'])->where('del_time',0)->first();
 
-         if(!empty($first))return [false,'名称已存在!'];
 
-         $model = new Technology();
 
-         $model = $model->where('id',$data['id'])->first();
 
-         $model->title = $data['title'];
 
-         $model->process_id = $data['process_id'];
 
-         $model->save();
 
-         return [true,'保存成功!'];
 
-     }
 
-     public function technologyAdd($data,$user){
 
-         list($status,$msg) = $this->technologyRule($data);
 
-         if(!$status) return [$status,$msg];
 
-         $first = Technology::where('title',$data['title'])->where('del_time',0)->first();
 
-         if(!empty($first))return [false,'名称已存在!'];
 
-         $model = new Technology();
 
-         $model->title = $data['title'];
 
-         $model->process_id = $data['process_id'];
 
-         $model->save();
 
-         return [true,'保存成功!'];
 
-     }
 
-     public function technologyDel($data){
 
-         if($this->isEmpty($data,'id')) return [false,'ID必须!'];
 
-         Technology::where('id',$data['id'])->update([
 
-             'del_time' => time()
 
-         ]);
 
-         return [true,'删除成功'];
 
-     }
 
-     public function technologyList($data){
 
-         $model = Technology::where('del_time',0)->select('*');
 
-         if(! empty($data['title'])) $model->where('title', 'LIKE', '%'.$data['title'].'%');
 
-         $list = $this->limit($model,'',$data);
 
-         return [200,$list];
 
-     }
 
-     public function technologyRule($data){
 
-         if($this->isEmpty($data,'title')) return [false,'名称不能为空!'];
 
-         if($this->isEmpty($data,'process_id')) return [false,'工序不能为空!'];
 
-         return [true,''];
 
-     }
 
-     public function technologyCopy($data,$user){
 
-         list($status,$msg) = $this->technologyCopyRule($data);
 
-         if(! $status) return [$status,$msg];
 
-         $first = Technology::where('id',$data['id'])->where('del_time',0)->first();
 
-         $model = new Technology();
 
-         $model->title = $data['title'];
 
-         $model->process_id = $first->process_id;
 
-         $model->save();
 
-         return [true,'保存成功!'];
 
-     }
 
-     public function technologyCopyRule($data){
 
-         if($this->isEmpty($data,'id')) return [false,'复制的工序ID不能为空!'];
 
-         if($this->isEmpty($data,'title')) return [false,'名称不能为空!'];
 
-         $bool = Technology::where('title',$data['title'])->where('del_time',0)->exists();
 
-         if($bool) return [false,'名称已存在!'];
 
-         return [true,''];
 
-     }
 
- }
 
 
  |