package com.qianwen.mdc.collect.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.qianwen.core.mp.base.BaseServiceImpl; import com.qianwen.mdc.collect.entity.mgr.WorkstationDatapoints; import com.qianwen.mdc.collect.mapper.mgr.WorkstationDatapointsMapper; import com.qianwen.mdc.collect.vo.WorkstationDatapointsVO; /** * 工位数据点服务,主要用于获取数据点定义。定义在smartman应用 */ @Service public class WorkstationDatapointsService extends BaseServiceImpl { private Logger log = LoggerFactory.getLogger(this.getClass()); /** * 获取工位数据点配置 ,从缓存 * @param workstationId * @return */ @Cacheable(value = "collect:datapoint" ,key = "#appId") public WorkstationDatapointsVO getDatapointsByAppIdFromCache(String appId) { return this.getDataPointByAppId(appId); } /* @CachePut(value = "collect:datapoint" ,key = "#appId") public WorkstationDatapointsVO datapointsCachePut(String appId) { return this.getDataPointByAppId(appId); } */ @CacheEvict(value = "collect:datapoint" ,key = "#appId") public void datapointsCacheEvict(String appId) { } /** * 从数据库查询数据点定义 * @param workstationId 工位id * @return */ WorkstationDatapointsVO getDataPointByAppId(String appId) { log.info("appid={}", appId); WorkstationDatapoints dp = baseMapper.selectOne(Wrappers.lambdaQuery() .eq(WorkstationDatapoints::getAppId, appId)); log.info("dp={}", dp); WorkstationDatapointsVO dpVO = null; if (dp != null) { dpVO = new WorkstationDatapointsVO(dp.getWorkstationId(), dp.getAppId(), dp.getDpConfig()); } return dpVO; } }