123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?php
- /**
- * Created by PhpStorm.
- * User: TianFeng
- * Date: 2019-03-18
- * Time: 15:38
- */
- namespace Home\Controller;
- use Think\Controller;
- include '../Common/function.php';
- class ScanwbController extends ComController {
- public function pdsflr(){
- $data=I('post.data');
- $company=I('post.company');
- $wxjid=I('post.wxjid');
- $wxjid1=explode('-',$wxjid);
- // print_r($wxjid);
- // echo $wxjid;
- // exit();
- $sql="select * from ytiot_t_maintenance_person where phone=".$_SESSION['phone'];
- $res=add($sql);
- if(empty($res)){
- echo 1;
- exit();
- }
- $sql1="select * from ytiot_t_qrcode_analysis2 where analysis_content='".$data."'";
- $res1=add($sql1);
- if(empty($res1)){
- echo 2;
- exit();
- }
- if(!empty($wxjid1)){
- // echo $wxjid1[0];
- $sql66="select * from ytiot_t_qrcode_analysis2 where id=".$wxjid1[0];
- $res66=add66($sql66);
- if($data!=$res66[0]['analysis_content']){
- echo 3;
- exit();
- }
- }
- $planned_date=date('Y-m-d');
- // $sql2="select * from ytiot_t_patrol_plan where personnel=".$res[0]['id']." and planned_date='".$planned_date."'";
- $sql2="select * from ytiot_t_maintenance_plan where id=".$wxjid1[1]." and planned_date='".$planned_date."'";
- $res2=add($sql2);
- $inspection_time=date('Y-m-d H:i:s');
- $res4=array();
- $res4['ms']=5;
- $res4['name_id']=$res2[0]['personnel'];
- $res4['analysis_content_id']=$wxjid1[0];
- $res4['inspection_time']=$inspection_time;
- $res4['route_id']=$res2[0]['route'];
- $res4['company']=$res2[0]['compoany_code'];
- $res4['xjjh_id']=$wxjid1[1];
- $res4['xjd_id']=$wxjid1[2];
- // print_r($res4);
- if (empty($res2)){
- echo 4;
- exit();
- }else{
- foreach ($res2 as $key=>$value){
- $sql3="select * from ytiot_t_route2 where id= ".$res2[0]['route'];
- $res3=add($sql3);
- if(!empty($res3)){
- // if(strpos($res3[$key]['route'],$res1[0]['id']) !== false){
- echo json_encode($res4);
- exit();
- // }else{
- // echo 6;
- // exit();
- // }
- }
- }
- }
- }
- public function sftjewm(){
- $data=I('post.data');
- $company=I('post.company');
- // $sql="insert into ytiot_t_qrcode_analysis (analysis_content) value ('".$data."')";
- $sql="insert into ytiot_t_qrcode_analysis2 (analysis_content,company_code) value ('".$data."','".$company."')";
- $res=addDataInfo($sql);
- if($res){
- echo 1;
- exit();
- }else{
- echo 0;
- exit();
- }
- }
- // public function qd(){
- // $data=I();
- // $sql="insert into ytiot_t_maintenance_record value (".$data['name'].",".$data['route'].",'".$data['inspection_time']."',".$data['analysis_content'].",".$data['firecl'].",'".$data['qk']."')";
- // $res=addDataInfo($sql);
- // if($res){
- //
- // }else{
- // $this->display('Index2/wbprc1');
- // }
- //
- // }
- public function wbfrom(){
- $res1 =I();
- $this->assign('res1',$res1);
- $this->display('Index2/wbfrom');
- }
- public function xjd_inset(){
- $data=I();
- // print_r($data);
- // exit();
- $sql4="select id,completion_status,company_code from ytiot_t_maintenance_plan where id=".$data['xjjh_id'];
- // print_r($data);
- // print_r($sql4);exit();
- $patrol_planid=add($sql4);
- // $sql88="select id from ytiot_t_qrcode_analysis id=".$data['analysis_content'];
- // $analysis_content=add($sql88);
- // $sql1="select id from ytiot_t_patrol_point where label=".$data['analysis_content'];
- // $resid=add($sql1);
- if(empty($data['xjd_id'])){
- $this->success('维保点为空',U('Index/index'),3);
- exit();
- }
- $sql8="select company_code from ytiot_t_maintenance_person where id=".$data['name_id'];
- $rescompany_code=add($sql8);
- if(empty($rescompany_code)){
- $this->success('维保人为空',U('Index/index'),3);
- exit();
- }
- // print_r($patrol_planid);exit();
- $sql2="insert into ytiot_t_maintenance_record (personnel,route,inspection_time,point_position,xjzt,qk,company_code) value (".$data['name_id'].",".$data['route'].",'".$data['inspection_time']."','".$data['xjd_id']."',".$data['zt'].",'".$data['qk']."','".$patrol_planid[0]['company_code']."')";
- // echo $sql;
- // exit();
- $res=addDataInfo($sql2);
- if($res){
- $sql3="select route from ytiot_t_route2 where id=".$data['route'];
- $routeid=add($sql3);
- $arr=explode(",",$routeid[0]['route']);//二维码解析id
- $z=count($arr);
- $bl1=1/$z*100;
- $bl=round($bl1,2);
- $time=date("Y-m-d");
- // $sql4="select id,completion_status from ytiot_t_patrol_plan where route=".$data['route']." and personnel=".$data['name_id']." and planned_date='".$time."' and company_code=".$data['company'];
- // $sql4="select id,completion_status from ytiot_t_patrol_plan where id=".$data['xjjh_id'];
- // $patrol_planid=add($sql4);
- // print_r($sql4);
- // print_r($patrol_planid);
- // exit();
- // $zbl=(int)$patrol_planid[0]['completion_status']+(int)$bl;
- $zbl=$patrol_planid[0]['completion_status']+$bl;
- // $sql5="update ytiot_t_patrol_plan set completion_status=".$zbl." where route=".$data['route']." and personnel=".$data['name_id']." and planned_date='".$time."'";
- $sql5="update ytiot_t_maintenance_plan set completion_status=".$zbl." where id=".$data['xjjh_id'];
- // print_r($sql5);
- // exit();
- $res1=addDataInfo($sql5);
- if($res1){
- // $this->success('保存成功',U('Inspection/index'),3);
- $this->success('保存成功',U('Maintenance/index?companyid='.$rescompany_code[0]['company_code']),3);
- }else{
- $this->success('保存失败1bl',U('Maintenance/index'),3);
- }
- }else{
- $this->success('保存失败',U('Index/index'),3);
- }
- }
- }
|