blade-service/blade-mdm/src/main/java/org/springblade/mdm/machineback/controller/MachineBackFileHandleController.java
@@ -63,10 +63,10 @@ List<MachineBackFileHandleExcelVO> list = new ArrayList<>(); pages.getRecords().forEach(vo ->{ MachineBackFileHandleExcelVO excelVO = new MachineBackFileHandleExcelVO(); excelVO.setCuredStatus(vo.getIsCured()==0?"固化":"未固化"); BeanUtil.copy(vo, excelVO); excelVO.setCuredStatus(vo.getIsCured()==0?"固化":"未固化"); }); ExcelUtil.export(response, "机床回传文件处理" + DateUtil.time(), "机床回传文件表", list, MachineBackFileHandleExcelVO.class); ExcelUtil.export(response, "机床回传程序" + DateUtil.time(), "机床回传程序表", list, MachineBackFileHandleExcelVO.class); } } blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/controller/DncSendBackController.java
@@ -48,15 +48,12 @@ /** * 上传DNC回传文件 * * @param files 流程文件 * @param category 类型 * @param file dnc程序打包文件 */ @PostMapping("dnc-sendback-upload") @ApiOperationSupport(order = 1) @Operation(summary = "上传DNC回传文件", description = "传入文件") public R<List<DncSendBackData>> dncSendBackUpload(@RequestParam MultipartFile file, @RequestParam String category, @RequestParam(required = false, defaultValue = "") String tenantIds) { public R<List<DncSendBackData>> dncSendBackUpload(@RequestParam MultipartFile file) { return R.data(dncSendBackService.dncSendBackUpload(file)); } blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/controller/NcProgramExchangeController.java
@@ -36,13 +36,12 @@ //return R.<Boolean>status(true); } /* @PostMapping("/import-dnc-file") @Operation(summary = "上传工控网回传文件", description = "上传程序/附件文件") public R<Boolean> importDncFile(@RequestParam MultipartFile file,Long nodeId, @RequestParam String category) { ncProgramService.uploadNcFile(file,nodeId,category); public R<Boolean> importDncFile(@RequestParam MultipartFile file) { ncProgramService.uploadNcPkgFile(file); return R.<Boolean>status(true); } }*/ } blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/DncSendBackService.java
@@ -28,15 +28,23 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.compress.utils.IOUtils; import org.apache.commons.compress.utils.SeekableInMemoryByteChannel; import org.flowable.engine.*; import org.springblade.core.tool.utils.FileUtil; import org.springblade.mdm.program.vo.DncSendBackData; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; /** @@ -49,23 +57,24 @@ @AllArgsConstructor public class DncSendBackService { private static final String XML_NAME = "xml"; private static final Integer INT_1024 = 1024; private final ObjectMapper objectMapper; private final RepositoryService repositoryService; private final RuntimeService runtimeService; private final HistoryService historyService; private final TaskService taskService; private final ProcessEngine processEngine; /** * dnc回传文件上传 * @param file * @return */ public List<DncSendBackData> dncSendBackUpload(MultipartFile file) { List<DncSendBackData> list = new ArrayList<>(); List<DncSendBackData> list=new ArrayList<>(); try { String fileName = file.getOriginalFilename(); InputStream fileInputStream = file.getInputStream(); byte[] bytes = FileUtil.copyToByteArray(fileInputStream); list = parseDncZipFromByteArray(bytes); //TODO 解析为列表文件 DncSendBackData dt = new DncSendBackData(); @@ -77,12 +86,52 @@ } catch (IOException e) { log.error("上传dnc文件失败",e); } return list; } public static List<DncSendBackData> parseDncZipFromByteArray(byte[] zipData) throws IOException { //List<DncSendBackData> datas = new ArrayList<>(); List<DncSendBackData> datas = ZipFileDirectoryScanner.getFilesInDirectoryRecursive(zipData, ""); /* try (ByteArrayInputStream bis = new ByteArrayInputStream(zipData); ZipArchiveInputStream zis = new ZipArchiveInputStream(bis)) { ZipArchiveEntry entry; while ((entry = zis.getNextZipEntry()) != null) { DncSendBackData prog = new DncSendBackData(); prog.setProgramName(entry.getName()); if (!entry.isDirectory()) { System.out.println("文件名: " + entry.getName()); System.out.println("大小: " + entry.getSize()); // 读取文件内容到字节数组 ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); IOUtils.copy(zis, outputStream); byte[] fileContent = outputStream.toByteArray(); // 处理文件内容... System.out.println("内容长度: " + fileContent.length); }else{ //文件夹,读内部文件,获取文件列表 System.out.println("文件夹程序:"+entry.getName()); List<String> children = new ArrayList<>(); prog.setChildren(children); } datas.add(prog); } }*/ return datas; } /** * 入库回传文件 * @param ids @@ -92,3 +141,35 @@ } } class ZipFileDirectoryScanner { public static List<DncSendBackData> getFilesInDirectoryRecursive(byte[] zipData, String dirPath) throws IOException { List<DncSendBackData> list = new ArrayList<>(); if (!dirPath.endsWith("/")) { dirPath += "/"; } try (SeekableInMemoryByteChannel channel = new SeekableInMemoryByteChannel(zipData); ZipFile zipFile = new ZipFile(channel)) { Enumeration<ZipArchiveEntry> entries = zipFile.getEntries(); while (entries.hasMoreElements()) { ZipArchiveEntry entry = entries.nextElement(); String entryName = entry.getName(); DncSendBackData d = new DncSendBackData(); d.setProgramName(entryName); if(entry.isDirectory()){ d.setHasChildren(true); } list.add(d); //if (entryName.startsWith(dirPath) && !entry.isDirectory()) { // fileList.add(entryName); //} } } return list; } } blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/service/NcProgramService.java
@@ -71,7 +71,12 @@ return this.getBaseMapper().getCuredNcProgram(partNo,machine.getMachineGroupCode()); } public void uploadNcFile(MultipartFile file,Long nodeId, String category) { /** * 上传程序文件到指定节点 * @param file * @param nodeId * @param category */ public void uploadNcFile(MultipartFile file, Long nodeId, String category) { } } blade-service/blade-mdm/src/main/java/org/springblade/mdm/program/vo/DncSendBackData.java
@@ -5,6 +5,7 @@ import lombok.Setter; import java.time.LocalDateTime; import java.util.List; @Setter @Getter @@ -22,4 +23,7 @@ @Schema(description = "MD5值") private String md5; @Schema(description = "子文件(用于可识别文件加的机器返回的程序)") private List<String> children; private boolean hasChildren; } blade-service/blade-mdm/src/main/resources/processesbpmn/program-cure.bpmn20.xml
@@ -2,12 +2,12 @@ <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef"> <process id="program-cure" name="固化流程" isExecutable="true"> <startEvent id="sid-abe970b9-1bee-49a1-91b4-1184c47c10b7"/> <userTask id="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6"/> <sequenceFlow id="sid-910649a5-8dac-48a2-b42d-9f1132d61b26" sourceRef="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6" targetRef="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6"/> <sequenceFlow id="sid-09c7cf44-bb1a-40f4-b231-919afae5c02f" sourceRef="sid-abe970b9-1bee-49a1-91b4-1184c47c10b7" targetRef="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6"/> <userTask id="cureProgramTask" name="固化编制"/> <sequenceFlow id="sid-910649a5-8dac-48a2-b42d-9f1132d61b26" sourceRef="cureProgramTask" targetRef="cureProgramTask"/> <sequenceFlow id="sid-09c7cf44-bb1a-40f4-b231-919afae5c02f" sourceRef="sid-abe970b9-1bee-49a1-91b4-1184c47c10b7" targetRef="cureProgramTask"/> <endEvent id="end" name="固化结束"/> <userTask id="seniorApproveTask" name="高师审核"/> <sequenceFlow id="sid-8dd21f02-ac10-4318-b897-19b4cdc558c7" sourceRef="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6" targetRef="seniorApproveTask"/> <sequenceFlow id="sid-8dd21f02-ac10-4318-b897-19b4cdc558c7" sourceRef="cureProgramTask" targetRef="seniorApproveTask"/> <sequenceFlow id="sid-504610fe-2b87-4df4-8f42-f10c8bf3ce01" sourceRef="seniorApproveTask" targetRef="end"/> </process> <bpmndi:BPMNDiagram id="BPMNDiagram_program-cure"> @@ -15,7 +15,7 @@ <bpmndi:BPMNShape id="shape-7fe43876-cd89-402e-aada-b7fe7d89e64a" bpmnElement="sid-abe970b9-1bee-49a1-91b4-1184c47c10b7"> <omgdc:Bounds x="-215.0" y="-85.0" width="30.0" height="30.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNShape id="shape-702fceb1-2073-4a25-a94d-86c2392dfc6f" bpmnElement="sid-e9be5408-2827-4ee7-bee5-fda38a8f23e6"> <bpmndi:BPMNShape id="shape-702fceb1-2073-4a25-a94d-86c2392dfc6f" bpmnElement="cureProgramTask"> <omgdc:Bounds x="-110.0" y="-95.0" width="75.0" height="55.0"/> </bpmndi:BPMNShape> <bpmndi:BPMNEdge id="edge-fbb946ca-a477-4237-b78f-72cf4e0b8479" bpmnElement="sid-910649a5-8dac-48a2-b42d-9f1132d61b26">