yangys
2025-09-22 12313d5b8a2b6eaa2c7562291cf08f23644ef1d7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
package org.springblade.mdm.program.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.mdm.program.service.DNCSendBackService;
import org.springblade.mdm.program.service.DncBackFileService;
import org.springblade.mdm.program.vo.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import java.util.List;
 
/**
 * 流程管理接口
 *
 * @author Chill
 */
@NonDS
@RestController
@RequestMapping("/program/dncsendback/")
@AllArgsConstructor
@Tag(name = "DNC导入", description = "DNC导入接口")
@Slf4j
public class DncSendBackController {
 
    private final DNCSendBackService dncSendBackService;
    private final DncBackFileService dncBackFileService;
    /**
     * 上传DNC回传文件
     *
     * @param file    dnc程序打包文件
     */
    @PostMapping("upload")
    @ApiOperationSupport(order = 1)
    @Operation(summary = "DNC回传文件导入,上传文件", description = "上传DNC回传文件,并返回解析结果")
    public R<List<DncSendBackData>> dncSendBackUpload(@RequestParam MultipartFile file) {
        try {
            return R.data(dncSendBackService.dncSendBackUpload(file));
        }catch (Exception e){
            log.error("导入错误",e);
            return R.fail(e.getMessage());
        }
    }
    @GetMapping("/back-file-content")
    @Operation(summary = "获取回传文件内容", description = "查看工控网回传文件内容")
    public R<String> fileContent(@Parameter(description = "文件的entryName") String entryName) {
        try {
            return R.data(dncSendBackService.getEntryFileContent(entryName));
        }catch(Exception e) {
            log.error("删除文件失败",e);
            return R.fail(e.getMessage());
        }
    }
    @PostMapping("accept")
    @ApiOperationSupport(order = 2)
    @Operation(summary = "DNC回传数据入库", description = "入库,同时启动固化流程,入参为上传是解析的数据列表")
    public R<Void> dncSendBackAccept(@RequestParam String ids) {
        try {
            dncSendBackService.dncFileAccept(ids);
        }catch (Exception e){
            log.error("入库错误",e);
            return R.fail(e.getMessage());
        }
        return R.success();
    }
 
    @Operation(summary = "工控网回传记录分页查询", description = "工控网回传记录分页查询,查询回传历史")
    @GetMapping("/dnc-back-page")
    public R<IPage<DncBackFileVO>> page(DncBackFileQueryVO query) {
        return R.data(dncBackFileService.pageQuery(query));
    }
 
    @Operation(summary = "回传取消", description = "工控网回传记录中取消未开始执行的流程")
    @PostMapping("/cancel-process")
    public R<Void> cancelProcess(@Parameter(description = "回传记录id")long id) {
        try{
            dncBackFileService.cancelProcess(id);
            return R.success();
        }catch (Exception e){
            log.error("流程取消失败",e);
            return R.fail(e.getMessage());
        }
 
    }
 
    @Operation(summary = "获取回传记录的文件列表", description = "获取回传记录的文件列表")
    @GetMapping("/files-by-id")
    public R<List<DncSendBackFile>> filesById(long id) {
        try {
            return R.data(dncBackFileService.filesById(id));
        }catch (Exception e){
            log.error("获取历史文件列表失败",e);
            return R.fail(e.getMessage());
        }
    }
 
    @GetMapping("/history-file-content")
    @Operation(summary = "临时记录回传文件内容", description = "临时记录回传文件内容")
    public R<String> historyContent(@Parameter(description = "历史记录id")long id,@Parameter(description = "文件的entryName") String entryName) {
        try {
 
            return R.data(dncBackFileService.getEntryFileContent(id,entryName));
        }catch(Exception e) {
            log.error("获取历史文件内容失败",e);
            return R.fail(e.getMessage());
        }
    }
}