修复信息系统打包下载bug,以及配置错误。
格式化代码。 将controller改成@RestController修复启动错误 Signed-off-by: ladventure <dylan-lili@foxmail.com>
This commit is contained in:
parent
f6ec25e494
commit
78b82266e3
|
@ -102,19 +102,24 @@ oracle-psw=oracle
|
|||
#=============================================================================================================
|
||||
# linux path
|
||||
#=============================================================================================================
|
||||
|
||||
#系统数据目录根路径
|
||||
data_path=/aggregation-platform_data_path/
|
||||
|
||||
# extract's log file location
|
||||
extract-log-localtion=/home/web_manage/log/
|
||||
extract-log-localtion=extract_log/
|
||||
# standard extract's log file location
|
||||
extract-standard-log-localtion=/home/web_manage/log2/
|
||||
extract-standard-log-localtion=extract_standard_log/
|
||||
#import excel file's location
|
||||
file_upload_path=/excel_import_dir/
|
||||
#export excel file's location
|
||||
file_download_path=/excel_export_dir/export.xlsx
|
||||
file_upload_path=excel_import_dir/
|
||||
|
||||
#信息系统excel导出文件
|
||||
file_download_path=excel_export_dir/export.xls
|
||||
#file package download's location
|
||||
package_download_path=/
|
||||
#file package's name
|
||||
package_name=DefaultDescription
|
||||
package_download_path=package_download_path/
|
||||
|
||||
package_name=package.zip
|
||||
#location of sql script lastest
|
||||
sql_script_path_last=/DefaultDescription_last/
|
||||
sql_script_path_last=sql_last/
|
||||
#location of sql script standard
|
||||
sql_script_path_standard=/DefaultDescription/
|
||||
sql_script_path_standard=sql_standard/
|
||||
|
|
|
@ -322,7 +322,7 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
and remove ='0'
|
||||
</select>
|
||||
|
||||
<update id="removes" parameterType="java.util.List">
|
||||
<!-- <update id="removes" parameterType="java.util.List">
|
||||
UPDATE
|
||||
data_info
|
||||
set remove = '1'
|
||||
|
@ -331,7 +331,14 @@ PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
|
|||
#{item}
|
||||
</foreach>
|
||||
and remove ='0'
|
||||
</update>
|
||||
</update> -->
|
||||
|
||||
<delete id="removes" parameterType="java.util.List">
|
||||
DELETE FROM data_info WHERE id in
|
||||
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateExtract" parameterType="com.platform.entities.DataInfoEntity">
|
||||
UPDATE
|
||||
|
|
|
@ -53,7 +53,7 @@ import com.platform.utils.UtilsHelper;
|
|||
* @author chen
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RestController
|
||||
public class DataModelController extends BaseController {
|
||||
|
||||
public static Logger log = Logger.getLogger(DataModelController.class);
|
||||
|
@ -114,8 +114,7 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping("/data.json")
|
||||
@ResponseBody
|
||||
public ModelMap getAllDataToJson(HttpServletRequest res,
|
||||
HttpServletResponse req) throws Exception {
|
||||
public ModelMap getAllDataToJson(HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
log.info("-----------/data.json-----------");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
Map<String, String[]> paramMap = res.getParameterMap();
|
||||
|
@ -132,10 +131,8 @@ public class DataModelController extends BaseController {
|
|||
}
|
||||
}
|
||||
log.info(sb.deleteCharAt(sb.length() - 1).append("}").toString());
|
||||
PagerOptions pagerOptions = (PagerOptions) UtilsHelper
|
||||
.newObjAndSetAttrsByClass(PagerOptions.class, params);
|
||||
pagerOptions.setCurrentPageNum(Integer.valueOf(params
|
||||
.get("currentPageNum")));
|
||||
PagerOptions pagerOptions = (PagerOptions) UtilsHelper.newObjAndSetAttrsByClass(PagerOptions.class, params);
|
||||
pagerOptions.setCurrentPageNum(Integer.valueOf(params.get("currentPageNum")));
|
||||
// 冷热区查询字段mark
|
||||
pagerOptions.setMark(pagerOptions.getVolumeType().trim());
|
||||
return dfs.getPagerTableData(pagerOptions);
|
||||
|
@ -150,8 +147,7 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/delete/data")
|
||||
@ResponseBody
|
||||
public ModelMap deleteData(HttpServletRequest res, HttpServletResponse req)
|
||||
throws Exception {
|
||||
public ModelMap deleteData(HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
log.info("-----------/delete/data-----------");
|
||||
ModelMap mode = new ModelMap();
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
|
@ -189,8 +185,8 @@ public class DataModelController extends BaseController {
|
|||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
@RequestMapping("/connectOracle")
|
||||
public void connectOracle(HttpServletRequest res, HttpServletResponse req)
|
||||
throws UnsupportedEncodingException {
|
||||
public void connectOracle(HttpServletRequest res, HttpServletResponse req) throws UnsupportedEncodingException {
|
||||
log.info("---------/connectOracle--- ");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
Map<String, String[]> paramMap = res.getParameterMap();
|
||||
String[] oraclesName = paramMap.get("oracleName");
|
||||
|
@ -198,11 +194,10 @@ public class DataModelController extends BaseController {
|
|||
for (String rcName : oraclesName) {
|
||||
log.info("执行连接\t" + rcName);
|
||||
|
||||
String cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS
|
||||
+ " label --overwrite rc " + rcName + " status=0";
|
||||
String cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS + " label --overwrite rc " + rcName
|
||||
+ " status=0";
|
||||
|
||||
List<String> rList = Constant.ganymedSSH
|
||||
.execCmdWaitAcquiescent(cmd);
|
||||
List<String> rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String string : rList)
|
||||
sb.append(string).append("\n");
|
||||
|
@ -220,8 +215,9 @@ public class DataModelController extends BaseController {
|
|||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
@RequestMapping("/cancelOracleConection")
|
||||
public void cancelOracleConnection(HttpServletRequest res,
|
||||
HttpServletResponse req) throws UnsupportedEncodingException {
|
||||
public void cancelOracleConnection(HttpServletRequest res, HttpServletResponse req)
|
||||
throws UnsupportedEncodingException {
|
||||
log.info("---------/cancelOracleConection--- ");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
Map<String, String[]> paramMap = res.getParameterMap();
|
||||
String[] oraclesName = paramMap.get("oracleName");
|
||||
|
@ -246,8 +242,7 @@ public class DataModelController extends BaseController {
|
|||
public String volumeList() throws Exception {
|
||||
log.info("-----/volume/list------");
|
||||
String rest = volumeService.getAllvolume();
|
||||
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-volumeList")
|
||||
.start();
|
||||
new ThreadVolumeImm("ThreadVolumeImm-in-VolumeController-volumeList").start();
|
||||
return rest;
|
||||
}
|
||||
|
||||
|
@ -261,8 +256,10 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/volume/{name}/move", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void volumeMove(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody volumeMoveForm form) throws Exception {
|
||||
public void volumeMove(HttpServletRequest res, HttpServletResponse req, @RequestBody volumeMoveForm form)
|
||||
throws Exception {
|
||||
|
||||
log.info("------/volume/{name}/move--------");
|
||||
List<DataInfoEntity> datas = new ArrayList<DataInfoEntity>();
|
||||
List<DataInfoEntity> selectItems = form.getSelectItems();
|
||||
if (null == selectItems) {
|
||||
|
@ -270,8 +267,6 @@ public class DataModelController extends BaseController {
|
|||
return;
|
||||
}
|
||||
datas.addAll(selectItems);
|
||||
|
||||
log.info("------/volume/{name}/move--------");
|
||||
if (datas.size() > 0) {
|
||||
moveDataService.moveData(datas, form.getSelectNode());
|
||||
}
|
||||
|
@ -287,21 +282,18 @@ public class DataModelController extends BaseController {
|
|||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/oracle/{name}/extract", method = RequestMethod.POST)
|
||||
public void oracleExtract(HttpServletRequest res, HttpServletResponse req,
|
||||
@RequestBody oracleForm form) throws Exception {
|
||||
log.info("/oracle/{name}/extract");
|
||||
public void oracleExtract(HttpServletRequest res, HttpServletResponse req, @RequestBody oracleForm form)
|
||||
throws Exception {
|
||||
log.info(res.getServletPath());
|
||||
if (null != form.getTarget()) { // 检查请求参数中是否包含汇总库信息
|
||||
boolean isConnect = OracleExtract.isConnectTotalOracle(form
|
||||
.getTarget()); // 检查汇总库是否可以连接成功,连接成功返回200状态吗,连接失败返回500状态吗
|
||||
boolean isConnect = OracleExtract.isConnectTotalOracle(form.getTarget()); // 检查汇总库是否可以连接成功,连接成功返回200状态吗,连接失败返回500状态吗
|
||||
if (isConnect) {
|
||||
req.setStatus(200);
|
||||
if (null != form.getInneed() && form.getInneed().size() > 0) {
|
||||
for (OracleConnectorParams oracleParams : form.getInneed()) {
|
||||
BasedTask task = new OracleExtractTask(
|
||||
oracleParams.getName(), form.getTarget(),
|
||||
oracleParams, OracleExtract);
|
||||
OracleExtractExecuter oee = new OracleExtractExecuter(
|
||||
task);
|
||||
BasedTask task = new OracleExtractTask(oracleParams.getName(), form.getTarget(), oracleParams,
|
||||
OracleExtract);
|
||||
OracleExtractExecuter oee = new OracleExtractExecuter(task);
|
||||
new Thread(oee, oracleParams.getName()).start();
|
||||
}
|
||||
}
|
||||
|
@ -334,8 +326,8 @@ public class DataModelController extends BaseController {
|
|||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/oracle/{id}/delete", method = RequestMethod.POST)
|
||||
public void oracleDelete(HttpServletRequest req, HttpServletResponse res,
|
||||
@PathVariable String id) throws Exception {
|
||||
public void oracleDelete(HttpServletRequest req, HttpServletResponse res, @PathVariable String id)
|
||||
throws Exception {
|
||||
log.info("----------deleteOracleInfo----------------");
|
||||
Integer num = Integer.valueOf(id);
|
||||
Integer result = mySqlService.deleteOracle(num);
|
||||
|
@ -354,10 +346,9 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/oracle/{id}/insert", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void oracleInsert(HttpServletRequest res, HttpServletResponse req,
|
||||
@PathVariable String id, @RequestBody GatherOracleInfo oracle)
|
||||
throws Exception {
|
||||
log.info("----------insertOracleInfo----------------");
|
||||
public void oracleInsert(HttpServletRequest res, HttpServletResponse req, @PathVariable String id,
|
||||
@RequestBody GatherOracleInfo oracle) throws Exception {
|
||||
log.info(res.getServletPath());
|
||||
oracle.setId(Integer.valueOf(id));
|
||||
mySqlService.insertOracle(oracle);
|
||||
req.setStatus(200);
|
||||
|
@ -374,10 +365,9 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/oracle/{id}/update", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public void oracleUpdate(HttpServletRequest res, HttpServletResponse req,
|
||||
@PathVariable("id") String id, @RequestBody GatherOracleInfo oracle)
|
||||
throws Exception {
|
||||
log.info("----------updateOracleInfo-----------------------");
|
||||
public void oracleUpdate(HttpServletRequest res, HttpServletResponse req, @PathVariable("id") String id,
|
||||
@RequestBody GatherOracleInfo oracle) throws Exception {
|
||||
log.info(res.getServletPath());
|
||||
log.info(oracle);
|
||||
mySqlService.updateOracle(oracle);
|
||||
req.setStatus(200);
|
||||
|
@ -408,8 +398,8 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/task/transfer/{id}/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object taskTransferDelete(HttpServletRequest res,
|
||||
HttpServletResponse req, @PathVariable String id) throws Exception {
|
||||
public Object taskTransferDelete(HttpServletRequest res, HttpServletResponse req, @PathVariable String id)
|
||||
throws Exception {
|
||||
log.info("----------/task/transfer/{id}/delete-----------------------");
|
||||
DataInfoEntityMoveTmp move = new DataInfoEntityMoveTmp();
|
||||
move.setId(Integer.valueOf(id));
|
||||
|
@ -417,7 +407,7 @@ public class DataModelController extends BaseController {
|
|||
req.setStatus(200);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 迁移完成后的 删除记录功能
|
||||
*
|
||||
|
@ -429,16 +419,15 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/task/transfer/deletes", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object taskTransferDeletes(HttpServletRequest res,
|
||||
HttpServletResponse req, @RequestBody String[] ids) throws Exception {
|
||||
public Object taskTransferDeletes(HttpServletRequest res, HttpServletResponse req, @RequestBody String[] ids)
|
||||
throws Exception {
|
||||
log.info("---------/task/transfer/deletes----------------------");
|
||||
req.setStatus(200);
|
||||
int result = 0;
|
||||
if (ids != null ) {
|
||||
// String[] ids = idsString.split(",");
|
||||
if (ids != null) {
|
||||
// String[] ids = idsString.split(",");
|
||||
result = moveDataService.delete(ids);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
req.setStatus(500);
|
||||
}
|
||||
return result;
|
||||
|
@ -455,8 +444,7 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/task/transfer/save", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object taskTransferSave(HttpServletRequest res,
|
||||
HttpServletResponse req, @RequestBody DataInfoEntity move)
|
||||
public Object taskTransferSave(HttpServletRequest res, HttpServletResponse req, @RequestBody DataInfoEntity move)
|
||||
throws Exception {
|
||||
log.info("---------/task/transfer/save-----------------------");
|
||||
// int result = dfs.save(move);
|
||||
|
@ -489,8 +477,8 @@ public class DataModelController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/oracle/extract/log", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object getExtractLog(@RequestParam("rcName") String name,
|
||||
HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
public Object getExtractLog(@RequestParam("rcName") String name, HttpServletRequest res, HttpServletResponse req)
|
||||
throws Exception {
|
||||
log.info("---------/oracle/extract/log-------------------");
|
||||
String result = logReadService.readLog(name);
|
||||
// "查看相应日志"
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ExcelController extends BaseController{
|
|||
@RequestMapping(value = "/file/upload", method = RequestMethod.POST)
|
||||
public void upload(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
log.info("---------/file/upload--- ");
|
||||
int resumableChunkNumber = HttpUtils.toInt(
|
||||
request.getParameter("resumableChunkNumber"), -1);
|
||||
ResumableInfo info = getResumableInfo(request);
|
||||
|
@ -141,6 +141,7 @@ public class ExcelController extends BaseController{
|
|||
@RequestMapping(value = "/file/download")
|
||||
public ResponseEntity<byte[]> download(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
log.info("---------/file/download--- ");
|
||||
//先导出
|
||||
preDataInfoService.exportExcel(Configs.FILE_DOWNLOAD_PATH);
|
||||
|
||||
|
@ -208,7 +209,7 @@ public class ExcelController extends BaseController{
|
|||
@RequestMapping("/findByParam")
|
||||
public ModelMap findByParam(HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
ModelMap modelMap = new ModelMap();
|
||||
|
||||
log.info("---------/findByParam--- ");
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
Map<String, String[]> paramMap = res.getParameterMap();
|
||||
Set<String> keySet = paramMap.keySet();
|
||||
|
@ -241,6 +242,7 @@ public class ExcelController extends BaseController{
|
|||
@ResponseBody
|
||||
@RequestMapping("/findAll")
|
||||
public ModelMap findAll() throws Exception {
|
||||
log.info("---------/findAll--- ");
|
||||
ModelMap modelMap = new ModelMap();
|
||||
List<PreDataInfo> result = preDataInfoService.findAll();
|
||||
modelMap.addAttribute("data", result);
|
||||
|
|
|
@ -27,47 +27,50 @@ import com.platform.entities.SqlFileInfoEntity;
|
|||
import com.platform.form.ScriptForm;
|
||||
import com.platform.service.IScriptMakeService;
|
||||
import com.platform.utils.Configs;
|
||||
import com.platform.utils.Constant;
|
||||
import com.platform.utils.ZipCompressUtils;
|
||||
|
||||
/** 信息系统--脚本管理
|
||||
/**
|
||||
* 信息系统--脚本管理
|
||||
*
|
||||
* @author chen
|
||||
*
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/filePackage")
|
||||
public class FilePackageController extends BaseController {
|
||||
|
||||
|
||||
public static Logger log = Logger.getLogger(FilePackageController.class);
|
||||
|
||||
|
||||
@Resource(name = "scriptMakeService")
|
||||
private IScriptMakeService scriptMakeService;
|
||||
|
||||
/** 信息系统--脚本管理--文件包导出
|
||||
/**
|
||||
* 信息系统--脚本管理--文件包导出
|
||||
* 将sql_script_path_standard中的所有文件压缩,保存到package_download_path下,然后下载该文件
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping("/download")
|
||||
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
public ResponseEntity<byte[]> downloadFile(HttpServletRequest request, HttpServletResponse response)
|
||||
throws Exception {
|
||||
log.info("---------/download--- ");
|
||||
scriptMakeService.makeCfg();
|
||||
scriptMakeService.makeXml();
|
||||
String filePath = Configs.PACKAGE_DOWNLOAD_PATH;
|
||||
log.info(filePath + Configs.PACKAGE_NAME);
|
||||
ZipCompressUtils.zip(new File(filePath + Configs.PACKAGE_NAME),
|
||||
filePath + "package.zip"); // 产生压缩文件
|
||||
File file = new File(filePath + "package.zip");
|
||||
String packageFilePath = Configs.PACKAGE_DOWNLOAD_PATH + Configs.PACKAGE_NAME;
|
||||
log.info(packageFilePath);
|
||||
ZipCompressUtils.zip(new File(Configs.SQL_SCRIPT_PATH_STANDARD), packageFilePath); // 产生压缩文件
|
||||
File file = new File(packageFilePath);
|
||||
if (file.exists()) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
String fileName = new String(file.getName());// 为了解决中文名称乱码问题
|
||||
log.info(fileName);
|
||||
headers.setContentDispositionFormData("attachment", fileName);
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(
|
||||
FileUtils.readFileToByteArray(file), headers,
|
||||
HttpStatus.CREATED);
|
||||
ResponseEntity<byte[]> responseEntity = new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),
|
||||
headers, HttpStatus.CREATED);
|
||||
file.delete(); //
|
||||
return responseEntity;
|
||||
} else {
|
||||
|
@ -75,8 +78,10 @@ public class FilePackageController extends BaseController {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 信息系统--脚本管理--查看所有系统的 脚本及系统
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
|
@ -93,6 +98,7 @@ public class FilePackageController extends BaseController {
|
|||
|
||||
/**
|
||||
* 信息系统--脚本管理--读取 脚本内容、查看
|
||||
*
|
||||
* @param type
|
||||
* @param data
|
||||
* @param res
|
||||
|
@ -102,7 +108,7 @@ public class FilePackageController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/readSqlFile", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object getSqlFile(/*@PathVariable*/@RequestParam("type") String type, @RequestBody SqlFileInfoEntity data,
|
||||
public Object getSqlFile(/*@PathVariable*/@RequestParam("type") String type, @RequestBody SqlFileInfoEntity data,
|
||||
HttpServletRequest res, HttpServletResponse req) throws Exception {
|
||||
log.info("---------/readSqlFile------------------");
|
||||
ModelMap modelMap = new ModelMap();
|
||||
|
@ -110,9 +116,10 @@ public class FilePackageController extends BaseController {
|
|||
modelMap.addAllAttributes(result);
|
||||
return modelMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息系统--脚本管理--脚本 的 查看、审核、归档、上传
|
||||
*
|
||||
* @param type
|
||||
* @param opt
|
||||
* @param form
|
||||
|
@ -123,20 +130,21 @@ public class FilePackageController extends BaseController {
|
|||
*/
|
||||
@RequestMapping(value = "/handleSqlFile", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public ModelMap handleSqlFile(@RequestParam("type") String type, @RequestParam("opt") String opt, @RequestBody ScriptForm form,
|
||||
HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||||
log.info("---------/handleSqlFile--- " + type +" "+ opt + " ");
|
||||
public ModelMap handleSqlFile(@RequestParam("type") String type, @RequestParam("opt") String opt,
|
||||
@RequestBody ScriptForm form, HttpServletRequest req, HttpServletResponse res) throws Exception {
|
||||
log.info("---------/handleSqlFile--- " + type + " " + opt + " ");
|
||||
ModelMap modelMap = new ModelMap();
|
||||
Map<String, Object> result = scriptMakeService.handleSqlFile(type, opt, form.getContent(), form.getItem());
|
||||
Map<String, Object> result = scriptMakeService.handleSqlFile(type, opt, form.getContent(), form.getItem());
|
||||
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
|
||||
|
@ -147,12 +155,12 @@ public class FilePackageController extends BaseController {
|
|||
*/
|
||||
@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());
|
||||
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);
|
||||
Map<String, Object> result = scriptMakeService.totalOnholeSqlFile(forms);
|
||||
if (result.containsKey("nosqlfile")) {
|
||||
modelMap.addAllAttributes(result);
|
||||
}
|
||||
|
@ -162,9 +170,10 @@ public class FilePackageController extends BaseController {
|
|||
modelMap.addAttribute("length", results.size());
|
||||
return modelMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 信息系统--脚本管理--一键审核
|
||||
*
|
||||
* @param type
|
||||
* @param opt
|
||||
* @param form
|
||||
|
@ -175,12 +184,12 @@ public class FilePackageController extends BaseController {
|
|||
*/
|
||||
@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());
|
||||
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);
|
||||
Map<String, Object> result = scriptMakeService.totalVerifySqlFile(forms);
|
||||
if (result.containsKey("nosqlfile")) {
|
||||
modelMap.addAllAttributes(result);
|
||||
res.setStatus(500);
|
||||
|
|
|
@ -57,7 +57,7 @@ public class OracleController extends BaseController {
|
|||
@Resource(name = "gatherOracleDao")
|
||||
private GatherOracleDao gatherOracleDao;
|
||||
|
||||
/** oracle 标准表抽取
|
||||
/** oracle 标准表抽取,是将该库中的标准用户名下的标准表抽取到配置的标准库中
|
||||
* @param res
|
||||
* @param req
|
||||
* @param form
|
||||
|
@ -66,7 +66,7 @@ public class OracleController extends BaseController {
|
|||
@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(res.getServletPath()+ "?" + res.getQueryString());
|
||||
log.info(form.getInneed().get(0).getName());
|
||||
boolean isConnect = false;
|
||||
//5秒内是否能获得oracle连接,否则认为超时。
|
||||
|
|
|
@ -3,35 +3,45 @@ package com.platform.service;
|
|||
import com.platform.entities.VolumeDataEntity;
|
||||
|
||||
public interface IVolumeService {
|
||||
|
||||
/** 查询所有 volume 包括 其目录(返回字符串)
|
||||
|
||||
/**
|
||||
* 查询所有 volume 包括 其目录(返回字符串)
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getAllvolume() throws Exception;
|
||||
|
||||
/** 新增 volume
|
||||
|
||||
/**
|
||||
* 新增 volume
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int save(VolumeDataEntity entity) throws Exception;
|
||||
|
||||
/** 删除 volume
|
||||
|
||||
/**
|
||||
* 删除 volume
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int delete(VolumeDataEntity entity) throws Exception;
|
||||
|
||||
/** 启动volume
|
||||
|
||||
/**
|
||||
* 启动volume
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int start(VolumeDataEntity entity) throws Exception;
|
||||
|
||||
/** 停止 volume
|
||||
|
||||
/**
|
||||
* 停止 volume
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @throws Exception
|
||||
|
|
|
@ -27,16 +27,16 @@ public class OracleExtractTask extends AbstractOracleExtractTask {
|
|||
|
||||
private IOracleExtractService OracleExtract;
|
||||
|
||||
public OracleExtractTask(String name, GatherOracleInfo gatherOracleInfo,
|
||||
OracleConnectorParams oc, IOracleExtractService OracleExtract) {
|
||||
public OracleExtractTask(String name, GatherOracleInfo gatherOracleInfo, OracleConnectorParams oc,
|
||||
IOracleExtractService OracleExtract) {
|
||||
super(name);
|
||||
this.gatherOracleInfo = gatherOracleInfo;
|
||||
this.oc = oc;
|
||||
this.OracleExtract = OracleExtract;
|
||||
}
|
||||
|
||||
public OracleExtractTask(GatherOracleInfo gatherOracleInfo,
|
||||
OracleConnectorParams oc, IOracleExtractService OracleExtract) {
|
||||
public OracleExtractTask(GatherOracleInfo gatherOracleInfo, OracleConnectorParams oc,
|
||||
IOracleExtractService OracleExtract) {
|
||||
this.gatherOracleInfo = gatherOracleInfo;
|
||||
this.oc = oc;
|
||||
this.OracleExtract = OracleExtract;
|
||||
|
@ -49,55 +49,41 @@ public class OracleExtractTask extends AbstractOracleExtractTask {
|
|||
Connection conn = null;
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
conn = OracleConnector.connectionBuilder(
|
||||
createConnectUrl(), gatherOracleInfo.getUser(),
|
||||
conn = OracleConnector.connectionBuilder(createConnectUrl(), gatherOracleInfo.getUser(),
|
||||
gatherOracleInfo.getPassword(), oc);
|
||||
if (null != conn) {
|
||||
String cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS
|
||||
+ " label --overwrite rc " + oc.getName()
|
||||
String cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS + " label --overwrite rc " + oc.getName()
|
||||
+ " isExtract=1";
|
||||
OracleExtract.updateDataExtractStatus(oc, 1); // 更新数据库的状态
|
||||
FileOperateHelper
|
||||
.fileWrite(
|
||||
Configs.EXTRACT_LOG_LOCALTION + oc.getName()
|
||||
+ ".log",
|
||||
"["
|
||||
+ DateForm
|
||||
.date2StringBysecond(new Date())
|
||||
+ "]>>>>>>>>>>>>>>>>开始汇总 >>>>>>>>>>>>>>>>>>\r\n");
|
||||
List<String> rList = Constant.ganymedSSH
|
||||
.execCmdWaitAcquiescent(cmd);
|
||||
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION + oc.getName() + ".log", "["
|
||||
+ DateForm.date2StringBysecond(new Date()) + "]>>>>>>>>>>>>>>>>开始汇总 >>>>>>>>>>>>>>>>>>\r\n");
|
||||
List<String> rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String string : rList)
|
||||
for (String string : rList) {
|
||||
sb.append(string).append("\n");
|
||||
}
|
||||
Configs.CONSOLE_LOGGER.info(sb.toString());
|
||||
oracleExtract.createDBLink(conn, oc); // 创建dblink
|
||||
oracleExtract.createTableSpace(conn, oc, gatherOracleInfo); // 创建表空间
|
||||
oracleExtract.createUser(conn, oc, gatherOracleInfo);// 创建用户并授权
|
||||
oracleExtract.extractColleDB(conn, oc, gatherOracleInfo);// 执行抽取
|
||||
cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS
|
||||
+ " label --overwrite rc " + oc.getName()
|
||||
oracleExtract.extractColleDB(conn, oc, gatherOracleInfo);// 执行汇总抽取
|
||||
cmd = "kubectl --server " + Configs.KUBE_MASTER_ADDRESS + " label --overwrite rc " + oc.getName()
|
||||
+ " isExtract=2";
|
||||
rList = Constant.ganymedSSH.execCmdWaitAcquiescent(cmd);
|
||||
sb = new StringBuffer();
|
||||
for (String string : rList)
|
||||
for (String string : rList) {
|
||||
sb.append(string).append("\n");
|
||||
}
|
||||
Configs.CONSOLE_LOGGER.info(sb.toString());
|
||||
FileOperateHelper
|
||||
.fileWrite(
|
||||
Configs.EXTRACT_LOG_LOCALTION + oc.getName()
|
||||
+ ".log",
|
||||
"["
|
||||
+ DateForm
|
||||
.date2StringBysecond(new Date())
|
||||
+ "]>>>>>>>>>>>>>>>>汇总结束 >>>>>>>>>>>>>>>>>>\r\n\r\n");
|
||||
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION + oc.getName() + ".log",
|
||||
"[" + DateForm.date2StringBysecond(new Date())
|
||||
+ "]>>>>>>>>>>>>>>>>汇总结束 >>>>>>>>>>>>>>>>>>\r\n\r\n");
|
||||
OracleExtract.updateDataExtractStatus(oc, 2); // 更新数据库的状态
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(Custom4exception.OracleSQL_Except, e);
|
||||
}
|
||||
finally{
|
||||
if(conn != null)
|
||||
} finally {
|
||||
if (conn != null)
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
@ -110,8 +96,7 @@ public class OracleExtractTask extends AbstractOracleExtractTask {
|
|||
private String createConnectUrl() {
|
||||
String answer = "";
|
||||
if (null != gatherOracleInfo) {
|
||||
answer = "jdbc:oracle:thin:@" + gatherOracleInfo.getIp() + ":"
|
||||
+ gatherOracleInfo.getPort() + ":"
|
||||
answer = "jdbc:oracle:thin:@" + gatherOracleInfo.getIp() + ":" + gatherOracleInfo.getPort() + ":"
|
||||
+ gatherOracleInfo.getDatabaseName();
|
||||
}
|
||||
return answer;
|
||||
|
|
|
@ -12,15 +12,17 @@ import com.platform.dao.GatherOracleDao;
|
|||
import com.platform.entities.GatherOracleInfo;
|
||||
import com.platform.service.IGatherOracleService;
|
||||
|
||||
/** oracle数据总库 管理
|
||||
/**
|
||||
* oracle数据总库 管理
|
||||
*
|
||||
* @author chen
|
||||
*
|
||||
*/
|
||||
@Service(value = "mySqlService")
|
||||
public class GatherOracleServiceImpl implements IGatherOracleService{
|
||||
|
||||
public class GatherOracleServiceImpl implements IGatherOracleService {
|
||||
|
||||
public final static Logger log = Logger.getLogger(GatherOracleServiceImpl.class);
|
||||
|
||||
|
||||
/**
|
||||
* oracle数据库 对象记录
|
||||
*/
|
||||
|
@ -35,30 +37,31 @@ public class GatherOracleServiceImpl implements IGatherOracleService{
|
|||
|
||||
@Override
|
||||
public int deleteOracle(int id) throws Exception {
|
||||
|
||||
|
||||
int result = 0;
|
||||
if (id > 0) {
|
||||
//删除汇总的库--逻辑删除
|
||||
GatherOracleInfo oracle = new GatherOracleInfo();
|
||||
oracle.setId(id);
|
||||
oracle.setRemove("1");
|
||||
result = gatherOracleDao.updateOracleById(oracle );
|
||||
// 删除汇总的库--逻辑删除
|
||||
// GatherOracleInfo oracle = new GatherOracleInfo();
|
||||
// oracle.setId(id);
|
||||
// oracle.setRemove("1");
|
||||
// result = gatherOracleDao.updateOracleById(oracle );
|
||||
result = gatherOracleDao.deleteOracleById(id);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public int insertOracle(GatherOracleInfo oracle) throws Exception {
|
||||
// 连接oracle,
|
||||
int result = 0;
|
||||
//1 代表 是标准库抽取
|
||||
// 1 代表 是标准库抽取
|
||||
if ("1".equals(oracle.getType())) {
|
||||
GatherOracleInfo ora = new GatherOracleInfo();
|
||||
ora.setType("0");
|
||||
gatherOracleDao.updateAllOracle(ora);
|
||||
}
|
||||
try{
|
||||
try {
|
||||
result = gatherOracleDao.insertOracle(oracle);
|
||||
}catch(Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
return result;
|
||||
|
@ -69,7 +72,7 @@ public class GatherOracleServiceImpl implements IGatherOracleService{
|
|||
int status = 1;
|
||||
int result = 0;
|
||||
Connection conn = null /*OracleConnector.ConnectionBuilder("jdbc:oracle:thin:@" + oracle.getIp() + ":" + oracle.getPort() + ":"
|
||||
+ oracle.getDatabaseName(), oracle.getUser(), oracle.getPassword())*/;
|
||||
+ oracle.getDatabaseName(), oracle.getUser(), oracle.getPassword())*/;
|
||||
if (null == conn) {
|
||||
status = 0;
|
||||
}
|
||||
|
@ -81,8 +84,7 @@ public class GatherOracleServiceImpl implements IGatherOracleService{
|
|||
gatherOracleDao.updateAllOracleExceptId(ora);
|
||||
}
|
||||
result = gatherOracleDao.updateOracleById(oracle);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
result = insertOracle(oracle);
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -166,10 +166,10 @@ public class MoveDataServiceImpl implements IMoveDataService {
|
|||
}
|
||||
dataMove.setCompleteStatus("0");
|
||||
//只 允许 冷区的数据迁移 mark=1表示冷区
|
||||
if ("1".equals(dataInfoEntity.getMark())) {
|
||||
dataMove.setAddData("1");
|
||||
// if ("1".equals(dataInfoEntity.getMark())) {
|
||||
// dataMove.setAddData("1");
|
||||
moveList.add(dataMove);
|
||||
}
|
||||
// }
|
||||
}
|
||||
if (moveList.size() > 0) {
|
||||
dataInfoMoveTmpDao.insertBatch(moveList);
|
||||
|
|
|
@ -68,6 +68,9 @@ public class Configs {
|
|||
|
||||
public static String GATHER_TABLE_PASSWORD="1"; //登入密码
|
||||
|
||||
//数据根目录
|
||||
public static String DATA_PATH="";
|
||||
|
||||
/** excel上传路径 */
|
||||
public static String FILE_UPLOAD_PATH="";
|
||||
|
||||
|
|
|
@ -1,19 +1,29 @@
|
|||
package com.platform.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.base.MyException;
|
||||
import com.mysql.jdbc.log.Log;
|
||||
import com.platform.controller.ExcelController;
|
||||
import com.platform.http.HttpClientConstant;
|
||||
import com.platform.utils.excelUtils.ExcelOperation;
|
||||
|
||||
/** web容器初始化
|
||||
/**
|
||||
* web容器初始化
|
||||
*
|
||||
* @author chen
|
||||
*
|
||||
*/
|
||||
public class ConfigsLoader implements ServletContextListener {
|
||||
private static ConfigPropertyReader cReader = null;
|
||||
private final static Logger log = Logger.getLogger(ConfigsLoader.class);
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sEvent) {
|
||||
|
@ -26,8 +36,7 @@ public class ConfigsLoader implements ServletContextListener {
|
|||
public void contextInitialized(ServletContextEvent sEvent) {
|
||||
// TODO Auto-generated method stub
|
||||
Configs.CONSOLE_LOGGER.info("系统初始化..");
|
||||
String contextPath = sEvent.getServletContext().getRealPath("/")
|
||||
+ "WEB-INF/config/config.properties";
|
||||
String contextPath = sEvent.getServletContext().getRealPath("/") + "WEB-INF/config/config.properties";
|
||||
this.cReader = ConfigPropertyReader.Builder(contextPath);
|
||||
init();
|
||||
new ThreadVolume("ThreadVolume-in-ConfigsLoader").start();
|
||||
|
@ -35,83 +44,71 @@ public class ConfigsLoader implements ServletContextListener {
|
|||
|
||||
public static void init() {
|
||||
Properties properties = cReader.getProperties();
|
||||
|
||||
Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl");
|
||||
|
||||
Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name");
|
||||
|
||||
Configs.COLLECT_PASSWORD = properties.getProperty("collect-password");
|
||||
|
||||
Configs.COLLECT_SERVICE_NAME = properties
|
||||
.getProperty("collect-service-name");
|
||||
|
||||
Configs.COLLECT_SERVICE_NAME = properties.getProperty("collect-service-name");
|
||||
Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name");
|
||||
|
||||
Configs.GATHER_USER_PASSWORD = properties
|
||||
.getProperty("gather-user-password");
|
||||
|
||||
Configs.GATHER_STANDARD_USER_NAME = properties
|
||||
.getProperty("gather-standard-user-name");
|
||||
|
||||
Configs.GATHER_STANDARD_EXEC_TABLE_NAME = properties
|
||||
.getProperty("gather-standard-exec-table-name");
|
||||
|
||||
Configs.GATHER_STANDARD_PAY_TABLE_NAME = properties
|
||||
.getProperty("gather-standard-pay-table-name");
|
||||
|
||||
Configs.GATHER_USER_PASSWORD = properties.getProperty("gather-user-password");
|
||||
Configs.GATHER_STANDARD_USER_NAME = properties.getProperty("gather-standard-user-name");
|
||||
Configs.GATHER_STANDARD_EXEC_TABLE_NAME = properties.getProperty("gather-standard-exec-table-name");
|
||||
Configs.GATHER_STANDARD_PAY_TABLE_NAME = properties.getProperty("gather-standard-pay-table-name");
|
||||
Configs.GATHER_PORT = properties.getProperty("gather-port");
|
||||
|
||||
Configs.GATHER_SERVICE_NAME = properties
|
||||
.getProperty("gather-service-name");
|
||||
|
||||
Configs.GATHER_SERVICE_NAME = properties.getProperty("gather-service-name");
|
||||
Configs.TABLE_SUFFIX = properties.getProperty("table-suffix");
|
||||
|
||||
Configs.EXTRACT_LOG_LOCALTION = properties
|
||||
.getProperty("extract-log-localtion");
|
||||
|
||||
Configs.EXTRACT_STANDARD_LOG_LOCALTION = properties
|
||||
.getProperty("extract-standard-log-localtion");
|
||||
|
||||
Configs.GATHER_TABLESPACE_NAME = properties
|
||||
.getProperty("gather-tablespace-name");
|
||||
|
||||
Configs.GATHER_TABLESPACE_PATH = properties
|
||||
.getProperty("gather-tablespace-path");
|
||||
|
||||
Configs.KUBE_MASTER_ADDRESS= properties.getProperty("kubeMasterAddress");
|
||||
|
||||
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");
|
||||
|
||||
Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path");
|
||||
|
||||
Configs.GATHER_TABLESPACE_NAME = properties.getProperty("gather-tablespace-name");
|
||||
Configs.GATHER_TABLESPACE_PATH = properties.getProperty("gather-tablespace-path");
|
||||
Configs.KUBE_MASTER_ADDRESS = properties.getProperty("kubeMasterAddress");
|
||||
Configs.GATHER_TABLE_PASSWORD = properties.getProperty("gather-table-user-password");
|
||||
Configs.PACKAGE_NAME = properties.getProperty("package_name");
|
||||
|
||||
Configs.SQL_SCRIPT_PATH_LAST = properties.getProperty("sql_script_path_last");
|
||||
|
||||
Configs.SQL_SCRIPT_PATH_STANDARD = properties.getProperty("sql_script_path_standard");
|
||||
|
||||
Configs.DATA_PATH =properties.getProperty("data_path");
|
||||
Configs.EXTRACT_LOG_LOCALTION = Configs.DATA_PATH + properties.getProperty("extract-log-localtion");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.EXTRACT_LOG_LOCALTION)) {
|
||||
log.error(Configs.EXTRACT_LOG_LOCALTION + "创建失败");
|
||||
}
|
||||
Configs.EXTRACT_STANDARD_LOG_LOCALTION = Configs.DATA_PATH
|
||||
+ properties.getProperty("extract-standard-log-localtion");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.EXTRACT_STANDARD_LOG_LOCALTION)) {
|
||||
log.error(Configs.EXTRACT_STANDARD_LOG_LOCALTION + "创建失败");
|
||||
}
|
||||
Configs.FILE_UPLOAD_PATH = Configs.DATA_PATH + properties.getProperty("file_upload_path");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.FILE_UPLOAD_PATH)) {
|
||||
log.error(Configs.FILE_UPLOAD_PATH + "创建失败");
|
||||
}
|
||||
|
||||
Configs.FILE_DOWNLOAD_PATH = Configs.DATA_PATH + properties.getProperty("file_download_path");
|
||||
if (!FileOperateHelper.ifNotExistMkdirParentFolder(Configs.FILE_DOWNLOAD_PATH)) {
|
||||
log.error(Configs.FILE_DOWNLOAD_PATH + "创建失败");
|
||||
}
|
||||
|
||||
Configs.PACKAGE_DOWNLOAD_PATH = Configs.DATA_PATH + properties.getProperty("package_download_path");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.PACKAGE_DOWNLOAD_PATH)) {
|
||||
log.error(Configs.PACKAGE_DOWNLOAD_PATH + "创建失败");
|
||||
}
|
||||
Configs.SQL_SCRIPT_PATH_LAST = Configs.DATA_PATH + properties.getProperty("sql_script_path_last");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.SQL_SCRIPT_PATH_LAST)) {
|
||||
log.error(Configs.SQL_SCRIPT_PATH_LAST + "创建失败");
|
||||
}
|
||||
Configs.SQL_SCRIPT_PATH_STANDARD = Configs.DATA_PATH + properties.getProperty("sql_script_path_standard");
|
||||
if (!FileOperateHelper.ifNotExistMkdir(Configs.SQL_SCRIPT_PATH_STANDARD)) {
|
||||
log.error(Configs.SQL_SCRIPT_PATH_STANDARD + "创建失败");
|
||||
}
|
||||
|
||||
Configs.dataBefore = Integer.valueOf(properties.getProperty("dataBefore"));
|
||||
|
||||
Configs.NUM_ONE_IMPORT_EXCEL = Integer.valueOf(properties.getProperty("numOneImportExcel"));
|
||||
|
||||
Configs.ORACLE_ORCL = properties.getProperty("oracle-orcl");
|
||||
Configs.ORACLE_USER = properties.getProperty("oracle-user");
|
||||
Configs.ORACLE_PSW = properties.getProperty("oracle-psw");
|
||||
|
||||
Configs.COLLECT_STANDARD_TABLE_USER= properties.getProperty("collect-user-table");
|
||||
Configs.COLLECT_STANDARD_TABLE_USER = properties.getProperty("collect-user-table");
|
||||
Configs.COLLECT_EXEC_TABLE = properties.getProperty("collect-exec-table");
|
||||
Configs.COLLECT_PAY_TABLE = properties.getProperty("collect-pay-table");
|
||||
|
||||
HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim();
|
||||
Constant.moveFileMaxNum=Integer.valueOf(properties.getProperty("moveFileMaxNum").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);
|
||||
|
||||
Constant.moveFileMaxNum = Integer.valueOf(properties.getProperty("moveFileMaxNum").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);
|
||||
|
||||
ExcelOperation.initTemplate(Constant.EXCEL_TEMPLATE_INIT_ROW, Constant.EXCEL_TEMPLATE_TOTAL_COL);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.poifs.property.Parent;
|
||||
|
||||
/**
|
||||
* 文件读写操作帮助类
|
||||
|
@ -16,7 +17,7 @@ import org.apache.log4j.Logger;
|
|||
*
|
||||
*/
|
||||
public class FileOperateHelper {
|
||||
|
||||
|
||||
private static Logger log = Configs.CONSOLE_LOGGER.getLogger(FileOperateHelper.class);
|
||||
|
||||
/**
|
||||
|
@ -31,7 +32,7 @@ public class FileOperateHelper {
|
|||
}
|
||||
try {
|
||||
File file = new File(path);
|
||||
File fileParent = file.getParentFile();
|
||||
File fileParent = file.getParentFile();
|
||||
if (!fileParent.exists()) {
|
||||
fileParent.mkdirs();
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ public class FileOperateHelper {
|
|||
log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以重写的方式将信息写入文件
|
||||
*
|
||||
|
@ -70,8 +71,7 @@ public class FileOperateHelper {
|
|||
out.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
}
|
||||
finally{
|
||||
} finally {
|
||||
if (null != out) {
|
||||
try {
|
||||
out.close();
|
||||
|
@ -81,7 +81,7 @@ public class FileOperateHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 以重写的方式将信息写入文件
|
||||
*
|
||||
|
@ -104,8 +104,7 @@ public class FileOperateHelper {
|
|||
out.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e);
|
||||
}
|
||||
finally{
|
||||
} finally {
|
||||
if (null != out) {
|
||||
try {
|
||||
out.close();
|
||||
|
@ -118,27 +117,27 @@ public class FileOperateHelper {
|
|||
|
||||
/**
|
||||
* 文件读取方法
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public static String fileReader(String path) {
|
||||
public static String fileReader(String path) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String tempString = "";
|
||||
FileInputStream fis = null;
|
||||
try {
|
||||
File file = new File(path);
|
||||
File file = new File(path);
|
||||
if (!file.exists())
|
||||
return "当前没有信息!";
|
||||
fis = new FileInputStream(file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"UTF-8"));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
|
||||
while ((tempString = br.readLine()) != null) {
|
||||
sb.append(tempString).append("\r\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
finally{
|
||||
} finally {
|
||||
if (null != fis) {
|
||||
try {
|
||||
fis.close();
|
||||
|
@ -149,9 +148,10 @@ public class FileOperateHelper {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件读取方法-GBK
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
|
@ -167,14 +167,13 @@ public class FileOperateHelper {
|
|||
if (!file.exists())
|
||||
return "";
|
||||
fis = new FileInputStream(file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"GBK"));
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis, "GBK"));
|
||||
while ((tempString = br.readLine()) != null) {
|
||||
sb.append(tempString+"\n");
|
||||
sb.append(tempString + "\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e);
|
||||
}
|
||||
finally{
|
||||
} finally {
|
||||
if (null != fis) {
|
||||
try {
|
||||
fis.close();
|
||||
|
@ -185,70 +184,107 @@ public class FileOperateHelper {
|
|||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String addLastSeparator(String path){
|
||||
//去掉 File.separator
|
||||
|
||||
public static String addLastSeparator(String path) {
|
||||
// 去掉 File.separator
|
||||
path = removeLastSeparator(path);
|
||||
// 末尾 加上 /
|
||||
path = path + File.separator;
|
||||
path = path + "/";
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String addLastLinuxSeparator(String path){
|
||||
//去掉 File.separator
|
||||
|
||||
public static String addLastLinuxSeparator(String path) {
|
||||
// 去掉 File.separator
|
||||
path = removeLastLinuxSeparator(path);
|
||||
// 末尾 加上 /
|
||||
path = path + "/";
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String removeLastSeparator(String path){
|
||||
|
||||
public static String removeLastSeparator(String path) {
|
||||
// 递归去掉 所有 结尾 /
|
||||
if (path.length() < 1) {
|
||||
return path;
|
||||
}
|
||||
// String sep = "\\"+File.separator;
|
||||
// Pattern pattern2 = Pattern.compile(sep+"$");
|
||||
// Matcher matcher2 = pattern2.matcher(path);
|
||||
// if (matcher2.find()) {
|
||||
// path = path.substring(0, path.length()-1);
|
||||
// path = removeLastSeparator(path);
|
||||
// }
|
||||
// String sep = "\\"+File.separator;
|
||||
// Pattern pattern2 = Pattern.compile(sep+"$");
|
||||
// Matcher matcher2 = pattern2.matcher(path);
|
||||
// if (matcher2.find()) {
|
||||
// path = path.substring(0, path.length()-1);
|
||||
// path = removeLastSeparator(path);
|
||||
// }
|
||||
String sep = File.separator;
|
||||
if (path.endsWith(sep)) {
|
||||
path = path.substring(0, path.length()-1);
|
||||
path = path.substring(0, path.length() - 1);
|
||||
path = removeLastLinuxSeparator(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String removeLastLinuxSeparator(String path){
|
||||
|
||||
public static String removeLastLinuxSeparator(String path) {
|
||||
// 递归去掉 所有 结尾 /
|
||||
if (path.length() < 1) {
|
||||
return path;
|
||||
}
|
||||
String sep = "/";
|
||||
if (path.endsWith(sep)) {
|
||||
path = path.substring(0, path.length()-1);
|
||||
path = path.substring(0, path.length() - 1);
|
||||
path = removeLastLinuxSeparator(path);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/** 单文件移动
|
||||
* @param srcPath 源文件
|
||||
* @param dstPath 目标文件
|
||||
|
||||
/**
|
||||
* 单文件移动
|
||||
*
|
||||
* @param srcPath
|
||||
* 源文件
|
||||
* @param dstPath
|
||||
* 目标文件
|
||||
* @return
|
||||
*/
|
||||
public static boolean singleFileMove(String srcPath, String dstPath){
|
||||
public static boolean singleFileMove(String srcPath, String dstPath) {
|
||||
boolean isSuccess = false;
|
||||
File dstfile = new File(dstPath);
|
||||
dstfile.delete();
|
||||
File srcfile = new File(srcPath);
|
||||
if(srcfile.exists()){
|
||||
if (srcfile.exists()) {
|
||||
// windows linux下通用的 迁移数据
|
||||
isSuccess = srcfile.renameTo(dstfile);
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 如果文件夹不存在,则创建
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public static boolean ifNotExistMkdir(String path) {
|
||||
File folder = new File(path);
|
||||
if (!folder.exists()) {
|
||||
return folder.mkdirs();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 如果文件不存在,则创建
|
||||
*
|
||||
* @param path
|
||||
* @return
|
||||
* @throws IOException
|
||||
* @see [类、类#方法、类#成员]
|
||||
*/
|
||||
public static boolean ifNotExistMkdirParentFolder(String path) {
|
||||
File file = new File(path);
|
||||
if (!file.exists()) {
|
||||
return ifNotExistMkdir(file.getParent());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package com.platform.test;
|
||||
package com.platform.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -8,6 +8,7 @@ import org.junit.Test;
|
|||
|
||||
import com.platform.dao.EncodeInfoDao;
|
||||
import com.platform.entities.EncodedInfoEntity;
|
||||
import com.platform.test.SMBasedTest;
|
||||
|
||||
public class TestEncodeInfoDao extends SMBasedTest {
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
package com.platform.test;
|
||||
package com.platform.dao;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.platform.dao.DataInfoDao;
|
||||
import com.platform.test.SMBasedTest;
|
||||
|
||||
public class testSystemInfoDao extends SMBasedTest {
|
||||
public class TestSystemInfoDao extends SMBasedTest {
|
||||
private DataInfoDao dfDao;
|
||||
|
||||
@Before
|
|
@ -9,18 +9,19 @@ import org.junit.Test;
|
|||
import com.platform.utils.FileOperateHelper;
|
||||
|
||||
public class FileOperationTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void addLastSeparator() {
|
||||
System.out.println(FileOperateHelper.addLastSeparator("D:/gitTmp3/aggregation-platform"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeLastSeparator() {
|
||||
System.out.println(FileOperateHelper.removeLastSeparator("D:/gitTmp3/aggregation-platform/"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void fileCreate() {
|
||||
File f = new File("D:/Create1");
|
||||
|
@ -34,43 +35,46 @@ public class FileOperationTest {
|
|||
}
|
||||
File f3 = new File("D:/Create1");
|
||||
f3.mkdir();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileCreate2() {
|
||||
File f = new File("\\DefaultDescription\\320282");
|
||||
|
||||
System.out.println(f.mkdir());
|
||||
|
||||
|
||||
File f = new File(System.getProperty("user.dir") + "/data_path/extract_log");
|
||||
if (!f.exists()) {
|
||||
System.out.println(f.mkdirs());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reWriteFile() {
|
||||
|
||||
|
||||
FileOperateHelper.fileReWrite("D:/test/1.txt", "asdadada\r\n");
|
||||
FileOperateHelper.fileReWrite("D:/test/1.txt", "asdadada\r\n");
|
||||
FileOperateHelper.fileReWrite("D:/test/1.txt", "asdaaaaaaaaa\r\n");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void WriteFile() {
|
||||
|
||||
|
||||
FileOperateHelper.fileWrite("D:/test/1.txt", "asdadada\r\n");
|
||||
FileOperateHelper.fileWrite("D:/test/1.txt", "asdadada\r\n");
|
||||
FileOperateHelper.fileWrite("D:/test/1.txt", "asdaaaaaaaaa\r\n");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getsystem() {
|
||||
Properties sys = System.getProperties();
|
||||
System.out.println(sys.getProperty("os.name"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testsep() {
|
||||
String sep = "d:\\e\\w\\";
|
||||
if (sep.endsWith(File.separator)) {
|
||||
String path = sep.substring(0, sep.length()-1);
|
||||
String path = sep.substring(0, sep.length() - 1);
|
||||
System.out.println(path);
|
||||
}
|
||||
System.err.println("---");
|
||||
|
|
Loading…
Reference in New Issue