| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.gson.Gson; |
| | | import com.iailab.framework.common.constant.CommonConstant; |
| | | import com.iailab.module.data.channel.http.entity.HttpApiEntity; |
| | | import com.iailab.module.data.channel.http.entity.HttpTagEntity; |
| | | import com.iailab.module.data.channel.http.service.HttpApiService; |
| | | import com.iailab.module.data.channel.http.service.HttpTagService; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.utils.DateUtils; |
| | | import com.iailab.module.data.common.utils.HttpRequest; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private HttpApiService httpApiService; |
| | | |
| | | @Autowired |
| | | private HttpTagService httpTagService; |
| | | |
| | | private static final String STA_TRUE = "true"; |
| | | |
| | |
| | | return value; |
| | | } |
| | | |
| | | public Map<String, Object> getLastValues(List<String> tagNames) { |
| | | Map<String, Object> result = new HashMap<>(); |
| | | Gson gson = new Gson(); |
| | | String tagSb = gson.toJson(tagNames); |
| | | log.info("body=====" + tagSb); |
| | | String currentDate = DateUtils.format(new Date(), "yyyyMMddHHmm00"); |
| | | String responseStr = HttpRequest.sendPost("http://172.16.59.105:9082/api/IHD/getPointslast" + "/" + currentDate, tagSb); |
| | | JSONObject responseObj = JSON.parseObject(responseStr); |
| | | if (STA_TRUE.equals(responseObj.get("isSuccess").toString())) { |
| | | JSONArray tagValueList = responseObj.getJSONArray("data"); |
| | | if (!CollectionUtils.isEmpty(tagValueList)) { |
| | | for (int i = 0; i < tagValueList.size(); i++) { |
| | | JSONObject item = tagValueList.getJSONObject(i); |
| | | if(item.get("value")!=null){ |
| | | BigDecimal value = new BigDecimal(item.get("value").toString()); |
| | | result.put(item.get("tagname").toString(), value.setScale(3, RoundingMode.HALF_UP)); |
| | | }else{ |
| | | result.put(item.get("tagname").toString(), CommonConstant.BAD_VALUE); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | public Map<String, Object> getTagValues(List<Object[]> params) { |
| | | if (CollectionUtils.isEmpty(params)) { |
| | | return new HashMap<>(); |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.data.channel.http.collector.ihdb.HttpCollectorForIhd; |
| | | import com.iailab.module.data.channel.http.entity.HttpTagEntity; |
| | | import com.iailab.module.data.channel.http.service.HttpTagService; |
| | | import com.iailab.module.data.channel.http.vo.HttpTagPageReqVO; |
| | |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Resource |
| | | private HttpTagService tagService; |
| | | |
| | | @Resource |
| | | private HttpCollectorForIhd httpCollectorForIhd; |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-http:query')") |
| | | @GetMapping("page") |
| | | public CommonResult<PageResult<HttpTagRespVO>> page(@Valid HttpTagPageReqVO reqVO) { |
| | | |
| | | PageResult<HttpTagEntity> page = tagService.queryPage(reqVO); |
| | | return success(BeanUtils.toBean(page, HttpTagRespVO.class)); |
| | | PageResult<HttpTagRespVO> pageResultVO = new PageResult<>(); |
| | | List<String> tagNames = page.getList().stream() |
| | | .map(HttpTagEntity::getTagName) |
| | | .collect(Collectors.toList()); |
| | | Map<String, Object> dataMap = httpCollectorForIhd.getLastValues(tagNames); |
| | | |
| | | List<HttpTagRespVO> vos = page.getList().stream().map(entity -> { |
| | | |
| | | HttpTagRespVO vo = BeanUtils.toBean(entity,HttpTagRespVO.class); |
| | | vo.setDataValue(Double.parseDouble(dataMap.get(entity.getTagName()).toString())); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | pageResultVO.setList(vos); |
| | | |
| | | return success(pageResultVO); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-http:query')") |
| | |
| | | List<HttpTagEntity> selectList(Map<String, Object> params); |
| | | |
| | | List<HttpTagEntity> getApiId(String code); |
| | | |
| | | List<HttpTagEntity> getInfoByTagNoAndSourceId(String sourceId, String tagNo); |
| | | } |
| | |
| | | .orderByDesc("create_time")); |
| | | } |
| | | |
| | | @Override |
| | | public List<HttpTagEntity> getInfoByTagNoAndSourceId(String sourceId, String tagName) { |
| | | return httpTagDao.selectList(new QueryWrapper<HttpTagEntity>() |
| | | .eq("api_id",sourceId) |
| | | .eq("tag_name",tagName) |
| | | ); |
| | | } |
| | | |
| | | } |
| | |
| | | @ExcelProperty("是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("数据值") |
| | | private Double dataValue; |
| | | |
| | | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("创建时间") |
| | | private Date createTime; |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.data.channel.kio.collector.KingIOCollector; |
| | | import com.iailab.module.data.channel.kio.entity.ChannelKioTagEntity; |
| | | import com.iailab.module.data.channel.kio.service.ChannelKioTagService; |
| | | import com.iailab.module.data.channel.kio.vo.KioTagPageReqVO; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Resource |
| | | private ChannelKioTagService channelKioTagService; |
| | | |
| | | @Resource |
| | | private KingIOCollector kingIOCollector; |
| | | |
| | | /** |
| | | * 分页查询tag |
| | | * */ |
| | | @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") |
| | | @GetMapping("page") |
| | | public CommonResult<PageResult<KioTagRespVO>> page(@Valid KioTagPageReqVO reqVO){ |
| | | |
| | | PageResult<ChannelKioTagEntity> page = channelKioTagService.queryPage(reqVO); |
| | | return success(BeanUtils.toBean(page, KioTagRespVO.class)); |
| | | PageResult<KioTagRespVO> pageResultVO = new PageResult<>(); |
| | | pageResultVO.setTotal(page.getTotal()); |
| | | |
| | | List<KioTagRespVO> vos = page.getList().stream().map(entity -> { |
| | | |
| | | KioTagRespVO vo = BeanUtils.toBean(entity,KioTagRespVO.class); |
| | | try { |
| | | vo.setDataValue(Double.parseDouble(kingIOCollector.getTagValue(reqVO.getDeviceId(), entity.getTagName()))); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | pageResultVO.setList(vos); |
| | | |
| | | return success(pageResultVO); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-kio:query')") |
| | |
| | | private String tagName; |
| | | |
| | | private String device; |
| | | |
| | | private String deviceId; |
| | | } |
| | |
| | | @ExcelProperty("测点描述") |
| | | private String tagDesc; |
| | | |
| | | @Schema(description = "是否可以tag", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("是否可以tag") |
| | | @Schema(description = "是否启用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("数据值") |
| | | private Double dataValue; |
| | | |
| | | @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("关联设备") |
| | | private String device; |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | 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.entity.ChannelModBusTagEntity; |
| | | import com.iailab.module.data.channel.modbus.service.ChannelModbusTagService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Resource |
| | | private ChannelModbusTagService channelModbusTagService; |
| | | |
| | | @Resource |
| | | private ModBusCollector modBusCollector; |
| | | |
| | | @GetMapping("/page") |
| | | public CommonResult<PageResult<ModBusTagRespVO>> list(@Valid ModBusTagPageReqVO reqVO) { |
| | | PageResult<ChannelModBusTagEntity> page = channelModbusTagService.queryPage(reqVO); |
| | | PageResult<ModBusTagRespVO> pageResultVO = new PageResult<>(); |
| | | pageResultVO.setTotal(page.getTotal()); |
| | | |
| | | return success(BeanUtils.toBean(page, ModBusTagRespVO.class)); |
| | | List<ModBusTagRespVO> vos = page.getList().stream().map(entity -> { |
| | | |
| | | ModBusTagRespVO vo = BeanUtils.toBean(entity,ModBusTagRespVO.class); |
| | | vo.setDataValue(modBusCollector.getTagValue(reqVO.getDeviceId(),entity.getTagName())); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | pageResultVO.setList(vos); |
| | | |
| | | return success(pageResultVO); |
| | | } |
| | | |
| | | /** |
| | |
| | | private String tagDesc; |
| | | |
| | | private String device; |
| | | |
| | | private String deviceId; |
| | | } |
| | |
| | | @ExcelProperty("是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("数据值") |
| | | private Double dataValue; |
| | | |
| | | @Schema(description = "大小端", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("大小端") |
| | | private String format; |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.data.channel.opcda.collector.OpcDACollector; |
| | | import com.iailab.module.data.channel.opcda.entity.ChannelOPCDADeviceEntity; |
| | | import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity; |
| | | import com.iailab.module.data.channel.opcda.service.ChannelOPCDADeviceService; |
| | | import com.iailab.module.data.channel.opcda.service.ChannelOPCDATagService; |
| | | import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO; |
| | | import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO; |
| | | import com.iailab.module.data.common.enums.DataSourceType; |
| | | import com.iailab.module.data.common.exception.RRException; |
| | | import com.iailab.module.data.common.utils.TagUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.validation.Valid; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Autowired |
| | | private ChannelOPCDATagService channelOPCDATagService; |
| | | |
| | | @Autowired |
| | | private OpcDACollector opcDACollector; |
| | | |
| | | @Autowired |
| | | private ChannelOPCDADeviceService channelOPCDADeviceService; |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
| | | @GetMapping("page") |
| | | public CommonResult<PageResult<OpcDaTagRespVO>> list(@Valid OpcDaTagPageReqVO reqVO) { |
| | | |
| | | PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO); |
| | | return success(BeanUtils.toBean(page, OpcDaTagRespVO.class)); |
| | | PageResult<OpcDaTagRespVO> pageResultVO = new PageResult<>(); |
| | | pageResultVO.setTotal(page.getTotal()); |
| | | |
| | | List<OpcDaTagRespVO> vos = page.getList().stream().map(entity -> { |
| | | |
| | | OpcDaTagRespVO vo = BeanUtils.toBean(entity,OpcDaTagRespVO.class); |
| | | List<String[]> tags = new ArrayList<>(); |
| | | String[] array = {reqVO.getServerId(),entity.getTagName()}; |
| | | tags.add(array); |
| | | ChannelOPCDADeviceEntity OPCDADevice = channelOPCDADeviceService.info(reqVO.getServerId()); |
| | | vo.setDataValue(Double.parseDouble(opcDACollector.getTagValues(tags).get(TagUtils.genTagId(DataSourceType.OPCDA.getCode(), OPCDADevice.getServerName(),entity.getTagName())).toString())); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | pageResultVO.setList(vos); |
| | | |
| | | return success(pageResultVO); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
| | |
| | | @ExcelProperty("是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("数据值") |
| | | private Double dataValue; |
| | | |
| | | @Schema(description = "itemID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("itemID") |
| | | private String itemId; |
| | |
| | | import com.iailab.framework.common.pojo.CommonResult; |
| | | import com.iailab.framework.common.pojo.PageResult; |
| | | import com.iailab.framework.common.util.object.BeanUtils; |
| | | import com.iailab.module.data.channel.opcua.collector.OpcUaCollector; |
| | | 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.OpcUaTagPageReqVO; |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static com.iailab.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @Resource |
| | | private ChannelOPCUATagService channelOpcuaTagService; |
| | | |
| | | @Resource |
| | | private OpcUaCollector opcUaCollector; |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
| | | @GetMapping("page") |
| | | public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { |
| | | |
| | | PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); |
| | | return success(BeanUtils.toBean(page, OpcUaTagRespVO.class)); |
| | | 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); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
| | |
| | | private String tagName; |
| | | |
| | | private String device; |
| | | |
| | | private String deviceId; |
| | | } |
| | |
| | | @ExcelProperty("是否启用") |
| | | private Boolean enabled; |
| | | |
| | | @Schema(description = "数据值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("数据值") |
| | | private Double dataValue; |
| | | |
| | | @Schema(description = "关联设备", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| | | @ExcelProperty("关联设备") |
| | | private String device; |
| | |
| | | public class PointCollectTaskNet60 implements ITask { |
| | | private final Logger logger = LoggerFactory.getLogger(getClass()); |
| | | |
| | | private static final String NET = "1min"; |
| | | private static final String NET = "NET60"; |
| | | |
| | | @Resource |
| | | private PointCollector pointCollector; |