package com.iailab.module.data.channel.opcua.controller.admin;
|
|
import cn.hutool.core.codec.Base64;
|
import com.iailab.module.data.common.exception.RRException;
|
import com.iailab.module.data.common.utils.PageUtils;
|
import com.iailab.module.data.common.utils.R;
|
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity;
|
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService;
|
import javax.annotation.Resource;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* 操作opcua tag配置
|
*
|
* @author DongYukun
|
* @createTime 2023年05月6日 17:44:00
|
*/
|
@RestController
|
@RequestMapping("/data/channel/opcua/tag")
|
public class ChannelOPCUATagController {
|
@Resource
|
private ChannelOPCUATagService channelOpcuaTagService;
|
/**
|
* 分页查询tag
|
*
|
* @param params
|
*/
|
@GetMapping("/list")
|
public R tagList(@RequestParam Map<String, Object> params){
|
PageUtils page = channelOpcuaTagService.queryPage(params);
|
|
return R.ok().put("page", page);
|
}
|
/**
|
* 根据id查询tag详情
|
*
|
* @param id
|
*/
|
@GetMapping("/info/{id}")
|
public R tagInfo(@PathVariable("id") String id){
|
ChannelOPCUATagEntity info= channelOpcuaTagService.info(Base64.decodeStr(id));
|
return R.ok().put("data", info);
|
}
|
/**
|
* 添加tag
|
*
|
* @param entity
|
*/
|
@PostMapping("/add")
|
public R tagAdd(@RequestBody ChannelOPCUATagEntity entity){
|
entity.setId(UUID.randomUUID().toString());
|
channelOpcuaTagService.add(entity);
|
return R.ok();
|
}
|
|
/**
|
* 修改tag
|
*
|
* @param channelOPCUATagEntity
|
*/
|
@PostMapping("/update")
|
public R tagUpdate(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) {
|
channelOpcuaTagService.update(channelOPCUATagEntity);
|
return R.ok();
|
}
|
|
/**
|
* 删除tag
|
* @param params
|
*
|
*/
|
@PostMapping("/delete")
|
public R tagDelete(@RequestBody Map<String, Object> params) {
|
String id = (String)params.get("id");
|
channelOpcuaTagService.delete(id);
|
return R.ok();
|
}
|
|
/**
|
* 导入
|
*
|
* @param device
|
* @param file
|
* @return
|
*/
|
@PostMapping("/import/{device}")
|
public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) {
|
try {
|
if (file.isEmpty()) {
|
throw new RRException("上传文件不能为空");
|
}
|
channelOpcuaTagService.importTag(device, file);
|
} catch (Exception ex) {
|
return R.error(ex.getMessage());
|
}
|
return R.ok();
|
}
|
}
|