From 730d1944e3a13c517c77df2b0712df05645a38dd Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期一, 06 一月 2025 16:00:58 +0800 Subject: [PATCH] chartParamList api --- iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java | 34 +++++++++++----------------------- 1 files changed, 11 insertions(+), 23 deletions(-) diff --git a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java index bca1e0b..8c85b89 100644 --- a/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java +++ b/iailab-module-data/iailab-module-data-biz/src/main/java/com/iailab/module/data/channel/opcua/controller/admin/ChannelOPCUATagController.java @@ -8,8 +8,6 @@ import com.iailab.framework.common.util.object.ConvertUtils; import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; -import com.iailab.framework.common.util.object.ConvertUtils; -import com.iailab.framework.excel.core.util.ExcelUtils; import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; import com.iailab.module.data.channel.opcua.vo.OpcUaTagExportExcelVO; @@ -17,6 +15,7 @@ import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO; import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO; import com.iailab.module.data.channel.tag.vo.TagImportRespVO; +import com.iailab.module.data.common.enums.DataQualityEnum; import com.iailab.module.data.common.enums.IsEnableEnum; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -34,13 +33,13 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import java.util.stream.Collectors; import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static com.iailab.framework.common.pojo.CommonResult.success; /** * 操作opcua tag配置 + * * @author lirm * @Description * @createTime 2024年08月26日 @@ -57,25 +56,14 @@ @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @GetMapping("page") public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { - PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); - PageResult<OpcUaTagRespVO> pageResultVO = new PageResult<>(); - pageResultVO.setTotal(page.getTotal()); - - List<OpcUaTagRespVO> vos = page.getList().stream().map(entity -> { - - OpcUaTagRespVO vo = BeanUtils.toBean(entity,OpcUaTagRespVO.class); - try{ - vo.setDataValue( Double.parseDouble(opcUaCollector.getTagValue(reqVO.getDeviceId(),entity.getTagName()))); - }catch (Exception e){ - e.printStackTrace(); - } - return vo; - }).collect(Collectors.toList()); - - pageResultVO.setList(vos); - - return success(pageResultVO); + PageResult<OpcUaTagRespVO> pageResult = BeanUtils.toBean(page, OpcUaTagRespVO.class); + pageResult.getList().forEach(item -> { + item.setDataValue(opcUaCollector.getTagValue(reqVO.getDeviceId(), item.getTagName())); + item.setDataTime(new Date()); + item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); + }); + return success(pageResult); } @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") @@ -130,7 +118,7 @@ .build() ); // 输出 - ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcUaTagImportExcelVO.class, list,true); + ExcelUtils.write(response, "tag导入模板.xls", "tag列表", OpcUaTagImportExcelVO.class, list, true); } @PostMapping("/import") @@ -144,6 +132,6 @@ @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport, @RequestParam("device") String device) throws Exception { List<OpcUaTagImportExcelVO> list = ExcelUtils.read(file, OpcUaTagImportExcelVO.class); - return success(channelOpcuaTagService.importOpcUaTagList(list, updateSupport,device)); + return success(channelOpcuaTagService.importOpcUaTagList(list, updateSupport, device)); } } -- Gitblit v1.9.3