| | |
| | | import com.qxueyou.scc.exercise.model.ExerciseItemAnswerU; |
| | | |
| | | public class CommonUtils { |
| | | /** 一位小数 */ |
| | | /** 一位小数 */ |
| | | public static final String PARTEN_ONE = "#.#"; |
| | | /** 二位小数 */ |
| | | /** 二位小数 */ |
| | | public static final String PARTEN_TWO = "#.##"; |
| | | |
| | | //地球半径 |
| | | //地球半径 |
| | | private static final double EARTH_RADIUS = 6378.137; |
| | | |
| | | /** |
| | | * 答案显示图形颜色 自定义 |
| | | * 答案显示图形颜色 自定义 |
| | | * @return |
| | | */ |
| | | public static String[] getColors(){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 课程表显示图形颜色 自定义 |
| | | * 课程表显示图形颜色 自定义 |
| | | * @return |
| | | */ |
| | | public static String[] getRGBColors(){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 换算为2位小数 |
| | | * 换算为2位小数 |
| | | * @return |
| | | */ |
| | | public static String formatDecimalFormat(Object obj, String parten){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 删除字符最后的符号 |
| | | * 删除字符最后的符号 |
| | | * @return |
| | | */ |
| | | public static String removeStrLastComma(String string){ |
| | |
| | | } |
| | | |
| | | /** |
| | | * 转换答案值 0,1,2 |
| | | * 转换答案值 0,1,2 |
| | | * @param correct |
| | | * @return |
| | | */ |
| | |
| | | byte value; |
| | | |
| | | if("true".equals(correct)){ |
| | | value=ExerciseItemAnswerU.CORRECT_RIGHT;//正确 |
| | | value=ExerciseItemAnswerU.CORRECT_RIGHT;//正确 |
| | | }else if("false".equals(correct)){ |
| | | value=ExerciseItemAnswerU.CORRECT_ERROR;//错误 |
| | | value=ExerciseItemAnswerU.CORRECT_ERROR;//错误 |
| | | }else{ |
| | | value=7;//δ֪ |
| | | value=7;//未知 |
| | | } |
| | | |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * // 进行加法运算 |
| | | * // 进行加法运算 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * // 进行减法运算 |
| | | * // 进行减法运算 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * // 进行乘法运算 |
| | | * // 进行乘法运算 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * // 进行除法运算 四舍五入 |
| | | * // 进行除法运算 四舍五入 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | | */ |
| | | public static double divide(double d1,double d2,int len) {// 进行除法运算 |
| | | public static double divide(double d1,double d2,int len) {// 进行除法运算 |
| | | BigDecimal b1 = new BigDecimal(String.valueOf(d1)); |
| | | BigDecimal b2 = new BigDecimal(String.valueOf(d2)); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * // 进行除法运算 四舍五入 |
| | | * // 进行除法运算 四舍五入 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | | */ |
| | | public static double divide(String d1,String d2,int len) {// 进行除法运算 |
| | | public static double divide(String d1,String d2,int len) {// 进行除法运算 |
| | | BigDecimal b1 = new BigDecimal(d1); |
| | | BigDecimal b2 = new BigDecimal(d2); |
| | | |
| | |
| | | |
| | | |
| | | /** |
| | | * // 进行除法运算 四舍五入 |
| | | * // 进行除法运算 四舍五入 |
| | | * @param d1 |
| | | * @param d2 |
| | | * @return |
| | | */ |
| | | public static BigDecimal divide(BigDecimal b1,BigDecimal b2,int len) {// 进行除法运算 |
| | | public static BigDecimal divide(BigDecimal b1,BigDecimal b2,int len) {// 进行除法运算 |
| | | |
| | | return b1.divide(b2, new MathContext(len)); |
| | | } |
| | |
| | | } |
| | | /* |
| | | * |
| | | * 按指定长度截取源字符串,若源字符串不大于指定长度,则原样返回 |
| | | * 按指定长度截取源字符串,若源字符串不大于指定长度,则原样返回 |
| | | */ |
| | | public static String cutString(String res, Integer length, String suffix) { |
| | | if (StringUtils.isEmpty(res)) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 生成流水号 : module+时间戳 + 5位随机数,长度20位 |
| | | * 生成流水号 : module+时间戳 + 5位随机数,长度20位 |
| | | */ |
| | | public static String generateNo(String module){ |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 计算单位数字 |
| | | * 计算单位数字 |
| | | * |
| | | * @param number |
| | | * @return |
| | |
| | | return "0"; |
| | | } |
| | | |
| | | if(number.compareTo(new BigInteger("10000")) < 0){// 小于1万 |
| | | if(number.compareTo(new BigInteger("10000")) < 0){// 小于1万 |
| | | return String.valueOf(number); |
| | | } |
| | | |
| | | if(number.compareTo(new BigInteger("10000")) >= 0 |
| | | && number.compareTo(new BigInteger("100000000")) < 0){// 大于1万 小于一亿 前进1位为1.2万 |
| | | && number.compareTo(new BigInteger("100000000")) < 0){// 大于1万 小于一亿 前进1位为1.2万 |
| | | |
| | | return Math.ceil(number.doubleValue()/1000)/10 + "万"; |
| | | return Math.ceil(number.doubleValue()/1000)/10 + "万"; |
| | | |
| | | } |
| | | |
| | | if(number.compareTo(new BigInteger("100000000")) >= 0){// 大于一亿 前进1位为1.2亿 |
| | | if(number.compareTo(new BigInteger("100000000")) >= 0){// 大于一亿 前进1位为1.2亿 |
| | | |
| | | return Math.ceil(number.doubleValue()/1000000)/10 + "亿"; |
| | | return Math.ceil(number.doubleValue()/1000000)/10 + "亿"; |
| | | } |
| | | |
| | | return "0"; |
| | | } |
| | | |
| | | /** |
| | | * 格式化文本 |
| | | * 格式化文本 |
| | | * @param str |
| | | * @return |
| | | */ |
| | |
| | | return d * Math.PI / 180.0; |
| | | } |
| | | |
| | | //获取两个坐标距离 |
| | | //获取两个坐标距离 |
| | | public static double GetDistance(double long1, double lat1, double long2, double lat2) { |
| | | double a, b, d, sa2, sb2; |
| | | double latA = rad(lat1); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 银行卡验证 |
| | | * 银行卡验证 |
| | | * |
| | | * @param cardNo |
| | | * @return |
| | |
| | | } |
| | | |
| | | /** |
| | | * ftl-返回错误信息页面 |
| | | * ftl-返回错误信息页面 |
| | | * @param mv |
| | | * @param msg |
| | | * @return |
| | |
| | | return mv; |
| | | } |
| | | |
| | | /** 得到classId*/ |
| | | /** 得到classId*/ |
| | | public static String getClassId(String classId){ |
| | | return StringUtils.isEmpty(classId)?(StringUtils.isEmpty(ClientUtils.getClassId())?StringUtils.EMPTY:ClientUtils.getClassId()):classId; |
| | | } |