作者 钟来

模块整理

... ... @@ -7,6 +7,7 @@ import com.zhonglai.luhui.api.controller.data.SensorData;
import com.zhonglai.luhui.api.controller.data.TableGenerateSqlEnum;
import com.zhonglai.luhui.api.mapper.DeviceSensorDataMapper;
import com.zhonglai.luhui.dao.mapper.PublicMapper;
import com.zhonglai.luhui.datasource.config.DynamicDataSourceContextHolder;
import com.zhonglai.luhui.datasource.enums.DataSource;
import com.zhonglai.luhui.datasource.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -304,6 +305,7 @@ public class DataService {
@DataSource(value = DataSourceType.SLAVE)
public StringBuffer getBeifeiDbDeviceHistoryData(String deviceInfoId,String dataType,int startTime,int endTime,int interval)
{
DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
List<Map<String,Object>> list = publicMapper.getObjectListBySQL("SELECT count(*) ct FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='ly-device-data' and TABLE_NAME='"+deviceInfoId+"-"+dataType+"'");
if(null != list && list.size() !=0 && null != list.get(0) && null != list.get(0).get("ct") && (list.get(0).get("ct")+"").equals("1"))
... ... @@ -321,9 +323,13 @@ public class DataService {
sb.append(map.get("value"));
sb.append("\r\n");
}
// 销毁数据源 在执行方法之后
DynamicDataSourceContextHolder.clearDataSourceType();
return sb;
}
}
// 销毁数据源 在执行方法之后
DynamicDataSourceContextHolder.clearDataSourceType();
return null;
}
... ... @@ -335,7 +341,6 @@ public class DataService {
* @param date 指定天数
* @return
*/
@DataSource(value = DataSourceType.SLAVE)
public StringBuffer getDeviceTimeData(String deviceInfoId, String dataType, Date date, int interval) {
String dataTypestr = dataType;
... ...