lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/listener/FileListener.java
@@ -2,22 +2,25 @@ import org.apache.commons.io.monitor.FileAlterationListener; import org.apache.commons.io.monitor.FileAlterationObserver; import org.jeecg.common.util.FileUtil; import org.jeecg.modules.dnc.service.IDocInfoService; import org.jeecg.modules.dnc.utils.file.FileUtilS; import org.jeecg.modules.dnc.dto.TransferPackage; import org.jeecg.modules.dnc.service.impl.DataImportService; import org.jeecg.modules.dnc.service.impl.FileFerryService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.io.File; import java.util.Objects; @Component public class FileListener implements FileAlterationListener { private static final Logger log = LoggerFactory.getLogger(FileListener.class); @Autowired private IDocInfoService docInfoService; // 文档服务 private FileFerryService fileFerryService; @Autowired private DataImportService dataImportService; @Override public void onStart(FileAlterationObserver observer) { @@ -43,6 +46,11 @@ public void onFileCreate(File file) { String filePath = file.getAbsolutePath(); log.info("[新建]: {}", filePath); if (filePath.endsWith(".ferry")){ TransferPackage data = fileFerryService.importData(filePath); dataImportService.importTransferPackage(data); log.info("文件导入完成"); } } @Override public void onFileChange(File file) { @@ -58,42 +66,5 @@ public void onStop(FileAlterationObserver observer) { // log.info("结束监听目录: {}", observer.getDirectory().getAbsolutePath()); } /** * 工控网解析涉密网传过来的NC文件与nc文件进行解析 * @param file */ private void handleIndustrialDocFile(File file) { log.info("工控网解析涉密网传过来的NC文件与nc文件进行解析: {}", file.getAbsolutePath()); try { if (Objects.equals(FileUtil.getFileSuffix(file.getName()), "nc")) { boolean success = docInfoService.addDocInfoAnalysisGwNcService(file.getAbsolutePath(), file); if (success) { FileUtilS.copyFileRec(file.getAbsolutePath()); FileUtilS.fileRecDelete(file.getAbsolutePath()); } }else if (Objects.equals(FileUtil.getFileSuffix(file.getName()), "txt")) { //todo 是否解析工作流操作 } } catch (Exception e) { log.error("工控网解析涉密网传过来的NC文件与nc文件进行解析: {}", e.getMessage()); } } /** * 涉密网解析工控网传过来的NC文件与nc文件进行解析(程序回传) * @param file */ private void handleSecretDocFile(File file) { log.info("涉密网解析工控网传过来的NC文件与nc文件进行解析: {}", file.getAbsolutePath()); try { boolean b= docInfoService.addDocInfoAnalysisSmwNcService(file.getAbsolutePath(), file); }catch (Exception e) { log.error("涉密网解析工控网传过来的NC文件与nc文件进行解析: {}", e.getMessage()); } } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/mapper/xml/DocInfoMapper.xml
@@ -118,6 +118,7 @@ ,d.publish_file_id ,d.publish_version ,d.description ,d.doc_dispatch_status from (select classification_id, doc_id,attribution_type,attribution_id from nc_doc_relative where delete_flag=0 and doc_id=#{docId} and attribution_type=#{attrType} and attribution_id=#{attrId}) r inner join nc_doc_info d lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/ComponentInfoSeServiceImpl.java
@@ -628,14 +628,18 @@ List<Long> ids = productMixList.stream().map(ProductMix::getId).collect(Collectors.toList()); //获取已经自身被借用的部件 LambdaQueryWrapper<ComponentInfo> borrowQueryWrapper = new LambdaQueryWrapper<>(); borrowQueryWrapper.in(ComponentInfo::getBorrowId,ids); if (!ids.isEmpty()){ borrowQueryWrapper.in(ComponentInfo::getBorrowId,ids); } borrowQueryWrapper.eq(ComponentInfo::getParentId,componentInfo.getComponentId()); List<String> borrowIds= super.list(borrowQueryWrapper).stream().map(ComponentInfo::getBorrowId).collect(Collectors.toList()); LambdaQueryWrapper<ComponentInfo> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.like(StrUtil.isNotEmpty(componentInfo.getComponentName()),ComponentInfo::getComponentName, componentInfo.getComponentName()); queryWrapper.like(StrUtil.isNotEmpty(componentInfo.getComponentCode()),ComponentInfo::getComponentCode, componentInfo.getComponentCode()); queryWrapper.isNull(ComponentInfo::getBorrowId); queryWrapper.in(ComponentInfo::getComponentId,ids); if (!ids.isEmpty()){ queryWrapper.in(ComponentInfo::getComponentId,ids); } queryWrapper.ne(StrUtil.isNotEmpty(oldComponentInfo.getBorrowId()),ComponentInfo::getComponentId,oldComponentInfo.getBorrowId()); if (!borrowIds.isEmpty()) { queryWrapper.notIn(ComponentInfo::getComponentId,borrowIds); lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/DataImportService.java
@@ -1,6 +1,5 @@ package org.jeecg.modules.dnc.service.impl; import cn.hutool.core.util.StrUtil; import com.jeecg.weibo.exception.BusinessException; import org.jeecg.modules.dnc.dto.ComponentHierarchy; import org.jeecg.modules.dnc.dto.TransferPackage; @@ -157,12 +156,6 @@ saveTreePath(transferPackage.getTraceChain().getTreePath()); } //保存权限 if (transferPackage.getTraceChain() != null&& transferPackage.getTraceChain().getPermissionStreamNewList() != null) { savePermissionStreamNewList(transferPackage.getTraceChain().getPermissionStreamNewList()); } // 保存设备类 if (transferPackage.getTraceChain() != null&& transferPackage.getTraceChain().getDeviceManagement() != null) { @@ -222,7 +215,8 @@ productMapper.insert(product); logger.debug("产品已保存: {}", product.getProductId()); } else { logger.debug("产品已存在: {}", product.getProductId()); productMapper.updateById(product); logger.debug("产品已更新: {}", product.getProductId()); } } @@ -232,7 +226,8 @@ componentMapper.insert(component); logger.debug("部件已保存: {}", component.getComponentId()); } else { logger.debug("部件已存在: {}", component.getComponentId()); componentMapper.updateById(component); logger.debug("部件已更新: {}", component.getComponentId()); } } } @@ -242,7 +237,8 @@ partsMapper.insert(parts); logger.debug("零件已保存: {}", parts.getPartsId()); } else { logger.debug("零件已存在: {}", parts.getPartsId()); partsMapper.updateById(parts); logger.debug("零件已更新: {}", parts.getPartsId()); } } @@ -251,7 +247,8 @@ psvMapper.insert(processSpec); logger.debug("工艺规程已保存: {}", processSpec.getId()); } else { logger.debug("工艺规程已存在: {}", processSpec.getId()); psvMapper.updateById(processSpec); logger.debug("工艺规程已更新: {}", processSpec.getId()); } } @@ -260,7 +257,8 @@ processMapper.insert(process); logger.debug("工序已保存: {}", process.getProcessId()); } else { logger.debug("工序已存在: {}", process.getProcessId()); processMapper.updateById(process); logger.debug("工序已更新: {}", process.getProcessId()); } } @@ -269,7 +267,8 @@ workStepMapper.insert(workStep); logger.debug("工步已保存: {}", workStep.getId()); } else { logger.debug("工步已存在: {}", workStep.getId()); workStepMapper.updateById(workStep); logger.debug("工步已更新: {}", workStep.getId()); } } @@ -279,113 +278,10 @@ productMixMapper.insert(productMix); logger.debug("产品组合已保存: {}", productMix.getId()); } else { logger.debug("产品组合已存在: {}", productMix.getId()); productMixMapper.updateById(productMix); logger.debug("产品组合已更新: {}", productMix.getId()); } } } private void savePermissionStreamNewList(List<PermissionStreamNew> permissionStreamNewList) { for (PermissionStreamNew permissionStreamNew : permissionStreamNewList) { if (permissionStreamNew.getUserId() != null) { String id=sysUserService.getUserByName(permissionStreamNew.getUserId()).getId(); if (id!=null){ permissionStreamNew.setUserId(id); } } if (permissionStreamNew.getDepartId() != null) { String id=mdcProductionService.findByOrgCode(permissionStreamNew.getDepartId()).getId(); if (id!=null){ permissionStreamNew.setDepartId(id); } } permissionStreamNewMapper.insert(permissionStreamNew); logger.debug("权限已保存: {}", permissionStreamNew.getId()); } //分批添加产品、部件、零件、工艺规程、工序、工步权限 permissionStreamNewList.forEach(item -> { switch (item.getBusinessType()){ case "1": if (StrUtil.isNotEmpty(item.getUserId())){ ProductPermission productPermission = new ProductPermission(); productPermission.setProductId(item.getBusinessId()); productPermission.setUserId(item.getUserId()); productPermissionService.save(productPermission); }else { ProductDepartment productDepartment = new ProductDepartment(); productDepartment.setProductId(item.getBusinessId()); productDepartment.setDepartId(item.getDepartId()); productDepartmentService.save(productDepartment); } break; case "2": if (StrUtil.isNotEmpty(item.getUserId())){ ComponentPermission componentPermission = new ComponentPermission(); componentPermission.setComponentId(item.getBusinessId()); componentPermission.setUserId(item.getUserId()); componentPermissionService.save(componentPermission); }else { ComponentDepartment componentDepartment = new ComponentDepartment(); componentDepartment.setComponentId(item.getBusinessId()); componentDepartment.setDepartId(item.getDepartId()); componentDepartmentService.save(componentDepartment); } break; case "3": if (StrUtil.isNotEmpty(item.getUserId())){ PartsPermission partsPermission = new PartsPermission(); partsPermission.setPartsId(item.getBusinessId()); partsPermission.setUserId(item.getUserId()); partsPermissionService.save(partsPermission); }else { PartsDepartment partsDepartment = new PartsDepartment(); partsDepartment.setPartsId(item.getBusinessId()); partsDepartment.setDepartId(item.getDepartId()); partsDepartmentService.save(partsDepartment); } break; case "4": if (StrUtil.isNotEmpty(item.getUserId())){ ProcessSpecVersionPermission processSpecVersionPermission = new ProcessSpecVersionPermission(); processSpecVersionPermission.setPsvId(item.getBusinessId()); processSpecVersionPermission.setUserId(item.getUserId()); processSpecVersionPermissionService.save(processSpecVersionPermission); }else { ProcessSpecVersionDepartment processSpecVersionDepartment = new ProcessSpecVersionDepartment(); processSpecVersionDepartment.setPsvId(item.getBusinessId()); processSpecVersionDepartment.setDepartId(item.getDepartId()); processSpecVersionDepartmentService.save(processSpecVersionDepartment); } break; case "5": if (StrUtil.isNotEmpty(item.getUserId())){ ProcessionPermission processionPermission = new ProcessionPermission(); processionPermission.setProcessId(item.getBusinessId()); processionPermission.setUserId(item.getUserId()); processStreamPermissionService.save(processionPermission); }else { ProcessionDepartment processionDepartment = new ProcessionDepartment(); processionDepartment.setProcessId(item.getBusinessId()); processionDepartment.setDepartId(item.getDepartId()); processionDepartmentService.save(processionDepartment); } break; case "6": if (StrUtil.isNotEmpty(item.getUserId())){ WorkStepPermission workStepPermission = new WorkStepPermission(); workStepPermission.setStepId(item.getBusinessId()); workStepPermission.setUserId(item.getUserId()); workStepPermissionService.save(workStepPermission); }else { WorkStepDepartment workStepDepartment = new WorkStepDepartment(); workStepDepartment.setStepId(item.getBusinessId()); workStepDepartment.setDepartId(item.getDepartId()); workStepDepartmentService.save(workStepDepartment); } break; default: } }); } private void saveDeviceManagement(DeviceManagement deviceManagement) { @@ -393,7 +289,8 @@ deviceManagementMapper.insert(deviceManagement); logger.debug("设备类信息已保存: {}", deviceManagement.getId()); } else { logger.debug("设备类信息已存在: {}", deviceManagement.getId()); deviceManagementMapper.updateById(deviceManagement); logger.debug("设备类信息已更新: {}", deviceManagement.getId()); } } @@ -402,7 +299,8 @@ deviceTypeMapper.insert(deviceType); logger.debug("设备类已保存: {}", deviceType.getId()); } else { logger.debug("设备类已存在: {}", deviceType.getId()); deviceTypeMapper.updateById(deviceType); logger.debug("设备类已更新: {}", deviceType.getId()); } } @@ -411,7 +309,8 @@ docInfoMapper.insert(docInfo); logger.debug("文档已保存: {}", docInfo.getDocId()); } else { logger.debug("文档已存在: {}", docInfo.getDocId()); docInfoMapper.updateById(docInfo); logger.debug("文档已更新: {}", docInfo.getDocId()); } } @@ -420,7 +319,8 @@ docFileMapper.insert(docFile); logger.debug("文档文件已保存: {}", docFile.getFileId()); } else { logger.debug("文档文件已存在: {}", docFile.getFileId()); docFileMapper.updateById(docFile); logger.debug("文档文件已更新: {}", docFile.getFileId()); } } @@ -429,7 +329,8 @@ docRelativeMapper.insert(docRelative); logger.debug("文档对应关系已保存: {}", docRelative.getId()); } else { logger.debug("文档对应关系已存在: {}", docRelative.getId()); docRelativeMapper.updateById(docRelative); logger.debug("文档对应关系已更新: {}", docRelative.getId()); } } @@ -440,6 +341,7 @@ logger.debug("刀具已保存: {}", cutter.getId()); } else { cutterMapper.updateById(cutter); logger.debug("刀具已更新: {}", cutter.getId()); } } } @@ -447,9 +349,10 @@ private void saveGuideCardBatch(GuideCardBatch guideCardBatch) { if (guideCardBatchMapper.selectById(guideCardBatch.getId()) == null) { guideCardBatchMapper.insert(guideCardBatch); logger.debug("刀片批次已保存: {}", guideCardBatch.getId()); logger.debug("程序加工确认表已保存: {}", guideCardBatch.getId()); } else { logger.debug("刀片批次已存在: {}", guideCardBatch.getId()); guideCardBatchMapper.updateById(guideCardBatch); logger.debug("程序加工确认表已更新: {}", guideCardBatch.getId()); } } } lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FileFerryService.java
@@ -1,19 +1,13 @@ package org.jeecg.modules.dnc.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.apache.commons.lang3.StringUtils; import org.jeecg.modules.dnc.dto.ComponentHierarchy; import org.jeecg.modules.dnc.dto.TransferPackage; import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.exception.ExceptionCast; import org.jeecg.modules.dnc.response.ActivitiCode; import org.jeecg.modules.dnc.response.DocumentCode; import org.jeecg.modules.dnc.entity.ComponentInfo; import org.jeecg.modules.dnc.entity.DocFile; import org.jeecg.modules.dnc.service.IDocClassificationService; import org.jeecg.modules.dnc.service.IDocInfoService; import org.jeecg.modules.dnc.service.IDocRelativeService; import org.jeecg.modules.dnc.utils.JsonUtils; import org.jeecg.modules.dnc.utils.file.FileUtilS; import org.jeecg.modules.mdc.entity.MdcEquipment; import org.jeecg.modules.mdc.mapper.MdcEquipmentMapper; import org.jeecg.modules.system.service.IMdcProductionService; import org.slf4j.Logger; @@ -146,7 +140,6 @@ // 6. 获取文件复制目标路径 DocFile docFile = pkg.getTraceChain().getDocFile(); DocInfo docInfo = pkg.getTraceChain().getDocInfo(); if (docFile == null) { throw new IllegalStateException("传输包中缺少文档文件信息"); } @@ -165,41 +158,6 @@ logger.info("复制文件: {} → {}", ncFilePath, targetPath); Path source = Paths.get(ncFilePath); Files.copy(source, Paths.get(targetPath), StandardCopyOption.REPLACE_EXISTING); // 8. 查询设备id MdcEquipment mdcEquipment=mdcEquipmentMapper.selectOne(new QueryWrapper<MdcEquipment>().eq("equipment_id",equipmentId)); if (mdcEquipment == null) { throw new IllegalArgumentException("无效的设备ID: " + equipmentId); } // 9.传输文件到设备下 List<String> strings = mdcProductionService.findListParentTreeAll(mdcEquipment.getId()); if (strings != null && !strings.isEmpty()) { DocInfo deviceDoc = docInfoService.getByDocAttrAndDocId(docInfo.getDocId(), 7, mdcEquipment.getId()); if (deviceDoc == null) { DocClassification classification = classificationService.getByCode("send"); if(classification == null) ExceptionCast.cast(DocumentCode.DOC_CLASS_ERROR); DocRelative docRelative = new DocRelative(); docRelative.setDocId(docInfo.getDocId()); docRelative.setClassificationId(classification.getClassificationId()); docRelative.setAttributionType(7); docRelative.setAttributionId(mdcEquipment.getId()); docRelativeService.save(docRelative); } String sendPath = StringUtils.join(strings.toArray(), "/"); boolean copyFileNc = FileUtilS.copyFileNc(docFile.getFilePath(), sendPath + "/" + mdcEquipment.getEquipmentId(), docFile.getFileEncodeName(), docFile.getFileName(), docFile.getFileSuffix()); if (!copyFileNc) { ExceptionCast.cast(ActivitiCode.ACT_FILE_ERROR); } else { FileUtilS.deleteZipFromToSend(sendPath + "/" + mdcEquipment.getEquipmentId(), docFile.getFileName(), docFile.getFileSuffix()); } } else { throw new RuntimeException("文件传输路径获取失败"); } // 10.删除临时NC文件与json文件 logger.info("删除临时文件: {}", ncFilePath); lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/FullHierarchyTraceService.java
@@ -6,6 +6,7 @@ import org.jeecg.modules.dnc.entity.*; import org.jeecg.modules.dnc.mapper.*; import org.jeecg.modules.dnc.service.IPermissionStreamNewService; import org.jeecg.modules.system.entity.MdcProduction; import org.jeecg.modules.system.service.IMdcProductionService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; @@ -225,7 +226,10 @@ .eq("delete_flag",0)); path.forEach(item->{ if (item.getDepartId()!=null){ item.setDepartId(mdcProductionService.getById(item.getDepartId()).getOrgCode()); MdcProduction mdcProduction=mdcProductionService.getById(item.getDepartId()); if(mdcProduction!=null){ item.setDepartId(item.getDepartId()); } } if (item.getUserId()!=null){ item.setUserId(sysUserService.getById(item.getUserId()).getUsername()); lxzn-module-dnc/src/main/java/org/jeecg/modules/dnc/service/impl/GuideCardBatchServiceImpl.java
@@ -33,9 +33,6 @@ private IDocInfoService docInfoService; @Autowired private IDocRelativeService docRelativeService; @Autowired private IPartsInfoService partsInfoService; @Autowired @@ -138,6 +135,7 @@ guideCardBatch.setPartsName(partsInfo.getPartsName()); guideCardBatch.setMaterielDesp(partsInfo.getMaterielDesp()); } guideCardBatch.setFlowStatus("0"); guideCardBatch.setCompiler(user.getUsername()); guideCardBatch.setCreateTime(new Date()); return this.save(guideCardBatch); lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/IAssignFileStreamService.java
@@ -18,7 +18,7 @@ * @param stream * @return */ Result applyAssignFile(AssignFileStream stream); Result<?> applyAssignFile(AssignFileStream stream); /**securedoc * 启动流程 保存相应的数据 绑定businessKey lxzn-module-dnc/src/main/java/org/jeecg/modules/dncFlow/service/impl/AssignFileStreamServiceImpl.java
@@ -98,9 +98,11 @@ private String secretFolder; //涉密网传输nc文件夹 @Autowired private FileFerryService ferryService; @Autowired private IDocClassificationService iDocClassificationService; @Override @Transactional(rollbackFor = {Exception.class}) public Result applyAssignFile(AssignFileStream stream) { public Result<?> applyAssignFile(AssignFileStream stream) { synchronized (this){ //判断设备特殊字符 String specialChar = getDeviceSpecialChar(stream.getDeviceId(),stream.getFileId()); @@ -108,6 +110,12 @@ //抛出特殊字符异常 return Result.error("文件名称存在设备特殊字符"); } //查询文档的状态,批准状态才可以指派 DocInfo docInfo=getDocInfo(stream); DocClassification docClassification=iDocClassificationService.getById(docInfo.getClassificationId()); if (docInfo.getDocDispatchStatus()!=null&&docInfo.getDocDispatchStatus()!=3&&docClassification.getClassificationCode().equals("nc")){ return Result.error("该文件状态不允许指派,请先完成审签流程"); } if(flowableEnable) { return applyAssignFileActive(stream); }else {