save code

This commit is contained in:
xsl
2025-12-25 09:57:56 +08:00
commit b86860da8d
549 changed files with 52970 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
/digital-common/digital-base/target/
/digital-common/digital-util/target/
/digital-common/digital-config/target/
digital-common/digital-bean/target/
digital-application/target/
digital-system/target/
.idea
+36
View File
@@ -0,0 +1,36 @@
# digital-cloth-backend-service
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
+39
View File
@@ -0,0 +1,39 @@
# digital-cloth-backend-service
#### 介绍
{**以下是 Gitee 平台说明,您可以替换此简介**
Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台
无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)}
#### 软件架构
软件架构说明
#### 安装教程
1. xxxx
2. xxxx
3. xxxx
#### 使用说明
1. xxxx
2. xxxx
3. xxxx
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
+188
View File
@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jeecg-boot-parent</artifactId>
<groupId>org.jeecgframework.boot</groupId>
<version>3.2.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>digital-application</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!-- mp3文件支持(如语音时长)-->
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.1</version>
</dependency>
<!-- mp4文件支持(如语音时长)-->
<dependency>
<groupId>com.googlecode.mp4parser</groupId>
<artifactId>isoparser</artifactId>
<version>1.1.22</version>
</dependency>
<!-- 录音文件识别请求-->
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java-asr</artifactId>
<version>3.1.957</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>6.0</version>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
<!--springboot2.3+ 需引入validation对应的包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>digital-util</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>digital-base</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.volcengine</groupId>
<artifactId>volcengine-java-sdk-vpc</artifactId>
<version>0.1.142</version>
</dependency>
<dependency>
<groupId>com.volcengine</groupId>
<artifactId>volcengine-java-sdk-ecs</artifactId>
<version>0.1.142</version>
</dependency>
<dependency>
<groupId>com.volcengine</groupId>
<artifactId>ve-tos-java-sdk</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>digital-bean</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>digital-config</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java-live</artifactId>
<version>3.1.956</version>
</dependency>
<dependency>
<groupId>org.jeecgframework.boot</groupId>
<artifactId>digital-system</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<!-- 数据库驱动 -->
<!--mysql-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java.version}</version>
<scope>runtime</scope>
</dependency>
<!--集成springmvc框架 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.22</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
<!--微服务模式下修改为true,跳过此打包插件,否则微服务模块无法引用-->
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>digital.application.DigitalApplication</mainClass> <!-- 此处为主入口-->
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,53 @@
package digital.application;
import digital.util.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* 单体启动类(采用此类启动为单体模式)
* 特别提醒:
* 1.需要集成mongodb请删除 exclude={MongoAutoConfiguration.class}
* 2.切换微服务 勾选profile的SpringCloud,这个类就无法启动,启动会报错
*/
@Slf4j
@EnableScheduling
@SpringBootApplication(exclude = {RedisAutoConfiguration.class})
@ComponentScan(basePackages = {"digital"})
@EnableAsync
@EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
public class DigitalApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DigitalApplication.class);
}
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext application = SpringApplication.run(DigitalApplication.class, args);
Environment env = application.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
log.info("\n----------------------------------------------------------\n\t" +
"Application digital is running! Access URLs:\n\t" +
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
}
@@ -0,0 +1,38 @@
package digital.application.ScheduleTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
@Slf4j
public class ClothTaskExecutor {
@Autowired
private ClothTaskService clothTaskService;
@PostConstruct
public void init() {
// 使用自定义的ThreadFactory来设置线程名字
// 使用线程池执行任务处理线程
ExecutorService executorService = Executors.newSingleThreadExecutor();
// 任务处理线程1
executorService.execute(() -> {
try {
log.info("启动==换装==处理线程..." + Thread.currentThread().getName());
if (clothTaskService != null) {
clothTaskService.startClothProcessingTasks();
} else {
log.error("taskService 为 null,无法启动任务处理");
}
} catch (Exception e) {
log.error("任务==换装==处理线程启动失败", e);
}
});
// 关闭线程池(应用关闭时)
// executorService.shutdown();
}
}
@@ -0,0 +1,168 @@
package digital.application.ScheduleTask;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import digital.application.entity.SysHistory;
import digital.application.entity.SysTaskQueue;
import digital.application.mapper.MwTrainTaskMapper;
import digital.application.mapper.SysHistoryMapper;
import digital.application.service.SysTaskQueueService;
import digital.base.constant.CommonConstant;
import digital.base.constant.Face3dSeverHTTPConstant;
import digital.base.constant.ZitaCommonConstant;
import digital.bean.task.MwTrainTask;
import digital.config.oss.OssConfiguration;
import digital.util.oss.OssBootUtil;
import digital.util.util.RestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import java.util.concurrent.*;
@Component
@Slf4j
public class ClothTaskService {
@Autowired
OssConfiguration ossConfiguration;
@Autowired
private SysTaskQueueService sysTaskQueueService;
@Autowired
private MwTrainTaskMapper trainTaskMapper;
@Autowired
private SysHistoryMapper sysHistoryMapper;
private ScheduledExecutorService executorService;
private BlockingQueue<SysTaskQueue> clothTaskQueue = new LinkedBlockingQueue<>();
public ClothTaskService() {
this.executorService = Executors.newSingleThreadScheduledExecutor();
}
@Scheduled(fixedRate = 3000) // 每隔3秒执行一次
@Transactional
public synchronized void pollClothTaskTable() {
String taskId = UUID.randomUUID().toString();
QueryWrapper<SysTaskQueue> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_SINGLE)
.and(wrapper -> wrapper.isNull(SysTaskQueue::getTryOnAlgo)
.or().eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TRY_ON_TYPE_ALGO_CLOTH))
.last("LIMIT 1"); // 添加这个条件来限制查询结果为1条
// log.info(Thread.currentThread().getName() + "放入【换装】队列前,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
SysTaskQueue sysTaskQueue = sysTaskQueueService.getOne(queryWrapper);
if (null == sysTaskQueue) {
QueryWrapper<SysTaskQueue> qw = new QueryWrapper<>();
qw.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_BATCH)
.and(wrapper -> wrapper.isNull(SysTaskQueue::getTryOnAlgo)
.or().eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TRY_ON_TYPE_ALGO_CLOTH)) // 假设 "cloth" 是你要比较的值
.last("LIMIT 1"); // 限制只返回一条记录
sysTaskQueue = sysTaskQueueService.getOne(qw);
}
if (sysTaskQueue != null && clothTaskQueue.size() < 1) {
clothTaskQueue.offer(sysTaskQueue);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
sysTaskQueueService.updateById(sysTaskQueue);
}
// log.info(Thread.currentThread().getName() + " 放入【换装】队列后,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
}
public void startClothProcessingTasks() {
executorService.scheduleAtFixedRate(() -> {
// log.info("当前【换装】队列大小=" + clothTaskQueue.size());
SysTaskQueue clothTask = clothTaskQueue.poll();
// log.info("当前【换装】队列大小=" + clothTaskQueue.size());
if (clothTask != null) {
// 执行任务
processTask(clothTask);
}
}, 0, 3, TimeUnit.SECONDS);
}
private synchronized void processTask(SysTaskQueue sysTaskQueue) {
String taskId = sysTaskQueue.getTaskId();
long startTime = System.currentTimeMillis();
log.info(Thread.currentThread().getName() + " 开始【换装】=========================================taskId==" + taskId + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
String jsonInfo = sysTaskQueue.getJsonInfo();
JSONObject clothParam = JSON.parseObject(jsonInfo);
MwTrainTask trainTask = trainTaskMapper.selectOne(new QueryWrapper<MwTrainTask>().lambda().eq(MwTrainTask::getTaskId, taskId));
//防止数据删除空指针
SysHistory sysHistory = sysHistoryMapper.selectHistoryOne(taskId);
try {
String url;
if (ZitaCommonConstant.sex_male.equals(sysTaskQueue.getSex())) {
url = Face3dSeverHTTPConstant.SWAP_CLOTH_MALE;
} else {
url = Face3dSeverHTTPConstant.SWAP_CLOTH;
}
ResponseEntity<JSONObject> clothResult = RestUtil.zitaRequest(url,
HttpMethod.POST, null, clothParam, JSONObject.class);
String clothState = clothResult.getBody().get("status").toString();
log.info(taskId + " 返回结果信息成功 ==" + taskId + " clothResult=" + clothResult.getBody());
if (!ZitaCommonConstant.STATUS_NORMAL.equals(clothState)) {
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult(String.format("digital cloth 【换装】任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
trainTaskMapper.updateById(trainTask);
log.info(String.format("digital cloth 【换装】任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
// 尝试将返回结果转为JSON
JSONObject resultBody = clothResult.getBody();
String imagePath = (String) resultBody.get("data");
File file = new File(imagePath);
String newFileName = UUID.randomUUID().toString() + file.getName().substring(file.getName().lastIndexOf("."));
String fileUrl = OssBootUtil.uploadOssVideo(file, CommonConstant.PUTON_SWAP, newFileName);
String savePath = OssBootUtil.getDigitalObjectURL(ossConfiguration.getBucketName(), fileUrl, null);
trainTask.setResultImages(savePath);
trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
trainTask.setResult(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000; // 除以1000,将毫秒转换为秒
trainTask.setCostTime((int) duration);
trainTaskMapper.updateById(trainTask);
//替换换装后的照片
sysHistory.setFileUrl(savePath);
sysHistory.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysTaskQueueService.updateById(sysTaskQueue);
} catch (Exception ex) {
String message = ex.getMessage();
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult("digital cloth 【换装】失败!" + String.format("%s {taskId: %s}", message, taskId));
trainTaskMapper.updateById(trainTask);
log.error("digital cloth 【换装】任务失败!" + String.format("%s {taskId: %s}", message, taskId));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
log.info(Thread.currentThread().getName() + "结束【换装】=========================================" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
}
@@ -0,0 +1,39 @@
package digital.application.ScheduleTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
@Slf4j
public class FigureTaskExecutor {
@Autowired
private FigureTaskService figureTaskService;
@PostConstruct
public void init() {
// 使用自定义的ThreadFactory来设置线程名字
// 使用线程池执行任务处理线程
ExecutorService executorService = Executors.newSingleThreadExecutor();
// 任务处理线程1
executorService.execute(() -> {
try {
log.info("启动==换身材==处理线程..." + Thread.currentThread().getName());
if (figureTaskService != null) {
figureTaskService.startClothProcessingTasks();
} else {
log.error("换身材 taskService 为 null,无法启动任务处理");
}
} catch (Exception e) {
log.error("任务==换身材==处理线程启动失败", e);
}
});
// 关闭线程池(应用关闭时)
// executorService.shutdown();
}
}
@@ -0,0 +1,160 @@
package digital.application.ScheduleTask;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import digital.application.entity.SysHistory;
import digital.application.entity.SysTaskQueue;
import digital.application.mapper.MwTrainTaskMapper;
import digital.application.mapper.SysHistoryMapper;
import digital.application.service.SysTaskQueueService;
import digital.base.constant.CommonConstant;
import digital.base.constant.Face3dSeverHTTPConstant;
import digital.base.constant.ZitaCommonConstant;
import digital.bean.task.MwTrainTask;
import digital.config.oss.OssConfiguration;
import digital.util.oss.OssBootUtil;
import digital.util.util.RestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import java.util.concurrent.*;
@Component
@Slf4j
public class FigureTaskService {
@Autowired
OssConfiguration ossConfiguration;
@Autowired
private SysTaskQueueService sysTaskQueueService;
@Autowired
private MwTrainTaskMapper trainTaskMapper;
@Autowired
private SysHistoryMapper sysHistoryMapper;
private ScheduledExecutorService executorService;
private BlockingQueue<SysTaskQueue> figureTaskQueue = new LinkedBlockingQueue<>();
public FigureTaskService() {
this.executorService = Executors.newSingleThreadScheduledExecutor();
}
@Scheduled(fixedRate = 3000) // 每隔3秒执行一次
@Transactional
public synchronized void pollClothTaskTable() {
String taskId = UUID.randomUUID().toString();
QueryWrapper<SysTaskQueue> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_SINGLE)
.eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TYPE_FIGURE)
.last("LIMIT 1"); // 添加这个条件来限制查询结果为1条
// log.info(Thread.currentThread().getName() + "放入【换身材】队列前,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
SysTaskQueue sysTaskQueue = sysTaskQueueService.getOne(queryWrapper);
if (null == sysTaskQueue) {
QueryWrapper<SysTaskQueue> qw = new QueryWrapper<>();
qw.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_BATCH)
.eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TYPE_FIGURE)
.last("LIMIT 1"); // 限制只返回一条记录
sysTaskQueue = sysTaskQueueService.getOne(qw);
}
if (sysTaskQueue != null && figureTaskQueue.size() < 1) {
figureTaskQueue.offer(sysTaskQueue);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
sysTaskQueueService.updateById(sysTaskQueue);
}
// log.info(Thread.currentThread().getName() + " 放入【换身材】队列后,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
}
public void startClothProcessingTasks() {
executorService.scheduleAtFixedRate(() -> {
// log.info("当前【换身材】队列大小=" + clothTaskQueue.size());
SysTaskQueue figureTask = figureTaskQueue.poll();
// log.info("当前【换身材】队列大小=" + clothTaskQueue.size());
if (figureTask != null) {
// 执行任务
processTask(figureTask);
}
}, 0, 3, TimeUnit.SECONDS);
}
private synchronized void processTask(SysTaskQueue sysTaskQueue) {
String taskId = sysTaskQueue.getTaskId();
long startTime = System.currentTimeMillis();
log.info(Thread.currentThread().getName() + " 开始【换身材】=========================================taskId==" + taskId + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
String jsonInfo = sysTaskQueue.getJsonInfo();
JSONObject clothParam = JSON.parseObject(jsonInfo);
MwTrainTask trainTask = trainTaskMapper.selectOne(new QueryWrapper<MwTrainTask>().lambda().eq(MwTrainTask::getTaskId, taskId));
//防止数据删除空指针
SysHistory sysHistory = sysHistoryMapper.selectHistoryOne(taskId);
try {
ResponseEntity<JSONObject> clothResult = RestUtil.zitaRequest(Face3dSeverHTTPConstant.FIGURE_UPLOAD,
HttpMethod.POST, null, clothParam, JSONObject.class);
String clothState = clothResult.getBody().get("status").toString();
log.info(taskId + " 返回结果信息成功 ==" + taskId + " clothResult=" + clothResult.getBody());
if (!ZitaCommonConstant.STATUS_NORMAL.equals(clothState)) {
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult(String.format("digital figure 【换身材】任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
trainTaskMapper.updateById(trainTask);
log.info(String.format("digital figure 【换身材】任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
// 尝试将返回结果转为JSON
JSONObject resultBody = clothResult.getBody();
String imagePath = (String) resultBody.get("res_img_path");
File file = new File(imagePath);
String newFileName = UUID.randomUUID().toString() + file.getName().substring(file.getName().lastIndexOf("."));
String fileUrl = OssBootUtil.uploadOssVideo(file, CommonConstant.PUTON_SWAP, newFileName);
String savePath = OssBootUtil.getDigitalObjectURL(ossConfiguration.getBucketName(), fileUrl, null);
trainTask.setResultImages(savePath);
trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
trainTask.setResult(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000; // 除以1000,将毫秒转换为秒
trainTask.setCostTime((int) duration);
trainTaskMapper.updateById(trainTask);
//替换换身材后的照片
sysHistory.setFileUrl(savePath);
sysHistory.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysTaskQueueService.updateById(sysTaskQueue);
} catch (Exception ex) {
String message = ex.getMessage();
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult("digital figure 【换身材】失败!" + String.format("%s {taskId: %s}", message, taskId));
trainTaskMapper.updateById(trainTask);
log.error("digital figure 【换身材】任务失败!" + String.format("%s {taskId: %s}", message, taskId));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
log.info(Thread.currentThread().getName() + "结束【换身材】=========================================" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
}
@@ -0,0 +1,38 @@
package digital.application.ScheduleTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
@Slf4j
public class HairTaskExecutor {
@Autowired
private HairTaskService HairTaskService;
@PostConstruct
public void init() {
// 使用线程池执行任务处理线程
ExecutorService executorService = Executors.newSingleThreadExecutor();
// 任务处理线程2
executorService.execute(() -> {
try {
log.info("启动==换发型==处理线程..." + Thread.currentThread().getName());
if (HairTaskService != null) {
HairTaskService.startHairProcessingTasks();
} else {
log.error("taskService 为 null,无法启动任务处理");
}
} catch (Exception e) {
log.error("任务==换发型==处理线程启动失败", e);
}
});
// 关闭线程池(应用关闭时)
// executorService.shutdown();
}
}
@@ -0,0 +1,224 @@
package digital.application.ScheduleTask;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import digital.application.entity.SysHistory;
import digital.application.entity.SysTaskQueue;
import digital.application.entity.SysWhiteUser;
import digital.application.mapper.MwTrainTaskMapper;
import digital.application.mapper.SysHistoryMapper;
import digital.application.mapper.SysWhiteUserMapper;
import digital.application.service.SysTaskQueueService;
import digital.application.utils.CloudStorageService;
import digital.base.constant.CommonConstant;
import digital.base.constant.Face3dSeverHTTPConstant;
import digital.base.constant.ZitaCommonConstant;
import digital.bean.task.DpUser;
import digital.bean.task.MwTrainTask;
import digital.config.oss.OssConfiguration;
import digital.system.jeecg.system.service.IDpUserService;
import digital.util.util.RestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.net.URL;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.*;
import java.util.stream.Collectors;
@Component
@Slf4j
public class HairTaskService {
@Autowired
OssConfiguration ossConfiguration;
@Autowired
private SysTaskQueueService sysTaskQueueService;
@Autowired
private MwTrainTaskMapper trainTaskMapper;
@Autowired
private SysHistoryMapper sysHistoryMapper;
@Autowired
private SysWhiteUserMapper smsWhiteUserMapper;
@Autowired
private IDpUserService dpUserService;
private ScheduledExecutorService executorService;
private BlockingQueue<SysTaskQueue> hairTaskQueue;
public HairTaskService() {
this.executorService = Executors.newSingleThreadScheduledExecutor();
this.hairTaskQueue = new LinkedBlockingQueue<>();
}
@Scheduled(fixedRate = 3000) // 每隔3秒执行一次
@Transactional
public void pollHairTaskTable() {
QueryWrapper<SysTaskQueue> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT);
queryWrapper.lambda().eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_SINGLE);
queryWrapper.lambda().eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TRY_ON_TYPE_ALGO_HAIR);
queryWrapper.lambda().orderByAsc(SysTaskQueue::getId);
queryWrapper.lambda().last("LIMIT 1");
// log.info(Thread.currentThread().getName() + "放入【换发型】队列前,hairTaskQueue = " + hairTaskQueue.size());
SysTaskQueue sysTaskQueue = sysTaskQueueService.getOne(queryWrapper);
if (null == sysTaskQueue) {
QueryWrapper<SysTaskQueue> qw = new QueryWrapper<>();
qw.lambda().eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT);
qw.lambda().eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_BATCH);
qw.lambda().eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TRY_ON_TYPE_ALGO_HAIR);
qw.lambda().orderByAsc(SysTaskQueue::getId);
qw.lambda().last("LIMIT 1");
sysTaskQueue = sysTaskQueueService.getOne(qw);
}
if (sysTaskQueue != null && hairTaskQueue.size() < 1) {
hairTaskQueue.offer(sysTaskQueue);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
sysTaskQueueService.updateById(sysTaskQueue);
}
// log.info(Thread.currentThread().getName() + "放入【换发型】队列后,hairTaskQueue = " + hairTaskQueue.size());
}
public synchronized void startHairProcessingTasks() {
executorService.scheduleAtFixedRate(() -> {
// log.info("当前【换发型】队列大小=" + hairTaskQueue.size());
SysTaskQueue hairTask = hairTaskQueue.poll();
// log.info("当前【换发型】队列大小=" + hairTaskQueue.size());
if (hairTask != null) {
// 执行任务
processHairTask(hairTask);
}
}, 0, 1, TimeUnit.SECONDS);
}
@Transactional
synchronized void processHairTask(SysTaskQueue sysTaskQueue) {
String taskId = sysTaskQueue.getTaskId();
long startTime = System.currentTimeMillis();
log.info("开始【换发型】 =========================================" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
String jsonInfo = sysTaskQueue.getJsonInfo();
JSONObject hairParam = JSON.parseObject(jsonInfo);
MwTrainTask trainTask = trainTaskMapper.selectOne(new QueryWrapper<MwTrainTask>().lambda().eq(MwTrainTask::getTaskId, taskId));
//防止数据删除空指针
SysHistory sysHistory = sysHistoryMapper.selectHistoryOne(taskId);
try {
DpUser dpUser = dpUserService.getByUserId(sysTaskQueue.getUserId());
List<SysWhiteUser> sysWhiteUsers = smsWhiteUserMapper.selectList(new QueryWrapper<SysWhiteUser>().lambda().eq(SysWhiteUser::getDelFlag, CommonConstant.DEL_FLAG_0));
String url = Face3dSeverHTTPConstant.SWAP_HAIR_v1;
if (null != dpUser && sysWhiteUsers != null) {
List<String> accounts = sysWhiteUsers.stream()
.map(SysWhiteUser::getAccount) // 将Person对象映射到它们的name字段
.collect(Collectors.toList()); // 收集映射后的结果到List中
if (accounts.contains(dpUser.getAccount())) {
url = Face3dSeverHTTPConstant.SWAP_HAIR_v2;
}
}
ResponseEntity<JSONObject> hairResult = RestUtil.zitaRequest(url,
HttpMethod.POST, null, hairParam, JSONObject.class);
String clothState = hairResult.getStatusCodeValue() + "";
log.info(taskId + " 返回结果信息成功 ==" + taskId + " hairResult=" + hairResult.getBody());
if (clothState != null && !ZitaCommonConstant.STATUS_NORMAL.equals(clothState)
|| hairResult != null && hairResult.getBody() != null
&& !("0").equals(hairResult.getBody().getString("state"))) {
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult(String.format("digital 【换发型】 任务失败!{taskId: %s, resp: %s}", taskId, hairResult.getBody().toJSONString()));
trainTaskMapper.updateById(trainTask);
log.info(String.format("digital 【换发型】 任务失败!{taskId: %s, resp: %s}", taskId, hairResult.getBody().toJSONString()));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
// 尝试将返回结果转为JSON
JSONObject resultBody = hairResult.getBody();
String imageP = (String) resultBody.get("data");
// 判断手机号码
if (Objects.equals(dpUser.getAccount(), "13763009010")) {
// 获取图片流
String imgName = getFileNameFromURL(imageP);
InputStream imageStream = downloadImageStream(imageP);
// 上传到客户oss
String resReUrl = CloudStorageService.saveFileToBucket(imgName, imageStream);
imageP = resReUrl;
}
trainTask.setResultImages(imageP);
trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
trainTask.setResult(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000; // 除以1000,将毫秒转换为秒
trainTask.setCostTime((int) duration);
trainTaskMapper.updateById(trainTask);
//替换换装后的照片
sysHistory.setFileUrl(imageP);
sysHistory.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysTaskQueueService.updateById(sysTaskQueue);
} catch (Exception ex) {
String message = ex.getMessage();
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult("digital 【换发型】 任务失败!" + String.format("digital 【换发型】 任务失败!详情: {taskId: {}, message: {}}", message, taskId));
trainTaskMapper.updateById(trainTask);
log.error("digital 【换发型】 任务失败!详情: {taskId: {}, message: {}}", taskId, message);
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
log.info("结束【换发型】========================================" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
public static InputStream downloadImageStream(String imageUrl) {
// 创建一个 URL 对象
try {
URL url = new URL(imageUrl);
// 打开一个到 URL 指向的资源的连接
// 这里我们可以直接使用 URL.openStream() 方法来获取 InputStream
// 也可以使用 HttpURLConnection 来获取更多的连接控制(比如设置请求头、处理重定向等)
InputStream inputStream = url.openStream();
// 返回 InputStream,注意这里没有关闭它,因为调用者可能还需要使用它
// 调用者应该在不再需要时关闭 InputStream 以释放资源
return inputStream;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static String getFileNameFromURL(String urlString) {
try {
URL url = new URL(urlString);
// 使用URI和Paths来获取文件名
String fileName = url.getFile();
fileName = fileName.substring(fileName.lastIndexOf("/") + 1); // 获取文件名
return fileName;
} catch (Exception e) {
e.printStackTrace();
return null; // 或者抛出一个自定义的异常
}
}
}
@@ -0,0 +1,39 @@
package digital.application.ScheduleTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Component
@Slf4j
public class UnderwearTaskExecutor {
@Autowired
private UnderwearTaskService underwearTaskService;
@PostConstruct
public void init() {
// 使用自定义的ThreadFactory来设置线程名字
// 使用线程池执行任务处理线程
ExecutorService executorService = Executors.newSingleThreadExecutor();
// 任务处理线程1
executorService.execute(() -> {
try {
log.info("启动==换内衣==处理线程..." + Thread.currentThread().getName());
if (underwearTaskService != null) {
underwearTaskService.startClothProcessingTasks();
} else {
log.error("换内衣 taskService 为 null,无法启动任务处理");
}
} catch (Exception e) {
log.error("任务==换内衣==处理线程启动失败", e);
}
});
// 关闭线程池(应用关闭时)
// executorService.shutdown();
}
}
@@ -0,0 +1,160 @@
package digital.application.ScheduleTask;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import digital.application.entity.SysHistory;
import digital.application.entity.SysTaskQueue;
import digital.application.mapper.MwTrainTaskMapper;
import digital.application.mapper.SysHistoryMapper;
import digital.application.service.SysTaskQueueService;
import digital.base.constant.CommonConstant;
import digital.base.constant.Face3dSeverHTTPConstant;
import digital.base.constant.ZitaCommonConstant;
import digital.bean.task.MwTrainTask;
import digital.config.oss.OssConfiguration;
import digital.util.oss.OssBootUtil;
import digital.util.util.RestUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;
import java.util.concurrent.*;
@Component
@Slf4j
public class UnderwearTaskService {
@Autowired
OssConfiguration ossConfiguration;
@Autowired
private SysTaskQueueService sysTaskQueueService;
@Autowired
private MwTrainTaskMapper trainTaskMapper;
@Autowired
private SysHistoryMapper sysHistoryMapper;
private ScheduledExecutorService executorService;
private BlockingQueue<SysTaskQueue> underwearTaskQueue = new LinkedBlockingQueue<>();
public UnderwearTaskService() {
this.executorService = Executors.newSingleThreadScheduledExecutor();
}
@Scheduled(fixedRate = 3000) // 每隔3秒执行一次
@Transactional
public synchronized void pollClothTaskTable() {
String taskId = UUID.randomUUID().toString();
QueryWrapper<SysTaskQueue> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_SINGLE)
.eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TYPE_UNDERWEAR)
.last("LIMIT 1"); // 添加这个条件来限制查询结果为1条
// log.info(Thread.currentThread().getName() + "放入【换内衣】队列前,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
SysTaskQueue sysTaskQueue = sysTaskQueueService.getOne(queryWrapper);
if (null == sysTaskQueue) {
QueryWrapper<SysTaskQueue> qw = new QueryWrapper<>();
qw.lambda()
.eq(SysTaskQueue::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_DRAFT)
.orderByAsc(SysTaskQueue::getId)
.eq(SysTaskQueue::getTryOnType, CommonConstant.TRY_ON_TYPE_BATCH)
.eq(SysTaskQueue::getTryOnAlgo, CommonConstant.TYPE_UNDERWEAR)
.last("LIMIT 1"); // 限制只返回一条记录
sysTaskQueue = sysTaskQueueService.getOne(qw);
}
if (sysTaskQueue != null && underwearTaskQueue.size() < 1) {
underwearTaskQueue.offer(sysTaskQueue);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
sysTaskQueueService.updateById(sysTaskQueue);
}
// log.info(Thread.currentThread().getName() + " 放入【换内衣】队列后,clothTaskQueue = " + clothTaskQueue.size() + " taskId == " + taskId);
}
public void startClothProcessingTasks() {
executorService.scheduleAtFixedRate(() -> {
// log.info("当前【换内衣】队列大小=" + clothTaskQueue.size());
SysTaskQueue figureTask = underwearTaskQueue.poll();
// log.info("当前【换内衣】队列大小=" + clothTaskQueue.size());
if (figureTask != null) {
// 执行任务
processTask(figureTask);
}
}, 0, 3, TimeUnit.SECONDS);
}
private synchronized void processTask(SysTaskQueue sysTaskQueue) {
String taskId = sysTaskQueue.getTaskId();
long startTime = System.currentTimeMillis();
log.info(Thread.currentThread().getName() + " 开始【换内衣】=========================================taskId==" + taskId + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
String jsonInfo = sysTaskQueue.getJsonInfo();
JSONObject clothParam = JSON.parseObject(jsonInfo);
MwTrainTask trainTask = trainTaskMapper.selectOne(new QueryWrapper<MwTrainTask>().lambda().eq(MwTrainTask::getTaskId, taskId));
//防止数据删除空指针
SysHistory sysHistory = sysHistoryMapper.selectHistoryOne(taskId);
try {
ResponseEntity<JSONObject> underwearResult = RestUtil.zitaRequest(Face3dSeverHTTPConstant.SWAP_UNDERWEAR,
HttpMethod.POST, null, clothParam, JSONObject.class);
String clothState = underwearResult.getBody().get("status").toString();
log.info(taskId + " 返回结果信息成功 ==" + taskId + " underwearResult=" + underwearResult.getBody());
if (!ZitaCommonConstant.STATUS_NORMAL.equals(clothState)) {
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult(String.format("digital figure 【换内衣】任务失败!{taskId: %s, resp: %s}", taskId, underwearResult.getBody().toJSONString()));
trainTaskMapper.updateById(trainTask);
log.info(String.format("digital figure 【换内衣】任务失败!{taskId: %s, resp: %s}", taskId, underwearResult.getBody().toJSONString()));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
// 尝试将返回结果转为JSON
JSONObject resultBody = underwearResult.getBody();
String imagePath = (String) resultBody.get("data");
File file = new File(imagePath);
String newFileName = UUID.randomUUID().toString() + file.getName().substring(file.getName().lastIndexOf("."));
String fileUrl = OssBootUtil.uploadOssVideo(file, CommonConstant.PUTON_SWAP, newFileName);
String savePath = OssBootUtil.getDigitalObjectURL(ossConfiguration.getBucketName(), fileUrl, null);
trainTask.setResultImages(savePath);
trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
trainTask.setResult(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
long endTime = System.currentTimeMillis();
long duration = (endTime - startTime) / 1000; // 除以1000,将毫秒转换为秒
trainTask.setCostTime((int) duration);
trainTaskMapper.updateById(trainTask);
//替换换内衣后的照片
sysHistory.setFileUrl(savePath);
sysHistory.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
sysTaskQueueService.updateById(sysTaskQueue);
} catch (Exception ex) {
String message = ex.getMessage();
trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
trainTask.setRequestResult("digital figure 【换内衣】失败!" + String.format("%s {taskId: %s}", message, taskId));
trainTaskMapper.updateById(trainTask);
log.error("digital figure 【换内衣】任务失败!" + String.format("%s {taskId: %s}", message, taskId));
sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
sysHistoryMapper.updateById(sysHistory);
sysTaskQueue.setStatus(Face3dSeverHTTPConstant.result_fail);
sysTaskQueueService.updateById(sysTaskQueue);
return;
}
log.info(Thread.currentThread().getName() + "结束【换内衣】=========================================" + LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")));
}
}
@@ -0,0 +1,399 @@
package digital.application.controller;
import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import com.aliyuncs.exceptions.ClientException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import digital.application.dto.*;
import digital.application.entity.SysFile;
import digital.application.service.IMwTrainTaskService;
import digital.application.service.ISysContactService;
import digital.application.service.ISysFileService;
import digital.application.service.SysRoomService;
import digital.application.vo.LoginUserInfoVO;
import digital.base.annotation.AutoLog;
import digital.base.constant.CommonConstant;
import digital.base.vo.LoginUser;
import digital.base.vo.Result;
import digital.bean.task.DpUser;
import digital.system.jeecg.group.base.service.BaseCommonService;
import digital.system.jeecg.system.service.IDpUserService;
import digital.util.util.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
@Api(tags = "换装平台API")
@RestController
@RequestMapping("/api/cloth")
@Slf4j
public class DigitalClothController {
@Autowired
private IDpUserService dpUserService;
@Autowired
private ISysFileService sysFileService;
@Autowired
private JeecgRedisUtil redisUtil;
@Resource
private BaseCommonService baseCommonService;
@Autowired
private IMwTrainTaskService mwTrainTaskService;
@Autowired
private ISysContactService sysContactService;
@Autowired
private SysRoomService sysRoomService;
@AutoLog(value = "添加专题试衣间")
@ApiOperation(value = "添加专题试衣间", notes = "添加专题试衣间")
@PostMapping(value = "/addRoom")
public Result<?> addRoom(@RequestBody @Validated AddRoomDTO addRoomDTO) {
return sysRoomService.addRoom(addRoomDTO);
}
@AutoLog(value = "删除专题试衣间")
@ApiOperation(value = "删除专题试衣间", notes = "删除专题试衣间")
@PostMapping(value = "/delRoom")
public Result<?> delRoom(@RequestBody @Validated DelRoomDTO delRoomDTO) {
return sysRoomService.delRoom(delRoomDTO);
}
@AutoLog(value = "修改专题试衣间")
@ApiOperation(value = "修改专题试衣间", notes = "修改专题试衣间")
@PostMapping(value = "/updateRoom")
public Result<?> updateRoom(@RequestBody @Validated UpdateRoomDTO updateRoomDTO) {
return sysRoomService.updateRoom(updateRoomDTO);
}
@AutoLog(value = "查询本人专题试衣间")
@ApiOperation(value = "查询本人专题试衣间", notes = "查询本人专题试衣间")
@PostMapping(value = "/getRoomList")
public Result<?> getRoomList(@RequestBody @Validated GetRoomListDTO getRoomListDTO) {
return sysRoomService.getRoomList(getRoomListDTO);
}
@AutoLog(value = "专题试衣间-添加衣服")
@ApiOperation(value = "专题试衣间-添加衣服", notes = "专题试衣间-添加衣服")
@PostMapping(value = "/addRoomCloth")
public Result<?> addRoomCloth(@RequestBody @Validated AddRoomClothDTO addRoomClothDTO) {
return sysRoomService.addRoomCloth(addRoomClothDTO);
}
@AutoLog(value = "专题试衣间-删除衣服")
@ApiOperation(value = "专题试衣间-删除衣服", notes = "专题试衣间-删除衣服")
@PostMapping(value = "/delRoomCloth")
public Result<?> delRoomCloth(@RequestBody @Validated AddRoomClothDTO addRoomClothDTO) {
return sysRoomService.delRoomCloth(addRoomClothDTO);
}
@AutoLog(value = "专题试衣间-查询对应试衣间列表")
@ApiOperation(value = "专题试衣间-查询对应试衣间列表", notes = "专题试衣间-查询对应试衣间列表")
@PostMapping(value = "/getRoomClothList")
public Result<?> getRoomClothList(@RequestBody @Validated GetRoomClothListDTO getRoomClothListDTO) {
return sysRoomService.getRoomClothList(getRoomClothListDTO);
}
@AutoLog(value = "购买链接")
@ApiOperation(value = "购买链接", notes = "购买链接")
@PostMapping(value = "/buyLink")
public Result<?> buyLink(@RequestBody @Validated BuyLinksDTO buyLinksDTO) {
return sysFileService.buyLink(buyLinksDTO);
}
@AutoLog(value = "批量删除历史数据")
@ApiOperation(value = "批量删除历史数据", notes = "批量删除历史数据")
@PostMapping(value = "/batchDelHistory")
public Result<?> batchDelHistory(@RequestBody @Validated BatchDelHistoryDTO batchDelHistoryDTO) {
return sysFileService.batchDelHistory(batchDelHistoryDTO);
}
@AutoLog(value = "取消试穿")
@ApiOperation(value = "取消试穿", notes = "取消试穿")
@PostMapping(value = "/unTryOn")
public Result<?> unTryOn(@RequestBody @Validated UnTryOnDTO unTryOnDTO) {
return sysFileService.unTryOn(unTryOnDTO);
}
@AutoLog(value = "上传用户头像")
@ApiOperation(value = "上传用户头像", notes = "上传用户头像")
@PostMapping(value = "/uploadAvatar")
public Result<?> uploadAvatar(@RequestParam("file") MultipartFile file) {
return sysFileService.uploadAvatar(file);
}
@AutoLog(value = "获取登录用户信息")
@ApiOperation(value = "获取登录用户信息", notes = "获取登录用户信息")
@PostMapping(value = "/getLoginUserInfo")
public Result<?> getLoginUserInfo() {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
log.info("开始 获取登录用户信息 loginUser =" + loginUser);
DpUser dpUser = dpUserService.getByUserId(loginUser.getId());
log.info("开始 获取登录用户信息 dpUser =" + dpUser);
LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO();
BeanUtils.copyProperties(dpUser, loginUserInfoVO);
loginUserInfoVO.setUsername(DesensitizedUtil.mobilePhone(dpUser.getAccount()));
return Result.ok(loginUserInfoVO);
}
@AutoLog(value = "加入套装")
@ApiOperation(value = "加入套装", notes = "加入套装")
@PostMapping(value = "/addSuit")
public Result<?> addSuit(@RequestBody @Validated AddSuitDTO addSuitDTO) {
return sysFileService.addSuit(addSuitDTO);
}
// @AutoLog(value = "查看试穿历史数据")
@ApiOperation(value = "查看试穿历史数据", notes = "查看试穿历史数据")
@PostMapping(value = "/getTryOnHistory")
public Result<?> getTryOnHistory() {
return sysFileService.getTryOnHistory();
}
@AutoLog(value = "上传模特头像")
@ApiOperation(value = "上传模特头像", notes = "上传模特头像")
@PostMapping(value = "/uploadModel")
public Result<?> uploadModel(@RequestParam("file") MultipartFile file, @RequestParam("sex") String sex) throws IOException {
return sysFileService.uploadModel(file, sex);
}
@AutoLog(value = "获取模特列表")
@ApiOperation(value = "获取模特列表", notes = "获取模特列表")
@PostMapping(value = "/getModelList")
public Result<?> getModelList(@RequestBody @Validated GetModelDTO getModelDTO) {
return sysFileService.getModelList(getModelDTO);
}
@AutoLog(value = "衣服类型图片所有数据查询")
@ApiOperation(value = "衣服类型图片所有数据查询", notes = "衣服类型图片所有数据查询")
@PostMapping(value = "/list")
public Result<?> queryClothTypeList(@RequestBody @Validated QueryClothTypeDTO queryClothTypeDTO) {
return sysFileService.clothList(queryClothTypeDTO);
}
@AutoLog(value = "抓取图片")
@ApiOperation(value = "抓取图片", notes = "抓取图片")
@PostMapping(value = "/grabPicture")
public Result<?> grabPicture(@RequestBody @Validated CrawlerPictureDTO crawlerPictureDTO) {
return sysFileService.grabPicture(crawlerPictureDTO.getGrabUrl());
}
@AutoLog(value = "取消加入")
@ApiOperation(value = "取消加入", notes = "取消加入")
@PostMapping(value = "/unJoin")
public Result<?> unJoin(@RequestBody @Validated UnJoinDTO unJoinDTO) {
return sysFileService.unJoin(unJoinDTO);
}
@AutoLog(value = "加入衣橱")
@ApiOperation(value = "加入衣橱", notes = "加入衣橱")
@PostMapping(value = "/addWardrobe")
public Result<?> addWardrobe(@RequestBody @Validated AddWardrobeDTO addWardrobeDTO) {
return sysFileService.addWardrobe(addWardrobeDTO);
}
@AutoLog(value = "提交公司信息")
@ApiOperation(value = "提交公司信息", notes = "提交公司信息")
@PostMapping(value = "/submitContactInfo")
public Result<?> submitContactInfo(@RequestBody @Validated SubmitContactInfoDTO submitContactInfoDTO) {
return sysContactService.submitContactInfo(submitContactInfoDTO);
}
@AutoLog(value = "删除衣服或者模特")
@ApiOperation(value = "删除衣服或者模特", notes = "删除衣服或者模特")
@PostMapping(value = "/deleteCloth")
public Result<String> deleteCloth(@RequestBody @Validated DeleteClothDTO deleteClothDTO) {
String taskId = UUID.randomUUID().toString();
String id = deleteClothDTO.getId();
SysFile sysFile = sysFileService.getById(id);
if (sysFile == null) {
return Result.error("数据库中无此数据", taskId);
}
String commonClothType = sysFile.getCommonClothType();
if (oConvertUtils.isNotEmpty(commonClothType) && commonClothType.contains("in_")) {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if (!loginUser.getRoleType().equals("admin")) {
return Result.error("公共文件不能删除!", taskId);
}
}
sysFileService.removeById(id);
String materialPath = sysFile.getMaterialPath();
if (oConvertUtils.isNotEmpty(materialPath)) {
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysFile::getMaterialPath, materialPath);
List<SysFile> deleteList = sysFileService.list(queryWrapper);
if (deleteList != null && deleteList.size() > 0) {
log.info("需要删除的数据 deleteList =" + deleteList);
sysFileService.removeBatchByIds(deleteList);
}
}
return Result.OK("删除成功!", taskId);
}
@AutoLog(value = "上次训练时间")
@ApiOperation(value = "上次训练时间", notes = "上次训练时间")
@PostMapping(value = "/getCostTime")
public Result<?> getCostTime() {
return mwTrainTaskService.getCostTime();
}
@AutoLog(value = "换装回调接口")
@ApiOperation(value = "回调接口", notes = "回调接口")
@PostMapping(value = "/tryOnCallBack")
public Result<?> tryOnCallBack(@RequestBody TryOnCallBackDTO tryOnCallBackDTO) {
return sysFileService.tryOnCallBack(tryOnCallBackDTO);
}
@AutoLog(value = "上传衣服回调接口")
@ApiOperation(value = "上传衣服回调接口", notes = "上传衣服回调接口")
@PostMapping(value = "/callBack")
public Result<?> callBack(@RequestBody CallBackDTO callBackDTO) {
return sysFileService.callBack(callBackDTO);
}
@AutoLog(value = "试穿")
@ApiOperation(value = "试穿", notes = "试穿")
@PostMapping(value = "/tryOn")
public Result<?> tryOn(@RequestBody @Validated TryOnDTO tryOnDTO) {
return sysFileService.tryOn(tryOnDTO);
}
@AutoLog(value = "添加上衣")
@ApiOperation(value = "添加上衣", notes = "添加上衣")
@PostMapping(value = "/uploadClothFile")
public Result<?> uploadClothFile(MultipartFile file) {
return sysFileService.uploadFileCloth(file);
}
// @AutoLog(value = "批量添加上衣")
@ApiOperation(value = "批量添加上衣", notes = "批量添加上衣")
@PostMapping(value = "/batchUploadClothFile")
public Result<?> batchUploadClothFile(MultipartFile[] files) {
return sysFileService.batchUploadClothFile(files);
}
@AutoLog(value = "上传图片分类")
@ApiOperation(value = "上传图片分类", notes = "上传图片分类")
@PostMapping(value = "/uploadCloth")
public Result<?> uploadCloth(@RequestBody UploadClothDTO uploadClothDTO) {
return sysFileService.uploadCloth(uploadClothDTO);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* 用户信息
*
* @param sysUser
* @param result
* @return
*/
private Result<JSONObject> userInfo(DpUser sysUser, Result<JSONObject> result) {
String username = sysUser.getAccount();
String syspassword = sysUser.getPassword();
// 获取用户部门信息
JSONObject obj = new JSONObject();
// 生成token
String token = JwtUtil.sign(username, syspassword);
// 设置token缓存有效时间
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
obj.put("token", token);
obj.put("userInfo", sysUser);
result.setResult(obj);
result.success("登录成功");
return result;
}
@AutoLog(value = "手机号登录接口")
@ApiOperation("手机号登录接口")
@PostMapping("/phoneLogin")
public Result<?> phoneLogin(@RequestBody PhoneLoginDTO phoneLoginDTO) {
Result<JSONObject> result = new Result<JSONObject>();
String phone = phoneLoginDTO.getPhone();
//查看验证码是否正确
String smscode = phoneLoginDTO.getCaptcha();
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + phone;
Object code = redisUtil.get(redisKey);
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
if (!smscode.equals(code)) {
log.info("手机验证码=" + code);
result.setCode(500);
result.setSuccess(false);
result.setMessage("手机验证码错误");
return result;
}
DpUser sysUser = dpUserService.getUserByAccount(phone);
if (null == sysUser) {
sysUser = dpUserService.addUser(phone);
}
//用户信息
userInfo(sysUser, result);
//添加日志
baseCommonService.addLog("用户名: " + sysUser.getAccount() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
return result;
}
@AutoLog(value = "发送短信验证码")
@ApiOperation("发送短信验证码")
@PostMapping(value = "/sms")
public Result<String> sms(@RequestBody SmsLoginDTO smsLoginDTO) {
String mobile = smsLoginDTO.getPhone();
log.info(mobile);
if (oConvertUtils.isEmpty(mobile)) {
return Result.error("手机号不允许为空");
}
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
String redisKey = CommonConstant.PHONE_REDIS_KEY_PRE + mobile;
Object object = redisUtil.get(redisKey);
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
if (object != null) {
return Result.error("验证码2分钟内,仍然有效!");
}
//随机数
String captcha = RandomUtil.randomNumbers(6);
JSONObject obj = new JSONObject();
obj.put("code", captcha);
try {
boolean b = false;
//登录模板
b = DySmsHelper.sendSms(mobile, obj, DySmsEnum.LOGIN_TEMPLATE_CODE);
if (b == false) {
return Result.error("短信验证码发送失败,请稍后重试!");
}
//update-begin-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
//验证码10分钟内有效
redisUtil.set(redisKey, captcha, 120);
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
//update-begin--Author:scott Date:20190812 forissues#391
//result.setResult(captcha);
//update-end--Author:scott Date:20190812 forissues#391
//查看数据库中是否有改用户,如果没有,则新增用户
dpUserService.addUser(mobile);
return Result.OK("发送成功!");
} catch (ClientException e) {
return Result.error("短信接口未配置,请联系管理员!");
}
}
}
@@ -0,0 +1,112 @@
package digital.application.controller;
import digital.application.dto.tjHair.GetHairDataDTO;
import digital.application.dto.tjHair.GetSwapHairHistoryByTaskIdDTO;
import digital.application.service.ISysFileService;
import digital.base.annotation.AutoLog;
import digital.base.vo.Result;
import digital.bean.task.DpUser;
import digital.system.jeecg.system.service.IDpUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@Api(tags = "给第三方提供接口")
@RestController
@RequestMapping("/api/v1")
@Slf4j
public class TjSwapHairController {
@Autowired
private ISysFileService sysFileService;
@Autowired
private IDpUserService dpUserService;
@AutoLog(value = "第三方-根据账号查询可以换发型的数据")
@ApiOperation(value = "第三方-根据账号查询可以换发型的数据", notes = "第三方-根据账号查询可以换发型的数据")
@PostMapping(value = "/getHairData")
public Result<?> getHairData(@RequestBody @Validated GetHairDataDTO getHairData) {
String phone = "18701620166";
DpUser dpUser = dpUserService.getUserByAccount(phone);
log.info("第三方用户信息:{}", dpUser);
getHairData.setUserId(dpUser.getId());
return sysFileService.getHairData(getHairData);
}
@AutoLog(value = "第三方-根据手机账号查询可以换发型的数据")
@ApiOperation(value = "第三方-根据手机账号查询可以换发型的数据", notes = "第三方-根据手机账号查询可以换发型的数据")
@PostMapping(value = "/queryHairData")
public Result<?> queryHairData(@RequestBody @Validated GetHairDataDTO getHairData) {
String phone = getHairData.getPhone();
DpUser dpUser = dpUserService.getUserByAccount(phone);
log.info("查询的第三方用户信息:{}", dpUser);
getHairData.setUserId(dpUser.getId());
return sysFileService.getHairData(getHairData);
}
@ApiOperation(value = "第三方-试穿发型", notes = "第三方-试穿发型")
@PostMapping(value = "/swapHair")
public Result<?> swapHair(@RequestParam(value = "isHr") String isHr,
@RequestParam(value = "hairIds") String hairIds,
MultipartFile[] files,
@RequestParam(value = "sex") String sex) {
//判断手机号格式是否合法
String phone = "18701620166";
//首先判断用户是否存在,不存在则添加
DpUser dpUser = dpUserService.getUserByAccount(phone);
return sysFileService.swapHair(dpUser, isHr, hairIds, files, sex);
}
@ApiOperation(value = "第三方第二家-试穿发型", notes = "第三方第二家-试穿发型")
@PostMapping(value = "/swapHairAsync")
public Result<?> swapHairAsync(@RequestParam(value = "isHr") String isHr,
@RequestParam(value = "hairIds") String hairIds,
MultipartFile[] files,
@RequestParam(value = "modelUrls") String modelUrls,
@RequestParam(value = "sex") String sex) {
//判断手机号格式是否合法
String phone = "13763009010";
//首先判断用户是否存在,不存在则添加
DpUser dpUser = dpUserService.getUserByAccount(phone);
return sysFileService.swapHairAsync(dpUser, isHr, hairIds, files, modelUrls, sex);
}
@AutoLog(value = "查看换发结果数据")
@ApiOperation(value = "查看换发结果数据", notes = "查看换发结果数据")
@PostMapping(value = "/getSwapHairHistory")
public Result<?> getSwapHairHistory() {
String phone = "18701620166";
DpUser dpUser = dpUserService.getUserByAccount(phone);
return sysFileService.getSwapHairHistory(dpUser);
}
@AutoLog(value = "查看换发结果数据")
@ApiOperation(value = "查看换发结果数据", notes = "查看换发结果数据")
@PostMapping(value = "/getSwapHairHistoryByTaskId")
public Result<?> getSwapHairHistoryByTaskId(@RequestBody @Validated GetSwapHairHistoryByTaskIdDTO getSwapHairHistoryByTaskIdDTO) {
return sysFileService.getSwapHairHistoryByTaskId(getSwapHairHistoryByTaskIdDTO.getTaskId());
}
@ApiOperation(value = "查看固定手机号试穿历史数据", notes = "查看固定手机号试穿历史数据")
@PostMapping(value = "/getTargetTryOnHistory")
public Result<?> getTargetTryOnHistory() {
String phone = "13763009010";
DpUser dpUser = dpUserService.getUserByAccount(phone);
return sysFileService.getTargetTryOnHistory(dpUser);
}
@AutoLog(value = "查看第二家公司换发结果数据")
@ApiOperation(value = "查看第二家公司换发结果数据", notes = "查看第二家公司换发结果数据")
@PostMapping(value = "/querySwapHairHistory")
public Result<?> querySwapHairHistory() {
String phone = "13763009010";
DpUser dpUser = dpUserService.getUserByAccount(phone);
return sysFileService.getSwapHairHistory(dpUser);
}
}
@@ -0,0 +1,15 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddRoomClothDTO {
@NotBlank(message = "roomId 不能为空!")
private String roomId;
@NotBlank(message = "clothId 不能为空!")
private String clothId;
}
@@ -0,0 +1,19 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddRoomDTO {
@ApiModelProperty(value = "专题试衣间名称")
@NotBlank(message = "roomName 不能为空!")
private String roomName;
@ApiModelProperty(value = "专题试衣间名称")
@NotBlank(message = "sex 不能为空!")
private String sex;
}
@@ -0,0 +1,18 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddSuitDTO {
@ApiModelProperty(value = "上衣")
@NotBlank(message = "topClothId 不能为空!")
private String topClothId;
@ApiModelProperty(value = "下衣")
@NotBlank(message = "bottomClothId 不能为空!")
private String bottomClothId;
}
@@ -0,0 +1,18 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class AddWardrobeDTO {
@ApiModelProperty(value = " topCloth 上衣 bottomCloth 下衣 dress suit 套装 ")
@NotBlank(message = "clothType 不能为空!")
private String clothType;
@ApiModelProperty(value = "衣服id")
@NotBlank(message = "clothId 不能为空!")
private String clothId;
}
@@ -0,0 +1,13 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data
public class BatchDelHistoryDTO {
@NotEmpty
private List<String> historyIds;
}
@@ -0,0 +1,19 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class BuyLinksDTO {
@ApiModelProperty(value = "衣服id")
@NotBlank(message = "clothId 不能为空!")
private String clothId;
@ApiModelProperty(value = "购买链接")
@NotBlank(message = "buyLinks 不能为空!")
private String buyLink;
}
@@ -0,0 +1,18 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CallBackDTO {
@ApiModelProperty(value = "任务状态 0 成功 -1 失败")
private String status;
@ApiModelProperty(value = "任务id")
private String taskId;
@ApiModelProperty(value = "衣服id")
private String clothId;
}
@@ -0,0 +1,8 @@
package digital.application.dto;
import lombok.Data;
@Data
public class CrawlerPictureDTO {
private String grabUrl;
}
@@ -0,0 +1,12 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class DelRoomDTO {
@NotBlank(message = "roomId 不能为空!")
private String roomId;
}
@@ -0,0 +1,12 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class DeleteClothDTO {
@NotBlank(message = "id不能为空!")
private String id;
}
@@ -0,0 +1,12 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetModelDTO {
@NotBlank(message = "性别不能为空!")
private String sex;
}
@@ -0,0 +1,17 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetRoomClothListDTO {
@NotBlank(message = "roomId 不能为空!")
private String roomId;
@ApiModelProperty(value = "性别")
@NotBlank(message = "sex 不能为空!")
private String sex;
}
@@ -0,0 +1,12 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetRoomListDTO {
@NotBlank(message = "sex 不能为空!")
private String sex;
}
@@ -0,0 +1,14 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class LoginDTO {
@ApiModelProperty(value = "账号")
@NotBlank(message = "account 不能为空!")
private String account;
}
@@ -0,0 +1,24 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* author: damao
* date:2022-10-03 12:47
* description:手机号登录dto
**/
@Data
public class PhoneLoginDTO {
@NotBlank(message = "手机号不能为空!")
@ApiModelProperty(value = "手机号")
private String phone;
@NotBlank(message = "验证码不能为空!")
@ApiModelProperty(value = "验证码")
private String captcha;
}
@@ -0,0 +1,21 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class QueryClothTypeDTO {
@ApiModelProperty(value = "衣服库 no 我的衣橱 yes")
@NotBlank(message = "isPerson 不能为空!")
private String isPerson;
@ApiModelProperty(value = " topCloth 上衣 bottomCloth 下衣 dress suit 套装 excludeSuit 除了套装 ")
private String clothType;
@ApiModelProperty(value = "性别")
private String sex;
}
@@ -0,0 +1,15 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class SmsLoginDTO {
@ApiModelProperty(value = "手机号")
@NotBlank(message = "手机号不能为空!")
private String phone;
}
@@ -0,0 +1,25 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class SubmitContactInfoDTO {
@ApiModelProperty(value = "姓名")
@NotBlank(message = "name 不能为空!")
private String name;
@ApiModelProperty(value = "手机号")
@NotBlank(message = "phone 不能为空!")
private String phone;
@ApiModelProperty(value = "公司")
@NotBlank(message = "company 不能为空!")
private String company;
@ApiModelProperty(value = "需求描述")
private String description;
}
@@ -0,0 +1,20 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class TrainTaskCallbackDTO {
@ApiModelProperty(value = "状态")
private String status;
@ApiModelProperty(value = "taskId")
private String taskId;
@ApiModelProperty(value = "urlList")
private List<String> urlList;
}
@@ -0,0 +1,21 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class TryOnCallBackDTO {
@ApiModelProperty(value = "任务状态")
private Integer status;
@ApiModelProperty(value = "任务id")
private String taskId;
@ApiModelProperty(value = "衣服路径")
private String filePath;
@ApiModelProperty(value = "衣服路径")
private String msg;
}
@@ -0,0 +1,25 @@
package digital.application.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
public class TryOnDTO {
private List<TryOn> tryOnList;
private String isHr;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class TryOn {
private List<String> clothIds;
private String modelId;
}
}
@@ -0,0 +1,15 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class UnJoinDTO {
@ApiModelProperty(value = "衣服id")
@NotBlank(message = "clothId 不能为空!")
private String clothId;
}
@@ -0,0 +1,14 @@
package digital.application.dto;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.List;
@Data
public class UnTryOnDTO {
@NotEmpty
private List<String> historyIds;
}
@@ -0,0 +1,17 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class UpdateRoomDTO {
@NotBlank(message = "roomId 不能为空!")
private String roomId;
@ApiModelProperty(value = "专题试衣间名称")
@NotBlank(message = "roomName 不能为空!")
private String roomName;
}
@@ -0,0 +1,23 @@
package digital.application.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.util.List;
@Data
public class UploadClothDTO {
private List<String> clothFileList;
@NotBlank(message = "clothType不能为空!")
private String clothType;
@ApiModelProperty(value = "是否同步 yes 同步 no 不同步 ")
@NotBlank(message = "isSync 不能为空!")
private String isSync;
@NotBlank(message = "sex 不能为空!")
private String sex;
}
@@ -0,0 +1,21 @@
package digital.application.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class UserHistoryMap {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
private String batchNo;
private String historyIdFileUrls;
}
@@ -0,0 +1,22 @@
package digital.application.dto.tjHair;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetHairDataDTO {
// @NotBlank(message = "phone 不能为空!")
// @Pattern(regexp = "^1[3-9]\\d{9}$", message = "phone 不是合法的手机号!")
@ApiModelProperty(value = "手机号码")
private String phone;
@ApiModelProperty(value = "是否个人衣柜")
@NotBlank(message = "isPerson 不能为空!")
private String isPerson;
@ApiModelProperty(value = "用户id 前端不用传")
private String userId;
}
@@ -0,0 +1,12 @@
package digital.application.dto.tjHair;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class GetSwapHairHistoryByTaskIdDTO {
@NotBlank(message = "taskId 不能为空!")
private String taskId;
}
@@ -0,0 +1,31 @@
package digital.application.emun;
import java.io.IOException;
public enum LiveStatusEnum {
//枚举值
//STARTING 开启中
//SUCCESS 开播成功
//CANCEL 取消开播
//FAIL 开播失败
//说明
CANCEL, FAIL, STARTING, SUCCESS;
public String toValue() {
switch (this) {
case CANCEL: return "CANCEL";
case FAIL: return "FAIL";
case STARTING: return "STARTING";
case SUCCESS: return "SUCCESS";
}
return null;
}
public static LiveStatusEnum forValue(String value) throws IOException {
if (value.equals("CANCEL")) return CANCEL;
if (value.equals("FAIL")) return FAIL;
if (value.equals("STARTING")) return STARTING;
if (value.equals("SUCCESS")) return SUCCESS;
throw new IOException("Cannot deserialize Status");
}
}
@@ -0,0 +1,25 @@
package digital.application.emun;
import java.io.IOException;
/**
* 回复者 主播 ANCHOR, 助播 ASSISTANT;
*/
public enum ReplySource {
ANCHOR, ASSISTANT;
public String toValue() {
switch (this) {
case ANCHOR: return "ANCHOR";
case ASSISTANT: return "ASSISTANT";
}
return null;
}
public static ReplySource forValue(String value) throws IOException {
if (value.equals("ANCHOR")) return ANCHOR;
if (value.equals("ASSISTANT")) return ASSISTANT;
throw new IOException("Cannot deserialize ReplySource");
}
}
@@ -0,0 +1,21 @@
package digital.application.emun;
import java.io.IOException;
public enum ReplyType {
AUDIO, TEXT;
public String toValue() {
switch (this) {
case AUDIO: return "AUDIO";
case TEXT: return "TEXT";
}
return null;
}
public static ReplyType forValue(String value) throws IOException {
if (value.equals("AUDIO")) return AUDIO;
if (value.equals("TEXT")) return TEXT;
throw new IOException("Cannot deserialize ReplyType");
}
}
@@ -0,0 +1,49 @@
package digital.application.emun;
import io.swagger.models.auth.In;
public enum SortTypeEnum {
picture_1("1", "DESC"),
picture_2("0", "ASC"),
;
SortTypeEnum(String type, String extendName) {
this.type = type;
this.extendName = extendName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getExtendName() {
return extendName;
}
public void setExtendName(String extendName) {
this.extendName = extendName;
}
private String type;
private String extendName;
public static SortTypeEnum codeIn(String type) {
if (type == null) {
return null;
} else {
for (SortTypeEnum em : SortTypeEnum.values()) {
if (em.getType().equals(type)) {
return em;
}
}
return null;
}
}
}
@@ -0,0 +1,56 @@
package digital.application.emun;
/**
* U CAN GET A CRAB WHEN U MEET US
* IF GET A QUESTIONPLEASE CONTACT US
* WEBSITE www.crabholder.cn www.crabholder.com
* EMAILcrabholder@163.com.
* CREATED ON 2020/7/13
*/
public enum StatusTypeEnum {
picture_1("2", "DRAFT"),
picture_2("0", "IN_PROGRESS"),
picture_3("1", "SUCCESS"),
picture_4("-1", "FAIL"),
;
StatusTypeEnum(String fileType, String extendName) {
this.fileType = fileType;
this.extendName = extendName;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getExtendName() {
return extendName;
}
public void setExtendName(String extendName) {
this.extendName = extendName;
}
private String fileType;
private String extendName;
public static StatusTypeEnum codeIn(String fileType) {
if (fileType == null) {
return null;
} else {
for (StatusTypeEnum em : StatusTypeEnum.values()) {
if (em.getFileType().equals(fileType)) {
return em;
}
}
return null;
}
}
}
@@ -0,0 +1,31 @@
package digital.application.emun;
import java.io.IOException;
public enum Type {
GIFT, KEYS, LIVE_DURATION, LIVE_INTERVAL, ONLINE_NUM, TOTAL_VIEW_NUM, UPVOTE_NUM;
public String toValue() {
switch (this) {
case GIFT: return "GIFT";
case KEYS: return "KEYS";
case LIVE_DURATION: return "LIVE_DURATION";
case LIVE_INTERVAL: return "LIVE_INTERVAL";
case ONLINE_NUM: return "ONLINE_NUM";
case TOTAL_VIEW_NUM: return "TOTAL_VIEW_NUM";
case UPVOTE_NUM: return "UPVOTE_NUM";
}
return null;
}
public static Type forValue(String value) throws IOException {
if (value.equals("GIFT")) return GIFT;
if (value.equals("KEYS")) return KEYS;
if (value.equals("LIVE_DURATION")) return LIVE_DURATION;
if (value.equals("LIVE_INTERVAL")) return LIVE_INTERVAL;
if (value.equals("ONLINE_NUM")) return ONLINE_NUM;
if (value.equals("TOTAL_VIEW_NUM")) return TOTAL_VIEW_NUM;
if (value.equals("UPVOTE_NUM")) return UPVOTE_NUM;
throw new IOException("Cannot deserialize Type");
}
}
@@ -0,0 +1,23 @@
package digital.application.emun;
import java.io.IOException;
public enum TypeEnum {
GLOBAL_IMAGE, IMAGE, VIDEO;
public String toValue() {
switch (this) {
case GLOBAL_IMAGE: return "GlobalImage";
case IMAGE: return "Image";
case VIDEO: return "Video";
}
return null;
}
public static TypeEnum forValue(String value) throws IOException {
if (value.equals("GlobalImage")) return GLOBAL_IMAGE;
if (value.equals("Image")) return IMAGE;
if (value.equals("Video")) return VIDEO;
throw new IOException("Cannot deserialize TypeEnum");
}
}
@@ -0,0 +1,94 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* @Description: sys_contact
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
@Data
@TableName("sys_contact")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_contact对象", description = "sys_contact")
public class SysContact implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
/**
* 姓名
*/
@Excel(name = "姓名", width = 15)
@ApiModelProperty(value = "姓名")
private String name;
/**
* 手机号
*/
@Excel(name = "手机号", width = 15)
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 公司
*/
@Excel(name = "公司", width = 15)
@ApiModelProperty(value = "公司")
private String company;
/**
* 需求描述
*/
@Excel(name = "需求描述", width = 15)
@ApiModelProperty(value = "需求描述")
private String description;
/**
* 逻辑删
*/
@Excel(name = "逻辑删", width = 15)
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,168 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_file")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_file对象", description = "sys_file")
public class SysFile implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "代表值")
private String repValue;
@ApiModelProperty(value = "衣服库id 记录加入衣橱的时候的id")
private String wardrobeId;
@ApiModelProperty(value = "购买链接")
private String buyLink;
@ApiModelProperty(value = "性别")
private String sex;
@ApiModelProperty(value = "素材路径")
private String materialPath;
@ApiModelProperty(value = "是否个人衣柜")
private String isPerson;
private String processType;
@ApiModelProperty(value = "文件状态 enable 启用 disable :禁用 fail 失败 ")
private String fileStatus;
@ApiModelProperty(value = "衣服类型 topCloth 上衣\n" +
"bottomCloth 下衣\n" +
"dress 连衣裙\n" +
"发型类型 hair" +
"身材 figure" +
"不全全部展示\n")
private String clothType;
@ApiModelProperty(value = "文件类型 clothType modelType hairType")
private String fileType;
@ApiModelProperty(value = "是否公共数据")
private String commonClothType;
@ApiModelProperty(value = "扩展名")
private String extendName;
@ApiModelProperty(value = "文件夹下文件个数")
private Integer fileSum;
@ApiModelProperty(value = "文件名")
private String fileName;
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String ossFilePath;
/**
* 文件路径
*/
@Excel(name = "文件路径", width = 15)
@ApiModelProperty(value = "文件路径")
private String filePath;
/**
* 文件路径id
*/
@Excel(name = "文件路径id", width = 15)
@ApiModelProperty(value = "文件路径id")
private String filePathId;
/**
* 对应ossId
*/
@Excel(name = "对应ossId", width = 15)
@ApiModelProperty(value = "对应ossId")
private String fileOssId;
/**
* 文件名称
*/
@Excel(name = "文件名称", width = 15)
@ApiModelProperty(value = "文件名称")
private String ossFileName;
/**
* 删除标识(0-未删除,1-已删除)
*/
@Excel(name = "删除标识(0-未删除,1-已删除)", width = 15)
@ApiModelProperty(value = "删除标识(0-未删除,1-已删除)")
@TableLogic
private Integer delFlag;
/**
* 文件大小
*/
@Excel(name = "文件大小", width = 15)
@ApiModelProperty(value = "文件大小")
private Integer fileSize;
@ApiModelProperty(value = "访问地址")
private String fileUrl;
@ApiModelProperty(value = "缩略图访问地址")
private String thumbnailFileUrl;
@ApiModelProperty(value = "过期时间")
private Integer expireTime;
/**
* 临时数据 1 是,0 不是
*/
@Excel(name = "临时数据 1 是,0 不是", width = 15)
@ApiModelProperty(value = "临时数据 1 是,0 不是")
private String isTemp;
/**
* 用户id
*/
@Excel(name = "用户id", width = 15)
@ApiModelProperty(value = "用户id")
private String userId;
/**
* 创建人
*/
@ApiModelProperty(value = "创建人")
private String createBy;
/**
* 创建时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "创建时间")
private Date createTime;
/**
* 更新人
*/
@ApiModelProperty(value = "更新人")
private String updateBy;
/**
* 更新时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,70 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_history")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_history", description = "sys_history")
public class SysHistory implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "试穿类型 单个single 还是批量 batch ")
private String tryOnType;
@ApiModelProperty(value = "试穿算法 cloth 衣服 hair 发型 ")
private String tryOnAlgo;
@ApiModelProperty(value = "批次号")
private String batchNo;
@ApiModelProperty(value = "任务状态")
private String status;
@ApiModelProperty(value = "批次号")
private String taskId;
@ApiModelProperty(value = "图片集合")
private String fileUrl;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,58 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_room")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_room", description = "sys_room")
public class SysRoom implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "专题试衣间名称")
private String roomName;
@ApiModelProperty(value = "性别")
private String sex;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,56 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_room_cloth")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_room_cloth", description = "sys_room_cloth")
public class SysRoomCloth implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "专题试衣间id")
private String roomId;
@ApiModelProperty(value = "文件id")
private String fileId;
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,73 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_task_queue")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_task_queue", description = "sys_task_queue")
public class SysTaskQueue implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "主键")
private Integer id;
@ApiModelProperty(value = "是否高清")
private String isHr;
@ApiModelProperty(value = "试穿类型 单个 single 还是批量 batch ")
private String tryOnType;
@ApiModelProperty(value = "试穿算法 cloth 衣服 hair 发型 figure 身材 underwear 内衣 ")
private String tryOnAlgo;
@ApiModelProperty(value = "sex")
private String sex;
@ApiModelProperty(value = "任务状态")
private String status;
@ApiModelProperty(value = "批次号")
private String taskId;
@ApiModelProperty(value = "图片集合")
private String jsonInfo;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,52 @@
package digital.application.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName("sys_white_user")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "sys_white_user", description = "sys_white_user")
public class SysWhiteUser implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "白名单账号")
private String account;
@ApiModelProperty(value = "逻辑删")
@TableLogic
private Integer delFlag;
@ApiModelProperty(value = "创建人")
private String createBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "更新人")
private String updateBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "更新时间")
private Date updateTime;
}
@@ -0,0 +1,14 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.bean.task.MwTrainTask;
/**
* @Description: mw_train_task
* @Author: jeecg-boot
* @Date: 2023-10-06
* @Version: V1.0
*/
public interface MwTrainTaskMapper extends BaseMapper<MwTrainTask> {
}
@@ -0,0 +1,8 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.entity.SysContact;
public interface SysContactMapper extends BaseMapper<SysContact> {
}
@@ -0,0 +1,24 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import digital.application.entity.SysFile;
import digital.application.vo.QueryClothTypeListVO;
import org.apache.ibatis.annotations.Param;
/**
* @Description: sys_file
* @Author: jeecg-boot
* @Date: 2024-04-23
* @Version: V1.0
*/
public interface SysFileMapper extends BaseMapper<SysFile> {
IPage<QueryClothTypeListVO> queryClothTypeList(@Param("page") Page<SysFile> page, @Param(Constants.WRAPPER) QueryWrapper<SysFile> queryWrapper);
SysFile selectWithoutLogicDeleteById(String clothId);
}
@@ -0,0 +1,22 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.dto.UserHistoryMap;
import digital.application.entity.SysHistory;
import java.util.List;
public interface SysHistoryMapper extends BaseMapper<SysHistory> {
List<String> selectBatchNosFieldValues(String userId);
List<String> selectAllBatchNosFieldValues();
SysHistory selectHistoryOne(String taskId);
List<UserHistoryMap> getUserHistory(String userId);
List<UserHistoryMap> getAllUserHistory();
}
@@ -0,0 +1,9 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.entity.SysRoomCloth;
public interface SysRoomClothMapper extends BaseMapper<SysRoomCloth> {
}
@@ -0,0 +1,9 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.entity.SysRoom;
public interface SysRoomMapper extends BaseMapper<SysRoom> {
}
@@ -0,0 +1,8 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.entity.SysTaskQueue;
public interface SysTaskQueueMapper extends BaseMapper<SysTaskQueue> {
}
@@ -0,0 +1,9 @@
package digital.application.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.application.entity.SysWhiteUser;
public interface SysWhiteUserMapper extends BaseMapper<SysWhiteUser> {
}
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.MwTrainTaskMapper">
</mapper>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysContactMapper">
</mapper>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysFileMapper">
<select id="queryClothTypeList" resultType="digital.application.vo.QueryClothTypeListVO">
select *
from sys_file ${ew.customSqlSegment}
</select>
<select id="selectWithoutLogicDeleteById" resultType="digital.application.entity.SysFile"
parameterType="java.lang.String">
select *
from sys_file
where id = #{clothId}
</select>
</mapper>
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysHistoryMapper">
<select id="selectBatchNosFieldValues" parameterType="string" resultType="java.lang.String">
SELECT DISTINCT sys_history.batch_no
FROM sys_history
WHERE sys_history.del_flag = 0
and sys_history.user_id = #{userId}
</select>
<select id="selectAllBatchNosFieldValues" resultType="java.lang.String">
SELECT DISTINCT sys_history.batch_no
FROM sys_history
WHERE del_flag = 0
</select>
<select id="selectHistoryOne" resultType="digital.application.entity.SysHistory"
parameterType="java.lang.String">
SELECT *
FROM sys_history
WHERE task_id = #{taskId}
</select>
<select id="getUserHistory" resultType="digital.application.dto.UserHistoryMap" parameterType="java.lang.String">
SELECT batch_no as batchNo,
MIN(create_time) AS createTime,
GROUP_CONCAT(CONCAT(id, '#', file_url) SEPARATOR ',') AS historyIdFileUrls
FROM sys_history
WHERE batch_no IN (SELECT DISTINCT batch_no
FROM sys_history
WHERE del_flag = 0
and sys_history.user_id = #{userId})
and del_flag = 0
GROUP BY batch_no
</select>
<select id="getAllUserHistory" resultType="digital.application.dto.UserHistoryMap">
SELECT batch_no as batchNo,
MIN(create_time) AS createTime,
GROUP_CONCAT(CONCAT(id, '#', file_url) SEPARATOR ',') AS historyIdFileUrls
FROM sys_history
WHERE batch_no IN (SELECT DISTINCT batch_no FROM sys_history WHERE del_flag = 0)
and del_flag = 0
GROUP BY batch_no
</select>
</mapper>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysRoomClothMapper">
</mapper>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysRoomMapper">
</mapper>
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysTaskQueueMapper">
</mapper>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.application.mapper.SysWhiteUserMapper">
</mapper>
@@ -0,0 +1,183 @@
//package digital.application.service;
//
//import com.alibaba.fastjson.JSONObject;
//import digital.application.dto.TryOnDTO;
//import digital.application.entity.SysFile;
//import digital.application.entity.SysHistory;
//import digital.application.mapper.MwTrainTaskMapper;
//import digital.application.mapper.SysFileMapper;
//import digital.application.mapper.SysHistoryMapper;
//import digital.base.constant.CommonConstant;
//import digital.base.constant.Face3dSeverHTTPConstant;
//import digital.base.constant.ZitaCommonConstant;
//import digital.bean.task.MwTrainTask;
//import digital.config.oss.OssConfiguration;
//import digital.util.oss.OssBootUtil;
//import digital.util.util.RestUtil;
//import digital.util.util.oConvertUtils;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpMethod;
//import org.springframework.http.ResponseEntity;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//import java.util.Arrays;
//import java.util.List;
//import java.util.UUID;
//
//@Component
//@Slf4j
//public class AsyncService {
// @Autowired
// OssConfiguration ossConfiguration;
// @Autowired
// private SysFileMapper sysFileMapper;
// @Autowired
// private MwTrainTaskMapper trainTaskMapper;
// @Autowired
// private SysHistoryMapper sysHistoryMapper;
//
//// @Transactional
// @Async("defaultThreadPoolExecutor")
// public void syncCommon(List<SysHistory> sysHistoryList, TryOnDTO tryOns, String userId) {
// String batchNo = UUID.randomUUID().toString();
// log.info("开始同步任务" + batchNo);
// List<TryOnDTO.TryOn> tryOnDTOList = tryOns.getTryOnList();
// ////////////////// 开始处理试穿 /////////////////////
// for (int i = 0; i < tryOnDTOList.size(); i++) {
// String taskId = UUID.randomUUID().toString();
// log.info(taskId + "开始处理试穿");
// TryOnDTO.TryOn tryOnDTO = tryOnDTOList.get(i);
// SysHistory sysHistory = sysHistoryList.get(i);
// String modelId = tryOnDTO.getModelId();
// SysFile modelImage = sysFileMapper.selectById(modelId);
// if (modelImage == null) {
// log.info(taskId + "数据库中无此数据! modelId=" + modelId);
// continue;
// }
// List<String> clothIds = tryOnDTO.getClothIds();
// JSONObject jsonObject = new JSONObject();
// MwTrainTask trainTask = new MwTrainTask();
// trainTask.setTaskId(taskId);
// trainTask.setUserId(userId);
// trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
// trainTask.setClothPath(String.join(",", clothIds));
// trainTaskMapper.insert(trainTask);
// //给历史记录添加taskid
// sysHistory.setTaskId(taskId);
// sysHistoryMapper.updateById(sysHistory);
// //添加完毕
// int size = clothIds.size();
// if (size == 1) {
// for (String clothId : clothIds) {
// SysFile clothImage = sysFileMapper.selectById(clothId);
// if (clothImage != null) {
// if ("topCloth".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "0", clothImage.getProcessType());
// jsonObject.put("upper", list);
// jsonObject.put("lower", "");
// }
// if ("bottomCloth".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "1", clothImage.getProcessType());
// jsonObject.put("upper", "");
// jsonObject.put("lower", list);
// }
// if ("dress".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "2", clothImage.getProcessType());
// jsonObject.put("upper", list);
// jsonObject.put("lower", "");
// }
// }
// }
// }
// if (size == 2) {
// if (clothIds != null && clothIds.size() > 0) {
// for (String clothId : clothIds) {
// SysFile clothImage = sysFileMapper.selectById(clothId);
// if (clothImage != null) {
// if ("topCloth".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "0", clothImage.getProcessType());
// jsonObject.put("upper", list);
// }
// if ("bottomCloth".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "0", clothImage.getProcessType());
// jsonObject.put("lower", list);
// }
// if ("dress".equals(clothImage.getClothType())) {
// List<String> list = Arrays.asList(clothImage.getMaterialPath(), "0", clothImage.getProcessType());
// jsonObject.put("upper", list);
// jsonObject.put("lower", "");
// }
// }
// }
// }
// }
// trainTask.setModelPath(modelImage.getFilePath());
// long startTime = System.currentTimeMillis();
// JSONObject clothParam = new JSONObject();
// clothParam.put("task_id", taskId);
// clothParam.put("userImgPath", modelImage.getFilePath());
// if (oConvertUtils.isNotEmpty(modelImage.getSex())) {
// clothParam.put("sex", modelImage.getSex());
// } else {
// clothParam.put("sex", "female");
// }
// clothParam.put("data_dict", jsonObject);
// log.info("算法 clothParam =" + clothParam);
// try {
// String url;
// if (ZitaCommonConstant.sex_male.equals(modelImage.getSex())) {
// url = Face3dSeverHTTPConstant.SWAP_CLOTH_MALE;
// } else {
// url = Face3dSeverHTTPConstant.SWAP_CLOTH;
// }
// ResponseEntity<JSONObject> clothResult = RestUtil.zitaRequest(url,
// HttpMethod.POST, null, clothParam, JSONObject.class);
// String clothState = clothResult.getBody().get("status").toString();
// log.info(taskId + " 返回结果信息成功 ==" + taskId + " clothResult=" + clothResult.getBody());
// if (!ZitaCommonConstant.STATUS_NORMAL.equals(clothState)) {
// trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
// trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
// trainTask.setRequestResult(String.format("digital cloth 任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
// trainTaskMapper.updateById(trainTask);
// log.info(String.format("digital cloth 任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
// sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
// sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
// sysHistoryMapper.updateById(sysHistory);
// continue;
// }
// // 尝试将返回结果转为JSON
// JSONObject resultBody = clothResult.getBody();
// String imagePath = (String) resultBody.get("data");
// File file = new File(imagePath);
// String newFileName = UUID.randomUUID().toString() + file.getName().substring(file.getName().lastIndexOf("."));
// String fileUrl = OssBootUtil.uploadOssVideo(file, CommonConstant.PUTON_SWAP, newFileName);
// String savePath = OssBootUtil.getDigitalObjectURL(ossConfiguration.getBucketName(), fileUrl, null);
// log.info("oss 图片 savePath=" + savePath);
// trainTask.setResultImages(savePath);
// trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
// trainTask.setResult(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
// long endTime = System.currentTimeMillis();
// long duration = (endTime - startTime) / 1000; // 除以1000将毫秒转换为秒
// trainTask.setCostTime((int) duration);
// trainTaskMapper.updateById(trainTask);
// //替换换装后的照片
// sysHistory.setFileUrl(savePath);
// sysHistory.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
// sysHistoryMapper.updateById(sysHistory);
// } catch (Exception ex) {
// String message = ex.getMessage();
// trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
// trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
// trainTask.setRequestResult("digital cloth 任务失败!" + String.format("%s {taskId: %s}", message, taskId));
// trainTaskMapper.updateById(trainTask);
// log.info("digital cloth 任务失败!" + String.format("%s {taskId: %s}", message, taskId));
// sysHistory.setFileUrl(CommonConstant.TRY_ON_FAIL);
// sysHistory.setStatus(Face3dSeverHTTPConstant.result_fail);
// sysHistoryMapper.updateById(sysHistory);
// }
// }
// }
//}
@@ -0,0 +1,43 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.dto.TrainTaskCallbackDTO;
import org.springframework.web.multipart.MultipartFile;
import digital.base.vo.Result;
import digital.bean.task.MwTrainTask;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* @Description: mw_train_task
* @Author: jeecg-boot
* @Date: 2023-10-06
* @Version: V1.0
*/
public interface IMwTrainTaskService extends IService<MwTrainTask> {
/**
* 数字人服务
* @return
* @param clothFileList
* @param modelFileList
*/
Result<?> getFace3dSever(List<MultipartFile> clothFileList, List<MultipartFile> modelFileList, MultipartFile tileFile) ;
/**
* 换装体验任务 回调
* @param trainTaskCallbackDTO
* @return
*/
Result<?> trainTaskCallback(TrainTaskCallbackDTO trainTaskCallbackDTO);
/**
*
* @return
*/
Result<?> getCostTime();
}
@@ -0,0 +1,18 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.dto.SubmitContactInfoDTO;
import digital.application.entity.SysContact;
import digital.base.vo.Result;
/**
* @Description: sys_contact
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
public interface ISysContactService extends IService<SysContact> {
Result<?> submitContactInfo(SubmitContactInfoDTO submitContactInfoDTO);
}
@@ -0,0 +1,151 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.dto.*;
import digital.application.dto.tjHair.GetHairDataDTO;
import digital.application.entity.SysFile;
import digital.base.vo.Result;
import digital.bean.task.DpUser;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
public interface ISysFileService extends IService<SysFile> {
/**
* 衣服类型图片-分页列表查询
*
* @param page
* @param clothType
* @return
*/
Result<?> queryClothTypeList(Page<SysFile> page, String clothType);
/**
* 上传图片分类
*
* @return
*/
Result<?> uploadCloth(UploadClothDTO uploadClothDTO);
/**
* 衣服类型图片所有数据查询
*
* @param clothType
* @return
*/
Result<?> clothList(QueryClothTypeDTO clothType);
Result<?> uploadFileCloth(MultipartFile files);
Result<?> uploadModel(MultipartFile file, String sex) throws IOException;
/**
* 获取模特列表
*
* @return
*/
Result<?> getModelList(GetModelDTO sex);
/**
* 试穿
*
* @param tryOnDTO
* @return
*/
Result<?> tryOn(TryOnDTO tryOnDTO);
/**
* @param callBackDTO
* @return
*/
Result<?> callBack(CallBackDTO callBackDTO);
/**
* 抓取图片
*
* @param crawlerUrl
* @return
*/
Result<?> grabPicture(String crawlerUrl);
/**
* 加入衣橱
*
* @param addWardrobeDTO
* @return
*/
Result<?> addWardrobe(AddWardrobeDTO addWardrobeDTO);
/**
* 取消加入
*
* @param unJoinDTO
* @return
*/
Result<?> unJoin(UnJoinDTO unJoinDTO);
/**
* 查看试穿历史数据
*
* @return
*/
Result<?> getTryOnHistory();
/**
* 查看写死手机号试穿的历史数据
*
* @return
*/
Result<?> getTargetTryOnHistory(DpUser dpUser);
/**
* 加入套装
*
* @param addSuitDTO
* @return
*/
Result<?> addSuit(AddSuitDTO addSuitDTO);
/**
* @param file
* @return
*/
Result<?> uploadAvatar(MultipartFile file);
Result<?> tryOnCallBack(TryOnCallBackDTO tryOnCallBackDTO);
Result<?> unTryOn(UnTryOnDTO unTryOnDTO);
/**
* 批量删除历史数据
*
* @param batchDelHistoryDTO
* @return
*/
Result<?> batchDelHistory(BatchDelHistoryDTO batchDelHistoryDTO);
/**
* 购买链接
*
* @param buyLinksDTO
* @return
*/
Result<?> buyLink(BuyLinksDTO buyLinksDTO);
Result<?> batchUploadClothFile(MultipartFile[] files);
Result<?> getHairData(GetHairDataDTO getHairData);
Result<?> swapHair(DpUser dpUser, String isHr, String clothIds, MultipartFile[] file, String sex);
Result<?> swapHairAsync(DpUser dpUser, String isHr, String clothIds, MultipartFile[] file, String modelUrls, String sex);
Result<?> getSwapHairHistory(DpUser dpUser);
Result<?> getSwapHairHistoryByTaskId(String taskId);
}
@@ -0,0 +1,8 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.entity.SysHistory;
public interface SysHistoryService extends IService<SysHistory> {
}
@@ -0,0 +1,64 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.dto.*;
import digital.application.entity.SysRoom;
import digital.base.vo.Result;
public interface SysRoomService extends IService<SysRoom> {
/**
* 添加专题试衣间
*
* @param addRoomDTO
* @return
*/
Result<?> addRoom(AddRoomDTO addRoomDTO);
/**
* 删除专题试衣间
*
* @param delRoomDTO
* @return
*/
Result<?> delRoom(DelRoomDTO delRoomDTO);
/**
* 修改专题试衣间
*
* @param updateRoomDTO
* @return
*/
Result<?> updateRoom(UpdateRoomDTO updateRoomDTO);
/**
* 查询本人专题试衣间
*
* @return
*/
Result<?> getRoomList(GetRoomListDTO getRoomListDTO);
/**
* 专题试衣间-添加衣服
*
* @param addRoomClothDTO
* @return
*/
Result<?> addRoomCloth(AddRoomClothDTO addRoomClothDTO);
/**
* 专题试衣间-查询对应试衣间列表
*
* @return
*/
Result<?> getRoomClothList(GetRoomClothListDTO getRoomClothListDTO);
/**
* 专题试衣间-删除衣服
*
* @param addRoomClothDTO
* @return
*/
Result<?> delRoomCloth(AddRoomClothDTO addRoomClothDTO);
}
@@ -0,0 +1,9 @@
package digital.application.service;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.application.entity.SysTaskQueue;
public interface SysTaskQueueService extends IService<SysTaskQueue> {
}
@@ -0,0 +1,218 @@
package digital.application.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.application.dto.TrainTaskCallbackDTO;
import digital.application.mapper.MwTrainTaskMapper;
import digital.application.service.IMwTrainTaskService;
import digital.base.constant.CommonConstant;
import digital.base.constant.Face3dSeverHTTPConstant;
import digital.base.vo.LoginUser;
import digital.base.vo.Result;
import digital.bean.task.MwTrainTask;
import digital.util.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Service
@Slf4j
public class MwTrainTaskServiceImpl extends ServiceImpl<MwTrainTaskMapper, MwTrainTask> implements IMwTrainTaskService {
@Autowired
private MwTrainTaskMapper trainTaskMapper;
@Value("${cloth.uploaded_folder}")
private String uploaded_folder;
@Override
public Result<?> getCostTime() {
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
QueryWrapper<MwTrainTask> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(MwTrainTask::getUserId, loginUser.getId());
queryWrapper.lambda().eq(MwTrainTask::getDelFlag, CommonConstant.DEL_FLAG_0);
queryWrapper.lambda().eq(MwTrainTask::getStatus, Face3dSeverHTTPConstant.CREATE_STATUS_SUCCESS);
queryWrapper.lambda().orderByDesc(MwTrainTask::getCreateTime);
queryWrapper.lambda().last("LIMIT 1");
MwTrainTask mwTrainTask = trainTaskMapper.selectOne(queryWrapper);
if (mwTrainTask == null){
return Result.ok(0);
}
Integer costTime = (mwTrainTask.getCostTime() != null) ? mwTrainTask.getCostTime() : 0;
return Result.ok(costTime);
}
@Override
public Result<?> getFace3dSever(List<MultipartFile> clothFileList, List<MultipartFile> modelFileList, MultipartFile tileFile) {
// String taskId = UUID.randomUUID().toString();
// log.info("开始===执行任务!!!"+taskId);
// log.info("clothFileList " + clothFileList + " modelFileList=" + modelFileList + " tileFile=" + tileFile);
// if (CollectionUtil.isEmpty(clothFileList) || null == tileFile) {
// return Result.error("平铺图和服装图不能为空!", taskId);
// }
// MwTrainTask trainTask = new MwTrainTask();
// trainTask.setTaskId(taskId);
// ////////////////////////////////////// 开始处理 clothFileList ////////////////////////////////////////////////////////////////////
// log.info("开始处理 clothFileList ");
// List<String> clothPath = new ArrayList<>();
// if (!CollectionUtil.isEmpty(clothFileList)) {
// for (MultipartFile file : clothFileList) {
// if (file != null) {
// log.info(taskId + " 上传 cloth ========================" + file.getOriginalFilename());
// // 生成UUID文件名
// String newFileName = UUID.randomUUID().toString() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
// log.info(taskId + " 上传 cloth 改名 ========================" + newFileName);
// try {
// String pathName = uploaded_folder + Face3dSeverHTTPConstant.UPLOADED_FOLDER_CLOTH + newFileName;
// Path path = Paths.get(pathName);
// // 检查文件路径是否存在
// if (!Files.isDirectory(path)) {
// // 如果不存在则创建路径中的目录
// Files.createDirectories(path.getParent());
// log.info("cloth 路径不存在,已创建。");
// } else {
// log.info("cloth 路径已存在。");
// }
// byte[] bytes = file.getBytes();
// Files.write(path, bytes);
// clothPath.add(pathName);
// } catch (IOException e) {
// log.info(taskId + "cloth 落盘失败:", e);
// log.info(taskId + " 上传 cloth ========================" + String.format("图片落盘失败!{taskId: %s}", taskId));
// }
// }
// }
// String commaSeparatedString = String.join(",", clothPath);
// trainTask.setClothPath(commaSeparatedString);
// }
// ////////////////////////////////////// 开始处理 modelFileList ////////////////////////////////////////////////////////////////////
// log.info(" 开始处理 clothFileList ");
// List<String> modelPath = new ArrayList<>();
// if (!CollectionUtil.isEmpty(modelFileList)) {
// for (MultipartFile file : modelFileList) {
// if (file != null) {
// log.info(taskId + " 上传 model ========================" + file.getOriginalFilename());
// // 生成UUID文件名
// String newFileName = UUID.randomUUID().toString() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
// log.info(taskId + " 上传 model 改名 ========================" + newFileName);
// try {
// String pathName = uploaded_folder + Face3dSeverHTTPConstant.UPLOADED_FOLDER_MODEL + newFileName;
// Path path = Paths.get(pathName);
// // 检查文件路径是否存在
// if (!Files.isDirectory(path)) {
// // 如果不存在则创建路径中的目录
// Files.createDirectories(path.getParent());
// log.info("model 路径不存在,已创建。");
// } else {
// log.info("model 路径已存在。");
// }
// byte[] bytes = file.getBytes();
// Files.write(path, bytes);
// modelPath.add(pathName);
// } catch (IOException e) {
// log.info(taskId + "model 落盘失败:", e);
// log.info(taskId + " 上传 model 改名 ========================" + String.format(" model 落盘失败!{taskId: %s}", taskId));
// }
// }
// }
// String modelPathString = String.join(",", modelPath);
// trainTask.setModelPath(modelPathString);
// }
//
// ////////////////////////////////////// 开始处理 平铺图 ////////////////////////////////////////////////////////////////////
// String tilePath = null;
// if (null != tileFile) {
// log.info(taskId + " 上传 平铺图 ========================" + tileFile.getOriginalFilename());
// // 生成UUID文件名
// String newFileName = UUID.randomUUID().toString() + tileFile.getOriginalFilename().substring(tileFile.getOriginalFilename().lastIndexOf("."));
// log.info(taskId + " 上传 平铺图 改名 ========================" + newFileName);
// try {
// tilePath = uploaded_folder + Face3dSeverHTTPConstant.UPLOADED_FOLDER_TILE + newFileName;
// Path path = Paths.get(tilePath);
// // 检查文件路径是否存在
// if (!Files.isDirectory(path)) {
// // 如果不存在则创建路径中的目录
// Files.createDirectories(path.getParent());
// log.info("平铺图 路径不存在,已创建。");
// } else {
// log.info("平铺图 路径已存在。");
// }
// byte[] bytes = tileFile.getBytes();
// Files.write(path, bytes);
// } catch (IOException e) {
// log.info(taskId + "平铺图 落盘失败:", e);
// log.info(taskId + " 上传 平铺图 改名 ========================" + String.format(" 平铺图 落盘失败!{taskId: %s}", taskId));
// }
// }
//
// trainTask.setTilePath(tilePath);
// trainTask.setStatus(Face3dSeverHTTPConstant.CREATE_STATUS_IN_PROGRESS);
// trainTaskMapper.insert(trainTask);
//
// JSONObject clothParam = new JSONObject();
// clothParam.put("taskId", taskId);
// clothParam.put("clothPathLists", clothPath);
// clothParam.put("modelPathLists", modelPath);
// clothParam.put("tilePath", tilePath);
// log.info("算法 clothParam =" + clothParam);
//
// try {
// ResponseEntity<JSONObject> clothResult = RestUtil.zitaRequest(Face3dSeverHTTPConstant.DIGITAL_CLOTH,
// HttpMethod.POST, null, clothParam, JSONObject.class);
// String clothState = clothResult.getBody().get("status").toString();
// log.info(taskId + " 返回结果信息成功 ==" + taskId + " status=" + clothState);
// if (!ZitaCommonConstant.STATUS_NORMAL.equals(clothState)) {
// trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
// trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
// trainTask.setRequestResult(String.format("digital cloth 任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
// trainTaskMapper.updateById(trainTask);
// log.info(String.format("digital cloth 任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
// return Result.error(String.format("digital cloth 任务失败!{taskId: %s, resp: %s}", taskId, clothResult.getBody().toJSONString()));
// }
// // 尝试将返回结果转为JSON
// JSONObject jsonObject = clothResult.getBody();
// log.info("data=" + jsonObject);
// return Result.ok("调用成功!!!");
// } catch (Exception ex) {
// String message = ex.getMessage();
// trainTask.setStatus(Face3dSeverHTTPConstant.result_fail);
// trainTask.setResult(Face3dSeverHTTPConstant.result_fail);
// trainTask.setRequestResult("digital cloth 任务失败!" + String.format("%s {taskId: %s}", message, taskId));
// trainTaskMapper.updateById(trainTask);
// log.info("digital cloth 任务失败!" + String.format("%s {taskId: %s}", message, taskId));
// return Result.error("digital cloth 任务失败!" + String.format("%s {taskId: %s}", message, taskId));
// }
return null;
}
@Override
public Result<?> trainTaskCallback(TrainTaskCallbackDTO trainTaskCallbackDTO) {
String taskId = trainTaskCallbackDTO.getTaskId();
log.info("进入回调方法 " + taskId + " trainTaskCallbackDTO= " + trainTaskCallbackDTO);
if (oConvertUtils.isEmpty(taskId)) {
log.info("taskId 不能为空!!");
return Result.error("taskId 不能为空!!");
}
QueryWrapper<MwTrainTask> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(MwTrainTask::getDelFlag, CommonConstant.DEL_FLAG_0);
queryWrapper.lambda().eq(MwTrainTask::getTaskId, taskId);
MwTrainTask mwTrainTask = trainTaskMapper.selectOne(queryWrapper);
if (null == mwTrainTask) {
log.info("数据库中无此任务信息!!");
return Result.error("数据库中无此任务信息!!");
}
mwTrainTask.setStatus(trainTaskCallbackDTO.getStatus());
List<String> urlList = trainTaskCallbackDTO.getUrlList();
String resultString = String.join(",", urlList);
mwTrainTask.setResultImages(resultString);
trainTaskMapper.updateById(mwTrainTask);
log.info("回调成功!!");
return Result.ok("回调成功!!");
}
}
@@ -0,0 +1,37 @@
package digital.application.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.application.dto.SubmitContactInfoDTO;
import digital.application.entity.SysContact;
import digital.application.mapper.SysContactMapper;
import digital.application.service.ISysContactService;
import digital.base.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
/**
* @Description: sys_contact
* @Author: jeecg-boot
* @Date: 2024-05-07
* @Version: V1.0
*/
@Service
public class SysContactServiceImpl extends ServiceImpl<SysContactMapper, SysContact> implements ISysContactService {
@Autowired
private SysContactMapper sysContactMapper;
@Override
public Result<?> submitContactInfo(SubmitContactInfoDTO submitContactInfoDTO) {
String taskId = UUID.randomUUID().toString();
SysContact sysContact = new SysContact();
sysContact.setName(submitContactInfoDTO.getName());
sysContact.setPhone(submitContactInfoDTO.getPhone());
sysContact.setCompany(submitContactInfoDTO.getCompany());
sysContact.setDescription(submitContactInfoDTO.getDescription());
sysContactMapper.insert(sysContact);
return Result.OK("提交信息成功!", taskId);
}
}
@@ -0,0 +1,13 @@
package digital.application.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.application.entity.SysHistory;
import digital.application.mapper.SysHistoryMapper;
import digital.application.service.SysHistoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SysHistoryServiceImpl extends ServiceImpl<SysHistoryMapper, SysHistory> implements SysHistoryService {
}
@@ -0,0 +1,199 @@
package digital.application.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.application.dto.*;
import digital.application.entity.SysFile;
import digital.application.entity.SysRoom;
import digital.application.entity.SysRoomCloth;
import digital.application.mapper.SysFileMapper;
import digital.application.mapper.SysRoomClothMapper;
import digital.application.mapper.SysRoomMapper;
import digital.application.service.SysRoomService;
import digital.application.vo.GetRoomListVO;
import digital.application.vo.QueryClothTypeListVO;
import digital.base.constant.CommonConstant;
import digital.base.vo.LoginUser;
import digital.base.vo.Result;
import digital.util.util.oConvertUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static digital.application.utils.TimeUtils.compareHour;
@Slf4j
@Service
public class SysRoomServiceImpl extends ServiceImpl<SysRoomMapper, SysRoom> implements SysRoomService {
@Autowired
private SysRoomMapper sysRoomMapper;
@Autowired
private SysRoomClothMapper sysRoomClothMapper;
@Autowired
private SysFileMapper sysFileMapper;
@Override
public Result<?> delRoomCloth(AddRoomClothDTO addRoomClothDTO) {
String taskId = UUID.randomUUID().toString();
SysRoomCloth sysRoomCloth = sysRoomClothMapper.selectOne(new QueryWrapper<SysRoomCloth>().lambda()
.eq(SysRoomCloth::getRoomId, addRoomClothDTO.getRoomId())
.eq(SysRoomCloth::getFileId, addRoomClothDTO.getClothId()));
if (null == sysRoomCloth) {
return Result.error("该试衣间不存在该衣服!", taskId);
}
sysRoomClothMapper.deleteById(sysRoomCloth.getId());
return Result.OK("删除成功!", taskId);
}
@Override
public Result<?> addRoomCloth(AddRoomClothDTO addRoomClothDTO) {
String taskId = UUID.randomUUID().toString();
Long count = sysRoomClothMapper.selectCount(new QueryWrapper<SysRoomCloth>().lambda()
.eq(SysRoomCloth::getRoomId, addRoomClothDTO.getRoomId())
.eq(SysRoomCloth::getFileId, addRoomClothDTO.getClothId()));
if (count > 0) {
return Result.error("该试衣间已添加该衣服!", taskId);
}
SysRoomCloth sysRoomCloth = new SysRoomCloth();
sysRoomCloth.setFileId(addRoomClothDTO.getClothId());
sysRoomCloth.setRoomId(addRoomClothDTO.getRoomId());
sysRoomClothMapper.insert(sysRoomCloth);
return Result.ok("添加成功!", taskId);
}
@Override
public Result<?> getRoomClothList(GetRoomClothListDTO getRoomClothListDTO) {
String taskId = UUID.randomUUID().toString();
String roomId = getRoomClothListDTO.getRoomId();
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
SysRoom sysRoom = sysRoomMapper.selectById(roomId);
if (null == sysRoom) {
return Result.OK("数据库中不存在该试衣间!", taskId);
}
//查询本人试衣间的衣服id
List<String> fileIds = new ArrayList<>();
List<SysRoomCloth> sysRoomCloths = sysRoomClothMapper.selectList(new QueryWrapper<SysRoomCloth>().lambda().eq(SysRoomCloth::getRoomId, roomId));
if (null != sysRoomCloths && sysRoomCloths.size() > 0) {
fileIds = sysRoomCloths.stream()
.map(SysRoomCloth::getFileId)
.collect(Collectors.toList());
}
//查询我的衣橱全部衣服
QueryWrapper<SysFile> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(SysFile::getIsTemp, "0");
queryWrapper.lambda().eq(SysFile::getDelFlag, CommonConstant.DEL_FLAG_0);
queryWrapper.lambda().eq(SysFile::getFileType, CommonConstant.CLOTH_FILE_TYPE);
queryWrapper.lambda().eq(SysFile::getIsPerson, CommonConstant.COMMON_YES);
queryWrapper.lambda().eq(SysFile::getSex, getRoomClothListDTO.getSex());
queryWrapper.lambda().and(
w -> w.and(
(w1 -> w1.eq(SysFile::getUserId, loginUser.getId()))
)
.or()
.like(SysFile::getCommonClothType, "in_")
);
queryWrapper.lambda().orderByDesc(SysFile::getCreateTime);
List<SysFile> sysFileList = sysFileMapper.selectList(queryWrapper);
List<QueryClothTypeListVO> sysFileListVO = new ArrayList<>();
if (sysFileList != null && sysFileList.size() > 0) {
for (SysFile sysFile : sysFileList) {
Date createTime = sysFile.getCreateTime();
boolean result = compareHour(createTime);
String fileStatus = sysFile.getFileStatus();
if ("disable".equals(fileStatus) && result) {
sysFileMapper.deleteById(sysFile);
continue;
}
QueryClothTypeListVO queryClothTypeListVO = new QueryClothTypeListVO();
queryClothTypeListVO.setFileStatus(sysFile.getFileStatus());
queryClothTypeListVO.setClothType(sysFile.getClothType());
queryClothTypeListVO.setFileUrl(sysFile.getFileUrl());
queryClothTypeListVO.setClothId(sysFile.getId());
if (fileIds.contains(sysFile.getId())) {
queryClothTypeListVO.setIsHas(CommonConstant.COMMON_YES);
} else {
queryClothTypeListVO.setIsHas(CommonConstant.COMMON_NO);
}
queryClothTypeListVO.setThumbnailFileUrl(sysFile.getThumbnailFileUrl());
sysFileListVO.add(queryClothTypeListVO);
}
}
return Result.OK(sysFileListVO, taskId);
}
@Override
public Result<?> getRoomList(GetRoomListDTO getRoomListDTO) {
String taskId = UUID.randomUUID().toString();
List<GetRoomListVO> getRoomListVOList = new ArrayList<>();
QueryWrapper<SysRoom> queryWrapper = new QueryWrapper<>();
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
queryWrapper.lambda().eq(SysRoom::getUserId, loginUser.getId());
queryWrapper.lambda().eq(SysRoom::getDelFlag, CommonConstant.DEL_FLAG_0);
queryWrapper.lambda().eq(oConvertUtils.isNotEmpty(getRoomListDTO.getSex()), SysRoom::getSex, getRoomListDTO.getSex());
queryWrapper.lambda().orderByDesc(SysRoom::getCreateTime);
List<SysRoom> sysRooms = sysRoomMapper.selectList(queryWrapper);
if (null != sysRooms && sysRooms.size() > 0) {
for (SysRoom sysRoom : sysRooms) {
GetRoomListVO getRoomListVO = new GetRoomListVO();
getRoomListVO.setCreateTime(sysRoom.getCreateTime());
getRoomListVO.setRoomId(sysRoom.getId());
getRoomListVO.setSex(sysRoom.getSex());
getRoomListVO.setRoomName(sysRoom.getRoomName());
getRoomListVOList.add(getRoomListVO);
}
return Result.OK(getRoomListVOList, taskId);
}
return Result.OK(getRoomListVOList, taskId);
}
@Override
public Result<?> addRoom(AddRoomDTO addRoomDTO) {
String taskId = UUID.randomUUID().toString();
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
Long count = sysRoomMapper.selectCount(new QueryWrapper<SysRoom>().lambda().eq(SysRoom::getUserId, loginUser.getId()));
if (count >= 7) {
return Result.error("最多只能创建7个试衣间!", taskId);
}
SysRoom sysRoom = new SysRoom();
sysRoom.setRoomName(addRoomDTO.getRoomName());
sysRoom.setUserId(loginUser.getId());
sysRoom.setSex(addRoomDTO.getSex());
sysRoomMapper.insert(sysRoom);
return Result.OK("添加成功!", taskId);
}
@Override
public Result<?> delRoom(DelRoomDTO delRoomDTO) {
String taskId = UUID.randomUUID().toString();
SysRoom sysRoom = sysRoomMapper.selectById(delRoomDTO.getRoomId());
if (null == sysRoom) {
return Result.error("数据库中无此数据!", taskId);
}
sysRoomMapper.deleteById(sysRoom.getId());
return Result.OK("删除成功!", taskId);
}
@Override
public Result<?> updateRoom(UpdateRoomDTO updateRoomDTO) {
String taskId = UUID.randomUUID().toString();
SysRoom sysRoom = sysRoomMapper.selectById(updateRoomDTO.getRoomId());
if (null == sysRoom) {
return Result.error("数据库中无此数据!", taskId);
}
sysRoom.setRoomName(updateRoomDTO.getRoomName());
sysRoomMapper.updateById(sysRoom);
return Result.OK("修改成功!", taskId);
}
}
@@ -0,0 +1,15 @@
package digital.application.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.application.entity.SysTaskQueue;
import digital.application.mapper.SysTaskQueueMapper;
import digital.application.service.SysTaskQueueService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class SysTaskQueueServiceImpl extends ServiceImpl<SysTaskQueueMapper, SysTaskQueue> implements SysTaskQueueService {
}
@@ -0,0 +1,120 @@
package digital.application.utils;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.mp3.MP3AudioHeader;
import org.jaudiotagger.audio.mp3.MP3File;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import java.io.File;
import java.net.URL;
import java.net.URLConnection;
public class AudioUtil {
public static boolean testUrlWithTimeOut(String urlString, int timeOutMillSeconds) {
URL url;
try {
url = new URL(urlString);
URLConnection co = url.openConnection();
co.setConnectTimeout(timeOutMillSeconds);
co.connect();
return true;
} catch (Exception e1) {
url = null;
return false;
}
}
/**
* 获取语音文件播放时长() 支持wav 格式
*
* @param filePath
* @return
*/
public static Float getDuration(String filePath) {
try {
File destFile = new File(filePath);
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(destFile);
AudioFormat format = audioInputStream.getFormat();
long audioFileLength = destFile.length();
int frameSize = format.getFrameSize();
float frameRate = format.getFrameRate();
float durationInSeconds = (audioFileLength / (frameSize * frameRate));
return durationInSeconds;
} catch (Exception e) {
e.printStackTrace();
return 0f;
}
}
/**
* 获取mp3语音文件播放时长() mp3
*
* @param filePath
* @return
*/
public static Float getMp3Duration(String filePath) {
try {
File mp3File = new File(filePath);
MP3File f = (MP3File) AudioFileIO.read(mp3File);
MP3AudioHeader audioHeader = (MP3AudioHeader) f.getAudioHeader();
return Float.parseFloat(audioHeader.getTrackLength() + "");
} catch (Exception e) {
e.printStackTrace();
return 0f;
}
}
/**
* 获取mp3语音文件播放时长()
*
* @param mp3File
* @return
*/
public static Float getMp3Duration(File mp3File) {
try {
//File mp3File = new File(filePath);
MP3File f = (MP3File) AudioFileIO.read(mp3File);
MP3AudioHeader audioHeader = (MP3AudioHeader) f.getAudioHeader();
return Float.parseFloat(audioHeader.getTrackLength() + "");
} catch (Exception e) {
e.printStackTrace();
return 0f;
}
}
/**
* 得到pcm文件的毫秒数
* <p>
* pcm文件音频时长计算
* 同图像bmp文件一样pcm文件保存的是未压缩的音频信息 16bits 编码是指每次采样的音频信息用2个字节保存可以对比下bmp文件用分别用2个字节保存RGB颜色的信息 16000采样率 是指 1秒钟采样 16000次常见的音频是44100HZ即一秒采样44100次 单声道 只有一个声道
* <p>
* 根据这些信息我们可以计算 1秒的16000采样率音频文件大小是 2*16000 = 32000字节 约为32K 1秒的8000采样率音频文件大小是 2*8000 = 16000字节 约为 16K
* <p>
* 如果已知录音时长可以根据文件的大小计算采样率是否正常
*
* @param filePath
* @return
*/
public static long getPCMDurationMilliSecond(String filePath) {
File file = new File(filePath);
//得到多少秒
long second = file.length() / 32000;
long milliSecond = Math.round((file.length() % 32000) / 32000.0 * 1000);
return second * 1000 + milliSecond;
}
}
@@ -0,0 +1,55 @@
//package digital.application.utils;
//
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import digital.base.constant.CommonConstant;
//import digital.system.jeecg.system.entity.SysUser;
//import digital.system.jeecg.system.service.ISysUserService;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.Enumeration;
//
//
//@Component
//@Slf4j
//public class AuthInterceptor implements HandlerInterceptor {
//
// @Autowired
// private ISysUserService sysUserService;
//
// @Override
// public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// // 从请求中获取账号和密码
// String appKey = request.getHeader("appKey");
// String appSecret = request.getHeader("appSecret");
// log.info("开始鉴权 appKey ="+appKey+" appSecret"+appSecret);
// // 调用UserService来验证账号和密码
// QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
// queryWrapper.lambda().eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0);
// queryWrapper.lambda().eq(SysUser::getAppKey,appKey);
// queryWrapper.lambda().eq(SysUser::getAppSecret,appSecret);
// SysUser sysUser = sysUserService.getOne(queryWrapper);
// log.info("登录用户信息="+sysUser);
// // 打印通过HttpServletRequest获取的参数
// Enumeration<String> paramNames = request.getParameterNames();
// while (paramNames.hasMoreElements()) {
// String paramName = paramNames.nextElement();
// String paramValue = request.getParameter(paramName);
// log.info("Parameter Name: " + paramName +" Parameter Value: "+paramValue);
// }
// if (null == sysUser) {
// log.info("验证失败,返回错误信息");
// // 验证失败返回错误信息
// response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "非法访问,请输入秘钥信息!!!");
// return false; // 拦截请求不继续执行
// }
// log.info("验证通过,继续执行请求");
// // 验证通过继续执行请求
// return true;
// }
//
//}
@@ -0,0 +1,116 @@
package digital.application.utils;
import com.volcengine.tos.*;
import com.volcengine.tos.auth.StaticCredentials;
import com.volcengine.tos.model.object.PutObjectInput;
import com.volcengine.tos.model.object.PutObjectOutput;
import com.volcengine.tos.transport.TransportConfig;
import java.io.InputStream;
public class CloudStorageService {
static Long startTime = 0l;
static Long endTime = 0l;
static String bucketPath = "hair/result/image/";
private static TOSV2 tosClient = null;
private static TOSV2 getInstance() {
if (tosClient == null) {
tosClient = createTosClient();
}
return tosClient;
}
private static TOSV2 createTosClient() {
String endpoint = "tos-accelerate.volces.com";
String region = "ap-southeast-1";
String accessKey = "AKLTMDA2YjdiNGRmZDJmNGM2Y2JiYTA2MDFmZTVhMGU2Yzc";
String secretKey = "WWpnMk1HWmxZV1l3TWpVME5EazJZemxtTkRrMU1ERTVNV0pqWlRFMFpqYw==";
int idleConnectionTimeMills = 60000;
int maxConnections = 64;
TransportConfig config = TransportConfig.builder()
.idleConnectionTimeMills(idleConnectionTimeMills)
.maxConnections(maxConnections)
.build();
TOSClientConfiguration configuration = TOSClientConfiguration.builder()
.transportConfig(config)
.region(region)
.endpoint(endpoint)
.credentials(new StaticCredentials(accessKey, secretKey))
.build();
TOSV2 tos = new TOSV2ClientBuilder().build(configuration);
return tos;
}
private static boolean saveByteDanceTos(String fileName, InputStream inputStream) {
startTime = System.currentTimeMillis();
TOSV2 tos = getInstance();
endTime = System.currentTimeMillis();
startTime = System.currentTimeMillis();
String bucketName = "hairstyle";
// TOSV2 提供的所有接口均会抛出 TosException 异常需要使用 try-catch 进行捕获并处理
try {
// 设置上传的桶名和对象名
String objKey = bucketPath + fileName;
PutObjectInput putObjectInput = new PutObjectInput().setBucket(bucketName).setKey(objKey).setContent(inputStream);
// 上传对象
PutObjectOutput output = tos.putObject(putObjectInput);
endTime = System.currentTimeMillis();
return true;
} catch (TosClientException e) {
// 操作失败捕获客户端异常一般情况是请求参数错误此时请求并未发送
System.out.println("putObject failed");
System.out.println("Message: " + e.getMessage());
if (e.getCause() != null) {
e.getCause().printStackTrace();
}
} catch (TosServerException e) {
// 操作失败捕获服务端异常可以获取到从服务端返回的详细错误信息
System.out.println("putObject failed");
System.out.println("StatusCode: " + e.getStatusCode());
System.out.println("Code: " + e.getCode());
System.out.println("Message: " + e.getMessage());
System.out.println("RequestID: " + e.getRequestID());
} catch (Throwable t) {
// 作为兜底捕获其他异常一般不会执行到这里
System.out.println("putObject failed");
System.out.println("unexpected exception, message: " + t.getMessage());
}
return false;
}
/**
* 上传文件 云存储
*
* @param fileName
* @param fileStream
* @return
*/
public static String saveFileToBucket(String fileName, InputStream fileStream) {
String resultUrl = null;
try {
boolean saveResult = saveByteDanceTos(fileName, fileStream);
if(saveResult){
resultUrl = "https://hairstyle.tos-accelerate.volces.com/"+bucketPath+fileName;
}
} catch (Exception e) {
e.printStackTrace();
}
return resultUrl;
}
}
@@ -0,0 +1,41 @@
package digital.application.utils;
public class CommonUtils {
public static boolean isChineseMobileNumber(String number) {
// 正则表达式判断手机号格式
String regex = "^1[3-9]\\d{9}$";
return number.matches(regex);
}
/**
* 检查路径是否以target结尾如果不以target结尾则替换最后一个'/'后的部分为target
*
* @param path
* @param target
* @return
*/
public static String checkAndReplaceLastSegment(String path, String target) {
// 找到最后一个'/'的位置
int lastIndex = path.lastIndexOf('/');
if (lastIndex == -1) {
// 如果没有'/'则直接返回原字符串或进行其他处理
return path;
}
// 截取最后一个'/'之后的部分
String lastSegment = path.substring(lastIndex + 1);
// 判断截取的部分是否与target相等
if (!lastSegment.equals(target)) {
// 如果不相等则构建新的路径用target替换截取的部分
return lastSegment;
}
// 如果相等则返回原路径
return lastSegment;
}
public static void main(String[] args) {
String originalPath = "/mnt/database2/online-server/cloth-v2-online/material_path/1813824941203513345";
String modifiedPath = checkAndReplaceLastSegment(originalPath, "1813824941203513345");
System.out.println(modifiedPath);
}
}
@@ -0,0 +1,57 @@
package digital.application.utils;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
public class FileUtils {
public static void downloadImage(String imageUrl, String localFilePath) throws IOException {
URL url = new URL(imageUrl);
URLConnection connection = url.openConnection();
InputStream inputStream = new BufferedInputStream(connection.getInputStream());
try (OutputStream outputStream = new FileOutputStream(localFilePath)) {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
} finally {
inputStream.close();
}
}
public static String getObjectNameFromUrl(URL url) {
String path = url.getPath();
if (path != null && !path.isEmpty()) {
int lastIndex = path.lastIndexOf('/');
if (lastIndex != -1) {
return path.substring(lastIndex + 1);
} else {
return path;
}
}
return null;
}
public static String getExtensionFromObjectName(String objectName) {
if (objectName != null && !objectName.isEmpty()) {
int lastIndex = objectName.lastIndexOf('.');
if (lastIndex != -1 && lastIndex < objectName.length() - 1) {
return objectName.substring(lastIndex + 1);
}
}
return null;
}
public static long getObjectSizeFromUrl(URL url) throws IOException {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("HEAD");
connection.connect();
long contentLength = connection.getContentLengthLong();
connection.disconnect();
return contentLength;
}
}
@@ -0,0 +1,64 @@
package digital.application.utils;
import java.io.File;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
public class ImageUtils {
public static List<String> uploadImagesInFolder(String folderPath) {
List<String> list = new ArrayList<>();
File folder = new File(folderPath);
File[] files = folder.listFiles();
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
// 递归处理子文件夹
uploadImagesInFolder(file.getAbsolutePath());
} else {
// 上传图片文件到 OSS
if (isImageFile(file.getName())) {
list.add(file.getAbsolutePath());
}
}
}
}
return list;
}
private static boolean isImageFile(String fileName) {
String[] imageExtensions = {"jpg", "jpeg", "png", "gif", "bmp"}; // 可能的图片文件扩展名
for (String extension : imageExtensions) {
if (fileName.toLowerCase().endsWith(extension)) {
return true;
}
}
return false;
}
public static boolean isImageAccessible(String urlString) {
try {
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout(3000);
connection.setReadTimeout(3000);
int responseCode = connection.getResponseCode();
// Check if the response code is 200 (OK) and the content type is an image
return (200 <= responseCode && responseCode < 300) &&
connection.getContentType().startsWith("image/");
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
public static void main(String[] args) {
String urlString = "https://copyright.bdstatic.com/vcg/creative/cc9c744cf9f7c864889c563cbdeddce6.jpg";
boolean isImageAccessible = isImageAccessible(urlString);
System.out.println("Is the URL a accessible image? " + isImageAccessible);
}
}
@@ -0,0 +1,61 @@
package digital.application.utils;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class LiveUtils {
public static void main(String[] args) {
// System.out.println(getSafeUrl("live.aicloud.fit", "digital-person-5619", System.currentTimeMillis()));
}
private static final char[] DIGITS_LOWER =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
/*
* KEY+ streamName + txTime
*/
public static String getSafeUrl(String key, String streamName, long txTime) {
String input = new StringBuilder().
append(key).
append(streamName).
append(Long.toHexString(txTime).toUpperCase()).toString();
String txSecret = null;
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
txSecret = byteArrayToHexString(
messageDigest.digest(input.getBytes("UTF-8")));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return txSecret == null ? "" :
new StringBuilder().
append("txSecret=").
append(txSecret).
append("&").
append("txTime=").
append(Long.toHexString(txTime).toUpperCase()).
toString();
}
public static String byteArrayToHexString(byte[] data) {
char[] out = new char[data.length << 1];
for (int i = 0, j = 0; i < data.length; i++) {
out[j++] = DIGITS_LOWER[(0xF0 & data[i]) >>> 4];
out[j++] = DIGITS_LOWER[0x0F & data[i]];
}
return new String(out);
}
}
@@ -0,0 +1,84 @@
package digital.application.utils;
import com.tencentcloudapi.asr.v20190614.AsrClient;
import com.tencentcloudapi.asr.v20190614.models.CreateRecTaskRequest;
import com.tencentcloudapi.asr.v20190614.models.CreateRecTaskResponse;
import com.tencentcloudapi.asr.v20190614.models.DescribeTaskStatusRequest;
import com.tencentcloudapi.asr.v20190614.models.DescribeTaskStatusResponse;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import lombok.extern.slf4j.Slf4j;
/**
* 腾讯云 api
*/
@Slf4j
public class TencentCloudApiUtils {
public static CreateRecTaskResponse CreateRecTask(String url) {
try {
// 实例化一个认证对象入参需要传入腾讯云账户 SecretId SecretKey此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId SecretKey 泄露并威胁账号下所有资源的安全性以下代码示例仅供参考建议采用更安全的方式来使用密钥
//请参见https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential("AKID2DHE0d7Xt8HHBsSuDRZXMK4gIm8LPNCu", "nS6at34xkQvGUcKtLj3B6qcJwSxKk8Ox");
// 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("asr.tencentcloudapi.com");
// 实例化一个client选项可选的没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
AsrClient client = new AsrClient(cred, "", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
CreateRecTaskRequest req = new CreateRecTaskRequest();
req.setEngineModelType("16k_zh");
req.setChannelNum(1L);
req.setResTextFormat(0L);
req.setSourceType(312L);
req.setSourceType(0L);
req.setUrl(url);
// 返回的resp是一个CreateRecTaskResponse的实例与请求对象对应
CreateRecTaskResponse resp = client.CreateRecTask(req);
// 输出json格式的字符串回包
// log.info("输出json格式的字符串回包="+CreateRecTaskResponse.toJsonString(resp));
return resp;
} catch (TencentCloudSDKException e) {
log.info("方法异常="+e.toString());
}
return null;
}
public static DescribeTaskStatusResponse describeTaskStatus(Long taskId) {
try {
// 实例化一个认证对象入参需要传入腾讯云账户 SecretId SecretKey此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId SecretKey 泄露并威胁账号下所有资源的安全性以下代码示例仅供参考建议采用更安全的方式来使用密钥请参见https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential("AKID2DHE0d7Xt8HHBsSuDRZXMK4gIm8LPNCu", "nS6at34xkQvGUcKtLj3B6qcJwSxKk8Ox");
// 实例化一个http选项可选的没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("asr.ap-beijing.tencentcloudapi.com");
// 实例化一个client选项可选的没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
AsrClient client = new AsrClient(cred, "ap-guangzhou", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
DescribeTaskStatusRequest req = new DescribeTaskStatusRequest();
req.setTaskId(taskId);
// 返回的resp是一个DescribeTaskStatusResponse的实例与请求对象对应
DescribeTaskStatusResponse resp = client.DescribeTaskStatus(req);
// 输出json格式的字符串回包
// log.info("describeTaskStatus="+DescribeTaskStatusResponse.toJsonString(resp));
return resp;
} catch (TencentCloudSDKException e) {
log.info("方法异常="+e.toString());
}
return null;
}
}
@@ -0,0 +1,78 @@
package digital.application.utils;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.Date;
public class TimeUtils {
public static boolean compareHour(Date createTime) {
// 获取当前时间
Date currentTime = new Date();
// 计算时间差单位为毫秒
long diffInMillies = Math.abs(currentTime.getTime() - createTime.getTime());
// 1小时的毫秒数 3600000; // 60 * 60 * 1000
long oneHourInMillis = 86400000; // 1天的毫秒数 86400000; // 24 * 60 * 60 * 1000
// 判断时间差是否超过1个小时
return diffInMillies > oneHourInMillis;
}
/**
* 获取当前时间的UTC格式时间
*
* @return 当前时间的UTC格式时间
*/
public static String getCurrentUtcTime() {
// 获取当前时间的UTC时间戳
Instant currentInstant = Instant.now();
// 将时间戳转换为UTC时区的ZonedDateTime对象
ZonedDateTime currentUtcZonedDateTime = currentInstant.atZone(ZoneId.of("UTC"));
// 格式化输出
return currentUtcZonedDateTime.format(java.time.format.DateTimeFormatter.ISO_DATE_TIME);
}
/**
* 获取2天后的UTC格式时间 String
*
* @return
*/
public static String getTwoDayLaterStringUtcTime() {
// 获取当前时间的UTC时间戳
Instant currentInstant = Instant.now();
// 将时间戳转换为UTC时区的ZonedDateTime对象
ZonedDateTime currentUtcZonedDateTime = currentInstant.atZone(ZoneId.of("UTC"));
// 添加一天的时间
ZonedDateTime oneDayLaterUtcZonedDateTime = currentUtcZonedDateTime.plus(6, ChronoUnit.DAYS);
// 格式化输出
return oneDayLaterUtcZonedDateTime.format(java.time.format.DateTimeFormatter.ISO_DATE_TIME);
}
/**
* 获取2天后的UTC格式时间 long
*
* @return
*/
public static long getTwoDayLaterLongUtcTime() {
// 获取当前的UTC时间
Instant now = Instant.now();
// 在当前时间上增加两天
Instant future = now.plus(2, ChronoUnit.DAYS);
// 转换为自1970年1月1日以来的毫秒数
long futureMillis = future.toEpochMilli();
return futureMillis;
}
public static void main(String[] args) {
// 获取当前时间的UTC格式时间
String currentUtcTime = TimeUtils.getCurrentUtcTime();
System.out.println("当前时间的UTC格式时间: " + currentUtcTime);
// 获取一天后的UTC格式时间
String oneDayLaterUtcTime = TimeUtils.getTwoDayLaterStringUtcTime();
System.out.println("一天后的UTC格式时间: " + oneDayLaterUtcTime);
}
}
@@ -0,0 +1,78 @@
package digital.application.utils;
import com.coremedia.iso.IsoFile;
import java.io.IOException;
public class VideoUtil {
/**
* 获取视频文件的播放长度(mp4mov格式)
* @param videoPath
* @return 单位为毫秒
*/
public static long getMp4Duration(String videoPath) throws IOException {
IsoFile isoFile = new IsoFile(videoPath);
long lengthInSeconds =
isoFile.getMovieBox().getMovieHeaderBox().getDuration() /
isoFile.getMovieBox().getMovieHeaderBox().getTimescale();
return lengthInSeconds;
}
/**
* 得到语音或视频文件时长,单位秒
* @param filePath
* @return
* @throws IOException
*/
public static long getDuration(String filePath) throws IOException {
String format = getVideoFormat(filePath);
long result = 0;
if("wav".equals(format)){
result = AudioUtil.getDuration(filePath).intValue();
}else if("mp3".equals(format)){
result = AudioUtil.getMp3Duration(filePath).intValue();
}else if("m4a".equals(format)) {
result = VideoUtil.getMp4Duration(filePath);
}else if("mov".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}else if("mp4".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}
return result;
}
/**
* 得到语音或视频文件时长,单位秒
* @param filePath
* @return
* @throws IOException
*/
public static long getDuration(String filePath,String format) throws IOException {
long result = 0;
if("wav".equals(format)){
result = AudioUtil.getDuration(filePath).intValue();
}else if("mp3".equals(format)){
result = AudioUtil.getMp3Duration(filePath).intValue();
}else if("m4a".equals(format)) {
result = VideoUtil.getMp4Duration(filePath);
}else if("mov".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}else if("mp4".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}
return result;
}
/**
* 得到文件格式
* @param path
* @return
*/
public static String getVideoFormat(String path){
return path.toLowerCase().substring(path.toLowerCase().lastIndexOf(".") + 1);
}
}
@@ -0,0 +1,30 @@
//package digital.application.utils;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//
///**
// * 拦截器 接口需要传输appkey 和appsecret
// */
//@Configuration
//public class WebConfig implements WebMvcConfigurer {
//
// public static String[] SIGN_URL_LIST = new String[]
// {"/login", "/doc.html", "/*/home", "/error", "/druid/**", "/swagger-ui.html", "/api/common/**",
// "/swagger**/**", "/webjars/**", "/v2/**",
// "/api/digital/custom_callback","/api/video/create_video_callback",
// "/**/*.js", "/**/*.css", "/swagger-resources",
// "/**/*.html", "/**/*.svg", "/**/*.pdf", "/**/*.jpg", "/**/*.png", "/**/*.ico", "/api-docs",
// "/", "/**/*.html"};
// @Autowired
// private AuthInterceptor authInterceptor;
//
// @Override
// public void addInterceptors(InterceptorRegistry registry) {
// registry.addInterceptor(authInterceptor)
// .addPathPatterns("/**") // 拦截所有路径可以根据需要调整
// .excludePathPatterns(SIGN_URL_LIST); // 排除不需要拦截的路径
// }
//}
@@ -0,0 +1,17 @@
package digital.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class CrawlerPictureVO {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "访问地址")
private String fileUrl;
@ApiModelProperty(value = "缩略图访问地址")
private String thumbnailFileUrl;
}
@@ -0,0 +1,18 @@
package digital.application.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class GetModelListVO {
@ApiModelProperty(value = "id")
private String id;
@ApiModelProperty(value = "访问地址")
private String fileUrl;
@ApiModelProperty(value = "缩略图访问地址")
private String thumbnailFileUrl;
}
@@ -0,0 +1,26 @@
package digital.application.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class GetRoomListVO {
@ApiModelProperty(value = "专题试衣间名称id")
private String roomId;
@ApiModelProperty(value = "专题试衣间名称")
private String roomName;
@ApiModelProperty(value = "性别")
private String sex;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "创建时间")
private Date createTime;
}

Some files were not shown because too many files have changed in this diff Show More