Merge branch 'web_backend_develope' of https://git.trustie.net/fhx569287825/aggregation-platform into develope

web_backend_develope
wu ming 8 years ago
commit bf3fcb267f

@ -17,6 +17,9 @@ jdbc.mysql.password=root
#=============================================================================================================
# hui用户名
gather-user-name=system
gather-standard-user-name=u_bzbjy
gather-standard-exec-table-name=kzxzb
gather-standard-pay-table-name=zfxxb
# 密码
gather-user-password=oracle
@ -43,7 +46,7 @@ jdbc.minEvictableIdleTimeMillis=300000
#
#==============================================================================================================
table-suffix=_20152016
extract-log-localtion=/home/web_manage/log/
gather-tablespace-name=TS_TTSSS
#dbf file's path must exist
@ -57,43 +60,53 @@ kubeMasterUrl=http://192.168.0.110:8080/
collect-user-name=system
collect-password=oracle
collect-service-name=orcl
# standard table :
# eg:sql -> select count(*) from u_bzbjy.kzxzb; select count(*) from u_bzbjy.zfxxb;
collect-user-table=u_bzbjy
collect-exec-table=kzxzb
collect-pay-table=zfxxb
gfs_control_ip=192.168.0.110
gfs_control_rootPassWd=root
HttpClientConstant_URL_IP_PORT=http://192.168.0.110:8088/jfinal/
HttpClientConstant_URL_IP_PORT=http://192.168.0.110:9001/
dataBefore=6
numOneImportExcel=12
oracle-orcl=orcl
oracle-user=system
oracle-psw=oracle
#=============================================================================================================
# 文件上传下载
# windows path
#=============================================================================================================
#file_upload_path=D:\\test\\
#extract-log-localtion=D:\\test\\log\\
#extract-standard-log-localtion=D:\\test\\log2\\
#
#file_upload_path=D:\\test\\
#file_download_path=D:\\test\\export.xlsx
#
#package_download_path=D:\\test\\
#
#package_name=sql_script_standard
#
#sql_script_path_last=D:\\test\\sql_script_last\\
#
#sql_script_path_standard=D:\\test\\sql_script_standard\\
#=============================================================================================================
# 文件上传下载
# linux path
#=============================================================================================================
file_upload_path=/excel_import_dir/
extract-log-localtion=/home/web_manage/log/
extract-standard-log-localtion=/home/web_manage/log2/
file_upload_path=/excel_import_dir/
file_download_path=/excel_export_dir/export.xlsx
package_download_path=/
package_name=DefaultDescription
sql_script_path_last=/DefaultDescription_last/
sql_script_path_standard=/DefaultDescription/

@ -4,16 +4,24 @@
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="string" type="java.lang.String" />
<typeAlias alias="EncodedInfoEntity" type="com.platform.entities.EncodedInfoEntity" />
<typeAlias alias="DataInfoEntity" type="com.platform.entities.DataInfoEntity" />
<typeAlias alias="PagerOptions" type="com.platform.entities.PagerOptions"/>
<typeAlias alias="PagerOptions" type="com.platform.form.PagerOptions"/>
<typeAlias alias="GatherOracleInfo" type="com.platform.entities.GatherOracleInfo"/>
<typeAlias alias="DataInfoEntityMoveTmp" type="com.platform.entities.DataInfoEntityMoveTmp"/>
<typeAlias alias="SystemEntity" type="com.platform.entities.SystemEntity"/>
<typeAlias alias="RegionalismEntity" type="com.platform.entities.RegionalismEntity"/>
<typeAlias alias="oracleForm" type="com.platform.entities.oracleForm"/>
<typeAlias alias="oracleForm" type="com.platform.form.oracleForm"/>
</typeAliases>
<mappers>
<plugins>
<plugin interceptor="com.platform.utils.page.PageInterceptor">
</plugin>
</plugins>
<!-- <mappers>
<mapper resource="com/dao/mapper/data-details-mapper.xml" />
<mapper resource="com/dao/mapper/config-details-mapper.xml"/>
<mapper resource="com/dao/mapper/dataInfoMoveTmpmapper.xml"/>
@ -22,4 +30,6 @@
<mapper resource="com/dao/mapper/SystemCodeMapper.xml"/>
<mapper resource="com/dao/mapper/VolumeMapper.xml"/>
</mappers>
-->
</configuration>

@ -22,6 +22,7 @@
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<!-- 读取db.properties中的属性值 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="WEB-INF/config/config.properties"></property>
@ -40,13 +41,29 @@
<property name="username" value="${jdbc.mysql.username}" />
<property name="password" value="${jdbc.mysql.password}" />
</bean>
<!-- <bean id="mySQLSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="WEB-INF/config/mybatis-applicationConfig.xml" />
<property name="dataSource" ref="mySQLDataSource" />
</bean> -->
<bean id="mySQLSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="WEB-INF/config/mybatis-applicationConfig.xml" />
<property name="dataSource" ref="mySQLDataSource" />
<property name="mapperLocations">
<list>
<value>classpath:com/dao/mapper/*apper.xml</value>
</list>
</property>
</bean>
<!-- mapper扫描器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.platform.dao,com.dao.mapper" />
<!-- 扫描包路径,如果需要扫描多个包,中间使用半角逗号隔开 -->
<property name="basePackage" value="com/platform/dao"></property>
<property name="sqlSessionFactoryBeanName" value="mySQLSessionFactory" />
</bean>
<!-- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.platform.dao" />
</bean> -->
<!-- 配置声明式事物 事物管理器 -->
<!-- 配置声明式事物 -->
<bean id="mySQLTxManager"

@ -15,6 +15,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.platform.utils.Configs;
@ -30,7 +31,7 @@ import com.platform.utils.Configs;
public class BaseController {
/** log4j */
public static Logger log = Configs.DAILY_ROLLING_LOGGER;
public final static Logger log = Logger.getLogger(BaseController.class);
/**
* <> @ExceptionHandler----
@ -42,19 +43,21 @@ public class BaseController {
*/
@ExceptionHandler
public Object exp(HttpServletRequest request, HttpServletResponse response,Exception ex) {
System.out.println("URI"+request.getRequestURI());
request.setAttribute("ex", ex);
System.err.println("BaseController --exp " + ex);
log.error("URI"+request.getRequestURI());
log.error("BaseController --exp " + ex);
new CustomException("base_code_", ex);
// 根据不同错误转向不同页面
if(ex instanceof CustomException) {
//返回异常信息
ModelMap modelMap = new ModelMap();
CustomException cuse = (CustomException) ex;
Map<String, String> errmsg = new HashMap<>();
errmsg.put("code", cuse.getCode());
errmsg.put("msg", cuse.getMsg());
log.error(cuse.getCode());
modelMap.addAllAttributes(errmsg);
response.setStatus(500);
return response;
return modelMap;
} else {
//其他错误则 调到指定页面
log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex);

@ -42,4 +42,8 @@ public class Custom4exception {
/** * MySQL错误 */
public final static String MySQL_Except = "3002002001";
//3003001
/** * 信息系统-校验-sqlserver抽取标准表 --连接不上标准表汇总库错误 */
public final static String CHECKOUT_EXTRACT_EXCEPT = "3003001001";
}

@ -7,7 +7,6 @@ import java.lang.reflect.InvocationTargetException;
import org.apache.log4j.Logger;
import com.platform.controller.DataModelController;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
@ -51,7 +50,7 @@ public class CustomException extends Exception {
* @param obj
*/
public CustomException(String code,Exception e,Object... obj) {
super(code);
// super(code);
StringBuffer sbuf= new StringBuffer();
this.code = code;
sbuf.append(code);

@ -0,0 +1,44 @@
/**
* : MyException.java
* : </>
* : <>
* @author liliy
* : <>
* 20161019
* <>
*/
package com.base;
/**
* <>
* <>
* @author liliy
* @version [20161019]
* @see [/]
* @since [/]
*/
public class MyException {
private String mess;
public MyException() {
}
/**
* <>
* <>
* @see [##]
*/
public MyException(String mess) {
// TODO Auto-generated constructor stub
setMess(mess);
}
public void setMess(String mess){
this.mess=mess;
}
public String getMess(){
return this.mess;
}
}

@ -0,0 +1,114 @@
/**
* : PostObj.java
* : </>
* : <>
* @author liliy
* : <>
* 20161018
* <>
*/
package com.base;
import java.util.List;
import java.util.Stack;
/**
* <>
* <>
* @author liliy
* @version [20161018]
* @see [/]
* @since [/]
*/
public class PostData {
private Object data;
private Stack<MyException> exceptionsStack;
/**
* <>
* <>
* @see [##]
*/
public PostData() {
// TODO Auto-generated constructor stub
exceptionsStack=new Stack<>();
}
public PostData(Object data) {
// TODO Auto-generated constructor stub
this.data=data;
exceptionsStack=new Stack<>();
}
/**
* @return the data
*/
public Object getData() {
return data;
}
/**
* @param data the data to set
*/
public void setData(Object data) {
this.data = data;
}
/**
*
* <>
* <>
* @param e
* @see [##]
*/
public void pushExceptionsStack(String mess){
MyException myException=new MyException(mess);
exceptionsStack.push(myException);
}
public void pushExceptionsStackList(List<String> messs){
if(messs==null)return;
for(String mess:messs){
MyException myException=new MyException(mess);
exceptionsStack.push(myException);
}
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public MyException popExceptionsStack(){
if (isEmptyExceptionsStack()){
return null;
}
return exceptionsStack.pop();
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public boolean isEmptyExceptionsStack(){
return exceptionsStack.empty();
}
/**
*
* <>
* <>
* @return
* @see [##]
*/
public Stack<MyException> getExceptionsStack() {
return exceptionsStack;
}
/**
* @param exceptionsStack the exceptionsStack to set
*/
public void setExceptionsStack(Stack<MyException> exceptionsStack) {
this.exceptionsStack = exceptionsStack;
}
}

@ -0,0 +1,182 @@
/**
* : TaskOperateData.java
* : </>
* : <>
* @author liliy
* : <>
* 2016112
* <>
*/
package com.base;
import java.util.ArrayList;
import java.util.List;
import com.platform.glusterfs.SetCluster;
import com.platform.utils.Constant;
import com.platform.utils.Support;
/**
* <>
*
* @author liliy
* @version [2016112]
* @see [/]
* @since [/]
*/
public class TaskOperateData {
/**
* 012MD53-1,-2:
* 4:5-3
*/
private int status = 1;
/**
*
*/
// private int taskReturn = 0;
/**
*
*/
private Long allSize = 0L;
/**
*
*/
private Long completedSize = 0L;
/**
*
*/
private int progress = 0;
/**
*
*/
private String sourcePath = null;
/** 目的路径 */
private String destPath = null;
/**
*
*/
private String removeDataName = null;
/**
*
*/
private String startTime = null;
/** 结束时间 */
private String endTime = null;
/**
* @return the status
*/
public int getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(int status) {
this.status = status;
}
/**
* @return the allSize
*/
public Long getAllSize() {
return allSize;
}
/**
* @param allSize the allSize to set
*/
public void setAllSize(Long allSize) {
this.allSize = allSize;
}
/**
* @return the completedSize
*/
public Long getCompletedSize() {
return completedSize;
}
/**
* @param completedSize the completedSize to set
*/
public void setCompletedSize(Long completedSize) {
this.completedSize = completedSize;
}
/**
* @return the progress
*/
public int getProgress() {
return progress;
}
/**
* @param progress the progress to set
*/
public void setProgress(int progress) {
this.progress = progress;
}
/**
* @return the sourcePath
*/
public String getSourcePath() {
return sourcePath;
}
/**
* @param sourcePath the sourcePath to set
*/
public void setSourcePath(String sourcePath) {
this.sourcePath = sourcePath;
}
/**
* @return the destPath
*/
public String getDestPath() {
return destPath;
}
/**
* @param destPath the destPath to set
*/
public void setDestPath(String destPath) {
this.destPath = destPath;
}
/**
* @return the removeDataName
*/
public String getRemoveDataName() {
return removeDataName;
}
/**
* @param removeDataName the removeDataName to set
*/
public void setRemoveDataName(String removeDataName) {
this.removeDataName = removeDataName;
}
/**
* @return the startTime
*/
public String getStartTime() {
return startTime;
}
/**
* @param startTime the startTime to set
*/
public void setStartTime(String startTime) {
this.startTime = startTime;
}
/**
* @return the endTime
*/
public String getEndTime() {
return endTime;
}
/**
* @param endTime the endTime to set
*/
public void setEndTime(String endTime) {
this.endTime = endTime;
}
}

@ -8,4 +8,7 @@
3002001003=\u8FDE\u63A5\u6C47\u603B-\u521B\u5EFAoracle\u8FDE\u63A5\u5931\u8D25
#3002002
3002002001=MySQL\u9519\u8BEF
3002002001=MySQL\u9519\u8BEF
#3003001
3003001001=\u8FDE\u63A5\u4E0D\u4E0A\u6807\u51C6\u8868\u6C47\u603B\u5E93

@ -15,10 +15,11 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<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="type" column="type" 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
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,type type
</sql>
<select id="selectAllOracle" resultType="com.platform.entities.GatherOracleInfo">
@ -59,6 +60,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
service_status,
</if>
<if test="type != null and type != ''">
type,
</if>
</trim>
)
VALUES(
@ -90,6 +94,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
#{status},
</if>
<if test="type != null and type != ''">
#{type},
</if>
</trim>
)
</insert>
@ -133,6 +140,9 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="status != null and status != ''">
service_status= #{status},
</if>
<if test="type != null and type != ''">
type= #{type},
</if>
<if test="remove != null and remove != ''">
remove= #{remove},
</if>
@ -142,5 +152,30 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
id = #{id}
</where>
</update>
<update id="updateAllOracle" parameterType="com.platform.entities.GatherOracleInfo">
UPDATE
services_info
<set >
<trim suffixOverrides=",">
<if test="type != null and type != ''">
type= #{type},
</if>
</trim>
</set>
</update>
<update id="updateAllOracleExceptId" parameterType="com.platform.entities.GatherOracleInfo">
UPDATE
services_info
<set >
<trim suffixOverrides=",">
<if test="type != null and type != ''">
type= #{type},
</if>
</trim>
</set>
<where>
id != #{id}
</where>
</update>
</mapper>

@ -5,51 +5,36 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<mapper namespace="com.platform.dao.DataInfoDao">
<resultMap id="getEntityByText" type="com.platform.entities.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="extractStatus" column="extract_status" jdbcType="INTEGER" />
<id property="id" column="id"/>
<result property="regionalismCode" column="regionalism_code"/>
<result property="cityName" column="city_name"/>
<result property="districtName" column="district_name"/>
<result property="systemCode" column="system_code"/>
<result property="systemName" column="system_name"/>
<result property="dataType" column="data_type"/>
<result property="dataVersion" column="data_version"/>
<result property="submittedBatch" column="submitted_batch"/>
<result property="dataPath" column="data_path"/>
<result property="charset" column="data_charset"/>
<result property="collectingTime" column="collection_time"/>
<result property="collectorContacts" column="collector_contacts"/>
<result property="collectorName" column="collector_name"/>
<result property="extractStatus" column="extract_status"/>
<result property="year" column="data_year" javaType="string"
jdbcType="VARCHAR" />
<result property="startYear" column="start_year" javaType="string"
jdbcType="VARCHAR" />
<result property="endYear" column="end_year" javaType="string"
jdbcType="VARCHAR" />
<result property="volumeIp" column="volume_ip" javaType="string"
jdbcType="VARCHAR" />
<result property="volumePath" column="volume_path" javaType="string"
jdbcType="VARCHAR" />
<result property="mark" column="mark" javaType="string"
jdbcType="VARCHAR" />
<result property="volumePath" column="volume_path" javaType="string"
jdbcType="VARCHAR" />
<result property="mark" column="mark" javaType="string"
jdbcType="VARCHAR" />
<result property="year" column="data_year"/>
<result property="startYear" column="start_year"/>
<result property="endYear" column="end_year"/>
<result property="volumeIp" column="volume_ip"/>
<result property="volumePath" column="volume_path"/>
<result property="mark" column="mark"/>
<result property="volumePath" column="volume_path"/>
<result property="dataBaseType" column="data_base_type"/>
<result property="execResultLast" column="checkout_indicate_last"/>
<result property="payResultLast" column="checkout_pay_last"/>
<result property="standardExtractStatus" column="standard_extract_status"/>
<result property="checkoutFlag" column="checkout_flag"/>
<result property="mark" column="mark"/>
</resultMap>
<sql id="conditionsFilters">
<if test="dataType!=null">
@ -78,18 +63,21 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="dataYear !=null">
AND data_details.data_year=#{dataYear}
</if>
<if test="array !=null and array.length > 0">
<if test="dataBaseType !=null and dataBaseType !=''">
AND data_details.data_base_type=#{dataBaseType}
</if>
<if test="array !=null and array.size() != 0">
<foreach collection="array" item="item" index="index">
AND CONCAT(regionalism_code,system_code,city_name,district_name,system_name,data_year) LIKE CONCAT('%',CONCAT(#{item},'%'))
AND CONCAT(regionalism_code,system_code,city_name,district_name,system_name,data_year) LIKE CONCAT('%',CONCAT('${item}','%'))
</foreach>
</if>
</sql>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="getLimitedDataInfoEntities" parameterType="com.platform.entities.PagerOptions"
<select id="getLimitedDataInfoEntities" parameterType="com.platform.form.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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,mark
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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_flag,mark
FROM data_details
<where>
<include refid="conditionsFilters" />
@ -108,15 +96,34 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
LIMIT #{limit}
</if>
</select>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="getLimitedDataInfoByPage" parameterType="com.platform.form.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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_flag,mark
FROM data_details
<where>
<include refid="conditionsFilters" />
</where>
ORDER BY data_details.id
</select>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="findAll" 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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,mark
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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_flag,mark
FROM data_details
ORDER BY data_details.id
</select>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="findById" resultMap="getEntityByText" parameterType="java.lang.Integer">
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,extract_status,data_year,start_year,end_year,volume_ip,volume_path,data_base_type,standard_extract_status,checkout_indicate_last,checkout_pay_last,checkout_flag,mark
FROM data_details
WHERE id =#{id}
</select>
<!-- 获取数据 条件:采集时间 -->
<select id="findByParam" resultType="com.platform.entities.DataInfoEntity" parameterType="com.platform.entities.DataInfoEntity">
SELECT
@ -129,7 +136,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- 获取数据符合筛选条件的总记录条数 -->
<select id="getLimitedDataCount" resultType="java.lang.Integer"
parameterType="com.platform.entities.PagerOptions">
parameterType="com.platform.form.PagerOptions">
SELECT COUNT(id) FROM data_details
<where>
<include refid="conditionsFilters" />
@ -139,7 +146,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- 获取数据查询的起始di -->
<select id="getLimitedBeginId" resultType="java.lang.Integer"
parameterType="com.platform.entities.PagerOptions">
parameterType="com.platform.form.PagerOptions">
SELECT MAX(idx) FROM (SELECT id idx FROM data_details
ORDER BY id LIMIT 0,#{totalLimit}) AS TEMP
</select>
@ -196,6 +203,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="extractStatus > 0">
extract_status,
</if>
<if test="payResult != null and payResult != ''">
checkout_pay,
</if>
<if test="execResult != null and execResult != ''">
checkout_indicate,
</if>
<if test="startMonth != null and startMonth != ''">
start_month,
</if>
<if test="endMonth != null and endMonth != ''">
end_month,
</if>
</trim>
)
VALUES(
@ -248,6 +267,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<if test="extractStatus > 0">
#{extractStatus},
</if>
<if test="payResult != null and payResult != ''">
#{payResult},
</if>
<if test="execResult != null and execResult != ''">
#{execResult},
</if>
<if test="startMonth != null and startMonth != ''">
#{startMonth},
</if>
<if test="endMonth != null and endMonth != ''">
#{endMonth},
</if>
</trim>
)
</insert>

@ -61,7 +61,8 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
b.data_version dataVersion,b.submitted_batch submittedBatch,b.data_path dataPath,b.data_charset charset,
b.collection_time collectingTime,b.collector_name collectorName,b.collector_contacts collectorContacts,
b.data_year year,b.extract_status extractStatus,b.start_year startYear,b.end_year endYear,
b.volume_ip volumeIp,b.volume_path volumePath
b.volume_ip volumeIp,b.volume_path volumePath,b.checkout_pay payResult,b.checkout_indicate execResult,
b.start_month startMonth,b.end_month endMonth
FROM
move_data_tmp a LEFT JOIN data_details b
ON a.system_code = b.system_code AND a.regionalism_code = b.regionalism_code AND a.fkid = b.id
@ -78,6 +79,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<where>
a.id = #{id}
</where>
for update
</select>
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">

@ -108,7 +108,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- sql txt find_city_Column_List -->
<sql id="find_city_Column_List">
d.id dataId,a.area_code areaCode,a.city_name cityName,a.district_name districtName,a.system_name sysName,a.sys_code sysCode,a.area_level areaLevel,a.sys_version sysVersion,a.begin_in_use beginUseTime,a.function_details functionDetails,
d.standard_extract_status standardExtractStatus,d.extract_status extractStatus,d.data_year year,d.data_path path,d.id dataId,a.area_code areaCode,a.city_name cityName,a.district_name districtName,a.system_name sysName,a.sys_code sysCode,a.area_level areaLevel,a.sys_version sysVersion,a.begin_in_use beginUseTime,a.function_details functionDetails,
a.department_manager departmentManager,a.manager_contacts managerContacts,a.sys_developer_full_name developerFullName,a.data_base_type dataBaseType,a.data_base_version dataBaseVersion,
a.is_budget_exec budgetExecManage,a.is_budget_quota budgetQuotaManage,a.is_collection collection,a.is_department_budget departmentBudgetManage,a.total_budget_account totalBudgetAccount,
a.final_account_manage finalAccountManage,a.report_form_manage reportFormManage,a.non_tax_revenue_manage nonTaxManage,a.wage_system wageSystem,
@ -117,7 +117,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
</sql>
<!-- 获取数据符合筛选条件的全部记录信息 -->
<select id="getLimitedDataInfoEntities" parameterType="com.platform.entities.PagerOptions"
<select id="getLimitedDataInfoEntities" parameterType="com.platform.form.PagerOptions"
resultMap="getEntityByText">
SELECT
<include refid="Base_Column_List" />
@ -145,7 +145,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- 获取数据符合筛选条件的总记录条数 -->
<select id="getLimitedDataCount" resultType="java.lang.Integer"
parameterType="com.platform.entities.PagerOptions">
parameterType="com.platform.form.PagerOptions">
SELECT COUNT(id) FROM standard_data_details
<where>
<include refid="conditionsFilters" />
@ -155,7 +155,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
<!-- 获取数据查询的起始di -->
<select id="getLimitedBeginId" resultType="java.lang.Integer"
parameterType="com.platform.entities.PagerOptions">
parameterType="com.platform.form.PagerOptions">
SELECT MAX(idx) FROM (SELECT id idx FROM standard_data_details
ORDER BY id LIMIT 0,#{totalLimit}) AS TEMP
</select>
@ -196,8 +196,10 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
SELECT
<include refid="find_city_Column_List" />
FROM standard_data_details a left join collection_data_description l on a.area_code=l.regionalism_code AND a.sys_code=l.sys_code
left join data_info d on a.area_code=d.regionalism_code AND a.sys_code=d.system_code
WHERE a.is_collection='是' AND a.city_name=#{cityName}
left join data_info d on a.area_code=d.regionalism_code AND a.sys_code=d.system_code AND d.remove='0'
<where>
a.is_collection='是' AND a.city_name=#{cityName}
</where>
ORDER BY a.area_code,a.sys_code,d.data_version
</select>

@ -1,6 +1,5 @@
package com.platform.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -13,14 +12,12 @@ import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.PreDataInfo;
import com.platform.service.ICheckoutService;
import com.platform.utils.Configs;
/** --
* @author chen
@ -29,14 +26,14 @@ import com.platform.utils.Configs;
@Controller
@RequestMapping("/checkout")
public class CheckoutController extends BaseController {
@SuppressWarnings("static-access")
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(CheckoutController.class);
//日志
public final static Logger log = Logger.getLogger(CheckoutController.class);
@Resource(name = "checkoutService")
private ICheckoutService checkoutService;
/**
*
* ----
* @return
* @throws Exception
*/
@ -52,7 +49,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -68,7 +65,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -79,7 +76,6 @@ public class CheckoutController extends BaseController {
if (null != form) {
log.info("---------/checkList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.checkAll(form);
List<CheckoutEntity> data = new ArrayList<CheckoutEntity>();
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
@ -90,7 +86,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -111,7 +107,7 @@ public class CheckoutController extends BaseController {
}
/**
*
* ---- ->
* @return
* @throws Exception
*/
@ -137,4 +133,48 @@ public class CheckoutController extends BaseController {
}
return modelMap;
}
/**
* ----
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/deleteList")
public ModelMap deleteList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/deleteList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.deleteAll(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
else {
log.info("---------/deleteList--- "+ form);
}
return modelMap;
}
/** ----sqlserver
* @param form
* @param req
* @param res
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/extractList")
public ModelMap extractList(@RequestBody List<CheckoutEntity> form, HttpServletRequest req, HttpServletResponse res) throws Exception {
ModelMap modelMap = new ModelMap();
if (null != form) {
log.info("---------/extractList--- "+ form.size());
List<CheckoutEntity> result = checkoutService.extractSqlServer(form);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", result.size());
}
else {
log.info("---------/extractList--- "+ form);
}
return modelMap;
}
}

@ -1,8 +1,6 @@
package com.platform.controller;
import java.beans.IntrospectionException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -13,8 +11,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
@ -30,23 +26,21 @@ import com.base.BaseController;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.PagerOptions;
import com.platform.entities.VolumeEntity;
import com.platform.entities.oracleForm;
import com.platform.entities.volumeMoveForm;
import com.platform.http.gfs.HttpUtils;
import com.platform.form.PagerOptions;
import com.platform.form.oracleForm;
import com.platform.form.volumeMoveForm;
import com.platform.http.HttpUtils;
import com.platform.service.DataInfoService;
import com.platform.service.ICodeService;
import com.platform.service.IGfsService;
import com.platform.service.ILogRead;
import com.platform.service.IMoveDataService;
import com.platform.service.IMySqlService;
import com.platform.service.IGatherOracleService;
import com.platform.service.IOracleExtractService;
import com.platform.service.IVolumeService;
import com.platform.service.OracleStatusService;
import com.platform.service.thread.ThreadExtractOracle;
import com.platform.service.thread.ThreadGainOracleConnect;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.UtilsHelper;
@ -57,26 +51,47 @@ import com.platform.utils.UtilsHelper;
@Controller
public class DataModelController extends BaseController {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(DataModelController.class);
public static Logger log = Logger.getLogger(DataModelController.class);
/**
* --
*/
@Resource(name = "dataInfoService")
private DataInfoService dfs;
@Resource(name = "gfsService")
private IGfsService gfsService;
/**
* gfs
*/
@Resource(name = "volumeService")
private IVolumeService volumeService;
/**
* mysql
*/
@Resource(name = "mySqlService")
private IMySqlService mySqlService;
private IGatherOracleService mySqlService;
/**
* oracle
*/
@Resource(name = "OracleExtract")
private IOracleExtractService OracleExtract;
/**
*
*/
@Resource(name = "moveDataService")
private IMoveDataService moveDataService;
/**
* code
*/
@Resource(name = "codeService")
private ICodeService codeService;
/**
*
*/
@Resource(name = "logReadService")
private ILogRead logReadService;
@ -84,10 +99,17 @@ public class DataModelController extends BaseController {
this.dfs = dfs;
}
/** --
* @param res
* @param req
* @return
* @throws UnsupportedEncodingException
*/
@RequestMapping("/data.json")
@ResponseBody
public ModelMap getAllDataToJson(HttpServletRequest res,
HttpServletResponse req) throws UnsupportedEncodingException {
log.info("-----------/data.json-----------");
res.setCharacterEncoding("UTF-8");
Map<String, String[]> paramMap = res.getParameterMap();
Set<String> keySet = paramMap.keySet();
@ -102,15 +124,21 @@ public class DataModelController extends BaseController {
sb.append(str).append(":").append("null").append(",");
}
}
Configs.CONSOLE_LOGGER.info(sb.deleteCharAt(sb.length() - 1)
log.info(sb.deleteCharAt(sb.length() - 1)
.append("}").toString());
PagerOptions pagerOptions = (PagerOptions) UtilsHelper
.newObjAndSetAttrsByClass(PagerOptions.class, params);
pagerOptions.setCurrentPageNum(Integer.valueOf(params.get("currentPageNum")));
//冷热区查询字段mark
pagerOptions.setMark(pagerOptions.getVolumeType());
pagerOptions.setMark(pagerOptions.getVolumeType().trim());
return dfs.getPagerTableData(pagerOptions);
}
/** --
* @param res
* @param req
* @throws Exception
*/
@RequestMapping(value = "/delete/data", method = RequestMethod.POST)
public void deleteData(HttpServletRequest res, HttpServletResponse req)
throws Exception {
@ -121,6 +149,11 @@ public class DataModelController extends BaseController {
req.setStatus(200);
}
/** oracle
* @param res
* @param req
* @throws UnsupportedEncodingException
*/
@RequestMapping("/connectOracle")
public void connectOracle(HttpServletRequest res, HttpServletResponse req)
throws UnsupportedEncodingException {
@ -129,19 +162,24 @@ public class DataModelController extends BaseController {
String[] oraclesName = paramMap.get("oracleName");
if (oraclesName != null)
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("执行连接\t" + rcName);
log.info("执行连接\t" + rcName);
String cmd = "kubectl label --overwrite rc " + rcName
+ " status=0";
List<String> rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String string : rList)
sb.append(string).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
log.info(sb.toString());
new OracleStatusService().connectToOracle(rcName);
}
req.setStatus(200);
}
/** oracle
* @param res
* @param req
* @throws UnsupportedEncodingException
*/
@RequestMapping("/cancelOracleConection")
public void cancelOracleConnection(HttpServletRequest res,
HttpServletResponse req) throws UnsupportedEncodingException {
@ -151,18 +189,60 @@ public class DataModelController extends BaseController {
String operate = paramMap.get("operation")[0];
if (null != oraclesName) {
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("取消连接:\t" + rcName);
log.info("取消连接:\t" + rcName);
new OracleStatusService().cancelToOracle(rcName, operate);
}
}
req.setStatus(200);
}
/** gfs volume
* @return
* @throws Exception
*/
@RequestMapping(value = "/volume/list", method = RequestMethod.POST)
@ResponseBody
public String volumeList() throws Exception {
log.debug("-----/volume/list------");
String rest = volumeService.getAllvolume();
return rest;
}
/**
* @param res
* @param req
* @param form
* @throws Exception
*/
@RequestMapping(value = "/volume/{name}/move", method = RequestMethod.POST)
@ResponseBody
public void volumeMove(HttpServletRequest res, HttpServletResponse req,
@RequestBody volumeMoveForm form) throws Exception {
List<DataInfoEntity> datas = new ArrayList<DataInfoEntity>();
List<DataInfoEntity> selectItems = form.getSelectItems();
if (null == selectItems) {
req.setStatus(200);
return;
}
datas.addAll(selectItems);
log.debug("------/volume/{name}/move--------");
if (datas.size() > 0) {
moveDataService.moveData(datas, form.getSelectNode());
}
req.setStatus(200);
}
/** oracle
* @param res
* @param req
* @param form
* @throws Exception
*/
@RequestMapping(value = "/oracle/{name}/extract", method = RequestMethod.POST)
public void oracleExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
// res.setCharacterEncoding("UTF-8");
@RequestBody oracleForm form) throws Exception {
log.error("/oracle/{name}/extract");
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
@ -190,93 +270,44 @@ public class DataModelController extends BaseController {
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
thExtra.start();
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
// form.getTarget());
}
}
// public void oracleExtract(HttpServletRequest res,
// HttpServletResponse req, String name, @RequestBody GatherOracleInfo
// gather, @RequestBody List<OracleConnectorParams> collectOracles)
// throws Exception {
// // res.setCharacterEncoding("UTF-8");
// log.debug("------extract-------");
// // Map<String, String[]> paramMap = res.getParameterMap();
// // log.debug(paramMap);
// // //汇总库 对象信息--带有tableName-
// // String[] nodes = paramMap.get("target");
// // Map map = null;
// // for (String string : nodes) {
// // JSONObject jsonobject = JSONObject.fromObject(string);
// // map = jsonobject;
// // System.out.println(map);
// // }
// //
// // // 采集库对象--(多个采集库抽取到1个汇总库的1个tableName下)
// // String[] inneed = paramMap.get("inneed");
// // List<Map<String, String>> colleclist = new
// ArrayList<Map<String,String>>();
// // for (String string : nodes) {
// // JSONObject jsonobject = JSONObject.fromObject(string);
// // Map inneedMap = jsonobject;
// // colleclist.add(inneedMap);
// // }
// OracleExtract.extractOracle(name, collectOracles, gather);
// }
@RequestMapping(value = "/volume/list", method = RequestMethod.POST)
@ResponseBody
public String volumeList() throws Exception {
HttpUtils ht = new HttpUtils();
log.debug("-----/volume/list------");
//List<VolumeEntity> result = gfsService.getAllVolumes();
String rest = ht.sendPost("gfs/getAllvolume", null);
// List<VolumeEntity> result = null;
// if (null != rest) {
// System.out.println(rest);
// JSONArray jsondata = JSONArray.fromObject(rest);
// result = (ArrayList<VolumeEntity>) JSONArray.toCollection(jsondata, VolumeEntity.class);
// }
return rest;
}
@RequestMapping(value = "/volume/{name}/move", method = RequestMethod.POST)
@ResponseBody
public void volumeMove(HttpServletRequest res, HttpServletResponse req,
@RequestBody volumeMoveForm form) throws Exception {
List<DataInfoEntity> datas = new ArrayList<DataInfoEntity>();
List<DataInfoEntity> selectItems = form.getSelectItems();
if (null == selectItems) {
req.setStatus(200);
return;
}
datas.addAll(selectItems);
log.debug("------/volume/{name}/move--------");
if (datas.size() > 0) {
moveDataService.moveData(datas, form.getSelectNode());
}
req.setStatus(200);
}
/** oracle
* @return
* @throws Exception
*/
@RequestMapping(value = "/oracle/list", method = RequestMethod.POST)
@ResponseBody
public List<GatherOracleInfo> oracleList() throws Exception {
log.debug("----------getOracleInfo-----------------------");
List<GatherOracleInfo> result = mySqlService.findAllMySql();
List<GatherOracleInfo> result = mySqlService.findAllOracle();
return result;
}
/** oracle
* @param req
* @param res
* @param id
* @throws Exception
*/
@RequestMapping(value = "/oracle/{id}/delete", method = RequestMethod.POST)
public void oracleDelete(HttpServletRequest req, HttpServletResponse res,
@PathVariable String id) throws Exception {
log.debug("----------deleteOracleInfo----------------");
Integer num = Integer.valueOf(id);
Integer result = mySqlService.deleteMySql(num);
Integer result = mySqlService.deleteOracle(num);
log.info("oracleDelete : " + result);
res.setStatus(200);
}
/** oracle
* @param res
* @param req
* @param id
* @param oracle
* @throws Exception
*/
@RequestMapping(value = "/oracle/{id}/insert", method = RequestMethod.POST)
@ResponseBody
public void oracleInsert(HttpServletRequest res, HttpServletResponse req,
@ -288,6 +319,13 @@ public class DataModelController extends BaseController {
req.setStatus(200);
}
/** oracle
* @param res
* @param req
* @param id
* @param oracle
* @throws Exception
*/
@RequestMapping(value = "/oracle/{id}/update", method = RequestMethod.POST)
@ResponseBody
public void oracleUpdate(HttpServletRequest res, HttpServletResponse req,
@ -299,6 +337,10 @@ public class DataModelController extends BaseController {
req.setStatus(200);
}
/**
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/transfer/list", method = RequestMethod.POST)
@ResponseBody
public Object taskTransferList() throws Exception {
@ -307,6 +349,13 @@ public class DataModelController extends BaseController {
return result;
}
/**
* @param res
* @param req
* @param id
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/transfer/{id}/delete", method = RequestMethod.POST)
@ResponseBody
public Object taskTransferDelete(HttpServletRequest res,
@ -319,17 +368,28 @@ public class DataModelController extends BaseController {
return result;
}
/**
* @param res
* @param req
* @param move
* @return
* @throws Exception
*/
@RequestMapping(value = "/task/transfer/save", method = RequestMethod.POST)
@ResponseBody
public Object taskTransferSave(HttpServletRequest res,
HttpServletResponse req, @RequestBody DataInfoEntity move)
throws Exception {
log.debug("---------/task/transfer/save-----------------------");
int result = dfs.save(move);
// int result = dfs.save(move);
req.setStatus(200);
return result;
return 1;
}
/** code
* @return
* @throws Exception
*/
@RequestMapping(value = "/code/list", method = RequestMethod.POST)
@ResponseBody
public Object findCodeList() throws Exception {
@ -338,15 +398,21 @@ public class DataModelController extends BaseController {
return result;
}
/** oracle
* @param name
* @param res
* @param req
* @return
* @throws Exception
*/
@RequestMapping(value = "/oracle/extract/log", method = RequestMethod.POST)
@ResponseBody
public Object getExtractLog(@RequestParam("rcName") String name,
HttpServletRequest res, HttpServletResponse req) throws Exception {
log.info("---------/oracle/extract/log-------------------");
String result = logReadService.readLog(name);
// StringBuilder sb = new StringBuilder();
// sb.append("查看相应日志").append("\n").append("看到了");
Map<String, String> log = new HashMap<>();
// "查看相应日志"
Map<String, String> log = new HashMap<String, String>();
log.put(name, result);
return log;
}

@ -15,19 +15,28 @@ import com.platform.utils.Configs;
@Controller
public class DefaultController {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(DefaultController.class);
public final static Logger log = Logger.getLogger(DefaultController.class);
/**
* @param req
* @param res
* @return
*/
@RequestMapping("/")
public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){
//处理不匹配的请求
System.out.println("index");
log.info("index");
return new ModelAndView("index");
}
/**
* @param req
* @param res
* @return
*/
@RequestMapping("/test")
public ModelMap test(HttpServletRequest req, HttpServletResponse res){
//System.out.println(Class.class.getClass().getResource("/").getPath());
System.out.println(Configs.EXTRACT_LOG_LOCALTION);
log.info(Configs.EXTRACT_LOG_LOCALTION);
return new ModelMap();
}

@ -3,26 +3,24 @@ package com.platform.controller;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
@ -42,18 +40,20 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;
import com.base.BaseController;
import com.platform.entities.PagerOptions;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.platform.entities.PreDataInfo;
import com.platform.entities.ResumableInfo;
import com.platform.entities.ResumableInfoStorage;
import com.platform.form.PagerOptions;
import com.platform.service.IPreDataInfoService;
import com.platform.service.IScriptMakeService;
import com.platform.utils.Configs;
import com.platform.utils.FileOperateHelper;
import com.platform.utils.HttpUtils;
import com.platform.utils.ThreadRemoveFile;
import com.platform.utils.UtilsHelper;
/** --excel
/** --excel
* @author chen
*
*/
@ -61,13 +61,24 @@ import com.platform.utils.UtilsHelper;
@RequestMapping("/fileOperation")
public class ExcelController extends BaseController{
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(ExcelController.class);
private static ObjectMapper mapper = new ObjectMapper();
/**
*
*/
public final static Logger log = Logger.getLogger(ExcelController.class);
/**
* ----
*/
@Resource(name = "preDataInfoService")
private IPreDataInfoService preDataInfoService;
// 文件上传处理函数
/** ----
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
public void upload(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@ -97,9 +108,9 @@ public class ExcelController extends BaseController{
// Save to file
InputStream is = request.getInputStream();
long readed = 0;
long content_length = request.getContentLength();
long contentLength = request.getContentLength();
byte[] bytes = new byte[1024 * 100];
while (readed < content_length) {
while (readed < contentLength) {
int r = is.read(bytes);
if (r < 0) {
break;
@ -117,7 +128,6 @@ public class ExcelController extends BaseController{
log.info(info.resumableFilename);
ResumableInfoStorage.getInstance().remove(info);
response.getWriter().print("All finished.");
//开始导入excel
} else {
response.getWriter().print("Upload");
@ -128,7 +138,12 @@ public class ExcelController extends BaseController{
log.info("----");
}
// 文件下载处理函数
/** ----(excel)
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping(value = "/file/download")
public ResponseEntity<byte[]> download(HttpServletRequest request,
HttpServletResponse response) throws Exception {
@ -136,7 +151,6 @@ public class ExcelController extends BaseController{
preDataInfoService.exportExcel(Configs.FILE_DOWNLOAD_PATH);
File file = new File(Configs.FILE_DOWNLOAD_PATH);
// System.out.println(Configs.FILE_DOWNLOAD_PATH);
if (file.exists()) {
HttpHeaders headers = new HttpHeaders();
String fileName = new String(file.getName().getBytes("UTF-8"),
@ -152,7 +166,12 @@ public class ExcelController extends BaseController{
}
}
// 文件上传处理函数
/**
* @param request
* @return
* @throws ServletException
* @throws IOException
*/
private ResumableInfo getResumableInfo(HttpServletRequest request)
throws ServletException, IOException {
String base_dir = Configs.FILE_UPLOAD_PATH;
@ -185,6 +204,12 @@ public class ExcelController extends BaseController{
return info;
}
/** ----
* @param res
* @param req
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findByParam")
public ModelMap findByParam(HttpServletRequest res, HttpServletResponse req) throws Exception {
@ -215,6 +240,10 @@ public class ExcelController extends BaseController{
return modelMap;
}
/** ----
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping("/findAll")
public ModelMap findAll() throws Exception {
@ -225,30 +254,34 @@ public class ExcelController extends BaseController{
return modelMap;
}
/** ----excel
* @param request
* @param response
* @param fileNameList
* @return
* @throws Exception
*/
@ResponseBody
@RequestMapping(produces = "application/json", value = "/importExcel", method = RequestMethod.POST)
public ModelMap importExcel(HttpServletRequest request,
HttpServletResponse response, @RequestBody String fileNameList) throws Exception {
log.info("---importExcel---" + fileNameList);
JSONArray jsonArray = JSONArray.fromObject(fileNameList);
List<String> jsonlist = (List<String>) JSONArray.toCollection(jsonArray, String.class);
List<String> jsonlist = mapper.readValue(fileNameList, new TypeReference<List<String>>() {});
// JavaType javaType = mapper.getTypeFactory().constructParametricType(List.class, String.class);
// JSONArray jsonArray = JSONArray.fromObject(fileNameList);
// List<String> jsonlist = (List<String>) JSONArray.toCollection(jsonArray, String.class);
ModelMap modelMap = new ModelMap();
if (null == jsonlist && jsonlist.size() > 0) {
// System.err.println(request.getParameter("fileNameList"));
if (null == jsonlist || jsonlist.size() == 0) {
modelMap.addAttribute("returncode","3002");
return modelMap;
}
log.info(jsonlist.size());
List<String> listPath = new ArrayList<String>();
// 末尾 含有 /(linux)
Pattern pattern2 = Pattern.compile("\\/$");
Matcher matcher2 = pattern2.matcher(Configs.FILE_UPLOAD_PATH);
// 加上 最后 的 /
String dirPath = Configs.FILE_UPLOAD_PATH;
if (!matcher2.find()) {
dirPath = dirPath + File.separator;
}
String dirPath = FileOperateHelper.addLastSeparator(Configs.FILE_UPLOAD_PATH);;
for (String p : jsonlist) {
listPath.add(dirPath + p);
}
@ -257,7 +290,7 @@ public class ExcelController extends BaseController{
//导入
result = preDataInfoService.importExcel(listPath);
//失败
if (result.containsKey("fileUnExist") || result.containsKey("areaUnImport")) {
if (result.containsKey("fileUnExist")/* || result.containsKey("areaUnImport")*/) {
modelMap.addAttribute("data", result);
modelMap.addAttribute("code","3001");
response.setStatus(500);
@ -285,6 +318,7 @@ public class ExcelController extends BaseController{
//删除失败时--启用线程去删除
new ThreadRemoveFile(failedDelete).start();
}
log.info("success : "+modelMap);
return modelMap;
}
@ -296,11 +330,10 @@ public class ExcelController extends BaseController{
if(multipartResolver.isMultipart(request)){
//再将request中的数据转化成multipart类型的数据
MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request;
Iterator iter = multiRequest.getFileNames();
Iterator<String> iter = multiRequest.getFileNames();
while(iter.hasNext()){
//这里的name为fileItem的alias属性值相当于form表单中name
String name=(String)iter.next();
// System.out.println("name:"+name);
String name= iter.next();
//根据name值拿取文件
MultipartFile file = multiRequest.getFile(name);
if(file != null){
@ -310,14 +343,12 @@ public class ExcelController extends BaseController{
if(!localFile.getParentFile().exists()) {
//如果目标文件所在的目录不存在,则创建父目录
localFile.getParentFile().mkdirs();
// System.out.println("parent:"+localFile.getParentFile().getPath());
}
//写文件到本地
try {
file.transferTo(localFile);
} catch (IOException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
log.error(e.getStackTrace());
}
}

@ -29,16 +29,25 @@ import com.platform.service.IScriptMakeService;
import com.platform.utils.Configs;
import com.platform.utils.ZipCompressUtils;
/** --
* @author chen
*
*/
@Controller
@RequestMapping("/filePackage")
public class FilePackageController extends BaseController {
@SuppressWarnings("static-access")
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(FilePackageController.class);
public static Logger log = Logger.getLogger(FilePackageController.class);
@Resource(name = "scriptMakeService")
private IScriptMakeService scriptMakeService;
/** ----
* @param request
* @param response
* @return
* @throws Exception
*/
@RequestMapping("/download")
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
HttpServletResponse response) throws Exception {
@ -46,14 +55,14 @@ public class FilePackageController extends BaseController {
scriptMakeService.makeCfg();
scriptMakeService.makeXml();
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
System.out.println(filePath + Configs.PACKAGE_NAME);
log.info(filePath + Configs.PACKAGE_NAME);
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
filePath + "package.zip"); // 产生压缩文件
File file = new File(filePath + "package.zip");
if (file.exists()) {
HttpHeaders headers = new HttpHeaders();
String fileName = new String(file.getName());// 为了解决中文名称乱码问题
System.out.println(fileName);
log.info(fileName);
headers.setContentDispositionFormData("attachment", fileName);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(
@ -67,7 +76,7 @@ public class FilePackageController extends BaseController {
}
}
/**
*
* ----
* @return
* @throws Exception
*/
@ -83,7 +92,7 @@ public class FilePackageController extends BaseController {
}
/**
*
* ----
* @param type
* @param data
* @param res
@ -98,16 +107,12 @@ public class FilePackageController extends BaseController {
log.info("---------/readSqlFile------------------");
ModelMap modelMap = new ModelMap();
Map<String, Object> result = scriptMakeService.readSql(type, data);
// StringBuilder sb = new StringBuilder();
// sb.append("查看相应日志").append("\n").append("看到了");
// modelMap.addAttribute("data1", result.get("data1").toString());
// modelMap.addAttribute("data2", result.get("data2").toString());
modelMap.addAllAttributes(result);
return modelMap;
}
/**
*
* ----
* @param type
* @param opt
* @param form
@ -129,4 +134,61 @@ public class FilePackageController extends BaseController {
modelMap.addAttribute("length", results.size());
return modelMap;
}
/**
* ----
* @param type
* @param opt
* @param form
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(value = "/totalOnholeSqlFile", method = RequestMethod.POST)
@ResponseBody
public ModelMap totalOnholeSqlFile(@RequestBody List<SqlFileInfoEntity> forms,
HttpServletRequest req, HttpServletResponse res) throws Exception {
log.info("--------- /totalOnholeSqlFile --- " + forms +" "+ forms.size());
ModelMap modelMap = new ModelMap();
if (forms.size() > 0) {
Map<String, Object> result = scriptMakeService.totalOnholeSqlFile(forms);
if (result.containsKey("nosqlfile")) {
modelMap.addAllAttributes(result);
}
}
List<SqlFileInfoEntity> results = scriptMakeService.findAllFiles();
modelMap.addAttribute("data", results);
modelMap.addAttribute("length", results.size());
return modelMap;
}
/**
* ----
* @param type
* @param opt
* @param form
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(value = "/totalVerifySqlFile", method = RequestMethod.POST)
@ResponseBody
public ModelMap totalVerifySqlFile(@RequestBody List<SqlFileInfoEntity> forms,
HttpServletRequest req, HttpServletResponse res) throws Exception {
log.info("--------- /totalVerifySqlFile --- " + forms +" "+ forms.size());
ModelMap modelMap = new ModelMap();
if (forms.size() > 0) {
Map<String, Object> result = scriptMakeService.totalVerifySqlFile(forms);
if (result.containsKey("nosqlfile")) {
modelMap.addAllAttributes(result);
res.setStatus(500);
}
}
List<SqlFileInfoEntity> results = scriptMakeService.findAllFiles();
modelMap.addAttribute("data", results);
modelMap.addAttribute("length", results.size());
return modelMap;
}
}

@ -2,33 +2,16 @@
package com.platform.controller;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import oracle.sql.DATE;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.base.BaseController;
import com.base.CustomException;
import com.platform.entities.GfsFolderEntity;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo;
import com.platform.entities.VolumeDataEntity;
import com.platform.service.IGfsService;
import com.platform.utils.Configs;
/**
@ -42,37 +25,43 @@ import com.platform.utils.Configs;
@Controller
@RequestMapping("")
public class FolderController extends BaseController {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(FolderController.class);
public static Logger log = Logger.getLogger(FolderController.class);
@Resource(name = "gfsService")
private IGfsService gfsService;
/**
* @param path
* @return
* @throws Exception
*/
@RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST)
public Object getAllSubPathByPath(String path) throws Exception {
System.out.println(path);
log.info(path);
Object result = null;
if (null != path && !"".equals(path)) {
System.out.println(path);
log.info(path);
result = gfsService.getFolder(path);
}
return result;
}
/**
* @param srcpath
* @param dstPath
* @param name
* @return
* @throws Exception
*/
@RequestMapping("/copyFolder")
public Object copyFolder(String srcpath, String dstPath, String name) throws Exception {
// -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right
int result = 0;
// int result = gfsService.copyFolder(srcpath, dstPath, name);
System.out.println(srcpath);
System.out.println(dstPath);
log.info(srcpath);
log.info(dstPath);
String obj = "right";
if (1 != result) {
@ -81,23 +70,6 @@ public class FolderController extends BaseController {
return obj;
}
// /**
// * <一句话功能简述> 查询集群中所有的 volume 及其 信息
// * <功能详细描述>
// * @return
// * @throws Exception
// * @see [类、类#方法、类#成员]
// */
// @RequestMapping(value="/volume/list", method= RequestMethod.POST)
// public Object getVolums() throws Exception{
// System.out.println("----------------------------------");
// long a = new Date().getTime();
// List<VolumeEntity> result = gfsService.getAllVolumes();
// System.out.println("----------------------------------");
// System.out.println(new Date().getTime()-a);
// return result;
// }
//
/**
* <> volume
* <>
@ -106,12 +78,10 @@ public class FolderController extends BaseController {
* @throws Exception
* @see [##]
*/
@RequestMapping(value="/volume/findByName", method= RequestMethod.POST)
public Object getVolumByName(String volumeName) throws Exception{
VolumeEntity result = gfsService.getOneVolume(volumeName);
log.info(volumeName);
VolumeDataEntity result = gfsService.getOneVolume(volumeName);
return result;
}
}

@ -0,0 +1,137 @@
package com.platform.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.dao.GatherOracleDao;
import com.platform.entities.GatherOracleInfo;
import com.platform.form.oracleForm;
import com.platform.service.ILogRead;
import com.platform.service.IOracleExtractService;
import com.platform.service.thread.ThreadExtractStandardOracle;
import com.platform.service.thread.ThreadGainOracleConnect;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
/** oracle
* @author chen
*
*/
@Controller
public class OracleController extends BaseController {
/**
*
*/
public final static Logger log = Logger.getLogger(OracleController.class);
/**
* oracle
*/
@Resource(name = "OracleExtract")
private IOracleExtractService OracleExtract;
/**
* oracle
*/
@Resource(name = "logReadService")
private ILogRead logReadService;
/**
* oracle
*/
@Resource(name = "gatherOracleDao")
private GatherOracleDao gatherOracleDao;
/** oracle
* @param res
* @param req
* @param form
* @throws Exception
*/
@RequestMapping(value = "/oracle/standardextract/{name}/extract", method = RequestMethod.POST)
public void oracleStandardExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
log.info("/oracle/standardextract/{name}/extract");
log.info(form.getInneed().get(0).getName());
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
// 汇总库的信息
GatherOracleInfo oracleInfo = null;
List<GatherOracleInfo> oracleConnects = gatherOracleDao.selectAllOracle();
for (GatherOracleInfo info : oracleConnects) {
//抽取标准表的汇总库
if (Constant.ORACLE_EXTRACT_TYPE_ONE.equals(info.getType())) {
oracleInfo = info;
break;
}
}
if (null == oracleInfo) {
isConnect = false;
}
else {
form.setTarget(oracleInfo);
ThreadGainOracleConnect thOrcl = new ThreadGainOracleConnect(form, OracleExtract);
thOrcl.start();
for (int i = 0; i < 10; i++) {
Thread.sleep(400);
isConnect = thOrcl.isConnect();
if (isConnect) {
break;
}
else {
if (thOrcl.isExcept()) {
break;
}
Thread.sleep(100);
}
}
}
}
if (isConnect)
req.setStatus(200);
else
req.setStatus(500);
// 开始抽取数据到汇总库
if (isConnect && null != form.getInneed() && form.getInneed().size() > 0) {
ThreadExtractStandardOracle thExtra = new ThreadExtractStandardOracle(form, OracleExtract);
thExtra.start();
}
}
/** sqlserveroracle
* @param name
* @param res
* @param req
* @return
* @throws Exception
*/
@RequestMapping(value = "/standardextract/log", method = RequestMethod.POST)
@ResponseBody
public Object getStandardExtractLog(@RequestParam("rcName") String name,
HttpServletRequest res, HttpServletResponse req) throws Exception {
Configs.CONSOLE_LOGGER.info("/StandardExtract/log");
String result = logReadService.readStandardLog(name);
// StringBuilder sb = new StringBuilder();
// sb.append("查看相应日志").append("\n").append("看到了");
Map<String, String> log = new HashMap<String, String>();
log.put(name, result);
return log;
}
}

@ -17,8 +17,6 @@ import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.platform.utils.Configs;
/**
* <>
@ -35,23 +33,19 @@ import com.platform.utils.Configs;
@Controller
public class SetGlusterfsController {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(SetGlusterfsController.class);
public final static Logger log = Logger.getLogger(SetGlusterfsController.class);
@RequestMapping("/tes")
public Object defaultHandler(HttpServletRequest req, HttpServletResponse request) {
//<EFBFBD><EFBFBD><EFBFBD><><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//测试
try {
System.out.println("fsdfds");
log.info("fsdfds");
return "listAll";
} catch (Exception e) {
e.printStackTrace();
log.error(e);
return "result";
}
}
}

@ -12,12 +12,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.utils.Configs;
@Controller
public class TaskModelController extends BaseController{
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(TaskModelController.class);
public static Logger log = Logger.getLogger(TaskModelController.class);
@RequestMapping("/task/transfer/list")
@ResponseBody

@ -12,30 +12,43 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeForm;
import com.platform.entities.VolumeInitEntity;
import com.platform.http.gfs.HttpUtils;
import com.platform.entities.VolumeDataEntity;
import com.platform.http.gfs.SetVolume;
import com.platform.service.IVolumeService;
import com.platform.utils.Configs;
import com.platform.utils.ThreadVolume;
import com.platform.utils.ThreadVolumeImm;
/** gfs
* @author chen
*
*/
@Controller
public class VolumeController extends BaseController{
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(VolumeController.class);
public static Logger log = Logger.getLogger(VolumeController.class);
/**
* gfs
*/
@Resource(name = "volumeService")
private IVolumeService volumeService;
HttpUtils ht = new HttpUtils();
/**
* volumeClient
*/
SetVolume volumeClient = new SetVolume();
/** volume
* @param res
* @param req
* @param form
* @return
* @throws Exception
*/
@RequestMapping(value = "/volume/update", method = RequestMethod.POST)
@ResponseBody
public String volumeUpdate(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/update");
@RequestBody VolumeDataEntity form) throws Exception {
log.error("/oracle/update");
int rest = volumeService.save(form);
if (rest == 1) {
req.setStatus(200);
@ -43,16 +56,23 @@ public class VolumeController extends BaseController{
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
String result = volumeService.getAllvolume();
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-update").start();
return result;
}
/** volume
* @param res
* @param req
* @param entity
* @return
* @throws Exception
*/
@RequestMapping(value = "/volume/delete", method = RequestMethod.POST)
@ResponseBody
public String volumeDelete(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity entity) throws Exception {
Configs.CONSOLE_LOGGER.error("/volume/delete");
@RequestBody VolumeDataEntity entity) throws Exception {
log.error("/volume/delete");
int rest = volumeService.delete(entity);
if (rest == 1) {
req.setStatus(200);
@ -60,7 +80,7 @@ public class VolumeController extends BaseController{
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
String result = volumeClient.getAllvolume();
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-delete").start();
return result;
}

@ -7,7 +7,7 @@ import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions;
import com.platform.form.PagerOptions;
@Repository(value = "dataInfoDao")
public interface DataInfoDao {
@ -17,11 +17,15 @@ public interface DataInfoDao {
int getLimitedBeginId(PagerOptions pagerOptions);
List<DataInfoEntity> getLimitedDataInfoEntities(PagerOptions pagerOptions);
List<DataInfoEntity> getLimitedDataInfoByPage(PagerOptions pagerOptions);
List<String> getIdIsExist(List<Integer> list)throws Exception;
List<DataInfoEntity> findAll()throws Exception;
DataInfoEntity findById(int id)throws Exception;
List<DataInfoEntity> findByParam(DataInfoEntity data)throws Exception;
int removes(List<Integer> list)throws Exception;

@ -35,5 +35,19 @@ public interface GatherOracleDao {
* @throws Exception
*/
public int updateOracleById(GatherOracleInfo oracle) throws Exception;
/**
* @param oracle
* @return
* @throws Exception
*/
public int updateAllOracle(GatherOracleInfo oracle) throws Exception;
/**
* @param oracle
* @return
* @throws Exception
*/
public int updateAllOracleExceptId(GatherOracleInfo oracle) throws Exception;
}

@ -7,8 +7,8 @@ import org.springframework.stereotype.Repository;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.PagerOptions;
import com.platform.entities.RegionalismEntity;
import com.platform.form.PagerOptions;
/**
* @author chen

@ -1,16 +1,12 @@
package com.platform.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.PagerOptions;
import com.platform.entities.PreDataInfo;
import com.platform.form.PagerOptions;
@Repository(value = "preDataInfoDao")
public interface PreDataInfoDao {

@ -2,11 +2,6 @@ package com.platform.entities;
public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEntity> {
/**
* dataInfo id
*/
private int dataId;
/** 验证结果 */
private String checkResult;
@ -16,34 +11,32 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
/** 执行信息表 */
private String execResult;
/** 支付信息表校验--汇总 */
/** 支付信息表校验--汇总--校验字段0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成 */
private String payResultLast;
/** 执行信息表校验--汇总 */
/** 执行信息表校验--汇总 --校验字段0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成 */
private String execResultLast;
/** 是否进行了校验 */
/** 是否进行了校验 , 0未校验1已校验,2正则校验,6正在抽取7抽取完成*/
private String checkoutFlag;
/** 数据所在的路径 */
private String path;
/** 数据年度 */
private String year;
/** 是否抽取 0标示为未汇总1标示汇总中2标示汇总完成 */
private int extractStatus;
/** 标准表抽取标记 */
private String standardExtractStatus;
/**
* -
*/
private String mark;
/**
* @return the dataId
*/
public int getDataId() {
return dataId;
}
/**
* @param dataId the dataId to set
*/
public void setDataId(int dataId) {
this.dataId = dataId;
}
/**
* @return the checkResult
*/
@ -128,6 +121,48 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
this.checkoutFlag = checkoutFlag;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the year
*/
public String getYear() {
return year;
}
/**
* @param year the year to set
*/
public void setYear(String year) {
this.year = year;
}
/**
* @return the extractStatus
*/
public int getExtractStatus() {
return extractStatus;
}
/**
* @param extractStatus the extractStatus to set
*/
public void setExtractStatus(int extractStatus) {
this.extractStatus = extractStatus;
}
/**
* @return the mark
*/
@ -142,6 +177,20 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
this.mark = mark;
}
/**
* @return the standardExtractStatus
*/
public String getStandardExtractStatus() {
return standardExtractStatus;
}
/**
* @param standardExtractStatus the standardExtractStatus to set
*/
public void setStandardExtractStatus(String standardExtractStatus) {
this.standardExtractStatus = standardExtractStatus;
}
/** 按checkResult的状态排序 */
@Override
public int compareTo(CheckoutEntity arg0) {
@ -151,4 +200,14 @@ public class CheckoutEntity extends PreDataInfo implements Comparable<CheckoutEn
return 1;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append(this.getId()).append(",").append(this.getDataId()).append(",").append(this.getAreaCode())
.append(this.getCityName()).append(",").append(this.getDistrictName()).append(",").append(this.getSysName()).append(",").append(this.getDataVersion())
.append(",").append(this.getDataBaseType()).append(",falg ").append(this.getCheckoutFlag()).append(",Exec ")
.append(this.getExecResultLast()).append(",pay ").append(this.getPayResultLast());
return sb.toString();
}
}

@ -37,6 +37,9 @@ public class DataInfoEntity {
private String volumeType;
/** 数据库类型 */
private String dataBaseType;
private String mark;
/** 支付信息表校验--采集 */
@ -54,6 +57,15 @@ public class DataInfoEntity {
/** 是否进行了校验 */
private String checkoutFlag;
/** 起始月份 */
private String startMonth;
/** 结束月份 */
private String endMonth;
/** 是否进行了抽取 */
private String standardExtractStatus;
public DataInfoEntity() {
}
@ -298,6 +310,20 @@ public class DataInfoEntity {
this.mark = mark;
}
/**
* @return the dataBaseType
*/
public String getDataBaseType() {
return dataBaseType;
}
/**
* @param dataBaseType the dataBaseType to set
*/
public void setDataBaseType(String dataBaseType) {
this.dataBaseType = dataBaseType;
}
/**
* @return the payResult
*/
@ -368,6 +394,48 @@ public class DataInfoEntity {
this.checkoutFlag = checkoutFlag;
}
/**
* @return the standardExtractStatus
*/
public String getStandardExtractStatus() {
return standardExtractStatus;
}
/**
* @param standardExtractStatus the standardExtractStatus to set
*/
public void setStandardExtractStatus(String standardExtractStatus) {
this.standardExtractStatus = standardExtractStatus;
}
/**
* @return the startMonth
*/
public String getStartMonth() {
return startMonth;
}
/**
* @param startMonth the startMonth to set
*/
public void setStartMonth(String startMonth) {
this.startMonth = startMonth;
}
/**
* @return the endMonth
*/
public String getEndMonth() {
return endMonth;
}
/**
* @param endMonth the endMonth to set
*/
public void setEndMonth(String endMonth) {
this.endMonth = endMonth;
}
@Override
public String toString() {
return "id=" + this.id + " ,regionalismCode=" + this.regionalismCode

@ -28,7 +28,7 @@ public class DefaultDataDescription {
private String sys_description;
private String sys_develope;
private String sys_developer;
private String database;
@ -239,15 +239,15 @@ public class DefaultDataDescription {
/**
* @return the sys_develope
*/
public String getSys_develope() {
return sys_develope;
public String getSys_developer() {
return sys_developer;
}
/**
* @param sys_develope the sys_develope to set
*/
public void setSys_develope(String sys_develope) {
this.sys_develope = sys_develope;
public void setSys_developer(String sys_develope) {
this.sys_developer = sys_develope;
}
/**
@ -449,7 +449,7 @@ public class DefaultDataDescription {
sys_description = pre.getFunctionDetails();
sys_develope = pre.getDeveloperFullName();
sys_developer = pre.getDeveloperFullName();
database = pre.getDataBaseType();

@ -8,6 +8,8 @@ public class GatherOracleInfo extends OracleConnectorParams {
private String suffix;
private String type;
private int id;
private String remove;
@ -55,6 +57,20 @@ public class GatherOracleInfo extends OracleConnectorParams {
this.suffix = suffix;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
public int getId() {
return id;
}

@ -7,6 +7,8 @@ public class PreDataInfo {
private int id;
private int dataId;
private int sysCode;
private String updateTime;
@ -132,6 +134,21 @@ public class PreDataInfo {
public void setId(int id) {
this.id = id;
}
/**
* @return the dataId
*/
public int getDataId() {
return dataId;
}
/**
* @param dataId the dataId to set
*/
public void setDataId(int dataId) {
this.dataId = dataId;
}
/**
* @return the sysCode
*/

@ -1,6 +1,6 @@
package com.platform.entities;
public class SqlFileInfoEntity{
public class SqlFileInfoEntity implements Comparable<SqlFileInfoEntity> {
private int id;
@ -20,23 +20,38 @@ public class SqlFileInfoEntity{
/** 数据库类型 */
private String dataBaseType;
/** 状态 (含义,操作) -> 0有缺失上传 1 (正常,查看); 2待归档归档 3 (待审核,审核) */
private int userTableStatus;
private String userTableScriptPathLast;
private String userTableStatusPathLast;
private String userTableStatusLastModified;
private String userTableScriptPathStandard;
private String userTableStatusPathStandard;
private String userTableStatusStandardModified;
/** 状态 (含义,操作) -> 0有缺失上传 1 (正常,查看); 2待归档归档 3 (待审核,审核) */
private int ckPayStatus;
private String ckPayScriptPathLast;
private String ckPayStatusPathLast;
private String ckPayScriptPathStandard;
private String ckPayStatusLastModified;
private String ckPayStatusPathStandard;
private String ckPayStatusStandardModified;
/** 状态 (含义,操作) -> 0有缺失上传 1 (正常,查看); 2待归档归档 3 (待审核,审核) */
private int ckIndicateStatus;
private String ckIndicateScriptPathLast;
private String ckIndicateStatusPathLast;
private String ckIndicateStatusLastModified;
private String ckIndicateScriptPathStandard;
private String ckIndicateStatusPathStandard;
private String ckIndicateStatusStandardModified;
/**
* @return the id
@ -181,85 +196,85 @@ public class SqlFileInfoEntity{
/**
* @return the userTableScriptPathLast
*/
public String getUserTableScriptPathLast() {
return userTableScriptPathLast;
public String getUserTableStatusPathLast() {
return userTableStatusPathLast;
}
/**
* @param userTableScriptPathLast the userTableScriptPathLast to set
*/
public void setUserTableScriptPathLast(String userTableScriptPathLast) {
this.userTableScriptPathLast = userTableScriptPathLast;
public void setUserTableStatusPathLast(String userTableStatusPathLast) {
this.userTableStatusPathLast = userTableStatusPathLast;
}
/**
* @return the userTableScriptPathStandard
*/
public String getUserTableScriptPathStandard() {
return userTableScriptPathStandard;
public String getUserTableStatusPathStandard() {
return userTableStatusPathStandard;
}
/**
* @param userTableScriptPathStandard the userTableScriptPathStandard to set
*/
public void setUserTableScriptPathStandard(String userTableScriptPathStandard) {
this.userTableScriptPathStandard = userTableScriptPathStandard;
public void setUserTableStatusPathStandard(String userTableStatusPathStandard) {
this.userTableStatusPathStandard = userTableStatusPathStandard;
}
/**
* @return the ckPayScriptPathLast
*/
public String getCkPayScriptPathLast() {
return ckPayScriptPathLast;
public String getCkPayStatusPathLast() {
return ckPayStatusPathLast;
}
/**
* @param ckPayScriptPathLast the ckPayScriptPathLast to set
*/
public void setCkPayScriptPathLast(String ckPayScriptPathLast) {
this.ckPayScriptPathLast = ckPayScriptPathLast;
public void setCkPayStatusPathLast(String ckPayStatusPathLast) {
this.ckPayStatusPathLast = ckPayStatusPathLast;
}
/**
* @return the ckPayScriptPathStandard
*/
public String getCkPayScriptPathStandard() {
return ckPayScriptPathStandard;
public String getCkPayStatusPathStandard() {
return ckPayStatusPathStandard;
}
/**
* @param ckPayScriptPathStandard the ckPayScriptPathStandard to set
*/
public void setCkPayScriptPathStandard(String ckPayScriptPathStandard) {
this.ckPayScriptPathStandard = ckPayScriptPathStandard;
public void setCkPayStatusPathStandard(String ckPayStatusPathStandard) {
this.ckPayStatusPathStandard = ckPayStatusPathStandard;
}
/**
* @return the ckIndicateScriptPathLast
*/
public String getCkIndicateScriptPathLast() {
return ckIndicateScriptPathLast;
public String getCkIndicateStatusPathLast() {
return ckIndicateStatusPathLast;
}
/**
* @param ckIndicateScriptPathLast the ckIndicateScriptPathLast to set
*/
public void setCkIndicateScriptPathLast(String ckIndicateScriptPathLast) {
this.ckIndicateScriptPathLast = ckIndicateScriptPathLast;
public void setCkIndicateStatusPathLast(String ckIndicateStatusPathLast) {
this.ckIndicateStatusPathLast = ckIndicateStatusPathLast;
}
/**
* @return the ckIndicateScriptPathStandard
*/
public String getCkIndicateScriptPathStandard() {
return ckIndicateScriptPathStandard;
public String getCkIndicateStatusPathStandard() {
return ckIndicateStatusPathStandard;
}
/**
* @param ckIndicateScriptPathStandard the ckIndicateScriptPathStandard to set
*/
public void setCkIndicateScriptPathStandard(String ckIndicateScriptPathStandard) {
this.ckIndicateScriptPathStandard = ckIndicateScriptPathStandard;
public void setCkIndicateStatusPathStandard(String ckIndicateStatusPathStandard) {
this.ckIndicateStatusPathStandard = ckIndicateStatusPathStandard;
}
/**
@ -276,4 +291,98 @@ public class SqlFileInfoEntity{
return ckIndicateStatus;
}
/**
* @return the userTableLastModified
*/
public String getUserTableStatusLastModified() {
return userTableStatusLastModified;
}
/**
* @param userTableLastModified the userTableLastModified to set
*/
public void setUserTableStatusLastModified(String userTableStatusLastModified) {
this.userTableStatusLastModified = userTableStatusLastModified;
}
/**
* @return the userTableStandardModified
*/
public String getUserTableStatusStandardModified() {
return userTableStatusStandardModified;
}
/**
* @param userTableStandardModified the userTableStandardModified to set
*/
public void setUserTableStatusStandardModified(String userTableStatusStandardModified) {
this.userTableStatusStandardModified = userTableStatusStandardModified;
}
/**
* @return the ckPayLastModified
*/
public String getCkPayStatusLastModified() {
return ckPayStatusLastModified;
}
/**
* @param ckPayLastModified the ckPayLastModified to set
*/
public void setCkPayStatusLastModified(String ckPayStatusLastModified) {
this.ckPayStatusLastModified = ckPayStatusLastModified;
}
/**
* @return the ckPayStandardModified
*/
public String getCkPayStatusStandardModified() {
return ckPayStatusStandardModified;
}
/**
* @param ckPayStandardModified the ckPayStandardModified to set
*/
public void setCkPayStatusStandardModified(String ckPayStatusStandardModified) {
this.ckPayStatusStandardModified = ckPayStatusStandardModified;
}
/**
* @return the ckIndicateLastModified
*/
public String getCkIndicateStatusLastModified() {
return ckIndicateStatusLastModified;
}
/**
* @param ckIndicateLastModified the ckIndicateLastModified to set
*/
public void setCkIndicateStatusLastModified(String ckIndicateStatusLastModified) {
this.ckIndicateStatusLastModified = ckIndicateStatusLastModified;
}
/**
* @return the ckIndicateStandardModified
*/
public String getCkIndicateStatusStandardModified() {
return ckIndicateStatusStandardModified;
}
/**
* @param ckIndicateStandardModified the ckIndicateStandardModified to set
*/
public void setCkIndicateStatusStandardModified(String ckIndicateStatusStandardModified) {
this.ckIndicateStatusStandardModified = ckIndicateStatusStandardModified;
}
/** 按checkResult的状态排序 */
@Override
public int compareTo(SqlFileInfoEntity arg0) {
if (this.getSysStatus() < arg0.getSysStatus())
return 1;
else
return -1;
}
}

@ -22,7 +22,7 @@ import java.util.List;
* @since [/]
*/
public class VolumeEntity {
public class VolumeDataEntity {
/** volume总大小 */
private Double allSize;
@ -43,6 +43,7 @@ public class VolumeEntity {
/** volume树形目录 */
private List<FolderNode> folder = new ArrayList<FolderNode>();
// private FolderNode folder = new FolderNode();
/** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>();
@ -146,6 +147,13 @@ public class VolumeEntity {
this.folder = folder;
}
/**
* @return the status
*/
public Boolean getStatus() {
return status;
}
/**
* @return the brick
*/

@ -2,6 +2,10 @@ package com.platform.entities;
import java.util.List;
/** Mysql
* @author chen
*
*/
public class VolumeInitEntity {
private int id;

@ -1,14 +1,33 @@
package com.platform.entities;
package com.platform.form;
import java.util.List;
public class PagerOptions {
private Integer currentPageNum = 1; //当前页码
import com.platform.utils.page.Page;
/** form
* @author chen
*
*/
public class PagerOptions extends Page{
// private Integer currentPageNum = 1; //当前页码
// private Integer totalLimit; //当前页前面已有多少条数据
private Integer priorTableSize; //前一次操作一页显示的数据条数
// private Integer limit; //一次查询返回记录条数
private String dataType; //数据类型
private String submittedBatch; //数据批次
private String cityName; //城市名称
/**
*
*/
private String dataBaseType;
private String districtName; //区县名
@ -17,30 +36,16 @@ public class PagerOptions {
private String systemName; //系统名称
private String dataYear; // 数据年度
private Integer limit; //一次查询返回记录条数
private Integer offset; // 查询偏移量起始id
private Integer totalLimit; //当前页前面已有多少条数据
private Integer priorTableSize; //前一次操作一页显示的数据条数
private String keyQuery;
//模糊查询字段
private String[] array;
private List<String> array;
private String volumeType;
//冷热区字段
private String mark;
public Integer getCurrentPageNum() {
return currentPageNum;
}
public void setCurrentPageNum(Integer currentPageNum) {
this.currentPageNum = currentPageNum;
}
public String getDataType() {
return dataType;
@ -66,6 +71,20 @@ public class PagerOptions {
this.cityName = cityName;
}
/**
* @return the dataBaseType
*/
public String getDataBaseType() {
return dataBaseType;
}
/**
* @param dataBaseType the dataBaseType to set
*/
public void setDataBaseType(String dataBaseType) {
this.dataBaseType = dataBaseType;
}
public String getDistrictName() {
return districtName;
}
@ -98,14 +117,6 @@ public class PagerOptions {
this.dataYear = dataYear;
}
public Integer getLimit() {
return limit;
}
public void setLimit(Integer limit) {
this.limit = limit;
}
public Integer getOffset() {
return offset;
}
@ -114,14 +125,6 @@ public class PagerOptions {
this.offset = offset;
}
public Integer getTotalLimit() {
return totalLimit;
}
public void setTotalLimit(Integer totalLimit) {
this.totalLimit = totalLimit;
}
public Integer getPriorTableSize() {
return priorTableSize;
}
@ -141,20 +144,20 @@ public class PagerOptions {
* @param keyQuery the keyQuery to set
*/
public void setKeyQuery(String keyQuery) {
this.keyQuery = keyQuery;
this.keyQuery = keyQuery == null ? null: keyQuery.trim();
}
/**
* @return the array
*/
public String[] getArray() {
public List<String> getArray() {
return array;
}
/**
* @param array the array to set
*/
public void setArray(String[] array) {
public void setArray(List<String> array) {
this.array = array;
}

@ -1,5 +1,8 @@
package com.platform.form;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import com.platform.entities.SqlFileInfoEntity;
public class ScriptForm {
@ -19,6 +22,17 @@ public class ScriptForm {
* @param content the content to set
*/
public void setContent(String content) {
// Properties pro = System.getProperties();
// String osName = pro.getProperty("os.name");
// try {
// if("Linux".equals(osName)||"linux".equals(osName)){
// this.content = new String(content.getBytes("iso-8859-1"),"UTF-8");
// }
// else {
// this.content = new String(content.getBytes("iso-8859-1"),"GBK");
// }
// } catch (UnsupportedEncodingException e) {
// }
this.content = content;
}

@ -1,8 +1,11 @@
package com.platform.entities;
package com.platform.form;
import java.util.ArrayList;
import java.util.List;
import com.platform.entities.Brick;
import com.platform.entities.FolderNode;
public class VolumeForm {
//
// List<VolumeEntity> volumes;

@ -1,7 +1,10 @@
package com.platform.entities;
package com.platform.form;
import java.util.List;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
public class oracleForm {
private GatherOracleInfo target;

@ -1,7 +1,14 @@
package com.platform.entities;
package com.platform.form;
import java.util.List;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.FolderNode;
/**--volume
* @author chen
*
*/
public class volumeMoveForm {
private String name;

@ -1,23 +1,18 @@
package com.platform.glusterfs;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
import com.platform.utils.Constant;
import com.platform.utils.GanymedSSH;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* volume <>
@ -255,7 +250,7 @@ public class VolumeInfo {
*/
public List<String> getVolumeMountPoint(String volumeName) {
// log.info("get volume MountPoint");
List<String> mountPoints = new ArrayList<>();
List<String> mountPoints = new ArrayList<String>();
String cmd=Constant.df + "|grep " + volumeName + "|awk '{print $6}'";
List<String> reStrings = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
// System.out.println(reStrings);
@ -300,7 +295,7 @@ public class VolumeInfo {
*/
public Map<String, Double> getVolumebricksDataSize(String volumeName) {
List<String> bricks = getVolumeBricks(volumeName);
Map<String, Double> brick_size = new HashMap<>();
Map<String, Double> brick_size = new HashMap<String, Double>();
if (bricks == null) {
return null;
}
@ -340,7 +335,7 @@ public class VolumeInfo {
*/
public Map<String, Double> getVolumebricksAvailableSize(String volumeName) {
List<String> bricks = getVolumeBricks(volumeName);
Map<String, Double> brick_size = new HashMap<>();
Map<String, Double> brick_size = new HashMap<String, Double>();
if (bricks == null) {
return null;
}

@ -0,0 +1,14 @@
package com.platform.http;
/** http
* @author chen
*
*/
public class HttpClientConstant {
/**
* gfs web IP
*/
public static String URL_IP_PORT = "http://192.168.0.110:9001/";
}

@ -0,0 +1,214 @@
package com.platform.http;
import java.beans.IntrospectionException;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.springframework.http.HttpStatus;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.platform.utils.Bean2MapUtils;
/** http
* @author chen
*
*/
public class HttpUtils {
private static ObjectMapper mapper = new ObjectMapper();
/**
*
*/
public final static Logger log = Logger.getLogger(HttpUtils.class);
/** post json
* @param subUrl
* @param data
* @return
* @throws IOException
* @throws JsonMappingException
* @throws JsonGenerationException
*/
public String sendAjaxPost(String subUrl, Object data) throws JsonGenerationException, JsonMappingException, IOException {
String jsondata = null;
//转成json
if (null != data) {
Writer strWriter = new StringWriter();
mapper.writeValue(strWriter, data);
jsondata = strWriter.toString();
}
return sendAjaxPost(subUrl, jsondata);
}
/** post
* @param subUrl
* @param map
* @return
*/
public String sendAjaxPost(String subUrl, String json) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
if (null != json && !"".equals(json)) {
// 建立一个NameValuePair数组用于存储欲传送的参数
StringEntity entity = new StringEntity(json,"UTF-8");
entity.setContentEncoding("UTF-8");
entity.setContentType("application/json");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
//接收返回值
if(respone.getStatusLine().getStatusCode() == HttpStatus.OK.value()){
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
}
} catch (Exception e) {
log.info(HttpClientConstant.URL_IP_PORT + subUrl);
log.error(e);
}
return resultStr;
}
/** post map
* @param subUrl
* @param data
* @return
*/
public String sendPost(String subUrl, Object data) {
Map<String, Object> map = null;
if (null != data) {
//转成json
try {
map = Bean2MapUtils.convertBean(data);
} catch (IllegalAccessException e) {
log.error(e);
} catch (InvocationTargetException e) {
log.error(e);
} catch (IntrospectionException e) {
log.error(e);
}
}
return sendPost(subUrl, map);
}
/** map
* @param subUrl
* @param map
* @return
*/
public String sendPost(String subUrl, Map<String, Object> map) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
if (null != map) {
// 封装数据
for (String key : map.keySet()) {
String value = "";
Object obj = map.get(key);
String type = obj.getClass().getName();
//字符串
if (type.equals("java.lang.String")) {
value = (String) obj;
}
//数组
else if(type.contains("[L")){
JSONArray jsonarr = JSONArray.fromObject(obj);
value = jsonarr.toString();
}
//集合
else if(type.contains("java.util.")){
JSONArray jsonarr = JSONArray.fromObject(obj);
value = jsonarr.toString();
}
//除字符外的 其他 基本类型
else if(type.contains("java.lang.")){
value = String.valueOf(obj);
}
//对象
else {
JSONObject jsondata = JSONObject.fromObject(obj);
value = jsondata.toString();
}
parameters.add(new BasicNameValuePair(key, value));
}
// 传参 放入 url的 form中
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters,
"UTF-8");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
} catch (Exception e) {
log.info(HttpClientConstant.URL_IP_PORT + subUrl);
log.error(e);
}
return resultStr;
}
// public static void main(String[] args) {
// HttpUtils ht = new HttpUtils();
// Volume v = new Volume("a", 200, 10, null, null);
// String rest = ht.sendPost("data/getOperateTasks", v);
// System.out.println(rest);
// Map<String, Object> m = new HashMap<String, Object>();
// m.put("a", 1);
// rest = ht.sendPost("data/getOperateTasks", m);
// System.out.println(rest);
// rest = ht.sendPost("data/getOperateTasks", null);
// System.out.println(rest);
// //
// String[] str = new String[2];
// str[1] = "1";
// str[0] = "0";
// m.put("arr", str);
//
// Volume[] vli = new Volume[2];
// vli[1] = new Volume("a", 200, 10, null, null);
// vli[0] = new Volume("a", 200, 10, null, null);
// m.put("vli", vli);
// List<Integer> num = new ArrayList<Integer>();
// num.add(2);
// m.put("num", num);
// m.put("bool", true);
// rest = ht.sendPost("data/getOperateTasks", m);
// System.out.println(rest);
// }
}

@ -0,0 +1,167 @@
/**
* : VolumeEntity.java
* : </>
* : <>
* @author chen
* : <>
* 201699
* <>
*/
package com.platform.http;
import java.util.ArrayList;
import java.util.List;
import com.platform.entities.Brick;
import com.platform.entities.FolderNode;
/**
* gfs volume
*
* @author chen
* @version [201699]
* @see [/]
* @since [/]
*/
public class VolumeEntity {
/** volume总大小 */
private double allSize;
/** volume已使用大小 */
private double usedSize;
/** volume名称 */
private String name;
/** 挂载点 */
private String path;
/** * exist正常返回状态Started,Stopped,Created */
private String status;
private String type;
/** volume数据的树形目录 */
private FolderNode folder = new FolderNode();
/** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>();
/**
* @return the allSize
*/
public double getAllSize() {
return allSize;
}
/**
* @param allSize the allSize to set
*/
public void setAllSize(double allSize) {
this.allSize = allSize;
}
/**
* @return the usedSize
*/
public double getUsedSize() {
return usedSize;
}
/**
* @param usedSize the usedSize to set
*/
public void setUsedSize(double usedSize) {
this.usedSize = usedSize;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the path
*/
public String getPath() {
return path;
}
/**
* @param path the path to set
*/
public void setPath(String path) {
this.path = path;
}
/**
* @return the status
*/
public String getStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return the type
*/
public String getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType(String type) {
this.type = type;
}
/**
* @return the folder
*/
public FolderNode getFolder() {
return folder;
}
/**
* @param folder the folder to set
*/
public void setFolder(FolderNode folder) {
this.folder = folder;
}
/**
* @return the brick
*/
public List<Brick> getBrick() {
return brick;
}
/**
* @param brick the brick to set
*/
public void setBrick(List<Brick> brick) {
this.brick = brick;
}
}

@ -0,0 +1,131 @@
package com.platform.http.gfs;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import org.apache.log4j.Logger;
import com.base.MyException;
import com.base.PostData;
import com.base.TaskOperateData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.platform.http.HttpUtils;
import com.platform.http.VolumeEntity;
import com.platform.utils.DateForm;
/**
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public class CopyData {
public static Logger log = Logger.getLogger(CopyData.class);
HttpUtils ht = new HttpUtils();
/**
* sourceFolderNamedestFolderName
* 1sourceFolderName-2 destFolderName-3
* @param sourceFolderName
* @param destFolderName
* @return
* @see [##]
*/
public int copyFolder(String sourceFolderName, String destFolderName) throws Exception{
int reslut = 0;
log.info(" copyFolder " + sourceFolderName + " --> " + destFolderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sourcePath", sourceFolderName);
map.put("destPath", destFolderName);
//请求web
String rest = ht.sendPost("data/copyData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* sourceFolderNamedestFolderName
* 1sourceFolderName-2 destFolderName-3
* @param sourceFolderName
* @param destFolderName
* @return
* @see [##]
*/
public List<TaskOperateData> operationTask() throws Exception{
List<TaskOperateData> li = new ArrayList<TaskOperateData>();
Map<String, Object> map = new HashMap<String, Object>();
Calendar c2 = Calendar.getInstance();
map.put("endTime", DateForm.date2StringBysecond(c2.getTime()));
// 时间设置为 10天 前的时间
c2.set(Calendar.DAY_OF_YEAR, c2.get(Calendar.DAY_OF_YEAR) -10);
String time = DateForm.date2StringBysecond(c2.getTime());
map.put("startTime", time);
List<Integer> typeList = new ArrayList<Integer>();
typeList.add(0);
typeList.add(1);
typeList.add(2);
typeList.add(3);
typeList.add(-1);
typeList.add(-2);
map.put("statusList", typeList);
//请求web
String rest = ht.sendPost("data/getOperateTasks", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return li;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, (new PostData(new ArrayList<TaskOperateData>()).getClass()));
li = (List<TaskOperateData>) data.getData();
//解析 PostData
if(li.size() > 0){
JSONArray jsonarr = JSONArray.fromObject(data.getData());
try {
li = gs.fromJson(jsonarr.toString(), new TypeToken<List<TaskOperateData>>(){}.getType());
} catch (Exception e) {
log.error(e);
}
}
getExcept(data);
return li;
}
/**
* @param pd
*/
private void getExcept(PostData pd) {
StringBuffer sb = new StringBuffer();
for ( MyException object : pd.getExceptionsStack()) {
sb.append(object.getMess()).append(",");
}
if (!"".equals(sb.toString())) {
log.error(sb.toString());
}
}
}

@ -1,7 +0,0 @@
package com.platform.http.gfs;
public class HttpClientConstant {
public static String URL_IP_PORT = "http://192.168.0.110:8088/jfinal/";
}

@ -1,90 +0,0 @@
package com.platform.http.gfs;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import com.platform.controller.DataModelController;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Configs;
public class HttpUtils {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(HttpUtils.class);
public String sendPost(String subUrl, Object data) {
String resultStr = "";
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(HttpClientConstant.URL_IP_PORT + subUrl);
try {
// 传参
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
if (null != data) {
// 转 map
Map<String, Object> map = Bean2MapUtils.convertBean(data);
// 转json
JSONObject jsondata = JSONObject.fromObject(map);
// 封装数据
parameters.add(new BasicNameValuePair("jsondata", jsondata
.toString()));
parameters.add(new BasicNameValuePair("type", data.getClass()
.getName()));
// 传参 放入 url的 form中
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters,
"UTF-8");
post.setEntity(entity);
}
// 发送
HttpResponse respone = client.execute(post);
HttpEntity result = respone.getEntity();
if (null != result) {
resultStr = EntityUtils.toString(result);
}
// resultMap = Bean2MapUtils.convertBean(result);
} catch (Exception e) {
System.out.println(e);
}
return resultStr;
}
// public static void main(String[] args) {
// Date d = new Date();
// HttpUtils ht = new HttpUtils();
// BaseForm1 bas = new BaseForm1();
// bas.setId("12");
// bas.setName("n12");
// String rest = ht.sendPost("gfs/getAllvolume", null);
// if (null != rest) {
// System.out.println(rest);
// JSONArray jsondata = JSONArray.fromObject(rest);
// ArrayList<VolumeEntity> fo = (ArrayList<VolumeEntity>) JSONArray.toCollection(jsondata, VolumeEntity.class);
// System.err.println(fo);
// try {
// System.err.println(Bean2MapUtils.convertBean(fo));
// } catch (IllegalAccessException | InvocationTargetException
// | IntrospectionException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// Date r = new Date();
// System.err.println(r.getTime() - d.getTime());
// }
}

@ -0,0 +1,84 @@
package com.platform.http.gfs;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.base.MyException;
import com.base.PostData;
import com.google.gson.Gson;
import com.platform.http.HttpUtils;
/**
* @author chen
*
*/
public class RemoveData {
public static Logger log = Logger.getLogger ( RemoveData.class);
HttpUtils ht = new HttpUtils();
/**
* -1 :error; 0: the filename is not exists ; 1: right
* @param folderName
* @param fileName
* @return
*/
public int deleteFolder(String folderName) throws Exception{
int reslut = 0;
log.info("start delete "+folderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("removePath", folderName);
//请求 web sendPost
String rest = ht.sendPost("data/removeData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
public int abortcopyFolder(String sourceFolderName, String destFolderName) throws Exception{
int reslut = 0;
log.info(" abortcopyFolder " + sourceFolderName + " --> " + destFolderName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("sourcePath", sourceFolderName);
map.put("destPath", destFolderName);
//请求web
String rest = ht.sendPost("data/abortCopyData", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* @param pd
*/
private void getExcept(PostData pd) {
StringBuffer sb = new StringBuffer();
for ( MyException object : pd.getExceptionsStack()) {
sb.append(object.getMess()).append(",");
}
if (!"".equals(sb.toString())) {
log.error(sb.toString());
}
}
}

@ -0,0 +1,321 @@
/**
* @author
* volumevolumevolumebrick
*/
package com.platform.http.gfs;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import org.apache.log4j.Logger;
import com.base.MyException;
import com.base.PostData;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeDataEntity;
import com.platform.http.HttpUtils;
import com.platform.http.VolumeEntity;
import com.platform.utils.BeanCopy;
public class SetVolume {
public static Logger log = Logger.getLogger(SetVolume.class);
HttpUtils ht = new HttpUtils();
/** volume
* @return json
*/
public String getAllvolume() {
List<VolumeDataEntity> datas = new ArrayList<VolumeDataEntity>();
try {
datas = getAllvolumeEntity();
} catch (Exception e) {
log.error(e);
}
if (datas.size() == 0) {
return "";
}
JSONArray jsonarr = JSONArray.fromObject(datas);
return jsonarr.toString();
}
/** volume
* @return json
*/
public List<VolumeDataEntity> getAllvolumeEntity() throws Exception{
List<VolumeDataEntity> volumeList = new ArrayList<VolumeDataEntity>();
String rest = ht.sendPost("gfs/getAllVolume", null);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return volumeList;
}
// JSONObject json = JSONObject.fromObject(rest);
Gson gs = new Gson();
PostData data = gs.fromJson(rest, (new PostData(new ArrayList<VolumeEntity>())).getClass());
List<VolumeEntity> volumes = (List<VolumeEntity>) data.getData();
if(null == volumes){
log.error("-----gfs/getAllVolume----- no volume ----");
getExcept(data);
return volumeList;
}
//解析 PostData
if(volumes.size() > 0){
JSONArray jsonarr = JSONArray.fromObject(data.getData());
try {
volumes = gs.fromJson(jsonarr.toString(), new TypeToken<List<VolumeEntity>>(){}.getType());
} catch (Exception e) {
log.error(e);
}
}
for (VolumeEntity volumeEntity : volumes) {
VolumeDataEntity entity = new VolumeDataEntity();
BeanCopy.copyBean(volumeEntity, entity, "folder", "status");
if (null != volumeEntity.getFolder()) {
List<FolderNode> fn = new ArrayList<FolderNode>();
fn.add(volumeEntity.getFolder());
entity.setFolder(fn);
if ("Started".equals(volumeEntity.getStatus())) {
entity.setStatus(true);
}
}
volumeList.add(entity);
}
getExcept(data);
return volumeList;
}
/**
* volume 1 1: ;-1brickip; -2 -3
* -4:brick ; -5 :volumeName -6 -7
*
* @param volumeName
* @param count
* @param type
* @param bricks
* @param mountPoint
* @return
* @see [##]
*/
public int createVolume(String volumeName, int count, String type, List<String> bricks, String mountPoint) throws Exception{
int reslut = 0;
log.info("Creat new volume " + volumeName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
map.put("count", count);
map.put("type", type);
map.put("bricks", bricks);
map.put("mountPoint", mountPoint);
//请求 gfs 的 web
String rest = ht.sendPost("gfs/createVolume", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* volume 1 -1volume name-2volume
* -3-4/gfsAutoMount/mountPoint.record
* @param volumeName
* @return
* @see [##]
*/
public int deleteVolume(String volumeName) throws Exception{
int reslut = 0;
log.info("delete volume " + volumeName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
//请求web
this.stopVolume(volumeName);
String rest = ht.sendPost("gfs/deleteVolume", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* volumebrick, 1 ;
* volumebrickcount
*
* @param volumeName
* @param brickName
* @param count
* @param type
* @return
* @see [##]
*/
public int addBrickVolume(String volumeName, List<String> brickName, int count, String type) throws Exception{
int reslut = 0;
StringBuffer sb = new StringBuffer();
for (String string : brickName) {
sb.append(string).append(",");
}
log.info("addBrick Volume " + volumeName+" Brick "+ sb.toString());
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
map.put("bricks", brickName);
//请求web
String rest = ht.sendPost("gfs/addBricks", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* volumebrick, 1 ;
* volumebrickcount
*
* @param volumeName
* @param brickName
* @param count
* @param type
* @return
* @see [##]
*/
public int deleteBrickVolume(String volumeName, List<String> brickName, int count, String type) throws Exception {
int reslut = 0;
StringBuffer sb = new StringBuffer();
for (String string : brickName) {
sb.append(string).append(",");
}
log.info("deleteBrick Volume " + volumeName+" Brick "+ sb.toString());
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
map.put("bricks", brickName);
//请求web
String rest = ht.sendPost("gfs/deleteBrickForce", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/*
* volume volume 0 -1
* volumevolume
*/
public int stopVolume(String volumeName) throws Exception{
int reslut = 0;
log.info("stop volume " + volumeName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
//请求web
String rest = ht.sendPost("gfs/stopVolume", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/*
* volume volume 0 -1
* volumevolume
*/
public int startVolume(String volumeName) throws Exception {
int reslut = 0;
log.info("start volume " + volumeName);
Map<String, Object> map = new HashMap<String, Object>();
map.put("volumeName", volumeName);
//请求web
String rest = ht.sendPost("gfs/startVolume", map);
if (null == rest || "".equals(rest)) {
log.error(" --- gluster is disconnect ! \n");
return 0;
}
Gson gs = new Gson();
PostData data = gs.fromJson(rest, PostData.class);
// 1 : 成功
double copyResult = (double) data.getData();
reslut = (int) copyResult;
getExcept(data);
return reslut;
}
/**
* @param pd
*/
private void getExcept(PostData pd) {
StringBuffer sb = new StringBuffer();
for ( MyException object : pd.getExceptionsStack()) {
sb.append(object.getMess()).append(",");
}
if (!"".equals(sb.toString())) {
log.error(sb.toString());
}
}
// /** json 转 对象
// * @param folds
// * @return
// */
// private List<FolderNode> setChildFolders(List<FolderNode> folds) {
// List<FolderNode> folders = null;
// if (null != folds) {
// JSONArray foldJson = JSONArray.fromObject(folds);
// folders = (List<FolderNode>)JSONArray.toCollection(foldJson, FolderNode.class);
// for (FolderNode folderNode : folders) {
// List<FolderNode> childFolds = folderNode.getChildNodes();
// //递归
// folderNode.setChildNodes(setChildFolders(childFolds));
// }
// }
// return folders;
// }
//
// /** json 转 对象
// * @param bricks
// * @return
// */
// private List<Brick> setBricks(List<Brick> bricks) {
// List<Brick> bs = null;
// if (null != bricks) {
// JSONArray bsJson = JSONArray.fromObject(bricks);
// bs = (List<Brick>)JSONArray.toCollection(bsJson, Brick.class);
// }
// return bs;
// }
}

@ -6,6 +6,8 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.log4j.Logger;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.OracleConnectorParams;
@ -13,19 +15,23 @@ import com.platform.utils.Configs;
import com.platform.utils.FileOperateHelper;
public class OracleConnector {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(OracleConnector.class);
public OracleConnector() {
}
static {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
new CustomException(Custom4exception.OracleSQL_Except, e);
e.printStackTrace();
log.error(Custom4exception.OracleSQL_Except, e);
}
}
public synchronized static Connection ConnectionBuilder(String url, String user,
public synchronized static Connection connectionBuilder(String url, String user,
String password, OracleConnectorParams oc) throws CustomException {
Connection conn=null;
try {
@ -34,7 +40,7 @@ public class OracleConnector {
Configs.CONSOLE_LOGGER.info("创建oracle连接失败: [" + e.getMessage() + "]");
if (null != oc) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
+ oc.getName()+".log", "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
}
throw new CustomException(Custom4exception.OracleSQL_Except, e);
}
@ -44,27 +50,39 @@ public class OracleConnector {
public synchronized static boolean canConnect(String url, String user, String password) {
Connection result = null;
try {
result = ConnectionBuilder(url, user, password, null);
result = connectionBuilder(url, user, password, null);
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error(Custom4exception.OracleSQL_Except, e);
}
return (null != result);
}
public synchronized static ResultSet getSQLExecResultSet(Connection conn, String sql, String filePath) {
ResultSet resultSet = null;
if (null != filePath) {
filePath = filePath.replace(".log", "");
}
Statement statement = null;
try {
Statement statement = conn
statement = conn
.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
resultSet = statement.executeQuery(sql);
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+"OK \r\n");
.fileWrite(filePath+".log", sql+ "\r\n"+"OK \r\n");
} catch (SQLException e) {
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+e.getMessage()+"\r\n");
new CustomException(Custom4exception.OracleSQL_Except, e);
.fileWrite(filePath+".log", sql+ "\r\n"+e.getMessage()+"\r\n");
log.error(Custom4exception.OracleSQL_Except, e);
}
finally{
if (null != statement) {
try {
statement.close();
} catch (SQLException e) {
log.error(Custom4exception.OracleSQL_Except, e);
}
}
}
return resultSet;
@ -74,9 +92,9 @@ public class OracleConnector {
String password, String sql, String filePath) {
ResultSet result = null;
try {
result = getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath);
result = getSQLExecResultSet(connectionBuilder(url, user, password, null), sql, filePath);
} catch (CustomException e) {
new CustomException(Custom4exception.OracleSQL_Except, e);
log.error(Custom4exception.OracleSQL_Except, e);
}
return result;
}
@ -88,19 +106,32 @@ public class OracleConnector {
* @return true:sql
*/
public synchronized static boolean execOracleSQL(Connection conn, String sql, String filePath) {
if (null != filePath) {
filePath = filePath.replace(".log", "");
}
boolean flag = false;
Statement statement = null;
try {
Statement statement = conn.createStatement();
statement.execute(sql);
flag = true;
statement = conn.createStatement();
flag =statement.execute(sql);
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+"OK \r\n");
.fileWrite(filePath+".log", sql+ "\r\n"+ flag +" \r\n");
} catch (SQLException e) {
flag = false;
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+e.getMessage()+"\r\n");
new CustomException(Custom4exception.OracleSQL_Except, e);
.fileWrite(filePath+".log", sql+ "\r\n"+e.getMessage()+"\r\n");
log.error(Custom4exception.OracleSQL_Except, e);
}
finally{
if (null != statement) {
try {
statement.close();
} catch (SQLException e) {
log.error(Custom4exception.OracleSQL_Except, e);
}
}
}
return flag;
}
/**
@ -110,20 +141,33 @@ public class OracleConnector {
* @return true:1
*/
public synchronized static boolean execUpdateOracleSQL(Connection conn, String sql, String filePath) {
if (null != filePath) {
filePath = filePath.replace(".log", "");
}
boolean flag = false;
Statement statement = null;
try {
Statement statement = conn.createStatement();
statement = conn.createStatement();
if(statement.executeUpdate(sql) > 0)
{
flag = true;
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+"OK \r\n");
.fileWrite(filePath+".log", sql+ "\r\n"+"OK \r\n");
}
} catch (SQLException e) {
flag = false;
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+e.getMessage()+"\r\n");
new CustomException(Custom4exception.OracleSQL_Except, e, sql);
.fileWrite(filePath+".log", sql+ "\r\n"+e.getMessage()+"\r\n");
log.error(Custom4exception.OracleSQL_Except, e);
}
finally{
if (null != statement) {
try {
statement.close();
} catch (SQLException e) {
log.error(Custom4exception.OracleSQL_Except, e);
}
}
}
return flag;
}

@ -1,16 +1,41 @@
package com.platform.service;
import java.util.List;
import org.springframework.ui.ModelMap;
import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions;
import com.platform.form.PagerOptions;
/**
* @author chen
*
*/
public interface DataInfoService {
/**
* @param pagerOptions
* @return
*/
public ModelMap getPagerTableData(PagerOptions pagerOptions);
/**
* @param id
* @throws Exception
*/
void deleteData(String[] id) throws Exception;
/**
* @param ids
* @throws Exception
*/
void deleteData(List<Integer> ids) throws Exception;
/**
* @param data
* @return
* @throws Exception
*/
int save(DataInfoEntity data) throws Exception;
}

@ -5,16 +5,30 @@ import java.util.List;
import com.platform.entities.EncodedInfoEntity;
/**
*
* /
*
* @author wuming
*
*/
public interface EncodeInfoService {
/**
* @param tableName
* @return
*/
public List<EncodedInfoEntity> getAllEncodeInfo(String tableName);
/** code/
* @param code
* @param tableName
* @return
*/
public int deleteEncodeByCode(String code, String tableName);
/** /
* @param code
* @param name
* @return
*/
public String getEncodeNameByCode(String code, String name);
}

@ -8,13 +8,52 @@ import com.platform.entities.PreDataInfo;
public interface ICheckoutService {
/**
* @return
* @throws Exception
*/
public List<CheckoutEntity> findAll() throws Exception;
/**
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> checkAll(List<CheckoutEntity> list) throws Exception;
/**
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> deleteAll(List<CheckoutEntity> list) throws Exception;
/**
* @param ck
* @return
* @throws Exception
*/
public int updateStandardInfo(PreDataInfo ck) throws Exception;
/**
* @param ck
* @return
* @throws Exception
*/
public Map<String, PreDataInfo> findDetail(CheckoutEntity ck) throws Exception;
/** -
* @param city
* @return
* @throws Exception
*/
public List<CheckoutEntity> findByCity(String city) throws Exception;
/** sqlserver
* @param list
* @return
* @throws Exception
*/
public List<CheckoutEntity> extractSqlServer(List<CheckoutEntity> list) throws Exception;
}

@ -17,7 +17,7 @@ import java.util.Map;
import com.platform.entities.FolderNode;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
/**
@ -31,10 +31,24 @@ import com.platform.entities.VolumeEntity;
public interface ICodeService {
/**
* @param sys
* @return
* @throws Exception
*/
public List<SystemEntity> findSystem(SystemEntity sys) throws Exception;
/**
* @param region
* @return
* @throws Exception
*/
public List<RegionalismEntity> findRegionalism(RegionalismEntity region) throws Exception;
/**
* @return
* @throws Exception
*/
public Map<String, Object> findAll() throws Exception;
}

@ -0,0 +1,35 @@
package com.platform.service;
import java.util.List;
import com.platform.entities.GatherOracleInfo;
public interface IGatherOracleService {
/**
* @return oracle
* @throws Exception
*/
public List<GatherOracleInfo> findAllOracle() throws Exception;
/** oracle
* @return
* @throws Exception
*/
public int deleteOracle(int id) throws Exception;
/** oracle
* @param oracle
* @return
* @throws Exception
*/
public int insertOracle(GatherOracleInfo oracle) throws Exception;
/** oracle
* @param oracle
* @return
* @throws Exception
*/
public int updateOracle(GatherOracleInfo oracle) throws Exception;
}

@ -1,4 +1,3 @@
/**
* : IGfsService.java
* : </>
@ -9,13 +8,10 @@
* <>
*/
package com.platform.service;
import java.util.List;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
/**
* <>
@ -48,7 +44,7 @@ public interface IGfsService {
* @see [##]
*/
public int copyFolder(List<String> srcFolders, String dstFolder, String name) throws Exception;
// public int copyFolder(List<String> srcFolders, String dstFolder, String name) throws Exception;
/**
* <> volume name \ allsize \ usedsize \ folderTree \ brick
@ -57,20 +53,32 @@ public interface IGfsService {
* @throws Exception
* @see [##]
*/
public List<VolumeEntity> getAllVolumes() throws Exception;
public List<VolumeDataEntity> getAllVolumes() throws Exception;
/**
* <>
* <> volume volume
* <>
* @return
* @throws Exception
* @see [##]
*/
public VolumeEntity getOneVolume(String volumeName) throws Exception;
public VolumeDataEntity getOneVolume(String volumeName) throws Exception;
public int moveData(String volumeName, String srcPath, String dstPath) throws Exception;
/**
* @param volumeName
* @param srcPath
* @param dstPath
* @return
* @throws Exception
*/
// public int moveData(String volumeName, String srcPath, String dstPath) throws Exception;
/**
* @param volumeName
* @param srcPath
* @return
* @throws Exception
*/
public int deleteData(String volumeName, String srcPath) throws Exception;
}

@ -2,6 +2,17 @@ package com.platform.service;
public interface ILogRead {
/**
* @param filename
* @return
* @throws Exception
*/
public String readLog(String filename) throws Exception;
/**
* @param filename
* @return
* @throws Exception
*/
public String readStandardLog(String filename) throws Exception;
}

@ -32,10 +32,25 @@ public interface IMoveDataService {
*/
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception;
/** --
* @param data
* @return
* @throws Exception
*/
public int update(DataInfoEntityMoveTmp data) throws Exception;
/** --
* @param data
* @return
* @throws Exception
*/
public int save(DataInfoEntityMoveTmp data) throws Exception;
/** --
* @param list
* @return
* @throws Exception
*/
public int insertBatch(List<DataInfoEntityMoveTmp> list) throws Exception;
}

@ -1,25 +0,0 @@
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;
}

@ -1,16 +1,12 @@
package com.platform.service;
import java.util.List;
import java.util.Map;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
public interface IOracleExtractService {
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception;
// public boolean extractOracle(String name, List<DataInfoEntity> dataInfos, Map<String, String> oracleConnect) throws Exception;
/**
* @param name
* @param dataInfo //采集库连接参数
@ -26,5 +22,15 @@ public interface IOracleExtractService {
* @throws Exception
*/
public boolean isConnectTotalOracle(GatherOracleInfo oracleConnect) throws Exception;
/**
* @param name
* @param dataInfolist
* @param oracleConnect
* @return
* @throws Exception
*/
boolean extractStandardTable(String name, List<OracleConnectorParams> dataInfolist,
GatherOracleInfo oracleConnect) throws Exception;
}

@ -3,9 +3,13 @@ package com.platform.service;
import java.util.List;
import java.util.Map;
import com.platform.entities.PagerOptions;
import com.platform.entities.PreDataInfo;
import com.platform.form.PagerOptions;
/**
* @author chen
*
*/
public interface IPreDataInfoService {
/**

@ -7,14 +7,36 @@ import com.platform.entities.SqlFileInfoEntity;
public interface IScriptMakeService {
/** cfg
* @return
* @throws Exception
*/
public int makeCfg() throws Exception;
/** xml
* @return
* @throws Exception
*/
public int makeXml() throws Exception;
/**
* @param file
* @return
* @throws Exception
*/
public int moveFiles(List<SqlFileInfoEntity> file) throws Exception;
/**
* @return
* @throws Exception
*/
public List<SqlFileInfoEntity> findAllFiles() throws Exception;
/** sql
* @param name
* @param form
* @return
*/
public Map<String, Object> readSql(String name, SqlFileInfoEntity form);
/**
@ -26,4 +48,16 @@ public interface IScriptMakeService {
*/
public Map<String, Object> handleSqlFile(String type, String opt, String content, SqlFileInfoEntity form);
/**
* @param forms
* @return
*/
public Map<String, Object> totalOnholeSqlFile(List<SqlFileInfoEntity> forms);
/**
* @param forms
* @return
*/
public Map<String, Object> totalVerifySqlFile(List<SqlFileInfoEntity> forms);
}

@ -1,16 +1,41 @@
package com.platform.service;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeInitEntity;
import com.platform.entities.VolumeDataEntity;
public interface IVolumeService {
public int save(VolumeEntity entity) throws Exception;
/** volume
* @return
* @throws Exception
*/
public String getAllvolume() throws Exception;
public int delete(VolumeEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int save(VolumeDataEntity entity) throws Exception;
public int start(VolumeEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int delete(VolumeDataEntity entity) throws Exception;
public int stop(VolumeEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int start(VolumeDataEntity entity) throws Exception;
/** volume
* @param entity
* @return
* @throws Exception
*/
public int stop(VolumeDataEntity entity) throws Exception;
}

@ -5,8 +5,9 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.apache.log4j.Logger;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector;
@ -14,6 +15,8 @@ import com.platform.utils.Configs;
import com.platform.utils.FileOperateHelper;
public class OracleExtractHelper {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(OracleExtractHelper.class);
/**
* dblink
@ -24,6 +27,7 @@ public class OracleExtractHelper {
* @return
*/
private boolean hasSameNameDBLink(Connection conn, String linkName, String filePath) {
boolean flag = false;
String sql = "SELECT * FROM ALL_DB_LINKS WHERE DB_LINK='" + linkName+"'";
ResultSet rSet = null;
@ -37,7 +41,7 @@ public class OracleExtractHelper {
} catch (Exception e) {
FileOperateHelper
.fileWrite(filePath, sql+ "\r\n"+ e.getMessage() + "\r\n连接异常 \r\n");
new CustomException(Custom4exception.threadVolume_Oracle_Except, e, rSet);
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
return flag;
}
@ -62,28 +66,25 @@ public class OracleExtractHelper {
+ ")))(CONNECT_DATA =(SERVICE_NAME =" + oc.getDatabaseName()
+ ")))\'";
if (null != oc) {
if (hasSameNameDBLink(conn, linkName, Configs.EXTRACT_LOG_LOCALTION + oc.getName())) { // 如果dblink已经存在,先删除dblink在创建dblink
if (hasSameNameDBLink(conn, linkName, Configs.EXTRACT_LOG_LOCALTION + oc.getName()+".log")) { // 如果dblink已经存在,先删除dblink在创建dblink
String deleteSql = "DROP PUBLIC DATABASE LINK "
+ linkName;
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// deleteSql+"\r\n");
//删除 dblink
if (OracleConnector.execOracleSQL(conn, deleteSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())) {
// FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
// + oc.getName(), sql+"\r\n");
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
}
} else {
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "删除已有的DBLink失败,无法创建新的DBLink!"+"\r\n");
+ oc.getName()+".log", "删除已有的DBLink失败,无法创建新的DBLink!"+"\r\n");
}
} else {
// 否则创建dblink
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper.fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(), sql);
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
}
}
}
}
@ -99,21 +100,14 @@ public class OracleExtractHelper {
public boolean createTableSpace(Connection conn, OracleConnectorParams collectOracle, GatherOracleInfo oc) {
String tmpSql = "select TABLESPACE_NAME from dba_tablespaces where TABLESPACE_NAME = '"
+ oc.getTableName() + "'";
// 存在 表空间
if (OracleConnector.execUpdateOracleSQL(conn, tmpSql, Configs.EXTRACT_LOG_LOCALTION + collectOracle.getName())) {
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// tmpSql+"\r\n");
return true;
} else {
String sql = "create tablespace " + oc.getTableName()
+ " datafile '" + Configs.GATHER_TABLESPACE_PATH
+ oc.getTableName() + ".dbf"
+ "' size 512M autoextend on next 512M maxsize unlimited";
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// sql+"\r\n");
return OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + collectOracle.getName());
}
}
@ -133,16 +127,46 @@ public class OracleExtractHelper {
String grantSql = "grant connect, resource, dba to " + strTUser;
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// sql+"\r\n");
OracleConnector.execOracleSQL(conn, grantSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// grantSql+"\r\n");
}
/**
*
*
* @param conn
* @param oc
*/
public void createOnlyUser(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
String sql = "Create user " + strTUser + " default tablespace "
+ totalOracle.getTableName() + " identified by "
+ Configs.GATHER_TABLE_PASSWORD;
String grantSql = "grant connect, resource, dba to " + strTUser;
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
OracleConnector.execOracleSQL(conn, grantSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
/**
*
*
* @param conn
* @param oc
*/
public void createTable(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = oc.getName() + totalOracle.getSuffix();
String sql = "Create table " + strTUser + " default tablespace "
+ totalOracle.getTableName() + " identified by "
+ Configs.GATHER_TABLE_PASSWORD;
String grantSql = "grant connect, resource, dba to " + strTUser;
OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
OracleConnector.execOracleSQL(conn, grantSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
}
/**
@ -164,10 +188,6 @@ public class OracleExtractHelper {
+ " and t.owner||t.table_name not in (select owner||table_name from dba_tables@LINKTO"
+ oc.getName() + " where 'data_type'='CLOB')";
ResultSet rsSet = OracleConnector.getSQLExecResultSet(conn, sql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
// FileOperateHelper
// .fileWrite(
// Configs.EXTRACT_LOG_LOCALTION + oc.getName(),
// sql+"\r\n");
try {
while (rsSet.next()) {
try {
@ -175,12 +195,11 @@ public class OracleExtractHelper {
String resultSql = rsSet.getString(1).replace(";", "");
OracleConnector.execUpdateOracleSQL(conn, resultSql, Configs.EXTRACT_LOG_LOCALTION + oc.getName());
} catch (SQLException e) {
new CustomException(Custom4exception.threadVolume_Oracle_Except, e, rsSet.getString(1));
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
}
@ -197,8 +216,119 @@ public class OracleExtractHelper {
flag = true;
} catch (SQLException e) {
flag = false;
new CustomException(Custom4exception.OracleSQL_Except, e, testSql);
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
return flag;
}
/**
* --
*
* @param conn
* @param oc
*/
public void extractStandardPayTable(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
createPay(conn, oc);
String sql = "insert into " + strTUser + "." + Configs.GATHER_STANDARD_PAY_TABLE_NAME + " select * from "
+ strTUser + "." + Configs.GATHER_STANDARD_PAY_TABLE_NAME +"@LINKTOST"
+ oc.getName();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
/** --
* @param conn
* @param collectOracle
* @param oracleModel
*/
public void extractStandardExecTable(Connection conn,
OracleConnectorParams collectOracle, GatherOracleInfo oracleModel) {
createExec(conn, collectOracle);
String strTUser = Configs.GATHER_STANDARD_USER_NAME;
String sql = "insert into " + strTUser + "." + Configs.GATHER_STANDARD_EXEC_TABLE_NAME + " select * from "
+ strTUser + "." + Configs.GATHER_STANDARD_EXEC_TABLE_NAME +"@LINKTOST"
+ collectOracle.getName();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + collectOracle.getName());
}
private void createPay(Connection conn, OracleConnectorParams oc) {
String payCmd = "CREATE TABLE u_bzbjy.zfxxb(XZQHDM Varchar(255),XZQHMC Varchar(255),PZBH Varchar(255),LYZBKZH Varchar(255),"
+ "ZFDATE Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),YWGKCS Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),"
+"XMLBCODE Varchar(255),XMLBNAME Varchar(255),ZB_NO Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+"JJFLNAME Varchar(255),ZJXZCODE Varchar(255),ZJXZNAME Varchar(255),JSBFFSNAME Varchar(255),SKR Varchar(255),SKRYH Varchar(255),"
+ "SKRZHZH Varchar(255),FKZHCODE Varchar(255),FKZHNAME Varchar(255),FKYHCODE Varchar(255),FKYHNAME Varchar(255),QSZHCODE Varchar(255),"
+ "QSZHNAME Varchar(255),QSYHCODE Varchar(255),QSYHNAME Varchar(255),JE Numeric(18,2), SFTK Varchar(255),NIAN Varchar(255),ZY Varchar(255))";
try {
OracleConnector.execOracleSQL(conn, payCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
} catch (Exception e) {
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
}
/**
* dblink
*
* @param conn
* @param oc
* dblink
*/
public void createStandardDBLink(Connection conn, OracleConnectorParams oc) {
String linkName = "LINKTOST" + oc.getName();
String sql = "CREATE PUBLIC DATABASE LINK "
+ linkName
+ " CONNECT TO "
+ oc.getUser()
+ " IDENTIFIED BY "
+ oc.getPassword()
+ " USING \'(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = "
+ oc.getIp() + ")(PORT = " + oc.getPort()
+ ")))(CONNECT_DATA =(SERVICE_NAME =" + oc.getDatabaseName()
+ ")))\'";
if (null != oc) {
if (hasSameNameDBLink(conn, linkName, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName()+".log")) { // 如果dblink已经存在,先删除dblink在创建dblink
String deleteSql = "DROP PUBLIC DATABASE LINK "
+ linkName;
//删除 dblink
if (OracleConnector.execOracleSQL(conn, deleteSql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName())) {
// OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
} else {
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
FileOperateHelper.fileWrite(Configs.EXTRACT_STANDARD_LOG_LOCALTION
+ oc.getName()+".log", "删除已有的DBLink失败,无法创建新的DBLink!"+"\r\n");
}
} else {
// 否则创建dblink
// OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
if(!OracleConnector.execOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName())){
OracleConnector.execUpdateOracleSQL(conn, sql, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}
}
}
}
private void createExec(Connection conn, OracleConnectorParams oc) {
String execCmd = "CREATE TABLE u_bzbjy.kzxzb(XZQHDM Varchar(255),XZQHMC Varchar(255),YSND Varchar(255),ZBCODE Varchar(255),ZB_ID Varchar(255),ZB_NO Varchar(255),"
+ "ZBDJLXCODE Varchar(255),ZBDJLXNAME Varchar(255),ZBLXNAME Varchar(255),DOCNO Varchar(255),ZBSM Varchar(255),ZBFWDATE Varchar(255),ZBYSLXCODE Varchar(255),"
+ "ZBYSLXNAME Varchar(255),ZBYSLYNAME Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+ "JJFLNAME Varchar(255),ZBGLCSNAME Varchar(255),SZGLCODE Varchar(255),SZGLNAME Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),GZBZ Varchar(255),"
+ "JJBZ Varchar(255),CGBZ Varchar(255),ZFFSCODE Varchar(255),ZFFSNAME Varchar(255),JZZFBZ Varchar(255),ZBJE Numeric(18,2),ZBTJJE Numeric(18,2),ZBDJJE Numeric(18,2),"
+ "ZBKYJE Numeric(18,2),ZYZFBZ Varchar(255),BZ Varchar(255))";
try {
OracleConnector.execOracleSQL(conn, execCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
} catch (Exception e) {
log.error(Custom4exception.threadVolume_Oracle_Except, e);
}
}
}

@ -15,7 +15,7 @@ public class OracleExtractService extends Thread implements Runnable {
this.ocp=ocp;
String url = "";
try {
this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
this.conn=OracleConnector.connectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
} catch (CustomException e) {
this.conn = null;
}

@ -10,14 +10,16 @@ import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.commons.lang.text.StrBuilder;
import com.platform.entities.OracleConnectorParams;
import com.platform.kubernetes.SimpleKubeClient;
import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
/** oracle10
* @author chen
*
*/
public class OracleStatusService {
private static Map<String, Timer> alliveTask = new Hashtable<String, Timer>();
public final static int EXEC_TIME = 9;// 连接多少次后不成功,取消链接

@ -1,9 +1,8 @@
package com.platform.service.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@ -11,26 +10,65 @@ import java.util.Map;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.dao.GatherOracleDao;
import com.platform.dao.PreDataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.PreDataInfo;
import com.platform.oracle.OracleConnector;
import com.platform.service.DataInfoService;
import com.platform.service.ICheckoutService;
import com.platform.service.thread.ThreadCheckoutStandardOracle;
import com.platform.service.thread.ThreadExtractStandardSqlServer;
import com.platform.utils.BeanCopy;
import com.platform.utils.CacheOracleCheckoutEntity;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
import com.platform.utils.FileOperateHelper;
/**
* @author chen
*
*/
@Service(value = "checkoutService")
public class CheckoutServiceImpl implements ICheckoutService {
/**
*
*/
public static Logger log = Logger.getLogger(CheckoutServiceImpl.class);
/**
*
*/
@Resource(name = "dataInfoService")
private DataInfoService dataInfoService;
/**
*
*/
@Resource(name = "preDataInfoDao")
private PreDataInfoDao preDataInfoDao;
/**
*
*/
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
/**
* oracle
*/
@Resource(name = "gatherOracleDao")
private GatherOracleDao gatherOracleDao;
@Override
public List<CheckoutEntity> findAll() throws Exception {
@ -81,133 +119,79 @@ public class CheckoutServiceImpl implements ICheckoutService {
}
@Override
public List<CheckoutEntity> checkAll(List<CheckoutEntity> list) throws Exception {
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
checkOne(checkoutEntity);
map.put(checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion(),checkoutEntity);
}
for (int i = 0; i < result.size(); i++) {
CheckoutEntity checkoutEntity = result.get(i);
String area_sys = checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion();
if (map.containsKey(area_sys)) {
result.set(i, map.get(area_sys));
}
}
// for (CheckoutEntity checkoutEntity : list) {
// DataInfoEntity data = new DataInfoEntity();
// checkOne(checkoutEntity);
// data.setId(checkoutEntity.getDataId());
// data.setPayResultLast(checkoutEntity.getPayResultLast());
// data.setExecResultLast(checkoutEntity.getExecResultLast());
// data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
// dataInfoDao.update(data);
// }
return result;
}
private int getMonBeforeHalfYear(int num){
num -= Configs.dataBefore;
if (num <= 0) {
num = num + 12;
}
return num;
}
private String isY(String str1, String str2) {
String r = "否";
if (null !=str2 && null !=str1 && str1.equals(str2) && "y".equals(str1.toLowerCase())) {
r = "是";
}
return r;
}
private String isY(String str1) {
if (null != str1 && "y".equals(str1.toLowerCase())) {
return "是";
}
else {
return "否";
}
}
/**
* @param ck
* @return
*/
private CheckoutEntity checkOne(CheckoutEntity ck) {
String pay = ck.getPayResult();
String exec = ck.getExecResult();
ck.setPayResultLast(isY(pay));
ck.setExecResultLast(isY(exec));
ck.setCheckResult(isY(pay, exec));
// 1已校验
ck.setCheckoutFlag("1");
return ck;
}
@Override
public List<CheckoutEntity> findByCity(String city) throws Exception {
CheckoutEntity cksql = new CheckoutEntity();
Calendar c2 = Calendar.getInstance();
// 时间设置为 半年前的时间
c2.set(Calendar.MONTH, getMonBeforeHalfYear(c2.get(Calendar.MONTH)));
String time = DateForm.date2StringByDay(c2.getTime());
cksql.setCollectingTime(time);
cksql.setCityName(city);
List<CheckoutEntity> resul = new ArrayList<CheckoutEntity>();
List<CheckoutEntity> list = preDataInfoDao.findByCity(cksql);
int length = list.size();
for (int i = 0; i < length; i++) {
CheckoutEntity preDataInfo = list.get(i);
if (null != preDataInfo.getPayResultLast() &&
preDataInfo.getPayResultLast().equals(preDataInfo.getExecResultLast()) &&
"是".equals(preDataInfo.getExecResultLast())) {
preDataInfo.setCheckResult("是");
}else if(null != preDataInfo.getPayResultLast() && null != preDataInfo.getExecResultLast() && !"-".equals(preDataInfo.getPayResultLast()) && !"-".equals(preDataInfo.getExecResultLast())){
preDataInfo.setCheckResult("否");
public List<CheckoutEntity> findByCity(String city) throws Exception {
CheckoutEntity cksql = new CheckoutEntity();
Calendar c2 = Calendar.getInstance();
// 时间设置为 半年前的时间
c2.set(Calendar.MONTH, getMonBeforeHalfYear(c2.get(Calendar.MONTH)));
String time = DateForm.date2StringByDay(c2.getTime());
cksql.setCollectingTime(time);
cksql.setCityName(city);
Map<String,CheckoutEntity> resul = new HashMap<String,CheckoutEntity>();
Map<String,CheckoutEntity> nodata = new HashMap<String,CheckoutEntity>();
List<CheckoutEntity> list = preDataInfoDao.findByCity(cksql);
int length = list.size();
// 对所有数据分析
for (int i = 0; i < length; i++) {
CheckoutEntity preDataInfo = list.get(i);
preDataInfo.setId(i);
preDataInfo.setCollUpdate(isY(preDataInfo.getCollUpdate()));
if (preDataInfo.getDataVersion() < 1) {
preDataInfo.setCollection("否");
}
if (null != preDataInfo.getCollectingTime()) {
if (c2.getTime().before(DateForm.string2DateByDay(preDataInfo.getCollectingTime()))) {
resul.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode()+"_"+preDataInfo.getDataId(), preDataInfo);
}
else {
preDataInfo.setDataId(0);
preDataInfo.setPath(null);
preDataInfo.setDataVersion(0);
preDataInfo.setExecResult(null);
preDataInfo.setExecResultLast(null);
preDataInfo.setPayResult(null);
preDataInfo.setPayResultLast(null);
preDataInfo.setCheckoutFlag(null);
preDataInfo.setCollection("否");
//data_id 已经为 0 (数据不存在时)
nodata.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode(), preDataInfo);
}
}
else{
nodata.put(preDataInfo.getAreaCode()+"_"+preDataInfo.getSysCode(), preDataInfo);
}
}
preDataInfo.setId(i);
preDataInfo.setCollUpdate(isY(preDataInfo.getCollUpdate()));
if (preDataInfo.getDataVersion() < 1) {
preDataInfo.setCollection("否");
List<String> keyList = new ArrayList<String>();
//记录 不存在数据 在 nodata的 key值
for (String nodatakey : nodata.keySet()) {
keyList.add(nodatakey);
}
if (null != preDataInfo.getCollectingTime()) {
if (c2.getTime().before(DateForm.string2DateByDay(preDataInfo.getCollectingTime()))) {
resul.add(preDataInfo);
List<CheckoutEntity> resultList = new ArrayList<CheckoutEntity>();
for (String key : resul.keySet()) {
//如果有 校验失败的结果则 为否
CheckoutEntity tmp = resul.get(key);
if(!Constant.CHECKOUT_STATUS_ZERO.equals(tmp.getPayResultLast()) && !Constant.CHECKOUT_STATUS_ZERO.equals(tmp.getExecResultLast())){
if (Constant.CHECKOUT_STATUS_FOUR.equals(tmp.getPayResultLast()) || Constant.CHECKOUT_STATUS_FOUR.equals(tmp.getExecResultLast())) {
tmp.setCheckResult(Constant.ORACLE_CHECK_REULT_ONE);
}
else if(!Constant.CHECKOUT_STATUS_TWO.equals(tmp.getPayResultLast()) && !Constant.CHECKOUT_STATUS_TWO.equals(tmp.getExecResultLast())){
tmp.setCheckResult(Constant.ORACLE_CHECK_REULT_ZERO);
}
}
resultList.add(resul.get(key));
for (String nodatakey : keyList) {
if (key.contains(nodatakey)) {
nodata.remove(nodatakey);
}
}
}
else{
resul.add(preDataInfo);
for (String key : nodata.keySet()) {
resultList.add(nodata.get(key));
}
return resultList;
}
return resul;
}
@Override
public int updateStandardInfo(PreDataInfo ck) throws Exception {
ck.setProper();
String areaCode = ck.getAreaCode();
int sysCode = ck.getSysCode();
//对比字段 -- 采集描述的 更新字段是否 改为不更新
PreDataInfo data = new CheckoutEntity();
data.setAreaCode(areaCode);
data.setSysCode(sysCode);
PreDataInfo data2 = preDataInfoDao.findLastByCode(data);
data2.setCollUpdate("n");
//对比
if (checkField(ck, data2) && checkWorkRange(ck, data2)) {
preDataInfoDao.updateCollection(data2);
}
int r = preDataInfoDao.update(ck);
return r;
}
@Override
public Map<String, PreDataInfo> findDetail(CheckoutEntity ck)
@ -259,6 +243,222 @@ public class CheckoutServiceImpl implements ICheckoutService {
map.put("data2", data2);
return map;
}
@Override
public List<CheckoutEntity> checkAll(List<CheckoutEntity> list) throws Exception {
List<CheckoutEntity> oracleList = new ArrayList<CheckoutEntity>();
List<CheckoutEntity> sqlServerList = new ArrayList<CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
if ("SQL SERVER".equals(checkoutEntity.getDataBaseType())) {
sqlServerList.add(checkoutEntity);
}
else if ("ORACLE".equals(checkoutEntity.getDataBaseType())) {
oracleList.add(checkoutEntity);
}
log.info(checkoutEntity.toString());
}
// sql Server校验
for (CheckoutEntity checkoutEntity : sqlServerList) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
DataInfoEntity data = new DataInfoEntity();
this.checkSqlServerOne(checkoutEntity);
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
}
//oracle 校验
for (CheckoutEntity checkoutEntity : oracleList) {
if (checkoutEntity.getDataId() == 0) {
continue;
}
DataInfoEntity data = new DataInfoEntity();
// 状态改为 正则校验 Constant.CHECKOUTFLAG_TWO
this.checkOracleOne(checkoutEntity);
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
String kuberTaskName = checkoutEntity.getAreaCode().toLowerCase()+"-"
+ checkoutEntity.getSysCode() + "-" + checkoutEntity.getDataVersion();
if(!CacheOracleCheckoutEntity.getCheckKeys().contains(kuberTaskName)){
CacheOracleCheckoutEntity.putCheck(kuberTaskName, checkoutEntity);
}
}
//TODO 如果 CacheOracleCheckoutEntity.getCheckKeys() 有数据则启动 kuber客户端请求尝试链接oracle并查询标准表是否存在
if ( CacheOracleCheckoutEntity.getCheckKeys().size() > 0) {
new ThreadCheckoutStandardOracle(dataInfoDao).start();
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
// Map<String, CheckoutEntity> map = new HashMap<String, CheckoutEntity>();
// for (CheckoutEntity checkoutEntity : list) {
// //校验当前的数据:
// checkOne(checkoutEntity);
// map.put(checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion(),checkoutEntity);
// }
// for (int i = 0; i < result.size(); i++) {
// CheckoutEntity checkoutEntity = result.get(i);
// String area_sys = checkoutEntity.getAreaCode()+ "_" +checkoutEntity.getSysCode()+ "_" +checkoutEntity.getDataVersion();
// if (map.containsKey(area_sys)) {
// result.set(i, map.get(area_sys));
// }
// }
return result;
}
@Override
public List<CheckoutEntity> deleteAll(List<CheckoutEntity> list)
throws Exception {
List<Integer> dataIds = new ArrayList<Integer>();
for (CheckoutEntity checkoutEntity : list) {
int dataInfoId = checkoutEntity.getDataId();
if (dataInfoId > 0) {
dataIds.add(dataInfoId);
}
}
if (dataIds.size() > 0) {
dataInfoService.deleteData(dataIds);
// 根据 dataIds 删除
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
return result;
}
@Override
public int updateStandardInfo(PreDataInfo ck) throws Exception {
ck.setProper();
String areaCode = ck.getAreaCode();
int sysCode = ck.getSysCode();
//对比字段 -- 采集描述的 更新字段是否 改为不更新
PreDataInfo data = new CheckoutEntity();
data.setAreaCode(areaCode);
data.setSysCode(sysCode);
PreDataInfo data2 = preDataInfoDao.findLastByCode(data);
data2.setCollUpdate("n");
//对比
if (checkField(ck, data2) && checkWorkRange(ck, data2)) {
preDataInfoDao.updateCollection(data2);
}
int r = preDataInfoDao.update(ck);
return r;
}
@Override
public List<CheckoutEntity> extractSqlServer(List<CheckoutEntity> list)
throws Exception {
//待抽取标准表 的 SqlServer服务的 数据列表:
List<CheckoutEntity> sqlServer = new ArrayList<CheckoutEntity>();
for (CheckoutEntity checkoutEntity : list) {
if ("SQL SERVER".equals(checkoutEntity.getDataBaseType()) && checkoutEntity.getDataId() > 0) {
sqlServer.add(checkoutEntity);
}
}
//TODO 修改sqlServer 列表对应的 数据--- payResultLast 、execResultLast-> 正在抽取
// 待抽取的集合
List<CheckoutEntity> Extractlist = new ArrayList<CheckoutEntity>();
// TODO 抽取 --- 线程
if (sqlServer.size() > 0) {
for (CheckoutEntity checkoutEntity : sqlServer) {
boolean isTract = false;
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
if(Constant.CHECKOUT_STATUS_THREE.equals(checkoutEntity.getPayResultLast())){
isTract = true;
checkoutEntity.setPayResultLast(Constant.CHECKOUT_STATUS_FIVE);
}
if(Constant.CHECKOUT_STATUS_THREE.equals(checkoutEntity.getExecResultLast())){
isTract = true;
checkoutEntity.setExecResultLast(Constant.CHECKOUT_STATUS_FIVE);
}
if (isTract) {
Extractlist.add(checkoutEntity);
}
}
// 汇总库的信息
GatherOracleInfo oracleInfo = null;
List<GatherOracleInfo> oracleConnects = gatherOracleDao.selectAllOracle();
for (GatherOracleInfo info : oracleConnects) {
//抽取标准表的汇总库
if (Constant.ORACLE_EXTRACT_TYPE_ONE.equals(info.getType())) {
oracleInfo = info;
break;
}
}
if (null != oracleInfo) {
// 如果能连接
if(OracleConnector.canConnect("jdbc:oracle:thin:@" + oracleInfo.getIp() + ":" + oracleInfo.getPort() + ":"
+ oracleInfo.getDatabaseName(), oracleInfo.getUser(), oracleInfo.getPassword())){
for (CheckoutEntity check : Extractlist) {
DataInfoEntity data = new DataInfoEntity();
data.setId(check.getDataId());
data.setPayResultLast(check.getPayResultLast());
data.setExecResultLast(check.getExecResultLast());
data.setCheckoutFlag(check.getCheckoutFlag());
try {
dataInfoDao.update(data);
} catch (Exception e) {
log.error(e);
}
}
//抽取
new ThreadExtractStandardSqlServer(oracleInfo, Extractlist, dataInfoDao).start();
}
else {
//连接不上标准表汇总库错误
throw new CustomException(Custom4exception.CHECKOUT_EXTRACT_EXCEPT, null);
}
}
}
List<CheckoutEntity> result = new ArrayList<CheckoutEntity>();
//TODO findByCity
if (list.size() > 0) {
result = findByCity(list.get(0).getCityName());
}
return result;
}
/** Configs.dataBefore
* @param num
* @return
*/
private int getMonBeforeHalfYear(int num){
num -= Configs.dataBefore;
if (num <= 0) {
num = num + 12;
}
return num;
}
private String isY(String str1, String str2) {
String r = "否";
if (null !=str2 && null !=str1 && str1.equals(str2) && "y".equals(str1.toLowerCase())) {
r = "是";
}
return r;
}
private String isY(String str1) {
if (null != str1 && "y".equals(str1.toLowerCase())) {
return "是";
}
else {
return "否";
}
}
/** true false
* @param data1
@ -300,6 +500,11 @@ public class CheckoutServiceImpl implements ICheckoutService {
return true;
}
/** data1 data2
* @param data1
* @param data2
* @return
*/
private boolean checkField(PreDataInfo data1, PreDataInfo data2) {
if (!data1.getFunctionDetails().equals(data2.getFunctionDetails())) {
return false;
@ -330,4 +535,83 @@ public class CheckoutServiceImpl implements ICheckoutService {
}
return true;
}
/** sqlServer
* @param ck
* @return
*/
private CheckoutEntity checkSqlServerOne(CheckoutEntity ck) {
//TODO 校验: sqlserver数据-查看脚本在不在? 支付standard_pay_地区_系统码.sql ?,支付standard_indicate_地区_系统码.sql ?
//TODO sqlserver校验结果记录进数据库,
String pay = ck.getPayResult();
String exec = ck.getExecResult();
ck.setCheckResult("是");
if ("y".equals(pay) || "Y".equals(pay)) {
String payFilePath = FileOperateHelper.addLastSeparator(ck.getPath())+Constant.standard_pay
+ ck.getAreaCode().toLowerCase()+"_"+ck.getSysCode()+".sql";
File f = new File(payFilePath);
if(f.exists()){
ck.setPayResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else
{
ck.setPayResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
else {
//校验结果:成功或失败 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setPayResultLast(Constant.CHECKOUT_STATUS_ONE);
}
if ("y".equals(exec) || "Y".equals(exec)) {
String execFilePath = FileOperateHelper.addLastSeparator(ck.getPath())+Constant.standard_indicate
+ ck.getAreaCode().toLowerCase()+"_"+ck.getSysCode()+".sql";
File f = new File(execFilePath);
if (f.exists()) {
ck.setExecResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else
{
ck.setExecResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
else {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setExecResultLast(Constant.CHECKOUT_STATUS_ONE);
}
// 1已校验--
ck.setCheckoutFlag(Constant.CHECKOUTFLAG_ONE);
return ck;
}
/** ORACLE
* @param ck
* @return
*/
private CheckoutEntity checkOracleOne(CheckoutEntity ck) {
//校验: Oracle数据-更改为正在校验
// Oracle校验结果记录进数据库,
String pay = ck.getPayResult();
String exec = ck.getExecResult();
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getPayResultLast())) {
//校验结果:成功或失败 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
if ("y".equals(pay) || "Y".equals(pay)) {
ck.setPayResultLast(Constant.CHECKOUT_STATUS_TWO);
}
else {
ck.setPayResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
if (Constant.CHECKOUT_STATUS_ZERO.equals(ck.getExecResultLast())){
if ("y".equals(exec) || "Y".equals(exec)) {
ck.setExecResultLast(Constant.CHECKOUT_STATUS_TWO);
}
else {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
ck.setExecResultLast(Constant.CHECKOUT_STATUS_ONE);
}
}
// 2正在校验--
ck.setCheckoutFlag(Constant.CHECKOUTFLAG_TWO);
return ck;
}
}

@ -7,18 +7,27 @@ import java.util.Map;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.platform.dao.DataInfoDao;
import com.platform.dao.IRegionalismCodeDao;
import com.platform.dao.ISystemCodeDao;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.service.ICodeService;
/** code---
* @author chen
*
*/
@Service(value = "codeService")
public class CodeServiceImpl implements ICodeService {
/**
*
*/
public final static Logger log = Logger.getLogger(CodeServiceImpl.class);
@Resource(name = "systemCodeDao")
private ISystemCodeDao systemCodeDao;
@ -32,7 +41,7 @@ public class CodeServiceImpl implements ICodeService {
result = new ArrayList<SystemEntity>();
result = systemCodeDao.findSubSystemByCode(sys);
} catch (Exception e) {
// TODO: handle exception
log.error(e);
}
return result;
}
@ -43,7 +52,7 @@ public class CodeServiceImpl implements ICodeService {
try {
result = regionalismCodeDao.findSubRegionalism(region);
} catch (Exception e) {
// TODO: handle exception
log.error(e);
}
return result;
}
@ -57,7 +66,7 @@ public class CodeServiceImpl implements ICodeService {
result.put("system", syss);
result.put("regionalism", regions);
} catch (Exception e) {
// TODO: handle exception
log.error(e);
}
return result;
}

@ -1,9 +1,8 @@
package com.platform.service;
package com.platform.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -17,9 +16,9 @@ import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.PagerOptions;
import com.platform.glusterfs.RemoveData;
import com.platform.utils.Bean2MapUtils;
import com.platform.form.PagerOptions;
import com.platform.http.gfs.RemoveData;
import com.platform.service.DataInfoService;
import com.platform.utils.Configs;
@Service(value = "dataInfoService")
@ -46,16 +45,26 @@ public class DataInfoServiceImp implements DataInfoService {
List<String> removelist = new ArrayList<String>();
List<String> alllist = new ArrayList<String>();
List<String> list = new ArrayList<String>();
//如果有查询数据库类型的
//去掉版本字段
Pattern pattern = Pattern.compile("^版本\\d+$");
Pattern pattern = Pattern.compile("^版本\\d+");
if (null != querystr && !"".equals(querystr)) {
querys = querystr.split(" ");
if (querystr.toLowerCase().contains("oracle")) {
pagerOptions.setDataBaseType("ORACLE");
querystr = querystr.toUpperCase().replaceAll("ORACLE", "");
}else if(querystr.toLowerCase().contains("sql server")){
pagerOptions.setDataBaseType("SQL SERVER");
querystr = querystr.toUpperCase().replaceAll("SQL SERVER", "");
}
querys = querystr.trim().split(" ");
list = Arrays.asList(querys);
}
//遍历 list
for (String ss : list) {
ss = ss.trim();
alllist.add(ss);
if (!"".equals(ss)) {
alllist.add(ss);
}
}
for (String ss : alllist) {
Matcher matcher2 = pattern.matcher(ss);
@ -68,35 +77,45 @@ public class DataInfoServiceImp implements DataInfoService {
alllist.removeAll(removelist);
Object[] strs = alllist.toArray();
int length = strs.length;
String[] arrays = new String[length];
List<String> arrays = new ArrayList<String>();
for (int i = 0; i < length; i++) {
arrays[i] = strs[i].toString();
arrays.add(strs[i].toString().trim());
}
for (String version : removelist) {
pagerOptions.setDataVersion(Integer.valueOf(version.replace("版本", "")));
}
if (arrays.length > 0) {
if (arrays.size() > 0) {
pagerOptions.setArray(arrays);
}
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
log.info("total colume " + count);
int offset = 0;
if (pagerOptions.getCurrentPageNum() > 1) {
pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
* pagerOptions.getPriorTableSize());
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
log.info(offset);
if (null !=pagerOptions.getSubmittedBatch() && !"".equals(pagerOptions.getSubmittedBatch()) ) {
pagerOptions.setSubmittedBatch("批次"+pagerOptions.getSubmittedBatch());
}
pagerOptions.setOffset(offset + 1);
List<DataInfoEntity> result = dfdDao
.getLimitedDataInfoEntities(pagerOptions);
if (null != result) {
for (DataInfoEntity dataInfoEntity : result) {
dataInfoEntity.setVolumeType(dataInfoEntity.getMark());
}
List<DataInfoEntity> result = null;
try{
result = dfdDao.getLimitedDataInfoByPage(pagerOptions);
}catch(Exception e){
log.error(e.getMessage());
}
// int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
// log.info("total colume " + count);
// int offset = 0;
// if (pagerOptions.getCurrentPageNum() > 1) {
// pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
// * pagerOptions.getPriorTableSize());
// offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
// log.info(offset);
// }
// pagerOptions.setOffset(offset + 1);
// List<DataInfoEntity> result = dfdDao
// .getLimitedDataInfoEntities(pagerOptions);
// if (null != result) {
// for (DataInfoEntity dataInfoEntity : result) {
// dataInfoEntity.setVolumeType(dataInfoEntity.getMark());
// }
// }
modelMap.addAttribute("page", pagerOptions);
modelMap.addAttribute("data", result);
modelMap.addAttribute("length", count);
modelMap.addAttribute("length", pagerOptions.getTotleSize());
} catch (Exception e) {
new CustomException();
}
@ -110,6 +129,11 @@ public class DataInfoServiceImp implements DataInfoService {
for(String idx: id){
ids.add(Integer.parseInt(idx));
}
deleteData(ids);
}
@Override
public void deleteData(List<Integer> ids) throws Exception {
if (ids.size() > 0) {
//数据在不在?
List<String> paths = dfdDao.getIdIsExist(ids);
@ -137,6 +161,7 @@ public class DataInfoServiceImp implements DataInfoService {
dfdDao.removes(ids);
}
}
}
@Override

@ -1,4 +1,4 @@
package com.platform.service;
package com.platform.service.impl;
import java.util.List;
@ -8,9 +8,10 @@ import org.springframework.stereotype.Service;
import com.platform.dao.EncodeInfoDao;
import com.platform.entities.EncodedInfoEntity;
import com.platform.service.EncodeInfoService;
/**
*
* /
*
* @author wuming
*
@ -41,7 +42,6 @@ public class EncodeInfoServiceImpl implements EncodeInfoService {
public int deleteEncodeByCode(String code, String tableName) {
// TODO Auto-generated method stub
int cursor = eiDao.deleteEncodeByCode(code, tableName);
//cursor = cursor / 0;
return cursor;
}

@ -5,31 +5,40 @@ import java.util.List;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.platform.dao.GatherOracleDao;
import com.platform.entities.GatherOracleInfo;
import com.platform.oracle.OracleConnector;
import com.platform.service.IMySqlService;
import com.platform.service.IGatherOracleService;
/** oracle
* @author chen
*
*/
@Service(value = "mySqlService")
public class MySqlServiceImpl implements IMySqlService{
public class GatherOracleServiceImpl implements IGatherOracleService{
public final static Logger log = Logger.getLogger(GatherOracleServiceImpl.class);
/**
* oracle
*/
@Resource(name = "gatherOracleDao")
private GatherOracleDao gatherOracleDao;
@Override
public List<GatherOracleInfo> findAllMySql() throws Exception {
public List<GatherOracleInfo> findAllOracle() throws Exception {
List<GatherOracleInfo> result = gatherOracleDao.selectAllOracle();
return result;
}
@Override
public int deleteMySql(int id) throws Exception {
public int deleteOracle(int id) throws Exception {
int result = 0;
if (id > 0) {
// result = gatherOracleDao.deleteOracleById(id);
//删除汇总的库--逻辑删除
GatherOracleInfo oracle = new GatherOracleInfo();
oracle.setId(id);
oracle.setRemove("1");
@ -39,26 +48,42 @@ public class MySqlServiceImpl implements IMySqlService{
}
public int insertOracle(GatherOracleInfo oracle) throws Exception {
//TODO 连接oracle
int result = gatherOracleDao.insertOracle(oracle);
// 连接oracle
int result = 0;
//1 代表 是标准库抽取
if ("1".equals(oracle.getType())) {
GatherOracleInfo ora = new GatherOracleInfo();
ora.setType("0");
gatherOracleDao.updateAllOracle(ora);
}
try{
result = gatherOracleDao.insertOracle(oracle);
}catch(Exception e){
log.error(e);
}
return result;
}
@Override
public int updateOracle(GatherOracleInfo oracle) throws Exception {
int status = 1;
int result = 0;
Connection conn = null /*OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracle.getIp() + ":" + oracle.getPort() + ":"
+ oracle.getDatabaseName(), oracle.getUser(), oracle.getPassword())*/;
if (null == conn) {
status = 0;
}
oracle.setStatus(status);
int result;
if (oracle.getId() > 0) {
if ("1".equals(oracle.getType())) {
GatherOracleInfo ora = new GatherOracleInfo();
ora.setType("0");
gatherOracleDao.updateAllOracleExceptId(ora);
}
result = gatherOracleDao.updateOracleById(oracle);
}
else {
result = gatherOracleDao.insertOracle(oracle);
result = insertOracle(oracle);
}
return result;
}

@ -18,8 +18,8 @@ import org.springframework.stereotype.Service;
import com.platform.entities.Brick;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.CopyData;
import com.platform.entities.VolumeDataEntity;
import com.platform.http.gfs.CopyData;
import com.platform.glusterfs.GetTreeData;
import com.platform.glusterfs.VolumeInfo;
import com.platform.service.IGfsService;
@ -53,104 +53,48 @@ public class GfsServiceImpl implements IGfsService {
return result;
}
@Override
public int copyFolder(List<String> srcFolders, String dstFolder, String name)
throws Exception {
int status = 0 ;
if (null != srcFolders) {
for (String string : srcFolders) {
status = copydata.copyFolderFilesAnyway(string, dstFolder, name);
}
}
return status;
}
// @Override
// public int copyFolder(List<String> srcFolders, String dstFolder, String name)
// throws Exception {
// int status = 0 ;
// if (null != srcFolders) {
//
// for (String string : srcFolders) {
//// status = copydata.copyFolderFilesAnyway(string, dstFolder, name);
// }
// }
// return status;
// }
/* (non-Javadoc)
* @see com.platform.service.IGfsService#getAllVolume()
*/
@Override
public List<VolumeEntity> getAllVolumes() throws Exception {
List<VolumeEntity> volumeList = CacheTreeData.getVolumeList();
if (null == volumeList) {
return new ArrayList<VolumeEntity>();
}
for (VolumeEntity volume : volumeList) {
// VolumeEntity volume = new VolumeEntity();
// volume.setName(volumeName);
// List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
// //默认加载第一个路径
// if (null != path && path.size() > 0) {
// volume.setPath(path.get(0));
// }
// volume.setAllSize(volumeInfo.getVolumeAllSize(volumeName));
// volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
// //TODO 查询brick--
// //返回 ip:path
// List<String> brickStrs = volumeInfo.getVolumeBricks(volumeName);
// //brick已用大小
// Map<String, Double> usedSize = volumeInfo.getVolumebricksDataSize(volumeName);
// Map<String, Double> availableSize = volumeInfo.getVolumebricksAvailableSize(volumeName);
//
//
// List<Brick> brickList = new ArrayList<Brick>();
// for (String brickIpPath : brickStrs) {
// Brick b = new Brick();
// String ipAndpath[] = brickIpPath.split(":");
// String brickip = ipAndpath[0];
// String brickpath = ipAndpath[1];
// //iP , path ,
// b.setIp(brickip);
// b.setPath(brickpath);
// b.setAvailableSize(availableSize.get(brickIpPath));
// b.setUsedSize(usedSize.get(brickIpPath));
// brickList.add(b);
// }
// volume.setBrick(brickList);
if (null != volume.getPath()) {
// 获得 folder 目录
List<FolderNode> list = new ArrayList<FolderNode>();
FolderNode currNode = getFolder(volume.getPath());
if (null != currNode && null != currNode.getChildNodes()) {
list.addAll(currNode.getChildNodes());
}
volume.setFolder(list);
}
}
public List<VolumeDataEntity> getAllVolumes() throws Exception {
List<VolumeDataEntity> volumeList = CacheTreeData.getVolumeList();
return volumeList;
}
@Override
public VolumeEntity getOneVolume(String volumeName) throws Exception {
VolumeEntity volume = new VolumeEntity();
volume.setName(volumeName);
List<String> path = volumeInfo.getVolumeMountPoint(volumeName);
if (null != path && path.size() > 0) {
volume.setPath(path.get(0));
}
volume.setAllSize((double) volumeInfo.getVolumeAvailableSize(volumeName));
volume.setUsedSize((double) volumeInfo.getVolumeUseSize(volumeName));
// volume.setBrick(brick);
if (null != volume.getPath()) {
List<FolderNode> list = new ArrayList<FolderNode>();
if (null != path && path.size() > 0) {
FolderNode currNode = getFolder(path.get(0));
if (null != currNode && null != currNode.getChildNodes()) {
list.addAll(currNode.getChildNodes());
}
public VolumeDataEntity getOneVolume(String volumeName) throws Exception {
List<VolumeDataEntity> volumeList = CacheTreeData.getVolumeList();
VolumeDataEntity volume = new VolumeDataEntity();
for (VolumeDataEntity volumeEntity : volumeList) {
if (volumeName.equals(volumeEntity.getPath())) {
volume = volumeEntity;
}
volume.setFolder(list);
}
return volume;
}
@Override
public int moveData(String volumeName, String srcPath, String dstPath)
throws Exception {
int result = copydata.copyFolderFilesAnyway(srcPath, dstPath, "app");
return result;
}
//
// @Override
// public int moveData(String volumeName, String srcPath, String dstPath)
// throws Exception {
//
// int result = 0;
// result = copydata.copyFolder(srcPath, dstPath, "app");
// return result;
// }
@Override
public int deleteData(String volumeName, String srcPath) throws Exception {

@ -15,5 +15,11 @@ public class LogReadServiceImpl implements ILogRead {
String result = FileOperateHelper.fileReader(Configs.EXTRACT_LOG_LOCALTION + "J" + filename.replace("-", "_")+".log");
return result;
}
@Override
public String readStandardLog(String filename) throws Exception {
String result = FileOperateHelper.fileReader(Configs.EXTRACT_STANDARD_LOG_LOCALTION + "CQ" + filename.replace("-", "_")+".log");
return result;
}
}

@ -8,10 +8,11 @@ import java.util.regex.Pattern;
import javax.annotation.Resource;
import org.springframework.scheduling.annotation.Scheduled;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.platform.controller.CheckoutController;
import com.platform.dao.DataInfoDao;
import com.platform.dao.DataInfoMoveTmpDao;
import com.platform.dao.VolumeDao;
@ -20,17 +21,19 @@ import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeInitEntity;
import com.platform.glusterfs.CheckoutMD5;
import com.platform.glusterfs.CopyData;
import com.platform.glusterfs.RemoveData;
import com.platform.http.gfs.RemoveData;
import com.platform.glusterfs.ShowData;
import com.platform.service.IMoveDataService;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
@Component
@Service(value = "moveDataService")
public class MoveDataServiceImpl implements IMoveDataService {
/**
*
*/
public final static Logger log = Logger.getLogger(CheckoutController.class);
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
@ -40,15 +43,10 @@ public class MoveDataServiceImpl implements IMoveDataService {
private RemoveData removeservice = new RemoveData();
/**
*
*/
CopyData copy = new CopyData();
/**
* MD5
*/
CheckoutMD5 check = new CheckoutMD5();
// CheckoutMD5 check = new CheckoutMD5();
@Resource(name = "dataInfoMoveTmpDao")
private DataInfoMoveTmpDao dataInfoMoveTmpDao;
@ -148,20 +146,29 @@ public class MoveDataServiceImpl implements IMoveDataService {
else {
volumePath = node.getPath();
}
String path = "";
String ip = "";
for ( VolumeInitEntity ve : listVolume) {
if (volumePath.contains(ve.getPath())) {
dataMove.setDstVolumePath(ve.getPath());
dataMove.setDstVolumeIp(ve.getIp());
break;
String tmpPath = ve.getPath();
if (volumePath.contains(tmpPath)) {
if (tmpPath.length() > path.length()) {
path = tmpPath;
ip = ve.getIp();
}
}
}
if (path.length() == 0) {
dataMove.setDstVolumePath("nopath");
dataMove.setDstVolumePath("noIP");
}else {
dataMove.setDstVolumePath(path);
dataMove.setDstVolumeIp(ip);
}
dataMove.setCompleteStatus("0");
moveList.add(dataMove);
}
if (moveList.size() > 0) {
dataInfoMoveTmpDao.insertBatch(moveList);
// for (DataInfoEntityMoveTmp dataInfoEntityMoveTmp2 : moveList) {
// dataInfoMoveTmpDao.save(dataInfoEntityMoveTmp2);
// }
isSuccess = true;
}
}
@ -172,10 +179,17 @@ public class MoveDataServiceImpl implements IMoveDataService {
public List<DataInfoEntityMoveTmp> findAll() throws Exception {
List<DataInfoEntityMoveTmp> result = new ArrayList<DataInfoEntityMoveTmp>();
try {
result = dataInfoMoveTmpDao.findAll();
List<DataInfoEntityMoveTmp> tmp = dataInfoMoveTmpDao.findAll();
for (DataInfoEntityMoveTmp tmpentity : tmp) {
if (null != tmpentity.getSubmittedBatch() || null != tmpentity.getSystemName()) {
result.add(tmpentity);
}else {
this.delete(tmpentity);
}
}
} catch (Exception e) {
System.err.println(e);
log.error(e);
}
return result;
}
@ -192,13 +206,18 @@ public class MoveDataServiceImpl implements IMoveDataService {
}
}
//迁移失败
if ("3".equals(dataMove.getCompleteStatus())) {
removeservice.deleteFolder(dataMove.getDstPath());
}
int result = 0;
if (!"1".equals(dataMove.getCompleteStatus())) {
result = dataInfoMoveTmpDao.remove(dataMove.getId());
//是正则迁移时:
if ("1".equals(dataMove.getCompleteStatus())) {
if(1 != removeservice.abortcopyFolder(dataMove.getDataPath(), makeDstPath(dataMove.getDstPath()))){
removeservice.deleteFolder(dataMove.getDstPath());
}
}
result = dataInfoMoveTmpDao.remove(dataMove.getId());
return result;
}
@ -220,4 +239,19 @@ public class MoveDataServiceImpl implements IMoveDataService {
return result;
}
/** +/
* @param dstPath
* @return
*/
private String makeDstPath(String dstPath) {
// 末尾 含有 数字 + /
Pattern pattern2 = Pattern.compile("\\d+\\/$");
Matcher matcher2 = pattern2.matcher(dstPath);
//去掉 最后 的 数字 +/ 符合
if (matcher2.find()) {
String removeStr = matcher2.group();
dstPath = dstPath.replace(removeStr, "");
}
return dstPath;
}
}

@ -1,14 +1,17 @@
package com.platform.service.impl;
import java.sql.Connection;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.controller.OracleController;
import com.platform.dao.DataInfoDao;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
@ -19,13 +22,20 @@ import com.platform.service.IOracleExtractService;
import com.platform.service.OracleExtractHelper;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
import com.platform.utils.FileOperateHelper;
@Service(value = "OracleExtract")
public class OracleExtractServiceImpl implements IOracleExtractService {
/**
*
*/
public final static Logger log = Logger.getLogger(OracleExtractServiceImpl.class);
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
/**
* kubernetes client
*/
@ -52,24 +62,27 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
if (datainfos.size() == 0) {
return false;
}
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
Connection conn = OracleConnector.connectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(),dataInfolist.get(0));
if (null == conn) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ dataInfolist.get(0).getName(), "创建oracle连接失败: [" + conn + "]\r\n");
+ dataInfolist.get(0).getName()+".log", "创建oracle连接失败: [" + conn + "]\r\n");
return false;
}
for (OracleConnectorParams collectOracle : datainfos) {
String replicasName = collectOracle.getName();
try{
if(null != collectOracle.getDataId() && !"".equals(collectOracle.getDataId())){
DataInfoEntity data = new DataInfoEntity();
data.setId(Integer.valueOf(collectOracle.getDataId()));
data.setExtractStatus(1);
dataInfoDao.updateExtract(data);
String replicasName = collectOracle.getName();
collectOracle.setName("J" + collectOracle.getName().replace("-", "_"));
String cmd = "kubectl label --overwrite rc "
String cmd = "kubectl label --overwrite rc "
+ replicasName + " isExtract=1";
//sql日志记录时间
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ collectOracle.getName()+".log", "\r\n 开始汇总 \r\n"+ DateForm.date2StringBysecond(new Date()) +"\r\n");
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
@ -92,6 +105,17 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
data.setExtractStatus(2);
dataInfoDao.updateExtract(data);
}
}catch(Exception e){
log.error(Custom4exception.OracleSQL_Except, e);
}
finally{
//sql日志记录时间
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ collectOracle.getName()+".log", "\r\n 汇总结束 \r\n"+ DateForm.date2StringBysecond(new Date()) +"\r\n");
String cmd = "kubectl label --overwrite rc "
+ replicasName + " isExtract=2";
Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
}
}
isSuccess = true;
}catch(Exception e){
@ -103,7 +127,7 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
@Override
public boolean isConnectTotalOracle(GatherOracleInfo oracleModel) throws Exception {
boolean isConnect = false;
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
Connection conn = OracleConnector.connectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(), null);
if (null == conn) {
isConnect = false;
@ -115,6 +139,126 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
}
return isConnect;
}
@Override
public boolean extractStandardTable(String name, List<OracleConnectorParams> dataInfolist,
GatherOracleInfo oracleConnect) throws Exception {
boolean isSuccess = false;
try{
//map转 bean(汇总库信息-带tableName的)
GatherOracleInfo oracleModel = oracleConnect;
//采集库连接参数
List<OracleConnectorParams> datainfos = dataInfolist;
if (datainfos.size() == 0) {
return false;
}
Connection conn = OracleConnector.connectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(),dataInfolist.get(0));
if (null == conn) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ dataInfolist.get(0).getName()+".log", "创建oracle连接失败: [" + conn + "]\r\n");
return false;
}
for (OracleConnectorParams collectOracle : datainfos) {
String replicasName = collectOracle.getName();
try{
if(null != collectOracle.getDataId() && !"".equals(collectOracle.getDataId())){
DataInfoEntity data = new DataInfoEntity();
data.setId(Integer.valueOf(collectOracle.getDataId()));
//设置为 标准表 抽取中
data.setCheckoutFlag(Constant.CHECKOUTFLAG_SIX);
data.setStandardExtractStatus("1");
dataInfoDao.update(data);
collectOracle.setName("CQ" + collectOracle.getName().replace("-", "_"));
String cmd = "kubectl annotate --overwrite rc "
+ replicasName + " standardExtractStatus=1";
//sql日志记录时间
FileOperateHelper.fileWrite(Configs.EXTRACT_STANDARD_LOG_LOCALTION
+ collectOracle.getName()+".log", "\r\n 开始抽取标准表 \r\n"+ DateForm.date2StringBysecond(new Date()) +"\r\n");
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String string : rList)
sb.append(string).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
// client.updateOrAddReplicasLabelById(collectOracle.getName(), "isExtract", "1"); //更新oracle汇总状态0标示为未汇总1标示汇总中2标示汇总完成
oracleExtract.createStandardDBLink(conn, collectOracle); //创建dblink
oracleExtract.createTableSpace(conn, collectOracle, oracleModel); //创建表空间
oracleExtract.createOnlyUser(conn, collectOracle, oracleModel);//创建 抽取标准表的 用户并授权
DataInfoEntity tmpdata = dataInfoDao.findById(data.getId());
if (null != tmpdata) {
if (Constant.CHECKOUT_STATUS_THREE.equals(tmpdata.getPayResultLast())
|| Constant.CHECKOUT_STATUS_FIVE.equals(tmpdata.getPayResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(tmpdata.getPayResultLast())) {
//抽取中
data.setPayResultLast(Constant.CHECKOUT_STATUS_SIX);
dataInfoDao.update(data);
boolean isExtrac = true;
try{
oracleExtract.extractStandardPayTable(conn, collectOracle, oracleModel);//执行抽取
}catch(Exception e){
//改回 校验存在的状态
data.setPayResultLast(Constant.CHECKOUT_STATUS_THREE);
dataInfoDao.update(data);
isExtrac = false;
}
if (isExtrac) {
//抽取成功
data.setPayResultLast(Constant.CHECKOUT_STATUS_SEVEN);
dataInfoDao.update(data);
}
}
if (Constant.CHECKOUT_STATUS_THREE.equals(tmpdata.getExecResultLast())
|| Constant.CHECKOUT_STATUS_FIVE.equals(tmpdata.getExecResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(tmpdata.getExecResultLast())) {
//抽取中
data.setExecResultLast(Constant.CHECKOUT_STATUS_SIX);
dataInfoDao.update(data);
boolean isExtrac = true;
try{
oracleExtract.extractStandardExecTable(conn, collectOracle, oracleModel);//执行抽取
}catch(Exception e){
//改回 校验存在的状态
data.setExecResultLast(Constant.CHECKOUT_STATUS_THREE);
dataInfoDao.update(data);
isExtrac = false;
}
if (isExtrac) {
data.setExecResultLast(Constant.CHECKOUT_STATUS_SEVEN);
dataInfoDao.update(data);
}
}
// client.updateOrAddReplicasLabelById(collectOracle.getName(), "isExtract", "2"); //更新oracle汇总状态0标示为未汇总1标示汇总中2标示汇总完成
cmd = "kubectl annotate --overwrite rc "
+ replicasName + " standardExtractStatus=2";
rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
sb = new StringBuffer();
for (String string : rList)
sb.append(string).append("\n");
Configs.CONSOLE_LOGGER.info(sb.toString());
data.setCheckoutFlag(Constant.CHECKOUTFLAG_SEVEN);
data.setStandardExtractStatus("2");
dataInfoDao.update(data);
}
}
}catch(Exception e){
log.error(Custom4exception.OracleSQL_Except, e);
}
finally{
//sql日志记录时间
FileOperateHelper.fileWrite(Configs.EXTRACT_STANDARD_LOG_LOCALTION
+ collectOracle.getName()+".log", "\r\n 抽取标准表结束 \r\n"+ DateForm.date2StringBysecond(new Date()) +"\r\n");
String cmd = "kubectl annotate --overwrite rc "
+ replicasName + " standardExtractStatus=2";
Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
}
}
isSuccess = true;
}catch(Exception e){
log.error(Custom4exception.OracleSQL_Except, e);
}
return isSuccess;
}
// @Override
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception {

@ -8,6 +8,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
@ -19,10 +20,10 @@ import org.springframework.stereotype.Service;
import com.platform.dao.IRegionalismCodeDao;
import com.platform.dao.ISystemCodeDao;
import com.platform.dao.PreDataInfoDao;
import com.platform.entities.PagerOptions;
import com.platform.entities.PreDataInfo;
import com.platform.entities.RegionalismEntity;
import com.platform.entities.SystemEntity;
import com.platform.form.PagerOptions;
import com.platform.service.IPreDataInfoService;
import com.platform.utils.BeanCopy;
import com.platform.utils.Configs;
@ -33,7 +34,7 @@ import com.platform.utils.excelUtils.ExcelOperation;
@Service(value = "preDataInfoService")
public class PreDataInfoServiceImpl implements IPreDataInfoService {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(PreDataInfoServiceImpl.class);
public final static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(PreDataInfoServiceImpl.class);
@Resource(name = "preDataInfoDao")
private PreDataInfoDao preDataInfoDao;
@ -60,7 +61,8 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
@Override
public List<PreDataInfo> findByParam(PagerOptions op) {
List<PreDataInfo> result = preDataInfoDao.getLimitedDataInfoEntities(op);
List<PreDataInfo> result = null;
result = preDataInfoDao.getLimitedDataInfoEntities(op);
return result;
}
@ -71,8 +73,6 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
List<String> errFile = new ArrayList<String>();
// 待增加的
List<PreDataInfo> all2Insert = new ArrayList<PreDataInfo>();
// 待修改的
List<PreDataInfo> all2Update = new ArrayList<PreDataInfo>();
//excel读出的 所有
List<PreDataInfo> all = new ArrayList<PreDataInfo>();
//excel读出的 所有修改操作的数据
@ -106,25 +106,26 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
try {
PreDataInfo pre = new PreDataInfo();
//excel数据 --> java bean
List<PreDataInfo> subPreData = ExcelOperation.readExcel4Update(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, pre, "id", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
List<PreDataInfo> subPreData = ExcelOperation.readExcel4Update(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, pre, "id", "dataId", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
if (null != subPreData && subPreData.size() > 0) {
//是否是 同一个县区的 系统--是则 加入
// 是否是 同一个县区的 系统--是则 加入
boolean isSameArea = true;
String areaCode = subPreData.get(0).getAreaCode();
for (PreDataInfo preDataInfo : subPreData) {
if (!areaCode.equals(preDataInfo.getAreaCode())) {
isSameArea = false;
// TODO 不是同一个地区: isSameArea = false;
// isSameArea = false;
errArea.add(areaCode);
break;
}
}
// 是同一个地区,则将 excel中的 待 操作的数据 全加载 到 all 里面
if (isSameArea) {
all.addAll(subPreData);
}
}
} catch (IllegalArgumentException
| IllegalAccessException | InstantiationException e) {
e.printStackTrace();
} catch (Exception e) {
log.error(e);
}
// finally{
// if (null != workbook) {
@ -142,8 +143,9 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
//根据 操作 类别 分类(修改, 新增行政区划,新增信息系统)
if (all.size() > 0) {
for (PreDataInfo preDataInfo : all) {
switch (preDataInfo.getIsupdate()) {
String updateType = preDataInfo.getIsupdate();
switch (updateType)
{
case Constant.preDataInfo_add_system:
list4AddSystem.add(preDataInfo);
break;
@ -161,6 +163,25 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
}
}
}
//TODO 查 地区 是否没有-(没有则添加新地区):
if (list4AddArea.size() > 0) {
this.addArea(list4AddArea);
}
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统 -- start
List<PreDataInfo> allAreaInsert = new ArrayList<PreDataInfo>();
List<String> sysNamesArea = new ArrayList<String>();
for (PreDataInfo preDataInfo : list4AddArea) {
sysNamesArea.add(preDataInfo.getSysName());
}
//查询系统的code。
List<SystemEntity> listSystem = new ArrayList<SystemEntity>();
Map<String, Integer> syscodeMap = new HashMap<String, Integer>();
// 去掉 已经导入的系统。。(例如 excel反复导入
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统
allAreaInsert = removeRepeat(list4AddArea);
if (allAreaInsert.size() > 0) {
list4AddSystem.addAll(allAreaInsert);
}
// 查系统 是否没有-(没有则在 pre_data_info添加新系统
if (list4AddSystem.size() > 0) {
this.AddSystem(list4AddSystem);
@ -168,11 +189,11 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
for (PreDataInfo preDataInfo : list4AddSystem) {
sysNames.add(preDataInfo.getSysName());
}
List<SystemEntity> listSystem = new ArrayList<SystemEntity>();
listSystem = new ArrayList<SystemEntity>();
if (sysNames.size() > 0) {
listSystem = systemCodeDao.findByName(sysNames);
}
Map<String, Integer> syscodeMap = new HashMap<String, Integer>();
syscodeMap = new HashMap<String, Integer>();
for (SystemEntity systemEntity : listSystem) {
syscodeMap.put(systemEntity.getSystemName(), systemEntity.getCode());
}
@ -184,47 +205,17 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
all2Insert.add(systemFull);
}
}
//TODO 去掉 已经导入的系统。。(例如 excel反复导入
//去掉 已经导入的系统。。(例如 excel反复导入
//在 pre_data_info表中 新增 操作为(新增信息系统)的系统
all2Insert = removeRepeat(all2Insert);
if (all2Insert.size() > 0) {
preDataInfoDao.insertBatch(all2Insert);
}
// 查 地区 是否没有-(没有则添加新地区):
if (list4AddArea.size() > 0) {
this.addArea(list4AddArea);
}
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统 -- start
List<PreDataInfo> allAreaInsert = new ArrayList<PreDataInfo>();
List<String> sysNamesArea = new ArrayList<String>();
for (PreDataInfo preDataInfo : list4AddArea) {
sysNamesArea.add(preDataInfo.getSysName());
}
//查询系统的code。
List<SystemEntity> listSystem = new ArrayList<SystemEntity>();
if (sysNamesArea.size() > 0) {
listSystem = systemCodeDao.findByName(sysNamesArea);
}
Map<String, Integer> syscodeMap = new HashMap<String, Integer>();
for (SystemEntity systemEntity : listSystem) {
syscodeMap.put(systemEntity.getSystemName(), systemEntity.getCode());
}
for (PreDataInfo preDataInfo : list4AddArea) {
PreDataInfo areaFull = new PreDataInfo();
BeanCopy.copyBean(preDataInfo, areaFull);
areaFull.setSysCode(syscodeMap.get(areaFull.getSysName()));
areaFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
allAreaInsert.add(areaFull);
}
//TODO 去掉 已经导入的系统。。(例如 excel反复导入
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统
allAreaInsert = removeRepeat(allAreaInsert);
if (allAreaInsert.size() > 0) {
preDataInfoDao.insertBatch(allAreaInsert);
insertBatch(all2Insert);
}
//在 pre_data_info表中 新增 操作为(新增行政区划)的系统 -- end
//在 pre_data_info表中 更新 操作为 (修改) 的系统
if (list4Update.size() > 0) {
// 待修改的
List<PreDataInfo> allUpdate = new ArrayList<PreDataInfo>();
// 查询系统 code
for (PreDataInfo preDataInfo : list4Update) {
@ -246,8 +237,14 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
UpdateFull.setUpdateTime(DateForm.date2StringBysecond(new Date()));
allUpdate.add(UpdateFull);
}
// 更新
for (PreDataInfo preEntity : allUpdate) {
preDataInfoDao.update(preEntity);
try{
preDataInfoDao.update(preEntity);
}
catch(Exception e){
log.error(e);
}
}
}
return errmap;
@ -258,20 +255,17 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
Map<String, List> map = new HashMap<String, List>();
List<String> errList = new ArrayList<String>();
List<PreDataInfo> list = findAll();
// InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(templateFilePath), "UTF-8");
ClassPathResource res = new ClassPathResource(Constant.SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH);
//此处 耗时太久原因excel 2007 以后采用的方式不同造成的建议升级 到 poi 3.15以上)
XSSFWorkbook workbook = null;
XSSFWorkbook result = null;
try {
workbook = new XSSFWorkbook(res.getInputStream());
result = ExcelOperation.writeExcelTemplate(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, 25, list, "id", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
} catch (IllegalArgumentException
| IllegalAccessException | IOException e) {
result = ExcelOperation.writeExcelTemplate(workbook, Constant.EXCEL_TEMPLATE_INIT_ROW, 0, 25, list, "id", "dataId", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
} catch (Exception e) {
errList.add(e.getMessage());
}
//不能进行close,
// workbook.close();
FileOutputStream fileOut = null;
try {
File f = new File(path);
@ -334,12 +328,12 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
List<String> areacodeList = new ArrayList<String>();
Map<String,RegionalismEntity> areaMap = new HashMap<String, RegionalismEntity>();
for (PreDataInfo preDataInfo : list4AddArea) {
areacodeList.add(preDataInfo.getAreaCode());
areacodeList.add(preDataInfo.getAreaCode().toLowerCase());
RegionalismEntity region = new RegionalismEntity();
region.setCode(preDataInfo.getAreaCode());
region.setCode(preDataInfo.getAreaCode().toLowerCase());
region.setCityName(preDataInfo.getCityName());
region.setDistrictName(preDataInfo.getDistrictName());
areaMap.put(region.getCode(), region);
areaMap.put(region.getCode().toLowerCase(), region);
}
List<RegionalismEntity> existEntity = regionalismCodeDao.findExistRegionalism(areacodeList);
for (RegionalismEntity regionalismEntity : existEntity) {
@ -352,7 +346,11 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
insert2Regionalism.add(areaMap.get(key));
}
if (insert2Regionalism.size() > 0) {
regionalismCodeDao.insertBatch(insert2Regionalism);
try {
regionalismCodeDao.insertBatch(insert2Regionalism);
} catch (Exception e) {
log.error(" -- regionalismCodeDao.insertBatch() --- error ");
}
insertNum = insert2Regionalism.size();
}
}
@ -415,7 +413,8 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
preDataInfo.setCheckoutPayPath("Checkout_Pay_"+preDataInfo.getAreaCode()+"_" + preDataInfo.getSysCode()+ ".sql");
}
// 设置 状态
if (!"ORACLE".equals(preDataInfo.getDataBaseType().toUpperCase())) {
String type = preDataInfo.getDataBaseType().toUpperCase();
if (!"ORACLE".equals(type)) {
preDataInfo.setUserTablespaceStatus("-");
}
fileEntitys.add(preDataInfo);
@ -466,12 +465,42 @@ public class PreDataInfoServiceImpl implements IPreDataInfoService {
}
excelAdd.put(pre.getAreaCode()+"_"+pre.getSysName().trim(), pre);
}
for (String key : excelAdd.keySet()) {
if (!sysInDataBaseMap.containsKey(key)) {
allResult.add(excelAdd.get(key));
Set<String> keys = excelAdd.keySet();
if (null != keys) {
for (String key : keys) {
if (!sysInDataBaseMap.containsKey(key)) {
allResult.add(excelAdd.get(key));
}
}
}
return allResult;
}
/** --(allAreaInsert ) allAreaInsert 100 11 10
* @param allAreaInsert
*/
private void insertBatch(List<PreDataInfo> allAreaInsert) {
if (allAreaInsert.size() > 0) {
int listSize = allAreaInsert.size();
int loopSize = listSize/Configs.NUM_ONE_IMPORT_EXCEL;
if (loopSize * Configs.NUM_ONE_IMPORT_EXCEL != listSize) {
loopSize++;
}
List<PreDataInfo>[] list = new ArrayList[loopSize];
for (int i = 0; i < loopSize; i++) {
list[i] = new ArrayList<PreDataInfo>();
}
for (int i = 0; i < listSize; i++) {
list[i%loopSize].add(allAreaInsert.get(i));
}
for (List<PreDataInfo> arrayList : list) {
try {
preDataInfoDao.insertBatch(arrayList);
} catch (Exception e) {
log.error(e.getStackTrace());
}
}
}
}
}

@ -1,38 +1,32 @@
package com.platform.service.impl;
import java.beans.IntrospectionException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import net.sf.json.regexp.RegexpUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.platform.dao.PreDataInfoDao;
import com.platform.entities.DefaultDataDescription;
import com.platform.entities.SqlFileInfoEntity;
import com.platform.entities.PreDataInfo;
import com.platform.entities.SqlFileInfoEntity;
import com.platform.service.IScriptMakeService;
import com.platform.utils.BeanCopy;
import com.platform.utils.Compare4SqlFilesEntity;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
import com.platform.utils.FileOperateHelper;
import com.platform.utils.ThreadRemoveFile;
import com.platform.utils.XmlOperationByDom4j;
import dk.brics.automaton.RegExp;
@Service(value = "scriptMakeService")
public class ScriptMakeService implements IScriptMakeService {
@ -53,7 +47,7 @@ public class ScriptMakeService implements IScriptMakeService {
sb.append("市\t县市、区\t行政区划代码\r\n");
Map<String, Object> startData = new HashMap<String, Object>();
for (PreDataInfo preDataInfo : systemInfoList) {
startData.put(preDataInfo.getAreaCode(), preDataInfo);
startData.put(preDataInfo.getAreaCode().toLowerCase(), preDataInfo);
}
// 以地区为准--一个地区一个xml
@ -63,10 +57,10 @@ public class ScriptMakeService implements IScriptMakeService {
sb.append("\t");
sb.append(preDataInfo.getDistrictName());
sb.append("\t");
sb.append(preDataInfo.getAreaCode());
sb.append(preDataInfo.getAreaCode().toLowerCase());
sb.append("\r\n");
}
FileOperateHelper.fileReWrite(path + Constant.cfgFileName,
FileOperateHelper.fileReWriteGBK(path + Constant.cfgFileName,
sb.toString());
log.info("makeCfg--end");
return 1;
@ -80,7 +74,7 @@ public class ScriptMakeService implements IScriptMakeService {
.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD);
Map<String, List<Object>> map = new HashMap<String, List<Object>>();
for (PreDataInfo preDataInfo : systemInfoList) {
putSystemByAreaCode(map, preDataInfo.getAreaCode(), preDataInfo);
putSystemByAreaCode(map, preDataInfo.getAreaCode().toLowerCase(), preDataInfo);
}
// 一个地区一个xml
for (String key : map.keySet()) {
@ -97,7 +91,7 @@ public class ScriptMakeService implements IScriptMakeService {
XmlOperationByDom4j
.createXml(FileOperateHelper.addLastSeparator(areaPath)
+ key + ".xml", defList, "Data_info", "id", "workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
+ key + ".xml", defList, "Data_info", "id", "dataId","workRange","sysCode","updateTime","userTablespaceStatus", "checkoutIndicateStatus", "checkoutPayStatus", "userTablespacePath", "checkoutIndicatePath", "checkoutPayPath", "sqlList", "dataVersion", "collectingTime", "collUpdate");
}
log.info("makeXml--end");
return 1;
@ -108,15 +102,17 @@ public class ScriptMakeService implements IScriptMakeService {
List<PreDataInfo> systemDataInfo = preDataInfoDao.findAll();
// 查找 Configs.SQL_SCRIPT_PATH_LAST 路径下的 所有的文件:路径
Map<String, String> sqlFilePathsLast = new HashMap<String, String>();
sqlFilePathsLast = getAllFile(sqlFilePathsLast,
Map<String, String> timeMapLast = new HashMap<String, String>();
sqlFilePathsLast = getAllFile(sqlFilePathsLast,timeMapLast,
Configs.SQL_SCRIPT_PATH_LAST);
// 遍历 查找 Configs.SQL_SCRIPT_PATH_STANDARD 脚本文件 放入集合中
Map<String, String> sqlFilePathsStandard = new HashMap<String, String>();
sqlFilePathsStandard = getAllFile(sqlFilePathsStandard,
Map<String, String> timeMapStandard = new HashMap<String, String>();
sqlFilePathsStandard = getAllFile(sqlFilePathsStandard,timeMapStandard,
Configs.SQL_SCRIPT_PATH_STANDARD);
// 填充 脚本状态、位置的信息
List<SqlFileInfoEntity> result = setScript(systemDataInfo,
sqlFilePathsStandard, sqlFilePathsLast);
sqlFilePathsStandard, sqlFilePathsLast, timeMapLast, timeMapStandard);
return result;
}
@ -127,26 +123,26 @@ public class ScriptMakeService implements IScriptMakeService {
String path2 = "";
switch (name) {
case "userTableStatus":
path1 = form.getUserTableScriptPathStandard();
path1 = form.getUserTableStatusPathStandard();
map.put("data1Path", path1);
map.put("data1", fileReader(path1));
path2 = form.getUserTableScriptPathLast();
path2 = form.getUserTableStatusPathLast();
map.put("data2Path", path2);
map.put("data2", fileReader(path2));
break;
case "ckIndicateStatus":
path1 = form.getCkIndicateScriptPathStandard();
path1 = form.getCkIndicateStatusPathStandard();
map.put("data1Path", path1);
map.put("data1", fileReader(path1));
path2 = form.getCkIndicateScriptPathLast();
path2 = form.getCkIndicateStatusPathLast();
map.put("data2Path", path2);
map.put("data2", fileReader(path2));
break;
case "ckPayStatus":
path1 = form.getCkPayScriptPathStandard();
path1 = form.getCkPayStatusPathStandard();
map.put("data1Path", path1);
map.put("data1", fileReader(path1));
path2 = form.getCkPayScriptPathLast();
path2 = form.getCkPayStatusPathLast();
map.put("data2Path", path2);
map.put("data2", fileReader(path2));
break;
@ -174,34 +170,34 @@ public class ScriptMakeService implements IScriptMakeService {
// 选择哪种类型的 脚本 path 可能 = null
switch (type) {
case "userTableStatus":
standardPath = form.getUserTableScriptPathStandard();
standardPath = form.getUserTableStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
File file = new File(FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode());
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode()
+ File.separator + "UserTablespace_" + form.getAreaCode() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.UserTablespace + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getUserTableScriptPathLast();
lastPath = form.getUserTableStatusPathLast();
break;
case "ckIndicateStatus":
standardPath = form.getCkIndicateScriptPathStandard();
standardPath = form.getCkIndicateStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
File file = new File(FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode());
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode()
+ File.separator + "Checkout_Indicate_" + form.getAreaCode() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Indicate + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getCkIndicateScriptPathLast();
lastPath = form.getCkIndicateStatusPathLast();
break;
case "ckPayStatus":
standardPath = form.getCkPayScriptPathStandard();
standardPath = form.getCkPayStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
File file = new File(FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode());
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + form.getAreaCode()
+ File.separator + "Checkout_Pay_" + form.getAreaCode() + "_" + form.getSysCode() + ".sql";
standardPath = spath + File.separator + Constant.Checkout_Pay + form.getAreaCode().toLowerCase() + "_" + form.getSysCode() + ".sql";
}
lastPath = form.getCkPayScriptPathLast();
lastPath = form.getCkPayStatusPathLast();
break;
default:
map.put("err", "请选择脚本类型!");
@ -215,14 +211,14 @@ public class ScriptMakeService implements IScriptMakeService {
case "delete":
fileDelete(lastPath);
break;
// 最新脚本 替换 标准脚本(即 以最新脚本为准 (归档或审核-替换)
// 最新脚本 替换 标准脚本(即 以最新脚本为准 (归档 或审核-替换)
case "replace":
FileOperateHelper.fileReWrite(standardPath, fileReader(lastPath));
FileOperateHelper.fileReWriteGBK(standardPath, fileReader(lastPath));
fileDelete(lastPath);
break;
//新增 标准的脚本(注意 造出 对应的 standardPath standardPath不能 = null '')(上传)
case "add":
FileOperateHelper.fileReWrite(standardPath,content);
FileOperateHelper.fileReWriteGBK(standardPath,content);
break;
// (查看)
case "read":
@ -259,17 +255,19 @@ public class ScriptMakeService implements IScriptMakeService {
* @param path
* @return
*/
public Map<String, String> getAllFile(Map<String, String> ps, String path) {
public Map<String, String> getAllFile(Map<String, String> ps, Map<String, String> timeMap,String path) {
File f = new File(path);
String name = f.getName();
// 如果是 sql文件
if (name.endsWith(".sql") || name.endsWith(".SQL"))
if (name.endsWith(".sql") || name.endsWith(".SQL")){
ps.put(name.toLowerCase(), f.getAbsolutePath());
timeMap.put(name.toLowerCase(), DateForm.date2StringBysecond(new Date(f.lastModified())));
}
if (f.exists()) {
String[] subpaths = f.list();
if (null != subpaths) {
for (String tmppath : subpaths) {
getAllFile(ps, f.getAbsolutePath() + "/" + tmppath);
getAllFile(ps, timeMap, f.getAbsolutePath() + "/" + tmppath);
}
}
}
@ -287,58 +285,101 @@ public class ScriptMakeService implements IScriptMakeService {
*/
private List<SqlFileInfoEntity> setScript(List<PreDataInfo> systemDataInfo,
Map<String, String> sqlFilePathsStandard,
Map<String, String> sqlFilePathsLast) {
Map<String, String> sqlFilePathsLast,Map<String, String> timeMapLast,
Map<String, String> timeMapStandard) {
List<SqlFileInfoEntity> fileEntitys = new ArrayList<SqlFileInfoEntity>();
for (PreDataInfo preDataInfo : systemDataInfo) {
SqlFileInfoEntity myfile = new SqlFileInfoEntity();
// 复制
BeanCopy.copyBean(preDataInfo, myfile);
//---------- 脚本的位置 ------
// 归档表空间脚本的位置-
String TablePathStandard = getFilePath("UserTablespace_",
String TablePathStandard = getFilePath(Constant.UserTablespace,
sqlFilePathsStandard, myfile, ".sql");
myfile.setUserTableScriptPathStandard(TablePathStandard);
myfile.setUserTableStatusPathStandard(TablePathStandard);
// 归档预算 脚本的位置-
String indicatePathStandard = getFilePath("Checkout_Indicate_",
String indicatePathStandard = getFilePath(Constant.Checkout_Indicate,
sqlFilePathsStandard, myfile, ".sql");
myfile.setCkIndicateScriptPathStandard(indicatePathStandard);
myfile.setCkIndicateStatusPathStandard(indicatePathStandard);
// 归档表空间脚本的位置-
String payPathStandard = getFilePath("Checkout_Pay_",
String payPathStandard = getFilePath(Constant.Checkout_Pay,
sqlFilePathsStandard, myfile, ".sql");
myfile.setCkPayScriptPathStandard(payPathStandard);
myfile.setCkPayStatusPathStandard(payPathStandard);
// 最新表空间脚本的位置-
String TablePathLast = getFilePath("UserTablespace_",
String TablePathLast = getFilePath(Constant.UserTablespace,
sqlFilePathsLast, myfile, ".sql");
myfile.setUserTableScriptPathLast(TablePathLast);
myfile.setUserTableStatusPathLast(TablePathLast);
// 最新预算 脚本的位置-
String indicatePathLast = getFilePath("Checkout_Indicate_",
String indicatePathLast = getFilePath(Constant.Checkout_Indicate,
sqlFilePathsLast, myfile, ".sql");
myfile.setCkIndicateScriptPathLast(indicatePathLast);
myfile.setCkIndicateStatusPathLast(indicatePathLast);
// 最新表空间脚本的位置-
String payPathLast = getFilePath("Checkout_Pay_", sqlFilePathsLast,
String payPathLast = getFilePath(Constant.Checkout_Pay, sqlFilePathsLast,
myfile, ".sql");
myfile.setCkPayStatusPathLast(payPathLast);
//-------文件最后更新-时间-------
// 时间
String uttimeStandard = getFilePath(Constant.UserTablespace,
timeMapStandard, myfile, ".sql");
myfile.setUserTableStatusStandardModified(uttimeStandard);
// 归档预算 脚本的时间-
String indicateTimeStandard = getFilePath(Constant.Checkout_Indicate,
timeMapStandard, myfile, ".sql");
myfile.setCkIndicateStatusStandardModified(indicateTimeStandard);
// 归档表空间脚本的时间-
String payTimeStandard = getFilePath(Constant.Checkout_Pay,
timeMapStandard, myfile, ".sql");
myfile.setCkPayStatusStandardModified(payTimeStandard);
// 最新表空间脚本的时间-
String utTimeLast = getFilePath(Constant.UserTablespace,
timeMapLast, myfile, ".sql");
myfile.setUserTableStatusLastModified(utTimeLast);
// 最新预算 脚本的时间-
String indicateTimeLast = getFilePath(Constant.Checkout_Indicate,
timeMapLast, myfile, ".sql");
myfile.setCkIndicateStatusLastModified(indicateTimeLast);
// 最新表空间脚本的时间-
String payTimeLast = getFilePath(Constant.Checkout_Pay, timeMapLast,
myfile, ".sql");
myfile.setCkPayScriptPathLast(payPathLast);
myfile.setCkPayStatusLastModified(payTimeLast);
// 设置 状态
if (null != myfile.getDataBaseType()) {
if ("ORACLE".equals(myfile.getDataBaseType().toUpperCase())) {
myfile.setUserTableStatus(getStatus(
myfile.getUserTableScriptPathStandard(),
myfile.getUserTableScriptPathLast()));
myfile.getUserTableStatusPathStandard(),
myfile.getUserTableStatusPathLast()));
} else {
myfile.setUserTableStatus(4);
}
}
myfile.setCkIndicateStatus(getStatus(
myfile.getCkIndicateScriptPathStandard(),
myfile.getCkIndicateScriptPathLast()));
myfile.getCkIndicateStatusPathStandard(),
myfile.getCkIndicateStatusPathLast()));
myfile.setCkPayStatus(getStatus(
myfile.getCkPayScriptPathStandard(),
myfile.getCkPayScriptPathLast()));
myfile.getCkPayStatusPathStandard(),
myfile.getCkPayStatusPathLast()));
myfile.setSysStatus(getTotalStatus(myfile));
fileEntitys.add(myfile);
}
Compare4SqlFilesEntity com = new Compare4SqlFilesEntity();
Collections.sort(fileEntitys, com);
return fileEntitys;
// Compare4SqlFilesEntity com = new Compare4SqlFilesEntity();
// System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
// Collections.sort(fileEntitys, com);
// Collections.sort(fileEntitys);
List<ArrayList<SqlFileInfoEntity>> tmpList = new ArrayList<ArrayList<SqlFileInfoEntity>>();
for (int i = 0; i < 4; i++) {
tmpList.add(new ArrayList<SqlFileInfoEntity>());
}
for (SqlFileInfoEntity sqlFileInfoEntity : fileEntitys) {
tmpList.get(sqlFileInfoEntity.getSysStatus()).add(sqlFileInfoEntity);
}
ArrayList<SqlFileInfoEntity> result = new ArrayList<SqlFileInfoEntity>();
for (int i = (tmpList.size()-1); i >= 0; i--) {
result.addAll(tmpList.get(i));
}
return result;
}
/**
@ -353,7 +394,7 @@ public class ScriptMakeService implements IScriptMakeService {
private String getFilePath(String prefix, Map<String, String> map,
SqlFileInfoEntity myf, String affix) {
StringBuffer sb = new StringBuffer();
sb.append(prefix).append(myf.getAreaCode()).append("_")
sb.append(prefix).append(myf.getAreaCode().toLowerCase()).append("_")
.append(myf.getSysCode()).append(affix);
String fileName = sb.toString().toLowerCase();
if (!map.containsKey(fileName)) {
@ -413,7 +454,7 @@ public class ScriptMakeService implements IScriptMakeService {
}
for (Integer integer : numArr) {
if (integer != 1) {
result = result & integer;
result = result | integer;
}
}
return result;
@ -441,4 +482,115 @@ public class ScriptMakeService implements IScriptMakeService {
}
return 1;
}
@Override
public Map<String, Object> totalOnholeSqlFile(List<SqlFileInfoEntity> forms) {
Map<String, Object> errMap = new HashMap<String, Object>();
List<String> errlist = new ArrayList<String>();
//待归档 status = 2
for (SqlFileInfoEntity sqlFile : forms) {
// 用户表空间脚本
if (sqlFile.getUserTableStatus() == 2) {
String standardPath = sqlFile.getUserTableStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.UserTablespace + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getUserTableStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
// 支付脚本
if (sqlFile.getCkPayStatus() == 2) {
String standardPath = sqlFile.getCkPayStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.Checkout_Pay + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkPayStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
// 可执行脚本
if (sqlFile.getCkIndicateStatus() == 2) {
String standardPath = sqlFile.getCkIndicateStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.Checkout_Indicate + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkIndicateStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
}
if (errlist.size() > 0) {
errMap.put("nosqlfile", errlist);
}
return errMap;
}
@Override
public Map<String, Object> totalVerifySqlFile(List<SqlFileInfoEntity> forms) {
Map<String, Object> errMap = new HashMap<String, Object>();
List<String> errlist = new ArrayList<String>();
//待归档 status = 2
for (SqlFileInfoEntity sqlFile : forms) {
// 用户表空间脚本
if (sqlFile.getUserTableStatus() == 3) {
String standardPath = sqlFile.getUserTableStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.UserTablespace + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getUserTableStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
// 支付脚本
if (sqlFile.getCkPayStatus() == 3) {
String standardPath = sqlFile.getCkPayStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.Checkout_Pay + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkPayStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
// 可执行脚本
if (sqlFile.getCkIndicateStatus() == 3) {
String standardPath = sqlFile.getCkIndicateStatusPathStandard();
if (null == standardPath || standardPath.isEmpty()) {
String spath = FileOperateHelper.addLastSeparator(Configs.SQL_SCRIPT_PATH_STANDARD) + sqlFile.getAreaCode().toLowerCase();
File file = new File(spath);
file.mkdir();
standardPath = spath + File.separator + Constant.Checkout_Indicate + sqlFile.getAreaCode().toLowerCase() + "_" + sqlFile.getSysCode() + ".sql";
}
String lastPath = sqlFile.getCkIndicateStatusPathLast();
if(!FileOperateHelper.singleFileMove(lastPath, standardPath)){
errlist.add(lastPath);
}
}
}
if (errlist.size() > 0) {
errMap.put("nosqlfile", errlist);
}
return errMap;
}
}

@ -11,23 +11,21 @@ import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import com.platform.controller.FilePackageController;
import com.platform.dao.VolumeDao;
import com.platform.entities.Brick;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
import com.platform.entities.VolumeInitEntity;
import com.platform.glusterfs.SetVolume;
import com.platform.http.gfs.SetVolume;
import com.platform.service.IGfsService;
import com.platform.service.IVolumeService;
import com.platform.utils.Configs;
@Service(value = "volumeService")
public class VolumeServiceImpl implements IVolumeService {
public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(VolumeServiceImpl.class);
public final static Logger log = Logger.getLogger(VolumeServiceImpl.class);
/** gfs的api */
SetVolume volumeService = new SetVolume();
/** gfs的 web 服务的 api */
SetVolume setVolume = new SetVolume();
@Resource(name = "gfsService")
private IGfsService gfsService;
@ -37,16 +35,16 @@ public class VolumeServiceImpl implements IVolumeService {
@Override
public int save(VolumeEntity entity) throws Exception {
public int save(VolumeDataEntity entity) throws Exception {
int rest = 1;
//createVolume("lili_test1", 0, "distributed", bricksToCreate, "/home/lili_test1_point")
List<VolumeEntity> result = gfsService.getAllVolumes();
List<VolumeEntity> addVolumes = new ArrayList<VolumeEntity>();
VolumeEntity volumeTmp = null;
List<VolumeDataEntity> result = gfsService.getAllVolumes();
List<VolumeDataEntity> addVolumes = new ArrayList<VolumeDataEntity>();
VolumeDataEntity volumeTmp = null;
if (null != result) {
boolean isExits = false;
//.trim() 去掉空格
for (VolumeEntity volumeOnServer : result) {
for (VolumeDataEntity volumeOnServer : result) {
if(entity.getName().trim().equals(volumeOnServer.getName().trim())){
isExits = true;
//TODO 服务器上有该volume
@ -62,7 +60,7 @@ public class VolumeServiceImpl implements IVolumeService {
}
boolean isContinue = true;
// 对比volume信息--原数据没有该volume则新增volume:
for (VolumeEntity add : addVolumes) {
for (VolumeDataEntity add : addVolumes) {
List<String> bristr = new ArrayList<String>();
if (null == add.getName() || "".equals(add.getName())) {
continue;
@ -82,7 +80,8 @@ public class VolumeServiceImpl implements IVolumeService {
//创建volume
if (bristr.size() > 0) {
int createreslt = volumeService.createVolume(add.getName(), 0, "distributed", bristr, add.getPath());
//TODO 换成 web 请求
int createreslt = setVolume.createVolume(add.getName(), 0, "distributed", bristr, add.getPath());
if (createreslt != 1) {
rest = createreslt;
}
@ -116,7 +115,8 @@ public class VolumeServiceImpl implements IVolumeService {
newKeys.addAll(newBrickKeys);
// 新增brick s
if (newKeys.size() > 0) {
int createreslt = volumeService.addBrickVolume(entity.getName(), newKeys, 0, "distributed");
//TODO 换成 web 请求
int createreslt = setVolume.addBrickVolume(entity.getName(), newKeys, 0, "distributed");
if (createreslt != 1) {
rest = createreslt;
}
@ -132,7 +132,8 @@ public class VolumeServiceImpl implements IVolumeService {
deleteKeys.addAll(serverBrickKeys);
// 删除brick s
if (deleteKeys.size() > 0) {
int createreslt = volumeService.deleteBrickVolume(entity.getName(), deleteKeys, 0, "distributed");
//TODO 换成 web 请求
int createreslt = setVolume.deleteBrickVolume(entity.getName(), deleteKeys, 0, "distributed");
if (createreslt != 1) {
rest = createreslt;
}
@ -153,29 +154,37 @@ public class VolumeServiceImpl implements IVolumeService {
}
@Override
public int delete(VolumeEntity entity) throws Exception {
public int delete(VolumeDataEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
int rest = volumeService.deleteVolume(entity.getName());
//TODO 换成 web 请求
int rest = setVolume.deleteVolume(entity.getName());
volumeDao.remove(entity.getName());
return rest;
}
@Override
public int start(VolumeEntity entity) throws Exception {
public int start(VolumeDataEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
return volumeService.startVolume(entity.getName());
//TODO 换成 web 请求
return setVolume.startVolume(entity.getName());
}
@Override
public int stop(VolumeEntity entity) throws Exception {
public int stop(VolumeDataEntity entity) throws Exception {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
return volumeService.stopVolume(entity.getName());
//TODO 换成 web 请求
return setVolume.stopVolume(entity.getName());
}
@Override
public String getAllvolume() throws Exception {
return setVolume.getAllvolume();
}
}

@ -0,0 +1,281 @@
package com.platform.service.thread;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.ReplicationController;
import java.sql.Connection;
import java.util.List;
import java.util.Set;
import org.apache.log4j.Logger;
import com.platform.dao.DataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.OracleConnectorParams;
import com.platform.kubernetes.SimpleKubeClient;
import com.platform.oracle.OracleConnector;
import com.platform.utils.CacheOracleCheckoutEntity;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper;
/** oracle
* @author chen
*
*/
public class ThreadCheckoutStandardOracle extends Thread {
public final static Logger log = Configs.CONSOLE_LOGGER.getLogger(ThreadCheckoutStandardOracle.class);
/**
* kuber
*/
private SimpleKubeClient client;
/**
* dataInfo
*/
private DataInfoDao dataInfoDao;
public ThreadCheckoutStandardOracle(DataInfoDao dataInfoDao) {
this.client = new SimpleKubeClient();
this.dataInfoDao = dataInfoDao;
}
@Override
public void run() {
try {
Thread.sleep(1000*5);
} catch (InterruptedException e2) {
log.error(e2);
}
//循环11次每次休眠
for (int i = 0; i < 11; i++) {
try {
// 数据的 keys =kuber的应用名称 taskName)
Set<String> taskNames = CacheOracleCheckoutEntity.getCheckKeys();
int lengs = taskNames.size();
if (lengs == 0) {
break;
}
String[] taskNamekeys = taskNames.toArray(new String[lengs]);
StringBuffer sbtask = new StringBuffer();
for (int j = 0; j < taskNamekeys.length; j++) {
sbtask.append(taskNamekeys[j]).append("\t");
}
log.info("replicationController标签 " + sbtask.toString());
for (String key : taskNamekeys) {
// 获得 kuber的 pod
Pod tmpPod = filterPod(key);
if (null == tmpPod) {
log.info("replicationController标签 " + key + " 的 pod 节点不存在!");
if (i > 5) {
CacheOracleCheckoutEntity.checkRemove(key);
}
continue;
}
// 尝试 连接 oracle
connectOracle(tmpPod, key);
if (i == 10) {
String cmd = "kubectl label --overwrite rc " + key
+ " status=1";
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
log.info("更新replicationController标签 "
+ key + "\t[标签更新为: 失败]");
log.info(sb.toString());
String cmd2 = "kubectl annotate --overwrite rc " + key
+ " checkoutFlag=0";
List<String> rList2 = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd2);
StringBuffer sb2 = new StringBuffer();
for (String str : rList2)
sb2.append(str).append("\n");
log.info("更新replicationController标签 "
+ key + "\t[标签更新为: 未校验]");
log.info(sb2.toString());
// 当前key标签对应的 数据服务的记录
CheckoutEntity tmp = CacheOracleCheckoutEntity.getCheck(key);
tmp.setCheckoutFlag(Constant.CHECKOUTFLAG_ZERO);
tmp.setPayResultLast(Constant.CHECKOUT_STATUS_ZERO);
tmp.setExecResultLast(Constant.CHECKOUT_STATUS_ZERO);
try {
//更新数据库
this.updateDataInfo(tmp);
} catch (Exception e) {
log.error(e.getMessage());
}
}
}
} catch (Exception e1) {
log.error(e1.getStackTrace());
}
finally{
try {
Thread.sleep(1000*60);
} catch (InterruptedException e) {
log.error(e.getMessage());
}
}
}
}
/** pod
* @param taskName
* @return
*/
private Pod filterPod(String taskName) {
Pod pod = null;
ReplicationController replicationController = client
.getReplicationController(taskName);
if (null != replicationController) {
List<Pod> filterPods = client
.getPodsForApplicaList(replicationController);
if (filterPods != null && filterPods.size() > 0) {
pod = filterPods.get(0);
}
}
return pod;
}
/** oracle
* @param tmpPod
* @param key
*/
private void connectOracle(Pod pod, String key) throws Exception{
if (pod != null) {
String ip = client.getPodHostIp(pod);
int port = client.getPodContainerport(pod);
if (ip != null && port != 0) {
String url = "jdbc:oracle:thin:@" + ip + ":" + port
+ ":" + Configs.ORACLE_ORCL;
boolean flag = OracleConnector.canConnect(url, // 连接结果返回参数true标示连接成功false标示连接失败
Configs.ORACLE_USER, Configs.ORACLE_PSW);
log.info("url:" + url + ",user:"
+ Configs.ORACLE_USER + ",password:"
+ Configs.ORACLE_PSW);
String message = "失败";
String cmd3 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=0";
List<String> rList3 = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd3);
StringBuffer sb3 = new StringBuffer();
for (String str : rList3)
sb3.append(str).append("\n");
log.info(sb3.toString());
log.info("更新replicationController标签 "
+ key + "\t[标签更新为:未校验]");
if (flag) {
String cmd = "kubectl label --overwrite rc "
+ key + " status=2";
// 设置服务为 成功
List<String> rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd);
StringBuffer sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
log.info(sb.toString());
message = "成功";
log.info("更新replicationController标签 "
+ key + "\t[标签更新为: 成功]");
//校验标签
String cmd2 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=2";
List<String> rList2 = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd2);
StringBuffer sb2 = new StringBuffer();
for (String str : rList2)
sb2.append(str).append("\n");
log.info(sb2.toString());
log.info("更新replicationController标签 "
+ key + "\t[标签更新为: 校验中]");
//获得当前 服务对应的 数据
CheckoutEntity tmp = CacheOracleCheckoutEntity.getCheck(key);
if (null != tmp) {
CacheOracleCheckoutEntity.putExtract(key, tmp);
}
// 查询 对应的 2 个标准表
OracleConnectorParams oc = new OracleConnectorParams();
String logName = tmp.getAreaCode().toLowerCase()+"_"+tmp.getSysCode()+"_"+tmp.getDataVersion();
oc.setName(logName);
try {
Connection conn = OracleConnector.connectionBuilder(url, Configs.ORACLE_USER, Configs.ORACLE_PSW, oc);
//支付--校验
if (!Constant.CHECKOUT_STATUS_ONE.equals(tmp.getPayResultLast())) {
String paySql = "select * from dba_tables where owner = '"+Configs.COLLECT_STANDARD_TABLE_USER.toUpperCase()
+ "' and table_name = '"+Configs.COLLECT_PAY_TABLE.toUpperCase() +"'";
if(OracleConnector.execUpdateOracleSQL(conn, paySql,
FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)+ logName +"jy.log")){
tmp.setPayResultLast(Constant.CHECKOUT_STATUS_THREE);
}
else {
tmp.setPayResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
//可执行-- 校验
if (!Constant.CHECKOUT_STATUS_ONE.equals(tmp.getExecResultLast())) {
String execSql = "select * from dba_tables where owner = '"+Configs.COLLECT_STANDARD_TABLE_USER.toUpperCase()
+ "' and table_name = '"+Configs.COLLECT_EXEC_TABLE.toUpperCase() +"'";
if(OracleConnector.execUpdateOracleSQL(conn, execSql,
FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)+ logName +"jy.log")){
tmp.setExecResultLast(Constant.CHECKOUT_STATUS_THREE);
}else {
tmp.setExecResultLast(Constant.CHECKOUT_STATUS_FOUR);
}
}
tmp.setCheckoutFlag(Constant.CHECKOUTFLAG_ONE);
// 更新数据库data_info
updateDataInfo(tmp);
// 将 CacheOracleCheckoutEntity checkMap中的 数据 放入extractMap中
/*CacheOracleCheckoutEntity.putExtract(key, */CacheOracleCheckoutEntity.checkRemove(key)/*)*/;
// 更新kuber状态
cmd2 = "kubectl annotate --overwrite rc "
+ key + " checkoutFlag=1";
// client.updateOrAddReplicasLabelById(taskNSyame,
// "status", "2");
rList = Constant.ganymedSSH
.execCmdWaitAcquiescent(cmd2);
sb = new StringBuffer();
for (String str : rList)
sb.append(str).append("\n");
log.info(sb.toString());
message = "成功";
log.info("更新replicationController标签 "
+ key + "\t[标签更新为: 已校验]");
} catch (Exception e) {
log.error(e.getStackTrace());
}
// 成功 就 清除 CacheOracleCheckoutEntity 中 的该条记录
CacheOracleCheckoutEntity.checkRemove(key);
}
log.info("连接到数据库服务: " + key
+ "\t[连接结果: " + message + "]");
}
}
}
/** dataInfo
* @param checkoutEntity
* @throws Exception
*/
private void updateDataInfo(CheckoutEntity checkoutEntity) throws Exception {
DataInfoEntity data = new DataInfoEntity();
// 状态改为 正则校验 Constant.CHECKOUTFLAG_TWO
data.setId(checkoutEntity.getDataId());
data.setPayResultLast(checkoutEntity.getPayResultLast());
data.setExecResultLast(checkoutEntity.getExecResultLast());
data.setCheckoutFlag(checkoutEntity.getCheckoutFlag());
dataInfoDao.update(data);
}
}

@ -2,7 +2,7 @@ package com.platform.service.thread;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.oracleForm;
import com.platform.form.oracleForm;
import com.platform.service.IOracleExtractService;
/** oracle

@ -0,0 +1,46 @@
package com.platform.service.thread;
import org.apache.log4j.Logger;
import com.base.Custom4exception;
import com.platform.form.oracleForm;
import com.platform.service.IOracleExtractService;
import com.platform.service.impl.CheckoutServiceImpl;
/** 线
* @author chen
*
*/
public class ThreadExtractStandardOracle extends Thread {
/**
*
*/
public static Logger log = Logger.getLogger(CheckoutServiceImpl.class);
/**
*
*/
private IOracleExtractService OracleExtract;
private oracleForm form;
/** oracle
* @param form
* @param OracleExtract
*/
public ThreadExtractStandardOracle(oracleForm form, IOracleExtractService OracleExtract) {
this.OracleExtract = OracleExtract;
this.form = form;
}
@Override
public void run() {
try {
OracleExtract.extractStandardTable(form.getName(), form.getInneed(),form.getTarget());
} catch (Exception e) {
log.error(Custom4exception.threadVolume_Oracle_Except,e);
}
}
}

@ -0,0 +1,209 @@
package com.platform.service.thread;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.util.List;
import com.base.CustomException;
import com.platform.dao.DataInfoDao;
import com.platform.entities.CheckoutEntity;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.GatherOracleInfo;
import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector;
import com.platform.service.OracleExtractHelper;
import com.platform.utils.Configs;
import com.platform.utils.Constant;
import com.platform.utils.FileOperateHelper;
/** sqlServer 线
* @author chen
*
*/
public class ThreadExtractStandardSqlServer extends Thread{
/**
*
*/
private OracleExtractHelper oracleExtract = new OracleExtractHelper();
/** 汇总库 */
private GatherOracleInfo oracleConnect;
/** 待抽取的实体 */
private List<CheckoutEntity> Extractlist;
/** 数据管理 DAO */
private DataInfoDao dataInfoDao;
public ThreadExtractStandardSqlServer(GatherOracleInfo oracleConnect, List<CheckoutEntity> Extractlist, DataInfoDao dataInfoDao) {
this.oracleConnect = oracleConnect;
this.Extractlist = Extractlist;
this.dataInfoDao = dataInfoDao;
}
@Override
public void run() {
for (CheckoutEntity element : Extractlist) {
//校验结果:成功或失 0未校验1不需校验2正在校验3校验成功4校验失败5待抽取6正在抽取7抽取完成
//TODO 开始抽取
//如果校验成功的 才 进行 抽取----支付标准表
if (Constant.CHECKOUT_STATUS_FIVE.equals(element.getPayResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(element.getPayResultLast())) {
String payFilePath = FileOperateHelper.addLastSeparator(element.getPath())+Constant.standard_pay
+ element.getAreaCode().toLowerCase()+"_" + element.getSysCode()+".sql";
DataInfoEntity data = new DataInfoEntity();
data.setId(element.getDataId());
data.setPayResultLast(Constant.CHECKOUT_STATUS_SIX);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
File paySql = new File(payFilePath);
//获取连接
Connection conn = OracleConnector.connectionBuilder("jdbc:oracle:thin:@" + oracleConnect.getIp() + ":" + oracleConnect.getPort() + ":"
+ oracleConnect.getDatabaseName(), oracleConnect.getUser(), oracleConnect.getPassword(), null);
//设置 日志 的 文件名
OracleConnectorParams collectOracle = new OracleConnectorParams();
collectOracle.setName("CQ"+ element.getAreaCode().toLowerCase()+"_"+element.getSysCode()+"_"+element.getDataVersion());
// 创建表空间 创建 抽取标准表的 用户并授权
oracleExtract.createTableSpace(conn, collectOracle , oracleConnect); //
oracleExtract.createOnlyUser(conn, collectOracle, oracleConnect);//
createPay(conn, collectOracle);
//读取文件流
FileInputStream fis = new FileInputStream(paySql);
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"GBK"));
String sql = br.readLine();
while (sql != null) {
//TODO 执行sql
sql = br.readLine();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)
+ "CQ"+element.getAreaCode()+"_"+element.getSysCode()+"_"+element.getDataVersion()+".log");
sql = br.readLine();
}
// 抽取完成
data.setPayResultLast(Constant.CHECKOUT_STATUS_SEVEN);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//如果校验成功的 才 进行 抽取----执行标准表
if (Constant.CHECKOUT_STATUS_FIVE.equals(element.getExecResultLast())
|| Constant.CHECKOUT_STATUS_SIX.equals(element.getExecResultLast())){
String execFilePath = FileOperateHelper.addLastSeparator(element.getPath())+Constant.standard_indicate
+ element.getAreaCode().toLowerCase() +"_" + element.getSysCode()+".sql";
DataInfoEntity data = new DataInfoEntity();
data.setId(element.getDataId());
data.setExecResultLast(Constant.CHECKOUT_STATUS_SIX);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
File execSql = new File(execFilePath);
Connection conn = OracleConnector.connectionBuilder("jdbc:oracle:thin:@" + oracleConnect.getIp() + ":" + oracleConnect.getPort() + ":"
+ oracleConnect.getDatabaseName(), oracleConnect.getUser(), oracleConnect.getPassword(), null);
//设置 日志 的 文件名
OracleConnectorParams collectOracle = new OracleConnectorParams();
collectOracle.setName("CQ"+ element.getAreaCode().toLowerCase()+"_"+element.getSysCode()+"_"+element.getDataVersion());
// 创建表空间 创建 抽取标准表的 用户并授权
oracleExtract.createTableSpace(conn, collectOracle , oracleConnect); //
oracleExtract.createOnlyUser(conn, collectOracle, oracleConnect);//
createExec(conn, collectOracle);
FileInputStream fis = new FileInputStream(execSql);
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"GBK"));
String sql = br.readLine();
while (sql != null) {
//TODO 执行sql
//TODO 执行sql
sql = br.readLine();
String resultSql = sql.replace(";", "");
OracleConnector.execOracleSQL(conn, resultSql, FileOperateHelper.addLastSeparator(Configs.EXTRACT_STANDARD_LOG_LOCALTION)
+ "CQ"+element.getAreaCode()+"_"+element.getSysCode()+"_"+element.getDataVersion()+".log");
sql = br.readLine();
}
//抽取完成
data.setExecResultLast(Constant.CHECKOUT_STATUS_SEVEN);
try {
dataInfoDao.update(data);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
private void createPay(Connection conn, OracleConnectorParams oc) {
String payCmd = "CREATE TABLE u_bzbjy.zfxxb(XZQHDM Varchar(255),XZQHMC Varchar(255),PZBH Varchar(255),LYZBKZH Varchar(255),"
+ "ZFDATE Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),YWGKCS Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),"
+"XMLBCODE Varchar(255),XMLBNAME Varchar(255),ZB_NO Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+"JJFLNAME Varchar(255),ZJXZCODE Varchar(255),ZJXZNAME Varchar(255),JSBFFSNAME Varchar(255),SKR Varchar(255),SKRYH Varchar(255),"
+ "SKRZHZH Varchar(255),FKZHCODE Varchar(255),FKZHNAME Varchar(255),FKYHCODE Varchar(255),FKYHNAME Varchar(255),QSZHCODE Varchar(255),"
+ "QSZHNAME Varchar(255),QSYHCODE Varchar(255),QSYHNAME Varchar(255),JE Numeric(18,2), SFTK Varchar(255),NIAN Varchar(255),ZY Varchar(255))";
try{
OracleConnector.execOracleSQL(conn, payCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}catch(Exception e){
}
}
private void createExec(Connection conn, OracleConnectorParams oc) {
String execCmd = "CREATE TABLE u_bzbjy.kzxzb(XZQHDM Varchar(255),XZQHMC Varchar(255),YSND Varchar(255),ZBCODE Varchar(255),ZB_ID Varchar(255),ZB_NO Varchar(255),"
+ "ZBDJLXCODE Varchar(255),ZBDJLXNAME Varchar(255),ZBLXNAME Varchar(255),DOCNO Varchar(255),ZBSM Varchar(255),ZBFWDATE Varchar(255),ZBYSLXCODE Varchar(255),"
+ "ZBYSLXNAME Varchar(255),ZBYSLYNAME Varchar(255),YSDWCODE Varchar(255),YSDWNAME Varchar(255),GNFLCODE Varchar(255),GNFLNAME Varchar(255),JJFLCODE Varchar(255),"
+ "JJFLNAME Varchar(255),ZBGLCSNAME Varchar(255),SZGLCODE Varchar(255),SZGLNAME Varchar(255),XMCODE Varchar(255),XMNAME Varchar(255),GZBZ Varchar(255),"
+ "JJBZ Varchar(255),CGBZ Varchar(255),ZFFSCODE Varchar(255),ZFFSNAME Varchar(255),JZZFBZ Varchar(255),ZBJE Numeric(18,2),ZBTJJE Numeric(18,2),ZBDJJE Numeric(18,2),"
+ "ZBKYJE Numeric(18,2),ZYZFBZ Varchar(255),BZ Varchar(255))";
try{
OracleConnector.execOracleSQL(conn, execCmd, Configs.EXTRACT_STANDARD_LOG_LOCALTION + oc.getName());
}catch(Exception e){
}
}
}

@ -2,7 +2,7 @@ package com.platform.service.thread;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.oracleForm;
import com.platform.form.oracleForm;
import com.platform.service.IOracleExtractService;
/** oracle

@ -1,5 +1,6 @@
package com.platform.service.thread;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -12,29 +13,28 @@ import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.base.TaskOperateData;
import com.platform.dao.DataInfoDao;
import com.platform.dao.DataInfoMoveTmpDao;
import com.platform.dao.GatherOracleDao;
import com.platform.entities.DataInfoEntity;
import com.platform.entities.DataInfoEntityMoveTmp;
import com.platform.entities.GatherOracleInfo;
import com.platform.glusterfs.CheckoutMD5;
import com.platform.glusterfs.CopyData;
import com.platform.http.gfs.CopyData;
import com.platform.glusterfs.ShowData;
import com.platform.service.DataInfoService;
import com.platform.service.DataInfoServiceImp;
import com.platform.service.IMoveDataService;
import com.platform.service.impl.MoveDataServiceImpl;
import com.platform.utils.Bean2MapUtils;
import com.platform.utils.Constant;
import com.platform.utils.DateForm;
import com.platform.utils.FileOperateHelper;
/** ---()
* @author chen
*
*/
@Component
public class ThreadMoveData{
public static Logger log = Logger.getLogger(ThreadMoveData.class);
public final static Logger log = Logger.getLogger(ThreadMoveData.class);
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
@ -63,8 +63,127 @@ public class ThreadMoveData{
public ThreadMoveData() {
}
//5秒
@Scheduled(fixedDelay = 5000)
//迁移数据 -- 2016-11-30后 使用
@Scheduled(fixedDelay = 4000)
public void moveDataByWebGfs(){
List<DataInfoEntityMoveTmp> result = new ArrayList<DataInfoEntityMoveTmp>();
List<DataInfoEntityMoveTmp>[] subMove = new ArrayList[4];
for (int i = 0; i < 4; i++) {
subMove[i] = new ArrayList<DataInfoEntityMoveTmp>();
}
try {
result = dataInfoMoveTmpDao.findAll();
} catch (Exception e) {
log.error(e);
}
Map<String, TaskOperateData> taskMap = new HashMap<String, TaskOperateData>();
for ( DataInfoEntityMoveTmp moveE : result) {
switch (moveE.getCompleteStatus()) {
//待迁移
case "0":
subMove[0].add(moveE);
break;
//正在迁移
case "1":
subMove[1].add(moveE);
break;
//迁移完成的
case "2":
subMove[2].add(moveE);
break;
//迁移失败
case "3":
subMove[3].add(moveE);
break;
default:
break;
}
}
//迁移失败---不处理 status = -1表示迁移完成校验失败,-2:表示迁移失败 -3表示删除失败
//迁移完成的--不处理 status = 3表示校验成功
//正则迁移 status = 1表示正在迁移(如果 web gfs 迁移成功 则 增加一条记录)
if(subMove[1].size() > 0){
//请求进度
List<TaskOperateData> list = new ArrayList<TaskOperateData>();
try {
list = copy.operationTask();
} catch (Exception e) {
log.error("copy.operationTask()");
log.error(e);
}
for (TaskOperateData taskOperateData : list) {
taskMap.put(FileOperateHelper.addLastLinuxSeparator(taskOperateData.getSourcePath())
+ "-" + FileOperateHelper.addLastLinuxSeparator(taskOperateData.getDestPath()),
taskOperateData);
}
for (DataInfoEntityMoveTmp moveE : subMove[1]) {
TaskOperateData taskOne = taskMap.get(FileOperateHelper.addLastLinuxSeparator(moveE.getDataPath())
+"-"+FileOperateHelper.addLastLinuxSeparator(makeDstPath(moveE.getDstPath())));
if (null == taskOne) {
long nowTime = new Date().getTime();
long timelong = nowTime - DateForm.string2DateBysecond(moveE.getLastTime()).getTime();
if (timelong > 1000*60*20) {
try {
dataInfoMoveTmpDao.update(moveE);
} catch (Exception e) {
log.error(e);
}
}
continue;
}
moveE.setRate(taskOne.getProgress());
moveE.setLastTime(DateForm.date2StringBysecond(new Date()));
if (3 == taskOne.getStatus()) {
//成功
makeDataInfo(moveE);
}else if(taskOne.getStatus() < 0){
//失败
moveE.setCompleteStatus("3");
try {
dataInfoMoveTmpDao.update(moveE);
} catch (Exception e) {
log.error(e);
}
}
}
}
//待迁移 status = 0准备迁移则开始迁移
if(subMove[0].size() > 0){
//正则迁移的 数量
int curMoveNum = subMove[1].size();
for ( DataInfoEntityMoveTmp moveE : subMove[0]) {
if(curMoveNum <= Constant.moveFileMaxNum){
moveE.setLastTime(DateForm.date2StringBysecond(new Date()));
//请求迁移
curMoveNum++;
try {
if(1==copy.copyFolder(moveE.getDataPath(), makeDstPath(moveE.getDstPath()))){
moveE.setCompleteStatus("1");
}
else {
moveE.setCompleteStatus("3");
}
} catch (Exception e) {
log.error("copy.copyFolder()");
log.error(e);
}
try {
dataInfoMoveTmpDao.update(moveE);
} catch (Exception e) {
log.error(e);
}
}
}
}
}
//5秒 //2016-11-30后 不使用
// @Scheduled(fixedDelay = 5000)
public void doSomething() {
try {
@ -89,8 +208,7 @@ public class ThreadMoveData{
long nowTime = new Date().getTime();
long timelong = nowTime - DateForm.string2DateBysecond(dataMove.getLastTime()).getTime();
if (timelong > 1000*60*20) {
dataMove.setCompleteStatus("3");
dataInfoMoveTmpDao.update(dataMove);
doMd5(srcSizeTemp, dstSize, dataMove);
}
//正在上传的个数。
moveFileCurrNum++;
@ -119,48 +237,22 @@ public class ThreadMoveData{
}
if (srcSize > 0 && dstSize > 0) {
realRate = (dstSize*100 / srcSize );
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
}
if (srcSize == dstSize || realRate > 100) {
realRate = 100;
}
dataMove.setRate((int) realRate);
if (realRate > dataMove.getRate()) {
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataMove.setRate((int) realRate);
}
}
if("1".equals(dataMove.getCompleteStatus()) && dataMove.getRate() > 0){
//传输完毕:进行校验
if (realRate >= 100) {
int difSize = (int) (srcSizeTemp-dstSize);
Thread.sleep(10*difSize);
//TODO 查看当前拷贝目录进程是否结束?
// 进行MD5校验
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
// 校验成功--则增加数据库记录
if(resl == 1){
// 判断 迁移数据的status是否改为 2
DataInfoEntityMoveTmp movetmp = dataInfoMoveTmpDao.findById(dataMove.getId());
if (null != movetmp && !"2".equals(movetmp.getCompleteStatus())) {
//校验成功--修改 数据库记录--
dataMove.setCompleteStatus("2");
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.update(dataMove);
//TODO 新增 一条数据-到-dataInfo
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
data.setDataPath(dataMove.getDstPath());
data.setVolumeIp(dataMove.getDstVolumeIp());
data.setVolumePath(dataMove.getDstVolumePath());
data.setVolumeIp(dataMove.getVolumeIp());
data.setId(0);
dataInfoDao.save(data);
}
}
else {
// 3:表示 迁移失败
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataMove.setCompleteStatus("3");
}
//TODO
doMd5(srcSizeTemp, dstSize, dataMove);
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
}
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.update(dataMove);
}
}
@ -178,15 +270,16 @@ public class ThreadMoveData{
if ("0".equals(next2move.getCompleteStatus())) {
//待迁移的数据 -- 开始迁移
// 末尾 含有 /
Pattern pattern2 = Pattern.compile("\\/$");
String dstPath = next2move.getDataPath();
Pattern pattern2 = Pattern.compile("\\d+\\/$");
String dstPath = next2move.getDstPath();
Matcher matcher2 = pattern2.matcher(dstPath);
//去掉 最后 的 / 符合
//去掉 最后 的 数字 +/ 符合
if (matcher2.find()) {
dstPath = dstPath.substring(0, dstPath.length()-1);
String removeStr = matcher2.group();
dstPath = dstPath.replace(removeStr, "");
}
//数据迁移。
copy.copyFolder(dstPath+"/app", next2move.getDstPath());
copy.copyFolder(next2move.getDataPath(), dstPath);
// "1" :正在上传0等待 迁移, 2成功 3失败
next2move.setCompleteStatus("1");
next2move.setLastTime(DateForm.date2StringBysecond(new Date()));
@ -205,5 +298,122 @@ public class ThreadMoveData{
}
}
/** md5
* @param srcSizeTemp
* @param dstSize
* @param dataMove
* @throws Exception
*/
private void doMd5(long srcSizeTemp, long dstSize, DataInfoEntityMoveTmp dataMove) throws Exception {
int difSize = (int) (srcSizeTemp-dstSize);
if (difSize < 1) {
difSize = 1;
}
Thread.sleep(10*difSize);
//TODO 查看当前拷贝目录进程是否结束?
// 进行MD5校验
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
// 校验成功--则增加数据库记录
if(resl == 1){
try{
// 判断 迁移数据的status是否改为 2
DataInfoEntityMoveTmp movetmp = dataInfoMoveTmpDao.findById(dataMove.getId());
if(null != movetmp){
if (!"2".equals(movetmp.getCompleteStatus())) {
//校验成功--修改 数据库记录--
dataMove.setCompleteStatus("2");
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.update(dataMove);
//TODO 新增 一条数据-到-dataInfo
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
data.setDataPath(dataMove.getDstPath());
data.setVolumeIp(dataMove.getDstVolumeIp());
data.setVolumePath(dataMove.getDstVolumePath());
data.setVolumeIp(dataMove.getVolumeIp());
data.setPayResult(dataMove.getPayResult());
data.setExecResult(dataMove.getExecResult());
data.setId(0);
dataInfoDao.save(data);
}
else {
dataMove.setCompleteStatus("2");
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.update(dataMove);
}
}
}catch(Exception e){
log.error(e);
}
}
else {
// 3:表示 迁移失败
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataMove.setCompleteStatus("3");
}
}
private int makeDataInfo(DataInfoEntityMoveTmp dataMove){
try{
// 判断 迁移数据的status是否改为 2
DataInfoEntityMoveTmp movetmp = dataInfoMoveTmpDao.findById(dataMove.getId());
if(null != movetmp){
if (!"2".equals(movetmp.getCompleteStatus())) {
//校验成功--修改 数据库记录--
dataMove.setCompleteStatus("2");
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
dataInfoMoveTmpDao.update(dataMove);
//TODO 新增 一条数据-到-dataInfo
DataInfoEntity data = (DataInfoEntity) Bean2MapUtils.convertMap(
DataInfoEntity.class, Bean2MapUtils.convertBean(dataMove));
data.setDataPath(dataMove.getDstPath());
if (null == dataMove.getDstVolumeIp()) {
data.setVolumeIp("localhost");
}else {
data.setVolumeIp(dataMove.getDstVolumeIp());
}
// volume路径没有传入
if (null == dataMove.getDstVolumePath()) {
data.setVolumePath(dataMove.getDstPath());
}else {
data.setVolumePath(dataMove.getDstVolumePath());
}
data.setPayResult(dataMove.getPayResult());
data.setExecResult(dataMove.getExecResult());
data.setId(0);
try {
dataInfoDao.save(data);
} catch (Exception e) {
log.error(e);
dataMove.setCompleteStatus("1");
dataInfoMoveTmpDao.update(dataMove);
}
}
}else {
dataInfoMoveTmpDao.update(dataMove);
}
}catch(Exception e){
log.error(e);
}
return 1;
}
/** +/
* @param dstPath
* @return
*/
private String makeDstPath(String dstPath) {
// 末尾 含有 数字 + /
Pattern pattern2 = Pattern.compile("\\d+\\/$");
Matcher matcher2 = pattern2.matcher(dstPath);
//去掉 最后 的 数字 +/ 符合
if (matcher2.find()) {
String removeStr = matcher2.group();
dstPath = dstPath.replace(removeStr, "");
}
return dstPath;
}
}

@ -25,7 +25,7 @@ public class Bean2MapUtils {
* @throws InvocationTargetException
* setter
*/
public static Object convertMap(Class type, Map map)
public static Object convertMap(Class<?> type, Map<String, Object> map)
throws IntrospectionException, IllegalAccessException,
InstantiationException, InvocationTargetException {
BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性
@ -62,10 +62,10 @@ public class Bean2MapUtils {
* @throws IllegalAccessException JavaBean
* @throws InvocationTargetException setter
*/
public static Map convertBean(Object bean)
public static Map<String, Object> convertBean(Object bean)
throws IntrospectionException, IllegalAccessException, InvocationTargetException {
Class type = bean.getClass();
Map returnMap = new HashMap();
Class<?> type = bean.getClass();
Map<String, Object> returnMap = new HashMap<String, Object>();
BeanInfo beanInfo = Introspector.getBeanInfo(type);
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();

@ -60,7 +60,7 @@ public class BeanCopy {
if (null != value)
field.set(dst, value);
} catch (Exception e) {
log.error(e.getStackTrace());
log.error(e);
}
}
}
@ -154,7 +154,7 @@ public class BeanCopy {
m = faClass.getMethod("get"+upperHeadChar(f.getName()));
Object obj = m.invoke(father);
f.set(dst, obj);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
} catch (Exception e) {
log.error(e.getStackTrace());
}
}

@ -0,0 +1,69 @@
package com.platform.utils;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import com.platform.entities.CheckoutEntity;
/** oracle
* @author chen
*
*/
public class CacheOracleCheckoutEntity {
/**
* oracle
*/
private static Map<String, CheckoutEntity> checkMap = new HashMap<String, CheckoutEntity>();
/**
* oracle--(使)
*/
private static Map<String, CheckoutEntity> extractStandardMap = new HashMap<String, CheckoutEntity>();
/**
* @return the checkMap
*/
public static Set<String> getCheckKeys() {
return checkMap.keySet();
}
/**
* @param checkMap the checkMap to set
*/
public static CheckoutEntity putCheck(String key, CheckoutEntity data) {
return checkMap.put(key, data);
}
public static CheckoutEntity getCheck(String key){
return checkMap.get(key);
}
public static CheckoutEntity checkRemove(String key){
return checkMap.remove(key);
}
/**
* @return the extractStandardMap
*/
public static Set<String> getExtractKeys() {
return extractStandardMap.keySet();
}
/**
* @param extractStandardMap the extractStandardMap to set
*/
public static CheckoutEntity putExtract(String key, CheckoutEntity data) {
return extractStandardMap.put(key, data);
}
public static CheckoutEntity getExtract(String key){
return extractStandardMap.get(key);
}
public static CheckoutEntity extractRemove(String key){
return extractStandardMap.remove(key);
}
}

@ -1,36 +1,51 @@
package com.platform.utils;
import java.util.List;
import java.util.Map;
import com.platform.entities.FolderNode;
import com.platform.entities.VolumeEntity;
import com.platform.entities.VolumeDataEntity;
/** gfs volume
* @author chen
*
*/
public class CacheTreeData {
/**
*
*/
private static List<FolderNode> folders = null;
private static List<VolumeEntity> volumeList = null;
/**
* volume
*/
private static List<VolumeDataEntity> volumeList = null;
/**
* @return
*/
public static List<FolderNode> getFolders() {
return folders;
}
/**
* @param folders
*/
public synchronized static void setFolders(List<FolderNode> folders) {
CacheTreeData.folders = folders;
}
/**
/** volume
* @return the volumeList
*/
public static List<VolumeEntity> getVolumeList() {
public static List<VolumeDataEntity> getVolumeList() {
return volumeList;
}
/**
/** volume
* @param volumeList the volumeList to set
*/
public synchronized static void setVolumeList(List<VolumeEntity> volumeList) {
public synchronized static void setVolumeList(List<VolumeDataEntity> volumeList) {
CacheTreeData.volumeList = volumeList;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save