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));
|
}
|
|
}
|