...
|
...
|
@@ -13,6 +13,7 @@ use think\Validate; |
|
|
use cmf\controller\RestBaseController;
|
|
|
use app\portal\model\YearsModel;
|
|
|
use app\portal\model\SpotModel;
|
|
|
use app\portal\model\TestModel;
|
|
|
/**
|
|
|
* @title 年检
|
|
|
*/
|
...
|
...
|
@@ -20,33 +21,39 @@ class YearsController extends RestBaseController |
|
|
{
|
|
|
|
|
|
/**
|
|
|
* @title 添加年检点
|
|
|
* @title 添加检测
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/addSpot
|
|
|
* @url /api/home/years/addYearTest
|
|
|
* @method POST
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
* @param name:spot_name type:string require:1 default: other desc:年检点名称
|
|
|
*
|
|
|
* @return spot_id:年检点id
|
|
|
* @param name:test_time type:inter require:1 default: other desc:检测点时间
|
|
|
* @param name:address type:string require:1 default: other desc:检测点地点
|
|
|
* @param name:remark type:string require:1 default: other desc:检测点备注
|
|
|
*/
|
|
|
public function addSpot(){
|
|
|
if($this->request->post()){
|
|
|
public function addYearTest(){
|
|
|
if($this->request->isPost()){
|
|
|
$data = $this->request->post();
|
|
|
$rule = config('site.add_spot');
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
//如果是甲方,则没有权限操作
|
|
|
if($user['party'] == 0){
|
|
|
$this->error('无权操作');
|
|
|
}
|
|
|
|
|
|
$rule = config('site.add_year_test');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check($data)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
$data['p_id'] = $user['project_id'];
|
|
|
|
|
|
$data['project_id'] = $user['project_id'];
|
|
|
$data['create_time'] = time();
|
|
|
$spotModel = new SpotModel();
|
|
|
$res = $spotModel->create($data);
|
|
|
$test = new TestModel();
|
|
|
$res = $test->create($data);
|
|
|
if($res){
|
|
|
$this->success('成功',['spot_id'=>$res->id]);
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
}
|
...
|
...
|
@@ -56,124 +63,159 @@ class YearsController extends RestBaseController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 年检列表
|
|
|
* @title 检测列表
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/insList
|
|
|
* @url /api/home/years/testList
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @return id:项目id
|
|
|
* @return project_name:项目名称
|
|
|
* @return point: @
|
|
|
* @point id:巡检点id spot_name:年检名称 status:年检状态(0:已检查,1:故障,2:未完成)
|
|
|
* @return is_finish: 未完成数量
|
|
|
* @param name:page type:inter require:1 default: other desc:分页页码
|
|
|
* @return data: @
|
|
|
* @data id:年检检测id project_id:项目id test_time:检测时间 address:检测地点 remark:检测备注 company_name:检测甲方公司
|
|
|
* @return page:当前页数
|
|
|
* @return total_page:总页数
|
|
|
*/
|
|
|
public function insList(){
|
|
|
public function testList(){
|
|
|
if($this->request->isGet()){
|
|
|
$page = $this->request->get('page');
|
|
|
$rule = config('site.pages');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['page'=>$page])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$common = new CommonController();
|
|
|
$arr = $common->getInsList(1);
|
|
|
$this->success('成功',$arr);
|
|
|
$res = $common->getTestList($page);
|
|
|
//查询总页数
|
|
|
$total_page = $common->getTestPage();
|
|
|
$this->success('成功',['data'=>$res,'page'=>intval($page),'total_page'=>$total_page]);
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 添加年检页面
|
|
|
* @title 检测详情
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/insAdd
|
|
|
* @url /api/home/years/testDetail
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:id type:int require:1 default: other desc:年检点id
|
|
|
* @param name:id type:inter require:1 default: other desc:年检检测id
|
|
|
*
|
|
|
* @return spot_id:年检点id
|
|
|
* @return spot_name:年检点名称
|
|
|
* @return id:年检检测id
|
|
|
* @return project_id:项目id
|
|
|
* @return project_name:项目名称
|
|
|
* @return test_time:检测时间
|
|
|
* @return address:检测地点
|
|
|
* @return remark:检测备注
|
|
|
* @return company_name:检测甲方公司
|
|
|
* @return spot:年检点@
|
|
|
* @spot id:检测点id spot_name:检测点名称 status:检测点状态(0:正常,1:故障,2:未检测)
|
|
|
*/
|
|
|
public function insAdd(){
|
|
|
public function testDetail(){
|
|
|
if($this->request->isGet()){
|
|
|
$id = $this->request->get('id');
|
|
|
$rule = config('site.ins_add');
|
|
|
|
|
|
$rule = config('site.data');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['id'=>$id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
//查询年检名称
|
|
|
$arr = Db::name('spot')
|
|
|
->alias('po')
|
|
|
->join('project p','po.p_id = p.id','LEFT')
|
|
|
->where('po.id',$id)
|
|
|
->field('po.id spot_id,po.spot_name,p.id project_id,p.name project_name')
|
|
|
$res = Db::name('test')
|
|
|
->where('id',$id)
|
|
|
->field('id,project_id,test_time,address,remark')
|
|
|
->find();
|
|
|
$this->success('成功',$arr);
|
|
|
if($res){
|
|
|
$common = new CommonController();
|
|
|
$company_name = $common->getACompanyName($res['project_id']);
|
|
|
$res['company_name'] = $company_name;
|
|
|
//获取巡检点
|
|
|
$spot = $common->getSpotList(['test_id'=>$res['id'],'project_id'=>$res['project_id']]);
|
|
|
$res['spot'] = $spot;
|
|
|
}
|
|
|
$this->success('成功',$res);
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 添加年检提交
|
|
|
* @title 添加检测点
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/insAddPost
|
|
|
* @url /api/home/years/addSpot
|
|
|
* @method POST
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:spot_id type:int require:1 default: other: desc:年检点id
|
|
|
* @param name:project_id type:int require:1 default: other: desc:项目id
|
|
|
* @param name:status type:int require:1 default: other desc:年检点状态(0:已检查,1:故障)
|
|
|
* @param name:create_time type:int require:1 default: other desc:年检时间
|
|
|
* @param name:images type:array require:1 default: other desc:年检图片(二维数组形式)
|
|
|
* @param name:test_id type:string require:1 default: other desc:检测id
|
|
|
* @param name:spot_name type:string require:1 default: other desc:检测点名称
|
|
|
* @param name:project_id type:string require:1 default: other desc:项目id
|
|
|
*/
|
|
|
public function insAddPost(){
|
|
|
if($this->request->isPost()){
|
|
|
public function addSpot(){
|
|
|
if($this->request->post()){
|
|
|
$data = $this->request->post();
|
|
|
$rule = config('site.years_post');
|
|
|
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
//如果是甲方,则没有权限操作
|
|
|
if($user['party'] == 0){
|
|
|
$this->error('无权操作');
|
|
|
}
|
|
|
|
|
|
$rule = config('site.add_spot');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check($data)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$data['create_time'] = time();
|
|
|
$spotModel = new SpotModel();
|
|
|
$res = $spotModel->create($data);
|
|
|
if($res){
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$data['uid'] = $this->userId;
|
|
|
//获取甲方,乙方
|
|
|
$common = new CommonController();
|
|
|
|
|
|
//处理图片+时间格式,序列化存入数据库中
|
|
|
//绝对路径转相对路径
|
|
|
$data['images'] = $common->relationUrl($data['images']);
|
|
|
|
|
|
$party = $common->getUserIdentity();
|
|
|
/**
|
|
|
* @title 删除检测点
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/deleteSpot
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:id type:string require:1 default: other desc:检测点id
|
|
|
*/
|
|
|
public function deleteSpot(){
|
|
|
if($this->request->get()){
|
|
|
$id = $this->request->get('id');
|
|
|
|
|
|
$where = [
|
|
|
'project_id'=>$data['project_id'],
|
|
|
'spot_id'=>$data['spot_id'],
|
|
|
'party'=>$party['party']
|
|
|
];
|
|
|
//查询是否已添加巡检
|
|
|
$result = Db::name('years')
|
|
|
->where($where)
|
|
|
->whereTime('create_time','year')
|
|
|
->find();
|
|
|
if($result){
|
|
|
$this->error('您已提交过年检点信息!');
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
//如果是甲方,则没有权限操作
|
|
|
if($user['party'] == 0){
|
|
|
$this->error('无权操作');
|
|
|
}
|
|
|
|
|
|
$data['party'] = $party['party'];
|
|
|
$yearsModel = new YearsModel();
|
|
|
|
|
|
// $keys = ['images','file_time'];
|
|
|
// $images = $common->array_merge_more($keys, $data['images'], $data['file_time']);
|
|
|
$rule = config('site.data');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check(['id'=>$id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
|
|
|
$res = $yearsModel->create($data);
|
|
|
$spotModel = new SpotModel();
|
|
|
$res = $spotModel->where('id',$id)->delete();
|
|
|
if($res){
|
|
|
$this->success('您的年检点信息添加成功!');
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
}
|
...
|
...
|
@@ -183,26 +225,23 @@ class YearsController extends RestBaseController |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 编辑年检页面
|
|
|
* @title 检测点详情
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/insEdit
|
|
|
* @url /api/home/years/spotDetail
|
|
|
* @method GET
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:id type:int require:1 default: other desc:年检点id
|
|
|
* @param name:id type:inter require:1 default: other desc:检测点id
|
|
|
*
|
|
|
* @return spot_id:年检点id
|
|
|
* @return spot_name:年检点名称
|
|
|
* @return project_id:项目id
|
|
|
* @return project_name:项目名称
|
|
|
* @return status:年检点状态(0:已检查,1:故障)
|
|
|
* @return images:年检图片@
|
|
|
* @return id:检测点id
|
|
|
* @return spot_name:检测点名称
|
|
|
* @return status:检测点状态(0:正常,1:故障,2:未检测)
|
|
|
* @return images:检测点图片@
|
|
|
* @images image_url:图片路径 file_time:图片时间
|
|
|
* @return create_time:年检时间
|
|
|
*/
|
|
|
public function insEdit(){
|
|
|
public function spotDetail(){
|
|
|
if($this->request->isGet()){
|
|
|
$id = $this->request->get('id');
|
|
|
$rule = config('site.ins_add');
|
...
|
...
|
@@ -210,63 +249,114 @@ class YearsController extends RestBaseController |
|
|
if (!$validate->check(['id'=>$id])) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getIdentity();
|
|
|
//查询年检名称
|
|
|
$res = Db::table('xf_spot')
|
|
|
->alias('po')
|
|
|
->join('xf_years','po.id = xf_years.spot_id','LEFT')
|
|
|
->join('xf_project p','po.p_id = p.id','LEFT')
|
|
|
->whereTime('xf_years.create_time','year')
|
|
|
->where(['xf_years.party'=>$user['party'],'po.id'=>$id])
|
|
|
->field('po.id spot_id,po.spot_name,p.id project_id,p.name project_name,xf_years.status,xf_years.images,xf_years.create_time')
|
|
|
//查询年检名称,状态
|
|
|
$res = Db::name('spot')
|
|
|
->where(['id'=>$id])
|
|
|
->field('id,test_id,spot_name')
|
|
|
->find();
|
|
|
//相对路径转绝对路径
|
|
|
if($res['images']){
|
|
|
$arr = [];
|
|
|
if($res){
|
|
|
$arr['id'] = $res['id'];
|
|
|
$arr['spot_name'] = $res['spot_name'];
|
|
|
$arr['status'] = 2;
|
|
|
$arr['images'] = [];
|
|
|
//查询检测时间
|
|
|
$common = new CommonController();
|
|
|
$res['images'] = $common->absolutionUrl($res['images']);
|
|
|
//根据检测时间查看是否检测巡检点
|
|
|
$years = $common->getYearsList($id,'status,images');
|
|
|
if($years){
|
|
|
$arr['status'] = $years['status'];
|
|
|
$arr['images'] = $common->absolutionUrl($years['images']);
|
|
|
}
|
|
|
}
|
|
|
$this->success('成功',$res);
|
|
|
$this->success('成功',$arr);
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 编辑巡检提交
|
|
|
* @title 添加检测点状态
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/insEditPost
|
|
|
* @url /api/home/years/addTestStatus
|
|
|
* @method POST
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:spot_id type:int require:1 default: other: desc:年检点id
|
|
|
* @param name:project_id type:int require:1 default: other: desc:项目id
|
|
|
* @param name:status type:int require:1 default: other desc:年检点状态(0:已检查,1:故障)
|
|
|
* @param name:create_time type:int require:1 default: other desc:年检时间
|
|
|
* @param name:images type:array require:1 default: other desc:年检图片(二维数组形式)
|
|
|
*
|
|
|
* @param name:spot_id type:inter require:1 default: other desc:检测点id
|
|
|
* @param name:status type:inter require:1 default: other desc:检测点状态(0:正常,1:故障)
|
|
|
* @param name:images type:array require:1 default: other desc:检测点图片(二维数组形式)
|
|
|
*/
|
|
|
public function insEditPost(){
|
|
|
public function addTestStatus(){
|
|
|
if($this->request->isPost()){
|
|
|
$data = $this->request->post();
|
|
|
$rule = config('site.years_post');
|
|
|
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
//如果是甲方,则没有权限操作
|
|
|
if($user['party'] == 0){
|
|
|
$this->error('无权操作');
|
|
|
}
|
|
|
$rule = config('site.test_status');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check($data)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
//绝对路径转相对路径
|
|
|
$common = new CommonController();
|
|
|
$images = $common->relationUrl($data['images']);
|
|
|
$arr['images'] = $images;
|
|
|
$data['images'] = $images;
|
|
|
$data['uid'] = $this->userId;
|
|
|
$data['create_time'] = time();
|
|
|
$years = new YearsModel();
|
|
|
$res = $years->create($data);
|
|
|
if($res){
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @title 修改检测点状态
|
|
|
* @description 接口说明
|
|
|
* @author 开发者
|
|
|
* @url /api/home/years/editTestStatus
|
|
|
* @method POST
|
|
|
*
|
|
|
* @header name:token require:1 default: desc:header
|
|
|
*
|
|
|
* @param name:spot_id type:inter require:1 default: other desc:检测点id
|
|
|
* @param name:status type:inter require:1 default: other desc:检测点状态(0:正常,1:故障)
|
|
|
* @param name:images type:array require:1 default: other desc:检测点图片(二维数组形式)
|
|
|
*/
|
|
|
public function editTestStatus(){
|
|
|
if($this->request->isPost()){
|
|
|
$data = $this->request->post();
|
|
|
|
|
|
$arr['status'] = $data['status'];
|
|
|
$arr['create_time'] = $data['create_time'];
|
|
|
$yearsModel = new YearsModel();
|
|
|
$user = $common->getIdentity();
|
|
|
$yearsModel->where(['spot_id'=>$data['spot_id'],'party'=>$user['party']])->whereTime('create_time','year')->update($arr);
|
|
|
$this->success('保存成功!');
|
|
|
$common = new CommonController();
|
|
|
$user = $common->getUserIdentity();
|
|
|
//如果是甲方,则没有权限操作
|
|
|
if($user['party'] == 0){
|
|
|
$this->error('无权操作');
|
|
|
}
|
|
|
$rule = config('site.test_status');
|
|
|
$validate = new Validate($rule['rule'],$rule['msg']);
|
|
|
if (!$validate->check($data)) {
|
|
|
$this->error($validate->getError());
|
|
|
}
|
|
|
//绝对路径转相对路径
|
|
|
$images = $common->relationUrl($data['images']);
|
|
|
$years = new YearsModel();
|
|
|
$res = $years->where(['spot_id'=>$data['spot_id']])->update(['status'=>$data['status'],'images'=>$images]);
|
|
|
if($res){
|
|
|
$this->success('成功');
|
|
|
}else{
|
|
|
$this->error('失败');
|
|
|
}
|
|
|
}else{
|
|
|
$this->error('请求方式错误!');
|
|
|
}
|
...
|
...
|
|