瀏覽代碼

统计新需求接口开发

zhaops 5 年之前
父節點
當前提交
076e456c26

+ 3 - 0
zzcx-service/src/main/java/com/diagbot/vo/OptHospPageVO.java

@@ -29,4 +29,7 @@ public class OptHospPageVO extends Page {
 
     //医院名称列表
     private List<String> hospitalCodeList;
+
+    // 类型数组,默认都会返回访问量,有uvSum:再返回用户量,有zzSum:再返回提交量
+    private List<String> typeList;
 }

+ 2 - 1
zzcx-service/src/main/java/com/diagbot/web/OptInfoController.java

@@ -116,7 +116,8 @@ public class OptInfoController {
                     "endDate: 结束时间,Date<br>" +
                     "desc:排序指标,[pvSum|uvSum|zzSum]<br>" +
                     "page;第几页<br>" +
-                    "size:条数<br>")
+                    "size:条数<br>" +
+                    "typeList:类型数组,默认都会返回访问量,有uvSum:再返回用户量,有zzSum:再返回提交量")
     @PostMapping("/getOptSumHospNoDaysPage")
     @SysLogger("getOptSumHospNoDaysPage")
     public RespDTO<IPage<HospItemDTO>> getOptSumHospNoDaysPage(@RequestBody OptHospPageVO optHospPageVO) {

+ 61 - 47
zzcx-service/src/main/resources/mapper/OptInfoMapper.xml

@@ -435,55 +435,69 @@
     <select id="getPageHospitalPUZ" resultType="com.diagbot.dto.HospItemDTO">
         select tt.hospitalCode, IFNULL(tt.pvSum, 0) pvSum , iFNULL(tt.uvSum, 0) uvSum,  iFNULL(tt.zzSum, 0) zzSum from (
         select a.*,
-            (SELECT
-            count(ip)
-            FROM
-            (
-            SELECT DISTINCT
-            hospital_code AS hospitalCode,
-            DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
-            ip
-            FROM
-            zzcx_opt_info
-            WHERE
-            opt_type = 1
-            <if test="startDate!=null">
-                AND gmt_create &gt;= #{startDate}
-            </if>
-            <if test="endDate!=null">
-                AND gmt_create &lt;= #{endDate}
-            </if>
-            --         AND hospital_code !='朗通通用'
-            ) t1 where t1.hospitalCode = a.hospitalCode
-
-            GROUP BY
-            hospitalCode
-            )  AS uvSum,
+            <choose>
+                <when test='typeList != null and typeList.contains("uvSum")'>
+                    (SELECT
+                    count(ip)
+                    FROM
+                    (
+                    SELECT DISTINCT
+                    hospital_code AS hospitalCode,
+                    DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
+                    ip
+                    FROM
+                    zzcx_opt_info
+                    WHERE
+                    opt_type = 1
+                    <if test="startDate!=null">
+                        AND gmt_create &gt;= #{startDate}
+                    </if>
+                    <if test="endDate!=null">
+                        AND gmt_create &lt;= #{endDate}
+                    </if>
+                    --         AND hospital_code !='朗通通用'
+                    ) t1 where t1.hospitalCode = a.hospitalCode
 
-            (
-            SELECT
-            count(ip)
-            FROM
-            (
-            SELECT DISTINCT
-            hospital_code AS hospitalCode,
-            DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
-            ip
-            FROM
-            zzcx_opt_info
-            WHERE
-            opt_type = 2
-            <if test="startDate!=null">
-                AND gmt_create &gt;= #{startDate}
-            </if>
-            <if test="endDate!=null">
-                AND gmt_create &lt;= #{endDate}
-            </if>
-            ) t2 where t2.hospitalCode = a.hospitalCode
-            GROUP BY
-            hospitalCode
-            )  AS zzSum
+                    GROUP BY
+                    hospitalCode
+                    )  AS uvSum
+                </when>
+                <otherwise>
+                    0 AS uvSum
+                </otherwise>
+            </choose>
+            ,
 
+            <choose>
+              <when test='typeList != null and typeList.contains("zzSum")'>
+                (
+                SELECT
+                count(ip)
+                FROM
+                (
+                SELECT DISTINCT
+                hospital_code AS hospitalCode,
+                DATE_FORMAT(gmt_create, '%Y-%m-%d') AS days,
+                ip
+                FROM
+                zzcx_opt_info
+                WHERE
+                opt_type = 2
+                <if test="startDate!=null">
+                    AND gmt_create &gt;= #{startDate}
+                </if>
+                <if test="endDate!=null">
+                    AND gmt_create &lt;= #{endDate}
+                </if>
+                ) t2 where t2.hospitalCode = a.hospitalCode
+                GROUP BY
+                hospitalCode
+                )  AS zzSum
+            </when>
+                <otherwise>
+                    0 AS zzSum
+                </otherwise>
+            </choose>
         from
         (
         SELECT