From 990ad5f6db0bb3ad5a3795e77c5d6f3971c12ff3 Mon Sep 17 00:00:00 2001 From: lyh <925863403@qq.com> Date: 星期四, 17 四月 2025 09:43:01 +0800 Subject: [PATCH] 增加筛选电子样板 --- lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java | 195 ++++++++++++++++++++++-------------------------- 1 files changed, 91 insertions(+), 104 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 d80aefb..a1498cd 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,7 +1,6 @@ package org.jeecg.modules.dnc.service.impl; import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.IdWorker; @@ -12,22 +11,23 @@ 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; import org.jeecg.modules.dnc.mapper.DocInfoMapper; +import org.jeecg.modules.dnc.request.DocInfoQueryRequest; +import org.jeecg.modules.dnc.request.DocInfoUploadRequest; +import org.jeecg.modules.dnc.response.*; import org.jeecg.modules.dnc.service.*; import org.jeecg.modules.dnc.utils.CamelToSnakeRegex; import org.jeecg.modules.dnc.utils.ValidateUtil; - - -import org.jeecg.modules.dnc.request.DocInfoQueryRequest; -import org.jeecg.modules.dnc.request.DocInfoUploadRequest; import org.jeecg.modules.dnc.utils.file.FileUtilS; - -import org.jeecg.modules.dnc.entity.*; -import org.jeecg.modules.dnc.response.*; +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.service.ISysDictService; +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; @@ -60,7 +60,9 @@ @Autowired private IDeviceGroupService deviceGroupService; @Autowired - private INcLogInfoService iNcLogInfoService; + private IDispatchFileService dispatchFileService; + @Autowired + private ISysParamsService sysParamsService; /*澶囦唤澶勭悊*/ @Override @@ -138,20 +140,27 @@ } } - } - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("瀵煎叆"+docClass.getClassificationName()+"锛屾枃妗e悕绉�:"+(docFile.getFileName()+"."+docFile.getFileSuffix())); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); boolean saveBool = super.save(docInfo); + SysParams sysParams=sysParamsService.getSysPramBySettingKey("nc_dispatch_file"); + if (sysParams ==null){ + throw new JeecgBootException("鏈厤缃鍏C涓庣數瀛愬浘鐗堟槸鍚﹁Е鍙戝绛炬祦绋嬶紝璇疯仈绯荤鐞嗗憳"); + }else { + if (saveBool&&sysParams.getSettingValue().equals("1")&&uploadRequest.getDocClassCode().equals("NC")){ + //瑙﹀彂瀹$ + 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; } + + @Override @Transactional(rollbackFor = {Exception.class}) @@ -171,7 +180,7 @@ } String recF = pathFile.substring(0,recNum);//灏嗚繑鍥瀌ef}ab Integer equipmentId = recF.lastIndexOf("\\"); - String deviceNo = recF.substring(equipmentId+1,recF.length()); + String deviceNo = recF.substring(equipmentId+1); if (StringUtils.isEmpty(deviceNo)) { return false; } @@ -304,17 +313,6 @@ docInfo.setClassificationId(null); docInfo.setPublishFileId(null); docInfo.setPublishVersion(null); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(3); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鏂囨。鍚嶇О锛�"+docInfo.getDocName()); - //淇敼淇濆瓨澶囨敞 - ncLogInfo.setRemark(JSONObject.toJSONString(en)); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return super.updateById(docInfo); } @@ -337,15 +335,6 @@ b = docRelativeService.deleteByDocId(id); if(!b) ExceptionCast.cast(CommonCode.FAIL); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("浜у搧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(4); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鏂囨。鍚嶇О锛�"+en.getDocName()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return super.removeById(id); } @@ -384,16 +373,6 @@ docFile.setFilePath(fileUploadResult.getFilePath()); docFile.setFileSize(fileUploadResult.getFileSize()); docFile.setFileSuffix(fileUploadResult.getFileSuffix()); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鍏ュ簱"+docFile.getFileSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+docFile.getFileName()); - ncLogInfo.setRemark(JSONObject.toJSONString(en)); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); boolean b = fileOperateService.deleteByDocId(id); if(!b) ExceptionCast.cast(CommonCode.FAIL); @@ -452,15 +431,6 @@ DocFile old = docFileService.getDocFileNearest(en.getDocId()); if(old == null) ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鍙戝竷"+en.getDocSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+en.getDocName()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); if(old.getDocVersion().contains(".")) { DocFile docFile = new DocFile(); BeanUtils.copyProperties(pubFile, docFile); @@ -487,15 +457,6 @@ ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); if(en.getDocStatus() != 2) ExceptionCast.cast(DocumentCode.DOC_REPUBLISH_ERROR); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("閲嶆柊鍙戝竷"+en.getDocSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+en.getDocName()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 1).update(); } @@ -512,15 +473,6 @@ FileOperate operate = fileOperateService.getByDocId(id); if(operate != null) ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("褰掓。"+en.getDocSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+en.getDocName()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 3).update(); } @@ -538,15 +490,6 @@ DocInfo en = super.getById(id); if(en == null) ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鍙栨秷鍑哄簱"+en.getDocSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+en.getDocName()); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return fileOperateService.deleteByDocId(id); } @@ -595,6 +538,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"); @@ -604,10 +554,12 @@ } queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"u.create_time",docQuery.getStartTime()+" 00:00:00"); queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"u.create_time",docQuery.getEndTime()+" 23:59:59"); - if (("desc").equals(docQuery.getOrder())){ - queryWrapper.orderByDesc("u."+ CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); - }else { - queryWrapper.orderByAsc("u."+CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); + if (StrUtil.isNotEmpty(docQuery.getColumn())){ + if (("desc").equals(docQuery.getOrder())){ + queryWrapper.orderByDesc("u."+ CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); + }else { + queryWrapper.orderByAsc("u."+CamelToSnakeRegex.camelToSnake(docQuery.getColumn())); + } } } @@ -735,10 +687,7 @@ @Transactional(rollbackFor = {Exception.class}) public boolean deleteByDocAttr(Integer attrType, String attrId) { int i = super.getBaseMapper().deleteByDocAttr(attrType, attrId); - if(i >= 0) { - return true; - } - return false; + return i >= 0; } @Override @@ -757,15 +706,6 @@ String filePath = docFile.getFilePath(); String fileEncodeName = docFile.getFileEncodeName(); FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName); - //娣诲姞鏃ュ織 - NcLogInfo ncLogInfo = new NcLogInfo(); - //妯″潡 - ncLogInfo.setModuleInfo("璁惧缁撴瀯鏍�"); - //绫诲瀷 - ncLogInfo.setOperateType(7); - //鏃ュ織鍐呭 - ncLogInfo.setLogContent("鍑哄簱"+docFile.getFileSuffix()+"鏍煎紡鏂囨。锛屾枃妗e悕绉�:"+fileName); - iNcLogInfoService.saveLogNcInfos(ncLogInfo); return null; } @@ -831,6 +771,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"); @@ -874,6 +821,7 @@ } QueryWrapper<DocInfo> queryWrapper = Wrappers.query(); + queryWrapper.eq(StrUtil.isNotEmpty(docQuery.getDocId()),"u.doc_id",docQuery.getDocId()); queryWrapper.eq("r.attribution_type", docQuery.getAttributionType()).eq("r.attribution_id", docQuery.getAttributionId()) .eq("r.classification_id", docClassification.getClassificationId()); if (StringUtils.isNotEmpty(docQuery.getDocName())) { @@ -890,6 +838,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<>(); -- Gitblit v1.9.3