【调度系统】广东民航医疗快线调度系统源代码
wanglizhong
2025-06-16 ae5b0a8c63979351028215b8fe8cdf4b0766c272
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
<?php
//分页信息
$page=empty($_REQUEST['page'])!=false ? 1 : $_REQUEST['page'];
$QuantityInt = 20;    //每页显示数量
$acc1=$page;        //当前页数
$acc2=0;            //总页数
$acc3=0;            //总记录数
 
//查询条件
$searchSql="";
/*
$searchTXT=empty($searchTXT)!=false ? "" : $searchTXT;
if ($searchTXT!=""){
    $searchSql=" and (OA_Name like '%$searchTXT%') ";
}else{
    $searchSql="";
}
*/
if (!empty($OrdAreaTypeID)) {
    $searchSql=$searchSql." and ServiceOrdAreaType=".$OrdAreaTypeID;
}
if (!empty($OrdTypeID)) {
     $searchSql=$searchSql." and ServiceOrdType=".$OrdTypeID;
}
 
 
//$OrdClassListSql="";
//查看各分公司报表权限
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);
    }
}
 
$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="↓";
}
 
//查询开始
$SqlOrdDateType=empty($SqlOrdDateType)!=false ? "" : $SqlOrdDateType;
$OrdClassType=empty($OrdClassType)!=false ? "1" : $OrdClassType;
 
$sql="select * from (
        select UnitID,UnitName,(case UnitShort when '微信小程序' then '广州' else UnitShort end) UnitShort,ServiceBranch,
        PointsCost=(
            select isnull(sum(Points_Score),0) from UserPoints,ServiceOrder
            where Points_State=1 and ServiceOrdID=ServiceOrdIDDt and Points_Type in (1) and ServiceOrdClass=ServiceBranch
            and Points_Time ".$SqlOrdDateType."
        ),
        PointsIncome=(
            select isnull(sum(Points_Score),0) from UserPoints,ServiceOrder
            where Points_State=1 and ServiceOrdID=ServiceOrdIDDt and Points_Type in (6) and ServiceOrdClass=ServiceBranch
            and Points_Time ".$SqlOrdDateType."
        )
        from IntroducerUnitData where ServiceBranch<>'' and UnitState>=1 and ServiceBranch in ('".$OrdClassListSql."')
    ) as a1
    where PointsCost+PointsIncome>0";
//echo $sql;exit;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $FormArray=array();
    //表头
    $FormArray[0]=array("分支机构名称","积分支出","积分收入","积分累计");
    $FormArrayX=count($FormArray[0]);
    if (sqlsrv_rows_affected($data)==0) {
        $SystemMessageType=2;
        $SystemMessageTXT="数据库中相关无数据!";
        $y=0;
    } else {
        $y=0;
        $i=0;
        while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
            //读取数据
            $UnitID            = $rs['UnitID'];
            $UnitShort        = $rs['UnitShort'];
            $ServiceBranch    = $rs['ServiceBranch'];
            $PointsCost        = intval($rs['PointsCost']);
            $PointsIncome    = intval($rs['PointsIncome']);
            if ($PointsCost>0) {$PointsCost=-$PointsCost;}
            //读取数据--End
            
            //写入数组
            $i++;
            $FormArray[$i][0]="<a href='/Report_PointsInstitution.php?OrdDateType=$OrdDateType&OrdDateStart=&OrdDateEnd=&searchTXT=&orderby=&ServiceBranch=$ServiceBranch'>$UnitShort</a>";
            $FormArray[$i][1]="<a href='/Report_PointsInstitution.php?OrdDateType=$OrdDateType&OrdDateStart=&OrdDateEnd=&searchTXT=&orderby=&ServiceBranch=$ServiceBranch'>$PointsCost</a>";
            $FormArray[$i][2]="<a href='/Report_PointsInstitution.php?OrdDateType=$OrdDateType&OrdDateStart=&OrdDateEnd=&searchTXT=&orderby=&ServiceBranch=$ServiceBranch'>$PointsIncome</a>";
            $FormArray[$i][3]="<a href='/Report_PointsInstitution.php?OrdDateType=$OrdDateType&OrdDateStart=&OrdDateEnd=&searchTXT=&orderby=&ServiceBranch=$ServiceBranch'>".($PointsIncome+$PointsCost)."</a>";
            
            
            //写入数组--End
        }
 
    }
}
 
//echo print_r($FormArray);
//exit;
?>