From cc0e9036de6e922e8fe254fef01d8de9996024b7 Mon Sep 17 00:00:00 2001
From: hyingbo <1363390067@qq.com>
Date: 星期四, 17 七月 2025 18:16:03 +0800
Subject: [PATCH] 获取报警描述修改

---
 lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DocInfoServiceImpl.java |  485 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 347 insertions(+), 138 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 33a1e56..a6f9814 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,7 @@
 package org.jeecg.modules.dnc.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
 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,20 +12,30 @@
 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.service.*;
-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.system.service.ISysDictService;
+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.flowable.apithird.business.entity.FlowMyBusiness;
+import org.jeecg.modules.flowable.apithird.business.service.IFlowMyBusinessService;
+import org.jeecg.modules.flowable.service.IFlowTaskService;
+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;
@@ -36,11 +46,22 @@
 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
@@ -51,12 +72,19 @@
     @Lazy
     private IDocRelativeService docRelativeService;
     @Autowired
+    private IDispatchFileService dispatchFileService;
+    @Autowired
+    private ISysParamsService sysParamsService;
+    @Autowired
     @Lazy
-    private IDeviceInfoService deviceInfoService;
+    private IComponentInfoService componentInfoService;
     @Autowired
-    private IDeviceGroupService deviceGroupService;
+    @Lazy
+    private IGuideCardBatchService guideCardBatchService;
     @Autowired
-    private INcLogInfoService iNcLogInfoService;
+    private IFlowMyBusinessService flowMyBusinessService;
+    @Autowired
+    private IFlowTaskService flowTaskService;
 
     /*澶囦唤澶勭悊*/
     @Override
@@ -93,6 +121,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();
@@ -108,46 +149,61 @@
         docInfo.setPublishVersion(docFile.getDocVersion());
         docInfo.setPublishFileId(docFile.getFileId());
         //COPY
-        DeviceInfo deviceInfo= deviceInfoService.getById(uploadRequest.getAttributionId());
-        if (deviceInfo != null) {
-            List<String> strings =  deviceGroupService.findListParentTreeAll(deviceInfo.getGroupId());
+        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+ "/" + deviceInfo.getDeviceNo() ,fileNameAll);
+                        path+ "/" + mdcEquipment.getEquipmentId() ,fileNameAll);
                 if (!copyFileNc) {
                     ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
                 } else {
-                    FileUtilS.deleteZipFromToSend(path + "/"+ deviceInfo.getDeviceNo(),
+                    FileUtilS.deleteZipFromToSend(path + "/"+ mdcEquipment.getEquipmentId(),
                             docFile.getFileName(),docFile.getFileSuffix());
 
                 }
             } else {
                 copyFileNc =FileUtilS.copyFile(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName(),
-                        deviceInfo.getDeviceNo() ,fileNameAll);
+                        mdcEquipment.getEquipmentId() ,fileNameAll);
                 if (!copyFileNc) {
                     ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR);
                 } else {
-                    FileUtilS.deleteZipFromToSend(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName() + "/"+ deviceInfo.getDeviceNo(),
+                    FileUtilS.deleteZipFromToSend(fileUploadResult.getFilePath()+"/" + fileUploadResult.getFileEncodeName() + "/"+ mdcEquipment.getEquipmentId(),
                             docFile.getFileName(),docFile.getFileSuffix());
 
                 }
             }
-
         }
-        //娣诲姞鏃ュ織
-        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);
+        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})
@@ -167,12 +223,12 @@
         }
         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;
         }
-        DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
-        if (deviceInfo == null) {
+        MdcEquipment mdcEquipment = iMdcEquipmentService.findEquipmentNameByEquipmentId(deviceNo);
+        if (mdcEquipment == null) {
             return false;
         }
         String fileName = FileUtilS.getFilenameNonSuffix(file.getOriginalFilename());
@@ -181,7 +237,7 @@
         if(fileUploadResult == null) {
             return false;
         }
-        DocInfo en = findByAttrAndDocName(fileName, 4, deviceInfo.getDeviceId());
+        DocInfo en = findByAttrAndDocName(fileName, 7, mdcEquipment.getId());
         if(en != null) {
             return false;
         }
@@ -194,9 +250,9 @@
         docInfo.setDocStatus(1);
         docInfo.setSyncStatus(2);
         DocRelative docRelative = new DocRelative();
-        docRelative.setAttributionId(deviceInfo.getDeviceId());
+        docRelative.setAttributionId(mdcEquipment.getId());
         docRelative.setDocId(docInfo.getDocId());
-        docRelative.setAttributionType(4);
+        docRelative.setAttributionType(7);
         docRelative.setClassificationId(docClass.getClassificationId());
         boolean b = docRelativeService.save(docRelative);
         if(!b) {
@@ -219,6 +275,94 @@
         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 ) {
@@ -231,12 +375,11 @@
             ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR);
         }
         //鏍规嵁璁惧缂栧彿鏌ヨ鏁版嵁
-        String deviceNo = equipmentId;
-        if (StringUtils.isEmpty(deviceNo)) {
+        if (StringUtils.isEmpty(equipmentId)) {
             return false;
         }
-        DeviceInfo deviceInfo = deviceInfoService.getByDeviceNo(deviceNo);
-        if (deviceInfo == null) {
+        MdcEquipment mdcEquipment = iMdcEquipmentService.findEquipmentNameByEquipmentId(equipmentId);
+        if (mdcEquipment == null) {
             return false;
         }
         String fileName = FileUtilS.getFilenameNonSuffix(file.getOriginalFilename());
@@ -245,7 +388,7 @@
         if(fileUploadResult == null) {
             return false;
         }
-        DocInfo en = findByAttrAndDocName(fileName, 4, deviceInfo.getDeviceId());
+        DocInfo en = findByAttrAndDocName(fileName, 7, mdcEquipment.getId());
         if(en != null) {
             return false;
         }
@@ -258,9 +401,9 @@
         docInfo.setDocStatus(1);
         docInfo.setSyncStatus(2);
         DocRelative docRelative = new DocRelative();
-        docRelative.setAttributionId(deviceInfo.getDeviceId());
+        docRelative.setAttributionId(mdcEquipment.getId());
         docRelative.setDocId(docInfo.getDocId());
-        docRelative.setAttributionType(4);
+        docRelative.setAttributionType(7);
         docRelative.setClassificationId(docClass.getClassificationId());
         boolean b = docRelativeService.save(docRelative);
         if(!b) {
@@ -300,23 +443,12 @@
         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);
     }
 
     @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);
@@ -324,6 +456,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);
@@ -333,15 +479,14 @@
         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);
+        //寮哄埗缁撴潫娴佺▼ 鍒犻櫎鐢ㄦ埛鐨勬寰呭姙浠诲姟
+        List<DispatchFile> dispatchFiles=dispatchFileService.list(new QueryWrapper<DispatchFile>().eq("doc_id",id));
+        if (dispatchFiles != null && !dispatchFiles.isEmpty()) {
+            FlowMyBusiness flowMyBusiness = flowMyBusinessService.selectByDataId(dispatchFiles.get(0).getId());
+            if (flowMyBusiness != null) {
+                flowTaskService.end(flowMyBusiness.getProcessInstanceId(), "鍒犻櫎鏂囨。");
+            }
+        }
         return super.removeById(id);
     }
 
@@ -359,7 +504,7 @@
         DocInfo en = super.getById(id);
         if(en == null)
             ExceptionCast.cast(DocumentCode.DOC_NOT_EXIST);
-        List<DeviceInfo> deviceList = docRelativeService.findDeviceByDocId(en.getDocId());
+        List<MdcEquipment> deviceList = docRelativeService.findDeviceByDocId(en.getDocId());
         if(deviceList != null && !deviceList.isEmpty())
             ExceptionCast.cast(DocumentCode.DOC_DEVICE_EXIST);
         String suffix = FileUtilS.getFileSuffix(file.getOriginalFilename());
@@ -380,16 +525,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);
@@ -448,15 +583,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);
@@ -483,15 +609,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();
     }
 
@@ -508,15 +625,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();
     }
 
@@ -534,15 +642,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);
     }
 
@@ -578,11 +677,42 @@
                 queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]);
             }
         }
-        queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime());
-        queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime());
-        queryWrapper.orderByDesc("u.create_time");
+        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
@@ -658,7 +788,7 @@
     public boolean deleteByDeviceId(String deviceId) {
         if(!ValidateUtil.validateString(deviceId))
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        Integer attrType = 4;
+        Integer attrType = 7;
         /*boolean b = docFileService.deleteByDocAttr(attrType, deviceId);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
@@ -673,7 +803,7 @@
     public boolean deleteByProcessId(String processId) {
         if(!ValidateUtil.validateString(processId))
             ExceptionCast.cast(CommonCode.INVALID_PARAM);
-        Integer attrType = 4;
+        Integer attrType = 5;
         boolean b = docFileService.deleteByDocAttr(attrType, processId);
         if(!b)
             ExceptionCast.cast(CommonCode.FAIL);
@@ -684,14 +814,32 @@
         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);
-        if(i >= 0) {
-            return true;
-        }
-        return false;
+        return i >= 0;
     }
 
     @Override
@@ -710,15 +858,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;
     }
 
@@ -777,9 +916,41 @@
                 queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]);
             }
         }
-        queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime());
-        queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime());
-        queryWrapper.orderByDesc("u.create_time");
+        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()) {
@@ -790,7 +961,7 @@
     }
 
     @Override
-    public Result<?> findList(DocInfoQueryRequest docQuery) {
+    public List<DocInfo> findList(DocInfoQueryRequest docQuery) {
         if(docQuery == null || !ValidateUtil.validateString(docQuery.getAttributionId())
                 || !ValidateUtil.validateInteger(docQuery.getAttributionType()) ||
                 !ValidateUtil.validateString(docQuery.getDocClassCode())) {
@@ -802,6 +973,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())) {
@@ -814,11 +986,48 @@
                 queryWrapper.eq(StrUtil.isNotEmpty(docNameArr[1]), "u.doc_suffix", docNameArr[1]);
             }
         }
-        queryWrapper.ge(StrUtil.isNotEmpty(docQuery.getStartTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getStartTime());
-        queryWrapper.le(StrUtil.isNotEmpty(docQuery.getEndTime()),"date_format(u.create_time,'%Y-%m-%d %H:%i:%s')",docQuery.getEndTime());
-        List<DocInfo> docInfoIPage = super.getBaseMapper().findDocExtList(queryWrapper);
-        return Result.ok(docInfoIPage);
+        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) {
@@ -839,11 +1048,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