|
@@ -4,14 +4,8 @@ import com.xhkjedu.exception.MissingParametersException;
|
4
|
4
|
import lombok.extern.slf4j.Slf4j;
|
5
|
5
|
import org.springframework.util.CollectionUtils;
|
6
|
6
|
|
7
|
|
-import java.io.BufferedReader;
|
8
|
|
-import java.io.IOException;
|
9
|
|
-import java.io.InputStreamReader;
|
10
|
|
-import java.io.OutputStreamWriter;
|
11
|
7
|
import java.math.BigDecimal;
|
12
|
8
|
import java.math.RoundingMode;
|
13
|
|
-import java.net.URL;
|
14
|
|
-import java.net.URLConnection;
|
15
|
9
|
import java.text.DecimalFormat;
|
16
|
10
|
import java.text.ParseException;
|
17
|
11
|
import java.text.SimpleDateFormat;
|
|
@@ -721,259 +715,10 @@ public class N_Utils {
|
721
|
715
|
return map;//返回包含数字及其对应百分比的哈希映射
|
722
|
716
|
}
|
723
|
717
|
|
724
|
|
- /**
|
725
|
|
- * 格式化百分比
|
726
|
|
- * @Param [arr]
|
727
|
|
- * @Author ywx
|
728
|
|
- * @Date 2020/10/12 11:58
|
729
|
|
- * @return double[]
|
730
|
|
- **/
|
731
|
|
- public static double[] getPercentValue(int[] arr){
|
732
|
|
- //求和
|
733
|
|
- double sum = 0;
|
734
|
|
- if(sum <= 0){
|
735
|
|
- for (int i = 0; i < arr.length; i++) {
|
736
|
|
- sum += arr[i];
|
737
|
|
- }
|
738
|
|
- }
|
739
|
|
- //10的2次幂是100,用于计算精度。
|
740
|
|
- double digits = 1;
|
741
|
|
- //扩大比例100
|
742
|
|
- double[] votesPerQuota = new double[arr.length];
|
743
|
|
- for(int i = 0; i < arr.length; i++){
|
744
|
|
- double val = arr[i] / sum * digits * 100;
|
745
|
|
- votesPerQuota[i] = val;
|
746
|
|
- }
|
747
|
|
- //总数,扩大比例意味的总数要扩大
|
748
|
|
- double targetSeats = digits * 100;
|
749
|
|
- //再向下取值,组成数组
|
750
|
|
- double[] seats = new double[arr.length];
|
751
|
|
- for(int i = 0; i < votesPerQuota.length; i++){
|
752
|
|
- seats[i] = Math.floor(votesPerQuota[i]);
|
753
|
|
- }
|
754
|
|
- //再新计算合计,用于判断与总数量是否相同,相同则占比会100%
|
755
|
|
- double currentSum = 0;
|
756
|
|
- for (int i = 0; i < seats.length; i++) {
|
757
|
|
- currentSum += seats[i];
|
758
|
|
- }
|
759
|
|
- //余数部分的数组:原先数组减去向下取值的数组,得到余数部分的数组
|
760
|
|
- double[] remainder = new double[arr.length];
|
761
|
|
- for(int i = 0; i < seats.length; i++){
|
762
|
|
- remainder[i] = votesPerQuota[i] - seats[i];
|
763
|
|
- }
|
764
|
|
- while(currentSum < targetSeats){
|
765
|
|
- double max = 0;
|
766
|
|
- int maxId = 0;
|
767
|
|
- for(int i = 0;i < remainder.length;++i){
|
768
|
|
- if(remainder[i] > max){
|
769
|
|
- max = remainder[i];
|
770
|
|
- maxId = i;
|
771
|
|
- }
|
772
|
|
- }
|
773
|
|
- //对最大项余额加1
|
774
|
|
- ++seats[maxId];
|
775
|
|
- //已经增加最大余数加1,则下次判断就可以不需要再判断这个余额数。
|
776
|
|
- remainder[maxId] = 0;
|
777
|
|
- //总的也要加1,为了判断是否总数是否相同,跳出循环。
|
778
|
|
- ++currentSum;
|
779
|
|
- }
|
780
|
|
- // 这时候的seats就会总数占比会100%
|
781
|
|
- return seats;
|
782
|
|
- }
|
783
|
|
-
|
784
|
|
- /**
|
785
|
|
- *功能描述 字符串是否包含中文
|
786
|
|
- * @author WN
|
787
|
|
- * @date 2020/11/21
|
788
|
|
- * @param * @param str 待校验字符串
|
789
|
|
- * @return true 包含中文字符 false 不包含中文字符
|
790
|
|
- */
|
791
|
|
- public static boolean isContainChinese(String str){
|
792
|
|
- Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
|
793
|
|
- Matcher m = p.matcher(str);
|
794
|
|
- if(m.find()){
|
795
|
|
- return true;
|
796
|
|
- }
|
797
|
|
- return false;
|
798
|
|
-
|
799
|
|
- }
|
800
|
|
-
|
801
|
|
-
|
802
|
|
- /**
|
803
|
|
- * 随机生成4位随机码
|
804
|
|
- * @Param []
|
805
|
|
- * @Author ywx
|
806
|
|
- * @Date 2020/5/8 9:29
|
807
|
|
- * @return java.lang.Integer
|
808
|
|
- **/
|
809
|
|
- public static Integer messageCode(){
|
810
|
|
- return (int) ((Math.random()*9+1)*1000);
|
811
|
|
- }
|
812
|
|
-
|
813
|
|
- /**
|
814
|
|
- * 向指定 URL 发送POST方法的请求
|
815
|
|
- * @param url 发送请求的 URL
|
816
|
|
- * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
|
817
|
|
- * @return 所代表远程资源的响应结果
|
818
|
|
- */
|
819
|
|
- public static String sendPost(String url, String param) {
|
820
|
|
- OutputStreamWriter out = null;
|
821
|
|
- BufferedReader in = null;
|
822
|
|
- String result = "";
|
823
|
|
- try {
|
824
|
|
- URL realUrl = new URL(url);
|
825
|
|
- // 打开和URL之间的连接
|
826
|
|
- URLConnection conn = realUrl.openConnection();
|
827
|
|
- // 设置通用的请求属性
|
828
|
|
- conn.setRequestProperty("accept", "application/x-www-form-urlencoded");
|
829
|
|
- conn.setRequestProperty("connection", "Keep-Alive");
|
830
|
|
- conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
831
|
|
- // 发送POST请求必须设置如下两行
|
832
|
|
- conn.setDoOutput(true);
|
833
|
|
- conn.setDoInput(true);
|
834
|
|
- //设置请求编码格式
|
835
|
|
- conn.setRequestProperty("Accept-Charset", "UTF-8");
|
836
|
|
- // 文件流编码设置
|
837
|
|
- out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
838
|
|
- out.write(param);
|
839
|
|
- // flush输出流的缓冲
|
840
|
|
- out.flush();
|
841
|
|
- // 定义BufferedReader输入流来读取URL的响应
|
842
|
|
- in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
843
|
|
- String line;
|
844
|
|
- while ((line = in.readLine()) != null) {
|
845
|
|
- result += line;
|
846
|
|
- }
|
847
|
|
- } catch (Exception e) {
|
848
|
|
- log.error("发送 POST 请求出现异常!" + e.getMessage());
|
849
|
|
- }
|
850
|
|
- // 使用finally块来关闭输出流、输入流
|
851
|
|
- finally {
|
852
|
|
- try {
|
853
|
|
- if (out != null) {
|
854
|
|
- out.close();
|
855
|
|
- }
|
856
|
|
- if (in != null) {
|
857
|
|
- in.close();
|
858
|
|
- }
|
859
|
|
- } catch (IOException ex) {
|
860
|
|
- log.error("关闭输入输出流异常", ex.getMessage());
|
861
|
|
- }
|
862
|
|
- }
|
863
|
|
- return result;
|
864
|
|
- }
|
865
|
|
-
|
866
|
|
- /**
|
867
|
|
- * 向指定 URL 发送POST方法的请求
|
868
|
|
- * @Param [url, param]
|
869
|
|
- * @Author ywx
|
870
|
|
- * @Date 2021/5/6 16:01
|
871
|
|
- * @return java.lang.String
|
872
|
|
- **/
|
873
|
|
- public static String sendJsonPost(String url, String param) {
|
874
|
|
- OutputStreamWriter out = null;
|
875
|
|
- BufferedReader in = null;
|
876
|
|
- String result = "";
|
877
|
|
- try {
|
878
|
|
- URL realUrl = new URL(url);
|
879
|
|
- // 打开和URL之间的连接
|
880
|
|
- URLConnection conn = realUrl.openConnection();
|
881
|
|
- // 设置通用的请求属性
|
882
|
|
- conn.setRequestProperty("accept", "application/json");
|
883
|
|
- conn.setRequestProperty("Content-Type","application/json;charset=UTF-8");
|
884
|
|
- conn.setRequestProperty("connection", "Keep-Alive");
|
885
|
|
- conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
|
886
|
|
- // 发送POST请求必须设置如下两行
|
887
|
|
- conn.setDoOutput(true);
|
888
|
|
- conn.setDoInput(true);
|
889
|
|
- //设置请求编码格式
|
890
|
|
- conn.setRequestProperty("Accept-Charset", "UTF-8");
|
891
|
|
- // 文件流编码设置
|
892
|
|
- out = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
|
893
|
|
- out.write(param);
|
894
|
|
- // flush输出流的缓冲
|
895
|
|
- out.flush();
|
896
|
|
- // 定义BufferedReader输入流来读取URL的响应
|
897
|
|
- in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
|
898
|
|
- String line;
|
899
|
|
- while ((line = in.readLine()) != null) {
|
900
|
|
- result += line;
|
901
|
|
- }
|
902
|
|
- } catch (Exception e) {
|
903
|
|
- System.out.println("发送 POST 请求出现异常!" + e.getMessage());
|
904
|
|
- }
|
905
|
|
- // 使用finally块来关闭输出流、输入流
|
906
|
|
- finally {
|
907
|
|
- try {
|
908
|
|
- if (out != null) {
|
909
|
|
- out.close();
|
910
|
|
- }
|
911
|
|
- if (in != null) {
|
912
|
|
- in.close();
|
913
|
|
- }
|
914
|
|
- } catch (IOException ex) {
|
915
|
|
- System.out.println("关闭输入输出流异常" + ex.getMessage());
|
916
|
|
- }
|
917
|
|
- }
|
918
|
|
- return result;
|
919
|
|
- }
|
920
|
|
-
|
921
|
|
- /**
|
922
|
|
- * 发送form-data请求返回json结果
|
923
|
|
- * @Param [apiUrl, param]
|
924
|
|
- * @Author ywx
|
925
|
|
- * @Date 2021/5/14 17:41
|
926
|
|
- * @return java.lang.String
|
927
|
|
- **/
|
928
|
|
- /*public static String sendFormData(String apiUrl, MultiValueMap<String, String> param) {
|
929
|
|
- try {
|
930
|
|
- HttpHeaders headers = new HttpHeaders();
|
931
|
|
- headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
|
932
|
|
- List<MediaType> acceptableMediaTypes = new ArrayList<>();
|
933
|
|
- acceptableMediaTypes.add(MediaType.APPLICATION_FORM_URLENCODED);
|
934
|
|
- acceptableMediaTypes.add(MediaType.APPLICATION_PROBLEM_JSON_UTF8);
|
935
|
|
- HttpEntity<MultiValueMap<String, String>> requestParams = new HttpEntity<>(param, headers);
|
936
|
|
- ResponseEntity<String> response = new RestTemplate().postForEntity(apiUrl, requestParams, String.class);
|
937
|
|
- String result = response.getBody();
|
938
|
|
- return result;
|
939
|
|
- } catch (RestClientException e) {
|
940
|
|
- log.error("发送form-data请求失败",e.getMessage());
|
941
|
|
- return null;
|
942
|
|
- }
|
943
|
|
- }*/
|
944
|
|
-
|
945
|
718
|
static String CHN_NUMBER[] = { "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" };
|
946
|
719
|
static String CHN_UNIT[] = { "", "十", "百", "千" }; // 权位
|
947
|
720
|
static String CHN_UNIT_SECTION[] = { "", "万", "亿", "万亿" }; // 节权位
|
948
|
721
|
|
949
|
|
- /**
|
950
|
|
- * 阿拉伯数字转换为中文数字的核心算法实现。
|
951
|
|
- * @return
|
952
|
|
- */
|
953
|
|
- public static String NumberToChn(int num) {
|
954
|
|
- StringBuffer returnStr = new StringBuffer();
|
955
|
|
- Boolean needZero = false;
|
956
|
|
- int pos = 0; // 节权位的位置
|
957
|
|
- if (num == 0) {
|
958
|
|
- // 如果num为0,进行特殊处理。
|
959
|
|
- returnStr.insert(0, CHN_NUMBER[0]);
|
960
|
|
- }
|
961
|
|
- while (num > 0) {
|
962
|
|
- int section = num % 10000;
|
963
|
|
- if (needZero) {
|
964
|
|
- returnStr.insert(0, CHN_NUMBER[0]);
|
965
|
|
- }
|
966
|
|
- String sectionToChn = SectionNumToChn(section);
|
967
|
|
- // 判断是否需要节权位
|
968
|
|
- sectionToChn += (section != 0) ? CHN_UNIT_SECTION[pos] : CHN_UNIT_SECTION[0];
|
969
|
|
- returnStr.insert(0, sectionToChn);
|
970
|
|
- needZero = ((section < 1000 && section > 0) ? true : false); // 判断section中的千位上是不是为零,若为零应该添加一个零。
|
971
|
|
- pos++;
|
972
|
|
- num = num / 10000;
|
973
|
|
- }
|
974
|
|
- return returnStr.toString().replace("一十", "十");
|
975
|
|
- }
|
976
|
|
-
|
977
|
722
|
/**
|
978
|
723
|
* 将四位的section转换为中文数字
|
979
|
724
|
*
|
|
@@ -1006,39 +751,6 @@ public class N_Utils {
|
1006
|
751
|
return returnStr.toString();
|
1007
|
752
|
}
|
1008
|
753
|
|
1009
|
|
- /**
|
1010
|
|
- * 字符串是否包含在集合中的字符串集合
|
1011
|
|
- * @Param [num, nums]
|
1012
|
|
- * @Author ywx
|
1013
|
|
- * @Date 2020/12/24 14:10
|
1014
|
|
- * @return boolean
|
1015
|
|
- **/
|
1016
|
|
- public static boolean strInList(String num,List<String> nums){
|
1017
|
|
- if (nums.contains(num)){
|
1018
|
|
- return true;
|
1019
|
|
- } else {
|
1020
|
|
- return false;
|
1021
|
|
- }
|
1022
|
|
- }
|
1023
|
|
-
|
1024
|
|
- //计算比例
|
1025
|
|
- public static String getFs(int a, int b){ // 设置分子和分母
|
1026
|
|
- int numerator; // 分子
|
1027
|
|
- int denominator; // 分母
|
1028
|
|
- if(a == 0 || b == 0){
|
1029
|
|
- numerator = a;
|
1030
|
|
- denominator = b;
|
1031
|
|
- }else{
|
1032
|
|
- int c = f(Math.abs(a),Math.abs(b)); // 计算最大公约数
|
1033
|
|
- numerator = a / c;
|
1034
|
|
- denominator = b / c;
|
1035
|
|
- if(numerator<0 && denominator<0){
|
1036
|
|
- numerator = - numerator;
|
1037
|
|
- denominator = - denominator;
|
1038
|
|
- }
|
1039
|
|
- }
|
1040
|
|
- return numerator + ":" + denominator;
|
1041
|
|
- }
|
1042
|
754
|
|
1043
|
755
|
static int f(int a,int b){ // 求a和b的最大公约数
|
1044
|
756
|
if(a < b){
|
|
@@ -1055,24 +767,7 @@ public class N_Utils {
|
1055
|
767
|
return b;
|
1056
|
768
|
}
|
1057
|
769
|
|
1058
|
|
- //求一个数组的最大公约数
|
1059
|
|
- public static int getArrMaxGys(int nums[]){
|
1060
|
|
- int a=nums[0];int b=nums[1];int i=0;
|
1061
|
|
- int temp;
|
1062
|
|
- if(a<b){
|
1063
|
|
- temp = a;
|
1064
|
|
- a = b;
|
1065
|
|
- b = temp;
|
1066
|
|
- temp = a % b;
|
1067
|
|
- while (temp != 0) {
|
1068
|
|
- a = b;
|
1069
|
|
- b = temp;
|
1070
|
|
- temp = a % b;
|
1071
|
|
- }
|
1072
|
|
- nums[i + 1] = b;
|
1073
|
|
- }
|
1074
|
|
- return nums[nums.length - 1];
|
1075
|
|
- }
|
|
770
|
+
|
1076
|
771
|
|
1077
|
772
|
//处理题型中客观题1选择题2多选题456判断7完型填空全选择(弃用)8阅读理解全选择(弃用)10任务行阅读券选择(弃用)16完型填空复合17任务型阅读复合
|
1078
|
773
|
private static int[] octypelist = new int[]{1,2,4,5,6,7,8,10,16,17};
|
|
@@ -1100,125 +795,38 @@ public class N_Utils {
|
1100
|
795
|
}
|
1101
|
796
|
}
|
1102
|
797
|
|
1103
|
|
- //处理题型中复合题
|
1104
|
|
- private static int[] cctypelist = new int[]{11,16,17};
|
1105
|
|
- /*
|
1106
|
|
- * 判断ctype是否是复合题
|
1107
|
|
- * @Param [ctype]
|
1108
|
|
- * @Author ywx
|
1109
|
|
- * @Date 2022/10/18 19:11
|
1110
|
|
- * @return boolean
|
1111
|
|
- **/
|
1112
|
|
- public static boolean isComplexQuestion(Integer ctype){
|
1113
|
|
- if(ctype != null && ctype != 0){
|
1114
|
|
- return IntStream.of(cctypelist).anyMatch(x -> x == ctype);
|
1115
|
|
- }else{
|
1116
|
|
- return false;
|
1117
|
|
- }
|
1118
|
|
- }
|
1119
|
|
-
|
1120
|
|
- /*
|
1121
|
|
- * @Description 年级集合(导入时根据名次获取对应数字)
|
1122
|
|
- * @Author WN
|
1123
|
|
- * @Date 2023/4/11 10:07
|
1124
|
|
- */
|
1125
|
|
- public static Map<String, Integer> listGrade() {
|
1126
|
|
- Map m = new HashMap();
|
1127
|
|
- m.put("一年级", 1);
|
1128
|
|
- m.put("二年级", 2);
|
1129
|
|
- m.put("三年级", 3);
|
1130
|
|
- m.put("四年级", 4);
|
1131
|
|
- m.put("五年级", 5);
|
1132
|
|
- m.put("六年级", 6);
|
1133
|
|
- m.put("七年级", 7);
|
1134
|
|
- m.put("八年级", 8);
|
1135
|
|
- m.put("九年级", 9);
|
1136
|
|
- m.put("高一", 10);
|
1137
|
|
- m.put("高二", 11);
|
1138
|
|
- m.put("高三", 12);
|
1139
|
|
- return m;
|
1140
|
|
- }
|
1141
|
|
-
|
1142
|
|
- /*
|
1143
|
|
- * @Description 根据年级id获取年级名次
|
1144
|
|
- * @Author WN
|
1145
|
|
- * @Date 2023/4/11 10:07
|
1146
|
|
- */
|
1147
|
|
- public static String getGradeName(Integer gradeid){
|
1148
|
|
- Map gradeMap = new HashMap();
|
1149
|
|
- gradeMap.put(1, "一年级");
|
1150
|
|
- gradeMap.put(2, "二年级");
|
1151
|
|
- gradeMap.put(3, "三年级");
|
1152
|
|
- gradeMap.put(4, "四年级");
|
1153
|
|
- gradeMap.put(5, "五年级");
|
1154
|
|
- gradeMap.put(6, "六年级");
|
1155
|
|
- gradeMap.put(7, "七年级");
|
1156
|
|
- gradeMap.put(8, "八年级");
|
1157
|
|
- gradeMap.put(9, "九年级");
|
1158
|
|
- gradeMap.put(10, "高一");
|
1159
|
|
- gradeMap.put(11, "高二");
|
1160
|
|
- gradeMap.put(12, "高三");
|
1161
|
|
- String gradename = gradeMap.get(gradeid).toString();
|
1162
|
|
- return gradename;
|
1163
|
|
- }
|
1164
|
798
|
|
1165
|
799
|
/**
|
1166
|
|
- * 分数百分比
|
|
800
|
+ * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字舍弃。
|
1167
|
801
|
*
|
1168
|
|
- * @param v1 分数
|
1169
|
|
- * @param v2 占比如80%写作0.8
|
1170
|
|
- * @return
|
|
802
|
+ * @param v1 被除数
|
|
803
|
+ * @param v2 除数
|
|
804
|
+ * @param scale 表示表示需要精确到小数点以后几位。
|
|
805
|
+ * @return 两个参数的商
|
1171
|
806
|
*/
|
1172
|
|
- public static double getScoreRateScore(double v1, double v2) {
|
1173
|
|
- BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
1174
|
|
- BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
1175
|
|
-
|
1176
|
|
- return b1.multiply(b2).setScale(0, BigDecimal.ROUND_HALF_UP).doubleValue();
|
1177
|
|
- }
|
1178
|
|
-
|
1179
|
|
- /**
|
1180
|
|
- * @Description 分值平均后得到的值,如果整除返回数组元素1,未整除返回元素数量2
|
1181
|
|
- * @Param [num, score] 数量,分值
|
1182
|
|
- * @Return java.lang.Double[] 第一个未平均分值,第二个值为最后一个数的分值
|
1183
|
|
- * @Author wn
|
1184
|
|
- * @Date 2022/8/18 11:07
|
1185
|
|
- **/
|
1186
|
|
- public static Double[] getPointAvgScore(int num, Double score) {
|
1187
|
|
- BigDecimal bScore = new BigDecimal(Double.toString(score));
|
1188
|
|
- BigDecimal bNum = new BigDecimal(Integer.toString(num));
|
1189
|
|
-
|
1190
|
|
- //2023-07-04通过四舍五入进行计算,
|
1191
|
|
- BigDecimal avg = bScore.divide(bNum, 1, BigDecimal.ROUND_HALF_UP);
|
1192
|
|
- BigDecimal avgAllScore = avg.multiply(bNum);//平均分乘以数量得到的分值
|
1193
|
|
- if (bScore.equals(avgAllScore)) {
|
1194
|
|
- //说明整除
|
1195
|
|
- return new Double[]{avg.doubleValue()};
|
1196
|
|
- } else {
|
1197
|
|
- //未整除,计算最后剩余分值,subtract总分减去平均分和数量的积
|
1198
|
|
- // 平均分加上剩余得分得到最后一个分值
|
1199
|
|
- BigDecimal lastScore = avg.add(bScore.subtract(avgAllScore));
|
1200
|
|
- return new Double[]{avg.doubleValue(), lastScore.doubleValue()};
|
|
807
|
+ public static double div(double v1, double v2, int scale) {
|
|
808
|
+ try {
|
|
809
|
+ if (scale < 0) {
|
|
810
|
+ throw new IllegalArgumentException("The scale must be a positive integer or zero");
|
|
811
|
+ }
|
|
812
|
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
|
813
|
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
|
814
|
+ return b1.divide(b2, scale, BigDecimal.ROUND_DOWN).doubleValue();
|
|
815
|
+ } catch (Exception e) {
|
|
816
|
+ return 0;
|
1201
|
817
|
}
|
1202
|
818
|
}
|
1203
|
819
|
|
1204
|
820
|
/**
|
1205
|
|
- * @Description 是否是白名单接口
|
1206
|
|
- * @Date 2023/11/3 9:26
|
1207
|
|
- * @Author YWX
|
1208
|
|
- * @Param [requestURI, whitelistAPI]
|
1209
|
|
- * @Return boolean
|
1210
|
|
- **/
|
1211
|
|
- public static boolean whiteAPI(String requestURI, String whitelistAPI) {
|
1212
|
|
- boolean rtn = false;
|
1213
|
|
- if (isEmpty(whitelistAPI)) return rtn;
|
1214
|
|
-
|
1215
|
|
- String[] apis = whitelistAPI.split(",");
|
1216
|
|
- for (String api : apis) {
|
1217
|
|
- if (requestURI.contains(api)) {
|
1218
|
|
- rtn = true;
|
1219
|
|
- break;
|
1220
|
|
- }
|
1221
|
|
- }
|
1222
|
|
- return rtn;
|
|
821
|
+ * 提供精确的加法运算。
|
|
822
|
+ *
|
|
823
|
+ * @param v1 被加数
|
|
824
|
+ * @param v2 加数
|
|
825
|
+ * @return 两个参数的和
|
|
826
|
+ */
|
|
827
|
+ public static double add(double v1, double v2) {
|
|
828
|
+ BigDecimal b1 = new BigDecimal(Double.toString(v1));
|
|
829
|
+ BigDecimal b2 = new BigDecimal(Double.toString(v2));
|
|
830
|
+ return b1.add(b2).doubleValue();
|
1223
|
831
|
}
|
1224
|
832
|
}
|