{ "properties" : { }, "id" : "45e7dbe75ad44dd48cab6f9042a46c99", "script" : null, "groupId" : "05b429d9d76e469eb86e3e7ab55eb0fd", "name" : "警情上报", "createTime" : null, "updateTime" : 1698027409127, "lock" : null, "createBy" : null, "updateBy" : null, "path" : "/policeReport", "method" : "GET", "parameters" : [ { "name" : "isFirst", "value" : "0", "description" : null, "required" : false, "dataType" : "String", "type" : null, "defaultValue" : null, "validateType" : null, "error" : null, "expression" : null, "children" : null }, { "name" : "region", "value" : "娄底市公安局", "description" : null, "required" : false, "dataType" : "String", "type" : null, "defaultValue" : null, "validateType" : null, "error" : null, "expression" : null, "children" : null } ], "options" : [ ], "requestBody" : "", "headers" : [ ], "paths" : [ ], "responseBody" : "{\n \"code\": 1,\n \"message\": \"success\",\n \"data\": [\n {\n \"类型\": \"一般\",\n \"已处理\": 0,\n \"未处理\": 0\n },\n {\n \"类型\": \"较大\",\n \"已处理\": 0,\n \"未处理\": 0\n },\n {\n \"类型\": \"重大\",\n \"已处理\": 0,\n \"未处理\": 0\n },\n {\n \"类型\": \"特别重大\",\n \"已处理\": 0,\n \"未处理\": 0\n }\n ],\n \"timestamp\": 1698024533195,\n \"executeTime\": 2076\n}", "description" : null, "requestBodyDefinition" : null, "responseBodyDefinition" : null } ================================ var sql = """ SELECT "一般" as 类型, IFNULL(sum(case police_status when 2 then 1 else 0 end),0) AS 已处理, IFNULL(sum(case police_status when 2 then 0 else 1 end),0) AS 未处理 FROM dispatch.police_incidents where police_level=0 ?{isFirst!=null&&isFirst!='1', and supervise_depart_name like CONCAT('%',#{region},'%') } union SELECT "较大" as 类型, IFNULL(sum(case police_status when 2 then 1 else 0 end),0) AS 已处理, IFNULL(sum(case police_status when 2 then 0 else 1 end),0) AS 未处理 FROM dispatch.police_incidents where police_level=1 ?{isFirst!=null&&isFirst!='1', and supervise_depart_name like CONCAT('%',#{region},'%') } union SELECT "重大" as 类型, IFNULL(sum(case police_status when 2 then 1 else 0 end),0) AS 已处理, IFNULL(sum(case police_status when 2 then 0 else 1 end),0) AS 未处理 FROM dispatch.police_incidents where police_level=2 ?{isFirst!=null&&isFirst!='1', and supervise_depart_name like CONCAT('%',#{region},'%') } union SELECT "特别重大" as 类型, IFNULL(sum(case police_status when 2 then 1 else 0 end),0) AS 已处理, IFNULL(sum(case police_status when 2 then 0 else 1 end),0) AS 未处理 FROM dispatch.police_incidents where police_level=3 ?{isFirst!=null&&isFirst!='1', and supervise_depart_name like CONCAT('%',#{region},'%') } """ return db.cache('one-countDispatch-' + region, 1000 * 60 * 1).select(sql)