From 54c480e3632fbc6fc821786e2b473bceb2f0ae4e Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期六, 22 三月 2025 15:35:29 +0800 Subject: [PATCH] 天线的电路总报告保留两位小数 --- inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java | 78 ++++++++++++++++++++++++++------------- 1 files changed, 52 insertions(+), 26 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java b/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java index 1825187..e9a6973 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/utils/WordUtils.java @@ -3585,8 +3585,9 @@ if (i % 2 == 0) { //鏈�宸�� String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); + String text = value.split(",")[(j - 5) + (i - 1) / 2 * (Math.min(ports, 8))]; try { - textRenderData.setText(value.split(",")[(j - 5) + (i - 1) / 2 * (Math.min(ports, 8))]); + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -3674,7 +3675,8 @@ } else if (j % 2 == 0) { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 6) / 2 + (i - cc - 1) * 4] + "鈭�5" + i + (j - 6)); + String text = value.split(",")[(j - 6) / 2 + (i - cc - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } @@ -3686,7 +3688,8 @@ } else { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 5) / 2 + (i - cc - 1) * 4] + "鈭�5" + i + (j - 5)); + String text = value.split(",")[(j - 5) / 2 + (i - cc - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -3766,7 +3769,8 @@ } else if (j % 2 == 0) { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 6) / 2 + (i - (dd == 0 ? cc : dd) - 1) * 4] + "鈭�5" + i + (j - 6)); + String text = value.split(",")[(j - 6) / 2 + (i - (dd == 0 ? cc : dd) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } @@ -3778,7 +3782,8 @@ } else { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 5) / 2 + (i - (dd == 0 ? cc : dd) - 1) * 4] + "鈭�5" + i + (j - 5)); + String text = value.split(",")[(j - 5) / 2 + (i - (dd == 0 ? cc : dd) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -3858,7 +3863,8 @@ } else if (j % 2 == 0) { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 6) / 2 + (i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) - 1) * 4] + "鈭�5" + i + (j - 6)); + String text = value.split(",")[(j - 6) / 2 + (i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } @@ -3870,7 +3876,8 @@ } else { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 5) / 2 + (i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) - 1) * 4] + "鈭�5" + i + (j - 5)); + String text = value.split(",")[(j - 5) / 2 + (i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -3950,7 +3957,8 @@ } else if (j % 2 == 0) { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 6) / 2 + (i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) - 1) * 4] + "鈭�5" + i + (j - 6)); + String text = value.split(",")[(j - 6) / 2 + (i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } @@ -3962,7 +3970,8 @@ } else { String value = result2s.get(0).getValue().replaceAll("[\\[\\]\"]", ""); try { - textRenderData.setText(value.split(",")[(j - 5) / 2 + (i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) - 1) * 4] + "鈭�5" + i + (j - 5)); + String text = value.split(",")[(j - 5) / 2 + (i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) - 1) * 4]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -4053,7 +4062,8 @@ String[] value = result2s.get((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) / portRow / (angles + 2)).getValue().split("\\],\\["); String[] split = value[(i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) - 2) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[((j - 5) + ((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) - 1) / (angles + 1) % portRow) * (Math.min(ports, 8)))]); + String text = split[((j - 5) + ((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) - 1) / (angles + 1) % portRow) * (Math.min(ports, 8)))]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -4157,7 +4167,8 @@ String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[(j - 5) + ((i + (angles - 1)) / (angles + 1) - 1) * (Math.min(ports, 8))]); + String text = split[(j - 5) + ((i + (angles - 1)) / (angles + 1) - 1) * (Math.min(ports, 8))]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -4272,13 +4283,15 @@ String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); if (j % 2 == 0) { try { - textRenderData.setText(split[(j - 6) / 2 + ((i - cc) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 6)); + String text = split[(j - 6) / 2 + ((i - cc) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } } else { try { - textRenderData.setText(split[(j - 5) / 2 + ((i - cc) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 5)); + String text = split[(j - 5) / 2 + ((i - cc) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -4395,13 +4408,15 @@ String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); if (j % 2 == 0) { try { - textRenderData.setText(split[(j - 6) / 2 + ((i - (dd == 0 ? cc : dd)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 6)); + String text = split[(j - 6) / 2 + ((i - (dd == 0 ? cc : dd)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } } else { try { - textRenderData.setText(split[(j - 5) / 2 + ((i - (dd == 0 ? cc : dd)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 5)); + String text = split[(j - 5) / 2 + ((i - (dd == 0 ? cc : dd)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -4518,13 +4533,15 @@ String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); if (j % 2 == 0) { try { - textRenderData.setText(split[(j - 6) / 2 + ((i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 6)); + String text = split[(j - 6) / 2 + ((i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } } else { try { - textRenderData.setText(split[(j - 5) / 2 + ((i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 5)); + String text = split[(j - 5) / 2 + ((i - (ee == 0 ? ((dd == 0 ? cc : dd)) : ee)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -4640,13 +4657,15 @@ String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); if (j % 2 == 0) { try { - textRenderData.setText(split[(j - 6) / 2 + ((i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 6)); + String text = split[(j - 6) / 2 + ((i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 6)); } catch (Exception e) { textRenderData.setText(""); } } else { try { - textRenderData.setText(split[(j - 5) / 2 + ((i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)] + "鈭�5" + i + (j - 5)); + String text = split[(j - 5) / 2 + ((i - (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff)) / (angles + 2)) * (ports > 8 ? 4 : (ports + 1) / 2)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�5" + i + (j - 5)); } catch (Exception e) { textRenderData.setText(""); } @@ -4745,7 +4764,8 @@ String[] value = result2s.get((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg)) / portRow / (angles + 2)).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[((j - 5) + ((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) - 1) / (angles + 1) % portRow) * (Math.min(ports, 8)))]); + String text = split[((j - 5) + ((i - (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) - 1) / (angles + 1) % portRow) * (Math.min(ports, 8)))]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -4841,7 +4861,8 @@ //鏈�宸�� String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); - textRenderData.setText(split[0] + "鈭�7" + i); + String text = split[0]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�7" + i); } renderData.add(textRenderData); paragraphRenderData.setContents(renderData); @@ -4934,7 +4955,8 @@ //鏈�宸�� String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); - textRenderData.setText(split[0] + "鈭�7" + i); + String text = split[0]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text)) + "鈭�7" + i); } renderData.add(textRenderData); paragraphRenderData.setContents(renderData); @@ -5036,7 +5058,8 @@ String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[(j - 5) + ((i - (nn == 0 ? (mm == 0 ? (hh == 0 ? (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) : hh) : mm) : nn)) / (angles + 2)) * Math.min(length, 8)]); + String text = split[(j - 5) + ((i - (nn == 0 ? (mm == 0 ? (hh == 0 ? (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) : hh) : mm) : nn)) / (angles + 2)) * Math.min(length, 8)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -5143,7 +5166,8 @@ String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[(j - 5) + ((i - (pp == 0 ? (nn == 0 ? (mm == 0 ? (hh == 0 ? (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) : hh) : mm) : nn) : pp)) / (angles + 2)) * Math.min(length, 8)]); + String text = split[(j - 5) + ((i - (pp == 0 ? (nn == 0 ? (mm == 0 ? (hh == 0 ? (gg == 0 ? (ff == 0 ? (ee == 0 ? ((dd == 0 ? cc : dd)) : ee) : ff) : gg) : hh) : mm) : nn) : pp)) / (angles + 2)) * Math.min(length, 8)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -5250,7 +5274,8 @@ String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[(j - 5) + ((i - rr) / (angles + 2)) * Math.min(length, 8)]); + String text = split[(j - 5) + ((i - rr) / (angles + 2)) * Math.min(length, 8)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } @@ -5356,7 +5381,8 @@ String[] value = result2s.get(0).getValue().split("\\],\\["); String[] split = value[(i + (angles - 1)) % (angles + 1)].replaceAll("[\\[\\]\"]", "").split(","); try { - textRenderData.setText(split[(j - 5) + ((i - ss) / (angles + 2)) * Math.min(length, 8)]); + String text = split[(j - 5) + ((i - ss) / (angles + 2)) * Math.min(length, 8)]; + textRenderData.setText(String.format("%.2f",Double.parseDouble(text))); } catch (Exception e) { textRenderData.setText(""); } -- Gitblit v1.9.3