From 9a58acebc825f20deee5ee38e58d917c7d628ff7 Mon Sep 17 00:00:00 2001 From: ling li <709673163@qq.com> Date: Thu, 29 Jun 2023 16:30:17 +0800 Subject: [PATCH] =?UTF-8?q?rf=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-admin/pom.xml | 6 +++ .../controller/VnaRawDataController.java | 41 +++++++++++++++-- .../rfMsg/vnaRawData/vnaRawData.html | 46 ++++++++++++------- 3 files changed, 74 insertions(+), 19 deletions(-) diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml index 04cd79d3..441beb7f 100644 --- a/ruoyi-admin/pom.xml +++ b/ruoyi-admin/pom.xml @@ -45,6 +45,12 @@ 1.5.21 + + cn.hutool + hutool-all + 5.7.16 + + io.swagger swagger-models diff --git a/ruoyi-admin/src/main/java/com/ruoyi/rfMsg/controller/VnaRawDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/rfMsg/controller/VnaRawDataController.java index 872a5ed7..955c782e 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/rfMsg/controller/VnaRawDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/rfMsg/controller/VnaRawDataController.java @@ -1,5 +1,7 @@ package com.ruoyi.rfMsg.controller; +import com.alibaba.fastjson.JSONObject; +import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; @@ -14,7 +16,10 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * rf测试历史结果Controller @@ -53,14 +58,44 @@ public class VnaRawDataController extends BaseController @PostMapping("/getDataById/{id}") @ResponseBody - public String getDataById(@PathVariable("id") Long id) + public List getDataById(@PathVariable("id") Long id) { startPage(); VnaRawData vnaRawData = vnaRawDataService.selectVnaRawDataById(id); String frequency = vnaRawData.getFrequency(); -// JSONObject jsonObject = (JSONObject) JSONValue.parse(frequency.toJs()); System.out.println(frequency); - return frequency; + Map mapObj = JSONObject.parseObject(frequency,Map.class); + List listKey = new ArrayList(); + List listValue = new ArrayList(); + List listValueList = new ArrayList(); +// System.out.println("这个是用JSONObject的parseObject方法并执行返回类型来解析JSON字符串!!!"); +// for (Object map: mapObj.entrySet()){ +// System.out.println(((Map.Entry)map).getKey()+":"+((Map.Entry)map).getValue()); +// listKey.add(((Map.Entry)map).getKey()); +// listValue.add(((Map.Entry)map).getValue()); +// } +// LinkedHashMap map = JSONUtil.toBean(frequency, new TypeReference>() {}, true); +// for (Map.Entry entry : map.entrySet()) { +// System.out.println(entry.getKey() + ": " + entry.getValue()); +// listKey.add((entry.getKey())); +// listValue.add((entry.getValue())); +// } + try { + ObjectMapper objectMapper = new ObjectMapper(); + com.fasterxml.jackson.core.type.TypeReference> typeRef = new com.fasterxml.jackson.core.type.TypeReference>() {}; + LinkedHashMap map = objectMapper.readValue(frequency, typeRef); + for (Map.Entry entry : map.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + listKey.add((entry.getKey())); + listValue.add((entry.getValue())); + } + } catch (Exception e) { + System.out.println("序列化出错"); + } + listValueList.add(listKey); + listValueList.add(listValue); + System.out.println(listValueList); + return listValueList; } /** diff --git a/ruoyi-admin/src/main/resources/templates/rfMsg/vnaRawData/vnaRawData.html b/ruoyi-admin/src/main/resources/templates/rfMsg/vnaRawData/vnaRawData.html index 986dbe57..ffa60496 100644 --- a/ruoyi-admin/src/main/resources/templates/rfMsg/vnaRawData/vnaRawData.html +++ b/ruoyi-admin/src/main/resources/templates/rfMsg/vnaRawData/vnaRawData.html @@ -131,28 +131,16 @@ function initSubTable(index, row, $detail) { var parentid = row.id; - var cur_table = $detail.html('
').find('table'); + var cur_table = $detail.html('' + + '' + + '
').find('table'); getData(parentid) - // confirm_income_list_sun: 子表的数据 - var timu = 'nihao' - var timu2 = 'zg' $(cur_table).bootstrapTable({ // data: confirm_income_list_sun, pageSize: 10, detailView: false, //是否显示父子表 singleSelect: true, - contentType: "application/x-www-form-urlencoded", - columns: [ - { - title: timu, - field: "detailData", - formatter: function (value, row, index) { - console.log(row.detailData) - row.detailData = timu2 - return timu2 - } - } - ] + contentType: "application/x-www-form-urlencoded" }); } @@ -163,6 +151,32 @@ success: function (res) { console.log(id) console.log(res) + console.log(res[0]) + console.log(res[1]) + var listKey = res[0] + var listValue = res[1] + var tableThead = ""; + // for (var i = 0; i < listKey.length; i++) { + // tableThead = tableThead + "" + listKey[i] + // + ""; + // } + //将动态生成的table添加的事先隐藏的div中. + // $("#thead_"+id).html(tableThead); + var tableTbody = ""; + for (var i = 0; i < listKey.length; i++) { + tableTbody += "" + listKey[i] + ""; + } + tableTbody += ""; + for (var i = 0; i < listValue.length; i++) { + tableTbody += "" + listValue[i] + ""; + } + tableTbody += ""; + // for (var j = 0; j < listValue.length; j++) { + // tableTbody = tableTbody + "" + listValue[j] + // + ""; + // } + //将动态生成的table添加的事先隐藏的div中. + $("#tbody_"+id).html(tableTbody); } }) }