diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index b26911b..af673e7 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -2,5 +2,7 @@
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml
deleted file mode 100644
index d411041..0000000
--- a/.idea/libraries/Maven__junit_junit_4_12.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/libraries/Maven__junit_junit_4_13_2.xml b/.idea/libraries/Maven__junit_junit_4_13_2.xml
new file mode 100644
index 0000000..606c352
--- /dev/null
+++ b/.idea/libraries/Maven__junit_junit_4_13_2.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6157b54..8ff9c29 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,54 +4,201 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
- {
- "associatedIndex": 8
-}
-
+
@@ -281,23 +429,17 @@
- {
- "keyToString": {
- "JUnit.ParamUtilsTest.test2.executor": "Run",
- "RunOnceActivity.OpenProjectViewOnStart": "true",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "git-widget-placeholder": "zxr",
- "kotlin-language-version-configured": "true",
- "last_opened_file_path": "D:/git/project/UserActionAnalyzePlatform",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "reference.settings.project.maven.repository.indices",
- "vue.rearranger.settings.migration": "true"
- }
-}
+
+
+
+
+
+
+
+
+
+
+
@@ -308,7 +450,7 @@
-
+
@@ -316,12 +458,6 @@
-
-
-
-
-
-
@@ -342,6 +478,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -426,30 +573,33 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
@@ -469,19 +619,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
1529592741848
@@ -497,175 +635,28 @@
1529593229553
-
-
- 1734351693404
+
+ 1734352510160
- 1734351693404
+ 1734352510160
-
-
- 1734352975106
+
+ 1734357362481
- 1734352975106
+ 1734357362481
-
-
- 1734353193141
+
+ 1734361788229
- 1734353193141
-
-
-
- 1734353269426
-
-
-
- 1734353269426
-
-
-
- 1734354775314
-
-
-
- 1734354775314
-
-
-
- 1734354900465
-
-
-
- 1734354900465
+ 1734361788229
-
-
- 1734354969705
-
-
-
- 1734354969705
-
-
-
- 1734357525655
-
-
-
- 1734357525655
-
-
-
- 1734358371283
-
-
-
- 1734358371283
-
-
-
- 1734360173676
-
-
-
- 1734360173676
-
-
-
- 1734362412393
-
-
-
- 1734362412393
-
-
-
- 1734363163041
-
-
-
- 1734363163041
-
-
-
- 1734363388179
-
-
-
- 1734363388179
-
-
-
- 1734365844392
-
-
-
- 1734365844392
-
-
-
- 1734368636062
-
-
-
- 1734368636062
-
-
-
- 1734369061766
-
-
-
- 1734369061766
-
-
-
- 1734369482371
-
-
-
- 1734369482371
-
-
-
- 1734370121454
-
-
-
- 1734370121454
-
-
-
- 1734370179773
-
-
-
- 1734370179773
-
-
-
- 1734370518519
-
-
-
- 1734370518519
-
-
-
- 1734370728253
-
-
-
- 1734370728253
-
-
+
@@ -780,20 +771,14 @@
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
diff --git a/UserActionAnalyzePlatform.iml b/UserActionAnalyzePlatform.iml
index 6e9857d..65c4040 100644
--- a/UserActionAnalyzePlatform.iml
+++ b/UserActionAnalyzePlatform.iml
@@ -8,6 +8,8 @@
+
+
@@ -186,7 +188,7 @@
-
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9b55150..e10085e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -79,6 +79,12 @@
4.12
test
+
+ junit
+ junit
+ RELEASE
+ test
+
diff --git a/src/main/java/cn/edu/hust/conf/ConfigurationManager.java b/src/main/java/cn/edu/hust/conf/ConfigurationManager.java
index dbae85b..6f09f9d 100644
--- a/src/main/java/cn/edu/hust/conf/ConfigurationManager.java
+++ b/src/main/java/cn/edu/hust/conf/ConfigurationManager.java
@@ -1,75 +1,83 @@
-package cn.edu.hust.conf;
-
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * 配置文件管理类
- * 主要的功能:从特定的properties文件中读取相应的key/value
- */
-public class ConfigurationManager {
- private static Properties prop=new Properties();
-
- /**
- * 通过静态代码块加载配置文件
- */
- static{
- try
- {
- //通过类的加载器读取配置文件
- InputStream is=ConfigurationManager.class.getClassLoader().getResourceAsStream("conf.properties");
- //加载配置文件
- prop.load(is);
- }catch(Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- * 通过指定的key获取value
- * @param key
- * @return
- */
- public static String getProperty(String key)
- {
- return prop.getProperty(key);
- }
-
- /**
- * 获取整数变量
- * @param key
- * @return
- */
- public static Integer getInteger(String key)
- {
- String value=getProperty(key);
- try
- {
- Integer result=Integer.valueOf(value);
- return result;
- }
- catch (Exception e)
- {
-
- e.printStackTrace();
- }
- return 0;
- }
-
- /**
- * 获取布尔型
- * @param key
- * @return
- */
- public static Boolean getBoolean(String key)
- {
- String value=getProperty(key);
- if("false".equals(value))
- {
- return false;
- }
- return true;
- }
-
-}
+package cn.edu.hust.conf;//包
+//
+import java.io.InputStream;//申明
+//
+import java.util.Properties;//申明
+//
+//
+ //配置文件管理类
+ //主要的功能:从特定的properties文件中读取相应的key/value
+ //
+public class ConfigurationManager { //
+ // 创建一个静态的Properties对象,用于存储从配置文件中读取的配置信息
+ private static Properties prop = new Properties();// 创建一个静态的Properties对象,用于存储从配置文件中读取的配置信息
+//
+ //
+ // 通过静态代码块加载配置文件
+ //
+ static { //ha
+ try { //dd
+ // 通过类的加载器读取名为"conf.properties"的配置文件
+ InputStream is = ConfigurationManager.class.getClassLoader().getResourceAsStream("conf.properties");//加载
+ // 加载配置文件到Properties对象中
+ prop.load(is);//加载
+ } catch (Exception e)//kuaizai
+ // 捕获加载文件时的异常并打印错误堆栈信息
+ e.printStackTrace();//kuaizai
+ }//对象
+ } //
+//编写过程
+ //编写过程
+ //
+ //通过指定的key获取value
+ // @param key 配置项的key
+ //@return 返回与key对应的value,如果没有则返回null
+ //
+ public static String getProperty(String key) { //
+ // 使用Properties对象的getProperty方法获取指定key的值
+ return prop.getProperty(key); //
+ } //
+//
+ //
+ // 获取整数变量
+ // @param key 配置项的key
+ // @return 返回与key对应的整数值,如果转换失败则返回默认值0
+ //
+ public static Integer getInteger(String key) { //加载
+ // 获取key对应的字符串值
+ String value = getProperty(key);//
+ //
+ try { //
+ // 尝试将字符串值转换为整数
+ Integer result = Integer.valueOf(value);//
+ //
+ return result; //输出结果
+ //
+ } catch (Exception e) { //catch
+ // 捕获转换时的异常并打印错误堆栈信息
+ e.printStackTrace(); //e
+ //
+ }//
+ // 如果转换失败,返回默认值0
+ return 0; //返回值
+ } //
+//
+ //
+ //获取布尔型
+ // @param key 配置项的key
+ // @return 返回与key对应的布尔值,如果值为"false"则返回false,其他情况返回true
+ //
+ public static Boolean getBoolean(String key) { //
+ // 获取key对应的字符串值
+ String value = getProperty(key); //string
+ // 如果值为"false"(不区分大小写),则返回false
+ if ("false".equals(value)) { //错误
+ //返回值
+ return false; //返回错误结果
+ } //
+ // 默认返回true
+ return true; //返回正确
+ }//
+ //
+}//
+//完成
\ No newline at end of file
diff --git a/src/main/java/cn/edu/hust/constant/Constants.java b/src/main/java/cn/edu/hust/constant/Constants.java
index 4ad5a94..ead3d2b 100644
--- a/src/main/java/cn/edu/hust/constant/Constants.java
+++ b/src/main/java/cn/edu/hust/constant/Constants.java
@@ -1,64 +1,128 @@
-package cn.edu.hust.constant;
-
-public class Constants {
- /**
- * 项目配置常量
- */
- public static final String JDBC_DRIVER="jdbc.driver";
- public static final String JDBC_URL="jdbc.url";
- public static final String JDBC_USERNAME="jdbc.username";
- public static final String JDBC_PSSWORD="jdbc.password";
- public static final String JDBC_ACTIVE="jdbc.active";
-
- /**
- * Spark作业相关常量
- */
- public static final String APP_NAME_SESSION="UserVisitAnalyze";
- public static final String SPARK_LOCAL="spark_local";
- public static final String FIELD_SESSIONID="sessionId";
- public static final String FIELD_SERACH_KEYWORDS="searchKeywords";
- public static final String FIELD_CLICK_CATEGORYIDS="clickCategoryIds";
- public static final String FIELD_AGE="age";
- public static final String FIELD_CITY="city";
- public static final String FIELD_SEX="sex";
- public static final String FIELD_PROFESSIONAL="professional";
- public static final String FIELD_VISIT_LENGTH="visitLength";
- public static final String FIELD_STEP_LENGTH="stepLength";
- public static final String FIELD_START_TIME="startTime";
- public static final String FIELD_CATEGORY_ID="categoryId";
- public static final String FIELD_CLICK_CATEGORY="categoryId";
- public static final String FIELD_ORDER_CATEGORY="clickCategory";
- public static final String FIELD_PAY_CATEGORY="orderCategory";
-
- /**
- * Spark任务相关厂常量
- */
- public static final String PARAM_STARTTIME ="startDate";
- public static final String PARAM_ENDTIME ="endDate";
- public static final String PARAM_STARTAGE ="startAge";
- public static final String PARAM_ENDAGE ="endAge";
- public static final String PARAM_PROFESSONALS ="professionals";
- public static final String PARAM_CIYTIES ="cities";
- public static final String PARAM_SEX ="sex";
- public static final String PARAM_SERACH_KEYWORDS="searchKeywords";
- public static final String PARAM_CLICK_CATEGORYIDS="clickCategoryIds";
-
- public static final String SESSION_COUNT = "session_count";
- public static final String TIME_PERIOD_1s_3s = "1s_3s";
- public static final String TIME_PERIOD_4s_6s = "4s_6s";
- public static final String TIME_PERIOD_7s_9s = "7s_9s";
- public static final String TIME_PERIOD_10s_30s = "10s_30s";
- public static final String TIME_PERIOD_30s_60s = "30s_60s";
- public static final String TIME_PERIOD_1m_3m = "1m_3m";
- public static final String TIME_PERIOD_3m_10m = "3m_10m";
- public static final String TIME_PERIOD_10m_30m = "10m_30m";
- public static final String TIME_PERIOD_30m = "30m";
-
- public static final String STEP_PERIOD_1_3 = "1_3";
- public static final String STEP_PERIOD_4_6 = "4_6";
- public static final String STEP_PERIOD_7_9 = "7_9";
- public static final String STEP_PERIOD_10_30 = "10_30";
- public static final String STEP_PERIOD_30_60 = "30_60";
- public static final String STEP_PERIOD_60 = "60";
-
-}
+//开始
+package cn.edu.hust.constant;//申明
+//
+public class Constants { //
+//
+ //
+ // 项目配置常量
+ //这些常量用于存储数据库连接的配置信息
+ //
+ public static final String JDBC_DRIVER="jdbc.driver"; // JDBC驱动类
+ //
+ public static final String JDBC_URL="jdbc.url"; // 数据库连接URL
+ //
+ public static final String JDBC_USERNAME="jdbc.username"; // 数据库用户名
+ //
+ public static final String JDBC_PSSWORD="jdbc.password"; // 数据库密码
+ //
+ public static final String JDBC_ACTIVE="jdbc.active"; // 数据库连接是否活跃
+ //
+//
+ //
+ //Spark作业相关常量
+ // 这些常量用于存储Spark作业相关的配置信息、字段名等
+ //
+ public static final String APP_NAME_SESSION="UserVisitAnalyze"; // Spark应用名称,用于标识作业
+ //
+ public static final String SPARK_LOCAL="spark_local"; // Spark本地模式的配置标识
+ //
+ public static final String FIELD_SESSIONID="sessionId"; // 用户会话ID字段名
+ //
+ public static final String FIELD_SERACH_KEYWORDS="searchKeywords"; // 搜索关键词字段名
+ //
+ public static final String FIELD_CLICK_CATEGORYIDS="clickCategoryIds"; // 点击的分类ID字段名
+ //
+ public static final String FIELD_AGE="age"; // 用户年龄字段名
+ //
+ public static final String FIELD_CITY="city"; // 用户所在城市字段名
+ //
+ public static final String FIELD_SEX="sex"; // 用户性别字段名
+ //
+ public static final String FIELD_PROFESSIONAL="professional"; // 用户职业字段名
+ //
+ public static final String FIELD_VISIT_LENGTH="visitLength"; // 访问时长字段名
+ //
+ public static final String FIELD_STEP_LENGTH="stepLength"; // 访问步长字段名
+ //
+ public static final String FIELD_START_TIME="startTime"; // 会话开始时间字段名
+ //
+ public static final String FIELD_CATEGORY_ID="categoryId"; // 分类ID字段名
+ //
+ public static final String FIELD_CLICK_CATEGORY="categoryId"; // 点击的分类字段名
+ //
+ public static final String FIELD_ORDER_CATEGORY="clickCategory"; // 订单分类字段名
+ //
+ public static final String FIELD_PAY_CATEGORY="orderCategory"; // 支付分类字段名
+//
+ //
+ // Spark任务相关参数常量
+ // 这些常量用于存储Spark任务中的参数名称
+ //
+ public static final String PARAM_STARTTIME ="startDate"; // 起始日期参数
+ //
+ public static final String PARAM_ENDTIME ="endDate"; // 结束日期参数
+ //
+ public static final String PARAM_STARTAGE ="startAge"; // 起始年龄参数
+ //
+ public static final String PARAM_ENDAGE ="endAge"; // 结束年龄参数
+ //
+ public static final String PARAM_PROFESSONALS ="professionals"; // 专业参数
+ //
+ public static final String PARAM_CIYTIES ="cities"; // 城市参数
+ //
+ public static final String PARAM_SEX ="sex"; // 性别参数
+ //
+ public static final String PARAM_SERACH_KEYWORDS="searchKeywords"; // 搜索关键词参数
+ //
+ public static final String PARAM_CLICK_CATEGORYIDS="clickCategoryIds"; // 点击的分类ID参数
+ //
+//
+ //
+ // 会话统计相关常量
+ //用于会话时长或访问步数的统计分类
+ //
+ public static final String SESSION_COUNT = "session_count"; // 会话统计
+ //
+//
+ //
+ // 用户访问时长时间段常量
+ //用于标识用户访问时长的各个时间段
+ //
+ public static final String TIME_PERIOD_1s_3s = "1s_3s"; // 1秒到3秒的时长
+ //
+ public static final String TIME_PERIOD_4s_6s = "4s_6s"; // 4秒到6秒的时长
+ //
+ public static final String TIME_PERIOD_7s_9s = "7s_9s"; // 7秒到9秒的时长
+ //
+ public static final String TIME_PERIOD_10s_30s = "10s_30s"; // 10秒到30秒的时长
+ //
+ public static final String TIME_PERIOD_30s_60s = "30s_60s"; // 30秒到60秒的时长
+ //
+ public static final String TIME_PERIOD_1m_3m = "1m_3m"; // 1分钟到3分钟的时长
+ //
+ public static final String TIME_PERIOD_3m_10m = "3m_10m"; // 3分钟到10分钟的时长
+ //
+ public static final String TIME_PERIOD_10m_30m = "10m_30m"; // 10分钟到30分钟的时长
+ //
+ public static final String TIME_PERIOD_30m = "30m"; // 超过30分钟的时长
+ //
+//
+ //
+ // 用户访问步数时间段常量
+ //用于标识用户的访问步数区间
+ //
+ public static final String STEP_PERIOD_1_3 = "1_3"; // 1步到3步的访问
+ //
+ public static final String STEP_PERIOD_4_6 = "4_6"; // 4步到6步的访问
+ //
+ public static final String STEP_PERIOD_7_9 = "7_9"; // 7步到9步的访问
+ //
+ public static final String STEP_PERIOD_10_30 = "10_30"; // 10步到30步的访问
+ //
+ public static final String STEP_PERIOD_30_60 = "30_60"; // 30步到60步的访问
+ //
+ public static final String STEP_PERIOD_60 = "60"; // 超过60步的访问
+ //
+//
+}//返回
+//完成
diff --git a/src/main/java/cn/edu/hust/util/DateUtils.java b/src/main/java/cn/edu/hust/util/DateUtils.java
index 7883fdf..6a8496d 100644
--- a/src/main/java/cn/edu/hust/util/DateUtils.java
+++ b/src/main/java/cn/edu/hust/util/DateUtils.java
@@ -1,150 +1,226 @@
-package cn.edu.hust.util;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
+//开始
+package cn.edu.hust.util;//申明
+//
+import java.text.ParseException;//申明
+import java.text.SimpleDateFormat;//申明
+import java.util.Calendar;//申明
+import java.util.Date;//申明
+//
/**
* 日期时间工具类
- * @author Administrator
+ * 提供了多个静态方法来处理日期和时间的相关操作
+ * @author Administrator111222
*
*/
-public class DateUtils {
-
- public static final SimpleDateFormat TIME_FORMAT =
+public class DateUtils {//申明
+//
+ // 时间格式化:年月日 时分秒
+ public static final SimpleDateFormat TIME_FORMAT =
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- public static final SimpleDateFormat DATE_FORMAT =
+ //
+ // 日期格式化:年月日
+ public static final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat("yyyy-MM-dd");
- public static ThreadLocal simpleDateFormatThreadLocal=new ThreadLocal(){
- @Override
+//
+ // ThreadLocal 用于线程安全地存储 SimpleDateFormat 实例
+ public static ThreadLocal simpleDateFormatThreadLocal = new ThreadLocal(){
+ //
+ @Override//
+ //
protected SimpleDateFormat initialValue() {
+ // 初始化 SimpleDateFormat 实例,格式为 yyyy-MM-dd HH:mm:ss
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- }
- };
-
+ //
+ }//
+ //
+ };//
+ //
+//
/**
* 判断一个时间是否在另一个时间之前
* @param time1 第一个时间
* @param time2 第二个时间
- * @return 判断结果
+ * @return 判断结果:如果 time1 在 time2 之前,返回 true,否则返回 false
*/
- public static boolean before(String time1, String time2) {
- try {
- Date dateTime1 = TIME_FORMAT.parse(time1);
- Date dateTime2 = TIME_FORMAT.parse(time2);
-
- if(dateTime1.before(dateTime2)) {
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
- }
-
+ public static boolean before(String time1, String time2) {//申明
+ //
+ try {//申明
+ // 解析时间字符串为 Date 对象
+ Date dateTime1 = TIME_FORMAT.parse(time1);//解析字符串
+ //
+ Date dateTime2 = TIME_FORMAT.parse(time2);//解析字符串
+//
+ // 判断 dateTime1 是否在 dateTime2 之前
+ if(dateTime1.before(dateTime2)) {//
+ //
+ return true;//返回正确
+ }//
+ } catch (Exception e) {//
+ //
+ e.printStackTrace(); // 捕获异常并打印堆栈信息
+ }//
+ //
+ return false; // 如果发生异常或判断结果不为 true,返回 false
+ }//
+//
+ //
/**
* 判断一个时间是否在另一个时间之后
* @param time1 第一个时间
* @param time2 第二个时间
- * @return 判断结果
+ * @return 判断结果:如果 time1 在 time2 之后,返回 true,否则返回 false
*/
- public static boolean after(String time1, String time2) {
+ public static boolean after(String time1, String time2) {//
try {
- Date dateTime1 = TIME_FORMAT.parse(time1);
- Date dateTime2 = TIME_FORMAT.parse(time2);
-
- if(dateTime1.after(dateTime2)) {
- return true;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return false;
+ //
+ // 解析时间字符串为 Date 对象
+ Date dateTime1 = TIME_FORMAT.parse(time1);//解析字符串
+ //
+ Date dateTime2 = TIME_FORMAT.parse(time2);//解析字符串
+ //
+//
+ // 判断 dateTime1 是否在 dateTime2 之后
+ if(dateTime1.after(dateTime2)) {//
+ //
+ return true;//返回正确
+ //
+ }//
+ //
+ } catch (Exception e) {//
+ //
+ e.printStackTrace(); // 捕获异常并打印堆栈信息
+ }//
+ //
+ return false; // 如果发生异常或判断结果不为 true,返回 false
}
-
+
/**
* 计算时间差值(单位为秒)
* @param time1 时间1
* @param time2 时间2
- * @return 差值
+ * @return 时间差值,单位为秒
*/
- public static int minus(String time1, String time2) {
+ public static int minus(String time1, String time2) {//
+ //
try {
- Date datetime1 = TIME_FORMAT.parse(time1);
- Date datetime2 = TIME_FORMAT.parse(time2);
-
- long millisecond = datetime1.getTime() - datetime2.getTime();
-
- return Integer.valueOf(String.valueOf(millisecond / 1000));
- } catch (Exception e) {
- e.printStackTrace();
+ // 解析时间字符串为 Date 对象
+ Date datetime1 = TIME_FORMAT.parse(time1);// 解析时间字符串
+ //
+ Date datetime2 = TIME_FORMAT.parse(time2);// 解析时间字符串
+ //
+//
+ // 计算时间差,单位为毫秒
+ long millisecond = datetime1.getTime() - datetime2.getTime();//计算时间差,单位为毫秒
+//
+ // 转换为秒,并返回
+ return Integer.valueOf(String.valueOf(millisecond / 1000));//
+ //
+ } catch (Exception e) {//
+ //
+ e.printStackTrace(); // 捕获异常并打印堆栈信息
+ //
}
- return 0;
+ return 0; // 如果发生异常,返回 0
+ //
}
-
+
/**
- * 获取年月日和小时
- * @param datetime 时间(yyyy-MM-dd HH:mm:ss)
- * @return 结果
+ * 获取年月日和小时(如:yyyy-MM-dd_HH)
+ * @param datetime 时间(格式:yyyy-MM-dd HH:mm:ss)
+ * @return 格式化后的结果,形如 yyyy-MM-dd_HH
*/
- public static String getDateHour(String datetime) {
- String date = datetime.split(" ")[0];
- String hourMinuteSecond = datetime.split(" ")[1];
- String hour = hourMinuteSecond.split(":")[0];
- return date + "_" + hour;
- }
-
+ public static String getDateHour(String datetime) {//
+ // 获取日期部分:yyyy-MM-dd
+ String date = datetime.split(" ")[0];//
+ // 获取时间部分:HH:mm:ss
+ String hourMinuteSecond = datetime.split(" ")[1];//
+ // 获取小时部分
+ String hour = hourMinuteSecond.split(":")[0];//
+ // 返回格式化后的日期和小时
+ return date + "_" + hour;//
+ //
+ }
+//
/**
* 获取当天日期(yyyy-MM-dd)
- * @return 当天日期
+ * @return 当前日期,格式为 yyyy-MM-dd
*/
- public static String getTodayDate() {
- return DATE_FORMAT.format(new Date());
- }
-
+ public static String getTodayDate() {//
+ //
+ // 获取当前日期并格式化
+ return DATE_FORMAT.format(new Date());//
+ //
+ }//
+//
/**
* 获取昨天的日期(yyyy-MM-dd)
- * @return 昨天的日期
+ * @return 昨天的日期,格式为 yyyy-MM-dd
*/
- public static String getYesterdayDate() {
- Calendar cal = Calendar.getInstance();
- cal.setTime(new Date());
- cal.add(Calendar.DAY_OF_YEAR, -1);
-
- Date date = cal.getTime();
-
- return DATE_FORMAT.format(date);
- }
-
+ public static String getYesterdayDate() {/
+ //
+ // 获取当前时间的 Calendar 实例
+ Calendar cal = Calendar.getInstance();//
+ //
+ // 设置当前时间
+ cal.setTime(new Date());//
+ //
+ // 当前日期减去一天
+ cal.add(Calendar.DAY_OF_YEAR, -1);//
+ //
+//
+ // 获取昨天的日期
+ Date date = cal.getTime();//
+//
+ // 格式化并返回昨天的日期
+ return DATE_FORMAT.format(date);//
+ }//
+//
/**
* 格式化日期(yyyy-MM-dd)
* @param date Date对象
- * @return 格式化后的日期
+ * @return 格式化后的日期字符串
*/
- public static String formatDate(Date date) {
- return DATE_FORMAT.format(date);
+ public static String formatDate(Date date) {//
+ //
+ // 使用日期格式化器格式化 Date 对象
+ return DATE_FORMAT.format(date);//
+ //
}
-
+
/**
* 格式化时间(yyyy-MM-dd HH:mm:ss)
* @param date Date对象
- * @return 格式化后的时间
+ * @return 格式化后的时间字符串
*/
- public static String formatTime(Date date) {
- return TIME_FORMAT.format(date);
- }
-
- public static Date parseTime(String time)
- {
- try {
- Date result=simpleDateFormatThreadLocal.get().parse(time);
- simpleDateFormatThreadLocal.remove();
- return result;
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return null;
- }
-
-}
+ public static String formatTime(Date date) {//
+ // 使用时间格式化器格式化 Date 对象
+ return TIME_FORMAT.format(date);//
+ //
+ }//
+//
+ /**
+ * 将时间字符串解析为 Date 对象
+ * @param time 时间字符串,格式为 yyyy-MM-dd HH:mm:ss
+ * @return 解析后的 Date 对象
+ */
+ public static Date parseTime(String time) {//
+ //
+ try {//
+ // 使用 ThreadLocal 提供的 SimpleDateFormat 解析时间字符串
+ //
+ Date result = simpleDateFormatThreadLocal.get().parse(time);//
+ //
+ // 移除 ThreadLocal 中的 SimpleDateFormat 实例
+ simpleDateFormatThreadLocal.remove();//
+ //
+ return result; // 返回解析后的 Date 对象
+ //
+ } catch (ParseException e) {//
+ //
+ e.printStackTrace(); // 捕获异常并打印堆栈信息
+ }//
+ return null; // 如果解析失败,返回 null
+ }//
+//
+}//
+//
\ No newline at end of file
diff --git a/src/main/java/cn/edu/hust/util/NumberUtils.java b/src/main/java/cn/edu/hust/util/NumberUtils.java
index 14a5341..cee15ef 100644
--- a/src/main/java/cn/edu/hust/util/NumberUtils.java
+++ b/src/main/java/cn/edu/hust/util/NumberUtils.java
@@ -1,23 +1,32 @@
-package cn.edu.hust.util;
-
-import java.math.BigDecimal;
-
+//start
+package cn.edu.hust.util; // 引入包,指定该类所在的包
+//引入包,指定该类所在的包
+import java.math.BigDecimal; // 导入 BigDecimal 类,用于高精度的浮点数运算
+//引入包,指定该类所在的包
+//s
/**
* 数字格工具类
* @author Administrator
- *
+ * 该类提供了一个静态方法用于格式化小数
*/
-public class NumberUtils {
-
+public class NumberUtils {//
+ //s
+ //ss
+ //sss
+//
/**
* 格式化小数
- * @param num 数字
- * @param scale 四舍五入的位数
- * @return 格式化小数
+ * @param num 数字 需要格式化的数字
+ * @param scale 四舍五入的位数 保留的小数位数
+ * @return 格式化小数 返回四舍五入后的数字
*/
- public static double formatDouble(double num, int scale) {
- BigDecimal bd = new BigDecimal(num);
- return bd.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
- }
-
-}
+ public static double formatDouble(double num, int scale) {//shengming
+ //kellly
+ BigDecimal bd = new BigDecimal(num); // 将输入的数字转换为 BigDecimal 对象,以提高计算精度
+ //将输入的数字转换为 BigDecimal 对象,以提高计算精度
+ return bd.setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue(); // 设置四舍五入的精度并返回对应的 double 值
+ //设置四舍五入的精度并返回对应的 double 值
+ }//
+//
+}//
+//结束
\ No newline at end of file
diff --git a/src/main/java/cn/edu/hust/util/ParamUtils.java b/src/main/java/cn/edu/hust/util/ParamUtils.java
index 77cddc2..47eba11 100644
--- a/src/main/java/cn/edu/hust/util/ParamUtils.java
+++ b/src/main/java/cn/edu/hust/util/ParamUtils.java
@@ -1,42 +1,60 @@
-package cn.edu.hust.util;
-
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-
+package cn.edu.hust.util; // 定义类所在的包名,方便包管理和组织
+//
+import com.alibaba.fastjson.JSONArray; // 引入 fastjson 库中的 JSONArray 类,用于处理 JSON 数组
+// 引入 fastjson 库中的 JSONArray 类用于处理 JSON 数组
+import com.alibaba.fastjson.JSONObject; // 引入 fastjson 库中的 JSONObject 类,用于处理 JSON 对象
+// 引入 fastjson 库中的 JSONObject 类用于处理 JSON 对象
+//
/**
* 参数工具类
+ * 该类提供了从命令行参数或 JSON 对象中提取参数的方法
* @author Administrator
*
*/
-public class ParamUtils {
-
+public class ParamUtils {//
+//
/**
* 从命令行参数中提取任务id
- * @param args 命令行参数
- * @return 任务id
+ * @param args 命令行参数,通常是启动程序时传递的参数
+ * @return 返回任务ID,如果没有找到返回 null
*/
- public static Long getTaskIdFromArgs(String[] args) {
- try {
- if(args != null && args.length > 0) {
- return Long.valueOf(args[0]);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
+ public static Long getTaskIdFromArgs(String[] args) { // 定义静态方法,接受命令行参数数组 args
+ //
+ try { // 尝试执行以下代码
+ //尝试
+ if(args != null && args.length > 0) { // 如果参数数组不为空且长度大于0
+ //
+ return Long.valueOf(args[0]); // 将第一个参数转化为 Long 类型并返回
+ //
+ }//
+ } catch (Exception e) { // 捕获任何异常
+ //
+ e.printStackTrace(); // 打印堆栈信息,便于调试
+ //
+ }//
+ return null; // 如果未能提取到有效的任务 ID,则返回 null
+ //
}
-
+//
/**
- * 从JSON对象中提取参数
- * @param jsonObject JSON对象
- * @return 参数
+ * 从 JSON 对象中提取指定字段的第一个值
+ * @param jsonObject JSON 对象,包含了需要提取的字段数据
+ * @param field 字段名,表示要从 JSON 对象中提取的字段
+ * @return 返回字段对应的第一个值,如果字段不存在或者值为空返回 null
*/
- public static String getParam(JSONObject jsonObject, String field) {
- JSONArray jsonArray = jsonObject.getJSONArray(field);
- if(jsonArray != null && jsonArray.size() > 0) {
- return jsonArray.getString(0);
- }
- return null;
- }
-
-}
+ public static String getParam(JSONObject jsonObject, String field) { // 定义静态方法,接受一个 JSON 对象和一个字段名
+ //
+ JSONArray jsonArray = jsonObject.getJSONArray(field); // 从 JSON 对象中获取指定字段的 JSON 数组
+ //
+ if(jsonArray != null && jsonArray.size() > 0) { // 如果该字段存在且 JSON 数组非空
+ //
+ return jsonArray.getString(0); // 返回 JSON 数组的第一个字符串值
+ //
+ }//测试完成
+ //
+ return null; // 如果字段不存在或数组为空,返回 null
+ //
+ }//
+//
+}//
+//结束
diff --git a/src/main/java/cn/edu/hust/util/StringUtils.java b/src/main/java/cn/edu/hust/util/StringUtils.java
index 0919d52..5d82007 100644
--- a/src/main/java/cn/edu/hust/util/StringUtils.java
+++ b/src/main/java/cn/edu/hust/util/StringUtils.java
@@ -1,110 +1,152 @@
-package cn.edu.hust.util;
-
+//start
+package cn.edu.hust.util; // 定义类所在的包名,便于组织和管理代码
+//
/**
* 字符串工具类
+ * 提供了一些常见的字符串操作方法
* @author Administrator
*
*/
-public class StringUtils {
-
+public class StringUtils {//尝试编写
+//
/**
* 判断字符串是否为空
* @param str 字符串
- * @return 是否为空
+ * @return 如果字符串为空或为 null,返回 true;否则返回 false
*/
- public static boolean isEmpty(String str) {
- return str == null || "".equals(str);
- }
-
+ public static boolean isEmpty(String str) {//
+ //申明
+ return str == null || "".equals(str); // 如果字符串为 null 或者是空字符串,返回 true
+ //
+ }//
+//
/**
* 判断字符串是否不为空
* @param str 字符串
- * @return 是否不为空
+ * @return 如果字符串不为空且不为 null,返回 true;否则返回 false
*/
- public static boolean isNotEmpty(String str) {
- return str != null && !"".equals(str);
- }
-
+ public static boolean isNotEmpty(String str) {//
+ //
+ return str != null && !"".equals(str); // 如果字符串非空且非 null,返回 true
+ }//
+//
/**
* 截断字符串两侧的逗号
* @param str 字符串
- * @return 字符串
+ * @return 去掉两侧逗号后的字符串
*/
- public static String trimComma(String str) {
- if(str.startsWith(",")) {
- str = str.substring(1);
- }
- if(str.endsWith(",")) {
- str = str.substring(0, str.length() - 1);
- }
- return str;
- }
-
+ public static String trimComma(String str) {//
+ //
+ if(str.startsWith(",")) { // 如果字符串以逗号开始
+ //
+ str = str.substring(1); // 去掉开头的逗号
+ }//
+ if(str.endsWith(",")) { // 如果字符串以逗号结束
+ //
+ str = str.substring(0, str.length() - 1); // 去掉结尾的逗号
+ }//
+ //
+ return str; // 返回处理后的字符串
+ }//
+//
/**
- * 补全两位数字
- * @param str
- * @return
+ * 补全两位数字(如果输入是单个数字,前面加零)
+ * @param str 输入的数字字符串
+ * @return 返回两位数字的字符串
*/
- public static String fulfuill(String str) {
- if(str.length() == 2) {
- return str;
- } else {
- return "0" + str;
- }
- }
-
+ public static String fulfuill(String str) {//
+ //
+ if(str.length() == 2) { // 如果字符串已经是两位数字
+ //
+ return str; // 直接返回该字符串
+ //
+ } else {//
+ return "0" + str; // 否则,在前面加上一个零
+ //
+ }//
+ }//
+//
/**
- * 从拼接的字符串中提取字段
- * @param str 字符串
- * @param delimiter 分隔符
- * @param field 字段
- * @return 字段值
+ * 从拼接的字符串中提取字段值
+ * 例如:str = "field1=value1|field2=value2",delimiter="|",field="field1"
+ * 该方法返回 "value1"
+ * @param str 拼接的字符串
+ * @param delimiter 分隔符
+ * @param field 字段名
+ * @return 字段值,如果不存在返回 null
*/
- public static String getFieldFromConcatString(String str,
- String delimiter, String field) {
- String[] fields = str.split(delimiter);
- for(String concatField : fields) {
- if(concatField.split("=").length==2) {
- String fieldName = concatField.split("=")[0];
- String fieldValue = concatField.split("=")[1];
- if (fieldName.equals(field)) {
- return fieldValue;
- }
- }
- }
- return null;
- }
-
+ public static String getFieldFromConcatString(String str,//申明
+ //
+ String delimiter, String field) {//
+ String[] fields = str.split(delimiter); // 根据分隔符将字符串分割成数组
+ //
+ for(String concatField : fields) { // 遍历每个分割后的字段
+ //
+ if(concatField.split("=").length==2) { // 判断字段是否符合 "key=value" 形式
+ //
+ String fieldName = concatField.split("=")[0]; // 获取字段名
+ //
+ String fieldValue = concatField.split("=")[1]; // 获取字段值
+ //
+ if (fieldName.equals(field)) { // 如果字段名匹配
+ //
+ return fieldValue; // 返回该字段的值
+ //
+ }//
+ }//
+ }//
+ return null; // 如果没有找到匹配的字段,返回 null
+ //
+ }//
+//
/**
- * 从拼接的字符串中给字段设置值
- * @param str 字符串
- * @param delimiter 分隔符
+ * 从拼接的字符串中给指定字段设置新值
+ * 例如:str = "field1=value1|field2=value2",delimiter="|",field="field1",newFieldValue="newValue"
+ * 该方法返回 "field1=newValue|field2=value2"
+ * @param str 拼接的字符串
+ * @param delimiter 分隔符
* @param field 字段名
- * @param newFieldValue 新的field值
- * @return 字段值
+ * @param newFieldValue 新的字段值
+ * @return 修改后的拼接字符串
*/
- public static String setFieldInConcatString(String str,
- String delimiter, String field, String newFieldValue) {
- String[] fields = str.split(delimiter);
-
- for(int i = 0; i < fields.length; i++) {
- String fieldName = fields[i].split("=")[0];
- if(fieldName.equals(field)) {
- String concatField = fieldName + "=" + newFieldValue;
- fields[i] = concatField;
- break;
- }
- }
-
+ public static String setFieldInConcatString(String str,//申明
+ //
+ String delimiter, String field, String newFieldValue) {//
+ //
+ String[] fields = str.split(delimiter); // 根据分隔符将字符串分割成数组
+//
+ for(int i = 0; i < fields.length; i++) { // 遍历每个字段
+ //
+ String fieldName = fields[i].split("=")[0]; // 获取字段名
+ //
+ if(fieldName.equals(field)) { // 如果字段名匹配
+ //
+ String concatField = fieldName + "=" + newFieldValue; // 创建新的字段
+ //
+ fields[i] = concatField; // 替换原字段
+ //
+ break; // 找到并修改后跳出循环
+ //
+ }//
+ }//
+//
+ // 使用 StringBuffer 构建修改后的拼接字符串
StringBuffer buffer = new StringBuffer("");
- for(int i = 0; i < fields.length; i++) {
- buffer.append(fields[i]);
- if(i < fields.length - 1) {
- buffer.append("|");
- }
- }
-
- return buffer.toString();
- }
-
-}
+ //
+ for(int i = 0; i < fields.length; i++) { // 遍历修改后的字段数组
+ //
+ buffer.append(fields[i]); // 将字段拼接到 buffer 中
+ //
+ if(i < fields.length - 1) { // 如果不是最后一个字段
+ //
+ buffer.append("|"); // 添加分隔符
+ //
+ }//
+ }//
+//
+ return buffer.toString(); // 返回修改后的拼接字符串
+ //
+ }//
+//
+}//
+//结束
\ No newline at end of file
diff --git a/src/main/java/cn/edu/hust/util/ValidUtils.java b/src/main/java/cn/edu/hust/util/ValidUtils.java
index df4da76..1aca9de 100644
--- a/src/main/java/cn/edu/hust/util/ValidUtils.java
+++ b/src/main/java/cn/edu/hust/util/ValidUtils.java
@@ -1,12 +1,15 @@
-package cn.edu.hust.util;
-
+//导入包
+package cn.edu.hust.util;//
+//
+//
/**
* 校验工具类
+ * 提供了校验数据字段是否符合某些条件的常用方法
* @author Administrator
*
*/
-public class ValidUtils {
-
+public class ValidUtils {//
+//
/**
* 校验数据中的指定字段,是否在指定范围内
* @param data 数据
@@ -14,95 +17,162 @@ public class ValidUtils {
* @param parameter 参数
* @param startParamField 起始参数字段
* @param endParamField 结束参数字段
- * @return 校验结果
+ * @return 校验结果,如果在范围内返回 true,否则返回 false
*/
- public static boolean between(String data, String dataField,
- String parameter, String startParamField, String endParamField) {
- String startParamFieldStr = StringUtils.getFieldFromConcatString(
- parameter, "\\|", startParamField);
- String endParamFieldStr = StringUtils.getFieldFromConcatString(
- parameter, "\\|", endParamField);
- if(startParamFieldStr == null || endParamFieldStr == null) {
- return true;
- }
-
- int startParamFieldValue = Integer.valueOf(startParamFieldStr);
- int endParamFieldValue = Integer.valueOf(endParamFieldStr);
-
- String dataFieldStr = StringUtils.getFieldFromConcatString(
- data, "\\|", dataField);
- if(dataFieldStr != null) {
- int dataFieldValue = Integer.valueOf(dataFieldStr);
- if(dataFieldValue >= startParamFieldValue &&
- dataFieldValue <= endParamFieldValue) {
- return true;
- } else {
- return false;
- }
- }
-
- return false;
- }
-
+ public static boolean between(String data, String dataField,//
+ //
+ String parameter, String startParamField, String endParamField) {//尝试编写
+ // 获取参数中的起始范围值
+ String startParamFieldStr = StringUtils.getFieldFromConcatString(//
+ //
+ parameter, "\\|", startParamField);//
+ // 获取参数中的结束de范围值
+ // 获取参数中的结束范围值
+ String endParamFieldStr = StringUtils.getFieldFromConcatString(//
+ //
+ parameter, "\\|", endParamField);//
+//
+ // 如果起始值或结束值为空,直接返回 true
+ if(startParamFieldStr == null || endParamFieldStr == null) {//
+ //
+ return true;//返回正确值
+ }//
+//
+ // 将起始和结束值转换为整数
+ int startParamFieldValue = Integer.valueOf(startParamFieldStr);//
+ //转换
+ int endParamFieldValue = Integer.valueOf(endParamFieldStr);//
+ //转换
+//
+ // 获取数据字段的值
+ String dataFieldStr = StringUtils.getFieldFromConcatString(//
+ //
+ data, "\\|", dataField);//
+//
+ // 如果数据字段值不为空,进行范围校验
+ if(dataFieldStr != null) {//
+ //
+ int dataFieldValue = Integer.valueOf(dataFieldStr);//
+ // 校验数据字段值是否在指定范围内
+ if(dataFieldValue >= startParamFieldValue &&//
+ //
+ dataFieldValue <= endParamFieldValue) {//
+ //
+ return true;//返回
+ //
+ } else {//
+ //
+ return false; // 如果数据字段值超出范围,返回 false
+ //
+ }//
+ }//
+//
+ // 如果数据字段值为空,返回 false
+ return false;//返回错误
+ //
+ }//
+//
/**
* 校验数据中的指定字段,是否有值与参数字段的值相同
* @param data 数据
* @param dataField 数据字段
* @param parameter 参数
* @param paramField 参数字段
- * @return 校验结果
+ * @return 校验结果,如果匹配返回 true,否则返回 false
*/
- public static boolean in(String data, String dataField,
- String parameter, String paramField) {
- String paramFieldValue = StringUtils.getFieldFromConcatString(
- parameter, "\\|", paramField);
- if(paramFieldValue == null) {
- return true;
- }
- String[] paramFieldValueSplited = paramFieldValue.split(",");
-
- String dataFieldValue = StringUtils.getFieldFromConcatString(
- data, "\\|", dataField);
- if(dataFieldValue != null) {
+ //申明
+ public static boolean in(String data, String dataField,//申明
+ // 申明
+ // 申明
+ //申明
+ String parameter, String paramField) {//
+ //
+ // 获取参数字段的值
+ String paramFieldValue = StringUtils.getFieldFromConcatString(//
+ //
+ parameter, "\\|", paramField);//
+ //
+ // 如果参数字段值为空,直接返回 true
+ if(paramFieldValue == null) {//
+ //
+ return true;//
+ //
+ }//
+ // 将参数字段的值按逗号分隔成数组
+ String[] paramFieldValueSplited = paramFieldValue.split(",");//
+ //
+//sdzf
+ // 获取数据字段的值
+ String dataFieldValue = StringUtils.getFieldFromConcatString(//
+ //
+ data, "\\|", dataField);//
+ //
+ // 如果数据字段值不为空,进行匹配校验
+ if(dataFieldValue != null) {//
+ //
+ // 将数据字段值按逗号分隔成数组
String[] dataFieldValueSplited = dataFieldValue.split(",");
-
- for(String singleDataFieldValue : dataFieldValueSplited) {
- for(String singleParamFieldValue : paramFieldValueSplited) {
- if(singleDataFieldValue.equals(singleParamFieldValue)) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
+//
+ // 遍历数据字段值和参数字段值,检查是否存在匹配
+ for(String singleDataFieldValue : dataFieldValueSplited) {//
+ //
+ for(String singleParamFieldValue : paramFieldValueSplited) {//
+ //
+ // 如果有一个匹配项,返回 true
+ if(singleDataFieldValue.equals(singleParamFieldValue)) {//
+ //
+ return true;//返回正确
+ }//
+ }//
+ }//
+ }//
+//
+ // 如果没有任何匹配项,返回 false
+ return false;//返回错误
+ }//
+//
/**
- * 校验数据中的指定字段,是否在指定范围内
+ * 校验数据中的指定字段,是否等于参数字段的值
* @param data 数据
* @param dataField 数据字段
* @param parameter 参数
* @param paramField 参数字段
- * @return 校验结果
+ * @return 校验结果,如果等于返回 true,否则返回 false
*/
- public static boolean equal(String data, String dataField,
- String parameter, String paramField) {
- String paramFieldValue = StringUtils.getFieldFromConcatString(
- parameter, "\\|", paramField);
- if(paramFieldValue == null) {
- return true;
- }
-
- String dataFieldValue = StringUtils.getFieldFromConcatString(
- data, "\\|", dataField);
- if(dataFieldValue != null) {
- if(dataFieldValue.equals(paramFieldValue)) {
- return true;
- }
- }
-
- return false;
- }
-
-}
+ public static boolean equal(String data, String dataField,//申明
+ //
+ String parameter, String paramField) {//
+ //
+ // 获取参数字段的值
+ String paramFieldValue = StringUtils.getFieldFromConcatString(//
+ //
+ parameter, "\\|", paramField);//
+ // 如果参数字段值为空,直接返回 true
+ if(paramFieldValue == null) {//
+ //
+ return true;//返回正确
+ //
+ }//
+//
+ // 获取数据字段的值
+ String dataFieldValue = StringUtils.getFieldFromConcatString(//
+ //
+ data, "\\|", dataField);//
+ //
+ // 如果数据字段值不为空,进行值匹配校验
+ if(dataFieldValue != null) {//
+ //
+ // 如果数据字段值等于参数字段的值,返回 true
+ if(dataFieldValue.equals(paramFieldValue)) {//
+ //
+ return true;//返回正确
+ //
+ }//
+ }//
+
+ // 如果数据字段值与参数字段值不匹配,返回 false
+ return false;//返回错误
+ }//
+//
+}//
+//jieshu
\ No newline at end of file
diff --git a/src/main/resources/conf.properties b/src/main/resources/conf.properties
index 2e8b6dd..9dbcba9 100644
--- a/src/main/resources/conf.properties
+++ b/src/main/resources/conf.properties
@@ -1,6 +1,13 @@
-jdbc.driver=com.mysql.jdbc.Driver
-jdbc.url=jdbc:mysql://10.211.55.16:3306/BigDataPlatm?useUnicode=true&&characterEncoding=UTF-8
-jdbc.username=root
-jdbc.password=root
-jdbc.active=20
-spark.local=true;
+#
+jdbc.driver=com.mysql.jdbc.Driver # JDBCָ࣬ʹõݿMySQLJDBC
+#
+jdbc.url=jdbc:mysql://10.211.55.16:3306/BigDataPlatm?useUnicode=true&&characterEncoding=UTF-8 # ݿURLָMySQLݿIPַ˿ڡݿƼַ
+#
+jdbc.username=root # ݿûݿʱʹõûroot
+#
+jdbc.password=root # ݿ룬ݿʱʹõ룬root\
+#
+jdbc.active=20 # ݿӳصĻԾʾݿӳлԾӵ
+#
+spark.local=true; # SparkģʽãʾǷʹSparkıģʽ
+#
diff --git a/src/test/java/cn/edu/hust/conf/ConfigurationManagerTest.java b/src/test/java/cn/edu/hust/conf/ConfigurationManagerTest.java
index 75d3272..932b499 100644
--- a/src/test/java/cn/edu/hust/conf/ConfigurationManagerTest.java
+++ b/src/test/java/cn/edu/hust/conf/ConfigurationManagerTest.java
@@ -1,15 +1,17 @@
-package cn.edu.hust.conf;
-
-
-import org.junit.Test;
-
-public class ConfigurationManagerTest {
- /**
- * 测试配置文件管理类
- */
- @Test
- public void getMethod()
- {
- System.out.println(ConfigurationManager.getProperty("key1"));
- }
-}
+//开始
+package cn.edu.hust.conf; // 导入包:配置管理相关的类
+//
+import org.junit.Test; // 导入JUnit的Test注解,用于标识测试方法
+//
+public class ConfigurationManagerTest { // 定义测试类,测试ConfigurationManager类的功能
+ //
+ //测试配置文件管理类 // 方法注释,表示该方法用于测试配置文件管理类
+ //
+ @Test // 使用JUnit的Test注解,表示该方法为一个测试方法
+ //
+ public void getMethod() // 定义一个测试方法
+ { //
+ System.out.println(ConfigurationManager.getProperty("key1")); // 打印从ConfigurationManager获取key1对应的属性值
+ }//
+}//
+//完成
diff --git a/src/test/java/cn/edu/hust/utils/ParamUtilsTest.java b/src/test/java/cn/edu/hust/utils/ParamUtilsTest.java
index 215dd1a..163eafc 100644
--- a/src/test/java/cn/edu/hust/utils/ParamUtilsTest.java
+++ b/src/test/java/cn/edu/hust/utils/ParamUtilsTest.java
@@ -1,16 +1,28 @@
-package cn.edu.hust.utils;
-
-import cn.edu.hust.util.ParamUtils;
-import com.alibaba.fastjson.JSONObject;
-import org.junit.Test;
-
-public class ParamUtilsTest {
- @Test
- public void test2()
- {
- String json="{\"startAge\":[\"10\"],\"endAge\":[\"34\"],\"startDate\":[\"2018-06-22\"],\"endDate\":[\"2018-06-22\"]}";
- JSONObject param=JSONObject.parseObject(json);
- //param.getJSONArray("startAge");
- System.out.println(ParamUtils.getParam(param,"startDate"));
- }
-}
+//开始
+package cn.edu.hust.utils; // 定义类所在的包,包名为cn.edu.hust.utils
+//
+import cn.edu.hust.util.ParamUtils; // 导入ParamUtils工具类,假设该类中包含用于处理参数的实用方法
+//
+import com.alibaba.fastjson.JSONObject; // 导入fastjson库中的JSONObject类,用于处理JSON数据
+//
+import org.junit.Test; // 导入JUnit的Test注解,标识该方法为JUnit测试方法
+//
+//
+public class ParamUtilsTest { // 定义测试类ParamUtilsTest,主要用于测试ParamUtils类的方法
+ //
+ @Test // 使用JUnit的Test注解,标识该方法为一个测试方法
+ //
+ public void test2() // 定义测试方法test2
+ //
+ {//
+ String json="{\"startAge\":[\"10\"],\"endAge\":[\"34\"],\"startDate\":[\"2018-06-22\"],\"endDate\":[\"2018-06-22\"]}"; // 定义一个JSON格式的字符串,包含多个键值对,其中包含了年龄范围和日期范围
+ //运行
+ JSONObject param=JSONObject.parseObject(json); // 将JSON字符串转换为JSONObject对象,方便后续操作
+ //
+ //param.getJSONArray("startAge"); // 这行代码被注释掉了,原本是获取JSON中的"startAge"数组
+ //
+ System.out.println(ParamUtils.getParam(param,"startDate")); // 调用ParamUtils类中的getParam方法,获取"startDate"参数的值并输出到控制台
+ //
+ }//
+}//
+//结束
\ No newline at end of file