assign('phone',$Data['phone']);
// $this->assign('companyid',$Data['companyid']);
$wxry_id_sql="select * from ytiot_xj_inspectors where phone='".$Data['phone']."' and zn in(4,5,6,7)";
$res=add66($wxry_id_sql);
// print_r($res);
$wxry_id_list="";
if($res!=null){
foreach ($res as $key=>$value){
// print_r($key);
if ($key==0){
// print_r("第".$key.$res[$key]['id']);
$wxry_id_list.= $res[$key]['id'];
}else{
// print_r("第".$key.$res[$key]['id']);
$wxry_id_list.=','. $res[$key]['id'];
}
}
// print_r($wxry_id_list);
$zp_sql="select * from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") order by cl_type asc";
$zp=add66($zp_sql);
$dqsj1=date("Y-m-d",time());
$arr = array();
foreach ($zp as $key=>$value){
$a=date('Y-m-d', strtotime($zp[$key]['y_complete_time']));
$a1=date('Y-m-d', strtotime($zp[$key]['sh_time']));
if($zp[$key]['cl_type']==1 || $zp[$key]['cl_type']==2 || $zp[$key]['cl_type']==3 || ($zp[$key]['cl_type']==4 && $a1==$dqsj1) || ($zp[$key]['cl_type']==5 && $a1>=$dqsj1)){
if ($zp[$key]['sj_type']==1){
$arr[$key]['sj_type_name']='故障';
}elseif ($zp[$key]['sj_type']==2){
$arr[$key]['sj_type_name']='隐患';
}elseif ($zp[$key]['sj_type']==3){
$arr[$key]['sj_type_name']='其他';
}
// if ($zp[$key]['cl_type']==1){
// $arr[$key]['cl_type_anme']='未处理';
// }elseif ($zp[$key]['cl_type']==2){
// $arr[$key]['cl_type_anme']='未审核';
// }elseif ($zp[$key]['cl_type']==3){
// $arr[$key]['cl_type_anme']='审核未通过';
// }elseif ($zp[$key]['cl_type']==4){
// $arr[$key]['cl_type_anme']='已完成';
// }elseif ($zp[$key]['cl_type']==5){
// $arr[$key]['cl_type_anme']='超时完成';
// }
$arr[$key]['wx_name']=$zp[$key]['wx_name'];
$arr[$key]['id']=$zp[$key]['id'];
$arr[$key]['cl_type']=$zp[$key]['cl_type'];
}
}
// $zsl_sql="select count(*) as zsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type in(1,2,3,4,5)";
// $zsl=add66($zsl_sql);
// print_r($zsl_sql);
// print_r($zsl);
$wclsl_sql="select count(*) as wclsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=1";
$wclsl=add66($wclsl_sql);
if (empty($wclsl)){
$wclsl[0]['wclsl']=0;
}
$wshsl_sql="select count(*) as wshsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=2";
$wshsl=add66($wshsl_sql);
if (empty($wshsl)){
$wshsl[0]['wshsl']=0;
}
$shwtgsl_sql="select count(*) as shwtgsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=3";
$shwtgsl=add66($shwtgsl_sql);
if (empty($shwtgsl)){
$shwtgsl[0]['shwtgsl']=0;
}
$ywcsl_sql="select count(*) as ywcsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=4 and sh_time='%".$dqsj1."%'";
$ywcsl=add66($ywcsl_sql);
if (empty($ywcsl)){
$ywcsl[0]['ywcsl']=0;
}
$cswcsl_sql="select count(*) as cswcsl from ytiot_xj_event_processing where person_liable in(".$wxry_id_list.") and cl_type=5 and sh_time='%".$dqsj1."%'";
$cswcsl=add66($cswcsl_sql);
if (empty($cswcsl)){
$cswcsl[0]['cswcsl']=0;
}
$zsl=$wclsl[0]['wclsl']+$wshsl[0]['wshsl']+$shwtgsl[0]['shwtgsl']+$ywcsl[0]['ywcsl']+$cswcsl[0]['cswcsl'];
$this->assign('zsl',$zsl);
$this->assign('wclsl',$wclsl[0]['wclsl']);
$this->assign('wshsl',$wshsl[0]['wshsl']);
$this->assign('shwtgsl',$shwtgsl[0]['shwtgsl']);
$this->assign('ywcsl',$ywcsl[0]['ywcsl']);
$this->assign('cswcsl',$cswcsl[0]['cswcsl']);
$this->assign('companyid',$Data['companyid']);
// print_r($arr);
$this->assign('ResData',$arr);
}
// print_r($arr);
// exit();
$this->display('Maintinfo/device_manger');
}
public function bd(){
$Data=I();
// print_r($Data);
$jlid_sql = "select dwjl_id,sj_type,id from ytiot_xj_event_processing where id=".$Data['id'];
// print_r("测试0".$jlid_sql);
$jlid=add66($jlid_sql);
// print_r("测试0".$jlid);
if ($jlid[0]['sj_type']==1){
$sj_type_name='故障';
}elseif ($jlid[0]['sj_type']==2){
$sj_type_name='隐患';
}elseif ($jlid[0]['sj_type']==3){
$sj_type_name='其他';
}
if($jlid!=null){
$dwid_sql = "select spot_id from ytiot_xj_spot_operation_record where id=".$jlid[0]['dwjl_id'];
// print_r("测试1".$dwid_sql);
$dwid=add66($dwid_sql);
// print_r("测试2".$dwid);
if($dwid[0]['spot_id']!=null){
$dz_sql = "select spot_address from ytiot_xj_inspection_points where id=".$dwid[0]['spot_id'];
$dz=add66($dz_sql);
if($dz[0]['spot_address']!=null){
$address=$dz[0]['spot_address'];
}
}
}
// print_r($sj_type_name);
$this->assign('sj_type_name',$sj_type_name);
$this->assign('id',$jlid[0]['id']);
$this->assign('address',$address);
$this->display('Maintinfo/bxform');
}
public function tj()
{
$Data=I();
$time=date('Y-m-d h:i:s',time());
$BasefName='';
$tmpFilePath = $_FILES['img']['tmp_name'];
//确保我们有一个文件路径
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;
//将文件上传到临时目录中
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
// $newFilePath =$BasefName;
$sql="update ytiot_xj_event_processing set data1='1',jg_remarks='".$Data['jg_remarks']."',cl_time='".$time."',picture_path='".$newFilePath1."',cl_type=2 where id=".$Data['id'];
$val=$res1=addDataInfo($sql);
if($val){
// echo "";
$this->success('保存成功',U('Maintinfo/index'),3);
}else{
$this->error('上传失败');
}
}else{
$this->error('上传失败');
}
}
}
public function change()
{
$Data=I('');
$Map['sp_monitor.company']=$Data['companyid'];
switch ($Data['type'])
{
case 'fire':
$Map['sp_monitor.dwtype']=1;
break;
case 'water':
$Map['sp_monitor.dwtype']=array('in','2,5');
break;
case 'fume':
$Map['sp_monitor.dwtype']=3;
break;
case 'rtu':
$Map['sp_monitor.dwtype']=6;
break;
case 'efire':
$Map['sp_monitor.dwtype']=7;
break;
default:
break;
}
$count=M('monitor')->where($Map)->count();
$this->assign('count',$count);
$this->assign('phone',$Data['phone']);
$this->assign('companyid',$Data['companyid']);
$this->assign('type',$Data['type']);
//print_r($Map);
$ResData=M('monitor')->where($Map)->select();
$this->assign('ResData',$ResData);
$this->display('Maintinfo/dmanger-list');
}
public function setform()
{
$Data=I();
$this->assign('ownname',$Data[owner_name]);
$this->assign('companyid',$Data[companyid]);
$this->assign('ownid',$Data[owner_code]);
$this->assign('type',$Data['type']);
$this->assign('editor',$Data['phone']);
$time=date('Y-m-d h:i:s',time());
if($Data['companyid']){
$ResData=M('owner_company')->where("owner_id=$Data[companyid]")->find();
}
$this->assign('owner_name',$ResData['owner_name']);
$this->assign('address',$ResData['owner_address']);
$BasefName='';
$tmpFilePath = $_FILES['img']['tmp_name'];
//确保我们有一个文件路径
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;
//将文件上传到临时目录中
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
$newFilePath =$BasefName;
$sql="insert into sp_maint_infolist(owner_code,owner_name,owner_address,comp_name,company,type,image,datetime,content,editor) value(
'$Data[owner_code]','$Data[ownname]','$Data[owner_address]','$Data[owner_name]','$Data[companyid]','$Data[types]','$newFilePath','$time','$Data[content]','$Data[editors]')";
if($Data[editors]){
$val=M()->execute($sql);
if($val){
echo "";
}else{
$this->error('上传失败');
}
}
}else{
$this->error('上传失败');
}
}
$this->display('Maintinfo/setform');
}
public function maintlist()
{ $Data=I();
$Map['sp_maint_info.type']=$Data['type'];
$Map['sp_maint_info.company']=$Data['compangid'];
$counts=M('maint_info')->where($Map)->count();
//echo $counts;
$ResData=M('maint_info')->where($Map)->order("datetime desc")->select();
//echo M('maint_info')->getLastSql();
$this->assign('ResData',$ResData);
$this->assign('counts',$counts);
$this->assign('count',$Data['count']);
$this->assign('type',$Data['type']);
$this->assign('companyid',$Data['compangid']);
$this->display('Maintinfo/maint-list');
}
}
?>