TransUtil.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package com.gct.tools.etlcamelhuge.util;
  2. import java.text.DecimalFormat;
  3. /**
  4. * @author: Lijian
  5. * @create: 2020-11-16 11:34
  6. **/
  7. public class TransUtil {
  8. private static final DecimalFormat decimalFormat = new DecimalFormat("######0.00");
  9. String displacement = "[0,0,0,0,0.001,0.002,0.003,0.004,0.006,0.007,0.009,0.011,0.014,0.016,0.019,0.021,0.024,0.028,0.031,0.034," +
  10. "0.038,0.042,0.046,0.05,0.054,0.058,0.062,0.067,0.071,0.076,0.08,0.085,0.09,0.094,0.099,0.104,0.109,0.114,0.119,0.123," +
  11. "0.128,0.133,0.138,0.143,0.147,0.152,0.157,0.162,0.166,0.171,0.175,0.18,0.184,0.189,0.193,0.197,0.202,0.206,0.21,0.214," +
  12. "0.218,0.222,0.226,0.229,0.233,0.237,0.24,0.244,0.247,0.25,0.254,0.257,0.26,0.263,0.266,0.269,0.271,0.274,0.277,0.279," +
  13. "0.282,0.284,0.286,0.288,0.29,0.292,0.294,0.296,0.297,0.299,0.3,0.302,0.303,0.304,0.305,0.306,0.307,0.307,0.308,0.308," +
  14. "0.309,0.309,0.309,0.309,0.308,0.308,0.307,0.307,0.306,0.305,0.304,0.303,0.291,0.289,0.287,0.285,0.283,0.281,0.279,0.276," +
  15. "0.274,0.271,0.268,0.265,0.262,0.259,0.256,0.252,0.249,0.245,0.242,0.238,0.234,0.231,0.227,0.223,0.219,0.215,0.21,0.206," +
  16. "0.202,0.198,0.193,0.189,0.184,0.18,0.176,0.171,0.167,0.162,0.157,0.153,0.148,0.144,0.139,0.135,0.13,0.126,0.121,0.117," +
  17. "0.112,0.108,0.103,0.099,0.095,0.09,0.086,0.082,0.078,0.074,0.07,0.066,0.062,0.058,0.054,0.051,0.047,0.043,0.04,0.037," +
  18. "0.034,0.031,0.028,0.025,0.022,0.02,0.017,0.015,0.013,0.011,0.009,0.007,0.006,0.004,0.003,0.002,0.001,0,0,0]";
  19. String dispLoad = "[24.17,24.89,24.63,24.85,25.52,25.99,26.55,26.89,27.83,28.51,29.36,30.36,31.54,32.62,32.81,31.61," +
  20. "30.65,30.11,30.66,31.58,32.06,32.43,31.42,30.77,30.57,30.41,31.29,31.78,31.69,31.49,30.62,30.36,30.77,30.94," +
  21. "31.73,31.42,31.08,30.71,30.24,30.58,30.85,30.86,31.36,30.74,30.57,30.59,30.04,30.71,30.77,30.65,30.94,30.28," +
  22. "30.16,30.44,30.09,30.86,30.6,30.38,30.57,29.85,30.33,30.33,30.09,30.84,30.26,30.46,30.5,29.89,30.49,30.11,30.3," +
  23. "30.59,30.02,30.41,30.05,30.11,30.37,29.97,30.36,30.13,30.05,30.39,29.95,30.3,30.32,30.12,30.48,30.07,30.16,30.27," +
  24. "30.05,30.36,30.23,30.26,30.28,30.1,30.26,30.14,30.21,30.29,30.13,29.9,29.11,29.06,28.98,28.88,29.08,28.07,27.8," +
  25. "27.33,27.22,26.32,25.04,24.49,23.23,22.28,21.69,21.74,22.78,23.57,24.13,23.14,22.6,21.64,21.62,22.59,23.11,23.59," +
  26. "23.33,22.49,21.65,21.86,22.17,22.72,23.47,23,22.81,21.81,21.77,22.13,22.26,23.27,22.93,22.83,22.16,21.91,21.87," +
  27. "22.7,22.76,22.99,22.68,21.94,22.12,22.02,22.4,22.83,22.78,22.68,22.31,21.81,22.28,22.08,22.79,22.92,22.66,22.63," +
  28. "22.12,22.28,22.45,22.85,22.87,22.87,22.49,22.52,22.53,22.58,22.99,22.73,23.04,22.8,22.45,22.78,22.64,23.09,23.24," +
  29. "22.93,23.26,22.75,22.87,23.18,23.06,23.39,23.27,23.2,23.24,23.04,23.32,23.31,23.54,23.79]";
  30. String a = "[14.21,14.68,15.01,15.14,15.04,14.78,14.47,14.24,14.14,14.17,14.32,14.53,14.72,14.79,14.73,14.6,14.44,14.26,14.02,13.85," +
  31. "13.82,13.91,14.03,14.19,14.32,14.41,14.38,14.28,14.1,13.75,13.54,13.35,13.38,13.52,13.87,14.07,14.2,14.23,14.24," +
  32. "14.03,13.74,13.52,13.4,13.41,13.6,13.77,13.99,14.17,14.22,14.03,13.73,13.5,13.35,13.36,13.44,13.59,13.77,14,14.06," +
  33. "14.01,13.83,13.67,13.5,13.44,13.4,13.52,13.68,13.91,13.99,14.05,13.98,13.86,13.67,13.51,13.41,13.43,13.55,13.68,13.81," +
  34. "13.88,13.88,13.75,13.58,13.35,13.21,13.13,13.17,13.22,13.32,13.36,13.36,13.28,13.14,12.89,12.59,12.31,12.11,12.01,11.95," +
  35. "11.93,11.65,11.28,10.81,10.47,10.2,10.1,10.14,10.28,10.57,10.81,10.92,10.77,10.61,10.27,9.99,9.68,9.63,9.68,9.93,10.16," +
  36. "10.35,10.43,10.42,10.25,10.01,9.74,9.53,9.46,9.52,9.68,9.9,10.15,10.27,10.3,10.16,9.97,9.74,9.65,9.59,9.69,9.84,10.08," +
  37. "10.24,10.37,10.36,10.26,10.07,9.94,9.9,9.95,10.11,10.31,10.53,10.74,10.86,10.89,10.82,10.71,10.61,10.56,10.57,10.63," +
  38. "10.74,10.89,11.03,11.11,11.11,11.06,11,10.93,10.88,10.86,10.92,11.02,11.14,11.22,11.27,11.27,11.22,11.15,11.07,11.03," +
  39. "11.03,11.09,11.16,11.25,11.32,11.39,11.42,11.4,11.39,11.39,11.44,11.55,11.75,12.11,12.55,12.97,13.33,13.73]";
  40. /**
  41. * 转换为前3后5格式的功图数据
  42. * @param displacement
  43. * @param dispLoad
  44. * @return
  45. */
  46. public static String trans(String displacement,String dispLoad){
  47. StringBuffer sb = new StringBuffer();
  48. if(displacement == null || dispLoad ==null || "0".equals(displacement) || "0".equals(dispLoad)){
  49. return "";
  50. }
  51. displacement = displacement.substring(1, displacement.length() - 1);
  52. dispLoad = dispLoad.substring(1,dispLoad.length()-1);
  53. String[] s1 = displacement.split(",");
  54. String[] s2 = dispLoad.split(",");
  55. for(int i=0;i<s1.length && i< s2.length; i++){
  56. String s1_i = decimalFormat.format(Double.valueOf(s1[i]));
  57. sb.append(s1_i.replace(".",""));
  58. String s2_i = decimalFormat.format(Double.valueOf(s2[i]));
  59. int index = s2_i.indexOf(".");
  60. if (index == 2) {
  61. sb.append("0").append(s2_i.replace(".", ""));
  62. }else if ( index == 1){
  63. sb.append("00").append(s2_i.replace(".", ""));
  64. } else {
  65. sb.append(s2_i.replace(".", ""));
  66. }
  67. }
  68. return sb.toString();
  69. }
  70. public static String tranSGT(String displacement,String dispLoad){
  71. StringBuffer sb = new StringBuffer();
  72. if(displacement == null || dispLoad ==null || "0".equals(displacement) || "0".equals(dispLoad)){
  73. return "";
  74. }
  75. displacement = displacement.substring(1, displacement.length() - 1);
  76. dispLoad = dispLoad.substring(1,dispLoad.length()-1);
  77. String[] offset = displacement.split(",");
  78. String[] load = dispLoad.split(",");
  79. for(int i=0;i<offset.length && i< load.length; i++){
  80. if (i != 0) sb.append(",");
  81. int o = new Double(Double.valueOf(offset[i]) * 100 ).intValue();
  82. sb.append(o);
  83. int l = new Double(Double.valueOf(load[i]) * 100).intValue();
  84. sb.append(",").append(l);
  85. }
  86. return sb.toString();
  87. }
  88. }
  89. /* "0.00;0.00;0.01;0.01;0.02;0.02;0.03;0.04;0.06;0.07;0.09;0.11;0.12;0.14;0.17;0.19;0.22;0.24;0.27;0.30;0.34;" +
  90. "0.37;0.40;0.43;0.46;0.49;0.53;0.56;0.59;0.62;0.65;0.69;0.72;0.75;0.78;0.81;0.84;0.88;0.91;0.94;0.97;" +
  91. "1.00;1.04;1.07;1.10;1.13;1.16;1.20;1.23;1.26;1.29;1.32;1.35;1.39;1.42;1.45;1.48;1.51;1.54;1.58;1.61;" +
  92. "1.64;1.67;1.71;1.74;1.77;1.80;1.83;1.86;1.90;1.93;1.96;1.99;2.02;2.06;2.09;2.12;2.15;2.18;2.21;2.25;" +
  93. "2.28;2.31;2.34;2.37;2.40;2.42;2.45;2.47;2.49;2.51;2.52;2.54;2.56;2.57;2.58;2.59;2.60;2.60;2.61;2.61;" +
  94. "2.61;2.61;2.61;2.61;2.60;2.60;2.59;2.58;2.57;2.56;2.54;2.52;2.51;2.49;2.47;2.45;2.42;2.40;2.37;2.34;" +
  95. "2.31;2.28;2.25;2.22;2.19;2.16;2.13;2.10;2.07;2.04;2.01;1.98;1.95;1.92;1.89;1.86;1.83;1.80;1.77;1.74;" +
  96. "1.71;1.68;1.65;1.62;1.59;1.56;1.53;1.50;1.47;1.44;1.41;1.38;1.35;1.32;1.29;1.26;1.23;1.20;1.17;1.14;" +
  97. "1.11;1.08;1.05;1.02;0.99;0.96;0.93;0.90;0.87;0.84;0.81;0.78;0.75;0.72;0.69;0.66;0.63;0.60;0.57;0.54;" +
  98. "0.51;0.48;0.45;0.42;0.39;0.36;0.33;0.30;0.27;0.24;0.21;0.18;0.15;0.12;0.09;0.06;0.03;0.00;0.00" */
  99. /*
  100. 24.82;25.16;25.50;25.90;26.31;26.78;27.25;27.69;28.19;28.74;29.33;29.97;30.69;31.48;32.34;33.24;34.17;35.14;
  101. 36.12;37.03;37.83;38.47;38.95;39.29;39.44;39.50;39.45;39.38;39.31;39.32;39.39;39.50;39.59;39.66;39.66;39.68;
  102. 39.63;39.55;39.53;39.53;39.56;39.64;39.73;39.81;39.91;39.90;39.87;39.82;39.80;39.78;39.77;39.74;39.76;39.83;
  103. 39.82;39.81;39.78;39.74;39.70;39.68;39.62;39.61;39.58;39.54;39.47;39.41;39.34;39.25;39.16;39.06;38.96;38.89;
  104. 38.80;38.69;38.55;38.38;38.14;37.87;37.55;37.15;36.64;36.00;35.62;35.19;34.69;34.15;33.58;33.01;32.40;31.80;
  105. 31.21;30.64;30.13;29.65;29.23;28.85;28.50;28.21;27.98;27.83;27.79;27.70;27.58;27.42;27.18;26.87;26.58;26.31;
  106. 26.03;25.85;25.76;25.70;25.66;25.57;25.46;25.31;25.14;24.97;24.77;24.59;24.47;24.36;24.31;24.23;24.17;24.09;
  107. 23.97;23.83;23.68;23.53;23.39;23.31;23.19;23.07;23.01;22.95;22.87;22.80;22.69;22.56;22.51;22.45;22.39;22.36;
  108. 22.30;22.22;22.15;22.12;22.06;22.00;21.92;21.88;21.85;21.79;21.75;21.69;21.68;21.64;21.60;21.57;21.57;21.57;
  109. 21.59;21.58;21.60;21.63;21.64;21.68;21.72;21.74;21.80;21.83;21.92;22.01;22.11;22.21;22.34;22.43;22.55;22.68;
  110. 22.78;22.91;22.98;23.06;23.14;23.21;23.28;23.37;23.48;23.55;23.64;23.72;23.82;23.91;24.01;24.13;24.25;24.36;24.49;24.65
  111. */
  112. /* "0.00;0.00;0.01;0.01;0.02;0.02;0.03;0.04;0.06;0.07;0.09;0.11;0.12;0.14;0.17;0.19;0.22;0.24;0.27;0.30;0.34;" +
  113. "0.37;0.40;0.43;0.46;0.49;0.53;0.56;0.59;0.62;0.65;0.69;0.72;0.75;0.78;0.81;0.84;0.88;0.91;0.94;0.97;" +
  114. "1.00;1.04;1.07;1.10;1.13;1.16;1.20;1.23;1.26;1.29;1.32;1.35;1.39;1.42;1.45;1.48;1.51;1.54;1.58;1.61;" +
  115. "1.64;1.67;1.71;1.74;1.77;1.80;1.83;1.86;1.90;1.93;1.96;1.99;2.02;2.06;2.09;2.12;2.15;2.18;2.21;2.25;" +
  116. "2.28;2.31;2.34;2.37;2.40;2.42;2.45;2.47;2.49;2.51;2.52;2.54;2.56;2.57;2.58;2.59;2.60;2.60;2.61;2.61;" +
  117. "2.61;2.61;2.61;2.61;2.60;2.60;2.59;2.58;2.57;2.56;2.54;2.52;2.51;2.49;2.47;2.45;2.42;2.40;2.37;2.34;" +
  118. "2.31;2.28;2.25;2.22;2.19;2.16;2.13;2.10;2.07;2.04;2.01;1.98;1.95;1.92;1.89;1.86;1.83;1.80;1.77;1.74;" +
  119. "1.71;1.68;1.65;1.62;1.59;1.56;1.53;1.50;1.47;1.44;1.41;1.38;1.35;1.32;1.29;1.26;1.23;1.20;1.17;1.14;" +
  120. "1.11;1.08;1.05;1.02;0.99;0.96;0.93;0.90;0.87;0.84;0.81;0.78;0.75;0.72;0.69;0.66;0.63;0.60;0.57;0.54;" +
  121. "0.51;0.48;0.45;0.42;0.39;0.36;0.33;0.30;0.27;0.24;0.21;0.18;0.15;0.12;0.09;0.06;0.03;0.00;0.00" */
  122. /*
  123. 24.82;25.16;25.50;25.90;26.31;26.78;27.25;27.69;28.19;28.74;29.33;29.97;30.69;31.48;32.34;33.24;34.17;35.14;
  124. 36.12;37.03;37.83;38.47;38.95;39.29;39.44;39.50;39.45;39.38;39.31;39.32;39.39;39.50;39.59;39.66;39.66;39.68;
  125. 39.63;39.55;39.53;39.53;39.56;39.64;39.73;39.81;39.91;39.90;39.87;39.82;39.80;39.78;39.77;39.74;39.76;39.83;
  126. 39.82;39.81;39.78;39.74;39.70;39.68;39.62;39.61;39.58;39.54;39.47;39.41;39.34;39.25;39.16;39.06;38.96;38.89;
  127. 38.80;38.69;38.55;38.38;38.14;37.87;37.55;37.15;36.64;36.00;35.62;35.19;34.69;34.15;33.58;33.01;32.40;31.80;
  128. 31.21;30.64;30.13;29.65;29.23;28.85;28.50;28.21;27.98;27.83;27.79;27.70;27.58;27.42;27.18;26.87;26.58;26.31;
  129. 26.03;25.85;25.76;25.70;25.66;25.57;25.46;25.31;25.14;24.97;24.77;24.59;24.47;24.36;24.31;24.23;24.17;24.09;
  130. 23.97;23.83;23.68;23.53;23.39;23.31;23.19;23.07;23.01;22.95;22.87;22.80;22.69;22.56;22.51;22.45;22.39;22.36;
  131. 22.30;22.22;22.15;22.12;22.06;22.00;21.92;21.88;21.85;21.79;21.75;21.69;21.68;21.64;21.60;21.57;21.57;21.57;
  132. 21.59;21.58;21.60;21.63;21.64;21.68;21.72;21.74;21.80;21.83;21.92;22.01;22.11;22.21;22.34;22.43;22.55;22.68;
  133. 22.78;22.91;22.98;23.06;23.14;23.21;23.28;23.37;23.48;23.55;23.64;23.72;23.82;23.91;24.01;24.13;24.25;24.36;24.49;24.65
  134. */