|
@@ -21,6 +21,8 @@ import com.qmth.teachcloud.common.util.Zip4jUtil;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.maven.model.Model;
|
|
|
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -204,7 +206,7 @@ public class SystemConstant {
|
|
|
public static final String USER_DIR = "user.dir";
|
|
|
public static final String OS_NAME = "os.name";
|
|
|
public static final String TMP_DIR = "java.io.tmpdir";
|
|
|
-// public static final String PDF_TEMP = "pdf-temp";
|
|
|
+ // public static final String PDF_TEMP = "pdf-temp";
|
|
|
// public static final String FILE_TEMP = "file-temp";
|
|
|
public static final String TEMP = "temp";
|
|
|
public static final String SESSION = "session:";
|
|
@@ -1080,20 +1082,20 @@ public class SystemConstant {
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
- public static int calcBackupCount(Double backupCount, Integer studentCount, Integer defaultValue){
|
|
|
- if(defaultValue == null){
|
|
|
+ public static int calcBackupCount(Double backupCount, Integer studentCount, Integer defaultValue) {
|
|
|
+ if (defaultValue == null) {
|
|
|
defaultValue = DEFAULT_BACKUP_COUNT;
|
|
|
}
|
|
|
- if(backupCount == null || backupCount <= 0){
|
|
|
+ if (backupCount == null || backupCount <= 0) {
|
|
|
return defaultValue;
|
|
|
}
|
|
|
// <1按比例,>=1按数量
|
|
|
- if(backupCount < 1){
|
|
|
- if(studentCount == null || studentCount ==0){
|
|
|
+ if (backupCount < 1) {
|
|
|
+ if (studentCount == null || studentCount == 0) {
|
|
|
return defaultValue;
|
|
|
} else {
|
|
|
BigDecimal bigDecimal = new BigDecimal(studentCount).multiply(new BigDecimal(backupCount)).setScale(0, RoundingMode.CEILING);
|
|
|
- if(bigDecimal.intValue() == 0){
|
|
|
+ if (bigDecimal.intValue() == 0) {
|
|
|
return defaultValue;
|
|
|
} else {
|
|
|
return bigDecimal.intValue();
|
|
@@ -1123,4 +1125,24 @@ public class SystemConstant {
|
|
|
}
|
|
|
return file;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取版本号
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static String getVersion() {
|
|
|
+ String rootPath = System.getProperty(SystemConstant.USER_DIR);
|
|
|
+ MavenXpp3Reader reader = new MavenXpp3Reader();
|
|
|
+ String myPom = rootPath + File.separator + "pom.xml";
|
|
|
+ Model model = null;
|
|
|
+ String version = null;
|
|
|
+ try {
|
|
|
+ model = reader.read(new FileReader(myPom));
|
|
|
+ version = model.getVersion();
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
+ }
|
|
|
+ return version;
|
|
|
+ }
|
|
|
}
|