车间能级提升-智能设备管理系统
zhuguifei
2025-05-13 14681dfe7052cb76eefcc0c17d0a0d708e1ac9dd
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
package org.dromara.eims.controller;
 
import java.util.ArrayList;
import java.util.List;
 
import org.dromara.common.excel.core.ExcelResult;
import org.dromara.eims.domain.bo.EimsEquBo;
import org.dromara.eims.domain.vo.EimsEquImportVo;
import org.dromara.eims.domain.vo.EimsEquVo;
import org.dromara.eims.listener.EimsEquImportListener;
import org.dromara.eims.service.IEimsEquService;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
 
 
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.springframework.web.multipart.MultipartFile;
 
/**
 * 【设备台账】
 *
 * @author zhuguifei
 * @date 2025-01-04
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/eims/equ")
public class EimsEquController extends BaseController {
 
    private final IEimsEquService eimsEquipmentService;
 
    /**
     * 查询【设备台账】列表
     */
    @SaCheckPermission("eims:equ:list")
    @GetMapping("/list")
    public TableDataInfo<EimsEquVo> list(EimsEquBo bo, PageQuery pageQuery) {
        return eimsEquipmentService.queryPageList(bo, pageQuery);
    }
 
    /**
     * 导出【设备台账】列表
     */
    @SaCheckPermission("eims:equ:export")
    @Log(title = "【设备台账】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(EimsEquBo bo, HttpServletResponse response) {
        List<EimsEquVo> list = eimsEquipmentService.queryList(bo);
        ExcelUtil.exportExcel(list, "【设备台账】", EimsEquVo.class, response);
    }
 
    /**
     * 获取【设备台账】详细信息
     *
     * @param equId 主键
     */
    @SaCheckPermission("eims:equ:query")
    @GetMapping("/{equId}")
    public R<EimsEquVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long equId) {
        return R.ok(eimsEquipmentService.queryById(equId));
    }
 
    /**
     * 获取【设备台账】详细信息
     *
     * @param assetNo
     */
    @SaCheckPermission("eims:equ:query")
    @GetMapping("/info/{assetNo}")
    public R<EimsEquVo> getInfoByAssetNo(@NotNull(message = "资产编号不能为空")
                                @PathVariable String assetNo) {
        return R.ok(eimsEquipmentService.queryByAssetNo(assetNo));
    }
 
    /**
     * 新增【设备台账】
     */
    @SaCheckPermission("eims:equ:add")
    @Log(title = "【设备台账】", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody EimsEquBo bo) {
        return toAjax(eimsEquipmentService.insertByBo(bo));
    }
 
    /**
     * 修改【设备台账】
     */
    @SaCheckPermission("eims:equ:edit")
    @Log(title = "【设备台账】", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody EimsEquBo bo) {
        return toAjax(eimsEquipmentService.updateByBo(bo));
    }
 
    /**
     * 删除【设备台账】
     *
     * @param equIds 主键串
     */
    @SaCheckPermission("eims:equ:remove")
    @Log(title = "【设备台账】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{equIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] equIds) {
        return toAjax(eimsEquipmentService.deleteWithValidByIds(List.of(equIds), true));
    }
 
    /**
     * 导入数据
     *
     * @param file          导入文件
     * @param updateSupport 是否更新已存在数据
     */
    @Log(title = "设备管理", businessType = BusinessType.IMPORT)
    @SaCheckPermission("eims:equ:import")
    @PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport) throws Exception {
        ExcelResult<EimsEquImportVo> result = ExcelUtil.importExcel(file.getInputStream(), EimsEquImportVo.class, new EimsEquImportListener(updateSupport));
        return R.ok(result.getAnalysis());
    }
 
    /**
     * 获取导入模板
     */
    @PostMapping("/importTemplate")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil.exportExcel(new ArrayList<>(), "设备数据", EimsEquVo.class, response);
    }
}