|
@@ -539,7 +539,7 @@ public class N_Utils {
|
539
|
539
|
* @return java.math.BigDecimal
|
540
|
540
|
*/
|
541
|
541
|
public static double getIntegerDivideAndMulitiply(Integer linecount, Integer studentnum){
|
542
|
|
- if (isEmptyInteger(studentnum)) {
|
|
542
|
+ if (isEmptyInteger(studentnum) || isEmptyInteger(linecount)) {
|
543
|
543
|
return 0;
|
544
|
544
|
}
|
545
|
545
|
BigDecimal b1 = new BigDecimal(linecount.toString());
|
|
@@ -552,7 +552,7 @@ public class N_Utils {
|
552
|
552
|
|
553
|
553
|
//两个数相除并乘以100.保留2位小数
|
554
|
554
|
public static double getDoubleDivideAndMulitiply(Double linecount, Double studentnum){
|
555
|
|
- if (studentnum.compareTo(new Double(0)) == 0) {
|
|
555
|
+ if (studentnum.compareTo(new Double(0)) == 0 || linecount == null) {
|
556
|
556
|
return 0;
|
557
|
557
|
}
|
558
|
558
|
BigDecimal b1 = new BigDecimal(linecount.toString());
|
|
@@ -565,7 +565,7 @@ public class N_Utils {
|
565
|
565
|
|
566
|
566
|
//两个数相除并乘以100.保留2位小数
|
567
|
567
|
public static double getDoubleDivideAndMulitiply(Double linecount, Integer studentnum){
|
568
|
|
- if (isEmptyInteger(studentnum)) {
|
|
568
|
+ if (isEmptyInteger(studentnum) || linecount == null) {
|
569
|
569
|
return 0;
|
570
|
570
|
}
|
571
|
571
|
BigDecimal b1 = new BigDecimal(linecount.toString());
|
|
@@ -578,7 +578,7 @@ public class N_Utils {
|
578
|
578
|
|
579
|
579
|
//计算比例向下取整
|
580
|
580
|
public static Integer floorDiv(Integer num,Integer totalNum) {
|
581
|
|
- if (isEmptyInteger(totalNum)) return 0;
|
|
581
|
+ if (isEmptyInteger(totalNum) || isEmptyInteger(num)) return 0;
|
582
|
582
|
return Math.floorDiv(num * 100, totalNum);
|
583
|
583
|
}
|
584
|
584
|
|
|
@@ -590,7 +590,7 @@ public class N_Utils {
|
590
|
590
|
* @return java.lang.Integer
|
591
|
591
|
**/
|
592
|
592
|
public static Integer formatProportion(Integer num,Integer totalNum){
|
593
|
|
- if (isEmptyInteger(totalNum)) return 0;
|
|
593
|
+ if (isEmptyInteger(totalNum) || isEmptyInteger(num)) return 0;
|
594
|
594
|
BigDecimal countBigDecimal = new BigDecimal(num);
|
595
|
595
|
BigDecimal totalCountBigDecimal = new BigDecimal(totalNum);
|
596
|
596
|
BigDecimal divide = countBigDecimal.divide(totalCountBigDecimal, 20, BigDecimal.ROUND_HALF_UP);
|
|
@@ -599,7 +599,7 @@ public class N_Utils {
|
599
|
599
|
}
|
600
|
600
|
|
601
|
601
|
public static Integer formatAvg(Integer num,Integer totalNum){
|
602
|
|
- if (isEmptyInteger(totalNum)) return 0;
|
|
602
|
+ if (isEmptyInteger(totalNum) || isEmptyInteger(num)) return 0;
|
603
|
603
|
BigDecimal countBigDecimal = new BigDecimal(num);
|
604
|
604
|
BigDecimal totalCountBigDecimal = new BigDecimal(totalNum);
|
605
|
605
|
BigDecimal divide = countBigDecimal.divide(totalCountBigDecimal, 0, BigDecimal.ROUND_UP);
|
|
@@ -613,7 +613,9 @@ public class N_Utils {
|
613
|
613
|
* @Date 2021/5/28 9:57
|
614
|
614
|
* @return java.lang.Double
|
615
|
615
|
**/
|
616
|
|
- public static Double formatDouble(Double num,Integer decimalNum){
|
|
616
|
+ public static Double formatDouble(Double num,Integer decimalNum) {
|
|
617
|
+ if (num == null) num = 0.0;
|
|
618
|
+ if (isEmptyInteger(decimalNum)) return num;
|
617
|
619
|
BigDecimal bg = new BigDecimal(num);
|
618
|
620
|
double num2 = bg.setScale(decimalNum, BigDecimal.ROUND_DOWN).doubleValue();
|
619
|
621
|
return num2;
|
|
@@ -965,7 +967,7 @@ public class N_Utils {
|
965
|
967
|
int r = a % b;
|
966
|
968
|
while(r != 0){
|
967
|
969
|
a = b;
|
968
|
|
- b = r;;
|
|
970
|
+ b = r;
|
969
|
971
|
r = a % b;
|
970
|
972
|
}
|
971
|
973
|
return b;
|