运算操作工具类
package com.ruoyi.quartz.util;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Random;
@Service
public class RoundUtil {
public int getRandomNumberInRange(int min, int max) {
Random r = new Random();
return r.nextInt((max - min) + 1) + min;
}
public double getRandomNumberDouble(int min, int max,boolean open,int count){
Random r = new Random();
double num = r.nextInt((max - min) + 1) + min + r.nextDouble();
if (open) return num;
BigDecimal b = new BigDecimal(num);
return b.setScale(count, BigDecimal.ROUND_HALF_UP).doubleValue();
}
public double roundNum(double num,int count){
BigDecimal b = new BigDecimal(num);
return b.setScale(count, BigDecimal.ROUND_HALF_UP).doubleValue();
}
public double makeRandom(double max,double min,int count){
BigDecimal cha = new BigDecimal(Math.random() * (max-min) + min);
return cha.setScale(count,BigDecimal.ROUND_HALF_UP).doubleValue();
}
public int roundIntByLength(int length){
Random random = new Random();
return random.nextInt(length);
}
public double transformationAccuracy(String doubleStr){
BigDecimal doublevalue = new BigDecimal(doubleStr);
return doublevalue.doubleValue();
}
}