From 7ded966355e59547aee4f55f27b8280911942cce Mon Sep 17 00:00:00 2001 From: Diyu0904 <1819728964@qq.com> Date: Wed, 28 May 2025 14:49:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=98=E6=96=B9=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=97=A0=E6=B3=95=E5=8A=A0=E5=AF=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ModelServiceImpl.java | 129 +++++++++--------- .../service/impl/WorkFlowServiceImpl.java | 42 +++--- 2 files changed, 80 insertions(+), 91 deletions(-) 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 42828af..7444290 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 @@ -41,7 +41,9 @@ import org.springframework.stereotype.Service; import java.util.*; -/**模型 业务实现层 +/** + * 模型 业务实现层 + * * @Author:ChenYan * @Project:McWl * @Package:com.mcwl.resource.service.impl @@ -51,7 +53,7 @@ import java.util.*; */ @Log4j2 @Service -public class ModelServiceImpl extends ServiceImpl implements ModelService { +public class ModelServiceImpl extends ServiceImpl implements ModelService { @Autowired private ToActivityService toActivityService; @@ -85,13 +87,14 @@ public class ModelServiceImpl extends ServiceImpl impl /** * 设置模型置顶状态 * - * @param id 模型ID + * @param id 模型ID * @param isTop 是否置顶 */ @Override public void setModelTop(Long id, boolean isTop) { postMapper.updateTopStatus(id, isTop ? 1 : 0); } + /** * 获取模型列表 * @@ -107,46 +110,46 @@ public class ModelServiceImpl extends ServiceImpl impl @Override public PageInfo modelSquare(PageVo pageVo) { PageHelper pageHelper = new PageHelper(); - pageHelper.startPage(pageVo.getPageNumber(),pageVo.getPageSize()); + pageHelper.startPage(pageVo.getPageNumber(), pageVo.getPageSize()); Long userIdMax = SecurityUtils.getUserIdMax(); List responseModelProductList = postMapper.modelSquare(pageVo); for (ResponseModelProduct responseModelProduct : responseModelProductList) { - if (responseModelProduct.getModelType() != null){ + if (responseModelProduct.getModelType() != null) { - responseModelProduct.setType(DictInit.getDictValue(DictConstants.MODEL_TYPE,responseModelProduct.getModelType()+"")); + responseModelProduct.setType(DictInit.getDictValue(DictConstants.MODEL_TYPE, responseModelProduct.getModelType() + "")); } //查询该模型第一个版本信息 - if (pageVo.getIsCollect() == 0){ + if (pageVo.getIsCollect() == 0) { ModelVersion modelVersion = modelVersionMapper.selectByProductId(responseModelProduct.getId()); - if (modelVersion == null){ + if (modelVersion == null) { //跳出循环 continue; } - if (userIdMax == 0){ + if (userIdMax == 0) { //收藏为空 modelVersion.setIsCollect(0); //下载为空 modelVersion.setIsDownload(0); - }else { + } else { //查询是否收藏 Collect collect = collectService.selectCollectById(modelVersion.getId(), userIdMax, 0); - if (collect == null){ + if (collect == null) { modelVersion.setIsCollect(0); - }else { + } else { modelVersion.setIsCollect(1); } //校验是否下载 - modelVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax,modelVersion.getModelId(),0)); + modelVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax, modelVersion.getModelId(), 0)); } @@ -163,12 +166,12 @@ public class ModelServiceImpl extends ServiceImpl impl //根绝名字查找数据 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(ModelProduct::getModelName,name); - queryWrapper.eq(ModelProduct::getDelFlag,0); + queryWrapper.eq(ModelProduct::getModelName, name); + queryWrapper.eq(ModelProduct::getDelFlag, 0); List modelProducts = postMapper.selectList(queryWrapper); - if (modelProducts.size()>0){ + if (modelProducts.size() > 0) { return R.ok(0); } return R.ok(1); @@ -184,8 +187,8 @@ public class ModelServiceImpl extends ServiceImpl impl Long userId = SecurityUtils.getUserId(); LambdaQueryWrapper mallProductLambdaQueryWrapper = new LambdaQueryWrapper<>(); - mallProductLambdaQueryWrapper.eq(ModelProduct::getUserId,userId); - mallProductLambdaQueryWrapper.eq(ModelProduct::getDelFlag,0); + mallProductLambdaQueryWrapper.eq(ModelProduct::getUserId, userId); + mallProductLambdaQueryWrapper.eq(ModelProduct::getDelFlag, 0); // 开始时间和结束时间过滤 if (mallProductVo.getStartTime() != null && mallProductVo.getEndTime() != null) { @@ -233,7 +236,7 @@ public class ModelServiceImpl extends ServiceImpl impl LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(imagePageRes.getStatus() != null && imagePageRes.getStatus() != 0, ModelProduct::getAuditStatus, imagePageRes.getStatus()) - .eq( ModelProduct::getUserId, imagePageRes.getUserId()) + .eq(ModelProduct::getUserId, imagePageRes.getUserId()) .eq(imagePageRes.getOfficial() != null, ModelProduct::getIsOfficial, imagePageRes.getOfficial()) .ge(imagePageRes.getStartTime() != null, ModelProduct::getCreateTime, imagePageRes.getStartTime()) .le(imagePageRes.getEndTime() != null, ModelProduct::getCreateTime, imagePageRes.getEndTime()); @@ -279,13 +282,13 @@ public class ModelServiceImpl extends ServiceImpl impl public R addModel(RequestModel requestModel) { //官方发布则不校验实名以及审核 - if (requestModel.getModelProduct().getIsOfficial() == 0){ + if (requestModel.getModelProduct().getIsOfficial() == 0) { //校验是否实名 SysUser sysUser = sysUserService.selectUserInfoById(SecurityUtils.getUserId()); - log.info("查询到的个人数据:{}",sysUser); - if (StringUtils.isEmpty(sysUser.getName())){ + log.info("查询到的个人数据:{}", sysUser); + if (StringUtils.isEmpty(sysUser.getName())) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"实名制后才可以发布"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "实名制后才可以发布"); } } @@ -297,18 +300,17 @@ public class ModelServiceImpl extends ServiceImpl impl ModelVersion modelVersion1 = modelVersionMapper.selectByFileName(modelVersion.getFileName()); if (modelVersion1 != null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "文件名字重复"); } //校验hash ModelVersion modelVersion2 = modelVersionMapper.selectByHash(modelVersion.getFileHash()); - if (modelVersion2 != null){ + if (modelVersion2 != null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "文件内容重复"); } } - //获取封面图 String filePath = requestModel.getModelVersionList().get(0).getSampleImagePaths(); String[] split = filePath.split(","); @@ -320,7 +322,7 @@ public class ModelServiceImpl extends ServiceImpl impl //添加模型表数据 postMapper.insert(requestModel.getModelProduct()); - log.info("获取到的入参:{}",requestModel.getModelProduct()); + log.info("获取到的入参:{}", requestModel.getModelProduct()); //批量添加版本 // modelVersionMapper.addModelVersion(requestModel.getModelProduct(),requestModel.getModelVersionList()); @@ -329,12 +331,8 @@ public class ModelServiceImpl extends ServiceImpl impl modelVersionMapper.addModelVersion(modelVersion); } - if (requestModel.getModelProduct().getIsOfficial() == 0){ - //执行审核方法 - audit(requestModel); - - } - + //执行审核方法 + audit(requestModel); return R.ok("添加成功,等待审核"); @@ -344,9 +342,9 @@ public class ModelServiceImpl extends ServiceImpl impl public void updaModel(RequestModel requestModel) { //修改模版的信息 ModelProduct modelProduct = requestModel.getModelProduct(); - if (ObjectUtils.isNotEmpty(modelProduct)){ + if (ObjectUtils.isNotEmpty(modelProduct)) { - if (StringUtils.isNotNull(modelProduct.getId())){ + if (StringUtils.isNotNull(modelProduct.getId())) { modelProduct.setAuditStatus(3); modelProduct.setUpdateTime(new Date()); postMapper.updateById(requestModel.getModelProduct()); @@ -354,15 +352,15 @@ public class ModelServiceImpl extends ServiceImpl impl } //修改工作流版本的信息 - if (requestModel.getModelVersionList().size() != 0){ + if (requestModel.getModelVersionList().size() != 0) { //批量修改 for (ModelVersion modelVersion : requestModel.getModelVersionList()) { - if (modelVersion.getId() != null){ + if (modelVersion.getId() != null) { modelVersionMapper.updateById(modelVersion); - }else { + } else { modelVersion.setModelId(modelProduct.getId()); modelVersionMapper.insert(modelVersion); } @@ -370,8 +368,8 @@ public class ModelServiceImpl extends ServiceImpl impl } ModelProduct model = ModelProduct.builder(). - id(requestModel.getModelVersionList().get(0). - getModelId()).build(); + id(requestModel.getModelVersionList().get(0). + getModelId()).build(); model.setUpdateTime(new Date()); postMapper.updateById(model); } @@ -380,25 +378,26 @@ public class ModelServiceImpl extends ServiceImpl impl audit(requestModel); } + private void audit(RequestModel requestModel) { // 执行审核操作 threadPoolTaskExecutor.submit(() -> { ModelProduct modelProduct = requestModel.getModelProduct(); - if (modelProduct != null){ + if (modelProduct != null) { - if (modelProduct.getModelName() != null){ + if (modelProduct.getModelName() != null) { //审核名称 - String s = BaiduCensor.TextCensor(modelProduct.getModelName()+","+modelProduct.getTags()); + String s = BaiduCensor.TextCensor(modelProduct.getModelName() + "," + modelProduct.getTags()); // 解析 JSON 字符串 JSONObject jsonObject = JSONObject.parseObject(s); //获取状态码 String code = jsonObject.getString("code"); - if (code != null){ + if (code != null) { //审核失败,数据有问题 modelProduct.setAuditStatus(4); modelProduct.setAuditText("审核失败"); @@ -442,12 +441,12 @@ public class ModelServiceImpl extends ServiceImpl impl List modelVersionList = requestModel.getModelVersionList(); - if (modelVersionList != null){ + if (modelVersionList != null) { //审核版本 for (ModelVersion modelVersion : modelVersionList) { //判断版本是否删除 - if (modelVersion.getDelFlag().equals("2")){ + if (modelVersion.getDelFlag().equals("2")) { //不做审核 log.info("删除模型版本信息,不做审核校验"); continue; @@ -456,7 +455,7 @@ public class ModelServiceImpl extends ServiceImpl impl modelVersion.setModelId(modelProduct.getId()); //版本名称 String s1 = BaiduCensor.TextCensor(modelVersion.getVersionName() + "," + - modelVersion.getVersionDescription()+","+modelVersion.getTriggerWords()); + modelVersion.getVersionDescription() + "," + modelVersion.getTriggerWords()); // 解析 JSON 字符串 JSONObject jsonObject1 = JSONObject.parseObject(s1); // 获取 'conclusion' 字段的值 @@ -491,7 +490,7 @@ public class ModelServiceImpl extends ServiceImpl impl String s2 = BaiduCensor.ImageCnesor(path); JSONObject jsonObject2 = JSONObject.parseObject(s2); if (jsonObject2.getString("conclusion").equals("不合规") - || jsonObject2.getString("conclusion").equals("审核失败") ) { + || jsonObject2.getString("conclusion").equals("审核失败")) { //修改状态->跳出循环 判断下一个版本 // 获取 'data' 数组 @@ -519,17 +518,17 @@ public class ModelServiceImpl extends ServiceImpl impl String key = modelVersion.getObjectKey(); //审核成功,查看时候加密,拉取文件到ui - if (modelVersion.getIsEncrypt() == 1){ + if (modelVersion.getIsEncrypt() == 1) { //调用加密/创建参数 HashMap param = new HashMap<>(); - param.put("objectKey",modelVersion.getObjectKey()); - param.put("id",modelVersion.getId()+""); + param.put("objectKey", modelVersion.getObjectKey()); + param.put("id", modelVersion.getId() + ""); param.put("fileType", Constants.MODEL); String s = HttpUtils.pythonPost(encryptUrl, param); - log.info("调用加密服务结果:{}",s); + log.info("调用加密服务结果:{}", s); // JSONObject jsonObject = JSONObject.parseObject(s); // JSONObject data = JSONObject.parseObject(jsonObject.getString("data")); @@ -570,41 +569,39 @@ public class ModelServiceImpl extends ServiceImpl impl } - - @Override public R selectModelById(Long id) { //查询详情 ModelProduct modelProduct = postMapper.selectById(id); - if (modelProduct == null){ + if (modelProduct == null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"该模型不存在"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "该模型不存在"); } //翻译属性 垂类 - if (StringUtils.isNotEmpty(modelProduct.getCategory())){ - modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY,modelProduct.getCategory())); + if (StringUtils.isNotEmpty(modelProduct.getCategory())) { + modelProduct.setCategory(DictInit.getDictValue(DictConstants.MODEL_CHILD_CATEGORY, modelProduct.getCategory())); } //功能 - if (StringUtils.isNotEmpty(modelProduct.getFunctions())){ - modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS,modelProduct.getFunctions())); + if (StringUtils.isNotEmpty(modelProduct.getFunctions())) { + modelProduct.setCategory(DictInit.getDictValue(DictConstants.WORK_FLOW_FUNCTIONS, modelProduct.getFunctions())); } //活动 - if (StringUtils.isNotEmpty(modelProduct.getActivityId())){ + if (StringUtils.isNotEmpty(modelProduct.getActivityId())) { modelProduct.setActivityId(toActivityService.getById(modelProduct.getActivityId()).getActivityName()); } modelProduct.setIsAttention(1); SysUserAttention sysUserAttention = sysUserAttentionMapper.selectAttention(SecurityUtils.getUserIdMax(), modelProduct.getUserId()); - if (sysUserAttention == null){ + if (sysUserAttention == null) { modelProduct.setIsAttention(0); } - WorkFlowLike workFlowLike = modelLikeMapper.selectModelLikeById(SecurityUtils.getUserIdMax(),modelProduct.getId()); + WorkFlowLike workFlowLike = modelLikeMapper.selectModelLikeById(SecurityUtils.getUserIdMax(), modelProduct.getId()); modelProduct.setIsLike(1); - if (workFlowLike == null){ + if (workFlowLike == null) { modelProduct.setIsLike(0); } @@ -612,6 +609,4 @@ public class ModelServiceImpl extends ServiceImpl impl } - - } diff --git a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java index 82c103f..29a9eaa 100644 --- a/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java +++ b/mcwl-resource/src/main/java/com/mcwl/resource/service/impl/WorkFlowServiceImpl.java @@ -84,30 +84,29 @@ public class WorkFlowServiceImpl extends ServiceImpl i public R addWorkFlow(AddRequestWorkFlow addRequestWorkFlo) { //校验是否魔创未来官方发布 - if (addRequestWorkFlo.getWorkFlow().getIsOfficial() == 0){ + if (addRequestWorkFlo.getWorkFlow().getIsOfficial() == 0) { //校验是否实名 SysUser sysUser = sysUserService.selectUserInfoById(SecurityUtils.getUserId()); - if (sysUser.getName() == null){ + if (sysUser.getName() == null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"实名制后才可以发布"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "实名制后才可以发布"); } } - for (AddWorkFlowVersion addWorkFlowVersion : addRequestWorkFlo.getWorkFlowVersionList()) { //校验名字 WorkFlowVersion workFlowVersion1 = workFlowVersionMapper.selectByFileName(addWorkFlowVersion.getFileName()); if (workFlowVersion1 != null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件名字重复"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "文件名字重复"); } //校验hash WorkFlowVersion workFlowVersion2 = workFlowVersionMapper.selectByHash(addWorkFlowVersion.getFileHash()); - if (workFlowVersion2 != null){ + if (workFlowVersion2 != null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"文件内容重复"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "文件内容重复"); } } @@ -132,11 +131,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i //批量添加版本 workFlowVersionMapper.addWorkFlowVersion(requestWorkFlow.getWorkFlow(), addRequestWorkFlo.getWorkFlowVersionList()); - //校验是否魔创未来官方发布 - if (addRequestWorkFlo.getWorkFlow().getIsOfficial() == 0){ - audit(requestWorkFlow); - } - + audit(requestWorkFlow); return R.ok(); @@ -371,8 +366,8 @@ public class WorkFlowServiceImpl extends ServiceImpl i LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery() .like(StringUtils.isNotBlank(pageVo.getName()), WorkFlow::getWorkflowName, pageVo.getName()) - .eq(StringUtils.isNotNull(pageVo.getOfficial()),WorkFlow::getIsOfficial,pageVo.getOfficial()) - .eq(WorkFlow::getAuditStatus,1) + .eq(StringUtils.isNotNull(pageVo.getOfficial()), WorkFlow::getIsOfficial, pageVo.getOfficial()) + .eq(WorkFlow::getAuditStatus, 1) .eq(WorkFlow::getDelFlag, 0); if (pageVo.getOrder() == 1) { @@ -392,7 +387,7 @@ public class WorkFlowServiceImpl extends ServiceImpl i //查询详情 WorkFlow workFlow = flowMapper.selectById(id); if (workFlow == null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"工作流不存在"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "工作流不存在"); } //类别 @@ -504,12 +499,12 @@ public class WorkFlowServiceImpl extends ServiceImpl i WorkFlow workFlow = baseMapper.selectById(id); if (workFlow == null) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"数据不存在"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "数据不存在"); } if (workFlow.getDelFlag() == 2) { - return R.fail(HttpStatus.SHOW_ERROR_MSG,"数据不存在"); + return R.fail(HttpStatus.SHOW_ERROR_MSG, "数据不存在"); } LambdaQueryWrapper workFlowVersionLambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -535,28 +530,28 @@ public class WorkFlowServiceImpl extends ServiceImpl i responseWorkFlow.setType(DictInit.getDictValue(DictConstants.WORK_FLOW_TYPE_CHILD, responseWorkFlow.getType())); //查询工作流型第一个版本信息 - if (pageVo.getIsCollect() == 0){ + if (pageVo.getIsCollect() == 0) { WorkFlowVersion workFlowVersion = workFlowVersionMapper.selectByWorkFlowId(responseWorkFlow.getId()); - if (userIdMax == 0){ + if (userIdMax == 0) { //收藏为空 workFlowVersion.setIsCollect(0); //下载为空 workFlowVersion.setIsDownload(0); - }else { + } else { //查询是否收藏 Collect collect = collectService.selectCollectById(workFlowVersion.getId(), userIdMax, 1); - if (collect == null){ + if (collect == null) { workFlowVersion.setIsCollect(0); - }else { + } else { workFlowVersion.setIsCollect(1); } - workFlowVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax,workFlowVersion.getWorkFlowId(),1)); + workFlowVersion.setIsDownload(downloadRecordService.selectDownloadByUser(userIdMax, workFlowVersion.getWorkFlowId(), 1)); } responseWorkFlow.setWorkFlowVersion(workFlowVersion); @@ -570,5 +565,4 @@ public class WorkFlowServiceImpl extends ServiceImpl i } - }