作者 jinglong
1 个管道 的构建 通过 耗费 5 秒

修改标题检索

... ... @@ -930,4 +930,17 @@ return array (
'confirm_uid.number' => '申请验收人必须为数字',
]
],
//项目id
'project_ids' => [
'rule' => [
'project_id' => 'require|number',
'type' => 'require|number',
],
'msg' => [
'project_id.require' => '项目id不能为空',
'project_id.number' => '项目id必须是数字',
'type.require' => '类型不能为空',
'type.number' => '类型必须是数字',
]
],
);
\ No newline at end of file
... ...
... ... @@ -1366,6 +1366,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('c.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('c.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -1405,6 +1410,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('c.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('c.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -1452,6 +1462,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('r.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('r.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -1492,6 +1507,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('r.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('r.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -1535,6 +1555,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('r.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('r.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -1580,6 +1605,11 @@ class CommonController extends RestBaseController
if (!empty($project_id)) {
$query->where('r.project_id', $project_id);
}
//标题id
$title_id = !empty($data['title_id'])&&isset($data['title_id'])?$data['title_id']:'';
if (!empty($title_id)) {
$query->where('r.id', $title_id);
}
//日期范围查询
$startTime = isset($data['start_time'])&&!empty($data['start_time'])?$data['start_time']:'';
$endTime = isset($data['end_time'])&&!empty($data['end_time'])?$data['end_time']:'';
... ... @@ -2599,4 +2629,15 @@ class CommonController extends RestBaseController
return $registration_id;
}
//根据项目id获取title
public function getTitleById($table,$project_id){
$res = Db::name($table)
->where('project_id',$project_id)
->field('id,title')
->order('id desc')
->select()
->toArray();
return $res;
}
}
... ...
... ... @@ -11,6 +11,87 @@ use think\Db;
*/
class ReportController extends RestBaseController
{
/**
* @title 获取项目标题列表
* @description 接口说明
* @author 开发者
* @url /api/home/report/getTitleList
* @method GET
*
* @header name:token require:1 default: desc:header
*
* @param name:project_id type:inter require:0 default: other desc:项目id
* @param name:type type:inter require:0 default: other desc:类型(1:月检,2:年检,3:维修,4:改造,5:培训,6:演习 )
*
* @return title_a:字母排序['b','c']
* @return title_n:项目名称@
* @title_n acronym:字母 title_l:项目列表@
* @title_l id:列表标题id title:标题名称
*/
public function getTitleList(){
if($this->request->isGet()){
$project_id = $this->request->get('project_id');
$type = $this->request->get('type');
$rule = config('site.project_ids');
$validate = new Validate($rule['rule'],$rule['msg']);
if (!$validate->check(['project_id'=>$project_id,'type'=>$type])) {
$this->error($validate->getError());
}
$res = [];
$common = new CommonController();
if($type == 1){
//月检
$res = $common->getTitleById('check',$project_id);
}else if($type == 2){
//年检
$res = $common->getTitleById('pro_check',$project_id);
}else if($type == 3){
//维修
$res = $common->getTitleById('repair',$project_id);
}else if($type == 4){
//改造
$res = $common->getTitleById('reform',$project_id);
}else if($type == 5){
//培训
$res = $common->getTitleById('train',$project_id);
}else if($type == 6){
//演习
$res = $common->getTitleById('exercise',$project_id);
}
$arr2 = [];
if($res){
$acronym = [];
foreach($res as $key=>$value){
$acronym[$key] = $common->getFirstCharter($value['title']);
}
$acronym =array_values(array_unique($acronym));
sort($acronym);
$arr1 = [];
foreach($acronym as $a_key=>$a_value){
$k = 0;
$arr1[$a_key]['acronym'] = $a_value;
foreach($res as $r_value){
$k+=0;
$first = $common->getFirstCharter($r_value['title']);
if($first == $a_value){
$arr1[$a_key]['title_l'][$k] = $r_value;
$k++;
}
}
}
$arr2['title_a'] = $acronym;
$arr2['title_n'] = $arr1;
}
$this->success('成功',$arr2);
}else{
$this->error('请求方式错误!');
}
}
/**
* @title 月检年检项目状态
... ... @@ -159,6 +240,7 @@ class ReportController extends RestBaseController
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:title_id type:inter require:0 default: other desc:标题id(检索)
* @param name:status type:inter require:0 default: other desc:状态(检索状态:-1:全部,0:待确认,1:已驳回,2:进行中,3:申请中,4:已完成)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
... ... @@ -226,6 +308,7 @@ class ReportController extends RestBaseController
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:title_id type:inter require:0 default: other desc:标题id(检索)
* @param name:status type:inter require:0 default: other desc:状态(检索状态:-1:全部,0:待确认,1:进行中,2:申请中,3:已完成)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
... ... @@ -293,6 +376,7 @@ class ReportController extends RestBaseController
*
* @param name:company_id type:inter require:0 default: other desc:企业id(总领导传此字段)
* @param name:project_id type:inter require:0 default: other desc:项目id(检索)
* @param name:title_id type:inter require:0 default: other desc:标题id(检索)
* @param name:status type:inter require:0 default: other desc:状态(检索状态:-1:全部,0:待确认,1:进行中,2:已完成)
* @param name:start_time type:inter require:0 default: other desc:开始日期(检索开始日期)
* @param name:end_time type:inter require:0 default: other desc:开始日期(检索结束日期)
... ...