From 02c090a971ac87df2a18a0251f921770f865c878 Mon Sep 17 00:00:00 2001 From: ChenYan <3139166962@qq.com> Date: Tue, 21 Jan 2025 17:25:46 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=98=AF=E5=90=A6=E7=BD=AE=E9=A1=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resource/MallProductController.java | 2 + .../resource/ModelImageController.java | 10 +- .../resource/WorkFlowController.java | 2 + .../mcwl/resource/domain/ModelProduct.java | 5 - .../mcwl/resource/mapper/WorkFlowMapper.java | 2 + .../service/impl/ModelServiceImpl.java | 139 +++++++++++++++++- .../mapper/resource/WorkFlowMapper.xml | 4 + 7 files changed, 157 insertions(+), 7 deletions(-) diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java index d6e401c..fb12bd5 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/MallProductController.java @@ -162,6 +162,7 @@ public class MallProductController extends BaseController { * @param isTop * @return */ + @ApiOperation(value = "设置模型置顶状态") @PutMapping("/{id}/top") public ResponseEntity setModelTop(@PathVariable Long id, @RequestParam boolean isTop) { try { @@ -177,6 +178,7 @@ public class MallProductController extends BaseController { * 获取置顶的模型列表 * @return */ + @ApiOperation(value = "获取置顶的模型列表") @GetMapping public ResponseEntity> fetchModelsSortedByTopStatus() { List models = modelService.fetchModelsSortedByTopStatus(); diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java index 380d246..d3d3bb6 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java @@ -105,6 +105,13 @@ public class ModelImageController { } + /** + * 设置图片置顶 + * @param id + * @param isTop + * @return + */ + @ApiOperation(value = "设置图片置顶状态") @PutMapping("/{id}/top") public ResponseEntity setModelImageTop(@PathVariable Long id, @RequestParam boolean isTop) { try { @@ -117,9 +124,10 @@ public class ModelImageController { /** - * 获取置顶的模型列表 + * 获取置顶的图片列表 * @return */ + @ApiOperation(value = "获取置顶的图片列表") @GetMapping public ResponseEntity> fetchModelImagesSortedByTopStatus() { List models = modelImageLikeService.fetchModelImageSortedByTopStatus(); diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java index bcca61b..3262471 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/WorkFlowController.java @@ -43,6 +43,7 @@ public class WorkFlowController extends BaseController { * @param isTop * @return */ + @ApiOperation(value = "设置工作流的置顶状态") @PutMapping("/{id}/top") public ResponseEntity setworkFlowTop(@PathVariable Long id, @RequestParam boolean isTop) { try { @@ -58,6 +59,7 @@ public class WorkFlowController extends BaseController { * 获取所有工作流,按照置顶状态排序 * @return */ + @ApiOperation(value = "获取置顶的模型列表") @GetMapping public ResponseEntity> fetchWorkFlowSortedByTopStatus() { List models = workFlowService.fetchWorkFlowSortedByTopStatus(); diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java index c2a5789..5c5a876 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/domain/ModelProduct.java @@ -130,11 +130,6 @@ public class ModelProduct extends BaseEntity { @ApiModelProperty(value = "是否置顶") private Integer isTop; - /** - * 审核(1公开 2自见) - */ - @ApiModelProperty(value = "审核(1公开 2自见)") - private Integer jurisdiction; /** * 删除标志(0代表存在 2代表删除) diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowMapper.java b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowMapper.java index bfde145..89f4a27 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowMapper.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/mapper/WorkFlowMapper.java @@ -21,4 +21,6 @@ public interface WorkFlowMapper extends BaseMapper { List fetchWorkFlowSortedByTopStatus(); + void setworkFlowTop(Long id, int i); + } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java index f25cf21..d3d1b37 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/ModelServiceImpl.java @@ -69,7 +69,7 @@ public class ModelServiceImpl extends ServiceImpl impl /** * 设置模型置顶状态 * - * @param modelId 模型ID + * @param id 模型ID * @param isTop 是否置顶 */ @Override @@ -229,6 +229,143 @@ public class ModelServiceImpl extends ServiceImpl impl audit(requestModel); } + private void audit(RequestModel requestModel) { + + // 执行审核操作 + threadPoolTaskExecutor.submit(() -> { + ModelProduct modelProduct = requestModel.getModelProduct(); + + if (modelProduct != null){ + + if (modelProduct.getModelName() != null){ + + //审核名称 + String s = BaiduCensor.TextCensor(modelProduct.getModelName()+","+modelProduct.getTags()); + // 解析 JSON 字符串 + JSONObject jsonObject = JSONObject.parseObject(s); + // 获取 'conclusion' 字段的值 + String conclusion = jsonObject.getString("conclusion"); + + if (conclusion.equals("不合规")) { + + //更改状态,添加原因 -> 结束任务 + // 获取 'data' 数组 + JSONArray dataArray = jsonObject.getJSONArray("data"); + + // 存储所有的失败原因 + List 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); + modelProduct.setAuditText(concatenatedReasons); + + //修改状态以及失败原因 + modelProduct.setAuditStatus(4); + baseMapper.updateById(modelProduct); + log.info("模型审核未通过"); + //结束任务 + return; + } + + //修改为合格 + modelProduct.setAuditText(""); + modelProduct.setAuditStatus(modelProduct.getJurisdiction()); + baseMapper.updateById(modelProduct); + } + } + + + List modelVersionList = requestModel.getModelVersionList(); + + if (modelVersionList != null){ + //审核版本 + for (ModelVersion modelVersion : modelVersionList) { + modelVersion.setModelId(modelProduct.getId()); + //版本名称 + String s1 = BaiduCensor.TextCensor(modelVersion.getVersionName() + "," + + modelVersion.getVersionDescription()+","+modelVersion.getTriggerWords()); + // 解析 JSON 字符串 + JSONObject jsonObject1 = JSONObject.parseObject(s1); + // 获取 'conclusion' 字段的值 + String conclusion1 = jsonObject1.getString("conclusion"); + if (conclusion1.equals("不合规")) { + + //更改版本状态->跳出循环 审核下一个版本 + // 获取 'data' 数组 + JSONArray dataArray1 = jsonObject1.getJSONArray("data"); + // 存储所有的失败原因 + List 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); + modelVersion.setAuditText(concatenatedReasons); + modelVersion.setAuditStatus(4); + //校验id是否存在 区别修改审核或者新增审核 + if (modelVersion.getId() != null){ + modelVersionMapper.updateById(modelVersion); + }else { + modelVersionMapper.updateByName(modelVersion); + } + log.info("版本审核未通过"); + continue; + } + + //审核版本图片 + String[] split = modelVersion.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 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); + modelVersion.setAuditText(concatenatedReasons); + modelVersion.setAuditStatus(4); + //校验id是否存在 区别修改审核或者新增审核 + if (modelVersion.getId() != null){ + modelVersionMapper.updateById(modelVersion); + }else { + modelVersionMapper.updateByName(modelVersion); + } + modelVersionMapper.updateByName(modelVersion); + log.info("图片审核未通过"); + break; + } + } + + //修改版本成功审核状态 + modelProduct.setAuditText(""); + modelVersion.setAuditStatus(1); + modelVersionMapper.updateByName(modelVersion); + log.info("全部通过审核"); + } + } + + }); + + } + @Override public AjaxResult selectModelById(Long id) { diff --git a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowMapper.xml b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowMapper.xml index fbc873d..a025369 100644 --- a/mcwl-resource/src/main/resources/mapper/resource/WorkFlowMapper.xml +++ b/mcwl-resource/src/main/resources/mapper/resource/WorkFlowMapper.xml @@ -31,6 +31,10 @@ WHERE id = #{id} + + UPDATE work_flow SET is_top = #{isTop} WHERE id = #{id} + +