Commit 233e5135 authored by zhangsen's avatar zhangsen

bug修改

parent 5072533f
package com.yeejoin.amos.boot.module.jxiop.biz.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import javax.sql.DataSource;
import java.sql.SQLException;
/**
* 从数据源配置
* 若需要配置更多数据源 , 直接在yml中添加数据源配置再增加相应的新的数据源配置类即可
*/
@Configuration
@MapperScan(basePackages = "com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2", sqlSessionFactoryRef = "taosSqlSessionFactory2")
public class TdEngineConfig2 {
private Logger logger = LoggerFactory.getLogger(TdEngineConfig2.class);
// 精确到 cluster 目录,以便跟其他数据源隔离
private static final String MAPPER_LOCATION = "classpath*:mapper/tdengine2/*.xml";
@Value("${spring.db4.datasource.url}")
private String dbUrl;
@Value("${spring.db4.datasource.username}")
private String username;
@Value("${spring.db4.datasource.password}")
private String password;
@Value("${spring.db4.datasource.driver-class-name}")
private String driverClassName;
@Bean(name = "taosDataSource2") //声明其为Bean实例
public DataSource clusterDataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
datasource.setInitialSize(100); // 初始连接数
datasource.setMaxActive(200); // 最大连接数
datasource.setMaxWait(60000); // 最大等待时间
datasource.setMinIdle(5); // 最小空闲连接数
datasource.setValidationQuery("SELECT 1"); // 验证查询
try {
datasource.setFilters("stat");
} catch (SQLException throwables) {
throwables.printStackTrace();
}
datasource.setQueryTimeout(30); // 查询超时时间
datasource.setConnectionProperties("useUnicode=true;characterEncoding=UTF-8"); // 连接属性
return datasource;
}
@Bean(name = "taosTransactionManager2")
public DataSourceTransactionManager clusterTransactionManager() {
return new DataSourceTransactionManager(clusterDataSource());
}
@Bean(name = "taosSqlSessionFactory2")
public SqlSessionFactory clusterSqlSessionFactory(@Qualifier("taosDataSource2") DataSource culsterDataSource)
throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(culsterDataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
.getResources(MAPPER_LOCATION));
sessionFactory.setTypeAliasesPackage("com.yeejoin.amos.boot.module.jxiop.biz.entity");
//mybatis 数据库字段与实体类属性驼峰映射配置
sessionFactory.getObject().getConfiguration().setMapUnderscoreToCamelCase(true);
return sessionFactory.getObject();
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.controller; package com.yeejoin.amos.boot.module.jxiop.biz.controller;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData; import com.yeejoin.amos.boot.module.jxiop.biz.entity.IndicatorData;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl; import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -48,4 +48,44 @@ public class TestController extends BaseController { ...@@ -48,4 +48,44 @@ public class TestController extends BaseController {
commonService.healthWarningMinuteByFan(); commonService.healthWarningMinuteByFan();
} }
@Autowired
FanHealthIndexMapper fanHealthIndexMapper;
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "POST", value = "saveTest", notes = "saveTest")
@PostMapping("/saveTest")
public void saveTest () {
QueryWrapper<FanHealthIndex> fanHealthIndexQueryWrapper = new QueryWrapper<>();
List<FanHealthIndex> fanHealthIndices = fanHealthIndexMapper.selectList(fanHealthIndexQueryWrapper);
FanHealthIndex fanHealthIndex = new FanHealthIndex();
fanHealthIndex.setHealthIndex(2.0);
fanHealthIndex.setTs(System.currentTimeMillis());
fanHealthIndex.setArea("区域");
fanHealthIndex.setAnalysisEndTime(DateUtil.now());
fanHealthIndex.setAnalysisObjSeq("2");
fanHealthIndex.setHealthLevel("2321");
fanHealthIndex.setHealthIndex(25.0);
fanHealthIndex.setAnalysisStartTime(DateUtil.now());
fanHealthIndex.setAnalysisObjType("21");
fanHealthIndex.setAnalysisTime("21");
fanHealthIndex.setAnomaly(2.0);
fanHealthIndex.setEquipmentName("21");
fanHealthIndex.setGatewayId("213412");
fanHealthIndex.setPointName("21312");
fanHealthIndex.setNumber("213");
fanHealthIndex.setKks("213");
fanHealthIndex.setRecDate(DateUtil.now());
fanHealthIndex.setSubSystem("213421");
fanHealthIndex.setWeight(2.2);
fanHealthIndex.setAnalysisType("21");
fanHealthIndex.setStation("rwwrrw");
fanHealthIndex.setIndexAddress("2321");
// commonService.healthWarningMinuteByFJ();
fanHealthIndexMapper.insert(fanHealthIndex);
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexDay;
public interface FanHealthIndexDayMapper extends BaseMapper<FanHealthIndexDay> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexHour;
public interface FanHealthIndexHourMapper extends BaseMapper<FanHealthIndexHour> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndex;
public interface FanHealthIndexMapper extends BaseMapper<FanHealthIndex> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.FanHealthIndexMoment;
public interface FanHealthIndexMomentMapper extends BaseMapper<FanHealthIndexMoment> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexDay;
public interface PvHealthIndexDayMapper extends BaseMapper<PvHealthIndexDay> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexHour;
public interface PvHealthIndexHourMapper extends BaseMapper<PvHealthIndexHour> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndex;
public interface PvHealthIndexMapper extends BaseMapper<PvHealthIndex> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.jxiop.biz.tdengine.PvHealthIndexMoment;
public interface PvHealthIndexMomentMapper extends BaseMapper<PvHealthIndexMoment> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName(value = "fan_health_index", autoResultMap = true)
public class FanHealthIndex implements Serializable {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName(value = "fan_health_index_day", autoResultMap = true)
public class FanHealthIndexDay implements Serializable {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName(value = "fan_health_index_hour", autoResultMap = true)
public class FanHealthIndexHour implements Serializable {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
@Data
@TableName(value = "fan_health_index_moment", autoResultMap = true)
public class FanHealthIndexMoment implements Serializable {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subSystem;
private String number;
private String equipmentName;
private String gatewayId;
private String indexAddress;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@TableName(value = "pv_health_index", autoResultMap = true)
public class PvHealthIndex {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@TableName(value = "pv_health_index_day", autoResultMap = true)
public class PvHealthIndexDay {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@TableName(value = "pv_health_index_hour", autoResultMap = true)
public class PvHealthIndexHour {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
package com.yeejoin.amos.boot.module.jxiop.biz.tdengine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
*
*
* @author system_generator
* @date 2023-08-15
*/
@Data
@TableName(value = "pv_health_index_moment", autoResultMap = true)
public class PvHealthIndexMoment {
private Long ts;
private String recDate;
private String analysisObjType;
private String analysisObjSeq;
private Double weight;
private Double healthIndex;
private String healthLevel;
private String analysisType;
private String analysisStartTime;
private String analysisEndTime;
private String area;
private String station;
private String subarray;
private String manufacturer;
private String deviceType;
private String gatewayId;
private String indexAddress;
private String equipmentName;
private Double anomaly;
private String pointName;
private String analysisTime;
private String kks;
}
...@@ -75,6 +75,16 @@ spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/iot_data?user=root&pa ...@@ -75,6 +75,16 @@ spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/iot_data?user=root&pa
spring.db3.datasource.username=root spring.db3.datasource.username=root
spring.db3.datasource.password=taosdata spring.db3.datasource.password=taosdata
spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver spring.db3.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
# 分析专用td数据库 analyse_data
#spring.db4.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db4.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/analyse_data?user=root&password=taosdata&timezone=GMT%2b8&allowMultiQueries=true
spring.db4.datasource.username=root
spring.db4.datasource.password=taosdata
spring.db4.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
## influxDB ## influxDB
#spring.influx.url= http://172.16.3.155:18186 #spring.influx.url= http://172.16.3.155:18186
#spring.influx.password=Yeejoin@2020 #spring.influx.password=Yeejoin@2020
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexDayMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexHourMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.FanHealthIndexMomentMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexDayMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexHourMapper">
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jxiop.biz.tdMapper2.PvHealthIndexMomentMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment