liusheng
2024-11-07 37b79cfd8e5ecdc6f9f09750583f998183c338fb
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
package com.ruoyi.web.controller.smartor;
 
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.smartor.domain.PatArchiveImport;
import com.smartor.service.IPatArchiveImportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * Excel导入患者档案Controller
 *
 * @author lihu
 * @date 2024-09-05
 */
@Api("Excel导入患者档案")
@RestController
@RequestMapping("/smartor/import")
public class PatArchiveImportController extends BaseController {
    @Autowired
    private IPatArchiveImportService patArchiveImportService;
 
    /**
     * 查询Excel导入患者档案列表
     */
    @ApiOperation("查询Excel导入患者档案列表")
    //@PreAuthorize("@ss.hasPermi('smartor:import:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatArchiveImport patArchiveImport) {
        startPage();
        List<PatArchiveImport> list = patArchiveImportService.selectPatArchiveImportList(patArchiveImport);
        return getDataTable(list);
    }
 
    /**
     * 获取Excel导入患者档案详细信息
     */
    @ApiOperation("获取Excel导入患者档案详细信息")
    //@PreAuthorize("@ss.hasPermi('smartor:import:query')")
    @GetMapping(value = "/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(patArchiveImportService.selectPatArchiveImportById(id));
    }
 
    /**
     * 新增Excel导入患者档案
     */
    //@PreAuthorize("@ss.hasPermi('smartor:import:add')")
    @Log(title = "Excel导入患者档案", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PatArchiveImport patArchiveImport) {
        return toAjax(patArchiveImportService.insertPatArchiveImport(patArchiveImport));
    }
 
    /**
     * 修改Excel导入患者档案
     */
    @ApiOperation("修改Excel导入患者档案")
    //@PreAuthorize("@ss.hasPermi('smartor:import:edit')")
    @Log(title = "Excel导入患者档案", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody PatArchiveImport patArchiveImport) {
        return toAjax(patArchiveImportService.updatePatArchiveImport(patArchiveImport));
    }
 
    /**
     * 删除Excel导入患者档案
     */
    @ApiOperation("删除Excel导入患者档案")
    //@PreAuthorize("@ss.hasPermi('smartor:import:remove')")
    @Log(title = "Excel导入患者档案", businessType = BusinessType.DELETE)
    @GetMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patArchiveImportService.deletePatArchiveImportByIds(ids));
    }
 
    /**
     * 获取导入患者模板
     *
     * @param response
     */
    @ApiOperation("获取导入患者模板")
    @PostMapping("/getImportPatTemplate")
    public void getImportPatTemplate(HttpServletResponse response) {
        ExcelUtil<PatArchiveImport> util = new ExcelUtil<PatArchiveImport>(PatArchiveImport.class);
        util.importTemplateExcel(response, "导入患者");
    }
 
    @GetMapping("/download")
    public void fileDownload(HttpServletResponse response) {
        try {
            String filePath = "D:\\import\\患者信息.xlsx";
            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
            FileUtils.setAttachmentResponseHeader(response, "患者信息.xlsx");
            FileUtils.writeBytes(filePath, response.getOutputStream());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
 
    @ApiOperation("导入Excel患者信息")
    //@PreAuthorize("@ss.hasPermi('smartor:import:list')")
    @PostMapping("/importPatInfo")
    public TableDataInfo importPatInfo(MultipartFile file) {
        return getDataTable(patArchiveImportService.importPatInfo(file));
    }
}