修改配置文件

新增文件下载
联调工作流
master
Diyu0904 2025-03-08 18:38:01 +08:00
parent b24626ee9b
commit 158066bc9d
17 changed files with 182 additions and 50 deletions

View File

@ -0,0 +1,67 @@
package com.mcwl.web.controller.communityCenter;
import com.mcwl.common.core.domain.R;
import com.obs.services.ObsClient;
import com.obs.services.exception.ObsException;
import com.obs.services.model.DownloadFileRequest;
import com.obs.services.model.DownloadFileResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* @author DaiZibo
* @date 2025/3/8
* @apiNote
*/
@RequestMapping("/downFile")
@RestController
public class DownloadFile {
@Autowired
private ObsClient obsClient;
@Value("${huawei.obs.bucketName}")
private String bucketName;
@GetMapping("/down")
public R down(@RequestParam String objectKey, String path) {
try {
DownloadFileRequest request = new DownloadFileRequest(bucketName, objectKey);
// 设置下载对象的本地文件路径
request.setDownloadFile(path);
// 设置分段下载时的最大并发数
request.setTaskNum(10);
// 设置分段大小为10MB
request.setPartSize(10 * 1024 * 1024);
// 开启断点续传模式
request.setEnableCheckpoint(true);
// 进行断点续传下载
DownloadFileResult result = obsClient.downloadFile(request);
System.out.println("downloadFile successfully");
System.out.println("Etag:" + result.getObjectMetadata().getEtag());
} catch (ObsException e) {
System.out.println("downloadFile failed");
// 请求失败,打印http状态码
System.out.println("HTTP Code:" + e.getResponseCode());
// 请求失败,打印服务端错误码
System.out.println("Error Code:" + e.getErrorCode());
// 请求失败,打印详细错误信息
System.out.println("Error Message:" + e.getErrorMessage());
// 请求失败,打印请求id
System.out.println("Request ID:" + e.getErrorRequestId());
System.out.println("Host ID:" + e.getErrorHostId());
e.printStackTrace();
} catch (Exception e) {
System.out.println("downloadFile failed");
// 其他异常信息打印
e.printStackTrace();
}
return R.ok();
}
}

View File

@ -17,6 +17,7 @@ import javax.validation.constraints.NotNull;
import java.util.List;
/**
* app
* @AuthorChenYan
* @Projectmcwl-ai
* @Packagecom.mcwl.web.controller.communityCenter
@ -36,7 +37,7 @@ public class PlaFormController extends BaseController {
/**
*
*/
@ApiOperation(value = "模型列表")
@ApiOperation(value = "官方连接方式二维码列表")
@PostMapping("/list")
public List<PlatForm> list(@RequestBody PlatForm platForm) {

View File

@ -1,6 +1,7 @@
package com.mcwl.web.controller.resource;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.obs.ObsUtils;
import com.mcwl.resource.service.impl.FileServiceImpl;
import com.mcwl.web.controller.common.OssUtil;
@ -251,4 +252,15 @@ public class FileController {
}
}
/**
*
* @return
*/
@ApiOperation(value = "校验文件hash是否重复")
@GetMapping("/selectHash")
public R selectHash(String hashCode,Integer type){
return fileService.selectHash(hashCode,type);
}
}

View File

@ -143,11 +143,11 @@ mall:
alipayCertPath: cert/dev/alipayPublicCert.crt
# 沙箱支付宝根证书路径
alipayRootCertPath: cert/dev/alipayRootCert.crt
notifyUrl: https://53a65908.r27.cpolar.top/ali/pay/notify
notifyUrl: http://1.13.246.108:8080/ali/pay/notify
# 沙箱支付宝网关
gatewayUrl: https://openapi-sandbox.dl.alipaydev.com/gateway.do
# 绑定回调
bindUrl: https://4b0ca615.r27.cpolar.top/ali/pay/callback
bindUrl: http://1.13.246.108:8080/ali/pay/callback
huawei:
obs:

View File

@ -158,7 +158,8 @@ public class SecurityConfig {
"/WorkFlowVersion/selectVersionByWorkId",
"/memberLevel/list",
"/memberLevel/getMemberBenefitList",
"/attention/selectAttentionList"
"/attention/selectAttentionList",
"/downFile/down"
).permitAll()
// 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()

View File

@ -201,4 +201,10 @@ public class ModelVersion extends BaseEntity {
@TableField(exist = false)
private Integer isCollect = 1;
/**
* hash
*/
@ApiModelProperty(value = "文件hash")
private String fileHash;
}

View File

@ -104,4 +104,10 @@ public class WorkFlowVersion {
@TableField(exist = false)
@ApiModelProperty(value = "是否收藏")
private Integer isCollect =1;
/**
* hash
*/
@ApiModelProperty(value = "文件hash")
private String fileHash;
}

View File

@ -23,4 +23,6 @@ public interface ModelVersionMapper extends BaseMapper<ModelVersion> {
void addModelVersion (ModelVersion modelVersion);
ModelVersion selectByHash(@Param("hashCode") String hashCode);
}

View File

@ -13,5 +13,5 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface ReportMapper extends BaseMapper<Report> {
void updateStatus(@Param("productId") Long productId, @Param("type") Integer type);
void updateStatus(@Param("productId") Long productId, @Param("type") Integer type, @Param("status") Integer status);
}

View File

@ -26,4 +26,6 @@ public interface WorkFlowVersionMapper extends BaseMapper<WorkFlowVersion> {
WorkFlowVersion selectByFileName(@Param("name") String name);
WorkFlowVersion selectByHash(@Param("hashCode") String hashCode);
}

View File

@ -1,6 +1,7 @@
package com.mcwl.resource.service;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
/**
* @author DaiZibo
@ -12,4 +13,6 @@ public interface FileService {
AjaxResult selectFileName(String name, String type);
AjaxResult selectFile(String name, String type);
R selectHash(String hashCode, Integer type);
}

View File

@ -1,6 +1,7 @@
package com.mcwl.resource.service.impl;
import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.WorkFlowVersion;
@ -85,4 +86,27 @@ public class FileServiceImpl implements FileService {
return AjaxResult.error("type不合法");
}
@Override
public R selectHash(String hashCode, Integer type) {
//0模型 1工作流
if (type == 0){
ModelVersion modelVersion = versionMapper.selectByHash(hashCode);
if (modelVersion != null){
return R.ok(0);
}
return R.ok(1);
}else {
WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByHash(hashCode);
if (workFlowVersion != null){
return R.ok(0);
}
return R.ok(1);
}
}
}

View File

@ -9,7 +9,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.mcwl.common.constant.Constants;
import com.mcwl.common.constant.DictConstants;
import com.mcwl.common.constant.HttpStatus;
import com.mcwl.common.core.domain.R;
@ -18,7 +17,6 @@ import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.common.utils.SecurityUtils;
import com.mcwl.common.utils.StringUtils;
import com.mcwl.common.utils.baidu.BaiduCensor;
import com.mcwl.common.utils.http.HttpUtils;
import com.mcwl.resource.domain.ModelProduct;
import com.mcwl.resource.domain.ModelVersion;
import com.mcwl.resource.domain.SysUserAttention;
@ -42,7 +40,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
@ -301,7 +302,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
private void audit(RequestModel requestModel) {
// 执行审核操作
// threadPoolTaskExecutor.submit(() -> {
threadPoolTaskExecutor.submit(() -> {
ModelProduct modelProduct = requestModel.getModelProduct();
if (modelProduct != null){
@ -437,41 +438,41 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
String key = modelVersion.getObjectKey();
//审核成功查看时候加密拉取文件到ui
if (modelVersion.getIsEncrypt() == 1){
// if (modelVersion.getIsEncrypt() == 1){
//
// //调用加密/创建参数
// HashMap<String, String> param = new HashMap<>();
// param.put("object_key",modelVersion.getObjectKey());
// param.put("model_id",modelVersion.getId()+"");
// param.put("file_type", Constants.MODEL);
//
// String s = HttpUtils.pythonPost("http://1.13.246.108:9090/encrypt_and_upload", param);
//
// JSONObject jsonObject = JSONObject.parseObject(s);
// JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
// String objectKey = data.getString("objectKey");
// String path = data.getString("path");
// String secretKey = data.getString("secret_key");
//
// key = objectKey;
//
// ModelVersion modelVersion1 = ModelVersion.builder().id(modelVersion.getId())
// .encryptionObjectKey(objectKey)
// .encryptionFilePath(path)
// .keyRate(secretKey).build();
// //更新加密后数据
// modelVersionMapper.updateById(modelVersion1);
// }
//调用加密/创建参数
HashMap<String, String> param = new HashMap<>();
param.put("object_key",modelVersion.getObjectKey());
param.put("model_id",modelVersion.getId()+"");
param.put("file_type", Constants.MODEL);
String s = HttpUtils.pythonPost("http://1.13.246.108:9090/encrypt_and_upload", param);
JSONObject jsonObject = JSONObject.parseObject(s);
JSONObject data = JSONObject.parseObject(jsonObject.getString("data"));
String objectKey = data.getString("objectKey");
String path = data.getString("path");
String secretKey = data.getString("secret_key");
key = objectKey;
ModelVersion modelVersion1 = ModelVersion.builder().id(modelVersion.getId())
.encryptionObjectKey(objectKey)
.encryptionFilePath(path)
.keyRate(secretKey).build();
//更新加密后数据
modelVersionMapper.updateById(modelVersion1);
}
//调用ui拉取文件接口
log.info("开始拉取文件...");
HashMap<String, String> hashMap = new HashMap<>();
hashMap.put("objectKey",key);
log.info("整体版本数据:{}",modelVersion);
log.info("拉取文件数据:{}",key);
hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+""));
String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
log.info("文件拉取结果:{}",s);
// //调用ui拉取文件接口
// log.info("开始拉取文件...");
// HashMap<String, String> hashMap = new HashMap<>();
// hashMap.put("objectKey",key);
// log.info("整体版本数据:{}",modelVersion);
// log.info("拉取文件数据:{}",key);
// hashMap.put("type",DictInit.getDictValue(DictConstants.MODEL_TYPE,modelProduct.getModelType()+""));
// String s = HttpUtils.pythonPost("http://1.13.246.108:8188/api/experiment/models/upload", hashMap);
// log.info("文件拉取结果:{}",s);
//修改为合格
modelProduct.setAuditText("");
@ -481,7 +482,7 @@ public class ModelServiceImpl extends ServiceImpl<ModelMapper,ModelProduct> impl
}
}
// });
});
}

View File

@ -89,7 +89,7 @@ public class ReportServiceImpl implements ReportService {
public void updateStatus(Long productId,Integer type,Integer status,String text) {
//修改所有同类举报申请
reportMapper.updateStatus(productId,type);
reportMapper.updateStatus(productId,type,status);
if (status == 2){
//修改状态回退

View File

@ -8,7 +8,7 @@
model_id,version_name,version_description,model_version_type, file_path,file_name, trigger_words, sampling, high, vae, cfg,
is_free, is_public, is_encrypt, is_online_use, allow_download_image,
allow_software_use, allow_fusion, allow_commercial_use, allow_usage,
is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size
is_exclusive_model, sample_image_paths, hide_image_gen_info, del_flag,file_size,file_hash
)
VALUES
(
@ -17,7 +17,7 @@
#{isFree}, #{isPublic}, #{isEncrypt}, #{isOnlineUse},
#{allowDownloadImage}, #{allowSoftwareUse}, #{allowFusion},
#{allowCommercialUse}, #{allowUsage}, #{isExclusiveModel},
#{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize}
#{sampleImagePaths}, #{hideImageGenInfo},'0',#{fileSize},#{fileHash}
)
</insert>
@ -51,5 +51,8 @@
<select id="selectByFileName" resultType="com.mcwl.resource.domain.ModelVersion">
select key_rate,is_encrypt from model_version where file_name = #{name}
</select>
<select id="selectByHash" resultType="com.mcwl.resource.domain.ModelVersion">
select * from model_version where file_hash = #{hashCode}
</select>
</mapper>

View File

@ -7,7 +7,7 @@
<update id="updateStatus">
UPDATE report
SET status = 0
SET status = #{status}
WHERE product_id = #{productId} and type = #{type}
</update>

View File

@ -7,11 +7,11 @@
<insert id="addWorkFlowVersion">
INSERT INTO work_flow_version (version_name,version_description,file_path,image_paths,hide_gen_info,del_flag,
work_flow_id,file_name,file_size)
work_flow_id,file_name,file_size,file_hash)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.versionName}, #{item.versionDescription}, #{item.filePath}, #{item.imagePaths},#{item.hideGenInfo},
0,#{workFlow.id},#{item.fileName},#{item.fileSize})
0,#{workFlow.id},#{item.fileName},#{item.fileSize},#{item.fileHash})
</foreach>
</insert>
<update id="updateWorkFlowVersion">
@ -26,4 +26,8 @@
<select id="selectByFileName" resultType="com.mcwl.resource.domain.WorkFlowVersion">
select key_rate,is_encrypt from work_flow_version where file_name = #{name}
</select>
<select id="selectByHash" resultType="com.mcwl.resource.domain.WorkFlowVersion">
select * from work_flow_version where file_hash = #{hashCode}
</select>
</mapper>