'123123123'

This commit is contained in:
xd 2024-06-19 17:06:26 +08:00
parent 19962d419b
commit ecd5881b10
2 changed files with 155 additions and 54 deletions

View File

@ -1,7 +1,9 @@
package com.ruoyi.web.controller.quot;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
@ -375,6 +377,7 @@ public class QuotController extends BaseController
@PostMapping("/commitQuot")
public AjaxResult commitQuot(@RequestBody Quot quot)
{
try{
// 获取用户角色 --判断是否是核价组角色
Boolean hjRoleFlag = false;
List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
@ -394,6 +397,26 @@ public class QuotController extends BaseController
}
// 提交报价时间限制
String commitQuotTime = configService.selectConfigByKey("quot.allow.commitQuotTime");
if(commitQuotTime.indexOf("-")<0){
return error("提交报价时间限制系统参数错误,格式不规范");
}
String startTime = commitQuotTime.split("-")[0];
String endTime = commitQuotTime.split("-")[1];
if(!DateUtils.isMatch(startTime) || !DateUtils.isMatch(endTime)){
return error("提交报价时间限制系统参数错误,格式不规范");
}
//当前时间
Date date = new Date();
String currentTime = new SimpleDateFormat("HH:mm:ss").format(date);
Date nowTime = new SimpleDateFormat("HH:mm:ss").parse(currentTime);
Date startTimeD = new SimpleDateFormat("HH:mm:ss").parse(startTime);
Date endTimeE = new SimpleDateFormat("HH:mm:ss").parse(endTime);
Boolean flag = DateUtils.isEffectiveDate(nowTime,startTimeD,endTimeE);
if(!flag){
return error("已超过提交报价限制时间【"+commitQuotTime+"】,无法继续提交");
}
}
String quot_id = quot.getQuotId();
@ -438,6 +461,9 @@ public class QuotController extends BaseController
//sendNoticeToBjz(quot);
return success();
}
}catch (Exception e){
return error("系统异常");
}
}
/**

View File

@ -5,7 +5,11 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.time.DateFormatUtils;
/**
@ -204,8 +208,79 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return Integer.parseInt(String.valueOf(secondsLeft));
}
/**
* 判断当前时间是否在[startTime, endTime]区间注意时间格式要一致
*
* @param nowTime 当前时间
* @param startTime 开始时间
* @param endTime 结束时间
* @return
*/
public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
if (nowTime.getTime() == startTime.getTime()
|| nowTime.getTime() == endTime.getTime()) {
return true;
}
Calendar date = Calendar.getInstance();
date.setTime(nowTime);
Calendar begin = Calendar.getInstance();
begin.setTime(startTime);
Calendar end = Calendar.getInstance();
end.setTime(endTime);
if (date.after(begin) && date.before(end)) {
return true;
} else {
return false;
}
}
/**
* 是否满足时分秒时间格式
* @param inputString
* @return
*/
public static boolean isMatch(String inputString) {
String timeRegex = "^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$";
Pattern pattern = Pattern.compile(timeRegex);
Matcher matcher = pattern.matcher(inputString);
return matcher.matches();
}
public static void main(String[] args) {
System.out.println(secondsUntilMidnight());
try{
String format = "HH:mm:ss";
Date date = new Date();
String currentTime = new SimpleDateFormat(format).format(date);
Date nowTime = new SimpleDateFormat(format).parse(currentTime);
Date startTime = new SimpleDateFormat(format).parse("7:00:00");
Date endTime = new SimpleDateFormat(format).parse("19:00:00");
System.out.println(isEffectiveDate(nowTime, startTime, endTime));
String inputString = "7:34:56";
String timeRegex = "^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$";
Pattern pattern = Pattern.compile(timeRegex);
Matcher matcher = pattern.matcher(inputString);
if (matcher.matches()) {
System.out.println("输入的字符串是时分秒格式");
} else {
System.out.println("输入的字符串不是时分秒格式");
}
}catch (Exception e){
e.printStackTrace();
}
}
}