parent
6ce9f75ee7
commit
48ae986d5c
@ -1,2 +1,6 @@
|
||||
<<<<<<< HEAD
|
||||
/target/
|
||||
/build
|
||||
=======
|
||||
build/
|
||||
>>>>>>> 355b6e47a4fa8d058029ec939fe4fefdaa751275
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,37 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>extendGlusterfs</groupId>
|
||||
<artifactId>extendGlusterfs</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>extendGlusterfs</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/ch.ethz.ganymed/ganymed-ssh2 -->
|
||||
<dependency>
|
||||
<groupId>ch.ethz.ganymed</groupId>
|
||||
<artifactId>ganymed-ssh2</artifactId>
|
||||
<version>build209</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
||||
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.platform.dao.GatherOracleDao">
|
||||
<resultMap type="com.platform.entities.GatherOracleInfo" id="getEntityBytext">
|
||||
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
|
||||
<result property="port" column="service_port" javaType="int" jdbcType="INTEGER"/>
|
||||
<result property="ip" column="service_ip" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="service_name" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="user" column="service_user" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="service_password" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="databaseName" column="service_database" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="tableName" column="service_table" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="suffix" column="service_suffix" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="service_status" javaType="string" jdbcType="VARCHAR"/>
|
||||
<result property="remove" column="remove" jdbcType="CHAR"/>
|
||||
</resultMap>
|
||||
<sql id="baseOracleInfo">
|
||||
id id, service_port port, service_ip ip, service_name name, service_user user, service_password password, service_database databaseName, service_table tableName, service_suffix suffix, service_status status
|
||||
</sql>
|
||||
|
||||
<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
|
||||
SELECT
|
||||
<include refid="baseOracleInfo" />
|
||||
FROM services_info
|
||||
WHERE remove = "0"
|
||||
</select>
|
||||
|
||||
<insert id="insertOracle" parameterType="com.platform.entities.GatherOracleInfo">
|
||||
INSERT INTO
|
||||
services_info(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="port > 0">
|
||||
service_port,
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
service_ip,
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
service_name,
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
service_user,
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
service_password,
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
service_database,
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
service_table,
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
service_suffix,
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
service_status,
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
VALUES(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="port > 0">
|
||||
#{port},
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
#{ip},
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
#{name},
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
#{user},
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
#{password},
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
#{databaseName},
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
#{tableName},
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
#{suffix},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
#{status},
|
||||
</if>
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteOracleById" parameterType="java.lang.Integer">
|
||||
DELETE FROM services_info
|
||||
<where>
|
||||
id =#{id}
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<update id="updateOracleById" parameterType="com.platform.entities.GatherOracleInfo">
|
||||
UPDATE
|
||||
services_info
|
||||
<set >
|
||||
<trim suffixOverrides=",">
|
||||
<if test="name != null and name != ''">
|
||||
service_name = #{name},
|
||||
</if>
|
||||
<if test="ip != null and ip != ''">
|
||||
service_ip = #{ip},
|
||||
</if>
|
||||
<if test="port > 0">
|
||||
service_port= #{port},
|
||||
</if>
|
||||
<if test="user != null and user != ''">
|
||||
service_user= #{user},
|
||||
</if>
|
||||
<if test="password != null and password != ''">
|
||||
service_password= #{password},
|
||||
</if>
|
||||
<if test="databaseName != null and databaseName != ''">
|
||||
service_database= #{databaseName},
|
||||
</if>
|
||||
<if test="tableName != null and tableName != ''">
|
||||
service_table= #{tableName},
|
||||
</if>
|
||||
<if test="suffix != null and suffix != ''">
|
||||
service_suffix= #{suffix},
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
service_status= #{status},
|
||||
</if>
|
||||
<if test="remove != null and remove != ''">
|
||||
remove= #{remove},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
<where>
|
||||
id = #{id}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
||||
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.platform.dao.DataInfoDao">
|
||||
<resultMap id="getEntityByText" type="DataInfoEntity">
|
||||
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
|
||||
<result property="regionalismCode" column="regionalism_code"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="cityName" column="city_name" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="districtName" column="district_name"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="systemCode" column="system_code" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
<result property="systemName" column="system_name" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="dataType" column="data_type" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="dataVersion" column="data_version" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
<result property="submittedBatch" column="submitted_batch"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="dataPath" column="data_path" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="charset" column="data_charset" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="collectingTime" column="collection_time"
|
||||
javaType="string" jdbcType="DATE" />
|
||||
<result property="collectorContacts" column="collector_contacts"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="collectorName" column="collector_name"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="year" column="data_year" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
</resultMap>
|
||||
<sql id="conditionsFilters">
|
||||
<if test="PagerOptions.dataType!=null">
|
||||
and data_details.data_type=#{PagerOptions.dataType}
|
||||
</if>
|
||||
<if test="PagerOptions.submittedBatch!=null">
|
||||
and
|
||||
data_details.submitted_batch=#{PagerOptions.submittedBatch}
|
||||
</if>
|
||||
<if test="PagerOptions.cityName!=null">
|
||||
and data_details.city_name=#{PagerOptions.cityName}
|
||||
</if>
|
||||
<if test="PagerOptions.districtName!=null">
|
||||
and
|
||||
data_details.district_name=#{PagerOptions.districtName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataVersion !=null">
|
||||
and data_details.data_version=#{PagerOptions.dataVersion}
|
||||
</if>
|
||||
<if test="PagerOptions.systemName !=null">
|
||||
and data_details=#{PagerOptions.systemName}
|
||||
</if>
|
||||
<if test="PagerOptions.dataYear !=null">
|
||||
and data_details.data_year=#{PagerOptions.dataYear}
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<!-- 获取数据符合筛选条件的全部记录信息 -->
|
||||
<select id="getLimitedDataInfoEntities" parameterType="PagerOptions"
|
||||
resultMap="getEntityByText">
|
||||
SELECT
|
||||
id,regionalism_code,city_name,district_name,system_code,system_name,data_type,data_version,submitted_batch,data_path,data_charset,collection_time,collector_name,collector_contacts,data_year
|
||||
FROM data_details
|
||||
<if test="PagerOptions!=null">
|
||||
<where>
|
||||
<include refid="conditionsFilters" />
|
||||
<choose>
|
||||
<when test="PagerOptions.offset > 0">
|
||||
and data_details.id>= #{PagerOptions.offset}
|
||||
</when>
|
||||
<otherwise>
|
||||
and data_details.id>=0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
ORDER BY data_details.id
|
||||
<if test="PagerOptions.limit > 0">
|
||||
LIMIT #{PagerOptions.limit}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取数据符合筛选条件的总记录条数 -->
|
||||
<select id="getLimitedDataCount" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT COUNT(id) FROM data_details
|
||||
<if test="PagerOptions!=null">
|
||||
<where>
|
||||
<include refid="conditionsFilters" />
|
||||
</where>
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 获取数据查询的起始di -->
|
||||
<select id="getLimitedBeginId" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT MAX(idx) FROM (SELECT id idx FROM data_details
|
||||
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,151 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
||||
"http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.platform.dao.DataInfoMoveTmpDao">
|
||||
<resultMap id="getEntityByText" type="com.platform.entities.DataInfoEntityMoveTmp">
|
||||
<id property="id" column="id" javaType="int" jdbcType="INTEGER" />
|
||||
<result property="regionalismCode" column="regionalism_code"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="cityName" column="city_name" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="districtName" column="district_name"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="systemCode" column="system_code" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
<result property="systemName" column="system_name" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="dataType" column="data_type" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="dataVersion" column="data_version" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
<result property="submittedBatch" column="submitted_batch"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="dataPath" column="data_path" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="charset" column="data_charset" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="collectingTime" column="collection_time"
|
||||
javaType="string" jdbcType="DATE" />
|
||||
<result property="collectorContacts" column="collector_contacts"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="collectorName" column="collector_name"
|
||||
javaType="string" jdbcType="VARCHAR" />
|
||||
<result property="year" column="data_year" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
|
||||
<result property="dstPath" column="dst_path" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="completeStatus" column="complete_status" javaType="string"
|
||||
jdbcType="VARCHAR" />
|
||||
<result property="rate" column="rate" javaType="int"
|
||||
jdbcType="INTEGER" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 获取数据全部记录信息 -->
|
||||
<select id="findAll" parameterType="" resultMap="getEntityByText">
|
||||
SELECT
|
||||
a.id,a.regionalism_code,b.city_name,b.district_name, a.system_code,b.system_name,b.data_type,b.data_version,b.submitted_batch,
|
||||
b.data_path,b.data_charset,b.collection_time,b.collector_name,b.collector_contacts,b.data_year,a.dst_path,a.complete_status,a.rate
|
||||
FROM
|
||||
move_data_tmp a LEFT JOIN data_details b
|
||||
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code;
|
||||
</select>
|
||||
|
||||
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
|
||||
UPDATE
|
||||
move_data_tmp
|
||||
<set >
|
||||
<trim suffixOverrides=",">
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
regionalism_code = #{regionalismCode},
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
system_code= #{systemCode},
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
dst_path= #{dstPath},
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
complete_status= #{completeStatus},
|
||||
</if>
|
||||
rate= #{rate}
|
||||
</trim>
|
||||
</set>
|
||||
<where>
|
||||
id = #{id}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<insert id="save" parameterType="">
|
||||
INSERT INTO
|
||||
move_data_tmp(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id > 0">
|
||||
id,
|
||||
</if>
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
regionalism_code,
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
system_code,
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
dst_path,
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
complete_status,
|
||||
</if>
|
||||
rate
|
||||
</trim>
|
||||
)
|
||||
VALUES(
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id > 0">
|
||||
id,
|
||||
</if>
|
||||
<if test="regionalismCode != null and regionalismCode != ''">
|
||||
#{regionalismCode},
|
||||
</if>
|
||||
<if test="systemCode != null and systemCode != ''">
|
||||
#{systemCode},
|
||||
</if>
|
||||
<if test="dstPath != null and dstPath != ''">
|
||||
#{dstPath},
|
||||
</if>
|
||||
<if test="completeStatus != null and completeStatus != ''">
|
||||
#{completeStatus},
|
||||
</if>
|
||||
#{rate}
|
||||
</trim>
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="remove" parameterType="java.lang.INTEGER">
|
||||
DELETE FROM
|
||||
move_data_tmp
|
||||
WHERE
|
||||
id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 获取数据符合筛选条件的总记录条数 -->
|
||||
<select id="getLimitedDataCount" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT COUNT(id) FROM move_data_tmp
|
||||
<if test="PagerOptions!=null">
|
||||
<where>
|
||||
<include refid="conditionsFilters" />
|
||||
</where>
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- 获取数据查询的起始di -->
|
||||
<select id="getLimitedBeginId" resultType="java.lang.Integer"
|
||||
parameterType="PagerOptions">
|
||||
SELECT MAX(idx) FROM (SELECT id idx FROM move_data_tmp
|
||||
ORDER BY id LIMIT 0,#{PagerOptions.totalLimit}) AS TEMP
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,39 @@
|
||||
package com.platform.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
|
||||
@Repository(value = "gatherOracleDao")
|
||||
public interface GatherOracleDao {
|
||||
|
||||
/**
|
||||
* @return 查询所有的oracle记录
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public List<GatherOracleInfo> selectAllOracle() throws Exception;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteOracleById(int id) throws Exception;
|
||||
|
||||
/**
|
||||
* @param oracle
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
/**
|
||||
* @param oracle
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int updateOracleById(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.platform.entities;
|
||||
|
||||
public class DataInfoEntityMoveTmp extends DataInfoEntity {
|
||||
|
||||
private String dstPath;
|
||||
|
||||
private String completeStatus;
|
||||
|
||||
private int rate;
|
||||
|
||||
/**
|
||||
* @return the dstPath
|
||||
*/
|
||||
public String getDstPath() {
|
||||
return dstPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dstPath the dstPath to set
|
||||
*/
|
||||
public void setDstPath(String dstPath) {
|
||||
this.dstPath = dstPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the completeStatus
|
||||
*/
|
||||
public String getCompleteStatus() {
|
||||
return completeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param completeStatus the completeStatus to set
|
||||
*/
|
||||
public void setCompleteStatus(String completeStatus) {
|
||||
this.completeStatus = completeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rate
|
||||
*/
|
||||
public int getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rate the rate to set
|
||||
*/
|
||||
public void setRate(int rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.platform.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
|
||||
public interface IMySqlService {
|
||||
|
||||
/**
|
||||
* @return 查询
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<GatherOracleInfo> findAllMySql() throws Exception;
|
||||
|
||||
/** 删除
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int deleteMySql(int id) throws Exception;
|
||||
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
public int updateOracle(GatherOracleInfo oracle) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.platform.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IOracleExtractService {
|
||||
|
||||
/** 抽取数据库
|
||||
* @param name
|
||||
* @param dataInfo //采集库连接参数
|
||||
* @param oracleConnect
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public boolean extractOracle(String name, List<Map<String, String>> dataInfo, Map<String, String> oracleConnect) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.platform.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.platform.dao.GatherOracleDao;
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.service.IMySqlService;
|
||||
|
||||
@Service(value = "mySqlService")
|
||||
public class MySqlServiceImpl implements IMySqlService{
|
||||
|
||||
@Resource(name = "gatherOracleDao")
|
||||
private GatherOracleDao gatherOracleDao;
|
||||
|
||||
@Override
|
||||
public List<GatherOracleInfo> findAllMySql() throws Exception {
|
||||
List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteMySql(int id) throws Exception {
|
||||
|
||||
int result = 0;
|
||||
if (id > 0) {
|
||||
// result = gatherOracleDao.deleteOracleById(id);
|
||||
GatherOracleInfo oracle = new GatherOracleInfo();
|
||||
oracle.setId(id);
|
||||
oracle.setRemove("1");
|
||||
result = gatherOracleDao.updateOracleById(oracle );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception {
|
||||
int result = gatherOracleDao.insertOracle(oracle);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOracle(GatherOracleInfo oracle) throws Exception {
|
||||
int result;
|
||||
if (oracle.getId() > 0) {
|
||||
result = gatherOracleDao.updateOracleById(oracle);
|
||||
}
|
||||
else {
|
||||
result = gatherOracleDao.insertOracle(oracle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.platform.service.impl;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.platform.entities.DataInfoEntity;
|
||||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.entities.OracleConnectorParams;
|
||||
import com.platform.oracle.OracleConnector;
|
||||
import com.platform.service.IOracleExtractService;
|
||||
import com.platform.service.OracleExtractHelper;
|
||||
import com.platform.utils.Bean2MapUtils;
|
||||
|
||||
@Service(value = "OracleExtract")
|
||||
public class OracleExtractServiceImpl implements IOracleExtractService {
|
||||
|
||||
/**
|
||||
* 抽取
|
||||
*/
|
||||
private OracleExtractHelper oracleExtract = new OracleExtractHelper();
|
||||
|
||||
/**
|
||||
* 数据库连接实现类
|
||||
*/
|
||||
private OracleConnector connect = new OracleConnector();
|
||||
|
||||
@Override
|
||||
public boolean extractOracle(String name, List<Map<String, String>> dataInfoMap,
|
||||
Map<String, String> oracleConnect) throws Exception {
|
||||
boolean isSuccess = false;
|
||||
try{
|
||||
//map转 bean(汇总库信息-带tableName的)
|
||||
GatherOracleInfo oracleModel = (GatherOracleInfo) Bean2MapUtils.convertMap(GatherOracleInfo.class, oracleConnect);
|
||||
|
||||
//采集库连接参数
|
||||
List<OracleConnectorParams> datainfos = new ArrayList<OracleConnectorParams>();
|
||||
for (Map<String, String> map : dataInfoMap) {
|
||||
OracleConnectorParams dataInfoEntity = (OracleConnectorParams) Bean2MapUtils.convertMap(OracleConnectorParams.class, oracleConnect);
|
||||
datainfos.add(dataInfoEntity);
|
||||
}
|
||||
|
||||
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + "/"
|
||||
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword());
|
||||
|
||||
for (OracleConnectorParams collectOracle : datainfos) {
|
||||
|
||||
oracleExtract.createDBLink(conn, collectOracle);
|
||||
oracleExtract.createTableSpace(conn, oracleModel);
|
||||
oracleExtract.createUser(conn, oracleModel);
|
||||
oracleExtract.extractColleDB(conn, collectOracle);
|
||||
}
|
||||
isSuccess = true;
|
||||
}catch(Exception e){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bean2MapUtils {
|
||||
|
||||
/**
|
||||
* 将一个 Map 对象转化为一个 JavaBean
|
||||
* @param type 要转化的类型
|
||||
* @param map 包含属性值的 map
|
||||
* @return 转化出来的 JavaBean 对象
|
||||
* @throws IntrospectionException
|
||||
* 如果分析类属性失败
|
||||
* @throws IllegalAccessException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InstantiationException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException
|
||||
* 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Object convertMap(Class type, Map map)
|
||||
throws IntrospectionException, IllegalAccessException,
|
||||
InstantiationException, InvocationTargetException {
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性
|
||||
Object obj = type.newInstance(); // 创建 JavaBean 对象
|
||||
|
||||
// 给 JavaBean 对象的属性赋值
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
try{
|
||||
if (map.containsKey(propertyName)) {
|
||||
// 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。
|
||||
Object value = map.get(propertyName);
|
||||
|
||||
Object[] args = new Object[1];
|
||||
args[0] = value;
|
||||
|
||||
descriptor.getWriteMethod().invoke(obj, args);
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个 JavaBean 对象转化为一个 Map
|
||||
* @param bean 要转化的JavaBean 对象
|
||||
* @return 转化出来的 Map 对象
|
||||
* @throws IntrospectionException 如果分析类属性失败
|
||||
* @throws IllegalAccessException 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Map convertBean(Object bean)
|
||||
throws IntrospectionException, IllegalAccessException, InvocationTargetException {
|
||||
Class type = bean.getClass();
|
||||
Map returnMap = new HashMap();
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type);
|
||||
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
if (!propertyName.equals("class")) {
|
||||
Method readMethod = descriptor.getReadMethod();
|
||||
Object result = readMethod.invoke(bean, new Object[0]);
|
||||
if (result != null) {
|
||||
returnMap.put(propertyName, result);
|
||||
} else {
|
||||
returnMap.put(propertyName, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class CacheTreeData {
|
||||
|
||||
private static List<FolderNode> folders = null;
|
||||
|
||||
public static List<FolderNode> getFolders() {
|
||||
return folders;
|
||||
}
|
||||
|
||||
public static void setFolders(List<FolderNode> folders) {
|
||||
CacheTreeData.folders = folders;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestSupport {
|
||||
public List<String> strToList(String str) {
|
||||
List<String> reStrings=new ArrayList<String>();
|
||||
for(String one:str.split("\n")){
|
||||
reStrings.add(one);
|
||||
}
|
||||
return reStrings;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.platform.utils;
|
||||
|
||||
public class ThreadMoveData extends Thread {
|
||||
|
||||
/**
|
||||
* : 实时更新数据库--根据查询到的 正则迁移的数据
|
||||
*/
|
||||
public ThreadMoveData() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Thread#run()
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO Auto-generated method stub
|
||||
super.run();
|
||||
//查询 表 move_data_tmp
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep(Constant.update_dataInfo_sleep_time);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class getTreeDataByPath {
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public FolderNode findByPath(String path) {
|
||||
List<FolderNode> folderNodelist = CacheTreeData.getFolders();
|
||||
if (null == folderNodelist) {
|
||||
return null;
|
||||
}
|
||||
FolderNode folder = null;
|
||||
for (FolderNode folderNode : folderNodelist) {
|
||||
folder = getFolder(folderNode, path);
|
||||
if (null != folder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
private FolderNode getFolder(FolderNode f, String path){
|
||||
FolderNode result = null;
|
||||
if(path.equals(f.getPath())){
|
||||
return f;
|
||||
}
|
||||
List<FolderNode> folds = f.getChildNodes();
|
||||
if (null != folds) {
|
||||
for (FolderNode folderNode : folds) {
|
||||
result = getFolder(folderNode, path);
|
||||
if (null != result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.platform.test;
|
||||
|
||||
public class Brick {
|
||||
private String ip;
|
||||
private String path;
|
||||
|
||||
public Brick(String ip, String path) {
|
||||
super();
|
||||
this.ip = ip;
|
||||
this.path = path;
|
||||
}
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.platform.test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class FolderReader {
|
||||
|
||||
public static FolderNode reader(String path) {
|
||||
FolderNode folderNode = null;
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
List<FolderNode> childrens = new ArrayList<FolderNode>();
|
||||
if (file.isDirectory()) {
|
||||
File[] files = file.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
FolderNode children = reader(files[i].getAbsolutePath());
|
||||
if (children != null)
|
||||
childrens.add(children);
|
||||
}
|
||||
}
|
||||
// folderNode = new FolderNode(file.getName(), file.getAbsolutePath(),
|
||||
// childrens);
|
||||
}
|
||||
return folderNode;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// TODO Auto-generated method stub
|
||||
FolderReader folderReader = new FolderReader();
|
||||
FolderNode folderNode = folderReader.reader("D:/bootstrap");
|
||||
//folderReader.print(folderNode);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.platform.test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class Volume {
|
||||
private String name;
|
||||
private long totalSize;
|
||||
private long usedSize;
|
||||
private List<Brick> bricks;
|
||||
private List<FolderNode> folderNode;
|
||||
|
||||
public Volume(String volume, long totalSize, long usedSize,
|
||||
List<Brick> bricks, List<FolderNode> folderNode) {
|
||||
super();
|
||||
this.name = volume;
|
||||
this.totalSize = totalSize;
|
||||
this.usedSize = usedSize;
|
||||
this.bricks = bricks;
|
||||
this.folderNode = folderNode;
|
||||
}
|
||||
|
||||
public String getVolume() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setVolume(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
public void setTotalSize(long totalSize) {
|
||||
this.totalSize = totalSize;
|
||||
}
|
||||
|
||||
public long getUsedSize() {
|
||||
return usedSize;
|
||||
}
|
||||
|
||||
public void setUsedSize(long usedSize) {
|
||||
this.usedSize = usedSize;
|
||||
}
|
||||
|
||||
public List<Brick> getBricks() {
|
||||
return bricks;
|
||||
}
|
||||
|
||||
public void setBricks(List<Brick> bricks) {
|
||||
this.bricks = bricks;
|
||||
}
|
||||
|
||||
public List<FolderNode> getFolderNode() {
|
||||
return folderNode;
|
||||
}
|
||||
|
||||
public void setFolderNode(List<FolderNode> folderNode) {
|
||||
this.folderNode = folderNode;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue