正在显示
3 个修改的文件
包含
37 行增加
和
12 行删除
| @@ -111,4 +111,21 @@ public class FeishuUtil { | @@ -111,4 +111,21 @@ public class FeishuUtil { | ||
| 111 | } | 111 | } |
| 112 | return null; | 112 | return null; |
| 113 | } | 113 | } |
| 114 | + | ||
| 115 | + public static String getFeishuExcelSheet(String tenant_access_token,String spreadsheetToken,String ranges,String valueRenderOption,String dateTimeRenderOption,String user_id_type) | ||
| 116 | + { | ||
| 117 | + String url = "https://open.feishu.cn/open-apis/sheets/v2/spreadsheets/"+spreadsheetToken+"/values_batch_get?ranges="+ranges+"&valueRenderOption="+valueRenderOption+"&dateTimeRenderOption="+dateTimeRenderOption+"&user_id_type="+user_id_type; | ||
| 118 | + try { | ||
| 119 | + | ||
| 120 | + String str = HttpUtils.get(url, builder -> { | ||
| 121 | + builder.addHeader("Content-Type", "application/json"); | ||
| 122 | + builder.addHeader("Authorization", "Bearer " + tenant_access_token); | ||
| 123 | + }); | ||
| 124 | + return str; | ||
| 125 | + } catch (IOException e) { | ||
| 126 | + logger.error("查询飞书表数据异常",e); | ||
| 127 | + } | ||
| 128 | + return null; | ||
| 129 | + } | ||
| 130 | + | ||
| 114 | } | 131 | } |
| 1 | package com.zhonglai.luhui.device.analysis.comm.db.mode; | 1 | package com.zhonglai.luhui.device.analysis.comm.db.mode; |
| 2 | 2 | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 3 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 4 | import com.zhonglai.luhui.device.domain.IotThingsModel; | 5 | import com.zhonglai.luhui.device.domain.IotThingsModel; |
| 5 | import com.zhonglai.luhui.redis.service.RedisService; | 6 | import com.zhonglai.luhui.redis.service.RedisService; |
| @@ -80,11 +81,15 @@ public class TerminalDataThingsModeService { | @@ -80,11 +81,15 @@ public class TerminalDataThingsModeService { | ||
| 80 | */ | 81 | */ |
| 81 | public IotThingsModel getIotThingsModel(String mqtt_username,String identifier) | 82 | public IotThingsModel getIotThingsModel(String mqtt_username,String identifier) |
| 82 | { | 83 | { |
| 83 | - if(redisService.hHashKey(deviceTypeKeyPath+mqtt_username,identifier)) | ||
| 84 | - { | ||
| 85 | - return JSONObject.parseObject(JSONObject.toJSONString(redisService.hget(deviceTypeKeyPath+mqtt_username,identifier)),IotThingsModel.class); | 84 | + Object raw = redisService.hget(deviceTypeKeyPath+mqtt_username,identifier); |
| 85 | + if (raw == null) return null; | ||
| 86 | + String json; | ||
| 87 | + if (raw instanceof String) { | ||
| 88 | + json = (String) raw; | ||
| 89 | + } else { | ||
| 90 | + json = JSON.toJSONString(raw); | ||
| 86 | } | 91 | } |
| 87 | - return null; | 92 | + return JSON.parseObject(json, IotThingsModel.class); |
| 88 | } | 93 | } |
| 89 | 94 | ||
| 90 | /** | 95 | /** |
| @@ -100,6 +100,15 @@ public class TestController { | @@ -100,6 +100,15 @@ public class TestController { | ||
| 100 | "}"; | 100 | "}"; |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | + @ApiOperation("获取飞书excel表格数据") | ||
| 104 | + @RequestMapping(value = "getFeishuExcelSheet") | ||
| 105 | + public String getFeishuExcelSheet(String spreadsheetToken,String ranges,String valueRenderOption,String dateTimeRenderOption,String user_id_type) throws IOException { | ||
| 106 | + String str = FeishuUtil.getFeishuExcelSheet(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"), | ||
| 107 | + spreadsheetToken,ranges,valueRenderOption,dateTimeRenderOption,user_id_type); | ||
| 108 | + System.out.println(str); | ||
| 109 | + return str; | ||
| 110 | + } | ||
| 111 | + | ||
| 103 | @ApiOperation("重写Highcharts导出") | 112 | @ApiOperation("重写Highcharts导出") |
| 104 | @RequestMapping(value = "getFeishuTable") | 113 | @RequestMapping(value = "getFeishuTable") |
| 105 | public void getFeishuTable(HttpServletRequest request, HttpServletResponse response) throws IOException { | 114 | public void getFeishuTable(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| @@ -160,14 +169,8 @@ public class TestController { | @@ -160,14 +169,8 @@ public class TestController { | ||
| 160 | } | 169 | } |
| 161 | 170 | ||
| 162 | public static void main(String[] args) { | 171 | public static void main(String[] args) { |
| 163 | - JSONArray sort = new JSONArray(); | ||
| 164 | - JSONObject field_name = new JSONObject(); | ||
| 165 | - field_name.put("field_name","记录时间"); | ||
| 166 | - sort.add(field_name); | ||
| 167 | - | ||
| 168 | - Map<String,Object> body = new HashMap<>(); | ||
| 169 | - body.put("sort",sort); | ||
| 170 | - String str = FeishuUtil.getFeishuTable(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"),"OcUYbxkuCakxYlsbrEUcXyqKnbf","tblo4dUsFjWXAt8U",body); | 172 | + String str = FeishuUtil.getFeishuExcelSheet(FeishuUtil.gettenant_access_token("cli_a88a14d3b279d01c","Z3hpYKHeR1yR2aiv6Rp0mcnwKvehkzmT"), |
| 173 | + "C0JFs1rTchILbEt7Pg3cCnt6ngc","0hZoRZ","ToString","FormattedString","open_id"); | ||
| 171 | System.out.println(str); | 174 | System.out.println(str); |
| 172 | } | 175 | } |
| 173 | 176 |
-
请 注册 或 登录 后发表评论