正在显示
3 个修改的文件
包含
61 行增加
和
0 行删除
@@ -716,4 +716,17 @@ return array ( | @@ -716,4 +716,17 @@ return array ( | ||
716 | 'version_number.require' => '版本号不能为空', | 716 | 'version_number.require' => '版本号不能为空', |
717 | ] | 717 | ] |
718 | ], | 718 | ], |
719 | + //日检记录 | ||
720 | + 'ins_record' => [ | ||
721 | + 'rule' => [ | ||
722 | + 'date_time' => 'require|number', | ||
723 | + 'project_id' => 'require|number', | ||
724 | + ], | ||
725 | + 'msg' => [ | ||
726 | + 'date_time.require' => '时间不能为空', | ||
727 | + 'date_time.number' => '时间必须为数字', | ||
728 | + 'project_id.require' => '项目id不能为空', | ||
729 | + 'project_id.number' => '项目id必须为数字', | ||
730 | + ] | ||
731 | + ], | ||
719 | ); | 732 | ); |
@@ -2324,4 +2324,22 @@ class CommonController extends RestBaseController | @@ -2324,4 +2324,22 @@ class CommonController extends RestBaseController | ||
2324 | return $res; | 2324 | return $res; |
2325 | } | 2325 | } |
2326 | 2326 | ||
2327 | + //根据时间搜索获取日检记录id | ||
2328 | + public function getInsRecord($table,$data){ | ||
2329 | + $time = date('Y-m-d',$data['date_time']); | ||
2330 | + $startTime = strtotime($time); | ||
2331 | + $endTime = $startTime+86400; | ||
2332 | + $res = Db::name($table) | ||
2333 | + ->alias('i') | ||
2334 | + ->join('project p','i.project_id = p.id','LEFT') | ||
2335 | + ->where('i.project_id',$data['project_id']) | ||
2336 | + ->where('i.create_time', '>=', $startTime) | ||
2337 | + ->where('i.create_time', '<=', $endTime) | ||
2338 | + ->field('i.id') | ||
2339 | + ->group("i.project_id,DATE_FORMAT(FROM_UNIXTIME(i.create_time),'%Y-%m-%d')") | ||
2340 | + ->order('i.id desc') | ||
2341 | + ->find(); | ||
2342 | + return $res; | ||
2343 | + } | ||
2344 | + | ||
2327 | } | 2345 | } |
@@ -261,4 +261,34 @@ class InspectionController extends RestBaseController | @@ -261,4 +261,34 @@ class InspectionController extends RestBaseController | ||
261 | } | 261 | } |
262 | } | 262 | } |
263 | 263 | ||
264 | + /** | ||
265 | + * @title 日检记录 | ||
266 | + * @description 接口说明 | ||
267 | + * @author 开发者 | ||
268 | + * @url /api/home/inspection/insRecord | ||
269 | + * @method GET | ||
270 | + * | ||
271 | + * @header name:token require:1 default: desc:header | ||
272 | + * | ||
273 | + * @param name:date_time type:int require:1 default: other desc:时间 | ||
274 | + * @param name:project_id type:int require:1 default: other desc:项目id | ||
275 | + * | ||
276 | + * @return id:报表id | ||
277 | + */ | ||
278 | + public function insRecord(){ | ||
279 | + if($this->request->isGet()){ | ||
280 | + $data = $this->request->get(); | ||
281 | + $rule = config('site.ins_record'); | ||
282 | + $validate = new Validate($rule['rule'],$rule['msg']); | ||
283 | + if (!$validate->check($data)) { | ||
284 | + $this->error($validate->getError()); | ||
285 | + } | ||
286 | + $common = new CommonController(); | ||
287 | + $res = $common->getInsRecord('inspect',$data); | ||
288 | + $this->success('成功',$res); | ||
289 | + }else{ | ||
290 | + $this->error('请求方式错误'); | ||
291 | + } | ||
292 | + } | ||
293 | + | ||
264 | } | 294 | } |
-
请 注册 或 登录 后发表评论