---添加文件上传下载功能

web_backend_develope
wu ming 9 years ago
commit 159fe1a3c1

@ -1,56 +1,72 @@
#=============================================================================================================
# MySQL
#=============================================================================================================
# 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接url
jdbc.mysql.url=jdbc:mysql://192.168.0.101:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
# 用户名
jdbc.mysql.username=root
# 密码
jdbc.mysql.password=root
#=============================================================================================================
# Oracle 连接配置
#=============================================================================================================
# hui用户名
gather-user-name=system
# 密码
gather-user-password=oracle
#
gather-port=1521
#
gather-service-name=orcl
#=============================================================================================================
# 数据库公共配置
#=============================================================================================================
jdbc.initialSize=5
jdbc.minIdle=5
jdbc.maxIdle=20
jdbc.maxActive=100
jdbc.maxWait=100000
jdbc.defaultAutoCommit=false
jdbc.removeAbandoned=true
jdbc.removeAbandonedTimeout=600
jdbc.testWhileIdle=true
jdbc.timeBetweenEvictionRunsMillis=60000
jdbc.numTestsPerEvictionRun=20
jdbc.minEvictableIdleTimeMillis=300000
#==============================================================================================================
#
#==============================================================================================================
table-suffix=_20152016
extract-log-localtion=/home/web_manage/log/
gather-tablespace-name=TS_TTSSS
gather-tablespace-path=
gather-table-user-password=
kubeMasterUrl=http://192.168.0.110:8080/
collect-user-name=system
collect-password=oracle
collect-service-name=orcl
gfs_control_ip=192.168.0.110
#=============================================================================================================
# MySQL
#=============================================================================================================
# 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接url
jdbc.mysql.url=jdbc:mysql://192.168.0.110:3306/ftpdata?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&autoReconnect=true&failOverReadOnly=false
# 用户名
jdbc.mysql.username=root
# 密码
jdbc.mysql.password=root
#=============================================================================================================
# Oracle 连接配置
#=============================================================================================================
# hui用户名
gather-user-name=system
# 密码
gather-user-password=oracle
#
gather-port=1521
#
gather-service-name=orcl
#=============================================================================================================
# 数据库公共配置
#=============================================================================================================
jdbc.initialSize=5
jdbc.minIdle=5
jdbc.maxIdle=20
jdbc.maxActive=100
jdbc.maxWait=100000
jdbc.defaultAutoCommit=false
jdbc.removeAbandoned=true
jdbc.removeAbandonedTimeout=600
jdbc.testWhileIdle=true
jdbc.timeBetweenEvictionRunsMillis=60000
jdbc.numTestsPerEvictionRun=20
jdbc.minEvictableIdleTimeMillis=300000
#==============================================================================================================
#
#==============================================================================================================
table-suffix=_20152016
extract-log-localtion=/home/web_manage/log/
gather-tablespace-name=TS_TTSSS
#dbf file's path must exist
gather-tablespace-path=/opt/oracle/app/oradata/orcl/
# user's password must exist
gather-table-user-password=user
#kuber's url must exist
kubeMasterUrl=http://192.168.0.110:8080/
collect-user-name=system
collect-password=oracle
collect-service-name=orcl
gfs_control_ip=192.168.0.110
gfs_control_rootPassWd=root
HttpClientConstant_URL_IP_PORT=http://192.168.0.110:8088/jfinal/
#=============================================================================================================
# 文件上传下载
#=============================================================================================================
file_upload_path=D:\\
file_download_path=D:\\uuu.xls

@ -90,4 +90,13 @@
<task:executor id="executor" pool-size="5" />
<task:scheduler id="scheduler" pool-size="10" />
<task:annotation-driven executor="executor" scheduler="scheduler" />
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- set the max upload size100MB -->
<property name="maxUploadSize">
<value>104857600</value>
</property>
<property name="maxInMemorySize">
<value>4096</value>
</property>
</bean>
</beans>

@ -11,7 +11,10 @@ package com.base;
public class Constant {
/** 国际话配置文件文件-i18n.properties */
public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
public final static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
/** 信息系统excel导出模板 */
public final static String SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH = "/com/base/system_templates.xlsx";
/** WritefileThread-线程睡眠时间--3000 */
public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000;
@ -19,5 +22,6 @@ public class Constant {
/** CustomException记录报异常的对象的对象个数--10 */
public final static int CustomException_log_object_size = 10;
/** excel模板真实数据的起始行数 */
public final static int EXCEL_TEMPLATE_INIT_ROW = 8;
}

@ -16,6 +16,7 @@ public class Custom4exception {
* 001
* 001
*/
//3001001
/**
* ThreadVolume volume
*/
@ -26,6 +27,7 @@ public class Custom4exception {
*/
public final static String threadVolume_Thread_Except = "3001001002";
//3002001
/**
* ---
*/
@ -34,7 +36,10 @@ public class Custom4exception {
/** * SQL执行错误 */
public final static String OracleSQL_Except = "3002001002";
/** * 连接汇总-创建oracle连接失败 */
public final static String connect_Oracle_Except = "3002001003";
/** * MySQL错误 */
public final static String MySQL_Except = "3002002003";
public final static String MySQL_Except = "3002002001";
}

@ -2,9 +2,13 @@
package com.base;
import java.beans.IntrospectionException;
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;
/**
@ -83,9 +87,17 @@ public class CustomException extends Exception {
for (int i = 0; i < forSize; i++) {
sbuf.append(array[i]);
sbuf.append("\r\n");
try {
sbuf.append(Bean2MapUtils.convertBean(array[i]));
sbuf.append("\r\n");
} catch (IllegalAccessException | InvocationTargetException
| IntrospectionException e1) {
}
}
if (forSize == Constant.CustomException_log_object_size) {
sbuf.append("......");
sbuf.append("\r\n");
}
sbuf.append("......");
sbuf.append("\r\n");
}
else {
sbuf.append("null");

@ -1,4 +1,11 @@
#3001001
3001001001=ThreadVolume\u7C7B\u67E5\u8BE2 volume\u5F02\u5E38
3001001002=ThreadVolume\u7C7B\u7EBF\u7A0B\u4F11\u7720\u5F02\u5E38
3002001002= \u62BD\u53D6\u6C47\u603B--\u7684-\u83B7\u53D6\u62BD\u53D6\u52A8\u4F5C\u5F02\u5E38
3002001002=SQL\u6267\u884C\u9519\u8BEF
#3002001
3002001001= \u62BD\u53D6\u6C47\u603B--\u7684-\u83B7\u53D6\u62BD\u53D6\u52A8\u4F5C\u5F02\u5E38
3002001002=SQL\u6267\u884C\u9519\u8BEF
3002001003=\u8FDE\u63A5\u6C47\u603B-\u521B\u5EFAoracle\u8FDE\u63A5\u5931\u8D25
#3002002
3002002001=MySQL\u9519\u8BEF

@ -68,6 +68,18 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
ORDER BY a.id
</select>
<!-- 根据id查看某条记录信息 -->
<select id="findById" parameterType ="java.lang.Integer" resultType="com.platform.entities.DataInfoEntityMoveTmp">
SELECT
a.id id,a.regionalism_code regionalismCode,a.dst_path dstPath,a.complete_status completeStatus,
a.rate rate, a.lasttime lastTime, a.system_code systemCode,a.dst_volume_ip dstVolumeIp,a.dst_volume_path dstVolumePath
FROM
move_data_tmp a
<where>
a.id = #{id}
</where>
</select>
<update id="update" parameterType="com.platform.entities.DataInfoEntityMoveTmp">
UPDATE
move_data_tmp

@ -1,6 +1,8 @@
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;
@ -11,6 +13,8 @@ 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,6 +34,7 @@ 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.service.DataInfoService;
import com.platform.service.ICodeService;
import com.platform.service.IGfsService;
@ -38,7 +43,11 @@ import com.platform.service.IMoveDataService;
import com.platform.service.IMySqlService;
import com.platform.service.IOracleExtractService;
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;
@Controller
@ -66,7 +75,7 @@ public class DataModelController extends BaseController {
@Resource(name = "logReadService")
private ILogRead logReadService;
public void setDfsImp(DataInfoService dfs) {
this.dfs = dfs;
}
@ -117,6 +126,13 @@ public class DataModelController extends BaseController {
if (oraclesName != null)
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.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());
new OracleStatusService().connectToOracle(rcName);
}
req.setStatus(200);
@ -142,12 +158,37 @@ public class DataModelController extends BaseController {
public void oracleExtract(HttpServletRequest res, HttpServletResponse req,
@RequestBody oracleForm form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/{name}/extract");
res.setCharacterEncoding("UTF-8");
if (null != form.getInneed() && form.getInneed().size() > 0) {
OracleExtract.extractOracle(form.getName(), form.getInneed(),
form.getTarget());
// res.setCharacterEncoding("UTF-8");
boolean isConnect = false;
//5秒内是否能获得oracle连接否则认为超时。
if (null != form.getTarget()) {
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) {
ThreadExtractOracle thExtra = new ThreadExtractOracle(form, OracleExtract);
thExtra.start();
// OracleExtract.extractOracle(form.getName(), form.getInneed(),
// form.getTarget());
}
req.setStatus(200);
}
// public void oracleExtract(HttpServletRequest res,
@ -181,10 +222,18 @@ public class DataModelController extends BaseController {
@RequestMapping(value = "/volume/list", method = RequestMethod.POST)
@ResponseBody
public List<VolumeEntity> volumeList() throws Exception {
public String volumeList() throws Exception {
HttpUtils ht = new HttpUtils();
log.debug("-----/volume/list------");
List<VolumeEntity> result = gfsService.getAllVolumes();
return result;
//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)
@ -199,7 +248,7 @@ public class DataModelController extends BaseController {
}
datas.addAll(selectItems);
System.out.println("------/volume/{name}/move--------");
log.debug("------/volume/{name}/move--------");
if (datas.size() > 0) {
moveDataService.moveData(datas, form.getSelectNode());
}

@ -0,0 +1,140 @@
package com.platform.controller;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.base.BaseController;
import com.platform.entities.ResumableInfo;
import com.platform.entities.ResumableInfoStorage;
import com.platform.utils.Configs;
import com.platform.utils.HttpUtils;
@Controller
@RequestMapping("/fileOperation")
public class ExcelController extends BaseController {
// 文件上传处理函数
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
public void upload(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int resumableChunkNumber = HttpUtils.toInt(
request.getParameter("resumableChunkNumber"), -1);
ResumableInfo info = getResumableInfo(request);
String requestMethod = request.getMethod();
// 处理GET请求
if ("GET".equals(requestMethod)) {
if (info.uploadedChunks
.contains(new ResumableInfo.ResumableChunkNumber(
resumableChunkNumber))) {
response.getWriter().print("Uploaded."); // This Chunk has been
// Uploaded.
} else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
} else if ("POST".equals(requestMethod)) { // 处理POST请求
RandomAccessFile raf = new RandomAccessFile(info.resumableFilePath,
"rw");
// Seek to position
raf.seek((resumableChunkNumber - 1)
* (long) info.resumableChunkSize);
// Save to file
InputStream is = request.getInputStream();
long readed = 0;
long content_length = request.getContentLength();
byte[] bytes = new byte[1024 * 100];
while (readed < content_length) {
int r = is.read(bytes);
if (r < 0) {
break;
}
raf.write(bytes, 0, r);
readed += r;
}
raf.close();
// Mark as uploaded.
info.uploadedChunks.add(new ResumableInfo.ResumableChunkNumber(
resumableChunkNumber));
if (info.checkIfUploadFinished()) { // Check if all chunks uploaded,
// and change filename
ResumableInfoStorage.getInstance().remove(info);
response.getWriter().print("All finished.");
} else {
response.getWriter().print("Upload");
}
} else { // 不处理非GET/POST请求
throw new IllegalStateException("只接受 POST或GET请求");
}
}
// 文件下载处理函数
@RequestMapping(value = "/file/download")
public ResponseEntity<byte[]> download(HttpServletRequest request,
HttpServletResponse response) throws IOException {
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"),
"iso-8859-1");// 为了解决中文名称乱码问题
headers.setContentDispositionFormData("attachment", fileName);
headers.setContentDispositionFormData("attachment", fileName);
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
return new ResponseEntity<byte[]>(
FileUtils.readFileToByteArray(file), headers,
HttpStatus.CREATED);
} else {
response.setStatus(500);
return null;
}
}
// 文件上传处理函数
private ResumableInfo getResumableInfo(HttpServletRequest request)
throws ServletException {
String base_dir = Configs.FILE_UPLOAD_PATH;
int resumableChunkSize = HttpUtils.toInt(
request.getParameter("resumableChunkSize"), -1);
long resumableTotalSize = HttpUtils.toLong(
request.getParameter("resumableTotalSize"), -1);
String resumableIdentifier = request
.getParameter("resumableIdentifier");
String resumableFilename = request.getParameter("resumableFilename");
String resumableRelativePath = request
.getParameter("resumableRelativePath");
// Here we add a ".temp" to every upload file to indicate NON-FINISHED
new File(base_dir).mkdir();
String resumableFilePath = new File(base_dir, resumableFilename)
.getAbsolutePath() + ".temp";
ResumableInfoStorage storage = ResumableInfoStorage.getInstance();
ResumableInfo info = storage.get(resumableChunkSize,
resumableTotalSize, resumableIdentifier, resumableFilename,
resumableRelativePath, resumableFilePath);
if (!info.vaild()) {
storage.remove(info);
throw new ServletException("Invalid request params.");
}
return info;
}
}

@ -15,6 +15,7 @@ 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.service.IVolumeService;
import com.platform.utils.Configs;
import com.platform.utils.ThreadVolume;
@ -28,26 +29,40 @@ public class VolumeController extends BaseController{
@Resource(name = "volumeService")
private IVolumeService volumeService;
HttpUtils ht = new HttpUtils();
@RequestMapping(value = "/volume/update", method = RequestMethod.POST)
@ResponseBody
public void volumeUpdate(HttpServletRequest res, HttpServletResponse req,
public String volumeUpdate(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity form) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/update");
volumeService.save(form);
req.setStatus(200);
int rest = volumeService.save(form);
if (rest == 1) {
req.setStatus(200);
}
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-update").start();
return result;
}
@RequestMapping(value = "/volume/delete", method = RequestMethod.POST)
@ResponseBody
public void volumeDelete(HttpServletRequest res, HttpServletResponse req,
public String volumeDelete(HttpServletRequest res, HttpServletResponse req,
@RequestBody VolumeEntity entity) throws Exception {
Configs.CONSOLE_LOGGER.error("/oracle/delete");
volumeService.delete(entity);
req.setStatus(200);
Configs.CONSOLE_LOGGER.error("/volume/delete");
int rest = volumeService.delete(entity);
if (rest == 1) {
req.setStatus(200);
}
else {
req.setStatus(500);
}
String result = ht.sendPost("gfs/getAllvolume", null);
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-delete").start();
return result;
}
}

@ -19,6 +19,8 @@ public interface DataInfoMoveTmpDao {
*/
List<DataInfoEntityMoveTmp> findAll() throws Exception;
DataInfoEntityMoveTmp findById(int id) throws Exception;
int update(DataInfoEntityMoveTmp data) throws Exception;
int save(DataInfoEntityMoveTmp data) throws Exception;

@ -0,0 +1,431 @@
package com.platform.entities;
public class PreDataInfo {
/** 是否更新 */
private String isupdate = "-";
/** 是否采集 */
private String iscollect = "否";
/** 市名称 */
private String cityName;
/** 县区名称 */
private String districtName;
/** 地区编码 */
private String areaCode;
/** 地区级别 */
private String areaLevel;
/** 系统名称 */
private String sysName;
/** 系统版本信息 */
private String dataVersion;
/** 投入使用时间 */
private String beginUseTime;
/** 系统数据功能描述 */
private String functionDetails;
/** 管理部门联系人 */
private String departmentConcactor;
/** 联系方式 */
private String concacts;
/** 信息系统开发商全称 */
private String developerFullName;
/** 数据库类型 */
private String dataBaseType;
/** 数据库版本 */
private String dataBaseVersion;
/** 部门预算管理 */
private String departmentBudgetManage;
/** 预算指标管理 */
private String budgetQuotaManage;
/** 预算执行管理 */
private String budgetExecManage;
/** 总预算会计 */
private String totalBudgetAccount;
/** 决算管理 */
private String finalAccountManage;
/** 报表管理 */
private String reportFormManage;
/** 非税收入管理 */
private String nonTaxManage;
/** 工作统发系统 */
private String wageSystem;
/** 财政经济景气预测与分析 */
private String analysisOfFinancialEconomicProsperity;
/** 政府性债务管理 */
private String governmentDebtManage;
/**
* @return the isupdate
*/
public String getIsupdate() {
return isupdate;
}
/**
* @param isupdate the isupdate to set
*/
public void setIsupdate(String isupdate) {
this.isupdate = isupdate;
}
/**
* @return the iscollect
*/
public String getIscollect() {
return iscollect;
}
/**
* @param iscollect the iscollect to set
*/
public void setIscollect(String iscollect) {
this.iscollect = iscollect;
}
/**
* @return the cityName
*/
public String getCityName() {
return cityName;
}
/**
* @param cityName the cityName to set
*/
public void setCityName(String cityName) {
this.cityName = cityName;
}
/**
* @return the districtName
*/
public String getDistrictName() {
return districtName;
}
/**
* @param districtName the districtName to set
*/
public void setDistrictName(String districtName) {
this.districtName = districtName;
}
/**
* @return the areaCode
*/
public String getAreaCode() {
return areaCode;
}
/**
* @param areaCode the areaCode to set
*/
public void setAreaCode(String areaCode) {
this.areaCode = areaCode;
}
/**
* @return the areaLevel
*/
public String getAreaLevel() {
return areaLevel;
}
/**
* @param areaLevel the areaLevel to set
*/
public void setAreaLevel(String areaLevel) {
this.areaLevel = areaLevel;
}
/**
* @return the sysName
*/
public String getSysName() {
return sysName;
}
/**
* @param sysName the sysName to set
*/
public void setSysName(String sysName) {
this.sysName = sysName;
}
/**
* @return the dataVersion
*/
public String getDataVersion() {
return dataVersion;
}
/**
* @param dataVersion the dataVersion to set
*/
public void setDataVersion(String dataVersion) {
this.dataVersion = dataVersion;
}
/**
* @return the beginUseTime
*/
public String getBeginUseTime() {
return beginUseTime;
}
/**
* @param beginUseTime the beginUseTime to set
*/
public void setBeginUseTime(String beginUseTime) {
this.beginUseTime = beginUseTime;
}
/**
* @return the functionDetails
*/
public String getFunctionDetails() {
return functionDetails;
}
/**
* @param functionDetails the functionDetails to set
*/
public void setFunctionDetails(String functionDetails) {
this.functionDetails = functionDetails;
}
/**
* @return the departmentConcactor
*/
public String getDepartmentConcactor() {
return departmentConcactor;
}
/**
* @param departmentConcactor the departmentConcactor to set
*/
public void setDepartmentConcactor(String departmentConcactor) {
this.departmentConcactor = departmentConcactor;
}
/**
* @return the concacts
*/
public String getConcacts() {
return concacts;
}
/**
* @param concacts the concacts to set
*/
public void setConcacts(String concacts) {
this.concacts = concacts;
}
/**
* @return the developerFullName
*/
public String getDeveloperFullName() {
return developerFullName;
}
/**
* @param developerFullName the developerFullName to set
*/
public void setDeveloperFullName(String developerFullName) {
this.developerFullName = developerFullName;
}
/**
* @return the dataBaseType
*/
public String getDataBaseType() {
return dataBaseType;
}
/**
* @param dataBaseType the dataBaseType to set
*/
public void setDataBaseType(String dataBaseType) {
this.dataBaseType = dataBaseType;
}
/**
* @return the dataBaseVersion
*/
public String getDataBaseVersion() {
return dataBaseVersion;
}
/**
* @param dataBaseVersion the dataBaseVersion to set
*/
public void setDataBaseVersion(String dataBaseVersion) {
this.dataBaseVersion = dataBaseVersion;
}
/**
* @return the departmentBudgetManage
*/
public String getDepartmentBudgetManage() {
return departmentBudgetManage;
}
/**
* @param departmentBudgetManage the departmentBudgetManage to set
*/
public void setDepartmentBudgetManage(String departmentBudgetManage) {
this.departmentBudgetManage = departmentBudgetManage;
}
/**
* @return the budgetQuotaManage
*/
public String getBudgetQuotaManage() {
return budgetQuotaManage;
}
/**
* @param budgetQuotaManage the budgetQuotaManage to set
*/
public void setBudgetQuotaManage(String budgetQuotaManage) {
this.budgetQuotaManage = budgetQuotaManage;
}
/**
* @return the budgetExecManage
*/
public String getBudgetExecManage() {
return budgetExecManage;
}
/**
* @param budgetExecManage the budgetExecManage to set
*/
public void setBudgetExecManage(String budgetExecManage) {
this.budgetExecManage = budgetExecManage;
}
/**
* @return the totalBudgetAccount
*/
public String getTotalBudgetAccount() {
return totalBudgetAccount;
}
/**
* @param totalBudgetAccount the totalBudgetAccount to set
*/
public void setTotalBudgetAccount(String totalBudgetAccount) {
this.totalBudgetAccount = totalBudgetAccount;
}
/**
* @return the finalAccountManage
*/
public String getFinalAccountManage() {
return finalAccountManage;
}
/**
* @param finalAccountManage the finalAccountManage to set
*/
public void setFinalAccountManage(String finalAccountManage) {
this.finalAccountManage = finalAccountManage;
}
/**
* @return the reportFormManage
*/
public String getReportFormManage() {
return reportFormManage;
}
/**
* @param reportFormManage the reportFormManage to set
*/
public void setReportFormManage(String reportFormManage) {
this.reportFormManage = reportFormManage;
}
/**
* @return the nonTaxManage
*/
public String getNonTaxManage() {
return nonTaxManage;
}
/**
* @param nonTaxManage the nonTaxManage to set
*/
public void setNonTaxManage(String nonTaxManage) {
this.nonTaxManage = nonTaxManage;
}
/**
* @return the wageSystem
*/
public String getWageSystem() {
return wageSystem;
}
/**
* @param wageSystem the wageSystem to set
*/
public void setWageSystem(String wageSystem) {
this.wageSystem = wageSystem;
}
/**
* @return the analysisOfFinancialEconomicProsperity
*/
public String getAnalysisOfFinancialEconomicProsperity() {
return analysisOfFinancialEconomicProsperity;
}
/**
* @param analysisOfFinancialEconomicProsperity the analysisOfFinancialEconomicProsperity to set
*/
public void setAnalysisOfFinancialEconomicProsperity(
String analysisOfFinancialEconomicProsperity) {
this.analysisOfFinancialEconomicProsperity = analysisOfFinancialEconomicProsperity;
}
/**
* @return the governmentDebtManage
*/
public String getGovernmentDebtManage() {
return governmentDebtManage;
}
/**
* @param governmentDebtManage the governmentDebtManage to set
*/
public void setGovernmentDebtManage(String governmentDebtManage) {
this.governmentDebtManage = governmentDebtManage;
}
}

@ -0,0 +1,68 @@
package com.platform.entities;
import java.io.File;
import java.util.HashSet;
import com.platform.utils.HttpUtils;
public class ResumableInfo {
public int resumableChunkSize;
public long resumableTotalSize;
public String resumableIdentifier;
public String resumableFilename;
public String resumableRelativePath;
public static class ResumableChunkNumber {
public ResumableChunkNumber(int number) {
this.number = number;
}
public int number;
@Override
public boolean equals(Object obj) {
return obj instanceof ResumableChunkNumber ? ((ResumableChunkNumber) obj).number == this.number
: false;
}
@Override
public int hashCode() {
return number;
}
}
// Chunks uploaded
public HashSet<ResumableChunkNumber> uploadedChunks = new HashSet<ResumableChunkNumber>();
public String resumableFilePath;
public boolean vaild() {
if (resumableChunkSize < 0 || resumableTotalSize < 0
|| HttpUtils.isEmpty(resumableIdentifier)
|| HttpUtils.isEmpty(resumableFilename)
|| HttpUtils.isEmpty(resumableRelativePath)) {
return false;
} else {
return true;
}
}
public boolean checkIfUploadFinished() {
// check if upload finished
int count = (int) Math.ceil(((double) resumableTotalSize)
/ ((double) resumableChunkSize));
for (int i = 1; i < count; i++) {
if (!uploadedChunks.contains(new ResumableChunkNumber(i))) {
return false;
}
}
// Upload finished, change filename.
File file = new File(resumableFilePath);
String new_path = file.getAbsolutePath().substring(0,
file.getAbsolutePath().length() - ".temp".length());
file.renameTo(new File(new_path));
return true;
}
}

@ -0,0 +1,64 @@
package com.platform.entities;
import java.util.HashMap;
public class ResumableInfoStorage {
// Single instance
private ResumableInfoStorage() {
}
private static ResumableInfoStorage sInstance;
public static synchronized ResumableInfoStorage getInstance() {
if (sInstance == null) {
sInstance = new ResumableInfoStorage();
}
return sInstance;
}
// resumableIdentifier -- ResumableInfo
private HashMap<String, ResumableInfo> mMap = new HashMap<String, ResumableInfo>();
/**
* Get ResumableInfo from mMap or Create a new one.
*
* @param resumableChunkSize
* @param resumableTotalSize
* @param resumableIdentifier
* @param resumableFilename
* @param resumableRelativePath
* @param resumableFilePath
* @return
*/
public synchronized ResumableInfo get(int resumableChunkSize,
long resumableTotalSize, String resumableIdentifier,
String resumableFilename, String resumableRelativePath,
String resumableFilePath) {
ResumableInfo info = mMap.get(resumableIdentifier);
if (info == null) {
info = new ResumableInfo();
info.resumableChunkSize = resumableChunkSize;
info.resumableTotalSize = resumableTotalSize;
info.resumableIdentifier = resumableIdentifier;
info.resumableFilename = resumableFilename;
info.resumableRelativePath = resumableRelativePath;
info.resumableFilePath = resumableFilePath;
mMap.put(resumableIdentifier, info);
}
return info;
}
/**
* ɾ³ýResumableInfo
*
* @param info
*/
public void remove(ResumableInfo info) {
mMap.remove(info.resumableIdentifier);
}
}

@ -25,10 +25,10 @@ import java.util.List;
public class VolumeEntity {
/** volume总大小 */
private double allSize;
private Double allSize;
/** volume已使用大小 */
private double usedSize;
private Double usedSize;
/** volume名称 */
private String name;
@ -37,7 +37,7 @@ public class VolumeEntity {
private String path;
/** * exist正常返回状态Started,Stopped,Created */
private boolean status;
private Boolean status;
private String type;
@ -50,28 +50,28 @@ public class VolumeEntity {
/**
* @return the allSize
*/
public double getAllSize() {
public Double getAllSize() {
return allSize;
}
/**
* @param allSize the allSize to set
*/
public void setAllSize(double allSize) {
public void setAllSize(Double allSize) {
this.allSize = allSize;
}
/**
* @return the usedSize
*/
public double getUsedSize() {
public Double getUsedSize() {
return usedSize;
}
/**
* @param usedSize the usedSize to set
*/
public void setUsedSize(double usedSize) {
public void setUsedSize(Double usedSize) {
this.usedSize = usedSize;
}
@ -107,14 +107,14 @@ public class VolumeEntity {
/**
* @return the status
*/
public boolean isStatus() {
public Boolean isStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(boolean status) {
public void setStatus(Boolean status) {
this.status = status;
}

@ -1,23 +1,124 @@
package com.platform.entities;
import java.util.ArrayList;
import java.util.List;
public class VolumeForm {
//
// List<VolumeEntity> volumes;
//
// /**
// * @return the volumes
// */
// public List<VolumeEntity> getVolumes() {
// return volumes;
// }
//
// /**
// * @param volumes the volumes to set
// */
// public void setVolumes(List<VolumeEntity> volumes) {
// this.volumes = volumes;
// }
/** volume名称 */
private String name;
List<VolumeEntity> volumes;
/** 挂载点 */
private String path;
/** * exist正常返回状态Started,Stopped,Created */
private boolean status;
private String type;
/** volume树形目录 */
private List<FolderNode> folder = new ArrayList<FolderNode>();
/** volume的 块 */
private List<Brick> brick = new ArrayList<Brick>();
/**
* @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 boolean isStatus() {
return status;
}
/**
* @param status the status to set
*/
public void setStatus(boolean 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 List<FolderNode> getFolder() {
return folder;
}
/**
* @param folder the folder to set
*/
public void setFolder(List<FolderNode> folder) {
this.folder = folder;
}
/**
* @return the volumes
* @return the brick
*/
public List<VolumeEntity> getVolumes() {
return volumes;
public List<Brick> getBrick() {
return brick;
}
/**
* @param volumes the volumes to set
* @param brick the brick to set
*/
public void setVolumes(List<VolumeEntity> volumes) {
this.volumes = volumes;
public void setBrick(List<Brick> brick) {
this.brick = brick;
}
}

@ -6,9 +6,6 @@ import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.aspectj.weaver.ast.And;
import com.mysql.jdbc.log.Log;
import com.platform.utils.Constant;
public class CheckoutMD5 {

@ -239,14 +239,13 @@ public class SetVolume {
log.info("删除命令执行完毕");
// 删除成功的返回信息是“volume remove-brick: success”
if (reStrings.get(0).contains("volume remove-brick: success")) {
if (reStrings.get(0).contains("success")) {
{
log.info("删除brick成功");
return 1;
}
} else {
log.error("3305 remove brick failed,please check the system");
return -5;
}

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

@ -0,0 +1,85 @@
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 com.platform.utils.Bean2MapUtils;
public class HttpUtils {
public String sendPost(String subUrl, Object data) {
String resultStr = null;
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());
// }
}

@ -26,23 +26,30 @@ public class OracleConnector {
public synchronized static Connection ConnectionBuilder(String url, String user,
String password, OracleConnectorParams oc) {
String password, OracleConnectorParams oc) throws CustomException {
Connection conn=null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
new CustomException(Custom4exception.OracleSQL_Except, e);
Configs.CONSOLE_LOGGER.info("创建oracle连接失败: [" + e.getMessage() + "]");
if (null != oc) {
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "创建oracle连接失败: [" + e.getMessage() + "]\r\n");
}
throw new CustomException(Custom4exception.OracleSQL_Except, e);
}
return conn;
}
public synchronized static boolean canConnect(String url, String user, String password) {
return (null != ConnectionBuilder(url, user, password, null));
Connection result = null;
try {
result = ConnectionBuilder(url, user, password, null);
} catch (CustomException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (null != result);
}
public synchronized static ResultSet getSQLExecResultSet(Connection conn, String sql, String filePath) {
@ -65,7 +72,13 @@ public class OracleConnector {
public synchronized static ResultSet getSQLExecResultSet(String url, String user,
String password, String sql, String filePath) {
return getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath);
ResultSet result = null;
try {
result = getSQLExecResultSet(ConnectionBuilder(url, user, password, null), sql, filePath);
} catch (CustomException e) {
new CustomException(Custom4exception.OracleSQL_Except, e);
}
return result;
}
/**
@ -91,7 +104,7 @@ public class OracleConnector {
return flag;
}
/**
* oracle
* oraclesql
* @param conn
* @param sql
* @return true:1

@ -53,7 +53,7 @@ public class DataInfoServiceImp implements DataInfoService {
list = Arrays.asList(querys);
}
//遍历 list
for (String ss : alllist) {
for (String ss : list) {
ss = ss.trim();
alllist.add(ss);
}

@ -9,6 +9,8 @@ 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 //采集库连接参数
@ -16,7 +18,13 @@ public interface IOracleExtractService {
* @return
* @throws Exception
*/
// 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;
public boolean extractOracle(String name, List<OracleConnectorParams> dataInfo, GatherOracleInfo oracleConnect) throws Exception;
/**
* @param oracleConnect
* @return true
* @throws Exception
*/
public boolean isConnectTotalOracle(GatherOracleInfo oracleConnect) throws Exception;
}

@ -3,6 +3,7 @@ package com.platform.service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.base.Custom4exception;
import com.base.CustomException;
@ -150,8 +151,8 @@ public class OracleExtractHelper {
* @param conn
* @param oc
*/
public void extractColleDB(Connection conn, OracleConnectorParams oc) {
String strTUser = oc.getName() + Configs.TABLE_SUFFIX;
public void extractColleDB(Connection conn, OracleConnectorParams oc, GatherOracleInfo totalOracle) {
String strTUser = oc.getName() + totalOracle.getSuffix();
String sql = "SELECT 'create table "
+ strTUser
+ ".J'|| substr(t.OWNER||'_'||t.TABLE_NAME,0,29)||' as select * from '||t.OWNER||'.'||t.TABLE_NAME||"
@ -183,4 +184,21 @@ public class OracleExtractHelper {
}
}
/**
* @return true
*/
public boolean testConnect(Connection conn) {
String testSql = "select count(*) from user_tables";
boolean flag = false;
try {
Statement statement = conn.createStatement();
if(statement.executeUpdate(testSql) > 0)
flag = true;
} catch (SQLException e) {
flag = false;
new CustomException(Custom4exception.OracleSQL_Except, e, testSql);
}
return flag;
}
}

@ -2,6 +2,7 @@ package com.platform.service;
import com.base.CustomException;
import com.platform.entities.OracleConnectorParams;
import com.platform.oracle.OracleConnector;
import com.platform.utils.Configs;
@ -13,7 +14,11 @@ public class OracleExtractService extends Thread implements Runnable {
public OracleExtractService(OracleConnectorParams ocp){
this.ocp=ocp;
String url = "";
this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
try {
this.conn=OracleConnector.ConnectionBuilder(url, Configs.GATHER_USER_NAME, Configs.GATHER_USER_PASSWORD, null);
} catch (CustomException e) {
this.conn = null;
}
}
@Override
public void run() {

@ -128,8 +128,8 @@ public class GfsServiceImpl implements IGfsService {
if (null != path && path.size() > 0) {
volume.setPath(path.get(0));
}
volume.setAllSize(volumeInfo.getVolumeAvailableSize(volumeName));
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
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>();

@ -103,15 +103,22 @@ public class MoveDataServiceImpl implements IMoveDataService {
}
List<DataInfoEntityMoveTmp> moveList = new ArrayList<DataInfoEntityMoveTmp>();
for (DataInfoEntity dataInfoEntity : data) {
//(根据迁移路径判断)存在迁移过的数据,不允许迁移,先必须删除记录
if (existIds.contains(dataInfoEntity.getDataPath())) {
continue;
}
// 数据的id不存在的数据不允许迁移
if (dataInfoEntity.getId() == 0) {
continue;
}
// 根据数据的id判断存在迁移过的数据不允许迁移先必须删除记录
if (fkIds.contains(dataInfoEntity.getId())) {
continue;
}
// 迁移数据的位置在原数据路径或者原数据父目录及其上,不允许迁移
if (dataInfoEntity.getDataPath().contains(node.getPath())) {
continue;
}
// TODO 正则:取出 data 的后面 的 路径eg: XXX/320198_16/1,or
// XXX/320122KFQ_15/1
Matcher matcher = pattern.matcher(dataInfoEntity.getDataPath());

@ -80,7 +80,7 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
oracleExtract.createDBLink(conn, collectOracle); //创建dblink
oracleExtract.createTableSpace(conn, collectOracle, oracleModel); //创建表空间
oracleExtract.createUser(conn, collectOracle, oracleModel);//创建用户并授权
oracleExtract.extractColleDB(conn, collectOracle);//执行抽取
oracleExtract.extractColleDB(conn, collectOracle, oracleModel);//执行抽取
// client.updateOrAddReplicasLabelById(collectOracle.getName(), "isExtract", "2"); //更新oracle汇总状态0标示为未汇总1标示汇总中2标示汇总完成
cmd = "kubectl label --overwrite rc "
+ replicasName + " isExtract=2";
@ -100,6 +100,22 @@ public class OracleExtractServiceImpl implements IOracleExtractService {
return isSuccess;
}
@Override
public boolean isConnectTotalOracle(GatherOracleInfo oracleModel) throws Exception {
boolean isConnect = false;
Connection conn = OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracleModel.getIp() + ":" + oracleModel.getPort() + ":"
+ oracleModel.getDatabaseName(), oracleModel.getUser(), oracleModel.getPassword(), null);
if (null == conn) {
isConnect = false;
throw new CustomException(Custom4exception.connect_Oracle_Except, null, oracleModel);
// FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
// + dataInfolist.get(0).getName(), "创建oracle连接失败: [" + conn + "]\r\n");
}else {
isConnect = oracleExtract.testConnect(conn);
}
return isConnect;
}
// @Override
// public boolean extractOracle(String name, List<OracleConnectorParams> dataInfos, GatherOracleInfo oracleConnect) throws Exception {
// boolean isSuccess = false;

@ -33,6 +33,7 @@ public class VolumeServiceImpl implements IVolumeService {
@Override
public int save(VolumeEntity 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>();
@ -76,7 +77,10 @@ public class VolumeServiceImpl implements IVolumeService {
//创建volume
if (bristr.size() > 0) {
volumeService.createVolume(add.getName(), 0, "distributed", bristr, add.getPath());
int createreslt = volumeService.createVolume(add.getName(), 0, "distributed", bristr, add.getPath());
if (createreslt != 1) {
rest = createreslt;
}
}
//记录volume信息
VolumeInitEntity volInSql = new VolumeInitEntity();
@ -107,7 +111,10 @@ public class VolumeServiceImpl implements IVolumeService {
newKeys.addAll(newBrickKeys);
// 新增brick s
if (newKeys.size() > 0) {
volumeService.addBrickVolume(entity.getName(), newKeys, 0, "distributed");
int createreslt = volumeService.addBrickVolume(entity.getName(), newKeys, 0, "distributed");
if (createreslt != 1) {
rest = createreslt;
}
}
//待删除的Brick的 Keys
for (Brick brick : newBricks) {
@ -120,7 +127,10 @@ public class VolumeServiceImpl implements IVolumeService {
deleteKeys.addAll(serverBrickKeys);
// 删除brick s
if (deleteKeys.size() > 0) {
volumeService.deleteBrickVolume(entity.getName(), deleteKeys, 0, "distributed");
int createreslt = volumeService.deleteBrickVolume(entity.getName(), deleteKeys, 0, "distributed");
if (createreslt != 1) {
rest = createreslt;
}
}
// ---对比volume信息--原数据有该volume则对比brick信息确认那几个brick是新增的那几个brick是待删除的----- end
@ -134,7 +144,7 @@ public class VolumeServiceImpl implements IVolumeService {
}
}
}
return 0;
return rest;
}
@Override
@ -142,9 +152,9 @@ public class VolumeServiceImpl implements IVolumeService {
if (null == entity.getName() || "".equals(entity.getName())) {
return -1;
}
volumeService.deleteVolume(entity.getName());
int rest = volumeService.deleteVolume(entity.getName());
volumeDao.remove(entity.getName());
return 0;
return rest;
}
@Override

@ -0,0 +1,36 @@
package com.platform.service.thread;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.oracleForm;
import com.platform.service.IOracleExtractService;
/** oracle
* @author chen
*
*/
public class ThreadExtractOracle extends Thread {
private IOracleExtractService OracleExtract;
private oracleForm form;
/** oracle
* @param form
* @param OracleExtract
*/
public ThreadExtractOracle(oracleForm form, IOracleExtractService OracleExtract) {
this.OracleExtract = OracleExtract;
this.form = form;
}
@Override
public void run() {
try {
OracleExtract.extractOracle(form.getName(), form.getInneed(),form.getTarget());
} catch (Exception e) {
new CustomException(Custom4exception.threadVolume_Oracle_Except,e,form,OracleExtract);
}
}
}

@ -0,0 +1,55 @@
package com.platform.service.thread;
import com.base.Custom4exception;
import com.base.CustomException;
import com.platform.entities.oracleForm;
import com.platform.service.IOracleExtractService;
/** oracle
* @author chen
*
*/
public class ThreadGainOracleConnect extends Thread {
private boolean isConnect = false;
private boolean isExcept = false;
private IOracleExtractService OracleExtract;
private oracleForm form;
/** oracle
* @param form
* @param OracleExtract
*/
public ThreadGainOracleConnect(oracleForm form, IOracleExtractService OracleExtract) {
this.form = form;
this.OracleExtract= OracleExtract;
}
@Override
public void run() {
try {
this.isConnect = OracleExtract.isConnectTotalOracle(form.getTarget());
} catch (Exception e) {
isExcept = true;
new CustomException(Custom4exception.connect_Oracle_Except,e,form,OracleExtract);
}
}
/**
* @return the isConnect true:
*/
public boolean isConnect() {
return isConnect;
}
/**
* @return the isExcept
*/
public boolean isExcept() {
return isExcept;
}
}

@ -121,34 +121,38 @@ public class ThreadMoveData{
realRate = (dstSize*100 / srcSize );
dataMove.setLastTime(DateForm.date2StringBysecond(new Date()));
}
if (srcSize == dstSize) {
if (srcSize == dstSize || realRate > 100) {
realRate = 100;
}
dataMove.setRate((int) realRate);
}
if("1".equals(dataMove.getCompleteStatus()) && dataMove.getRate() > 0){
//传输完毕:进行校验
if (realRate == 100) {
if (realRate >= 100) {
int difSize = (int) (srcSizeTemp-dstSize);
Thread.sleep(10*difSize);
//TODO 查看当前拷贝目录进程是否结束?
//TODO 进行MD5校验
// 进行MD5校验
int resl = check.checkoutMD5Folder(dataMove.getDataPath(), dataMove.getDstPath());
//TODO 校验成功--则删除数据库记录
// 校验成功--则增加数据库记录
if(resl == 1){
//校验成功--修改 数据库记录--
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);
// 判断 迁移数据的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:表示 迁移失败

@ -49,4 +49,8 @@ public class Configs {
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
public static String FILE_UPLOAD_PATH="";
public static String FILE_DOWNLOAD_PATH="";
}

@ -6,6 +6,8 @@ import java.util.Properties;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.platform.http.gfs.HttpClientConstant;
import ch.ethz.ssh2.Connection;
public class ConfigsLoader implements ServletContextListener {
@ -64,11 +66,15 @@ public class ConfigsLoader implements ServletContextListener {
Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password");
Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path");
Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path");
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
Constant.hostIp=properties.getProperty("gfs_control_ip").trim();
Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim();
Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port);
}
public ConfigPropertyReader getcReader() {

@ -40,7 +40,7 @@ public class Constant {
/**
* volume 线
*/
public final static int get_volume_sleep_time = 10000;
public final static int get_volume_sleep_time = 5000;
/**
* volume 线

@ -0,0 +1,44 @@
package com.platform.utils;
public class HttpUtils {
public static boolean isEmpty(String value) {
return value == null || "".equals(value);
}
/**
* Convert String to long
* @param value
* @param def default value
* @return
*/
public static long toLong(String value, long def) {
if (isEmpty(value)) {
return def;
}
try {
return Long.valueOf(value);
} catch (NumberFormatException e) {
e.printStackTrace();
return def;
}
}
/**
* Convert String to int
* @param value
* @param def default value
* @return
*/
public static int toInt(String value, int def) {
if (isEmpty(value)) {
return def;
}
try {
return Integer.valueOf(value);
} catch (NumberFormatException e) {
e.printStackTrace();
return def;
}
}
}

@ -27,6 +27,9 @@ public class ThreadVolume extends Thread {
private ClusterInfo cluster = new ClusterInfo();
/** gfs目录树形展示 */
private GetTreeData gfsTree = new GetTreeData();
public ThreadVolume() {
// TODO Auto-generated constructor stub
}
@ -41,9 +44,6 @@ public class ThreadVolume extends Thread {
}
}
/** gfs目录树形展示 */
private GetTreeData gfsTree = new GetTreeData();
@Override
public void run() {
super.run();
@ -84,17 +84,19 @@ public class ThreadVolume extends Thread {
List<String> path = volumeInfo
.getVolumeMountPoint(volumeName);
// 默认加载第一个路径
for (String one : path) {
if (!one.contains("df")) {
volume.setPath(one);
if (null != path) {
for (String one : path) {
if (!one.contains("df")) {
volume.setPath(one);
}
}
}
if (null == volume.getPath()) {
volume.setPath("");
}
volume.setAllSize(volumeInfo
volume.setAllSize((double) (volumeInfo
.getVolumeAvailableSize(volumeName)
+ volumeInfo.getVolumeUseSize(volumeName));
+ volumeInfo.getVolumeUseSize(volumeName)));
// 状态Started,Stopped,Created
String status = volumeInfo.getVolumeStatus(volumeName);
if ("Started".equals(status)) {
@ -102,7 +104,7 @@ public class ThreadVolume extends Thread {
} else {
volume.setStatus(false);
}
volume.setUsedSize(volumeInfo.getVolumeUseSize(volumeName));
volume.setUsedSize((double) volumeInfo.getVolumeUseSize(volumeName));
volume.setType(volumeInfo.getVolumeType(volumeName));
// TODO 查询brick--
// 返回 ip:path

@ -0,0 +1,126 @@
package com.platform.utils.excelUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.core.io.ClassPathResource;
import com.base.Constant;
/**
* @author chen
* excel2007
*/
public class ExcelOperation {
/** excel
* @param templateFilePath
* @param list list
* @return HSSFWorkbook
* @throws FileNotFoundException
* @throws IOException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
public static XSSFWorkbook writeExcelTemplate(String templateFilePath, List list) throws FileNotFoundException, IOException, IllegalArgumentException, IllegalAccessException {
// InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(templateFilePath), "UTF-8");
ClassPathResource res = new ClassPathResource(templateFilePath);
//此处 耗时太久原因excel 2007 以后采用的方式不同造成的建议升级 到 poi 3.15以上)
Date date = new Date();
XSSFWorkbook workbook = new XSSFWorkbook(res.getInputStream());
Date date2 = new Date();
System.out.println(" new XSSFWorkbook "+ (date2.getTime()-date.getTime()));
//从第几行 填充数据
int excelInitRow = Constant.EXCEL_TEMPLATE_INIT_ROW;
//读取工作表
XSSFSheet sheet = workbook.getSheetAt(0);//getSheet("Sheet1");
XSSFRow row;
XSSFCell cell = null;
int size = list.size();
int lengths = 0;
XSSFCellStyle style = getStyle(workbook);
for (int i = 0; i < size; i++) {
row = sheet.createRow(excelInitRow);
Object obj = list.get(i);
Field[] fields = obj.getClass().getDeclaredFields();
lengths = fields.length;
for (int j = 0; j < lengths; j++) {
fields[j].setAccessible(true);
cell = row.createCell((short) j,HSSFCellStyle.ALIGN_CENTER);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
Object value = fields[j].get(obj);
if (null != value) {
cell.setCellValue(value.toString());
}
else {
cell.setCellValue("");
}
cell.setCellStyle(style);
}
//下一行
excelInitRow++;
}
for (int k = 0; k < lengths; k++) {
sheet.autoSizeColumn(k);
int width = sheet.getColumnWidth(k);
if (width < 1600) {
sheet.setColumnWidth(k, 1600);
}else {
sheet.setColumnWidth(k, width + 1000);
}
}
return workbook;
}
private static XSSFCellStyle getStyle(XSSFWorkbook workbook) {
// 设置字体;
XSSFFont font = workbook.createFont();
//设置字体大小;
font.setFontHeightInPoints((short)9);
//设置字体名字;
font.setFontName("Courier New");
//font.setItalic(true);
//font.setStrikeout(true);
// 设置样式;
XSSFCellStyle style = workbook.createCellStyle();
//设置底边框;
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
//设置底边框颜色;
style.setBottomBorderColor(HSSFColor.BLACK.index);
//设置左边框;
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
//设置左边框颜色;
style.setLeftBorderColor(HSSFColor.BLACK.index);
//设置右边框;
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
//设置右边框颜色;
style.setRightBorderColor(HSSFColor.BLACK.index);
//设置顶边框;
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
//设置顶边框颜色;
style.setTopBorderColor(HSSFColor.BLACK.index);
//在样式用应用设置的字体;
style.setFont(font);
//设置自动换行;
style.setWrapText(false);
//设置水平对齐的样式为居中对齐;
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
//设置垂直对齐的样式为居中对齐;
style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
return style;
}
}

@ -0,0 +1,63 @@
package com.platform.test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import com.base.Constant;
import com.platform.entities.PreDataInfo;
import com.platform.utils.excelUtils.ExcelOperation;
public class ExcelTest {
@Test
public void writeData() {
Date date = new Date();
PreDataInfo info = new PreDataInfo();
info.setAnalysisOfFinancialEconomicProsperity("否");
info.setAreaCode("321167");
info.setBeginUseTime("201107");
info.setFunctionDetails("这是一个神奇的功能");
List<PreDataInfo> list = new ArrayList<PreDataInfo>();
for (int i = 0; i < 400; i++) {
list.add(info);
}
XSSFWorkbook result = null;
try {
result = ExcelOperation.writeExcelTemplate(Constant.SYSTEM_INFO_EXCEL_TEMPLATE_FIEL_PATH, list);
} catch (IllegalArgumentException
| IllegalAccessException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("----"+result);
try {
File f = new File("D:/test/4.xlsx");
FileOutputStream fileOut = null;
if (f.exists()) {
fileOut = new FileOutputStream(f);
result.write(fileOut);
fileOut.close();
}
else {
System.out.println("no file");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Date date2 = new Date();
System.out.println("complete "+ (date2.getTime()-date.getTime()));
}
}
Loading…
Cancel
Save