【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-05-05 2a11acffdd3df927be6abace9e8155e370b49681
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
$UnitNameID=empty($_REQUEST['UnitNameID'])!=false ? "" : addslashes($_REQUEST['UnitNameID']);
 
//分页信息
$page=empty($_REQUEST['page'])!=false ? 1 : $_REQUEST['page'];
$QuantityInt = 20;    //每页显示数量
$acc1=$page;        //当前页数
$acc2=0;            //总页数
$acc3=0;            //总记录数
 
//类型列表
$ArrayOrdType=array();
$sql = "select vID,vtext from dictionary where vtitle='ServiceOrderType' order by vOrder" ;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $i=0;
    while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
        $ArrayOrdType[$rs['vID']]=$rs['vtext'];
        $i++;
    }
}
 
//查看各分公司报表权限
if (isDepartment("070109")==1) {
  $OrdClassListSql="";
  //$UnitNameID="1";
  If ($UnitNameID!="" and $UnitNameID!="0") {
      $sql="select vOrder2 from dictionary where vtitle='UnitName' and vID=".$UnitNameID;
        $data = sqlsrv_query($conn,$sql);
        if($data == true){
            if (sqlsrv_rows_affected($data)!=0) {
                while($rs = sqlsrv_fetch_array($data) ) {
                    $UnitTypeID        = $rs[0];
                    $sql="select vID,vtext,vOrder2 from dictionary where vID in (".$UnitTypeID.") and vtitle='OrderClass' order by vOrder";
                    $data1 = sqlsrv_query($conn,$sql);
                    if($data1 == true){
                        while($rs1 = sqlsrv_fetch_array($data1) ) {
                            $OrderClassID        = $rs1['vOrder2'];
                            $OrdClassListSql    .= ",".$OrderClassID;
                        }
                    }
                    $OrdClassListSql=substr($OrdClassListSql,1);
                    $OrdClassListSql=str_replace(",","','",$OrdClassListSql);
                }
            }
        }
    }else{
        $sql="select vID,vtext,vOrder2 from dictionary where vType in (1,2) and vtitle='OrderClass' order by vOrder";
        $data1 = sqlsrv_query($conn,$sql);
        if($data1 == true){
            while($rs1 = sqlsrv_fetch_array($data1) ) {
                $OrderClassID        = $rs1['vOrder2'];
                $OrdClassListSql    .= ",".$OrderClassID;
            }
        }
        $OrdClassListSql=substr($OrdClassListSql,1);
        $OrdClassListSql=str_replace(",","','",$OrdClassListSql);
    }
}
 
//查询条件
$searchSql="";
$searchTXT=empty($searchTXT)!=false ? "" : $searchTXT;
if ($searchTXT!=""){
    $searchSql=" and (OA_Name like '%$searchTXT%') ";
}else{
    $searchSql="";
}
if ($StaffScoreID=="1") {
    $searchSql=$searchSql." and (Guest_PointE like '%9%' or Guest_PointE like '%8%' or RV_PointE like '%9%' or RV_PointE like '%8%') ";
}elseif ($StaffScoreID=="2") {
    $searchSql=$searchSql." and (Guest_PointE like '%1%' or Guest_PointE like '%2%' or RV_PointE like '%1%' or RV_PointE like '%2%') ";
}elseif ($StaffScoreID=="3") {
    $searchSql=$searchSql." and (Guest_PointE='0' and RV_PointE='0' and ServiceOrdVisit<>'') ";
}
 
$orderby=empty($orderby)!=false ? "" : $orderby;
If (strrpos($orderby," desc")>1){
    $orderbydesc="";
    $descTXT="↓";
}else{
    $orderbydesc=" desc";
    $descTXT="↑";
}
 
If ($orderby=="") {
  $orderby="OA_DepartmentID,OA_User_ID";
  $descTXT="↓";
}
 
if ($OrdDateType=="0" and $OrdDateStart=="" and $OrdDateEnd=="") {$OrdDateType=4;}
 
 
$SqlOrdDateType=empty($SqlOrdDateType)!=false ? "" : $SqlOrdDateType;
$OAOccupationSQL=empty($OAOccupation)!=false ? "" : " and EntourageID in (".$OAOccupation.") ";
$StaffScoreSum=0;
$StaffScoreSum_Bad=0;
$StaffScoreSum_Other=0;
//条件查询
$ListSql="";
$OtherFormArray=array();
$OtherArray=array();
$sql="select vId,vtext from dictionary where vType=1 and vtitle='VisitDict' order by vOrder";
//echo $sql;exit;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
        $vId    = $rs['vId'];
        $vtext    = $rs['vtext'];
        array_push($OtherFormArray,"other".$vId);
        array_push($OtherArray,$vtext);
        $ListSql=$ListSql.",(select COUNT(ServiceOrdID) from ServiceOrder as b where b.ServiceOrdVisit_Dict= '".$vtext."' and a.ServiceOrdVisit_ID=b.ServiceOrdVisit_ID and b.ServiceOrdVisit_time ".$SqlOrdDateType.") other".$vId;
    }
}
 
//查询开始
$sql="select OA_Name,ServiceOrdVisit_ID,COUNT(ServiceOrdID) VisitSum,
( select COUNT(*) from (select b.ServiceOrdID VisitSum from ServiceOrder b,DispatchOrd_Entourage,DispatchOrd where a.ServiceOrdVisit_ID=b.ServiceOrdVisit_ID and EntourageState<>4 and DispatchOrdIDDt=DispatchOrdID and b.ServiceOrdID=ServiceOrdIDDt and DispatchOrdState not in (10,9) and (RV_PointE like '%1%' or RV_PointE like '%2%') and b.ServiceOrdVisit_time  ".$SqlOrdDateType." GROUP BY b.ServiceOrdID) as bb) dissatisfied".$ListSql."
 from ServiceOrder as a left join OA_User on ServiceOrdVisit_ID=OA_User_ID 
 where ServiceOrdVisit<>'' and ServiceOrdVisit_time  ".$SqlOrdDateType."
 GROUP BY OA_Name,ServiceOrdVisit_ID  order by COUNT(ServiceOrdID) desc";
//echo $sql;exit;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $FormArray=array();
    //表头
    $FormArray[0]=array("回访客服","总回访数量","满意任务数量","不满意任务数量");
    $FormArray[0]=array_merge($FormArray[0],$OtherArray);
 
    $FormArrayX=count($FormArray[0]);
    if (sqlsrv_rows_affected($data)==0) {
        $SystemMessageType=2;
        $SystemMessageTXT="数据库中相关无数据!";
        $y=0;
    } else {
        $i=1;
        while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
            //读取数据
            $OA_Name        = $rs['OA_Name'];
            $ServiceOrdVisit_ID    = $rs['ServiceOrdVisit_ID'];
            $VisitSum    = $rs['VisitSum'];
            $dissatisfied    = $rs['dissatisfied'];
            
            //读取数据--End
            
            //写入数组
            $FormArray[$i][0]=$OA_Name;
            $FormArray[$i][1]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore2|总量|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$VisitSum."</a>";
            $FormArray[$i][2]=$VisitSum-$dissatisfied;
            $FormArray[$i][3]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore3|".$FormArray[0][3]."|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$dissatisfied."</a>";
            $OtherInt=0;
            foreach($OtherFormArray as $value){
                $OtherInt++;
                $FormArray[$i][3+$OtherInt]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore1|".$FormArray[0][3+$OtherInt]."|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$rs[$value]."</a>";
                $FormArray[$i][2]=$FormArray[$i][2]-$rs[$value];
            }
            $FormArray[$i][2]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore0|满意|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$FormArray[$i][2]."</a>";
            $i++;
            
        }
            
 
    }
}
 
if ($is_CSV==2) {
    echo json_encode($FormArray);
}
//echo print_r($FormArray);
//exit;
?>