初始化代码
This commit is contained in:
143
app/farm/model/LandText.php
Normal file
143
app/farm/model/LandText.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
namespace app\farm\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class LandText extends BaseModel
|
||||
{
|
||||
//定义表名
|
||||
protected $name = 'lbfarm_land_text';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:04
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function dataAdd($data){
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:05
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function dataUpdate($dis,$data){
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param $data
|
||||
* @功能说明:1地块服务 2关联种子 3关联溯源 4关联监控
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-12-20 15:48
|
||||
*/
|
||||
public function eventLand($id,$data){
|
||||
|
||||
$arr = [
|
||||
|
||||
1 => 'massif',
|
||||
|
||||
2 => 'seed',
|
||||
|
||||
// 3 => 'source',
|
||||
|
||||
4 => 'monitor',
|
||||
|
||||
5 => 'cycle'
|
||||
];
|
||||
|
||||
foreach ($arr as $k=>$v){
|
||||
|
||||
if(key_exists($v,$data)){
|
||||
|
||||
$this->updateSome($id,$data['uniacid'],$data[$v],$k);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2021-12-10 17:15
|
||||
* @功能说明:1 地块服务 2关联种子 3关联溯源 4关联监控
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function updateSome($id,$uniacid,$data,$type){
|
||||
|
||||
$this->where(['uniacid'=>$uniacid,'type'=>$type,'land_id'=>$id])->delete();
|
||||
|
||||
if(!empty($data)){
|
||||
|
||||
foreach ($data as $k=>$v){
|
||||
|
||||
$insert[$k] = [
|
||||
|
||||
'uniacid' => $uniacid,
|
||||
|
||||
'land_id' => $id,
|
||||
|
||||
'obj_id' => $v,
|
||||
|
||||
'type' => $type,
|
||||
|
||||
// 'source_id' => $type==2?$v['source_id']:0,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
$this->saveAll($insert);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-09-29 11:43
|
||||
* @功能说明:
|
||||
*/
|
||||
public function dataInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user