Merge branch 'dev/dev' into dev/dev_xp
This commit is contained in:
25
pom.xml
25
pom.xml
@@ -202,6 +202,31 @@
|
|||||||
<version>20230618</version>
|
<version>20230618</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi</artifactId>
|
||||||
|
<version>5.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.poi</groupId>
|
||||||
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
<version>5.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -2,12 +2,25 @@ package com.ai.da.common.config;
|
|||||||
|
|
||||||
import com.ai.da.common.utils.SendEmailUtil;
|
import com.ai.da.common.utils.SendEmailUtil;
|
||||||
import com.ai.da.mapper.primary.AccountMapper;
|
import com.ai.da.mapper.primary.AccountMapper;
|
||||||
|
import com.ai.da.mapper.primary.TrialOrderMapper;
|
||||||
import com.ai.da.mapper.primary.entity.Account;
|
import com.ai.da.mapper.primary.entity.Account;
|
||||||
|
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -16,6 +29,9 @@ public class MyTaskScheduler {
|
|||||||
@Resource
|
@Resource
|
||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TrialOrderMapper trialOrderMapper;
|
||||||
|
|
||||||
// 定时任务,每十五天执行一次
|
// 定时任务,每十五天执行一次
|
||||||
// @Scheduled(cron = "0 0 0 ? * MON")
|
// @Scheduled(cron = "0 0 0 ? * MON")
|
||||||
@Scheduled(cron = "0 0 0 */15 * ?")
|
@Scheduled(cron = "0 0 0 */15 * ?")
|
||||||
@@ -36,7 +52,7 @@ public class MyTaskScheduler {
|
|||||||
Long currentTimestamp = System.currentTimeMillis();
|
Long currentTimestamp = System.currentTimeMillis();
|
||||||
|
|
||||||
// 计算时间差(毫秒)
|
// 计算时间差(毫秒)
|
||||||
long timeDifference = timestamp - currentTimestamp;
|
long timeDifference = currentTimestamp - timestamp;
|
||||||
|
|
||||||
if (timeDifference < 0) {
|
if (timeDifference < 0) {
|
||||||
continue;
|
continue;
|
||||||
@@ -52,4 +68,65 @@ public class MyTaskScheduler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Scheduled(cron = "0 0 8 * * ?")
|
||||||
|
public void sendTrialOrderExcelToManagements() {
|
||||||
|
// 获取前一天日期
|
||||||
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||||
|
|
||||||
|
// 查询前一天的试用订单
|
||||||
|
QueryWrapper<TrialOrder> qw = new QueryWrapper<>();
|
||||||
|
qw.lambda().between(TrialOrder::getCreateTime, yesterday.atStartOfDay(), yesterday.atTime(23, 59, 59));
|
||||||
|
List<TrialOrder> trialOrders = trialOrderMapper.selectList(qw);
|
||||||
|
|
||||||
|
if (!trialOrders.isEmpty()) {
|
||||||
|
// 创建Excel工作簿
|
||||||
|
try (Workbook workbook = new XSSFWorkbook()) {
|
||||||
|
// 创建工作表
|
||||||
|
Sheet sheet = workbook.createSheet("Trial Orders");
|
||||||
|
// 创建标题行
|
||||||
|
Row headerRow = sheet.createRow(0);
|
||||||
|
headerRow.createCell(0).setCellValue("ID");
|
||||||
|
headerRow.createCell(1).setCellValue("Title");
|
||||||
|
headerRow.createCell(2).setCellValue("Surname");
|
||||||
|
headerRow.createCell(3).setCellValue("Given Name");
|
||||||
|
headerRow.createCell(4).setCellValue("Username");
|
||||||
|
headerRow.createCell(5).setCellValue("Email");
|
||||||
|
headerRow.createCell(6).setCellValue("Country");
|
||||||
|
headerRow.createCell(7).setCellValue("Occupation");
|
||||||
|
headerRow.createCell(8).setCellValue("Create Time");
|
||||||
|
headerRow.createCell(9).setCellValue("Update Time");
|
||||||
|
headerRow.createCell(10).setCellValue("Status");
|
||||||
|
|
||||||
|
// 填充数据
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
int rowNum = 1;
|
||||||
|
for (TrialOrder trialOrder : trialOrders) {
|
||||||
|
Row row = sheet.createRow(rowNum++);
|
||||||
|
row.createCell(0).setCellValue(trialOrder.getId());
|
||||||
|
row.createCell(1).setCellValue(trialOrder.getTitle());
|
||||||
|
row.createCell(2).setCellValue(trialOrder.getSurname());
|
||||||
|
row.createCell(3).setCellValue(trialOrder.getGivenName());
|
||||||
|
row.createCell(4).setCellValue(trialOrder.getUserName());
|
||||||
|
row.createCell(5).setCellValue(trialOrder.getEmail());
|
||||||
|
row.createCell(6).setCellValue(trialOrder.getCountry());
|
||||||
|
row.createCell(7).setCellValue(trialOrder.getOccupation());
|
||||||
|
row.createCell(8).setCellValue(trialOrder.getCreateTime().format(formatter));
|
||||||
|
row.createCell(9).setCellValue(trialOrder.getUpdateTime().format(formatter));
|
||||||
|
row.createCell(10).setCellValue(trialOrder.getStatus());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存Excel文件
|
||||||
|
String fileName = "trialOrder-" + yesterday.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + ".xlsx";
|
||||||
|
try (FileOutputStream fileOut = new FileOutputStream(fileName)) {
|
||||||
|
workbook.write(fileOut);
|
||||||
|
SendEmailUtil.sendExcelEmail("1023316923@qq.com", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||||
|
SendEmailUtil.sendExcelEmail("calvinwong@aidlab.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||||
|
SendEmailUtil.sendExcelEmail("kaicpang.pang@connect.polyu.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||||
|
SendEmailUtil.sendExcelEmail("kimwong@code-create.com.hk", null, Files.readAllBytes(Paths.get(fileName)), fileName);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|||||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||||
import com.tencentcloudapi.ses.v20201002.SesClient;
|
import com.tencentcloudapi.ses.v20201002.SesClient;
|
||||||
|
import com.tencentcloudapi.ses.v20201002.models.Attachment;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
import com.tencentcloudapi.ses.v20201002.models.SendEmailRequest;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
import com.tencentcloudapi.ses.v20201002.models.SendEmailResponse;
|
||||||
import com.tencentcloudapi.ses.v20201002.models.Template;
|
import com.tencentcloudapi.ses.v20201002.models.Template;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +132,9 @@ public class SendEmailUtil {
|
|||||||
private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L;
|
private final static Long YOUR_TRIAL_TEMPLATE_ID = 117214L;
|
||||||
private final static Long APPROVAL_TEMPLATE_ID = 117215L;
|
private final static Long APPROVAL_TEMPLATE_ID = 117215L;
|
||||||
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
private final static Long NOTIFICATION_TEMPLATE_ID = 117216L;
|
||||||
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType) {
|
private final static Long NOTIFICATION_CHINESE_TEMPLATE_ID = 122229L;
|
||||||
|
private final static Long TRIAL_ORDER_LIST_ID = 122273L;
|
||||||
|
public static void sendCustomEmail(String receiverAddress, String senderAddress, TrialOrder trialOrder, int emailType, String country) {
|
||||||
try {
|
try {
|
||||||
// 实例化一个认证对象
|
// 实例化一个认证对象
|
||||||
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||||
@@ -162,7 +166,11 @@ public class SendEmailUtil {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
subject = "Approval Confirmation for AiDA System Trial Access";
|
subject = "Approval Confirmation for AiDA System Trial Access";
|
||||||
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
if (country.equals("China")) {
|
||||||
|
template.setTemplateID(NOTIFICATION_CHINESE_TEMPLATE_ID);
|
||||||
|
}else {
|
||||||
|
template.setTemplateID(NOTIFICATION_TEMPLATE_ID);
|
||||||
|
}
|
||||||
template.setTemplateData(buildNotificationData(trialOrder));
|
template.setTemplateData(buildNotificationData(trialOrder));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -180,6 +188,45 @@ public class SendEmailUtil {
|
|||||||
throw new BusinessException("failed.to.send.mail");
|
throw new BusinessException("failed.to.send.mail");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendExcelEmail(String receiverAddress, String senderAddress, byte[] fileContent, String fileName) {
|
||||||
|
try {
|
||||||
|
// 实例化一个认证对象
|
||||||
|
Credential cred = new Credential(SECRET_ID, SECRET_KEy);
|
||||||
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
|
httpProfile.setEndpoint("ses.tencentcloudapi.com");
|
||||||
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
|
SesClient client = new SesClient(cred, "ap-hongkong", clientProfile);
|
||||||
|
SendEmailRequest req = new SendEmailRequest();
|
||||||
|
if (StringUtils.isEmpty(senderAddress)) {
|
||||||
|
senderAddress = SEND_ADDRESS;
|
||||||
|
}
|
||||||
|
req.setFromEmailAddress(senderAddress);
|
||||||
|
req.setDestination(new String[]{receiverAddress});
|
||||||
|
|
||||||
|
// 根据邮件类型设置不同的主题和模板
|
||||||
|
String subject = "";
|
||||||
|
Template template = new Template();
|
||||||
|
subject = "昨日试用订单数据";
|
||||||
|
template.setTemplateID(TRIAL_ORDER_LIST_ID);
|
||||||
|
|
||||||
|
req.setSubject(subject);
|
||||||
|
req.setTemplate(template);
|
||||||
|
|
||||||
|
Attachment attachment = new Attachment();
|
||||||
|
attachment.setFileName(fileName); // 设置附件文件名
|
||||||
|
// 设置附件内容
|
||||||
|
attachment.setContent(Base64.getEncoder().encodeToString(fileContent));
|
||||||
|
req.setAttachments(new Attachment[] {attachment});
|
||||||
|
// 发送邮件
|
||||||
|
SendEmailResponse resp = client.SendEmail(req);
|
||||||
|
log.info("短信发送结果res###{}", SendEmailResponse.toJsonString(resp));
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
log.info("邮件发送失败###{}", e.toString());
|
||||||
|
throw new BusinessException("failed.to.send.mail");
|
||||||
|
}
|
||||||
|
}
|
||||||
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
private final static Long WILLBEEXPIRED_TEMPLATE_ID = 118178L;
|
||||||
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
public static void sendWillBeExpiredEmail(Account account, String senderAddress) {
|
||||||
try {
|
try {
|
||||||
@@ -293,7 +340,7 @@ public class SendEmailUtil {
|
|||||||
// 根据邮件类型设置不同的主题和模板
|
// 根据邮件类型设置不同的主题和模板
|
||||||
String subject = "";
|
String subject = "";
|
||||||
Template template = new Template();
|
Template template = new Template();
|
||||||
subject = "Notice: AiDA 3.0 Website Maintenance Downtime";
|
subject = "Upcoming AiDA 3.0 Launch and Scheduled Maintenance";
|
||||||
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
template.setTemplateID(UPGRADE_NOTIFICATION_ID);
|
||||||
template.setTemplateData(buildAccountData(account));
|
template.setTemplateData(buildAccountData(account));
|
||||||
|
|
||||||
|
|||||||
@@ -35,10 +35,15 @@ public class Workspace implements Serializable {
|
|||||||
@ApiModelProperty(value = "工作空间名称")
|
@ApiModelProperty(value = "工作空间名称")
|
||||||
private String workSpaceName;
|
private String workSpaceName;
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* 用户名
|
||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "用户名")
|
@ApiModelProperty(value = "用户名")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "用户ID")
|
||||||
|
private Long accountId;
|
||||||
/**
|
/**
|
||||||
* 性别
|
* 性别
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -228,19 +228,28 @@ public class PythonService {
|
|||||||
long noPrintNum = 8 - pinPrintNum - noPinPrintNum;
|
long noPrintNum = 8 - pinPrintNum - noPinPrintNum;
|
||||||
elementVO.setNoPinPrintNum(noPinPrintNum);
|
elementVO.setNoPinPrintNum(noPinPrintNum);
|
||||||
|
|
||||||
int pinSketchNum = 0;
|
int[] sketchNumbers = new int[3];
|
||||||
int sysSketchNum = 0;
|
|
||||||
int noPinSketchNum = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, pinSketchNum, sysSketchNum, noPinSketchNum, systemScale);
|
CurrentDesignPictureTypeEnum designPictureType = calculateCurrentDesignPictureTypeNew(elementVO, sketchNumbers, systemScale);
|
||||||
if (designPictureType == null) break;
|
if (designPictureType == null) break;
|
||||||
|
|
||||||
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
CurrentDesignPrintPictureTypeEnum designPrintPictureType = calculateCurrentDesignPintPictureType(pinPrintNum, noPinPrintNum, noPrintNum);
|
||||||
if (designPrintPictureType == null) break;
|
if (designPrintPictureType == null) break;
|
||||||
|
|
||||||
updateSketchNumbers(designPictureType, pinSketchNum, sysSketchNum, noPinSketchNum);
|
updateSketchNumbers(designPictureType, sketchNumbers);
|
||||||
updatePrintNumbers(designPrintPictureType, pinPrintNum, noPinPrintNum, noPrintNum);
|
switch (designPrintPictureType) {
|
||||||
|
case PIN:
|
||||||
|
pinPrintNum--;
|
||||||
|
break;
|
||||||
|
case NO_PIN:
|
||||||
|
noPinPrintNum--;
|
||||||
|
break;
|
||||||
|
case NO:
|
||||||
|
noPrintNum--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// updatePrintNumbers(designPrintPictureType, pinPrintNum, noPinPrintNum, noPrintNum);
|
||||||
|
|
||||||
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
DesignPythonItemPrint designPythonItemPrint = getRandomPrint(elementVO, designPrintPictureType);
|
||||||
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
elementVO.setDesignPythonItemPrint(designPythonItemPrint);
|
||||||
@@ -252,16 +261,16 @@ public class PythonService {
|
|||||||
return designPythonObjects;
|
return designPythonObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSketchNumbers(CurrentDesignPictureTypeEnum designPictureType, int pinSketchNum, int sysSketchNum, int noPinSketchNum) {
|
private void updateSketchNumbers(CurrentDesignPictureTypeEnum designPictureType, int[] sketchNumbers) {
|
||||||
switch (designPictureType) {
|
switch (designPictureType) {
|
||||||
case PIN:
|
case PIN:
|
||||||
pinSketchNum++;
|
sketchNumbers[0] ++;
|
||||||
break;
|
break;
|
||||||
case NO_PIN:
|
case NO_PIN:
|
||||||
noPinSketchNum--;
|
sketchNumbers[2] --;
|
||||||
break;
|
break;
|
||||||
case SYS_FILE:
|
case SYS_FILE:
|
||||||
sysSketchNum--;
|
sketchNumbers[1] --;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,16 +297,24 @@ public class PythonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int pinSketchNum, int sysSketchNum, int noPinSketchNum, BigDecimal systemScale) {
|
private CurrentDesignPictureTypeEnum calculateCurrentDesignPictureTypeNew(ValidateElementVO elementVO, int[] sketchNumbers, BigDecimal systemScale) {
|
||||||
List<CollectionElement> pinData = getPinData(elementVO);
|
List<CollectionElement> pinData = getPinData(elementVO);
|
||||||
if (CollectionUtil.isNotEmpty(pinData)) {
|
if (CollectionUtil.isNotEmpty(pinData)) {
|
||||||
return CurrentDesignPictureTypeEnum.PIN;
|
return CurrentDesignPictureTypeEnum.PIN;
|
||||||
} else {
|
} else {
|
||||||
if (sysSketchNum == 0 && noPinSketchNum == 0) {
|
if (sketchNumbers[1] == 0 && sketchNumbers[2] == 0) {
|
||||||
sysSketchNum = systemScale.multiply(BigDecimal.valueOf(8 - pinSketchNum)).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
sketchNumbers[1] = systemScale.multiply(BigDecimal.valueOf(8 - sketchNumbers[0])).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
|
||||||
noPinSketchNum = 8 - pinSketchNum - sysSketchNum;
|
sketchNumbers[2] = 8 - sketchNumbers[0] - sketchNumbers[1];
|
||||||
}
|
}
|
||||||
if (noPinSketchNum > 0) {
|
if (sketchNumbers[2] > 0 && sketchNumbers[1] > 0) {
|
||||||
|
Long l = RandomsUtil.randomSysFile(0l, 2l);
|
||||||
|
if (l == 0l) {
|
||||||
|
return CurrentDesignPictureTypeEnum.NO_PIN;
|
||||||
|
}else {
|
||||||
|
return CurrentDesignPictureTypeEnum.SYS_FILE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sketchNumbers[2] > 0) {
|
||||||
return CurrentDesignPictureTypeEnum.NO_PIN;
|
return CurrentDesignPictureTypeEnum.NO_PIN;
|
||||||
}
|
}
|
||||||
return CurrentDesignPictureTypeEnum.SYS_FILE;
|
return CurrentDesignPictureTypeEnum.SYS_FILE;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
@Transactional
|
@Transactional
|
||||||
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
|
public AccountPreLoginVO preLogin(AccountPreLoginDTO accountDTO) {
|
||||||
log.info("aida预先登入accountDTO###{}", JSON.toJSONString(accountDTO));
|
log.info("aida预先登入accountDTO###{}", JSON.toJSONString(accountDTO));
|
||||||
Account account = getOneByUserName(accountDTO.getUserName());
|
Account account = getOneByEmail(accountDTO.getEmail());
|
||||||
//用户有效期校验
|
//用户有效期校验
|
||||||
validateUserValidaExpire(account);
|
validateUserValidaExpire(account);
|
||||||
if ("Third-000000".equals(account.getUserPassword())) {
|
if ("Third-000000".equals(account.getUserPassword())) {
|
||||||
@@ -287,8 +287,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
|
|
||||||
private Account getOneByEmail(String email) {
|
private Account getOneByEmail(String email) {
|
||||||
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<Account> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.lambda().eq(Account::getUserEmail, email);
|
queryWrapper.eq("BINARY user_email", email);
|
||||||
queryWrapper.lambda().last("limit 1");
|
|
||||||
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
List<Account> accountList = accountMapper.selectList(queryWrapper);
|
||||||
if (CollectionUtil.isEmpty(accountList)) {
|
if (CollectionUtil.isEmpty(accountList)) {
|
||||||
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("email.does.not.exist", ResultEnum.PROMPT.getCode());
|
||||||
@@ -471,28 +470,27 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
String ipAddress = RequestInfoUtil.getIpAddress(request);
|
||||||
// 先检测试用订单
|
// 先检测试用订单
|
||||||
QueryWrapper<TrialOrder> trialOrderQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<TrialOrder> trialOrderQueryWrapper = new QueryWrapper<>();
|
||||||
trialOrderQueryWrapper.lambda().eq(TrialOrder::getIp, ipAddress);
|
trialOrderQueryWrapper.eq("BINARY email", accountTrialDTO.getEmail());
|
||||||
trialOrderQueryWrapper.lambda().and(wrapper ->
|
// trialOrderQueryWrapper.lambda().eq(TrialOrder::getIp, ipAddress);
|
||||||
wrapper.eq(TrialOrder::getEmail, accountTrialDTO.getEmail())
|
// trialOrderQueryWrapper.lambda().and(wrapper ->
|
||||||
.or() // OR
|
// wrapper.eq(TrialOrder::getEmail, accountTrialDTO.getEmail())
|
||||||
.like(TrialOrder::getUserName, accountTrialDTO.getUserName()));
|
// .or() // OR
|
||||||
|
// .like(TrialOrder::getUserName, accountTrialDTO.getUserName()));
|
||||||
List<TrialOrder> trialOrders = trialOrderMapper.selectList(trialOrderQueryWrapper);
|
List<TrialOrder> trialOrders = trialOrderMapper.selectList(trialOrderQueryWrapper);
|
||||||
if (CollectionUtil.isNotEmpty(trialOrders)) {
|
if (CollectionUtil.isNotEmpty(trialOrders)) {
|
||||||
throw new BusinessException("You have submitted a trial application, please wait for approval.");
|
throw new BusinessException("You have submitted a trial application, please wait for approval.");
|
||||||
}
|
}
|
||||||
// 先检测用户名和邮箱
|
// 先检测用户名和邮箱
|
||||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Account::getUserEmail, accountTrialDTO.getEmail())
|
qw.eq("BINARY email", accountTrialDTO.getEmail());
|
||||||
.or()
|
|
||||||
.eq(Account::getUserName, accountTrialDTO.getUserName());
|
|
||||||
List<Account> accountList = accountMapper.selectList(qw);
|
List<Account> accountList = accountMapper.selectList(qw);
|
||||||
if (CollectionUtil.isNotEmpty(accountList)) {
|
if (CollectionUtil.isNotEmpty(accountList)) {
|
||||||
if (accountList.get(0).getIsTrial() == 1) {
|
if (accountList.get(0).getIsTrial() == 1) {
|
||||||
throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("The email has already been registered", ResultEnum.PROMPT.getCode());
|
||||||
}else {
|
}else {
|
||||||
Account account = accountList.get(0);
|
Account account = accountList.get(0);
|
||||||
if (null == account.getValidEndTime() || account.getValidEndTime() > System.currentTimeMillis()) {
|
if (null == account.getValidEndTime() || account.getValidEndTime() > System.currentTimeMillis()) {
|
||||||
throw new BusinessException("The username or email has already been registered", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("The email has already been registered", ResultEnum.PROMPT.getCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -502,9 +500,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
trialOrder.setStatus(0);
|
trialOrder.setStatus(0);
|
||||||
trialOrder.setIp(ipAddress);
|
trialOrder.setIp(ipAddress);
|
||||||
trialOrderMapper.insert(trialOrder);
|
trialOrderMapper.insert(trialOrder);
|
||||||
SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,1);
|
// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,1);
|
||||||
SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,1);
|
// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,1);
|
||||||
SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,1);
|
// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,1);
|
||||||
// 判断当前的试用订单是否自动批准
|
// 判断当前的试用订单是否自动批准
|
||||||
if (AutoApproved.getStatus()) {
|
if (AutoApproved.getStatus()) {
|
||||||
// 改变试用订单状态,新增试用用户
|
// 改变试用订单状态,新增试用用户
|
||||||
@@ -532,10 +530,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
accountMapper.insert(account);
|
accountMapper.insert(account);
|
||||||
}
|
}
|
||||||
// 发送邮件提醒用户试用用户已创建
|
// 发送邮件提醒用户试用用户已创建
|
||||||
SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3);
|
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||||
}
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
@@ -556,9 +554,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
trialOrderMapper.updateById(trialOrder);
|
trialOrderMapper.updateById(trialOrder);
|
||||||
|
|
||||||
QueryWrapper<Account> qw = new QueryWrapper<>();
|
QueryWrapper<Account> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Account::getUserEmail, trialOrder.getEmail())
|
qw.eq("BINARY email", trialOrder.getEmail());
|
||||||
.or()
|
|
||||||
.eq(Account::getUserName, trialOrder.getUserName());
|
|
||||||
List<Account> accountList = accountMapper.selectList(qw);
|
List<Account> accountList = accountMapper.selectList(qw);
|
||||||
|
|
||||||
Account account = new Account();
|
Account account = new Account();
|
||||||
@@ -582,10 +578,10 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
accountMapper.insert(account);
|
accountMapper.insert(account);
|
||||||
}
|
}
|
||||||
// 发送邮件提醒用户试用用户已创建
|
// 发送邮件提醒用户试用用户已创建
|
||||||
SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("1023316923@qq.com", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("calvinwong@aidlab.hk", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2);
|
// SendEmailUtil.sendCustomEmail("kaicpang.pang@connect.polyu.hk", null, trialOrder,2);
|
||||||
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3);
|
SendEmailUtil.sendCustomEmail(account.getUserEmail(), null, trialOrder, 3, trialOrder.getCountry());
|
||||||
}
|
}
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ public class LibraryServiceImpl extends ServiceImpl<LibraryMapper, Library> impl
|
|||||||
public void checkModel(String value, List<Long> modelIds, Integer deleteModelConfirm) {
|
public void checkModel(String value, List<Long> modelIds, Integer deleteModelConfirm) {
|
||||||
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
AuthPrincipalVo authPrincipalVo = UserContext.getUserHolder();
|
||||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Workspace::getUserName, authPrincipalVo.getUsername());
|
qw.lambda().eq(Workspace::getAccountId, authPrincipalVo.getId());
|
||||||
if (value.equals(Sex.FEMALE.getValue())) {
|
if (value.equals(Sex.FEMALE.getValue())) {
|
||||||
qw.lambda().in(Workspace::getMannequinFemaleId, modelIds);
|
qw.lambda().in(Workspace::getMannequinFemaleId, modelIds);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
// 防止前端传值修改标识
|
// 防止前端传值修改标识
|
||||||
workspace.setIsLastIndex(null);
|
workspace.setIsLastIndex(null);
|
||||||
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
AuthPrincipalVo userInfo = UserContext.getUserHolder();
|
||||||
workspace.setUserName(userInfo.getUsername());
|
workspace.setAccountId(userInfo.getId());
|
||||||
checkWorkspaceName(workspace.getId(), workspace.getWorkSpaceName(), userInfo.getUsername());
|
checkWorkspaceName(workspace.getId(), workspace.getWorkSpaceName(), userInfo.getId());
|
||||||
if (null == workspace.getId()) {
|
if (null == workspace.getId()) {
|
||||||
workspace.setIsLastIndex(0);
|
workspace.setIsLastIndex(0);
|
||||||
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||||
@@ -123,11 +123,11 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkWorkspaceName(Long id, String workSpaceName, String userName) {
|
private void checkWorkspaceName(Long id, String workSpaceName, Long accountId) {
|
||||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||||
qw.lambda().ne(null != id, Workspace::getId, id);
|
qw.lambda().ne(null != id, Workspace::getId, id);
|
||||||
qw.lambda().eq(Workspace::getWorkSpaceName, workSpaceName);
|
qw.lambda().eq(Workspace::getWorkSpaceName, workSpaceName);
|
||||||
qw.lambda().eq(Workspace::getUserName, userName);
|
qw.lambda().eq(Workspace::getAccountId, accountId);
|
||||||
List<Workspace> workspaces = baseMapper.selectList(qw);
|
List<Workspace> workspaces = baseMapper.selectList(qw);
|
||||||
if (!CollectionUtils.isEmpty(workspaces)) {
|
if (!CollectionUtils.isEmpty(workspaces)) {
|
||||||
throw new BusinessException("the.workspaceName.already.exists", ResultEnum.PROMPT.getCode());
|
throw new BusinessException("the.workspaceName.already.exists", ResultEnum.PROMPT.getCode());
|
||||||
@@ -137,9 +137,9 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
@Override
|
@Override
|
||||||
public WorkspaceVO getPage(WorkspaceDTO query) {
|
public WorkspaceVO getPage(WorkspaceDTO query) {
|
||||||
WorkspaceVO vo = new WorkspaceVO();
|
WorkspaceVO vo = new WorkspaceVO();
|
||||||
String userName = UserContext.getUserHolder().getUsername();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
QueryWrapper<Workspace> qw = new QueryWrapper<>();
|
||||||
qw.lambda().eq(Workspace::getUserName, userName);
|
qw.lambda().eq(Workspace::getAccountId, accountId);
|
||||||
IPage<Workspace> page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
IPage<Workspace> page = workspaceMapper.selectPage(new Page<>(query.getPage(), query.getSize()), qw);
|
||||||
if (page.getTotal() == 0L) {
|
if (page.getTotal() == 0L) {
|
||||||
// 给用户新建默认workspace
|
// 给用户新建默认workspace
|
||||||
@@ -148,7 +148,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
workspace.setSex(Sex.FEMALE.getValue());
|
workspace.setSex(Sex.FEMALE.getValue());
|
||||||
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
workspace.setSystemDesignerPercentage(SYSTEM_DESIGNER_PERCENTAGE);
|
||||||
workspace.setPosition("Overall");
|
workspace.setPosition("Overall");
|
||||||
workspace.setUserName(userName);
|
workspace.setAccountId(accountId);
|
||||||
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
QueryWrapper<SysFile> systemFemaleQw = new QueryWrapper<>();
|
||||||
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
systemFemaleQw.lambda().eq(SysFile::getLevel1Type, "Models");
|
||||||
systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
systemFemaleQw.lambda().eq(SysFile::getLevel2Type, "Female");
|
||||||
@@ -225,7 +225,7 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
);
|
);
|
||||||
vo.setPage(PageBaseResponse.success(convert));
|
vo.setPage(PageBaseResponse.success(convert));
|
||||||
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
|
QueryWrapper<Workspace> qwIsLastIndex = new QueryWrapper<>();
|
||||||
qwIsLastIndex.lambda().eq(Workspace::getUserName, userName);
|
qwIsLastIndex.lambda().eq(Workspace::getAccountId, accountId);
|
||||||
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
qwIsLastIndex.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||||
qwIsLastIndex.last("limit 1");
|
qwIsLastIndex.last("limit 1");
|
||||||
List<Workspace> workspaces = workspaceMapper.selectList(qwIsLastIndex);
|
List<Workspace> workspaces = workspaceMapper.selectList(qwIsLastIndex);
|
||||||
@@ -250,9 +250,9 @@ public class WorkspaceServiceImpl extends ServiceImpl<WorkspaceMapper, Workspace
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Workspace getByIdNew(Long id) {
|
public Workspace getByIdNew(Long id) {
|
||||||
String userName = UserContext.getUserHolder().getUsername();
|
Long accountId = UserContext.getUserHolder().getId();
|
||||||
QueryWrapper<Workspace> qwOld = new QueryWrapper<>();
|
QueryWrapper<Workspace> qwOld = new QueryWrapper<>();
|
||||||
qwOld.lambda().eq(Workspace::getUserName, userName);
|
qwOld.lambda().eq(Workspace::getAccountId, accountId);
|
||||||
qwOld.lambda().eq(Workspace::getIsLastIndex, 1);
|
qwOld.lambda().eq(Workspace::getIsLastIndex, 1);
|
||||||
Workspace oldIsLastIndex = workspaceMapper.selectOne(qwOld);
|
Workspace oldIsLastIndex = workspaceMapper.selectOne(qwOld);
|
||||||
oldIsLastIndex.setIsLastIndex(0);
|
oldIsLastIndex.setIsLastIndex(0);
|
||||||
|
|||||||
@@ -7,12 +7,17 @@
|
|||||||
<id column="id" property="id"/>
|
<id column="id" property="id"/>
|
||||||
<result column="work_space_name" property="workSpaceName"/>
|
<result column="work_space_name" property="workSpaceName"/>
|
||||||
<result column="user_name" property="userName"/>
|
<result column="user_name" property="userName"/>
|
||||||
|
<result column="account_id" property="accountId"/>
|
||||||
<result column="sex" property="sex"/>
|
<result column="sex" property="sex"/>
|
||||||
<result column="position" property="position"/>
|
<result column="position" property="position"/>
|
||||||
<result column="system_designer_percentage" property="systemDesignerPercentage"/>
|
<result column="system_designer_percentage" property="systemDesignerPercentage"/>
|
||||||
<result column="mannequinId" property="mannequin"/>
|
<result column="mannequin_female_id" property="mannequinFemaleId"/>
|
||||||
<result column="mannequinUrl" property="mannequin"/>
|
<result column="mannequin_female_type" property="mannequinFemaleType"/>
|
||||||
<result column="mannequinType" property="mannequin"/>
|
<result column="mannequin_male_id" property="mannequinMaleId"/>
|
||||||
|
<result column="mannequin_male_type" property="mannequinMaleType"/>
|
||||||
|
<result column="mannequin_child_id" property="mannequinChildId"/>
|
||||||
|
<result column="mannequin_child_type" property="mannequinChildType"/>
|
||||||
|
<result column="is_last_index" property="isLastIndex"/>
|
||||||
<result column="create_time" property="createTime"/>
|
<result column="create_time" property="createTime"/>
|
||||||
<result column="update_time" property="updateTime"/>
|
<result column="update_time" property="updateTime"/>
|
||||||
<result column="is_deleted" property="isDeleted"/>
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user