From 23855599412c4d61b38d78f0f3abd3430a48b5b1 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 25 六月 2025 11:51:38 +0800
Subject: [PATCH] Merge branch 'mdc_hyjs_master'

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java | 1071 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,071 insertions(+), 0 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
new file mode 100644
index 0000000..dc6ef58
--- /dev/null
+++ b/lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java
@@ -0,0 +1,1071 @@
+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;
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+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.ext.NcTxtFilePathInfo;
+import org.jeecg.modules.dnc.listener.FileMonitorConfig;
+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.utils.file.FileUtilS;
+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.mdc.service.IMdcEquipmentService;
+import org.jeecg.modules.system.entity.SysParams;
+import org.jeecg.modules.system.service.IMdcProductionService;
+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;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Scanner;
+import java.util.stream.Collectors;
+
+@Service
+public class DocInfoServiceImpl extends ServiceImpl<DocInfoMapper, DocInfo> implements IDocInfoService {
+    @Autowired
+    private FileMonitorConfig config;
+    @Autowired
+    private IMdcEquipmentService iMdcEquipmentService;
+    @Autowired
+    private IMdcProductionService iMdcProductionService;
+    @Autowired
+    private IDocClassificationService docClassificationService;
+    @Autowired
+    private IDocFileService docFileService;
+    @Autowired
+    private IFileOperateService fileOperateService;
+    @Autowired
+    @Lazy
+    private IDocRelativeService docRelativeService;
+    @Autowired
+    private IDispatchFileService dispatchFileService;
+    @Autowired
+    private ISysParamsService sysParamsService;
+    @Autowired
+    @Lazy
+    private IComponentInfoService componentInfoService;
+    @Autowired
+    @Lazy
+    private IGuideCardBatchService guideCardBatchService;
+
+    /*澶囦唤澶勭悊*/
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean addDocInfo(MultipartFile file, DocInfoUploadRequest uploadRequest) {
+        if(file == null || file.isEmpty() || uploadRequest == null)
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        if(!ValidateUtil.validateString(uploadRequest.getAttributionId()) || !ValidateUtil.validateInteger(uploadRequest.getAttributionType()))
+            ExceptionCast.cast(DocumentCode.DOC_ATTRIBUTE_ERROR);
+        if(!ValidateUtil.validateString(uploadRequest.getDocClassCode()))
+            ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
+        DocClassification docClass = docClassificationService.getByCode(uploadRequest.getDocClassCode());
+        if(docClass == null)
+            ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
+        String fileName = FileUtilS.getFilenameNonSuffix(file.getOriginalFilename());
+        String fileNameAll = file.getOriginalFilename();
+        DocInfo en = findByAttrAndDocName(fileName, uploadRequest.getAttributionType(), uploadRequest.getAttributionId());
+        //閽堝瀛樺湪鐨勫鐞�
+        if(en != null)
+            ExceptionCast.cast(DocumentCode.DOC_IS_EXIST);
+        FileUploadResult fileUploadResult = FileUtilS.uploadFile(file);
+        if(fileUploadResult == null)
+            ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR);
+        DocInfo docInfo = new DocInfo();
+        String docId = IdWorker.getIdStr();
+        docInfo.setDocId(docId);
+        docInfo.setSyncStatus(2);
+        docInfo.setDocName(fileUploadResult.getFileName());
+        docInfo.setDocSuffix(fileUploadResult.getFileSuffix());
+        docInfo.setDocStatus(1);
+        DocRelative docRelative = new DocRelative();
+        docRelative.setAttributionId(uploadRequest.getAttributionId());
+        docRelative.setDocId(docInfo.getDocId());
+        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();
+        docFile.setDocId(docInfo.getDocId());
+        docFile.setFileName(fileUploadResult.getFileName());
+        docFile.setFileEncodeName(fileUploadResult.getFileEncodeName());
+        docFile.setFilePath(fileUploadResult.getFilePath());
+        docFile.setFileSize(fileUploadResult.getFileSize());
+        docFile.setFileSuffix(fileUploadResult.getFileSuffix());
+        b =  docFileService.addDocFile(docFile);
+        if(!b)
+            ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR);
+        docInfo.setPublishVersion(docFile.getDocVersion());
+        docInfo.setPublishFileId(docFile.getFileId());
+        //COPY
+        MdcEquipment mdcEquipment= iMdcEquipmentService.getById(uploadRequest.getAttributionId());
+        if (mdcEquipment != null) {
+            List<String> strings = iMdcProductionService.findListParentTreeAll(mdcEquipment.getId());
+            boolean copyFileNc = false;
+            if (strings != null && !strings.isEmpty()) {
+                String path = org.apache.commons.lang3.StringUtils.join(strings.toArray(), "/");
+                copyFileNc = FileUtilS.copyFile(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName(),
+                        path+ "/" + mdcEquipment.getEquipmentId() ,fileNameAll);
+                if (!copyFileNc) {
+                    ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
+                } else {
+                    FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(),
+                            docFile.getFileName(),docFile.getFileSuffix());
+
+                }
+            } else {
+                copyFileNc =FileUtilS.copyFile(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName(),
+                        mdcEquipment.getEquipmentId() ,fileNameAll);
+                if (!copyFileNc) {
+                    ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
+                } else {
+                    FileUtilS.deleteZipFromToSend(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName() + "/"+ mdcEquipment.getEquipmentId(),
+                            docFile.getFileName(),docFile.getFileSuffix());
+
+                }
+            }
+        }
+        boolean saveBool = super.save(docInfo);
+        if (uploadRequest.getDocClassCode().equals("NC")||uploadRequest.getDocClassCode().equals("other")){
+            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);
+                }
+            }
+        }
+        if (uploadRequest.getDocClassCode().equals("NC")){
+            boolean savaGuideCardBatch=guideCardBatchService.importGuideCardBatch(docInfo.getDocId(),uploadRequest.getAttributionId(),uploadRequest.getAttributionType());
+            if (!savaGuideCardBatch) {
+                ExceptionCast.cast(DocumentCode.DOC_BATCH_ERROR);
+            }
+        }
+        return saveBool;
+    }
+
+
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean addDocInfoRec(String pathFile,File fileRec) {
+        if (StringUtils.isEmpty(pathFile)) {
+            return false;
+        }
+        MultipartFile file = FileUtilS.fileToMultipartFile(fileRec);
+        DocClassification docClass = docClassificationService.getByCode("REC");
+        if(docClass == null) {
+            ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
+        }
+        //鏍规嵁璁惧缂栧彿鏌ヨ鏁版嵁
+        Integer recNum = pathFile.lastIndexOf("\\rec\\");
+        if (recNum == -1) {
+            return false;
+        }
+        String  recF =  pathFile.substring(0,recNum);//灏嗚繑鍥瀌ef}ab
+        Integer equipmentId = recF.lastIndexOf("\\");
+        String deviceNo = recF.substring(equipmentId+1);
+        if (StringUtils.isEmpty(deviceNo)) {
+            return false;
+        }
+        MdcEquipment mdcEquipment = iMdcEquipmentService.findEquipmentNameByEquipmentId(deviceNo);
+        if (mdcEquipment == null) {
+            return false;
+        }
+        String fileName = FileUtilS.getFilenameNonSuffix(file.getOriginalFilename());
+
+        FileUploadResult fileUploadResult = FileUtilS.uploadFile(file);
+        if(fileUploadResult == null) {
+            return false;
+        }
+        DocInfo en = findByAttrAndDocName(fileName, 7, mdcEquipment.getId());
+        if(en != null) {
+            return false;
+        }
+
+        DocInfo docInfo = new DocInfo();
+        String docId = IdWorker.getIdStr();
+        docInfo.setDocId(docId);
+        docInfo.setDocName(fileUploadResult.getFileName());
+        docInfo.setDocSuffix(fileUploadResult.getFileSuffix());
+        docInfo.setDocStatus(1);
+        docInfo.setSyncStatus(2);
+        DocRelative docRelative = new DocRelative();
+        docRelative.setAttributionId(mdcEquipment.getId());
+        docRelative.setDocId(docInfo.getDocId());
+        docRelative.setAttributionType(7);
+        docRelative.setClassificationId(docClass.getClassificationId());
+        boolean b = docRelativeService.save(docRelative);
+        if(!b) {
+            ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR);
+        }
+        DocFile docFile = new DocFile();
+        docFile.setDocId(docInfo.getDocId());
+        docFile.setFileName(fileUploadResult.getFileName());
+        docFile.setFileEncodeName(fileUploadResult.getFileEncodeName());
+        docFile.setFilePath(fileUploadResult.getFilePath());
+        docFile.setFileSize(fileUploadResult.getFileSize());
+        docFile.setFileSuffix(fileUploadResult.getFileSuffix());
+        b =  docFileService.addDocFile(docFile);
+        if(!b) {
+            return false;
+        }
+        docInfo.setPublishVersion(docFile.getDocVersion());
+        docInfo.setPublishFileId(docFile.getFileId());
+        boolean saveBool = super.save(docInfo);
+        return saveBool;
+    }
+
+    /**
+     * 瑙f瀽NC鏂囨。閫氱敤鏂规硶
+     * @param pathFile,fileRec
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean addDocInfoAnalysisGwNcService(String pathFile,File file) throws FileNotFoundException {
+        String line;
+        int count = 0;
+        String loFilePath = config.getPaths().get(0)+"/" + file.getName();
+        FileInputStream fis = new FileInputStream(loFilePath);
+        NcTxtFilePathInfo result = new NcTxtFilePathInfo();
+        Scanner sc = new Scanner(fis, "UTF-8");
+        while (count < 8 &&  sc.hasNext()) {
+            line = sc.nextLine();
+            if (count ==0) {
+                result.setFileTxtName(line.trim());
+            } else  if (count ==1) {
+                result.setFileNcName(line.trim());
+            }else  if (count ==2) {
+                result.setOrigFileName(line.trim());
+            }else  if (count ==3) {
+                result.setOrigFileSuffix(line.trim());
+            }else  if (count ==4) {
+                result.setFilePath(line.trim());
+            }else  if (count ==5) {
+                result.setEquipmentId(line.trim());
+            }else  if (count ==6) {
+                result.setFileAddOrDelete(Integer.valueOf(line.trim()));
+            }else  if (count == 7) {
+                result.setFileSize(line.trim());
+            }
+            count++;
+        }
+        sc.close();
+        if (result.getFileAddOrDelete() != null ) {
+            if ( result.getFileAddOrDelete()==1) {
+                String path = config.getPaths().get(0) +"/" + result.getFileNcName()+ ".NC";
+                    if (org.apache.commons.lang3.StringUtils.isNotBlank(result.getFileNcName()) &&
+                            result.getFileNcName().equals("null")) {
+                        //鏂囦欢寰呭鐞�
+                        //澶囦唤鏁版嵁
+                        FileUtilS.deleteFileNewRec(loFilePath);
+                    }
+                File ncFile = new File(path);
+                //宸茬粡瀛樺湪鏂囦欢闇�瑕佸浠�
+                String size = String.valueOf(ncFile.length());
+                if (!size.equals(result.getFileSize())) {
+                    return false;
+                }
+                boolean bool = this.addDocInfoRecService(result.getEquipmentId(),
+                        ncFile,result.getOrigFileSuffix(),
+                        FileUtilS.getFilenameNonSuffix(result.getOrigFileName())
+                        ,result.getFilePath());
+                if (bool) {
+                    FileUtilS.deleteFileNewRec(path);
+                    FileUtilS.deleteFileNewRec(loFilePath);
+                }else {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+
+    /**
+     * 绋嬪簭鍥炰紶锛堟秹瀵嗚В鏋愬伐鎺э級
+     * @param pathFile
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean addDocInfoAnalysisSmwNcService(String pathFile,File fileRec){
+        //纭瑙f瀽鐩綍
+        return true;
+    }
+
+    /**
+     * 鏂囨。瑙f瀽
+     * todo 淇敼鍒涘缓鏂囦欢鍏宠仈鍏崇郴锛屾敼鎴愬浐瀹歞ocId锛屽幓闄ゅ垱寤篋ocInfo
+     * @param equipmentId
+     * @param fileRec
+     * @param fileNameSuffix
+     * @param fileNameNew
+     * @param filePath
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean addDocInfoRecService(String equipmentId,File fileRec,String fileNameSuffix,String fileNameNew,String filePath ) {
+        if (StringUtils.isEmpty(filePath)) {
+            return false;
+        }
+        MultipartFile file = FileUtilS.fileToMultipartFile(fileRec);
+        DocClassification docClass = docClassificationService.getByCode("REC");
+        if(docClass == null) {
+            ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
+        }
+        //鏍规嵁璁惧缂栧彿鏌ヨ鏁版嵁
+        if (StringUtils.isEmpty(equipmentId)) {
+            return false;
+        }
+        MdcEquipment mdcEquipment = iMdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId);
+        if (mdcEquipment == null) {
+            return false;
+        }
+        String fileName = FileUtilS.getFilenameNonSuffix(file.getOriginalFilename());
+
+        FileUploadResult fileUploadResult = FileUtilS.uploadFileUpdateFileName(file,fileNameNew,fileNameSuffix);
+        if(fileUploadResult == null) {
+            return false;
+        }
+        DocInfo en = findByAttrAndDocName(fileName, 7, mdcEquipment.getId());
+        if(en != null) {
+            return false;
+        }
+
+        DocInfo docInfo = new DocInfo();
+        String docId = IdWorker.getIdStr();
+        docInfo.setDocId(docId);
+        docInfo.setDocName(fileUploadResult.getFileName());
+        docInfo.setDocSuffix(fileUploadResult.getFileSuffix());
+        docInfo.setDocStatus(1);
+        docInfo.setSyncStatus(2);
+        DocRelative docRelative = new DocRelative();
+        docRelative.setAttributionId(mdcEquipment.getId());
+        docRelative.setDocId(docInfo.getDocId());
+        docRelative.setAttributionType(7);
+        docRelative.setClassificationId(docClass.getClassificationId());
+        boolean b = docRelativeService.save(docRelative);
+        if(!b) {
+            ExceptionCast.cast(DocumentCode.DOC_UPLOAD_ERROR);
+        }
+        DocFile docFile = new DocFile();
+        docFile.setDocId(docInfo.getDocId());
+        docFile.setFileName(fileUploadResult.getFileName());
+        docFile.setFileEncodeName(fileUploadResult.getFileEncodeName());
+        docFile.setFilePath(fileUploadResult.getFilePath());
+        docFile.setFileSize(fileUploadResult.getFileSize());
+        docFile.setFileSuffix(fileUploadResult.getFileSuffix());
+        b =  docFileService.addDocFile(docFile);
+        if(!b) {
+            return false;
+        }
+        docInfo.setPublishVersion(docFile.getDocVersion());
+        docInfo.setPublishFileId(docFile.getFileId());
+        boolean saveBool = super.save(docInfo);
+        return saveBool;
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean editDocInfo(String id, DocInfo docInfo) {
+        if(!ValidateUtil.validateString(id) || docInfo == null)
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        DocInfo asDoc = findByAttrAndDocNameNotThis(docInfo.getDocName(), docInfo.getAttributionType(), docInfo.getAttributionId(), id);
+        if(asDoc != null)
+            ExceptionCast.cast(DocumentCode.DOC_IS_EXIST);
+        docInfo.setDocId(id);
+        docInfo.setDocStatus(null);
+        docInfo.setDocSuffix(null);
+        docInfo.setClassificationId(null);
+        docInfo.setPublishFileId(null);
+        docInfo.setPublishVersion(null);
+        return super.updateById(docInfo);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteDocInfo(String id,String attrType,String attrId) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            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);
+        boolean b = docFileService.deleteByDocId(id);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = docRelativeService.deleteByDocId(id);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        return super.removeById(id);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean pushDocFile(String id, MultipartFile file) {
+        if(file == null || file.isEmpty() || !ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if(!ValidateUtil.validateString(user.getUsername()))
+            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
+        FileOperate operate = fileOperateService.getByDocId(id);
+        if(operate == null || !user.getUsername().equals(operate.getCreateBy()))
+            ExceptionCast.cast(DocumentCode.DOC_OPERATE_PUSH_FAIL);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        List<MdcEquipment> deviceList = docRelativeService.findDeviceByDocId(en.getDocId());
+        if(deviceList != null && !deviceList.isEmpty())
+            ExceptionCast.cast(DocumentCode.DOC_DEVICE_EXIST);
+        String suffix = FileUtilS.getFileSuffix(file.getOriginalFilename());
+        if(ValidateUtil.validateString(en.getDocSuffix())) {
+            if(!en.getDocSuffix().equals(suffix)) {
+                ExceptionCast.cast(DocumentCode.DOC_SUFFIX_ERROR);
+            }
+        }else {
+            if(ValidateUtil.validateString(suffix)) {
+                ExceptionCast.cast(DocumentCode.DOC_SUFFIX_ERROR);
+            }
+        }
+        FileUploadResult fileUploadResult = FileUtilS.uploadFile(file);
+        DocFile docFile = new DocFile();
+        docFile.setDocId(id);
+        docFile.setFileName(fileUploadResult.getFileName());
+        docFile.setFileEncodeName(fileUploadResult.getFileEncodeName());
+        docFile.setFilePath(fileUploadResult.getFilePath());
+        docFile.setFileSize(fileUploadResult.getFileSize());
+        docFile.setFileSuffix(fileUploadResult.getFileSuffix());
+        boolean b = fileOperateService.deleteByDocId(id);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b=  docFileService.addDocFile(docFile);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        en.setPublishVersion(docFile.getDocVersion());
+        en.setPublishFileId(docFile.getFileId());
+        return super.updateById(en);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public DocFile checkDocInfo(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        if(en.getDocStatus() != 1)
+            ExceptionCast.cast(DocumentCode.DOC_OPERATE_FAIL);
+        if(!ValidateUtil.validateString(en.getPublishFileId()))
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE);
+        FileOperate operate = fileOperateService.getByDocId(id);
+        if(operate != null)
+            ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING);
+        operate = new FileOperate();
+        operate.setDocId(id);
+        boolean b = fileOperateService.save(operate);
+        if(!b)
+            ExceptionCast.cast(DocumentCode.DOC_OPERATE_FAIL);
+        DocFile fileInfo = docFileService.getById(en.getPublishFileId());
+        if(fileInfo == null)
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NOT_EXIST);
+        return fileInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean publishDocInfo(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        if(en.getDocStatus() != 1)
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_ERROR);
+        if(!ValidateUtil.validateString(en.getPublishFileId()))
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE);
+        DocFile pubFile = docFileService.getById(en.getPublishFileId());
+        if(pubFile == null)
+            ExceptionCast.cast(DocumentCode.DOC_FILE_ERROR);
+        FileOperate operate = fileOperateService.getByDocId(id);
+        if(operate != null)
+            ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING);
+        DocFile old = docFileService.getDocFileNearest(en.getDocId());
+        if(old == null)
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE);
+        if(old.getDocVersion().contains(".")) {
+            DocFile docFile = new DocFile();
+            BeanUtils.copyProperties(pubFile, docFile);
+            docFile.setFileId(null);
+            docFile.setDocVersion(old.getDocVersion().substring(0, 1));
+            boolean b =  docFileService.save(docFile);
+            if(!b)
+                ExceptionCast.cast(CommonCode.FAIL);
+            return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 2).set(DocInfo::getPublishFileId, docFile.getFileId())
+                    .set(DocInfo::getPublishVersion, docFile.getDocVersion()).update();
+        }else {
+            return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 2).set(DocInfo::getPublishFileId, old.getFileId())
+                    .set(DocInfo::getPublishVersion, old.getDocVersion()).update();
+        }
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean republishDocInfo(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        if(en.getDocStatus() != 2)
+            ExceptionCast.cast(DocumentCode.DOC_REPUBLISH_ERROR);
+        return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 1).update();
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean pigeonholeDocInfo(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        if(en.getDocStatus() == 3)
+            ExceptionCast.cast(DocumentCode.DOC_PIGEONHOLE_ERROR);
+        FileOperate operate = fileOperateService.getByDocId(id);
+        if(operate != null)
+            ExceptionCast.cast(DocumentCode.DOC_IS_OPERATING);
+        return super.lambdaUpdate().eq(DocInfo::getDocId, id).set(DocInfo::getDocStatus, 3).update();
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean cancelPullDocInfo(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if(!ValidateUtil.validateString(user.getUsername()))
+            ExceptionCast.cast(UcenterCode.UCENTER_ACCOUNT_NOT_EXIST);
+        FileOperate operate = fileOperateService.getByDocId(id);
+        if(operate == null || !user.getUsername().equals(operate.getCreateBy()))
+            ExceptionCast.cast(DocumentCode.DOC_CANCEL_PULL_ERROR);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        return fileOperateService.deleteByDocId(id);
+    }
+
+    @Override
+    public Result<?> findPageList(int page, int size, DocInfoQueryRequest docQuery) {
+        if(page < 1 || size < 1) {
+            ExceptionCast.cast(CommonCode.INVALID_PAGE);
+        }
+        if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionId())
+                || !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);
+        }
+        IPage<DocInfo> pageData = new Page<>(page, size);
+
+//        LambdaQueryWrapper<DocInfo> lambdaQuery = Wrappers.lambdaQuery();
+//        lambdaQuery.eq(DocInfo::getAttributionType, docQuery.getAttributionType()).eq(DocInfo::getAttributionId, docQuery.getAttributionId())
+//                .eq(DocInfo::getClassificationId, docClassification.getClassificationId());
+        QueryWrapper<DocInfo> queryWrapper = Wrappers.query();
+        queryWrapper.eq("r.attribution_type", docQuery.getAttributionType()).eq("r.attribution_id", docQuery.getAttributionId())
+                .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);
+        IPage<DocInfo> docInfoIPage = super.getBaseMapper().findDocExtList(pageData, queryWrapper);
+        return Result.ok(docInfoIPage);
+    }
+
+    private void getDocQuery(DocInfoQueryRequest docQuery, QueryWrapper<DocInfo> queryWrapper) {
+        if (docQuery.getDocStatus() != null && docQuery.getDocStatus().contains(",")) {
+            String[] docStatusArray = docQuery.getDocStatus().split(",");
+            List<Integer> docStatusList = Arrays.stream(docStatusArray).map(Integer::parseInt).collect(Collectors.toList());
+            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())){
+                queryWrapper.isNull("o.doc_id");
+            }else if (("2").equals(docQuery.getPullStatus())){
+                queryWrapper.isNotNull("o.doc_id");
+            }
+        }
+        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 (StrUtil.isNotEmpty(docQuery.getColumn())){
+            if (("desc").equals(docQuery.getOrder())){
+                queryWrapper.orderByDesc("u."+ CamelToSnakeRegex.camelToSnake(docQuery.getColumn()));
+            }else {
+                queryWrapper.orderByAsc("u."+CamelToSnakeRegex.camelToSnake(docQuery.getColumn()));
+            }
+        }
+    }
+
+    @Override
+    public DocInfo getByDocAttrAndDocId(String docId, Integer attrType, String attributeId) {
+        if(!ValidateUtil.validateString(docId) || !ValidateUtil.validateString(attributeId) || !ValidateUtil.validateInteger(attrType))
+            return null;
+        List<DocInfo> list = super.getBaseMapper().getByDocAttrAndDocId(docId, attrType, attributeId);
+        if(list == null || list.size() != 1)
+            return null;
+        return list.get(0);
+    }
+
+    @Override
+    public DocFile previewDocFile(String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        DocFile fileInfo = docFileService.getById(en.getPublishFileId());
+        if(fileInfo == null)
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NOT_EXIST);
+        return fileInfo;
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByProductId(String productId) {
+        if(!ValidateUtil.validateString(productId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 1;
+        boolean b = docFileService.deleteByDocAttr(attrType, productId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, productId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        return docRelativeService.deleteByDocAttr(attrType, productId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByComponentId(String componentId) {
+        if(!ValidateUtil.validateString(componentId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 2;
+        boolean b = docFileService.deleteByDocAttr(attrType, componentId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, componentId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        return docRelativeService.deleteByDocAttr(attrType, componentId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByPartsId(String partsId) {
+        if(!ValidateUtil.validateString(partsId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 3;
+        boolean b = docFileService.deleteByDocAttr(attrType, partsId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, partsId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        return docRelativeService.deleteByDocAttr(attrType, partsId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByDeviceId(String deviceId) {
+        if(!ValidateUtil.validateString(deviceId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 7;
+        /*boolean b = docFileService.deleteByDocAttr(attrType, deviceId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, deviceId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);*/
+        return docRelativeService.deleteByDocAttr(attrType, deviceId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByProcessId(String processId) {
+        if(!ValidateUtil.validateString(processId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 5;
+        boolean b = docFileService.deleteByDocAttr(attrType, processId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, processId);
+        if(!b) {
+            ExceptionCast.cast(CommonCode.FAIL);
+        }
+        return docRelativeService.deleteByDocAttr(attrType, processId);
+    }
+
+    /**
+     * 鍒犻櫎宸ユ涓嬬殑鎵�鏈夋枃妗�
+     * @param stepId
+     * @return
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByStepId(String stepId){
+        if(!ValidateUtil.validateString(stepId))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        Integer attrType = 6;
+        boolean b = docFileService.deleteByDocAttr(attrType, stepId);
+        if(!b)
+            ExceptionCast.cast(CommonCode.FAIL);
+        b = deleteByDocAttr(attrType, stepId);
+        if(!b) {
+            ExceptionCast.cast(CommonCode.FAIL);
+        }
+        return docRelativeService.deleteByDocAttr(attrType, stepId);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public boolean deleteByDocAttr(Integer attrType, String attrId) {
+        int i = super.getBaseMapper().deleteByDocAttr(attrType, attrId);
+        return i >= 0;
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResult pullDocFile(HttpServletRequest request, HttpServletResponse response, String id) {
+        DocFile docFile = checkDocInfo(id);
+        if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName()) ||
+                /*!ValidateUtil.validateString(docFile.getFileSuffix()) ||*/ !ValidateUtil.validateString(docFile.getFileEncodeName()))
+            return new ResponseResult(CommonCode.FAIL);
+        String fileName;
+        if(ValidateUtil.validateString(docFile.getFileSuffix())) {
+            fileName = docFile.getFileName() + "." + docFile.getFileSuffix();
+        }else {
+            fileName = docFile.getFileName();
+        }
+        String filePath = docFile.getFilePath();
+        String fileEncodeName = docFile.getFileEncodeName();
+        FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName);
+        return null;
+    }
+
+    @Override
+    public DocInfo findByAttrAndDocName(String docName, Integer attrType, String attrId) {
+        List<DocInfo> docInfoList = super.getBaseMapper().findByAttrAndDocName(docName, attrType, attrId);
+        if(docInfoList == null || docInfoList.isEmpty())
+            return null;
+        return docInfoList.get(0);
+    }
+
+    @Override
+    public DocInfo findByAttrAndDocNameNotThis(String docName, Integer attrType, String attrId, String docId) {
+        List<DocInfo> docInfoList = super.getBaseMapper().findByAttrAndDocName(docName, attrType, attrId);
+        if(docInfoList == null || docInfoList.isEmpty())
+            return null;
+        for(DocInfo docInfo : docInfoList) {
+            if(!docId.equals(docInfo.getDocId())) {
+                return docInfo;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public List<DocInfo> getByDocId(String docId) {
+        return super.getBaseMapper().getByDocId(docId);
+    }
+
+    @Override
+    public IPage<DocInfo> findPageListByDevice(int page, int size, DocInfoQueryRequest docQuery) {
+        if(page < 1 || size < 1) {
+            ExceptionCast.cast(CommonCode.INVALID_PAGE);
+        }
+        if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionId())
+                || !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);
+        }
+        IPage<DocInfo> pageData = new Page<>(page, size);
+        QueryWrapper<DocInfo> queryWrapper = Wrappers.query();
+        queryWrapper.eq("r.attribution_type", docQuery.getAttributionType())
+                .eq("r.attribution_id", docQuery.getAttributionId())
+                .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]);
+            }
+        }
+        if (docQuery.getDocStatus() != null && docQuery.getDocStatus().contains(",")) {
+            String[] docStatusArray = docQuery.getDocStatus().split(",");
+            List<Integer> docStatusList = Arrays.stream(docStatusArray).map(Integer::parseInt).collect(Collectors.toList());
+            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())){
+                queryWrapper.isNull("o.doc_id");
+            }else if (("2").equals(docQuery.getPullStatus())){
+                queryWrapper.isNotNull("o.doc_id");
+            }
+        }
+        if (docQuery.getSyncStatus()!=null){
+            if (docQuery.getSyncStatus()==1){
+                queryWrapper.isNotNull("t.sync_flag");
+            }else if (docQuery.getSyncStatus()==2){
+                queryWrapper.isNull("t.sync_flag");
+            }
+        }
+        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()));
+        }
+        IPage<DocInfo> docInfoIPage = super.getBaseMapper().findDeviceDocExtList(pageData, queryWrapper);
+        if (docInfoIPage != null && docInfoIPage.getRecords() != null && !docInfoIPage.getRecords().isEmpty()) {
+            for (DocInfo d : docInfoIPage.getRecords()) {
+                d.setSyncStatus(2);
+            }
+        }
+        return docInfoIPage;
+    }
+
+    @Override
+    public List<DocInfo> findList(DocInfoQueryRequest docQuery) {
+        if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionId())
+                || !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);
+        }
+
+        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())) {
+            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);
+    }
+
+    /**
+     * 閫氳繃涓�缁刟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<>();
+        for(ProcessStream s : streams) {
+            ids.add(s.getProcessId());
+        }
+        DocClassification docClassification = docClassificationService.getByCode("NC");
+        if(docClassification == null) {
+            ExceptionCast.cast(CommonCode.INVALID_PAGE);
+        }
+        QueryWrapper<DocInfo> queryWrapper = Wrappers.query();
+        queryWrapper.in("r.attribution_id", ids)
+                .eq("r.classification_id", docClassification.getClassificationId())
+        .ne("u.doc_status", 3).isNotNull("u.publish_file_id");
+        return super.getBaseMapper().findDocExtList(queryWrapper);
+    }
+
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    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,attrType,attrId);
+        }
+        return true;
+    }
+
+    @Override
+    public ResponseResult downloadDocFile(HttpServletRequest request, HttpServletResponse response, String id) {
+        if(!ValidateUtil.validateString(id))
+            ExceptionCast.cast(CommonCode.INVALID_PARAM);
+        DocInfo en = super.getById(id);
+        if(en == null)
+            ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
+        if(!ValidateUtil.validateString(en.getPublishFileId()))
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NONE);
+        DocFile docFile = docFileService.getById(en.getPublishFileId());
+        if(docFile == null)
+            ExceptionCast.cast(DocumentCode.DOC_PUBLISH_FILE_NOT_EXIST);
+        if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName()) ||
+                /*!ValidateUtil.validateString(docFile.getFileSuffix()) ||*/ !ValidateUtil.validateString(docFile.getFileEncodeName()))
+            return new ResponseResult(CommonCode.FAIL);
+        String fileName;
+        if(ValidateUtil.validateString(docFile.getFileSuffix())) {
+            fileName = docFile.getFileName() + "." + docFile.getFileSuffix();
+        }else {
+            fileName = docFile.getFileName();
+        }
+        String filePath = docFile.getFilePath();
+        String fileEncodeName = docFile.getFileEncodeName();
+        FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName);
+        return null;
+    }
+}

--
Gitblit v1.9.3