Commit 5e369b3e by 王祖波

ai视频创作

parent ea7f1271
......@@ -8,7 +8,10 @@ import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.template.ContentTemplateDTO;
import com.gic.content.api.dto.template.ContentTemplateTypeDTO;
import com.gic.content.api.qdto.template.CmeExportVideoQDTO;
import com.gic.content.api.qdto.template.ContentExportVideoQDTO;
import com.gic.content.api.qdto.template.ContentTemplateQDTO;
import com.gic.content.api.service.CmeFileApiService;
import com.gic.content.api.service.ContentTemplateApiService;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
......@@ -23,13 +26,13 @@ import com.gic.thirdparty.cloudfile.pojo.cme.CmeTaskProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Random;
/**
* 好办-AI创作
......@@ -43,6 +46,8 @@ public class ContentAIController {
private static final Logger log = LoggerFactory.getLogger(ContentAIController.class);
@Autowired
private CmeFileApiService cmeFileApiService;
@Autowired
private ContentTemplateApiService templateApiService;
@Autowired
private EnterpriseService enterpriseService;
......@@ -130,10 +135,23 @@ public class ContentAIController {
String enterpriseId = cmeExportVideo.getEnterpriseId();
EnterpriseDTO enterpriseDTO = enterpriseService.getEnterpriseById(enterpriseId);
String factoryCode = enterpriseDTO.getFactoryCode();
cmeExportVideo.setFactoryCode(factoryCode);
ContentExportVideoQDTO exportVideoQDTO = new ContentExportVideoQDTO();
exportVideoQDTO.setEnterpriseId(cmeExportVideo.getEnterpriseId());
exportVideoQDTO.setContentTemplateId(cmeExportVideo.getContentTemplateId());
exportVideoQDTO.setStoreId(cmeExportVideo.getStoreId());
exportVideoQDTO.setStoreCode(cmeExportVideo.getStoreCode());
exportVideoQDTO.setStoreName(cmeExportVideo.getStoreName());
exportVideoQDTO.setUserId(cmeExportVideo.getClerkId());
exportVideoQDTO.setUserCode(cmeExportVideo.getClerkCode());
exportVideoQDTO.setUserName(cmeExportVideo.getClerkName());
CmeExportVideoQDTO cmeExportVideoQDTO = EntityUtil.changeEntityByJSON(CmeExportVideoQDTO.class, cmeExportVideo);
cmeExportVideoQDTO.setFactoryCode(factoryCode);
try {
String taskId = CmeUtil.exportVideo(cmeExportVideo);
return RestResponse.successResult(taskId);
ServiceResponse<String> response = cmeFileApiService.cmeExportVideo(exportVideoQDTO, cmeExportVideoQDTO);
if (!response.isSuccess()) {
return RestResponse.failure(response.getCode(), response.getMessage());
}
return RestResponse.successResult(response.getResult());
} catch (Exception e) {
log.warn("剪辑视频导出:", e);
return RestResponse.failure("-1", "剪辑视频导出异常");
......@@ -152,27 +170,4 @@ public class ContentAIController {
return RestResponse.successResult(cmeTaskProcess);
}
@RequestMapping(value = "/test", method = RequestMethod.GET)
public SseEmitter streamStockPrice() {
SseEmitter emitter = new SseEmitter();
// 模拟生成实时股票价格并推送给客户端
Random random = new Random();
new Thread(() -> {
try {
while (true) {
// 生成随机的股票价格
double price = 100 + random.nextDouble() * 10;
// 构造股票价格的消息
String message = String.format("%.2f", price);
// 发送消息给客户端
emitter.send(SseEmitter.event().data(message,MediaType.TEXT_PLAIN));
// 休眠1秒钟
Thread.sleep(1000);
}
} catch (Exception e) {
emitter.completeWithError(e);
}
}).start();
return emitter;
}
}
......@@ -153,5 +153,7 @@
id="commissionSettleDetailApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.content.api.service.ContentMaterialCommentApiService"
id="contentMaterialCommentApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference id="cmeFileApiService" interface="com.gic.content.api.service.CmeFileApiService" timeout="10000" retries="0" check="false" />
</beans>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment