'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; package com.ruoyi.web.controller.quot;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -375,68 +377,92 @@ public class QuotController extends BaseController
@PostMapping("/commitQuot") @PostMapping("/commitQuot")
public AjaxResult commitQuot(@RequestBody Quot quot) public AjaxResult commitQuot(@RequestBody Quot quot)
{ {
// 获取用户角色 --判断是否是核价组角色 try{
Boolean hjRoleFlag = false; // 获取用户角色 --判断是否是核价组角色
List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles(); Boolean hjRoleFlag = false;
for(SysRole sysRole:roles){ List<SysRole> roles = SecurityUtils.getLoginUser().getUser().getRoles();
String roleKey = sysRole.getRoleKey(); for(SysRole sysRole:roles){
if("PRICE_VERIFICATION".equals(roleKey) || "QUOT".equals(roleKey)){ String roleKey = sysRole.getRoleKey();
hjRoleFlag = true; if("PRICE_VERIFICATION".equals(roleKey) || "QUOT".equals(roleKey)){
break; hjRoleFlag = true;
break;
}
} }
} if(!hjRoleFlag){
if(!hjRoleFlag){ // 每天限制提交200条
// 每天限制提交200条 String quotCommitCount = configService.selectConfigByKey("quot.commit.count");
String quotCommitCount = configService.selectConfigByKey("quot.commit.count"); String count = quotService.selectQuotListCount();
String count = quotService.selectQuotListCount(); if(Integer.valueOf(count)>=Integer.valueOf(quotCommitCount)){
if(Integer.valueOf(count)>=Integer.valueOf(quotCommitCount)){ return error("当前报价量已达极限,无法继续提供报价单");
return error("当前报价量已达极限,无法继续提供报价单"); }
// 提交报价时间限制
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();
}
String quot_id = quot.getQuotId(); quot.setUpdateBy(getUsername());
quot.setQuotApprovalStatus("1");//报价单 状态设置为 协助中
quot.setQuotInquiryDate(DateUtils.getNowDate());//报价单 询价日期设置为 当前日期
quot.setUpdateBy(getUsername()); // 校验 是否已有重复报价单客户+项目名
quot.setQuotApprovalStatus("1");//报价单 状态设置为 协助中 Boolean flag = false;
quot.setQuotInquiryDate(DateUtils.getNowDate());//报价单 询价日期设置为 当前日期 if(!hjRoleFlag){
flag = quotService.checkExistQuot(getUsername(),quot.getQuotCustomerBm(),quot.getQuotProject());
// 校验 是否已有重复报价单客户+项目名
Boolean flag = false;
if(!hjRoleFlag){
flag = quotService.checkExistQuot(getUsername(),quot.getQuotCustomerBm(),quot.getQuotProject());
}else{
flag = quotService.checkExistQuot(quot.getQuotSalesmanCode(),quot.getQuotCustomerBm(),quot.getQuotProject());
}
if(flag){
return error("存在相同客户且项目名称一致的报价单,无法提交");
}
if(StringUtils.isEmpty(quot_id)){
quot.setQuotId(UUID.fastUUID().toString());
//quot.setQuotCode(IdUtils.createNo("BJD_",0));
String quotCode = quotService.getCode("BJD");
quot.setQuotCode(quotCode);
if(hjRoleFlag){
quot.setCreateBy(quot.getQuotSalesmanCode());
}else{ }else{
quot.setCreateBy(getUsername()); flag = quotService.checkExistQuot(quot.getQuotSalesmanCode(),quot.getQuotCustomerBm(),quot.getQuotProject());
} }
//quot.setQuotSalesmanCode(getUsername()); if(flag){
quotService.insertQuot(quot); return error("存在相同客户且项目名称一致的报价单,无法提交");
//sendNoticeToBjz(quot); }
return success();
}else{ if(StringUtils.isEmpty(quot_id)){
if(hjRoleFlag){ quot.setQuotId(UUID.fastUUID().toString());
quot.setUpdateBy(quot.getQuotSalesmanCode()); //quot.setQuotCode(IdUtils.createNo("BJD_",0));
String quotCode = quotService.getCode("BJD");
quot.setQuotCode(quotCode);
if(hjRoleFlag){
quot.setCreateBy(quot.getQuotSalesmanCode());
}else{
quot.setCreateBy(getUsername());
}
//quot.setQuotSalesmanCode(getUsername());
quotService.insertQuot(quot);
//sendNoticeToBjz(quot);
return success();
}else{ }else{
quot.setUpdateBy(getUsername()); if(hjRoleFlag){
quot.setUpdateBy(quot.getQuotSalesmanCode());
}else{
quot.setUpdateBy(getUsername());
}
quotService.updateQuot(quot);
//sendNoticeToBjz(quot);
return success();
} }
quotService.updateQuot(quot); }catch (Exception e){
//sendNoticeToBjz(quot); return error("系统异常");
return success();
} }
} }

View File

@ -5,7 +5,11 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.*; import java.time.*;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.time.DateFormatUtils; 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)); 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) { 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();
}
} }
} }