lyh
3 天以前 3ce27b7faf8850d101a1511a685250fe562dca18
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
package com.lxzn.nc.controller;
 
import com.lxzn.auth.JwtUtil;
import com.lxzn.base.service.IMultilevelDictionaryService;
import com.lxzn.framework.domain.base.ext.MultilevelDictionaryExt;
import com.lxzn.framework.domain.nc.DeviceManagement;
import com.lxzn.framework.domain.nc.ext.DeviceGroupExt;
import com.lxzn.framework.model.response.CommonCode;
import com.lxzn.framework.model.response.QueryListResponseResult;
import com.lxzn.framework.model.response.QueryPageResponseResult;
import com.lxzn.framework.model.response.ResponseResult;
import com.lxzn.nc.service.IDeviceManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
 
@Slf4j
@Api(tags = "设备类管理信息")
@RestController
@RequestMapping("/nc/deviceManagement")
public class DeviceManagementController {
 
    @Autowired
    private IDeviceManagementService deviceManagementService;
 
    @Autowired
    private IMultilevelDictionaryService multilevelDictionaryService;
    /**
     * 设备类信息分页查询
     * @param deviceManagement
     * @param page
     * @param size
     * @return
     */
    @ApiOperation(value = "设备类管理信息-分页列表查询", notes = "设备类管理信息-分页列表查询")
    @GetMapping("/query/{page}/{size}")
    public QueryPageResponseResult<?> query(DeviceManagement deviceManagement,@PathVariable("page") int page, @PathVariable("size") int size){
        return deviceManagementService.query(deviceManagement, page, size);
    }
 
    /**
     * 获取所有设备类
     * @return
     */
    @ApiOperation(value = "设备类管理信息-获取所有设备类", notes = "设备类管理信息-获取所有设备类")
    @GetMapping("/find/list")
    public QueryListResponseResult<?> findAll(){
        return new QueryListResponseResult(CommonCode.SUCCESS, deviceManagementService.list());
    }
 
    @GetMapping("/find/select/list")
    public QueryListResponseResult<MultilevelDictionaryExt> findDictionaryList() {
        List<MultilevelDictionaryExt>  list = multilevelDictionaryService.findListByTypeCode("workcenter");
        if(list == null) {
            list = Collections.emptyList();
        }
        return new QueryListResponseResult(CommonCode.SUCCESS, list);
    }
 
    /**
     * 新增设备类
     * @param deviceManagement
     * @return
     */
    @ApiOperation(value = "设备类管理信息-新增设备类信息", notes = "设备类管理信息-新增设备类信息")
    @PostMapping("/add")
    public ResponseResult add(@RequestBody DeviceManagement deviceManagement){
        boolean b = deviceManagementService.add(deviceManagement);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    /**
     * 编辑设备类
     * @param deviceManagement
     * @return
     */
    @ApiOperation(value = "设备类管理信息-编辑设备类信息", notes = "设备类管理信息-编辑设备类信息")
    @PutMapping("/edit/{id}")
    public ResponseResult edit(@PathVariable("id") String id,@RequestBody DeviceManagement deviceManagement){
        deviceManagement.setId(id);
        boolean b = deviceManagementService.edit(deviceManagement);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    /**
     * 根据id删除设备类
     * @param id
     * @return
     */
    @ApiOperation(value = "设备类管理信息-根据id删除设备类信息", notes = "设备类管理信息-根据id删除设备类信息")
    @DeleteMapping("/delete")
    public ResponseResult delete(String id){
        boolean b = deviceManagementService.delete(id);
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    /**
     * 批量删除设备类
     * @param ids
     * @return
     */
    @ApiOperation(value = "设备类管理信息-批量删除设备类信息", notes = "设备类管理信息-批量删除设备类信息")
    @DeleteMapping("/deleteBatch")
    public ResponseResult deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        boolean b = deviceManagementService.deleteBatch(Arrays.asList(ids.split(",")));
        if(b) {
            return new ResponseResult(CommonCode.SUCCESS);
        }
        return new ResponseResult(CommonCode.FAIL);
    }
 
    /**
     * 获取用户权限拥有的车间信息
     * @return
     */
    @ApiOperation(value = "设备类管理信息-获取用户权限拥有的车间信息", notes = "设备类管理信息-获取用户权限拥有的车间信息")
    @GetMapping("/getProductionIdsByUserId")
    public QueryListResponseResult<DeviceGroupExt> getProductionIdsByUserId(){
        String userId = JwtUtil.getUserId();
        return new QueryListResponseResult<>(CommonCode.SUCCESS, deviceManagementService.getProductionIdsByUserId(userId));
    }
 
    /**
     * 通过车间id查询设备列表信息
     * @param productionId
     * @param equipmentId
     * @param equipmentName
     * @return
     */
    @ApiOperation(value = "设备类管理信息-通过车间id查询设备列表信息", notes = "设备类管理信息-通过车间id查询设备列表信息")
    @GetMapping("/getEquipmentListByProductionId")
    public QueryPageResponseResult<?> getEquipmentListByProductionId(String productionId,String equipmentId,String equipmentName,Integer pageNo,Integer pageSize){
        return new QueryPageResponseResult<>(CommonCode.SUCCESS, deviceManagementService.getEquipmentListByProductionId(productionId,equipmentId,equipmentName,pageNo,pageSize));
    }
 
    /**
     * 通过车间id查询设备类管理列表信息
     * @param productionId
     * @return
     */
    @ApiOperation(value = "设备类管理信息-通过车间id查询设备类管理列表信息", notes = "设备类管理信息-通过车间id查询设备类管理列表信息")
    @GetMapping("/getDeviceManagementListByProductionId")
    public QueryListResponseResult<?> getDeviceManagementListByProductionId(String productionId){
        return new QueryListResponseResult<>(CommonCode.SUCCESS, deviceManagementService.getDeviceManagementListByProductionId(productionId));
    }
 
    /**
     * 通过id查询设备列表信息
     * @param id
     * @return
     */
    @ApiOperation(value = "设备类管理信息-通过id查询设备列表信息", notes = "设备类管理信息-通过id查询设备列表信息")
    @GetMapping("/getEquipmentListById")
    public QueryListResponseResult<?> getEquipmentListByProductionId(String id){
        return new QueryListResponseResult<>(CommonCode.SUCCESS,deviceManagementService.getEquipmentListById(id));
    }
 
}