whycxzp
12 小时以前 5fd800ce3a0bf46ef9ad3ca865b9cad5c8751a18
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
package com.whyc.controller;
 
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.pojo.web_site.DeviceSpare;
import com.whyc.service.DeviceSpareService;
import com.whyc.util.JsonUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
 
@RestController
@RequestMapping("deviceSpare")
@Api(tags = {"设备器件备件","维修管理","维修调度"})
public class DeviceSpareController {
 
    @Autowired
    private DeviceSpareService service;
 
    @GetMapping("getPage")
    @ApiOperation("分页查询")
    public Response<PageInfo<DeviceSpare>> getPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
                                                   @RequestParam(required = false) String type,@RequestParam(required = false) String name ) {
        return service.getPage(pageNum, pageSize,type,name);
    }
 
    @GetMapping("getList")
    @ApiOperation(tags = "告警诊断",  value = "获取所有所需工具")
    public Response<List<DeviceSpare>> getList(@RequestParam(required = false) String name) {
        return service.getList(name);
    }
 
    @PostMapping("add")
    @ApiOperation("添加")
    public Response add(@RequestPart(value = "file",required = false) List<MultipartFile> file,@RequestParam String  deviceSpareJsonStr) throws IOException {
        DeviceSpare spare = JsonUtil.getGson().fromJson(deviceSpareJsonStr, DeviceSpare.class);
        return service.add(spare,file);
    }
 
    @PostMapping("addByExcel")
    @ApiOperation("excel导入")
    public Response addByExcel(@RequestParam MultipartFile file) throws IOException {
        return service.addByExcel(file);
    }
 
    @ApiOperation("excel导出")
    @GetMapping("excelExport")
    public void excelExport(HttpServletResponse response) {
        service.excelExport(response);
    }
 
 
    @PostMapping("update")
    @ApiOperation("修改")
    public Response update(@RequestBody DeviceSpare spare) {
        return service.update(spare);
    }
 
    @PostMapping("andOrChangePicture")
    @ApiOperation("新增或者替换图片")
    public Response andOrChangePicture(@RequestParam Integer id,@RequestParam MultipartFile file) throws IOException {
        return service.andOrChangePicture(id,file);
    }
 
    @PostMapping("delete")
    @ApiOperation("删除")
    public Response delete(@RequestParam Integer id) {
        return service.delete(id);
    }
 
    @GetMapping("getListByIds")
    @ApiOperation("查询器件的库存信息,根据告警巡检所需的器件ids")
    public Response<List<DeviceSpare>> getListByIds(@RequestParam String deviceSpareIds){
        return service.getListByIds(deviceSpareIds);
    }
 
}