From cc44920da3d40b8248b67560026e891afdd1a6ab Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 08 五月 2025 17:57:14 +0800 Subject: [PATCH] 1.查询可以被引用的部件接口开发完成 2.借用部件(可批量) 开发完成 3.修改原有新增、修改部件接口 完成 4.修改原有删除文档与导入文档接口 完成 5.修改工作流问题 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 106 insertions(+), 12 deletions(-) diff --git a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java index 7d4f340..3b4b965 100644 --- a/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java +++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java @@ -1,5 +1,6 @@ package org.jeecg.modules.dnc.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -11,6 +12,7 @@ import org.apache.shiro.SecurityUtils; import org.jeecg.common.api.vo.FileUploadResult; import org.jeecg.common.api.vo.Result; +import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.system.vo.LoginUser; import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; @@ -25,6 +27,8 @@ import org.jeecg.modules.dncFlow.entity.DispatchFile; import org.jeecg.modules.dncFlow.service.IDispatchFileService; import org.jeecg.modules.mdc.entity.MdcEquipment; +import org.jeecg.modules.system.entity.SysParams; +import org.jeecg.modules.system.service.ISysParamsService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -58,6 +62,11 @@ private IDeviceGroupService deviceGroupService; @Autowired private IDispatchFileService dispatchFileService; + @Autowired + private ISysParamsService sysParamsService; + @Autowired + @Lazy + private IComponentInfoService componentInfoService; /*澶囦唤澶勭悊*/ @Override @@ -94,6 +103,19 @@ docRelative.setAttributionType(uploadRequest.getAttributionType()); docRelative.setClassificationId(docClass.getClassificationId()); boolean b = docRelativeService.save(docRelative); + if (uploadRequest.getAttributionType()==2){ + //鏌ヨ鍊熺敤鐨勯儴浠� + List<ComponentInfo> borrowComponentInfoList=componentInfoService.list(new QueryWrapper<ComponentInfo>().eq("borrow_id", uploadRequest.getAttributionId())); + if (!borrowComponentInfoList.isEmpty()) { + borrowComponentInfoList.forEach(item->{ + DocRelative borrowDocRelative = new DocRelative(); + BeanUtil.copyProperties(docRelative,borrowDocRelative); + borrowDocRelative.setAttributionId(item.getComponentId()); + borrowDocRelative.setId(null); + docRelativeService.save(borrowDocRelative); + }); + } + } if(!b) ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR); DocFile docFile = new DocFile(); @@ -137,15 +159,20 @@ } } boolean saveBool = super.save(docInfo); - if (uploadRequest.getIsApprove()&&saveBool){ - //瑙﹀彂瀹$ - DispatchFile dispatchFile = new DispatchFile(); - dispatchFile.setDocId(docInfo.getDocId()); - dispatchFile.setFileId(docFile.getFileId()); - dispatchFile.setAttributionId(uploadRequest.getAttributionId()); - dispatchFile.setAttributionType(String.valueOf(uploadRequest.getAttributionType())); - dispatchFile.setDocClassCode(uploadRequest.getDocClassCode()); - dispatchFileService.saveDispatchFile(dispatchFile); + SysParams sysParams=sysParamsService.getSysPramBySettingKey("nc_dispatch_file"); + if (sysParams ==null){ + throw new JeecgBootException("鏈厤缃鍏C涓庣數瀛愬浘鐗堟槸鍚﹁Е鍙戝绛炬祦绋嬶紝璇疯仈绯荤鐞嗗憳"); + }else { + if (saveBool&&sysParams.getSettingValue().equals("1")){ + //瑙﹀彂瀹$ + DispatchFile dispatchFile = new DispatchFile(); + dispatchFile.setDocId(docInfo.getDocId()); + dispatchFile.setFileId(docFile.getFileId()); + dispatchFile.setAttributionId(uploadRequest.getAttributionId()); + dispatchFile.setAttributionType(String.valueOf(uploadRequest.getAttributionType())); + dispatchFile.setDocClassCode(uploadRequest.getDocClassCode()); + dispatchFileService.saveDispatchFile(dispatchFile); + } } return saveBool; } @@ -308,7 +335,7 @@ @Override @Transactional(rollbackFor = {Exception.class}) - public boolean deleteDocInfo(String id) { + public boolean deleteDocInfo(String id,String attrType,String attrId) { if(!ValidateUtil.validateString(id)) ExceptionCast.cast(CommonCode.INVALID_PARAM); DocInfo en = super.getById(id); @@ -316,6 +343,20 @@ ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); if(en.getDocStatus() != 1) ExceptionCast.cast(DocumentCode.DOC_DEL_ERROR); + //鏌ヨ瀵瑰簲鐨勫叧绯� + if ("2".equals(attrType)) { + //鍒ゆ柇閮ㄤ欢寮曠敤 + ComponentInfo componentInfo=componentInfoService.getById(attrId); + if(componentInfo!=null&&componentInfo.getBorrowId()!=null){ + //鍊熺敤鐨勯儴浠讹紝鍙垹闄よ嚜宸辩殑鍏崇郴 + DocRelative docRelative=docRelativeService.getOne(new QueryWrapper<DocRelative>() + .eq("attribution_id", attrId).eq("attribution_type", 2).eq("doc_id",id)); + if(docRelative!=null){ + docRelativeService.removeById(docRelative.getId()); + return true; + } + } + } FileOperate operate = fileOperateService.getByDocId(id); if(operate != null) ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING); @@ -527,6 +568,13 @@ queryWrapper.in("u.doc_status",docStatusList); }else { queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocStatus()),"u.doc_status",docQuery.getDocStatus()); + } + if (docQuery.getDocDispatchStatus() != null && docQuery.getDocDispatchStatus().contains(",")) { + String[] docDispatchStatusArray = docQuery.getDocDispatchStatus().split(","); + List<Integer> docDispatchStatusList = Arrays.stream(docDispatchStatusArray).map(Integer::parseInt).collect(Collectors.toList()); + queryWrapper.in("u.doc_dispatch_status",docDispatchStatusList); + }else { + queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocDispatchStatus()),"u.doc_dispatch_status",docQuery.getDocDispatchStatus()); } if (StrUtil.isNotEmpty(docQuery.getPullStatus())){ if (("1").equals(docQuery.getPullStatus())){ @@ -754,6 +802,13 @@ }else { queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocStatus()),"u.doc_status",docQuery.getDocStatus()); } + if (docQuery.getDocDispatchStatus() != null && docQuery.getDocDispatchStatus().contains(",")) { + String[] docDispatchStatusArray = docQuery.getDocDispatchStatus().split(","); + List<Integer> docDispatchStatusList = Arrays.stream(docDispatchStatusArray).map(Integer::parseInt).collect(Collectors.toList()); + queryWrapper.in("u.doc_dispatch_status",docDispatchStatusList); + }else { + queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocDispatchStatus()),"u.doc_dispatch_status",docQuery.getDocDispatchStatus()); + } if (StrUtil.isNotEmpty(docQuery.getPullStatus())){ if (("1").equals(docQuery.getPullStatus())){ queryWrapper.isNull("o.doc_id"); @@ -814,6 +869,45 @@ return super.getBaseMapper().findDocExtList(queryWrapper); } + /** + * 閫氳繃涓�缁刟ttributionId,docClassCode,attributionType鏌ヨ鍙寚娲剧殑鏂囨。淇℃伅鍒楄〃 + * @param docQuery + * @return + */ + @Override + public List<DocInfo> findListByDocQuery(DocInfoQueryRequest docQuery){ + if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionIds()) + || !ValidateUtil.validateInteger(docQuery.getAttributionType()) || + !ValidateUtil.validateString(docQuery.getDocClassCode())) { + ExceptionCast.cast(CommonCode.INVALID_PARAM); + } + DocClassification docClassification = docClassificationService.getByCode(docQuery.getDocClassCode()); + if(docClassification == null) { + ExceptionCast.cast(CommonCode.INVALID_PAGE); + } + List<String> attributionIds = Arrays.asList(docQuery.getAttributionIds().split(",")); + + QueryWrapper<DocInfo> queryWrapper = Wrappers.query(); + queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocId()),"u.doc_id",docQuery.getDocId()); + queryWrapper.eq("r.attribution_type", docQuery.getAttributionType()) + .in("r.attribution_id", attributionIds) + .eq("r.classification_id", docClassification.getClassificationId()); + if (StringUtils.isNotEmpty(docQuery.getDocName())) { + int dotIndex = docQuery.getDocName().lastIndexOf("."); + if (dotIndex == -1) { + queryWrapper.like("u.doc_name", docQuery.getDocName()); + } else { + String[] docNameArr = docQuery.getDocName().split("\\."); + queryWrapper.like(StrUtil.isNotEmpty(docNameArr[0]), "u.doc_name", docNameArr[0]); + queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]); + } + } + getDocQuery(docQuery, queryWrapper); + return super.getBaseMapper().findDocExtList(queryWrapper); + } + + + @Override public List<DocInfo> getByProcessIds(List<ProcessStream> streams) { List<String> ids = new ArrayList<>(); @@ -833,11 +927,11 @@ @Override @Transactional(rollbackFor = {Exception.class}) - public boolean batchRemoveDocInfo(String[] docIds) { + public boolean batchRemoveDocInfo(String[] docIds,String attrType,String attrId) { if(docIds == null || docIds.length < 1) ExceptionCast.cast(CommonCode.INVALID_PARAM); for(String docId : docIds) { - this.deleteDocInfo(docId); + this.deleteDocInfo(docId,attrType,attrId); } return true; } -- Gitblit v1.9.3