lyh
2025-06-25 e756af0f5bfd1addbd5d5c145441fb34aad91a28
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
package org.jeecg.modules.dnc.controller;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.dnc.entity.DocFile;
import org.jeecg.modules.dnc.entity.DocInfo;
import org.jeecg.modules.dnc.request.DocInfoQueryRequest;
import org.jeecg.modules.dnc.request.DocInfoUploadRequest;
import org.jeecg.modules.dnc.response.CommonCode;
import org.jeecg.modules.dnc.response.QueryListResponseResult;
import org.jeecg.modules.dnc.response.ResponseResult;
import org.jeecg.modules.dnc.service.IDocInfoService;
import org.jeecg.modules.dnc.utils.ValidateUtil;
import org.jeecg.modules.dnc.utils.file.FileUtilS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@Slf4j
@Api(tags = "文档表")
@RestController
@RequestMapping("/nc/doc")
public class DocInfoController extends JeecgController<DocInfo, IDocInfoService> {
    @Autowired
    private IDocInfoService docInfoService;
 
    @AutoLog(value = "文档表-导入文档进口")
    @ApiOperation(value = "文档表-导入文档进口", notes = "文档表-导入文档进口")
    @PostMapping("/add")
    public ResponseResult addDocInfo(@RequestParam("file") MultipartFile file, DocInfoUploadRequest docInfo) {
        boolean b = docInfoService.addDocInfo(file, docInfo);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
 
    @AutoLog(value = "文档表-编辑文档基本信息")
    @ApiOperation(value = "文档表-编辑文档基本信息", notes = "文档表-编辑文档基本信息")
    @PutMapping("/edit/{id}")
    public ResponseResult editDocInfo(@PathVariable("id") String id, @RequestBody DocInfo docInfo) {
        boolean b = docInfoService.editDocInfo(id, docInfo);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-删除文档信息")
    @ApiOperation(value = "文档表-删除文档信息", notes = "文档表-删除文档信息")
    @DeleteMapping("/delete/{id}/{attrType}/{attrId}")
    public ResponseResult deleteDocInfo(@PathVariable("id") String id, @PathVariable("attrType") String attrType, @PathVariable("attrId") String attrId) {
        boolean b = docInfoService.deleteDocInfo(id,attrType,attrId);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-入库操作 文档对应文件升版")
    @ApiOperation(value = "文档表-入库操作 文档对应文件升版", notes = "文档表-入库操作 文档对应文件升版")
    @PostMapping("/push/{id}")
    public ResponseResult pushDocFile(@PathVariable("id") String id, @RequestParam("file") MultipartFile file) {
        boolean b = docInfoService.pushDocFile(id, file);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-出库")
    @ApiOperation(value = "文档表-出库", notes = "文档表-出库")
    @GetMapping("/pull/{id}")
    public ResponseResult pullDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) {
        return docInfoService.pullDocFile(request, response, id);
    }
 
    @AutoLog(value = "文档表-取消出库")
    @ApiOperation(value = "文档表-取消出库", notes = "文档表-取消出库")
    @PutMapping("/cancel/pull/{id}")
    public ResponseResult cancelPullDocInfo(@PathVariable("id") String id) {
        boolean b = docInfoService.cancelPullDocInfo(id);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-文档发布")
    @ApiOperation(value = "文档表-文档发布", notes = "文档表-文档发布")
    @PutMapping("/publish/{id}")
    public ResponseResult publishDocInfo(@PathVariable("id") String id) {
        boolean b = docInfoService.publishDocInfo(id);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-文档重发布")
    @ApiOperation(value = "文档表-文档重发布", notes = "文档表-文档重发布")
    @PutMapping("/republish/{id}")
    public ResponseResult republishDocInfo(@PathVariable("id") String id) {
        boolean b = docInfoService.republishDocInfo(id);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-文档归档")
    @ApiOperation(value = "文档表-文档归档", notes = "文档表-文档归档")
    @PutMapping("/pigeonhole/{id}")
    public ResponseResult pigeonholeDocInfo(@PathVariable("id") String id) {
        boolean b = docInfoService.pigeonholeDocInfo(id);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文档表-分页查询接口")
    @ApiOperation(value = "文档表-分页查询接口", notes = "文档表-分页查询接口")
    @GetMapping("/find/page/{page}/{size}")
    public Result<?> findPageList(@PathVariable("page") int page, @PathVariable("size") int size, DocInfoQueryRequest docQuery) {
        return docInfoService.findPageList(page, size, docQuery);
    }
 
    @AutoLog(value = "文档表-查询设备发送目录的文档状态")
    @ApiOperation(value = "文档表-查询设备发送目录的文档状态", notes = "文档表-查询设备发送目录的文档状态")
    @GetMapping("/find/page/device/{page}/{size}")
    public Result<?> findPageListByDevice(@PathVariable("page") int page, @PathVariable("size") int size, DocInfoQueryRequest docQuery) {
        return Result.ok(docInfoService.findPageListByDevice(page, size, docQuery));
    }
 
    @AutoLog(value = "文档表-文档文件预览")
    @ApiOperation(value = "文档表-文档文件预览", notes = "文档表-文档文件预览")
    @GetMapping("/preview/{id}")
    public QueryListResponseResult previewDocFile(@PathVariable("id") String id) {
        DocFile docFile = docInfoService.previewDocFile(id);
        if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName())
//                || !ValidateUtil.validateString(docFile.getFileSuffix())
                || !ValidateUtil.validateString(docFile.getFileEncodeName()))
            return new QueryListResponseResult(CommonCode.FAIL, null);
        String filePath = docFile.getFilePath();
        String fileEncodeName = docFile.getFileEncodeName();
        List<String> list = FileUtilS.readFile(fileEncodeName, filePath);
        if(list == null || list.isEmpty())
            return new QueryListResponseResult(CommonCode.FAIL, null);
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
    }
 
    @AutoLog(value = "文档表-文档文件预览pdf")
    @ApiOperation(value = "文档表-文档文件预览pdf", notes = "文档表-文档文件预览pdf")
    @GetMapping("/preview/pdf/{id}")
    public ResponseResult previewPdfDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) {
        DocFile docFile = docInfoService.previewDocFile(id);
        if(!ValidateUtil.validateString(docFile.getFilePath()) || !ValidateUtil.validateString(docFile.getFileName()) ||
                /*!ValidateUtil.validateString(docFile.getFileSuffix()) ||*/ !ValidateUtil.validateString(docFile.getFileEncodeName()))
            return new ResponseResult(CommonCode.FAIL);
        String fileName;
        if(ValidateUtil.validateString(docFile.getFileSuffix())) {
            fileName = docFile.getFileName() + "." + docFile.getFileSuffix();
        }else {
            fileName = docFile.getFileName();
        }
        String filePath = docFile.getFilePath();
        String fileEncodeName = docFile.getFileEncodeName();
        FileUtilS.downLoadFile(response, fileEncodeName, filePath, fileName);
        return null;
    }
 
    @AutoLog(value = "文件表-查询可指派的文档信息列表")
    @ApiOperation(value = "文件表-查询可指派的文档信息列表", notes = "文件表-查询可指派的文档信息列表")
    @GetMapping("/find/list")
    public Result<?> findList(DocInfoQueryRequest docQuery) {
        List<DocInfo> docInfoList=docInfoService.findList(docQuery);
        return Result.ok(docInfoList);
    }
 
    @AutoLog(value = "文件表-批量删除文档接口")
    @ApiOperation(value = "文件表-批量删除文档接口", notes = "文件表-批量删除文档接口")
    @PostMapping("/batch/remove/{docIds}/{attrType}/{attrId}")
    public ResponseResult batchRemoveDocInfo(@PathVariable("docIds") String[] docIds, @PathVariable("attrType") String attrType, @PathVariable("attrId") String attrId) {
        boolean b = docInfoService.batchRemoveDocInfo(docIds,attrType,attrId);
        if(!b)
            return new ResponseResult(CommonCode.FAIL);
        return new ResponseResult(CommonCode.SUCCESS);
    }
 
    @AutoLog(value = "文件表-文档下载")
    @ApiOperation(value = "文件表-文档下载", notes = "文件表-文档下载")
    @GetMapping("/download/{id}")
    public ResponseResult downloadDocFile(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") String id) {
        return docInfoService.downloadDocFile(request, response, id);
    }
}