123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- include '../Common/function.php';
- class PhysicalExaminationController extends ComController {
- public function index(){
- $data =I();
- $company_code=$data['companyid'];
- $res=M()->query("select * from sp_owner where company=".$company_code);
- $company_data=M()->query("select owner_name,owner_address,create_time from sp_owner_company where owner_id=".$company_code);
- $time=date("Y-m-d");
- $time2=date("Y年m月");
- $time1=date("Y-m-d H:s:i");
- $physical_examination_data=M()->query("select * from sp_physical_examination where company_code='".$company_code."' and time like'%".$time."%'");
- $yc_device1="";
- $sj_device1="";
- $yg_device1="";
- $xfs_device1="";
- $yw_device1="";
- $rtu_device1="";
- $dqhz_device1="";
- $spjc_device1="";
- $dtjc_device1="";
- $jgjc_device1="";
- $dcjc_device1="";
- $mcjs_device1="";
- $krqt_device1="";
- foreach ($res as $val) {
- if ($val['dwtype']==1){
- $yc_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==2){
- $sj_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==3){
- $yg_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==4){
- $xfs_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==5){
- $yw_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==6){
- $rtu_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==7){
- $dqhz_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==16){
- $spjc_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==17){
- $dtjc_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==128){
- $jgjc_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==129){
- $dcjc_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==130){
- $mcjs_device1.="'".$val['owner_code']."',";
- }else if ($val['dwtype']==131){
- $krqt_device1.="'".$val['owner_code']."',";
- }
- }
- if (!empty($yc_device1)){
- $yc_device = substr($yc_device1,0,strlen($yc_device1)-1);
- $yc_data=M()->query("select count(id) as a from sp_hj2017 where device_code in (".$yc_device.")");
- $yc_count=$yc_data[0]['a'];
- $ycl_yc_data=M()->query("select count(id) as a from sp_hj2017 where device_code in (".$yc_device.") and clzt=1");
- $ycl_yc_count=$ycl_yc_data[0]['a'];
- $zb_yc=$ycl_yc_count/$yc_count*100;
- if ($zb_yc>=80){
- $zb_yc1=1;
- }else if ($zb_yc==0){
- $zb_yc1=3;
- }else{
- $zb_yc1=0;
- }
- }else{
- $yc_count=0;
- $zb_yc1=2;
- }
- if (!empty($sj_device1)){
- $sj_device = substr($sj_device1,0,strlen($sj_device1)-1);
- $sj_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$sj_device.")");
- $sj_count=$sj_data[0]['a'];
- $ycl_sj_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$sj_device.") and clzt=1");
- $ycl_sj_count=$ycl_sj_data[0]['a'];
- $zb_sj=$ycl_sj_count/$sj_count*100;
- // print_r($zb_sj);
- if ($zb_sj>=80){
- $zb_sj1=1;
- }else if ($zb_sj==0){
- $zb_sj1=3;
- }else{
- $zb_sj1=0;
- }
- }else{
- $sj_count=0;
- $zb_sj1=2;
- }
- if (!empty($yg_device1)){
- $yg_device = substr($yg_device1,0,strlen($yg_device1)-1);
- $yg_data=M()->query("select count(id) as a from sp_hj2017 where device_code in (".$yg_device.")");
- $yg_count=$yg_data[0]['a'];
- $ycl_yg_data=M()->query("select count(id) as a from sp_hj2017 where device_code in (".$yg_device.") and clzt=1");
- $ycl_yg_count=$ycl_yg_data[0]['a'];
- $zb_yg=$ycl_yg_count/$yg_count*100;
- if ($zb_yg>=80){
- $zb_yg1=1;
- }else if ($zb_yg==0){
- $zb_yg1=3;
- }else{
- $zb_yg1=0;
- }
- }else{
- $yg_count=0;
- $zb_yg1=2;
- }
- if (!empty($xfs_device1)){
- $xfs_device = substr($xfs_device1,0,strlen($xfs_device1)-1);
- $xfs_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$xfs_device.")");
- $xfs_count=$xfs_data[0]['a'];
- $ycl_xfs_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$xfs_device.") and clzt=1");
- $ycl_xfs_count=$ycl_xfs_data[0]['a'];
- $zb_xfs=$ycl_xfs_count/$xfs_count*100;
- if ($zb_xfs>=80){
- $zb_xfs1=1;
- }else if ($zb_xfs==0){
- $zb_xfs1=3;
- }else{
- $zb_xfs1=0;
- }
- }else{
- $xfs_count=0;
- $zb_xfs1=2;
- }
- if (!empty($yw_device1)){
- $yw_device = substr($yw_device1,0,strlen($yw_device1)-1);
- $yw_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$yw_device.")");
- $yw_count=$yw_data[0]['a'];
- $ycl_yw_data=M()->query("select count(id) as a from sp_sj2017 where device_code in (".$yw_device.") and clzt=1");
- $ycl_yw_count=$ycl_yw_data[0]['a'];
- $zb_yw=$ycl_yw_count/$yw_count*100;
- if ($zb_yw>=80){
- $zb_yw1=1;
- }else if ($zb_yw==0){
- $zb_yw1=3;
- }else{
- $zb_yw1=0;
- }
- }else{
- $yw_count=0;
- $zb_yw1=2;
- }
- if (!empty($rtu_device1)){
- $rtu_device = substr($rtu_device1,0,strlen($rtu_device1)-1);
- $rtu_data=M()->query("select count(id) as a from sp_rtu2017 where device_code in (".$rtu_device.")");
- $rtu_count=$rtu_data[0]['a'];
- $ycl_rtu_data=M()->query("select count(id) as a from sp_rtu2017 where device_code in (".$rtu_device.") and clzt=1");
- $ycl_rtu_count=$ycl_rtu_data[0]['a'];
- $zb_rtu=$ycl_rtu_count/$rtu_count*100;
- if ($zb_rtu>=80){
- $zb_rtu1=1;
- }else if ($zb_rtu==0){
- $zb_rtu1=3;
- }else{
- $zb_rtu1=0;
- }
- }else{
- $rtu_count=0;
- $zb_rtu1=2;
- }
- if (!empty($dqhz_device1)){
- $dqhz_device = substr($dqhz_device1,0,strlen($dqhz_device1)-1);
- $dqhz_data=M()->query("select count(id) as a from sp_ef2017 where device_code in (".$dqhz_device.")");
- $dqhz_count=$dqhz_data[0]['a'];
- $ycl_dqhz_data=M()->query("select count(id) as a from sp_ef2017 where device_code in (".$dqhz_device.") and clzt=1");
- $ycl_dqhz_count=$ycl_dqhz_data[0]['a'];
- $zb_dqhz=$ycl_dqhz_count/$dqhz_count*100;
- if ($zb_dqhz>=80){
- $zb_dqhz1=1;
- }else if ($zb_dqhz==0){
- $zb_dqhz1=3;
- }else{
- $zb_dqhz1=0;
- }
- }else{
- $dqhz_count=0;
- $zb_dqhz1=2;
- }
- if (!empty($spjc_device1)){
- $spjc_device = substr($spjc_device1,0,strlen($spjc_device1)-1);
- $spjc_data=M()->query("select count(id) as a from sp_video2017 where device_code in (".$spjc_device.")");
- $spjc_count=$spjc_data[0]['a'];
- $ycl_spjc_data=M()->query("select count(id) as a from sp_video2017 where device_code in (".$spjc_device.") and clzt=1");
- $ycl_spjc_count=$ycl_spjc_data[0]['a'];
- $zb_spjc=$ycl_spjc_count/$spjc_count*100;
- if ($zb_spjc>=80){
- $zb_spjc1=1;
- }else if ($zb_spjc==0){
- $zb_spjc1=3;
- }else{
- $zb_spjc1=0;
- }
- }else{
- $spjc_count=0;
- $zb_spjc1=2;
- }
- if (!empty($dtjc_device1)){
- $dtjc_device = substr($dtjc_device1,0,strlen($dtjc_device1)-1);
- $dtjc_data=M()->query("select count(id) as a from sp_lifter2017 where device_code in (".$dtjc_device.")");
- $dtjc_count=$dtjc_data[0]['a'];
- $ycl_dtjc_data=M()->query("select count(id) as a from sp_lifter2017 where device_code in (".$dtjc_device.") and clzt=1");
- $ycl_dtjc_count=$ycl_dtjc_data[0]['a'];
- $zb_dtjc=$ycl_dtjc_count/$dtjc_count*100;
- if ($zb_dtjc>=80){
- $zb_dtjc1=1;
- }else if ($zb_dtjc==0){
- $zb_dtjc1=3;
- }else{
- $zb_dtjc1=0;
- }
- }else{
- $dtjc_count=0;
- $zb_dtjc1=2;
- }
- if (!empty($jgjc_device1)){
- $jgjc_device = substr($jgjc_device1,0,strlen($jgjc_device1)-1);
- $jgjc_data=M()->query("select count(id) as a from sp_iw2017 where device_code in (".$jgjc_device.")");
- $jgjc_count=$jgjc_data[0]['a'];
- $ycl_jgjc_data=M()->query("select count(id) as a from sp_iw2017 where device_code in (".$jgjc_device.") and clzt=1");
- $ycl_jgjc_count=$ycl_jgjc_data[0]['a'];
- $zb_jgjc=$ycl_jgjc_count/$jgjc_count*100;
- if ($zb_jgjc>=80){
- $zb_jgjc1=1;
- }else if ($zb_jgjc==0){
- $zb_jgjc1=3;
- }else{
- $zb_jgjc1=0;
- }
- }else{
- $jgjc_count=0;
- $zb_jgjc1=2;
- }
- if (!empty($dcjc_device1)){
- $dcjc_device = substr($dcjc_device1,0,strlen($dcjc_device1)-1);
- $dcjc_data=M()->query("select count(id) as a from sp_dc2020 where device_code in (".$dcjc_device.")");
- $dcjc_count=$dcjc_data[0]['a'];
- $ycl_dcjc_data=M()->query("select count(id) as a from sp_dc2020 where device_code in (".$dcjc_device.") and clzt=1");
- $ycl_dcjc_count=$ycl_dcjc_data[0]['a'];
- $zb_dcjc=$ycl_dcjc_count/$dcjc_count*100;
- if ($zb_dcjc>=80){
- $zb_dcjc1=1;
- }else if ($zb_dcjc==0){
- $zb_dcjc1=3;
- }else{
- $zb_dcjc1=0;
- }
- }else{
- $dcjc_count=0;
- $zb_dcjc1=2;
- }
- if (!empty($mcjs_device1)){
- $mcjs_device = substr($mcjs_device1,0,strlen($mcjs_device1)-1);
- $mcjs_data=M()->query("select count(id) as a from sp_door2020 where device_code in (".$mcjs_device.")");
- $mcjs_count=$mcjs_data[0]['a'];
- $ycl_mcjs_data=M()->query("select count(id) as a from sp_door2020 where device_code in (".$mcjs_device.") and clzt=1");
- $ycl_mcjs_count=$ycl_mcjs_data[0]['a'];
- $zb_mcjs=$ycl_mcjs_count/$mcjs_count*100;
- if ($zb_mcjs>=80){
- $zb_mcjs1=1;
- }else if ($zb_mcjs==0){
- $zb_mcjs1=3;
- }else{
- $zb_mcjs1=0;
- }
- }else{
- $mcjs_count=0;
- $zb_mcjs1=2;
- }
- if (!empty($krqt_device1)){
- $krqt_device = substr($krqt_device1,0,strlen($krqt_device1)-1);
- $krqt_data=M()->query("select count(id) as a from sp_gas2020 where device_code in (".$krqt_device.")");
- $krqt_count=$krqt_data[0]['a'];
- $ycl_krqt_data=M()->query("select count(id) as a from sp_gas2020 where device_code in (".$krqt_device.") and clzt=1");
- $ycl_krqt_count=$ycl_krqt_data[0]['a'];
- $zb_krqt=$ycl_krqt_count/$krqt_count*100;
- if ($zb_krqt>=80){
- $zb_krqt1=1;
- }else if ($zb_krqt==0){
- $zb_krqt1=3;
- }else{
- $zb_krqt1=0;
- }
- }else{
- $krqt_count=0;
- $zb_krqt1=2;
- }
- $sy_count=$yc_count+$sj_count+$yg_count+$xfs_count+$yw_count+$rtu_count+$dqhz_count+$spjc_count+$dtjc_count+$jgjc_count+$dcjc_count+$mcjs_count+$krqt_count;
- if ($sy_count<180){
- $score=90;
- }else if ($sy_count>180&&$sy_count<300){
- $score=80;
- }else if ($sy_count>300){
- $score=60;
- }
- if (empty($physical_examination_data)){
- $inset_sql="INSERT INTO sp_physical_examination ( company_name, company_code,yc_count,sj_count,yg_count,xfs_count,yw_count,rtu_count,dqhz_count,spjc_count,dtjc_count,jgjc_count,dcjc_count,mcjs_count,krqt_count,sy_count,score,time) VALUE
- ('".$company_data[0]['owner_name']."', '".$company_code."',".$yc_count.",".$sj_count.",".$yg_count.",".$xfs_count.",".$yw_count.",".$rtu_count.",".$dqhz_count.",".$spjc_count.",".$dtjc_count.",".$jgjc_count.",".$dcjc_count.",".$mcjs_count.",".$krqt_count.",".$sy_count.",".$score.",'".$time1."')";
- addInt($inset_sql);
- }else{
- $update_sql="UPDATE sp_physical_examination set yc_count=".$yc_count.",sj_count=".$sj_count.",yg_count=".$yg_count.",xfs_count=".$xfs_count.",yw_count=".$yw_count.",rtu_count=".$rtu_count.",dqhz_count=".$dqhz_count.",spjc_count=".$spjc_count.",
- dtjc_count=".$dtjc_count.",jgjc_count=".$jgjc_count.",dcjc_count=".$dcjc_count.",mcjs_count=".$mcjs_count.",krqt_count=".$krqt_count.",sy_count=".$sy_count.",score=".$score.",time='".$time1."' where id=".$physical_examination_data[0]['id'];
- addInt($update_sql);
- }
- $physical_examination_data1=M()->query("select * from sp_physical_examination where time like'%".$time."%'");
- $pm=1;
- foreach ($physical_examination_data1 as $key => $value){
- if ($sy_count>$physical_examination_data1[$key]['sy_count']){
- $pm+=1;
- }
- }
- $this->assign('pm',$pm);
- $this->assign('zb_yc1',$zb_yc1);
- $this->assign('zb_sj1',$zb_sj1);
- $this->assign('zb_yg1',$zb_yg1);
- $this->assign('zb_xfs1',$zb_xfs1);
- $this->assign('zb_yw1',$zb_yw1);
- $this->assign('zb_rtu1',$zb_rtu1);
- $this->assign('zb_dqhz1',$zb_dqhz1);
- $this->assign('zb_spjc1',$zb_spjc1);
- $this->assign('zb_dtjc1',$zb_dtjc1);
- $this->assign('zb_jgjc1',$zb_jgjc1);
- $this->assign('zb_dcjc1',$zb_dcjc1);
- $this->assign('zb_mcjs1',$zb_mcjs1);
- $this->assign('zb_krqt1',$zb_krqt1);
- $this->assign('yc_count',$yc_count);
- $this->assign('sj_count',$sj_count);
- $this->assign('yg_count',$yg_count);
- $this->assign('xfs_count',$xfs_count);
- $this->assign('yw_count',$yw_count);
- $this->assign('rtu_count',$rtu_count);
- $this->assign('dqhz_count',$dqhz_count);
- $this->assign('spjc_count',$spjc_count);
- $this->assign('dtjc_count',$dtjc_count);
- $this->assign('jgjc_count',$jgjc_count);
- $this->assign('dcjc_count',$dcjc_count);
- $this->assign('mcjs_count',$mcjs_count);
- $this->assign('krqt_count',$krqt_count);
- $this->assign('ycl_yc_count',$ycl_yc_count);
- $this->assign('ycl_sj_count',$ycl_sj_count);
- $this->assign('ycl_yg_count',$ycl_yg_count);
- $this->assign('ycl_xfs_count',$ycl_xfs_count);
- $this->assign('ycl_yw_count',$ycl_yw_count);
- $this->assign('ycl_rtu_count',$ycl_rtu_count);
- $this->assign('ycl_dqhz_count',$ycl_dqhz_count);
- $this->assign('ycl_spjc_count',$ycl_spjc_count);
- $this->assign('ycl_dtjc_count',$ycl_dtjc_count);
- $this->assign('ycl_jgjc_count',$ycl_jgjc_count);
- $this->assign('ycl_dcjc_count',$ycl_dcjc_count);
- $this->assign('ycl_mcjs_count',$ycl_mcjs_count);
- $this->assign('ycl_krqt_count',$ycl_krqt_count);
- $this->assign('sy_count',$sy_count);
- $this->assign('score',$score);
- $this->assign('time',$time2);
- $this->assign('company_code',$company_code);
- $this->assign('company_data',$company_data[0]);
- $this->display('Index/physical_examination');
- }
- }
|