From 3922bccffe94affa2746f0068bd79fb5ff5cf25d Mon Sep 17 00:00:00 2001
From: haozq <1611483981@qq.com>
Date: Mon, 19 Jan 2026 10:00:30 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A4=9A=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E4=B8=8B=E8=BD=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 6 +-
.../project/CompanyProjectApplication.java | 2 +-
.../controller/SysFilesController.java | 2 +-
.../company/project/mapper/OptionMapper.java | 6 +
.../service/impl/OptionServiceImpl.java | 20 +-
.../com/company/project/utils/DateUtils.java | 691 ++++++++++++++++++
.../com/company/project/utils/PhoneUtils.java | 100 +++
.../resources/mapper/mysql/OptionMapper.xml | 5 +
.../templates/options/option_list.html | 4 +-
9 files changed, 828 insertions(+), 8 deletions(-)
create mode 100644 src/main/java/com/company/project/utils/DateUtils.java
create mode 100644 src/main/java/com/company/project/utils/PhoneUtils.java
diff --git a/pom.xml b/pom.xml
index 2dd7fae..7fc7f83 100644
--- a/pom.xml
+++ b/pom.xml
@@ -190,7 +190,11 @@
sa-token-dialect-thymeleaf
1.38.0
-
+
+ cn.hutool
+ hutool-all
+ 5.8.22
+
diff --git a/src/main/java/com/company/project/CompanyProjectApplication.java b/src/main/java/com/company/project/CompanyProjectApplication.java
index 9b52611..beeca15 100644
--- a/src/main/java/com/company/project/CompanyProjectApplication.java
+++ b/src/main/java/com/company/project/CompanyProjectApplication.java
@@ -24,7 +24,7 @@ public class CompanyProjectApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext application = SpringApplication.run(CompanyProjectApplication.class, args);
-
+ System.err.println("意见收集小程序启动成功");
Environment env = application.getEnvironment();
log.info("\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
diff --git a/src/main/java/com/company/project/controller/SysFilesController.java b/src/main/java/com/company/project/controller/SysFilesController.java
index fbfbcea..a0fb548 100644
--- a/src/main/java/com/company/project/controller/SysFilesController.java
+++ b/src/main/java/com/company/project/controller/SysFilesController.java
@@ -35,7 +35,7 @@ public class SysFilesController {
@ApiOperation(value = "新增")
@PostMapping("/upload")
@SaCheckPermission(value = {"sysFiles:add", "sysContent:update", "sysContent:add"}, mode = SaMode.OR)
- public String add(@RequestParam(value = "file") MultipartFile file, HttpServletRequest request) {
+ public String add(@RequestParam(value = "file") MultipartFile file,HttpServletRequest request) {
//判断文件是否空
if (file == null || file.getOriginalFilename() == null || "".equalsIgnoreCase(file.getOriginalFilename().trim())) {
throw new BusinessException("文件为空");
diff --git a/src/main/java/com/company/project/mapper/OptionMapper.java b/src/main/java/com/company/project/mapper/OptionMapper.java
index afc4ee9..5af1038 100644
--- a/src/main/java/com/company/project/mapper/OptionMapper.java
+++ b/src/main/java/com/company/project/mapper/OptionMapper.java
@@ -131,4 +131,10 @@ public interface OptionMapper extends BaseMapper {
* @return
*/
TbTask getTaskDetails(TbTask vo);
+
+ /**
+ * 查询用户信息
+ * @return
+ */
+ List getUserPhoneList();
}
diff --git a/src/main/java/com/company/project/service/impl/OptionServiceImpl.java b/src/main/java/com/company/project/service/impl/OptionServiceImpl.java
index a88cb75..b7ac91d 100644
--- a/src/main/java/com/company/project/service/impl/OptionServiceImpl.java
+++ b/src/main/java/com/company/project/service/impl/OptionServiceImpl.java
@@ -10,12 +10,12 @@ import com.company.project.mapper.OptionMapper;
import com.company.project.common.exception.BusinessException;
import com.company.project.service.OptionService;
import com.company.project.utils.IDUtils;
+import com.company.project.utils.PhoneUtils;
import com.company.project.utils.ZipExportUtils;
import com.company.project.vo.resp.TaskOwnUserRespVo;
-import com.company.project.vo.resp.UserOwnRoleRespVO;
import com.google.common.collect.Maps;
-import com.google.zxing.WriterException;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -24,7 +24,6 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
-import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@@ -148,6 +147,21 @@ public class OptionServiceImpl extends ServiceImpl implem
String createTimes= DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN);
vo.setCreateTime(createTimes);
int num= mapper.addTaskInfoData(vo);
+ List userPhone=mapper.getUserPhoneList();
+ if(userPhone!=null && !userPhone.isEmpty()){
+ for (String phone:userPhone) {
+ String msg=PhoneUtils.PHONE_HEAD+com.company.project.utils.DateUtils.getTime()+";";
+ if(StringUtils.isNotEmpty(vo.getUserName())){
+ msg=msg+ vo.getUserName();
+ }
+// if(StringUtils.isNotEmpty(vo.getUserPhone())){
+// msg=msg+"("+vo.getUserPhone()+")";
+// }
+ msg=msg +"提出了一条新的意见内容如下:"+vo.getUserOpinion();
+ System.err.println(msg);
+ PhoneUtils.sendPhoneMsg(phone,msg);
+ }
+ }
if(num>0){
if(files != null){
for (MultipartFile file : files) {
diff --git a/src/main/java/com/company/project/utils/DateUtils.java b/src/main/java/com/company/project/utils/DateUtils.java
new file mode 100644
index 0000000..387ff2d
--- /dev/null
+++ b/src/main/java/com/company/project/utils/DateUtils.java
@@ -0,0 +1,691 @@
+package com.company.project.utils;
+
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.lang.management.ManagementFactory;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.*;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoField;
+import java.time.temporal.TemporalAdjusters;
+import java.time.temporal.WeekFields;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 日期工具类,提供常见的日期处理方法。
+ * 作者: bonus
+ */
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
+
+ // 常见日期格式
+ public static final String YYYY = "yyyy";
+ public static final String YYYY_MM = "yyyy-MM";
+ public static final String YYYY_MM_DD = "yyyy-MM-dd";
+ public static final String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
+ public static final String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
+ public static final String YYYYMMDD = "yyyyMMdd";
+ private static final String[] PARSE_PATTERNS = {
+ "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
+ "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
+ "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
+
+ /**
+ * 获取当前 Date 型日期
+ *
+ * @return 当前日期
+ */
+ public static Date getNowDate() {
+ return new Date();
+ }
+ public static String getYMDDate() {
+ return dateTimeNow(YYYYMMDD);
+ }
+ /**
+ * 获取当前日期,格式为 yyyy-MM-dd
+ *
+ * @return 当前日期的字符串
+ */
+ public static String getDate() {
+ return dateTimeNow(YYYY_MM_DD);
+ }
+
+ /**
+ * 获取当前时间,格式为 yyyy-MM-dd HH:mm:ss
+ *
+ * @return 当前时间的字符串
+ */
+ public static String getTime() {
+ return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
+ }
+
+ /**
+ * 获取当前年份
+ *
+ * @return 当前年份的字符串
+ */
+ public static String getCurrentYear() {
+ return String.valueOf(LocalDate.now().getYear());
+ }
+
+ /**
+ * 获取当前月份
+ *
+ * @return 当前月份的字符串
+ */
+ public static String getCurrentMonth() {
+ return String.format("%02d", LocalDate.now().getMonthValue());
+ }
+
+ /**
+ * 获取当前日期中的日
+ *
+ * @return 当前日的字符串
+ */
+ public static String getCurrentDay() {
+ return String.format("%02d", LocalDate.now().getDayOfMonth());
+ }
+
+ /**
+ * 获取当前日期时间,格式为 yyyyMMddHHmmss
+ *
+ * @return 当前日期时间的字符串
+ */
+ public static String dateTimeNow() {
+ return dateTimeNow(YYYYMMDDHHMMSS);
+ }
+
+ /**
+ * 根据指定格式获取当前日期时间
+ *
+ * @param format 日期格式
+ * @return 当前日期时间的字符串
+ */
+ public static String dateTimeNow(final String format) {
+ return parseDateToStr(format, new Date());
+ }
+
+ /**
+ * 将 Date 类型日期转换为指定格式的字符串
+ *
+ * @param format 日期格式
+ * @param date 日期
+ * @return 格式化后的日期字符串
+ */
+ public static String parseDateToStr(final String format, final Date date) {
+ return new SimpleDateFormat(format).format(date);
+ }
+
+ /**
+ * 将字符串解析为 Date 类型日期
+ *
+ * @param format 日期格式
+ * @param ts 日期字符串
+ * @return 解析后的日期
+ */
+ public static Date dateTime(final String format, final String ts) {
+ try {
+ return new SimpleDateFormat(format).parse(ts);
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ /**
+ * 计算两个日期之间的时间差,返回格式为 X天X小时X分钟
+ *
+ * @param endDate 结束日期
+ * @param startDate 开始日期
+ * @return 时间差字符串
+ */
+ public static String timeDistance(Date endDate, Date startDate,String separator) {
+ long duration = endDate.getTime() - startDate.getTime();
+ long days = TimeUnit.MILLISECONDS.toDays(duration);
+ long hours = TimeUnit.MILLISECONDS.toHours(duration) % 24;
+ long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) % 60;
+ if (StringUtils.isEmpty(separator)) {
+ return days + "天" + hours + "小时" + minutes + "分钟";
+ }
+ return days + separator + hours + separator + minutes;
+ }
+ public static String timeDistance(Date endDate, Date startTime)
+ {
+ long nd = 1000 * 24 * 60 * 60;
+ long nh = 1000 * 60 * 60;
+ long nm = 1000 * 60;
+ // long ns = 1000;
+ // 获得两个时间的毫秒时间差异
+ long diff = endDate.getTime() - startTime.getTime();
+ // 计算差多少天
+ long day = diff / nd;
+ // 计算差多少小时
+ long hour = diff % nd / nh;
+ // 计算差多少分钟
+ long min = diff % nd % nh / nm;
+ // 计算差多少秒//输出结果
+ // long sec = diff % nd % nh % nm / ns;
+ return day + "天" + hour + "小时" + min + "分钟";
+ }
+
+ /**
+ * 将 LocalDateTime 转换为 Date
+ *
+ * @param localDateTime LocalDateTime 对象
+ * @return 转换后的 Date 对象
+ */
+ public static Date toDate(LocalDateTime localDateTime) {
+ ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
+ return Date.from(zdt.toInstant());
+ }
+
+ /**
+ * 将 LocalDate 转换为 Date
+ *
+ * @param localDate LocalDate 对象
+ * @return 转换后的 Date 对象
+ */
+ public static Date toDate(LocalDate localDate) {
+ LocalDateTime localDateTime = localDate.atTime(0, 0, 0);
+ ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
+ return Date.from(zdt.toInstant());
+ }
+
+ /**
+ * 将 Date 转换为 LocalDateTime
+ *
+ * @param date Date 对象
+ * @return 转换后的 LocalDateTime 对象
+ */
+ public static LocalDateTime toLocalDateTime(Date date) {
+ Instant instant = date.toInstant();
+ return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
+ }
+
+ /**
+ * 将 Date 转换为 LocalDate
+ *
+ * @param date Date 对象
+ * @return 转换后的 LocalDate 对象
+ */
+ public static LocalDate toLocalDate(Date date) {
+ Instant instant = date.toInstant();
+ return instant.atZone(ZoneId.systemDefault()).toLocalDate();
+ }
+
+ /**
+ * 将 Date 转换为 LocalTime
+ *
+ * @param date Date 对象
+ * @return 转换后的 LocalTime 对象
+ */
+ public static LocalTime toLocalTime(Date date) {
+ Instant instant = date.toInstant();
+ return instant.atZone(ZoneId.systemDefault()).toLocalTime();
+ }
+
+ /**
+ * 获取服务器启动时间
+ *
+ * @return 服务器启动时间
+ */
+ public static Date getServerStartDate() {
+ long startTime = ManagementFactory.getRuntimeMXBean().getStartTime();
+ return new Date(startTime);
+ }
+
+ /**
+ * 获取当前日期路径,格式为 yyyy/MM/dd
+ *
+ * @return 当前日期路径字符串
+ */
+ public static String datePath() {
+ return parseDateToStr("yyyy/MM/dd", new Date());
+ }
+
+ /**
+ * 获取当前日期路径,格式为 yyyyMMdd
+ *
+ * @return 当前日期路径字符串
+ */
+ public static String dateTime() {
+ return parseDateToStr("yyyyMMdd", new Date());
+ }
+
+ /**
+ * 获取两个日期之间的天数
+ *
+ * @param startDate 开始日期
+ * @param endDate 结束日期
+ * @return 两个日期之间的天数
+ */
+ public static long daysBetween(Date startDate, Date endDate) {
+ long diffInMillis = endDate.getTime() - startDate.getTime();
+ return TimeUnit.DAYS.convert(diffInMillis, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 获取两个日期之间的小时数
+ *
+ * @param startDate 开始日期
+ * @param endDate 结束日期
+ * @return 两个日期之间的小时数
+ */
+ public static long hoursBetween(Date startDate, Date endDate) {
+ long diffInMillis = endDate.getTime() - startDate.getTime();
+ return TimeUnit.HOURS.convert(diffInMillis, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 获取两个日期之间的分钟数
+ *
+ * @param startDate 开始日期
+ * @param endDate 结束日期
+ * @return 两个日期之间的分钟数
+ */
+ public static long minutesBetween(Date startDate, Date endDate) {
+ long diffInMillis = endDate.getTime() - startDate.getTime();
+ return TimeUnit.MINUTES.convert(diffInMillis, TimeUnit.MILLISECONDS);
+ }
+
+ /**
+ * 增加指定天数到日期
+ *
+ * @param date 日期
+ * @param days 天数
+ * @return 增加天数后的日期
+ */
+ public static Date addDays(Date date, int days) {
+ LocalDateTime localDateTime = toLocalDateTime(date);
+ localDateTime = localDateTime.plusDays(days);
+ return toDate(localDateTime);
+ }
+
+ /**
+ * 增加指定小时数到日期
+ *
+ * @param date 日期
+ * @param hours 小时数
+ * @return 增加小时数后的日期
+ */
+ public static Date addHours(Date date, int hours) {
+ LocalDateTime localDateTime = toLocalDateTime(date);
+ localDateTime = localDateTime.plusHours(hours);
+ return toDate(localDateTime);
+ }
+
+ /**
+ * 日期型字符串转化为日期 格式
+ */
+ public static Date parseDate(Object str) {
+ if (str == null) {
+ return null;
+ }
+ try {
+ return parseDate(str.toString(), PARSE_PATTERNS);
+ } catch (ParseException e) {
+ return null;
+ }
+ }
+
+ /**
+ * 增加指定分钟数到日期
+ *
+ * @param date 日期
+ * @param minutes 分钟数
+ * @return 增加分钟数后的日期
+ */
+ public static Date addMinutes(Date date, int minutes) {
+ LocalDateTime localDateTime = toLocalDateTime(date);
+ localDateTime = localDateTime.plusMinutes(minutes);
+ return toDate(localDateTime);
+ }
+
+ /**
+ * 判断一个日期是否在另一个日期之前
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 如果日期1在日期2之前,返回 true;否则返回 false
+ */
+ public static boolean isBefore(Date date1, Date date2) {
+ return date1.before(date2);
+ }
+
+ /**
+ * 判断一个日期是否在另一个日期之后
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 如果日期1在日期2之后,返回 true;否则返回 false
+ */
+ public static boolean isAfter(Date date1, Date date2) {
+ return date1.after(date2);
+ }
+
+ /**
+ * 判断两个日期是否相等
+ *
+ * @param date1 日期1
+ * @param date2 日期2
+ * @return 如果两个日期相等,返回 true;否则返回 false
+ */
+ public static boolean isEqual(Date date1, Date date2) {
+ return date1.equals(date2);
+ }
+
+ /**
+ * 获取当前时间的 Unix 时间戳
+ *
+ * @return 当前时间的 Unix 时间戳
+ */
+ public static long getUnixTimestamp() {
+ return System.currentTimeMillis() / 1000L;
+ }
+
+ /**
+ * 将 Unix 时间戳转换为 Date
+ *
+ * @param timestamp Unix 时间戳
+ * @return 转换后的 Date 对象
+ */
+ public static Date fromUnixTimestamp(long timestamp) {
+ return new Date(timestamp * 1000L);
+ }
+
+ /**
+ * 将 Date 转换为 Unix 时间戳
+ *
+ * @param date Date 对象
+ * @return 转换后的 Unix 时间戳
+ */
+ public static long toUnixTimestamp(Date date) {
+ return date.getTime() / 1000L;
+ }
+
+ /**
+ * 获取当前日期时间,格式为 yyyy-MM-dd'T'HH:mm:ss.SSSZ
+ *
+ * @return 当前日期时间的字符串
+ */
+ public static String getISO8601Timestamp() {
+ return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(OffsetDateTime.now());
+ }
+
+ /**
+ * 将 ISO8601 格式的字符串转换为 Date
+ *
+ * @param iso8601Timestamp ISO8601 格式的日期字符串
+ * @return 转换后的 Date 对象
+ */
+ public static Date fromISO8601Timestamp(String iso8601Timestamp) {
+ OffsetDateTime odt = OffsetDateTime.parse(iso8601Timestamp);
+ return Date.from(odt.toInstant());
+ }
+
+ /**
+ * 获取本周的开始时间
+ *
+ * @return 本周的开始时间
+ */
+ public static Date getStartOfWeek() {
+ LocalDate now = LocalDate.now();
+ LocalDate startOfWeek = now.with(DayOfWeek.MONDAY);
+ return toDate(startOfWeek);
+ }
+
+ /**
+ * 获取本周的结束时间
+ *
+ * @return 本周的结束时间
+ */
+ public static Date getEndOfWeek() {
+ LocalDate now = LocalDate.now();
+ LocalDate endOfWeek = now.with(DayOfWeek.SUNDAY);
+ return toDate(endOfWeek.atTime(LocalTime.MAX));
+ }
+
+ /**
+ * 获取当前日期是当年的第几周
+ *
+ * @return 当前日期是当年的第几周
+ */
+ public static int getWeekOfYear() {
+ LocalDate now = LocalDate.now();
+ return now.get(ChronoField.ALIGNED_WEEK_OF_YEAR);
+ }
+
+ /**
+ * 获取指定日期前几天的日期
+ *
+ * @param date 日期
+ * @param days 天数
+ * @return 指定日期前几天的日期
+ */
+ public static Date getDateBefore(Date date, int days) {
+ LocalDateTime localDateTime = toLocalDateTime(date);
+ localDateTime = localDateTime.minusDays(days);
+ return toDate(localDateTime);
+ }
+
+ /**
+ * 获取指定日期后几天的日期
+ *
+ * @param date 日期
+ * @param days 天数
+ * @return 指定日期后几天的日期
+ */
+ public static Date getDateAfter(Date date, int days) {
+ LocalDateTime localDateTime = toLocalDateTime(date);
+ localDateTime = localDateTime.plusDays(days);
+ return toDate(localDateTime);
+ }
+
+ /**
+ * 根据输入的日 返回月/日
+ *
+ * @param day 日
+ * @param separator 分隔符
+ * @return 月/日
+ */
+ public static String getMonthOrDay(int day, String separator) {
+ LocalDate today = LocalDate.now();
+ if (day < 1 || day > today.lengthOfMonth()) {
+ return null;
+ } else {
+ if (StringUtils.isEmpty(separator)) {
+ return String.format("%02d", LocalDate.now().getMonthValue()) + "月" + day;
+ } else {
+ return String.format("%02d", LocalDate.now().getMonthValue()) + separator + day;
+ }
+
+ }
+ }
+
+ /**
+ * 将日期字符串转换为 ISO 8601 格式
+ *
+ * @param dateStr 输入的日期字符串
+ * @param format 输入日期的格式
+ * @return ISO 8601 格式的日期字符串
+ */
+ public static String convertToISO8601(String dateStr, String format) {
+ DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern(format);
+ DateTimeFormatter isoFormatter = DateTimeFormatter.ISO_DATE_TIME;
+ LocalDateTime dateTime = LocalDateTime.parse(dateStr, inputFormatter);
+ return dateTime.format(isoFormatter);
+ }
+
+ /**
+ * 获取两个时间之间的相差秒数
+ *
+ * @param startTimeStr 开始时间的字符串
+ * @param endTimeStr 结束时间的字符串
+ * @param format 时间格式
+ * @return 相差的秒数
+ */
+ public static long getSecondsBetween(String startTimeStr, String endTimeStr, String format) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+
+ LocalDateTime startTime = LocalDateTime.parse(startTimeStr, formatter);
+ LocalDateTime endTime = LocalDateTime.parse(endTimeStr, formatter);
+
+ Duration duration = Duration.between(startTime, endTime);
+ return duration.getSeconds();
+ }
+
+ /**
+ * 根据输入日期字符串返回本周的周一和周日的日期
+ *
+ * @param dateStr 日期字符串
+ * @param format 日期格式
+ * @return 包含本周一和周日日期的数组
+ */
+ public static String[] getWeekStartAndEndDate(String dateStr, String format) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ LocalDate date = LocalDate.parse(dateStr, formatter);
+
+ // 获取本周一
+ LocalDate monday = date.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
+ // 获取本周日
+ LocalDate sunday = date.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
+ return new String[] {
+ monday.format(formatter),
+ sunday.format(formatter)
+ };
+ }
+
+ /**
+ * 根据输入日期字符串返回本周的开始时间和结束时间
+ *
+ * @param dateStr 日期字符串
+ * @param format 日期格式
+ * @return 包含本周开始时间和结束时间的数组
+ */
+ public static String[] getWeekStartAndEndDateTime(String dateStr, String format) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ LocalDate date = LocalDate.parse(dateStr, formatter);
+
+ // 获取本周一的开始时间
+ LocalDateTime startOfWeek = date.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY))
+ .atStartOfDay();
+
+ // 获取本周日的结束时间
+ LocalDateTime endOfWeek = date.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY))
+ .atTime(23, 59, 59);
+
+ return new String[] {
+ startOfWeek.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")),
+ endOfWeek.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))
+ };
+ }
+
+ /**
+ * 根据输入日期字符串返回该日期属于本月的第几周
+ *
+ * @param dateStr 日期字符串
+ * @param format 日期格式
+ * @return 该日期属于本月的第几周
+ */
+ public static int getWeekOfMonth(String dateStr, String format) {
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ LocalDate date = LocalDate.parse(dateStr, formatter);
+
+ // 获取周字段,周一为一周的开始
+ WeekFields weekFields = WeekFields.of(Locale.getDefault());
+ return date.get(weekFields.weekOfMonth());
+ }
+
+ /**
+ * 获取从当前日期往前推 n 天的所有日期,并以字符串形式返回
+ *
+ * @param n 天数
+ * @param format 日期格式
+ * @param sort 排序,sort =true 正序,false 倒叙
+ * @return 从当前日期往前推 n 天的所有日期的字符串列表
+ */
+ public static List getDatesBefore(int n, String format,boolean sort) {
+ List dates = new ArrayList<>();
+ LocalDate today = LocalDate.now();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ if(sort){
+ for (int i=n-1;i>=0;i--){
+ LocalDate date = today.minusDays(i);
+ dates.add(date.format(formatter));
+ }
+ }else{
+ for (int i = 0; i < n; i++) {
+ LocalDate date = today.minusDays(i);
+ dates.add(date.format(formatter));
+ }
+ }
+ return dates;
+ }
+
+ /**
+ * 获取从当前日期往后推 n 天的所有日期,并以字符串形式返回
+ *
+ * @param n 天数
+ * @param format 日期格式
+ * @return 从当前日期往后推 n 天的所有日期的字符串列表
+ */
+ public static List getDatesAfter(int n, String format) {
+ List dates = new ArrayList<>();
+ LocalDate today = LocalDate.now();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+
+ for (int i = 0; i < n; i++) {
+ LocalDate date = today.plusDays(i);
+ dates.add(date.format(formatter));
+ }
+
+ return dates;
+ }
+
+ /**
+ * 根据输入日期字符串获取从指定日期往后推 n 天的所有日期,并以字符串形式返回
+ *
+ * @param startDateStr 起始日期字符串
+ * @param n 天数
+ * @param format 输入日期的格式
+ * @return 从指定日期往后推 n 天的所有日期的字符串列表
+ */
+ public static List getDatesAfter(String startDateStr, int n, String format) {
+ List dates = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ LocalDate startDate = LocalDate.parse(startDateStr, formatter);
+
+ for (int i = 0; i < n; i++) {
+ LocalDate date = startDate.plusDays(i);
+ dates.add(date.format(formatter));
+ }
+
+ return dates;
+ }
+
+ /**
+ * 根据输入日期字符串获取从指定日期往前推 n 天的所有日期,并以字符串形式返回
+ *
+ * @param startDateStr 起始日期字符串
+ * @param n 天数
+ * @param format 日期格式
+ * @return 从指定日期往前推 n 天的所有日期的字符串列表
+ */
+ public static List getDatesBefore(String startDateStr, int n, String format) {
+ List dates = new ArrayList<>();
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
+ LocalDate startDate = LocalDate.parse(startDateStr, formatter);
+
+ for (int i = 0; i < n; i++) {
+ LocalDate date = startDate.minusDays(i);
+ dates.add(date.format(formatter));
+ }
+
+ return dates;
+ }
+}
diff --git a/src/main/java/com/company/project/utils/PhoneUtils.java b/src/main/java/com/company/project/utils/PhoneUtils.java
new file mode 100644
index 0000000..0ef3011
--- /dev/null
+++ b/src/main/java/com/company/project/utils/PhoneUtils.java
@@ -0,0 +1,100 @@
+package com.company.project.utils;
+
+import cn.hutool.http.HttpRequest;
+import org.hibernate.validator.internal.util.StringHelper;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * 第三方依赖
+ *
+ * cn.hutool
+ * hutool-all
+ * 5.8.22
+ *
+ * 手机 短信 下发工具类
+ * @author 黑子
+ */
+public class PhoneUtils {
+
+ /**
+ * 短信验证码 发送地址 及账号
+ */
+ public static String url="http://api.ktsms.cn/sms_token?ddtkey=bonus&secretkey=KtyBns@Admin2023!";
+
+ public static final String STRING_OK = "ok";
+ /**
+ * 验证码时长
+ * 分钟
+ */
+ public static final String TIMES = "5";
+
+ /**
+ * 系统平台名称
+ */
+ public static final String SYSTEM_NAME = "意见收集小程序";
+
+ /**
+ * 短信签名
+ */
+ public static final String PHONE_HEAD = "【博诺思】";
+
+ /**
+ * 发送短信验证吗
+ * @param phone 手机号码
+ * @param msg 消息内容
+ * 如果msg不传 会使用默认值
+ * @return
+ */
+ public static Map sendPhoneMsg(String phone, String msg){
+ Map map=new HashMap<>(4);
+ map.put("phone",phone);
+ if (!isValidPhoneNumber(phone)) {
+ map.put("code","201");
+ map.put("msg","手机号格式错误,请输入11位数字号码");
+ }
+
+ StringBuilder sb=new StringBuilder();
+ sb.append(url).append("&mobile=").append(phone);
+ sb.append("&content=");
+ if(StringHelper.isNullOrEmptyString(msg)){
+ String code = getSixBitCode();
+ map.put("captcha",code);
+ sb.append(PHONE_HEAD);
+ sb.append("您正在进行短信验证,验证码:").append(code).append(",请在").append(TIMES).append("分钟内完成验证,切勿将验证码泄漏于他人。");
+ map.put("times",TIMES);
+ sb.append("发送时间:").append(DateUtils.getTime()).append("。(");
+ sb.append(SYSTEM_NAME).append(")");
+ }else{
+ sb.append(msg);
+ }
+ String body = HttpRequest.post(sb.toString()).execute(false).body();
+ if (body == null || !body.contains(STRING_OK)) {
+ map.put("code","201");
+ map.put("msg","短信发送失败");
+ }else{
+ ; map.put("code","200");
+ map.put("msg","发送成功");
+ }
+ return map;
+ }
+
+
+ public static boolean isValidPhoneNumber(String phoneNumber) {
+ // 定义中国的手机号正则表达式
+ String regex = "^1[3-9]\\d{9}$";
+ return phoneNumber.matches(regex);
+ }
+
+
+
+ private static String getSixBitCode() {
+ //随机数
+ Random random = new Random();
+ return String.valueOf(random.nextInt(900000) + 100000);
+ }
+
+
+}
diff --git a/src/main/resources/mapper/mysql/OptionMapper.xml b/src/main/resources/mapper/mysql/OptionMapper.xml
index 8af7cf8..ad9d102 100644
--- a/src/main/resources/mapper/mysql/OptionMapper.xml
+++ b/src/main/resources/mapper/mysql/OptionMapper.xml
@@ -209,6 +209,11 @@
from tb_task
where id=#{id} and del_flag=0
+
diff --git a/src/main/resources/templates/options/option_list.html b/src/main/resources/templates/options/option_list.html
index cabad3f..153166b 100644
--- a/src/main/resources/templates/options/option_list.html
+++ b/src/main/resources/templates/options/option_list.html
@@ -792,7 +792,7 @@
if(res.data){
console.log(res.data[0])
if(res.data.length<1){
- layer.msg("暂无图片");
+ layer.msg("暂无文件");
return false;
}
let src= res.data[nowIndex];
@@ -823,7 +823,7 @@
fileList=res.data
layer.open({
type: 1,
- title: '意见图片',
+ title: '意见文件',
closeBtn: true,
area: [x_l,'800px'],
content: $("#look_file_all")