shiyunteng
7 天以前 0ad13cb4bf387d4f2db2d62540ebb73a376087f5
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
package com.by4cloud.platformx.device.controller;
 
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.by4cloud.platformx.common.core.util.R;
import com.by4cloud.platformx.common.log.annotation.SysLog;
import com.by4cloud.platformx.device.dto.DeviceRepairQueryDTO;
import com.by4cloud.platformx.device.entity.DeviceScrap;
import com.by4cloud.platformx.device.service.DeviceScrapService;
import org.springframework.security.access.prepost.PreAuthorize;
import com.by4cloud.platformx.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.http.HttpHeaders;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 设备报废
 *
 * @author syt
 * @date 2025-03-31 13:49:43
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/deviceScrap" )
@Tag(description = "deviceScrap" , name = "设备报废管理" )
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class DeviceScrapController {
 
    private final  DeviceScrapService deviceScrapService;
 
    /**
     * 分页查询
     * @param page 分页对象
     * @param queryDTO 设备报废
     * @return
     */
    @Operation(summary = "分页查询" , description = "分页查询" )
    @GetMapping("/page" )
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_view')" )
    public R getDeviceScrapPage(@ParameterObject Page page, @ParameterObject DeviceRepairQueryDTO queryDTO) {
        return R.ok(deviceScrapService.pageNew(page, queryDTO));
    }
 
 
    /**
     * 通过id查询设备报废
     * @param id id
     * @return R
     */
    @Operation(summary = "通过id查询" , description = "通过id查询" )
    @GetMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_view')" )
    public R getById(@PathVariable("id" ) Long id) {
        return R.ok(deviceScrapService.getById(id));
    }
 
    /**
     * 新增设备报废
     * @param deviceScrap 设备报废
     * @return R
     */
    @Operation(summary = "新增设备报废" , description = "新增设备报废" )
    @SysLog("新增设备报废" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_add')" )
    public R save(@RequestBody DeviceScrap deviceScrap) {
        deviceScrap.setStatus(1);
        return R.ok(deviceScrapService.save(deviceScrap));
    }
 
    /**
     * 修改设备报废
     * @param deviceScrap 设备报废
     * @return R
     */
    @Operation(summary = "修改设备报废" , description = "修改设备报废" )
    @SysLog("修改设备报废" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_edit')" )
    public R updateById(@RequestBody DeviceScrap deviceScrap) {
        return R.ok(deviceScrapService.updateById(deviceScrap));
    }
 
    /**
     * 通过id删除设备报废
     * @param ids id列表
     * @return R
     */
    @Operation(summary = "通过id删除设备报废" , description = "通过id删除设备报废" )
    @SysLog("通过id删除设备报废" )
    @DeleteMapping
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_del')" )
    public R removeById(@RequestBody Long[] ids) {
        return R.ok(deviceScrapService.removeBatchByIds(CollUtil.toList(ids)));
    }
 
 
    /**
     * 导出excel 表格
     * @param deviceScrap 查询条件
        * @param ids 导出指定ID
     * @return excel 文件流
     */
    @ResponseExcel
    @GetMapping("/export")
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_export')" )
    public List<DeviceScrap> export(DeviceScrap deviceScrap,Long[] ids) {
        return deviceScrapService.list(Wrappers.lambdaQuery(deviceScrap).in(ArrayUtil.isNotEmpty(ids), DeviceScrap::getId, ids));
    }
 
    /**
     * 设备维修审批通过
     * @return
     */
    @GetMapping("/approved/{id}" )
    @PreAuthorize("@pms.hasPermission('device_deviceScrap_approved')" )
    public R approved(@PathVariable("id")Long id) {
        return deviceScrapService.approved(id);
    }
}