| | |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.framework.common.util.object.ConvertUtils; |
| | | import com.iailab.framework.excel.core.util.ExcelUtils; |
| | | import com.iailab.module.data.channel.modbus.collector.ModBusCollector; |
| | | import com.iailab.module.data.channel.modbus.entity.ChannelModBusTagEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | | import com.iailab.module.data.channel.modbus.vo.ModBusTagExportExcelVO; |
| | |
| | | import com.iailab.module.data.channel.modbus.vo.ModBusTagPageReqVO; |
| | | import com.iailab.module.data.channel.modbus.vo.ModBusTagRespVO; |
| | | 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; |
| | |
| | | @Resource |
| | | private ChannelModbusTagService channelModbusTagService; |
| | | |
| | | @Resource |
| | | private ModBusCollector modBusCollector; |
| | | |
| | | @GetMapping("/page") |
| | | public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) { |
| | | PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO); |
| | | return success(BeanUtils.toBean(page, ModBusTagRespVO.class)); |
| | | PageResult<ModBusTagRespVO> pageResult = BeanUtils.toBean(page, ModBusTagRespVO.class); |
| | | pageResult.getList().forEach(item -> { |
| | | item.setDataValue(modBusCollector.getTagValue(reqVO.getDeviceId(), item.getTagName())); |
| | | item.setDataTime(new Date()); |
| | | item.setDataQuality(DataQualityEnum.getEumByValue(item.getDataValue()).getDesc()); |
| | | }); |
| | | return success(pageResult); |
| | | } |
| | | |
| | | /** |
| | |
| | | .build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "tag导入模板.xls", "tag列表", ModBusTagImportExcelVO.class, list,true); |
| | | ExcelUtils.write(response, "tag导入模板.xls", "tag列表", ModBusTagImportExcelVO.class, list, true); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | |
| | | @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport, |
| | | @RequestParam("device") String device) throws Exception { |
| | | List<ModBusTagImportExcelVO> list = ExcelUtils.read(file, ModBusTagImportExcelVO.class); |
| | | return success(channelModbusTagService.importModBusTagList(list, updateSupport,device)); |
| | | return success(channelModbusTagService.importModBusTagList(list, updateSupport, device)); |
| | | } |
| | | } |