123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- namespace app\controller;
- use app\BaseController;
- use app\model\CheckDict;
- use app\service\CheckClassService;
- use app\service\CheckDetailService;
- use app\service\CheckService;
- use app\service\ZdXzqService;
- use app\service\EnterprisesService;
- use app\validate\Id;
- use app\validate\Page;
- use think\annotation\Route;
- use think\annotation\route\Middleware;
- use hg\apidoc\annotation as Apidoc;
- use think\exception\ValidateException;
- use think\response\Json;
- /**
- * @Apidoc\Title("现场检查列表")
- * @Apidoc\Group("巡检")
- * @Apidoc\Sort (9)
- */
- class Check extends BaseController
- {
- protected $middleware = [
- 'jwt',
- ];
- /**
- * @Apidoc\Title("获取现场检查列表")
- * @Apidoc\Tag("巡检")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("ihavoc")
- * @Route("getCheckList",method="GET")
- * @Middleware({"jwt"})
- */
- public function getCheckList(): Json
- {
- $page = $this->request->get();
- try {
- validate(Page::class)->check($page);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
- return $this->JsonSucess(CheckService::getCheckList($page,getXzqdmSub()));
- }
- /**
- * @Apidoc\Title("获取待检检查列表")
- * @Apidoc\Tag("巡检")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("ihavoc")
- * @Route("getWaitCheckList",method="GET")
- * @Middleware({"jwt"})
- */
- public function getWaitCheckList(): Json
- {
- $page = $this->request->get();
- try {
- validate(Page::class)->check($page);
- }catch (ValidateException $e){
- return $this->JsonError($e->getError());
- }
-
- $res = EnterprisesService::getEnterPrisesList($page, getXzqdmSub());
- foreach ($res["row"] as $key => $value){
-
- $res["row"][$key]["townsc"]=ZdXzqService::getXzqDetail($value["towns"]);
- $res["row"][$key]["countryc"] = ZdXzqService::getXzqDetail(str_pad(substr($value["towns"],0,6),9,'0'));
- $res["row"][$key]["cityc"] = ZdXzqService::getXzqDetail(str_pad(substr($value["towns"],0,4),9,'0'));
- }
- return $this->JsonSucess($res);
- }
- /**
- * @Apidoc\Title("获取现场检查项目16项总表列表")
- * @Apidoc\Tag("巡检")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("郑雪瑞")
- * @Route("getCheckDict",method="GET")
- * @Middleware({"jwt"})
- */
- public function getCheckDict():Json
- {
- return $this->JsonSucess(CheckClassService::getCheckDict());
- }
- /**
- * @Apidoc\Title("获取现场检查项目详情列表根据check_class_id")
- * @Apidoc\Tag("巡检")
- * @Apidoc\Method ("GET")
- * @Apidoc\Author ("郑雪瑞")
- * @Route("getCheckDetailDict",method="GET")
- * @Middleware({"jwt"})
- */
- public function getCheckDetailDict():Json
- {
- $id = $this->request->get();
- try {
- validate(Id::class)->check($id);
- }catch (ValidateException $e){
- }
- return $this->JsonSucess(CheckClassService::getCheckDetailByCheckId($id["id"]));
- }
- /**
- * @Apidoc\Title("添加检查信息")
- * @Apidoc\Tag("巡检")
- * @Apidoc\Method ("POST")
- * @Apidoc\Author ("ihavoc")
- * @Route("addCheckInfo",method="POST")
- * @Middleware({"jwt"})
- */
- public function addCheckInfo(): Json
- {
- $data=$this->request->post();
- $data["is_pass"]=0;
- $data["nopass"]=0;
- for ($i=0;$i<count($data["detail"]);$i++){
- if ($data["detail"][$i]["check_res"]=="1" || $data["detail"][$i]["check_res"]=="2"){
- $data["is_pass"]++;
- }else{
- $data["nopass"]++;
- }
- }
- $id=CheckService::addCheck($data);
- for ($j=0;$j<count($data["detail"]);$j++){
- $data["detail"][$i]["check_id"]=$id;
- CheckDetailService::addCheckDetail($data["detail"][$i]);
- }
- return $this->JsonSucess();
- }
- }
|