| | |
| | | import org.springblade.mdm.flow.service.FlowBusinessService; |
| | | import org.springblade.mdm.program.entity.DncBackFile; |
| | | import org.springblade.mdm.program.entity.NcNode; |
| | | import org.springblade.mdm.program.entity.NcNodeHis; |
| | | import org.springblade.mdm.program.mapper.DncBackFileMapper; |
| | | import org.springblade.mdm.program.vo.DncBackFileQueryVO; |
| | | import org.springblade.mdm.program.vo.DncBackFileVO; |
| | |
| | | @AllArgsConstructor |
| | | public class DncBackFileService extends BizServiceImpl<DncBackFileMapper, DncBackFile> { |
| | | private final NcNodeService ncNodeService; |
| | | private final NcNodeHisService nodeHisService; |
| | | private final OssTemplate ossTemplate; |
| | | private final HistoryService historyService; |
| | | private final FlowBusinessService businessService; |
| | |
| | | * 检查流程实例是否被执行过(通过历史记录) |
| | | */ |
| | | public boolean isProcessExecuted(String processInstanceId) { |
| | | // 检查是否有历史活动记录 |
| | | /* |
| | | long activityCount = historyService.createHistoricActivityInstanceQuery() |
| | | .processInstanceId(processInstanceId) |
| | | .count(); |
| | | */ |
| | | if(StringUtils.isBlank(processInstanceId)){ |
| | | //空流程实例id,说明节点已经没有了 |
| | | return true; |
| | | } |
| | | // 检查是否有历史任务记录 |
| | | long taskCount = historyService.createHistoricTaskInstanceQuery() |
| | | .processInstanceId(processInstanceId) |
| | |
| | | |
| | | InputStream inputStream = this.ossTemplate.statFileStream(backFIle.getOssName()); |
| | | Path tempZipFile = createTempFile(inputStream); |
| | | List<String> entryNameList = new ArrayList<>(); |
| | | NcNode packageNode = this.ncNodeService.getById(backFIle.getNcNodeId()); |
| | | String targetFolder = packageNode.getName()+"-"+packageNode.getProcessEdition()+"/"; |
| | | NcNodeHis packageNode = nodeHisService.getById(backFIle.getNcNodeId()); |
| | | //String targetFolder = packageNode.getName()+"-"+packageNode.getProcessEdition()+"/"; |
| | | String targetFolder = packageNode.getName()+"/"; |
| | | ZipEntry entry; |
| | | try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) { |
| | | Enumeration<? extends ZipEntry> entries = zipFile.entries(); |
| | |
| | | DncBackFile backFIle = this.getById(id); |
| | | |
| | | return ZipTextFileContentUtil.getTextContent(this.ossTemplate.statFileStream(backFIle.getOssName()),entryName); |
| | | /* |
| | | try(InputStream inputStream = this.ossTemplate.statFileStream(backFIle.getOssName());){ |
| | | Path tempZipFile = createTempFile(inputStream); |
| | | |
| | | ZipEntry entry; |
| | | try (java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(tempZipFile.toFile())) { |
| | | Enumeration<? extends ZipEntry> entries = zipFile.entries(); |
| | | while (entries.hasMoreElements()) { |
| | | entry = entries.nextElement(); |
| | | if (!entryName.equals(entry.getName())) { |
| | | continue; |
| | | } |
| | | try (InputStream fileIns = zipFile.getInputStream(zipFile.getEntry(entryName))) { |
| | | ByteArrayInputStream bos = new ByteArrayInputStream(fileIns.readAllBytes()); |
| | | boolean isText = StringUtils.endsWithIgnoreCase(entryName,".txt") || StringUtils.endsWithIgnoreCase(entryName,".nc")|| StringUtils.endsWithIgnoreCase(entryName,".xml"); |
| | | if(!isText) { |
| | | isText = FileContentUtil.isTextFile(bos); |
| | | } |
| | | if (isText) { |
| | | bos.reset(); |
| | | result = FileContentUtil.getContentFromStream(bos); |
| | | } else { |
| | | result = "<非文本文件>"; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | |
| | | } |
| | | } |