parent
6ae9eca9b6
commit
b5ca5718f6
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.common.baidu;
|
package com.mcwl.common.utils.baidu;
|
||||||
|
|
||||||
|
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 百度审核接口登录
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
* @date 2025/1/16
|
* @date 2025/1/16
|
||||||
* @apiNote
|
* @apiNote
|
|
@ -1,4 +1,4 @@
|
||||||
package com.mcwl.web.controller.common.baidu;
|
package com.mcwl.common.utils.baidu;
|
||||||
|
|
||||||
|
|
||||||
import com.mcwl.common.utils.Base64Util;
|
import com.mcwl.common.utils.Base64Util;
|
||||||
|
@ -11,7 +11,7 @@ import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**百度审核接口
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
* @date 2025/1/16
|
* @date 2025/1/16
|
||||||
* @apiNote
|
* @apiNote
|
||||||
|
@ -21,9 +21,9 @@ import java.net.URLEncoder;
|
||||||
public class BaiduCensor {
|
public class BaiduCensor {
|
||||||
|
|
||||||
//设置APPID/AK/SK
|
//设置APPID/AK/SK
|
||||||
public static final String APP_ID = "115921420";
|
public static final String APP_ID = "6273132";
|
||||||
public static final String API_KEY = "UOU5eZh73FOrsQbSKbO0wAAA";
|
public static final String API_KEY = "8cxN3yyAbQeKGhS0cHAVzlNN";
|
||||||
public static final String SECRET_KEY = "nKT1ztffZk9XTxEnhcFdQW0UFggMWq9t";
|
public static final String SECRET_KEY = "hubX4QXVGJbV9ccEVGv4Ifd2w80B71nD";
|
||||||
|
|
||||||
//图像审核
|
//图像审核
|
||||||
public static String ImageCnesor(String filePath) {
|
public static String ImageCnesor(String filePath) {
|
|
@ -60,4 +60,5 @@ public class ThreadPoolConfig
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class WorkFlow {
|
||||||
/**
|
/**
|
||||||
* 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)
|
* 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)
|
||||||
*/
|
*/
|
||||||
private Integer auditStatus = 0;
|
private Integer auditStatus = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审核失败原因
|
* 审核失败原因
|
||||||
|
@ -118,6 +118,11 @@ public class WorkFlow {
|
||||||
*/
|
*/
|
||||||
private String coverPath;
|
private String coverPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审核权限
|
||||||
|
*/
|
||||||
|
private Integer jurisdiction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建时间
|
* 创建时间
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class WorkFlowVersion {
|
||||||
/**
|
/**
|
||||||
* 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)
|
* 审核状态(0全部状态 1已发布-公开 2已发布-仅自己可见 3审核中 4审核未通过)
|
||||||
*/
|
*/
|
||||||
private Integer auditStatus = 0;
|
private Integer auditStatus = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审核失败原因
|
* 审核失败原因
|
||||||
|
|
|
@ -22,4 +22,6 @@ public interface WorkFlowVersionMapper extends BaseMapper<WorkFlowVersion> {
|
||||||
|
|
||||||
void updateWorkFlowVersion(WorkFlowVersion workFlowVersion);
|
void updateWorkFlowVersion(WorkFlowVersion workFlowVersion);
|
||||||
|
|
||||||
|
void updateByName(WorkFlowVersion workFlowVersion);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
@ -12,7 +14,9 @@ import com.mcwl.common.constant.HttpStatus;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.common.utils.baidu.BaiduCensor;
|
||||||
import com.mcwl.resource.domain.WorkFlow;
|
import com.mcwl.resource.domain.WorkFlow;
|
||||||
import com.mcwl.resource.domain.WorkFlowVersion;
|
import com.mcwl.resource.domain.WorkFlowVersion;
|
||||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
|
@ -27,6 +31,7 @@ import com.mcwl.system.init.DictInit;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -36,6 +41,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作流 业务实现层
|
* 工作流 业务实现层
|
||||||
|
*
|
||||||
* @author DaiZibo
|
* @author DaiZibo
|
||||||
* @date 2025/1/9
|
* @date 2025/1/9
|
||||||
* @apiNote
|
* @apiNote
|
||||||
|
@ -57,6 +63,10 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserService sysUserService;
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow) {
|
public AjaxResult addWorkFlow(RequestWorkFlow requestWorkFlow) {
|
||||||
|
|
||||||
|
@ -66,28 +76,166 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
String[] split = filePath.split(",");
|
String[] split = filePath.split(",");
|
||||||
|
|
||||||
WorkFlow workFlow = requestWorkFlow.getWorkFlow();
|
WorkFlow workFlow = requestWorkFlow.getWorkFlow();
|
||||||
|
workFlow.setUserId(SecurityUtils.getUserId());
|
||||||
workFlow.setCoverPath(split[0]);
|
workFlow.setCoverPath(split[0]);
|
||||||
workFlow.setCreateTime(new Date());
|
workFlow.setCreateTime(new Date());
|
||||||
//添加模型表数据
|
//添加模型表数据
|
||||||
flowMapper.insert(requestWorkFlow.getWorkFlow());
|
flowMapper.insert(workFlow);
|
||||||
|
|
||||||
log.info("获取到的入参:{}", requestWorkFlow.getWorkFlow());
|
log.info("获取到的入参:{}", requestWorkFlow.getWorkFlow());
|
||||||
|
|
||||||
//批量添加版本
|
//批量添加版本
|
||||||
workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), requestWorkFlow.getWorkFlowVersionList());
|
workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), requestWorkFlow.getWorkFlowVersionList());
|
||||||
|
|
||||||
|
audit(requestWorkFlow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return AjaxResult.success("添加成功,等待审核");
|
return AjaxResult.success("添加成功,等待审核");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void audit(RequestWorkFlow requestWorkFlow) {
|
||||||
|
// 执行审核操作
|
||||||
|
threadPoolTaskExecutor.submit(() -> {
|
||||||
|
WorkFlow workFlow = requestWorkFlow.getWorkFlow();
|
||||||
|
|
||||||
|
if (workFlow != null){
|
||||||
|
|
||||||
|
if (workFlow.getWorkflowName() != null){
|
||||||
|
|
||||||
|
//审核名称
|
||||||
|
String s = BaiduCensor.TextCensor(workFlow.getWorkflowName());
|
||||||
|
// 解析 JSON 字符串
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
|
// 获取 'conclusion' 字段的值
|
||||||
|
String conclusion = jsonObject.getString("conclusion");
|
||||||
|
|
||||||
|
if (conclusion.equals("不合规")) {
|
||||||
|
|
||||||
|
//更改状态,添加原因 -> 结束任务
|
||||||
|
// 获取 'data' 数组
|
||||||
|
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||||
|
|
||||||
|
// 存储所有的失败原因
|
||||||
|
List<String> failureReasons = new ArrayList<>();
|
||||||
|
// 遍历 'data' 数组中的每个元素
|
||||||
|
for (Object itemObj : dataArray) {
|
||||||
|
JSONObject item = (JSONObject) itemObj;
|
||||||
|
String msg = item.getString("msg");
|
||||||
|
failureReasons.add(msg);
|
||||||
|
}
|
||||||
|
// 使用逗号拼接所有的失败原因
|
||||||
|
String concatenatedReasons = String.join(", ", failureReasons);
|
||||||
|
workFlow.setAuditText(concatenatedReasons);
|
||||||
|
|
||||||
|
//修改状态以及失败原因
|
||||||
|
workFlow.setAuditStatus(4);
|
||||||
|
flowMapper.updateById(workFlow);
|
||||||
|
log.info("工作流审核未通过");
|
||||||
|
//结束任务
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改为合格
|
||||||
|
workFlow.setAuditStatus(workFlow.getJurisdiction());
|
||||||
|
flowMapper.updateById(workFlow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<WorkFlowVersion> workFlowVersionList = requestWorkFlow.getWorkFlowVersionList();
|
||||||
|
|
||||||
|
if (workFlowVersionList != null){
|
||||||
|
//审核版本
|
||||||
|
for (WorkFlowVersion workFlowVersion : workFlowVersionList) {
|
||||||
|
workFlowVersion.setWorkFlowId(workFlow.getId());
|
||||||
|
//版本名称
|
||||||
|
String s1 = BaiduCensor.TextCensor(workFlowVersion.getVersionName() + "," + workFlowVersion.getVersionDescription());
|
||||||
|
// 解析 JSON 字符串
|
||||||
|
JSONObject jsonObject1 = JSONObject.parseObject(s1);
|
||||||
|
// 获取 'conclusion' 字段的值
|
||||||
|
String conclusion1 = jsonObject1.getString("conclusion");
|
||||||
|
if (conclusion1.equals("不合规")) {
|
||||||
|
|
||||||
|
//更改版本状态->跳出循环 审核下一个版本
|
||||||
|
// 获取 'data' 数组
|
||||||
|
JSONArray dataArray1 = jsonObject1.getJSONArray("data");
|
||||||
|
// 存储所有的失败原因
|
||||||
|
List<String> failureReasons = new ArrayList<>();
|
||||||
|
// 遍历 'data' 数组中的每个元素
|
||||||
|
for (Object itemObj : dataArray1) {
|
||||||
|
JSONObject item = (JSONObject) itemObj;
|
||||||
|
String msg = item.getString("msg");
|
||||||
|
failureReasons.add(msg);
|
||||||
|
}
|
||||||
|
// 使用逗号拼接所有的失败原因
|
||||||
|
String concatenatedReasons = String.join(", ", failureReasons);
|
||||||
|
workFlow.setAuditText(concatenatedReasons);
|
||||||
|
workFlowVersion.setAuditStatus(4);
|
||||||
|
//校验id是否存在 区别修改审核或者新增审核
|
||||||
|
if (workFlowVersion.getId() != null){
|
||||||
|
workFlowVersionMapper.updateById(workFlowVersion);
|
||||||
|
}else {
|
||||||
|
workFlowVersionMapper.updateByName(workFlowVersion);
|
||||||
|
}
|
||||||
|
log.info("版本审核未通过");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//审核版本图片
|
||||||
|
String[] split = workFlowVersion.getFilePath().split(",");
|
||||||
|
for (String path : split) {
|
||||||
|
String s2 = BaiduCensor.ImageCnesor(path);
|
||||||
|
JSONObject jsonObject2 = JSONObject.parseObject(s2);
|
||||||
|
if (jsonObject2.getString("conclusion").equals("不合规")) {
|
||||||
|
|
||||||
|
//修改状态->跳出循环 判断下一个版本
|
||||||
|
// 获取 'data' 数组
|
||||||
|
JSONArray dataArray2 = jsonObject2.getJSONArray("data");
|
||||||
|
// 存储所有的失败原因
|
||||||
|
List<String> failureReasons = new ArrayList<>();
|
||||||
|
// 遍历 'data' 数组中的每个元素
|
||||||
|
for (Object itemObj : dataArray2) {
|
||||||
|
JSONObject item = (JSONObject) itemObj;
|
||||||
|
String msg = item.getString("msg");
|
||||||
|
failureReasons.add(msg);
|
||||||
|
}
|
||||||
|
// 使用逗号拼接所有的失败原因
|
||||||
|
String concatenatedReasons = String.join(", ", failureReasons);
|
||||||
|
workFlow.setAuditText(concatenatedReasons);
|
||||||
|
workFlowVersion.setAuditStatus(4);
|
||||||
|
//校验id是否存在 区别修改审核或者新增审核
|
||||||
|
if (workFlowVersion.getId() != null){
|
||||||
|
workFlowVersionMapper.updateById(workFlowVersion);
|
||||||
|
}else {
|
||||||
|
workFlowVersionMapper.updateByName(workFlowVersion);
|
||||||
|
}
|
||||||
|
workFlowVersionMapper.updateByName(workFlowVersion);
|
||||||
|
log.info("图片审核未通过");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改版本成功审核状态
|
||||||
|
workFlowVersion.setAuditStatus(1);
|
||||||
|
workFlowVersionMapper.updateByName(workFlowVersion);
|
||||||
|
log.info("全部通过审核");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateWorkFlow(RequestWorkFlow requestWorkFlow) {
|
public void updateWorkFlow(RequestWorkFlow requestWorkFlow) {
|
||||||
WorkFlow workFlows = requestWorkFlow.getWorkFlow();
|
WorkFlow workFlows = requestWorkFlow.getWorkFlow();
|
||||||
//修改工作流的信息
|
//修改工作流的信息
|
||||||
if (ObjectUtils.isEmpty(workFlows)) {
|
if (ObjectUtils.isEmpty(workFlows)) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotNull(workFlows.getId())) {
|
if (StringUtils.isNotNull(workFlows.getId())) {
|
||||||
|
|
||||||
|
workFlows.setUpdateTime(new Date());
|
||||||
workFlows.setAuditStatus(3);
|
workFlows.setAuditStatus(3);
|
||||||
// flowMapper.updateWorkFlow(requestWorkFlow.getWorkFlow());
|
// flowMapper.updateWorkFlow(requestWorkFlow.getWorkFlow());
|
||||||
flowMapper.updateById(requestWorkFlow.getWorkFlow());
|
flowMapper.updateById(requestWorkFlow.getWorkFlow());
|
||||||
|
@ -107,8 +255,11 @@ public class WorkFlowServiceImpl extends ServiceImpl<WorkFlowMapper, WorkFlow> i
|
||||||
.updateTime(new Date()).build();
|
.updateTime(new Date()).build();
|
||||||
//更新时间
|
//更新时间
|
||||||
flowMapper.updateById(workFlow);
|
flowMapper.updateById(workFlow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//审核修改后的数据
|
||||||
|
audit(requestWorkFlow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,4 +17,9 @@
|
||||||
<update id="updateWorkFlowVersion">
|
<update id="updateWorkFlowVersion">
|
||||||
-- update work_flow_version
|
-- update work_flow_version
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateByName">
|
||||||
|
update work_flow_version set audit_status = #{auditStatus},
|
||||||
|
audit_text = #{auditText}
|
||||||
|
where version_name = #{versionName} and work_flow_id = #{workFlowId}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue