assign('res1',$res1);
$this->display('Index2/from');
}
//维保方法
public function from2(){
$res1 =I();
$this->assign('res1',$res1);
$this->display('Index2/wb_from');
}
//巡检方法
public function xjd_inset(){
$data=I();
// print_r($data);
// exit();
$zb_id=$data['zb_id'];
$spot_id=$data['spot_id'];
$wbr_id=$data['wbr_id'];
$spot_abnormal=$data['spot_abnormal'];
// $company_code1=$data['company_code'];
// print_r($spot_abnormal);
// exit();
$wc_time=date("Y-m-d H:i:s");
$dwsb_remarks=$data['dwsb_remarks'];
$data1=$data['data1'];
// $data3=2;
$people_id_sql=" select team_id,inspect_date,end_time,company_code,completion from ytiot_xj_plan_child where id=".$zb_id;
$people_id_res=add($people_id_sql);
if($people_id_res!=null){
$people_id_sql1="select person_liable_id from ytiot_xj_plan_team where id=". $people_id_res[0]['team_id'];
$people_id_res1=add($people_id_sql1);
if ($people_id_res1!=null){
$people_id = $people_id_res1[0]['person_liable_id'];
}
$ywc_time=$people_id_res[0]['inspect_date']." ".$people_id_res[0]['end_time'];
$company_code=$people_id_res[0]['company_code'];
}
$tmpFilePath = $_FILES['img']['tmp_name'];
if($_FILES["img"]["error"]==1){
$this->success('图片上传失败,图片大小超过限制2M',U('Inspection/index'),3);
}
// print_r($_FILES["file"]);
//确保我们有一个文件路径
if ($tmpFilePath != ""){
//设置我们的新文件路径
$FileCode=date('YmdHis').rand(1000,9999);
$FileName=$_FILES['img']['name'];
$FileType=strtolower(substr(strrchr($FileName,'.'),1));
$BasefName=$FileCode.'.'.$FileType;
$newFilePath ='/var/www/html/jdxf/Maintinfo/image/'.$BasefName;
$newFilePath1 ='https://qhome.usky.cn/jdxf/Maintinfo/image/'.$BasefName;
// $newFilePath ='D://QrCode/'.$BasefName;
//将文件上传到临时目录中
// exit();
// print_r("测试0".$tmpFilePath);
// print_r("测试1".move_uploaded_file($tmpFilePath, $newFilePath));
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
$wb_sql = "UPDATE ytiot_xj_spot_operation_record set people_id=".$people_id.",spot_abnormal=".$spot_abnormal.",wc_time='".$wc_time."',dwsb_remarks='".$dwsb_remarks."',data3='2',wbr_id=".$wbr_id.
" where zb_id=".$zb_id." and spot_id=".$spot_id;
// $jl_sql="insert into ytiot_xj_spot_operation_record(zb_id,spot_id,people_id,spot_abnormal,ywc_time,wc_time,company_code,dwsb_remarks,data3) value(
// $zb_id,$spot_id,$people_id,'$spot_abnormal','$ywc_time','$wc_time','$company_code','$dwsb_remarks','$data3')";
$res1=addDataInfo($wb_sql);
// print_r("测试2".$res1);
if($res1){
$photosql="select id,spot_abnormal,data1 from ytiot_xj_spot_operation_record where zb_id=".$zb_id." and spot_id=".$spot_id." and wc_time='".$wc_time."'";
$photosres=add($photosql);
echo 1;
if ($photosres!=null){
// if ($photosres[0]['spot_abnormal']==1 || $photosres[0]['spot_abnormal']==2 || $photosres[0]['spot_abnormal']==3){
// $wxsb_sql="insert into ytiot_xj_event_processing(dwjl_id,user_name,data1) value (".$photosres[0]['id'].",'".$photosres[0]['data1']."','".$data1."')";
// $photos_res=addDataInfo($wxsb_sql);
// }
if ($photosres[0]['spot_abnormal']==1 || $photosres[0]['spot_abnormal']==2 || $photosres[0]['spot_abnormal']==3){
$company_data=M()->query("select owner_id from sp_owner_company where building_id='".$company_code."'");
// $inster_sql="insert into ytiot_xj_event_processing (dwjl_id,user_name,wx_name,cl_type,data2,data3) value ('0','".$_SESSION['phone']."','".$wx_name."',2,'".$owner_data[0]['company']."','".$lsxx."')";
$wx_name='设备异常';
$dqsj= date('Y-m-d h:i:s', time());
$lsxx=$dqsj.",".$wx_name;
// $wxsb_sql="insert into ytiot_xj_event_processing(dwjl_id,user_name,wx_name,cl_type,data2,data3) value (".$photosres[0]['id'].",'".$_SESSION['phone']."','".$data1."',0,'".$company_data[0]['owner_id']."','".$lsxx."')";
$wxsb_sql="insert into ytiot_xj_event_processing (id,dwjl_id,wx_name,sj_type,y_complete_time,person_liable,zp_remarks,user_name,cl_type,jg_remarks,sh_remarks,sh_time,cl_time,picture_path,data1,data2,data3) value ('',".$photosres[0]['id'].",'".$data1."',0,'',null,'','".$photosres[0]['data1']."',0,'','','','','','','".$company_data[0]['owner_id']."','".$lsxx."');";
// print_r($wxsb_sql);
$photos_res=addDataInfo($wxsb_sql);
}
$photo_sql="insert into ytiot_xj_operation_record_photos(dwczjl_id,report_photos) value (".$photosres[0]['id'].",'".$newFilePath1."')";
$photos_res=addDataInfo($photo_sql);
if ($photos_res){
$dwzsl_sql="select count(id) as dwzsl from ytiot_xj_spot_operation_record where zb_id=".$zb_id;
// print_r('测试'.$dwzsl_sql);
$dwzsl=add($dwzsl_sql);
// print_r('测试'.$dwzsl);
$yxjzsl_sql="select count(id) as yxjzsl from ytiot_xj_spot_operation_record where zb_id=".$zb_id." and data3='2'";
// print_r('测试'.$yxjzsl_sql);
$yxjzsl=add($yxjzsl_sql);
// print_r('测试'.$yxjzsl);
if($dwzsl[0]['dwzsl']==$yxjzsl[0]['yxjzsl']){
$wcqk_sql="update ytiot_xj_plan_child set completion=100,data3='".$wc_time."' where id=".$zb_id;
$wcqk_res=addDataInfo($wcqk_sql);
if ($wcqk_res){
// echo "";
$this->success('保存成功',U('Inspection/index'),3);
}else{
$this->error('上传失败');
}
}else{
$yg=1/$dwzsl[0]['dwzsl']*100;
$completion=$people_id_res[0]['completion']+$yg;
$wcqk_sql="update ytiot_xj_plan_child set completion=".$completion." where id=".$zb_id;
$wcqk_res=addDataInfo($wcqk_sql);
if ($wcqk_res){
// echo "";
$this->success('保存成功',U('Inspection/index'),3);
}else{
$this->error('上传失败');
}
}
}else{
$this->error('上传失败');
}
}
}else{
$this->error('上传失败');
}
}else{
// $this->success('上传失败,图片大小超过上限2M',U('Inspection/index'),3);
$this->error('上传失败');
}
}
}
//维保方法
public function xjd_inset2(){
$data=I();
// print_r($data);
// exit();
$zb_id=$data['zb_id'];
$spot_id=$data['spot_id'];
$wbr_id=$data['wbr_id'];
$spot_abnormal=$data['spot_abnormal'];
$wc_time=date("Y-m-d H:i:s");
$dwsb_remarks=$data['dwsb_remarks'];
$data1=$data['data1'];
$company_code1=$data['company_code'];
// $data3=2;
$people_id_sql=" select team_id,inspect_date,end_time,company_code,completion from ytiot_xj_plan_child where id=".$zb_id;
$people_id_res=add($people_id_sql);
if($people_id_res!=null){
$people_id_sql1="select person_liable_id from ytiot_xj_plan_team where id=". $people_id_res[0]['team_id'];
$people_id_res1=add($people_id_sql1);
if ($people_id_res1!=null){
$people_id = $people_id_res1[0]['person_liable_id'];
}
$ywc_time=$people_id_res[0]['inspect_date']." ".$people_id_res[0]['end_time'];
$company_code=$people_id_res[0]['company_code'];
}
$tmpFilePath = $_FILES['img']['tmp_name'];
if($_FILES["img"]["error"]==1){
$this->success('图片上传失败,图片大小超过限制2M',U('Inspection/index'),3);
}
//确保我们有一个文件路径
if ($tmpFilePath != ""){
//设置我们的新文件路径
$FileCode=date('YmdHis').rand(1000,9999);
$FileName=$_FILES['img']['name'];
$FileType=strtolower(substr(strrchr($FileName,'.'),1));
$BasefName=$FileCode.'.'.$FileType;
$newFilePath ='/var/www/html/jdxf/Maintinfo/image/'.$BasefName;
$newFilePath1 ='https://qhome.usky.cn/jdxf/Maintinfo/image/'.$BasefName;
// $newFilePath ='D://QrCode/'.$BasefName;
//将文件上传到临时目录中
// exit();
// print_r("测试0".$tmpFilePath);
// print_r("测试1".$spot_id);
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
$wb_sql = "UPDATE ytiot_xj_spot_operation_record set people_id=".$people_id.",spot_abnormal=".$spot_abnormal.",wc_time='".$wc_time."',dwsb_remarks='".$dwsb_remarks."',data3='2',wbr_id=".$wbr_id.
" where zb_id=".$zb_id." and spot_id=".$spot_id;
// $jl_sql="insert into ytiot_xj_spot_operation_record(zb_id,spot_id,people_id,spot_abnormal,ywc_time,wc_time,company_code,dwsb_remarks,data3) value(
// $zb_id,$spot_id,$people_id,'$spot_abnormal','$ywc_time','$wc_time','$company_code','$dwsb_remarks','$data3')";
$res1=addDataInfo($wb_sql);
// print_r("测试2".$res1);
if($res1){
$photosql="select id,spot_abnormal,data1 from ytiot_xj_spot_operation_record where zb_id=".$zb_id." and spot_id=".$spot_id." and wc_time='".$wc_time."'";
$photosres=add($photosql);
if ($photosres!=null){
// if ($photosres[0]['spot_abnormal']==1 || $photosres[0]['spot_abnormal']==2 || $photosres[0]['spot_abnormal']==3){
// $wxsb_sql="insert into ytiot_xj_event_processing(dwjl_id,user_name,data1) value (".$photosres[0]['id'].",'".$photosres[0]['data1']."','".$data1."')";
// $photos_res=addDataInfo($wxsb_sql);
// }
if ($photosres[0]['spot_abnormal']==1 || $photosres[0]['spot_abnormal']==2 || $photosres[0]['spot_abnormal']==3){
$company_data=M()->query("select owner_id from sp_owner_company where building_id='".$company_code."'");
$wx_name='设备异常';
$dqsj= date('Y-m-d h:i:s', time());
$lsxx=$dqsj.",".$wx_name;
// $wxsb_sql="insert into ytiot_xj_event_processing(dwjl_id,user_name,wx_name,cl_type,data2,data3) value (".$photosres[0]['id'].",'".$_SESSION['phone']."','".$data1."',0,'".$company_code1."','".$lsxx."')";
$wxsb_sql="insert into ytiot_xj_event_processing(dwjl_id,user_name,wx_name,cl_type,data2,data3) value (".$photosres[0]['id'].",'".$_SESSION['phone']."','".$data1."',0,'".$company_data[0]['owner_id']."','".$lsxx."')";
$photos_res=addDataInfo($wxsb_sql);
}
$photo_sql="insert into ytiot_xj_operation_record_photos(dwczjl_id,report_photos) value (".$photosres[0]['id'].",'".$newFilePath1."')";
$photos_res=addDataInfo($photo_sql);
if ($photos_res){
$dwzsl_sql="select count(id) as dwzsl from ytiot_xj_spot_operation_record where zb_id=".$zb_id;
// print_r('测试'.$dwzsl_sql);
$dwzsl=add($dwzsl_sql);
// print_r('测试'.$dwzsl);
$yxjzsl_sql="select count(id) as yxjzsl from ytiot_xj_spot_operation_record where zb_id=".$zb_id." and data3='2'";
// print_r('测试'.$yxjzsl_sql);
$yxjzsl=add($yxjzsl_sql);
// print_r('测试'.$yxjzsl);
if($dwzsl[0]['dwzsl']==$yxjzsl[0]['yxjzsl']){
$wcqk_sql="update ytiot_xj_plan_child set completion=100,data3='".$wc_time."' where id=".$zb_id;
$wcqk_res=addDataInfo($wcqk_sql);
if ($wcqk_res){
// echo "";
$this->success('保存成功',U('Inspection/index2'),3);
}else{
$this->error('上传失败');
}
}else{
$yg=1/$dwzsl[0]['dwzsl']*100;
$completion=$people_id_res[0]['completion']+$yg;
$wcqk_sql="update ytiot_xj_plan_child set completion=".$completion." where id=".$zb_id;
$wcqk_res=addDataInfo($wcqk_sql);
if ($wcqk_res){
// echo "";
$this->success('保存成功',U('Inspection/index2'),3);
}else{
$this->error('上传失败');
}
}
}else{
$this->error('上传失败');
}
}
}else{
$this->error('上传失败');
}
}else{
$this->error('上传失败');
}
}
}
}