改编码方式utf8

glusterfs-api
chenlw 8 years ago
parent 8b64314d95
commit d7da61c394

@ -4,15 +4,11 @@
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v7.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/MyEclipse Tomcat v7.0"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>

@ -4,7 +4,7 @@
# 驱动程序
jdbc.mysql.driver=com.mysql.jdbc.Driver
# 连接url
jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
jdbc.mysql.url=jdbc:mysql://192.168.0.101:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
# 用户名
jdbc.mysql.username=root
# 密码

@ -1,2 +1,2 @@
/com/
/dataSystem.properties
/com
/spring-applicationContext-test.xml

@ -1,47 +1,54 @@
/**
* BaseController.java
* : XX
* : <>
* 201697
* <>
* BaseController.java
* : XX
* : <>
* 201697
* <>
*/
package com.base;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
import com.platform.utils.Configs;
/**
* <>
* <>
* <>
* <>
* @author chen
* @version [201697]
* @see [/]
* @since [/]
* @version [201697]
* @see [/]
* @since [/]
*/
public class BaseController {
public class BaseController {
/** log4j */
public static Logger log = Logger.getRootLogger();
/**
* <> @ExceptionHandler----
* <>
* <> @ExceptionHandler----
* <>
* @param request
* @param ex
* @param ex
* @return
* @see [##]
* @see [##]
*/
@ExceptionHandler
public String exp(HttpServletRequest request, Exception ex) {
public Object exp(HttpServletRequest request, Exception ex) {
request.setAttribute("ex", ex);
System.err.println("BaseController --exp ");
// 根据不同错误转向不同页面
if(ex instanceof CustomException) {
//TODO 从新封装json
System.err.println("BaseController --exp -- CustomException ");
return "error-business";
// 根据不同错误转向不同页面
if(ex instanceof CustomException) {
CustomException cuse = (CustomException) ex;
log.error(Configs.GLOBAL_EXP_CUSTOM);
//TODO 从新封装json
return "{"+Configs.GLOBAL_EXP_CUSTOM+":"+cuse.getMsg()+"}";
} else {
//TODO 其他错误则 调到指定页面
//TODO 其他错误则 调到指定页面
log.error(Configs.GLOBAL_EXP_NOT_CUSTOM, ex);
return "error";
}
}

@ -1,32 +1,22 @@
package com.base;
import java.io.File;
/**
* @
* @author chen
* @date 2016830
* @package com.base
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public class Constant {
/** 配置文件文件-dataSystem.properties */
public static String SYSTEM_PROPERTIES_FIEL_PATH = "/com/base/dataSystem.properties";
/** 国际话配置文件文件-i18n.properties */
/** 国际话配置文件文件-i18n.properties */
public static String I18N_PROPERTIES_FIEL_PATH = "/com/base/i18n.properties";
/** 记录异常的文件-system_exception.txt-的位置-- */
public final static String SYSTEM_EXCEPTION_FILEPATH = "\\log\\system_exception.txt";
/** WritefileThread-线程睡眠时间--3000 */
/** WritefileThread-线程睡眠时间--3000 */
public final static long THREAD_SLEEP_WRITEFILETHREAD = 3000;
/** 是否将异常写入文件 */
public final static String IS_WRITE_LOGFILE = "iswritelogfile";
/** CustomException记录报异常的对象的对象个数--10 */
/** CustomException记录报异常的对象的对象个数--10 */
public final static int CustomException_log_object_size = 10;

@ -1,41 +1,20 @@
package com.base;
/**
* @
* @author chen
* @date 2016822
* @package com.base
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public class Custom4exception {
//3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常
/** 3
* 003
* 001
* 001
//3003001001 : 第一位:标识异常, 第二到第四位:标识模块,第五道第七位:标识类别,第八道第十位标识具体异常
/**eg
* 3
* 003
* 001
* 001
*/
/** 虚拟机-资源-虚拟机VM启动异常 */
public final static String vbox_start_exp = "3003001001";
/** 虚拟机-资源-虚拟机VBoxManage.exe 不存在异常 */
public final static String vbox_exe_non_exist_exp = "3003001002";
/** 虚拟机-共享-设置共享文件夹中断异常 */
public final static String share_dir_interrupted_exp = "3003002001";
/** 数据管理-数据上报-中断或读写异常 */
public final static String data_manage_interrupted_exp = "3004001001";
/** 公共模块utils-xml类-xml非法异常 */
public final static String xml_field_Illega_exp = "3005001001";
/** 公共模块utils-xml类-document异常 */
public final static String xml_docu_exp = "3005001002";
/** 公共模块utils-xml类-读写异常 */
public final static String xml_io_exp = "3005001003";
/** 公共模块utils-oracle类-读写异常 */
public final static String oracle_io_exp = "3005002001";
}

@ -1,35 +1,38 @@
package com.base;
import org.apache.log4j.Logger;
/**
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
@SuppressWarnings("serial")
public class CustomException extends Exception {
/** 自定义异常信息-错误信息 */
/** log4j */
public static Logger log = Logger.getRootLogger();
/** 自定义异常信息-错误信息 */
private String msg;
/** 操作对象 */
/** 操作对象 */
private Object[] objArray;
/** 异常 */
/** 异常 */
private Throwable cause;
static{
// 是否 启动 记录 异常的线程
if (Boolean.valueOf(Resource.getProperties().get(Constant.IS_WRITE_LOGFILE))) {
//启动 记录 异常的线程
WritefileThread wt = new WritefileThread();
wt.start();
}
}
public CustomException() {
super();
}
/**
* @
* @param code
* @param msg
* @
* @param code
* @param msg
* @param e
* @param obj
*/
@ -41,12 +44,12 @@ public class CustomException extends Exception {
sbuf.append(code);
sbuf.append("\r\n");
msg = Resource.getProperties().get(code);
// 记录自定义的 异常
// 记录自定义的 异常
if (null != msg) {
sbuf.append(msg);
sbuf.append("\r\n");
}
// 记录原始的异常
// 记录原始的异常
if (null != e) {
StackTraceElement[] array = e.getStackTrace();
cause = e.getCause();
@ -55,7 +58,7 @@ public class CustomException extends Exception {
sbuf.append("\r\n");
}
}
//记录 出现异常时 当前的对象
//记录 出现异常时 当前的对象
if (null != obj) {
Object[] array = obj;
sbuf.append("Object[] size : ");
@ -80,14 +83,12 @@ public class CustomException extends Exception {
}
sbuf.append("\r\n");
// 是否 写入 文件
if (Boolean.valueOf(Resource.getProperties().get(Constant.IS_WRITE_LOGFILE))) {
WritefileThread.getStrArray().add(sbuf.toString());
}
// 是否 写入 文件
log.error(sbuf.toString());
}
/**
* @ msg
* @ msg
* @return msg
*/
public String getMsg() {
@ -95,7 +96,7 @@ public class CustomException extends Exception {
}
/**
* @ objArray
* @ objArray
* @return objArray
*/
public Object[] getObjArray() {
@ -103,7 +104,7 @@ public class CustomException extends Exception {
}
/**
* @ cause
* @ cause
* @return cause
*/
public Throwable getCause() {

@ -1,383 +0,0 @@
package com.base;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.nio.channels.FileLock;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.filechooser.FileSystemView;
/**
* @
* @author chen
* @date 201688
* @package com.utils
*/
public class FileOperate {
private final static String localDiskName = "本地磁盘";
private final static String enlocalDiskName = "Local Disk";
private final static String CD = "CD";
private final static String DVD = "DVD";
public static String usbPath = "";
/**
* @
*
* @return
*/
public static List<String> filterDiskPath() {
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
List<String> diskPathName = new ArrayList<String>();
File[] roots = File.listRoots();
for (File file : roots) {
String diskName = fileSystemView.getSystemTypeDescription(file);// 获取磁盘的类型描述信息
if (diskName.startsWith(localDiskName) || diskName.startsWith(enlocalDiskName) || diskName.contains(CD)
|| diskName.contains(CD) || diskName.contains(DVD)) // 当磁盘为可移动磁盘时{
continue;
diskPathName.add(file.getAbsolutePath());
}
return diskPathName;
}
/**
* @
* @param path
*
* @param dirName
*
* @return
*/
public static int createDir(String path, String dirName) {
File dirFile = new File(path + "\\" + dirName);
if (!dirFile.exists()) {
if (!dirFile.mkdirs()) {
System.out.println("目录不存在,创建失败!");
return 2;
}
return 1;
}
return 0;
}
/**
* @
*
* @param path
*
* @return
*/
public static boolean isFileExists(String path) {
File file = new File(path);
if (file.exists())
return true;
return false;
}
/**
* @
*
* @param name
*
* @return
*/
public static boolean file_dir_exist(String name) {
try {
File file = new File(name);
if (!file.exists()) {
return false;
// return true;
}
}
catch (Exception e) {
// TODO: handle exception
return false;
}
return true;
}
/**
* @ 26
* @param length
*
* @return
*/
public static String getRandomString(int length) { // length表示生成字符串的长度
String base = "abcdefghijklmnopqrstuvwxyz";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
/**
* @
* @param fiel_name
*
* @return
*/
public static String read_fileToStr(String fiel_name) {
String str = "";
try {
File file = new File(fiel_name);
String lineTxt = "";
InputStreamReader read = new InputStreamReader(new FileInputStream(file), "gbk");// 考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
while ((lineTxt = bufferedReader.readLine()) != null) {
str = str + lineTxt;
}
bufferedReader.close();
read.close();
}
catch (Exception e) {
e.printStackTrace();
return "Exception";
}
return str;
}
/**
* @
* @param path_filename
*
* @return
*/
public static String get_filename_from_path(String path_filename) {
String[] strings = path_filename.split("\\\\");
return strings[strings.length - 1];
}
/**
* @ dirPath
* @param dirPath
*
* @return
*/
public static List<String> findAllFilenameFromPath(String dirPath) {
ArrayList<String> fileAbsolutePaths = new ArrayList<>();
FileOperate.findFiles(dirPath, fileAbsolutePaths);
return fileAbsolutePaths;
}
/**
* @
* @param dirPath
*
* @return
*/
public static boolean delAllFileByDir(String dirPath) {
boolean flag = false;
File file = new File(dirPath);
// 判断目录或文件是否存在
if (!file.exists()) { // 不存在返回 false
return flag;
}
else {
// 判断是否为文件
if (file.isFile()) { // 为文件时调用删除文件方法
return deleteFile(dirPath);
}
else { // 为目录时调用删除目录方法
return deleteDirectory(dirPath);
}
}
}
/**
* @
* @param content
*
* @param filePathName
*
*/
public static void writeFile(List<Object> content, String filePathName) {
if (null == content) {
return;
}
try {
FileWriter writer = new FileWriter(filePathName);
for (Object one : content) {
writer.write(one.toString());
writer.write("\r\n");
}
writer.close();
}
catch (Exception e) {
// TODO: handle exception
// e.printStackTrace();
}
}
/**
* @
* @param content
* @param filePathName
*/
public static void appendWriteFile(String content, String filePathName){
File file = new File(filePathName);
if (!file.exists() || !file.isFile()) {
ArrayList<Object> list = new ArrayList<>();
list.add("系统异常日志\n");
writeFile(list, filePathName);
}
try {
// 打开一个随机访问文件流,按读写方式
RandomAccessFile randomFile = new RandomAccessFile(filePathName, "rw");
// 文件长度,字节数
long fileLength = randomFile.length();
// 将写文件指针移到文件尾。
randomFile.seek(fileLength);
// randomFile.writeBytes(content);
//解决中文乱码
randomFile.write(content.getBytes());
randomFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* @
* @param fileName
*
*/
public static boolean islockFile(String fileName) {
Object result = null;
boolean isSuccess = true;
try {
result = tryLock(fileName);
if (null == result) {
isSuccess = false;
}
}
catch (IOException e) {
e.printStackTrace();
isSuccess = false;
}
return isSuccess;
}
/**
* @
* @param dirPath
*
* @return
*/
private static boolean deleteDirectory(String dirPath) {
// 如果sPath不以文件分隔符结尾自动添加文件分隔符
if (!dirPath.endsWith(File.separator)) {
dirPath = dirPath + File.separator;
}
File dirFile = new File(dirPath);
// 如果dir对应的文件不存在或者不是一个目录则退出
if (!dirFile.exists() || !dirFile.isDirectory()) {
return false;
}
boolean flag = true;
// 删除文件夹下的所有文件(包括子目录)
File[] files = dirFile.listFiles();
for (int i = 0; i < files.length; i++) {
// 删除子文件
if (files[i].isFile()) {
flag = deleteFile(files[i].getAbsolutePath());
if (!flag)
break;
} // 删除子目录
else {
flag = deleteDirectory(files[i].getAbsolutePath());
if (!flag)
break;
}
}
if (!flag)
return false;
// 删除当前目录
if (dirFile.delete()) {
return true;
}
else {
return false;
}
}
/**
* @
* @param filePath
*
* @return
*/
private static boolean deleteFile(String filePath) {
boolean flag = false;
File file = new File(filePath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
flag = true;
}
return flag;
}
/**
* @ dirPath
* @param dirPath
*
* @param fileAbsolutePaths
*
* @return
*/
private static List<String> findFiles(String dirPath, List<String> fileAbsolutePaths) {
File file = new File(dirPath);
// 是文件时
if (!file.isDirectory()) {
String path = file.getAbsolutePath();
fileAbsolutePaths.add(path);
}
// 是文件夹时
else if (file.isDirectory()) {
String[] filelist = file.list();
if (null != filelist) {
int fileNum = filelist.length;
for (int i = 0; i < fileNum; i++) {
String tempPath = dirPath + "\\" + filelist[i];
findFiles(tempPath, fileAbsolutePaths);
}
}
}
return fileAbsolutePaths;
}
/**
* @
* @param fileName
* @return
* @throws IOException
*/
@SuppressWarnings("resource")
private static FileLock tryLock(String fileName) throws IOException {
File lockF = new File(fileName); // 要锁的文件
lockF.deleteOnExit(); // 指定在退出时释放锁
RandomAccessFile file = new RandomAccessFile(lockF, "rws"); // 指定要锁的文件
FileLock res = null;
try {
res = file.getChannel().tryLock(); // 试图取得文件的锁
}
catch (Exception e) { // 文件被其它线程锁时抛出此异常
file.close();
return null;
}
return res;
}
}

@ -17,25 +17,25 @@ public class Resource {
private static Map<String, String> properties = new HashMap<>();
static{
// 读取 properties文件
// 读取 properties文件
// readPropertiesFile(Constant.SYSTEM_PROPERTIES_FIEL_PATH);
readPropertiesFile4Chinese(Constant.I18N_PROPERTIES_FIEL_PATH);
}
/**
* @
* @param filename "/com/utils/exception/i18n.properties"
* @
* @param filename "/com/utils/exception/i18n.properties"
*/
public static void readPropertiesFile4Chinese(String filename) {
Properties pro = new Properties();
try {
// 读取属性文件 XXXX.propertiesReader。writer解决中文乱码
// 读取属性文件 XXXX.propertiesReader。writer解决中文乱码
// InputStreamReader in= new InputStreamReader(Resource.class.getClassLoader().getResourceAsStream(filename), "UTF-8");
InputStreamReader in= new InputStreamReader(Resource.class.getResourceAsStream(filename), "UTF-8");
BufferedReader bf = new BufferedReader(in);
// InputStreamReader in = new BufferedInputStream(new FileInputStream(filename));
pro.load(bf); // /加载属性列表
pro.load(bf); // /加载属性列表
Iterator<String> it = pro.stringPropertyNames().iterator();
while (it.hasNext()) {
String key = it.next();
@ -48,7 +48,7 @@ public class Resource {
}
/**
* @ properties
* @ properties
* @return properties
*/
public static Map<String, String> getProperties() {
@ -56,15 +56,15 @@ public class Resource {
}
/**
* @
* @param filename
* @
* @param filename
*/
public static void readPropertiesFile(String filename) {
Properties pro = new Properties();
try {
// 读取属性文件 XXXX.properties 中文会 乱码)
// 读取属性文件 XXXX.properties 中文会 乱码)
BufferedInputStream bf = new BufferedInputStream(new FileInputStream(filename));
pro.load(bf); // /加载属性列表
pro.load(bf); // /加载属性列表
Iterator<String> it = pro.stringPropertyNames().iterator();
while (it.hasNext()) {
String key = it.next();

@ -1,68 +0,0 @@
package com.base;
import java.util.ArrayList;
import java.util.List;
import com.base.Constant;
/**
* @ --system_exception.txt
* @author chen
* @date 2016830
* @package com.utils.exception
*/
public class WritefileThread extends Thread implements Runnable{
/** 存储异常信息 */
private static List<String> strArray = new ArrayList<>();
/** 是否继续运行 */
private static boolean isContinue = true;
@Override
public void run() {
super.run();
while(isContinue){
try {
Thread.sleep(Constant.THREAD_SLEEP_WRITEFILETHREAD);
} catch (InterruptedException e) {
e.printStackTrace();
}
synchronized (strArray) {
//同步代码--写入日志
String str = array2Str(strArray);
//TODO FileOperate.appendWriteFile(str, Constant.SYSTEM_EXCEPTION_FILEPATH);
strArray.clear();
}
}
}
/**
* @ strArray
* @return strArray
*/
public static List<String> getStrArray() {
return strArray;
}
/**
* @ isContinue
* @param isContinue
*/
public static void setContinue(boolean isContinue) {
WritefileThread.isContinue = isContinue;
}
/**
* @ list --> String
* @param array arrayList
* @return String
*/
@SuppressWarnings("rawtypes")
private static String array2Str(List array) {
StringBuffer sbuf = new StringBuffer();
for (Object object : array) {
sbuf.append(object);
}
return sbuf.toString();
}
}

@ -14,7 +14,6 @@ import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.base.BaseController;
import com.platform.entities.PagerOptions;
import com.platform.service.DataInfoService;
import com.platform.service.OracleStatusService;
@ -22,7 +21,7 @@ import com.platform.utils.Configs;
import com.platform.utils.UtilsHelper;
@Controller
public class DataModelController extends BaseController{
public class DataModelController {
@Resource(name = "dataInfoService")
private DataInfoService dfs;
@ -37,7 +36,7 @@ public class DataModelController extends BaseController{
Map<String, String[]> paramMap = res.getParameterMap();
Set<String> keySet = paramMap.keySet();
Map<String, String> params = new HashMap<String, String>();
StringBuffer sb = new StringBuffer().append("当前的请求参数:{");
StringBuffer sb = new StringBuffer().append("当前的请求参数:{");
for (String str : keySet) {
String value = paramMap.get(str)[0];
if (StringUtils.isNotEmpty(value)){
@ -68,7 +67,7 @@ public class DataModelController extends BaseController{
String[] oraclesName = paramMap.get("oracleName");
if (oraclesName != null)
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("执行后台数据库连接\t" + rcName);
Configs.CONSOLE_LOGGER.info("执行后台数据库连接\t" + rcName);
new OracleStatusService().connectToOracle(rcName);
}
}
@ -81,7 +80,7 @@ public class DataModelController extends BaseController{
String operate = paramMap.get("operation")[0];
if (null != oraclesName) {
for (String rcName : oraclesName) {
Configs.CONSOLE_LOGGER.info("取消后台数据库连接:\t" + rcName);
Configs.CONSOLE_LOGGER.info("取消后台数据库连接:\t" + rcName);
new OracleStatusService().cancelToOracle(rcName, operate);
}
}

@ -7,31 +7,22 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.BaseController;
import com.base.CustomException;
import com.base.Resource;
import com.platform.utils.Configs;
@Controller
public class DefaultController extends BaseController{
public class DefaultController {
@RequestMapping("/")
public ModelAndView defaultHandler(HttpServletRequest req, HttpServletResponse res){
//处理不匹配的请求
//处理不匹配的请求
System.out.println("index");
return new ModelAndView("index");
}
@RequestMapping("/test")
public void test(HttpServletRequest req, HttpServletResponse res) throws CustomException{
public void test(HttpServletRequest req, HttpServletResponse res){
//System.out.println(Class.class.getClass().getResource("/").getPath());
new Resource();
System.out.println(Configs.EXTRACT_LOG_LOCALTION);
boolean istrue = true;
if (istrue) {
throw new CustomException("3212", null);
}
System.out.println("end");
}
}

@ -0,0 +1,35 @@
/**
* : FolderController.java
* : </>
* : <>
* @author chen
* : <>
* 201698
* <>
*/
package com.platform.controller;
import com.base.BaseController;
/**
* <>
* <>
* @author chen
* @version [201698]
* @see [/]
* @since [/]
*/
public class FolderController extends BaseController {
/**
* <>
* <>
* @see [##]
*/
public FolderController() {
// TODO Auto-generated constructor stub
}
}

@ -12,7 +12,7 @@ import org.springframework.stereotype.Repository;
import com.platform.entities.EncodedInfoEntity;
/**
* :
* :
*
* @author wuming
*
@ -21,49 +21,49 @@ import com.platform.entities.EncodedInfoEntity;
public interface EncodeInfoDao {
/**
* /
* /
*
* @param tableName
*
* @return :
*
* @return :
*/
@Select("SELECT code, name FROM ${tableName}")
public List<EncodedInfoEntity> getAllEntityInfo(
@Param("tableName") String tableName);
/**
* /
* /
*
* @param code
*
*
* @param tableName
*
* @return
*
* @return
*/
@Select("SELECT name FROM ${tableName} WHERE code = #{code}")
public String getEncodeNameByCode(@Param("code") String code,
@Param("tableName") String tableName);
/**
* /
* /
*
* @param name
*
*
* @param tableName
*
* @return
*
* @return
*/
@Select("SELECT code FROM ${tableName} WHERE name = #{name}")
public List<String> getEncodeCodeByName(@Param("name") String name,
@Param("tableName") String tableName);
/**
* /
* /
*
* @param code
*
*
* @param tableName
*
*
* @return
*/
@Update("UPDATE ${tableName} SET name = #{name} WHERE code = #{code}")
@ -71,12 +71,12 @@ public interface EncodeInfoDao {
@Param("name") String name, @Param("tableName") String tableName);
/**
* /
* /
*
* @param efe
*
*
* @param tableName
*
*
* @return
*/
@Insert("INSERT INTO ${tableName} (code, name) VALUES (#{efe.code}, #{efe.name})")
@ -84,12 +84,12 @@ public interface EncodeInfoDao {
@Param("tableName") String tableName);
/**
* /
* /
*
* @param code
*
*
* @param tableName
*
*
* @return
*/
@Delete("DELETE FROM ${tableName} WHERE code = #{code}")

@ -1,27 +1,27 @@
package com.platform.entities;
/**
*
*
*
* @author wuming
*
*/
public class DataInfoEntity {
private int id;
private String regionalismCode; // 行政区划编码
private String cityName; // 市
private String districtName; // 区县
private int systemCode; // 系统编码
private String systemName; // 系统名称
private String dataType; // 数据类型:财政\社保\...
private int dataVersion; // 数据版本
private String submittedBatch; // 上报批次
private String dataPath; // 数据路径
private String collectingTime; // 采集时间
private String collectorContacts; // 采集人的联系
private String charset; // 数据的字符编码
private String collectorName; // 采集人姓名
private String year; // 数据年度
private String regionalismCode; // 行政区划编码
private String cityName; // 市
private String districtName; // 区县
private int systemCode; // 系统编码
private String systemName; // 系统名称
private String dataType; // 数据类型:财政\社保\...
private int dataVersion; // 数据版本
private String submittedBatch; // 上报批次
private String dataPath; // 数据路径
private String collectingTime; // 采集时间
private String collectorContacts; // 采集人的联系
private String charset; // 数据的字符编码
private String collectorName; // 采集人姓名
private String year; // 数据年度
public DataInfoEntity() {
}

@ -2,16 +2,14 @@ package com.platform.entities;
/**
*
*
* /
*
* /
* @author wuming
*
*/
public class EncodedInfoEntity {
/** 名称 */
private String name;
/** 编码 */
private String code;
private String name; //名称
private String code; //编码
public EncodedInfoEntity() {}

@ -1,29 +1,29 @@
package com.platform.entities;
public class PagerOptions {
private Integer currentPageNum; //当前页码
private Integer currentPageNum; //当前页码
private String dataType; //数据类型
private String dataType; //数据类型
private String submittedBatch; //数据批次
private String submittedBatch; //数据批次
private String cityName; //城市名称
private String cityName; //城市名称
private String districtName; //区县名
private String districtName; //区县名
private Integer dataVersion; //数据版本
private Integer dataVersion; //数据版本
private String systemName; //系统名称
private String systemName; //系统名称
private String dataYear; // 数据年度
private String dataYear; // 数据年度
private Integer limit; //一次查询返回记录条数
private Integer limit; //一次查询返回记录条数
private Integer offset; // 查询偏移量起始id
private Integer offset; // 查询偏移量起始id
private Integer totalLimit; //当前页前面已有多少条数据
private Integer totalLimit; //当前页前面已有多少条数据
private Integer priorTableSize; //前一次操作一页显示的数据条数
private Integer priorTableSize; //前一次操作一页显示的数据条数
public Integer getCurrentPageNum() {
return currentPageNum;

@ -14,7 +14,7 @@ public class OracleConnector {
static {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功");
Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@ -59,10 +59,10 @@ public class OracleConnector {
}
/**
* oracle
* oracle
* @param conn
* @param sql
* @return
* @return
*/
public boolean execOracleSQL(Connection conn, String sql) {
boolean flag = false;

@ -24,12 +24,12 @@ public class DataInfoServiceImp implements DataInfoService {
public ModelMap getPagerTableData(PagerOptions pagerOptions) {
// TODO Auto-generated method stub
ModelMap modelMap = new ModelMap();
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
int count = dfdDao.getLimitedDataCount(pagerOptions); //获取总记录条数
int offset = 0;
if (pagerOptions.getCurrentPageNum() > 1) {
pagerOptions.setTotalLimit((pagerOptions.getCurrentPageNum() - 1)
* pagerOptions.getPriorTableSize());
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
offset = dfdDao.getLimitedBeginId(pagerOptions); //获取起始查询id
System.out.println(offset);
}
pagerOptions.setOffset(offset + 1);
@ -46,11 +46,11 @@ public class DataInfoServiceImp implements DataInfoService {
for(String idx: id){
List<String> paths = dfdDao.getIdIsExist(Integer.parseInt(idx));
if(paths.size()>0){
//删除文件操作
//删除文件操作
for (int i = 0; i < paths.size(); i++) {
System.out.println(paths.get(i));
}
//删除数据库记录
//删除数据库记录
//dfdDao.deleteRow(idx);
}
}

@ -5,7 +5,7 @@ import java.util.List;
import com.platform.entities.EncodedInfoEntity;
/**
*
*
*
* @author wuming
*

@ -10,7 +10,7 @@ import com.platform.dao.EncodeInfoDao;
import com.platform.entities.EncodedInfoEntity;
/**
*
*
*
* @author wuming
*
@ -26,7 +26,7 @@ public class EncodeInfoServiceImpl implements EncodeInfoService {
}
/**
* tableName/
* tableName/
*/
@Override
public List<EncodedInfoEntity> getAllEncodeInfo(String tableName) {
@ -35,7 +35,7 @@ public class EncodeInfoServiceImpl implements EncodeInfoService {
}
/**
*
*
*/
@Override
public int deleteEncodeByCode(String code, String tableName) {

@ -14,11 +14,11 @@ public class OracleExtractHelper {
private OracleConnector oConnector;
/**
* dblink
* dblink
*
* @param conn
* @param linkName
* dblink
* dblink
* @return
*/
private boolean hasSameNameDBLink(Connection conn, String linkName) {
@ -37,11 +37,11 @@ public class OracleExtractHelper {
}
/**
* dblink
* dblink
*
* @param conn
* @param oc
* dblink
* dblink
*/
public void createDBLink(Connection conn, OracleConnectorParams oc) {
String linkName = "LinkTo" + oc.getName();
@ -55,7 +55,7 @@ public class OracleExtractHelper {
+ ")))(CONNECT_DATA =(SERVICE_NAME =" + oc.getDatabase()
+ ")))';";
if (null != oc) {
if (hasSameNameDBLink(conn, linkName)) { // 如果dblink已经存在,先删除dblink在创建dblink
if (hasSameNameDBLink(conn, linkName)) { // 如果dblink已经存在,先删除dblink在创建dblink
String deleteSql = "DROP PUBLIC DATABASE LINK LinkTo"
+ linkName;
FileOperateHelper
@ -67,13 +67,13 @@ public class OracleExtractHelper {
+ oc.getName(), sql);
oConnector.execOracleSQL(conn, sql);
} else {
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
Configs.CONSOLE_LOGGER.error("删除已有的DBLink失败,无法创建新的DBLink!");
FileOperateHelper.fileWrite(Configs.EXTRACT_LOG_LOCALTION
+ oc.getName(), "删除已有的DBLink失败,无法创建新的DBLink!");
+ oc.getName(), "删除已有的DBLink失败,无法创建新的DBLink!");
}
} else {
// 否则创建dblink
// 否则创建dblink
oConnector.execOracleSQL(conn, sql);
FileOperateHelper.fileWrite(
Configs.EXTRACT_LOG_LOCALTION + oc.getName(), sql);
@ -82,7 +82,7 @@ public class OracleExtractHelper {
}
/**
*
*
*
* @param conn
* @param oc
@ -103,7 +103,7 @@ public class OracleExtractHelper {
}
/**
*
*
*
* @param conn
* @param oc
@ -119,7 +119,7 @@ public class OracleExtractHelper {
}
/**
*
*
*
* @param conn
* @param oc

@ -17,9 +17,9 @@ import com.platform.utils.Configs;
public class OracleStatusService {
private static Map<String, Timer> alliveTask = new Hashtable<String, Timer>();
public final static int EXEC_TIME = 10;// 连接多少次后不成功,取消链接
public final static long INTERVAL_TIME = 60 * 1000;// 每隔多少毫秒执行一次连接任务
public final static long DELAY_TIME = 0; // 延迟多少秒后执行
public final static int EXEC_TIME = 10;// 连接多少次后不成功,取消链接
public final static long INTERVAL_TIME = 60 * 1000;// 每隔多少毫秒执行一次连接任务
public final static long DELAY_TIME = 0; // 延迟多少秒后执行
public void connectToOracle(String replicasName) {
SimpleKubeClient sKubeClient = new SimpleKubeClient();
@ -55,7 +55,7 @@ public class OracleStatusService {
}
/**
*
*
*
*
* @param taskName
@ -73,7 +73,7 @@ public class OracleStatusService {
}
/**
*
*
*/
public void cleanUpAlliveTask() {
Iterator<Map.Entry<String, Timer>> iterator = alliveTask.entrySet()
@ -86,7 +86,7 @@ public class OracleStatusService {
}
/**
* oracle
* oracle
*
* @author wuming
*
@ -114,14 +114,14 @@ public class OracleStatusService {
+ ocp.getPort() + ":" + ocp.getDatabase();
boolean flag = OracleConnector.canConnect(url, ocp.getUser(),
ocp.getPassword());
String message = "失败";
String message = "失败";
if (flag && alliveTask.containsKey(taskName)) {
client.updateOrAddReplicasLabelById(taskName, "status", "2");
message = "成功";
killAlliveTask(taskName); // 连接成功,取消连接
message = "成功";
killAlliveTask(taskName); // 连接成功,取消连接
}
Configs.CONSOLE_LOGGER.info("连接到数据库服务: " + taskName
+ "\t[连接结果: " + message + "]");
Configs.CONSOLE_LOGGER.info("连接到数据库服务: " + taskName
+ "\t[连接结果: " + message + "]");
}
count++;
}

@ -29,7 +29,7 @@ public class ConfigLoder {
}
/**
* Property
* Property
*
* @param key
* @return

@ -29,7 +29,7 @@ public class ConfigPropertyReader {
}
/**
* Property
* Property
*
* @param key
* @return

@ -3,6 +3,13 @@ package com.platform.utils;
import org.apache.log4j.Logger;
public class Configs {
/** 全局自定义异常--编码 */
public static final String GLOBAL_EXP_CUSTOM = "3001001001";
/** 全局非自定义异常--编码 */
public static final String GLOBAL_EXP_NOT_CUSTOM = "3001001002";
public static final String CONFIG_LOCALTION = "WebContent/WEB-INF/config/config.properties";
public static final Logger CONSOLE_LOGGER = Logger.getLogger("console");
@ -14,32 +21,32 @@ public class Configs {
public static final Logger LOGGER = Logger.getLogger(Configs.class);
public static String KUBE_MASTER_URL = "http://192.168.0.113:8080/"; // kubernetes集群的maser
public static String KUBE_MASTER_URL = "http://192.168.0.113:8080/"; // kubernetes集群的maser
// URl
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
public static int ORACLE_DEFAULT_PORT = 1521; // oracle的默认端口号
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
public static String COLLECT_USER_NAME = "system"; //采集统一的登入用户名
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
public static String COLLECT_PASSWORD = "oracle"; //采集统一的登入密码
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
public static String COLLECT_SERVICE_NAME = "orcl"; //采集库统一的服务名
public static String GATHER_PORT ="1521"; //汇总库的端口号
public static String GATHER_PORT ="1521"; //汇总库的端口号
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
public static String GATHER_USER_NAME = "system"; //汇总库的登入用户名
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
public static String GATHER_USER_PASSWORD = "1"; //汇总库的登入密码
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
public static String GATHER_SERVICE_NAME = "orcl"; //汇总库的服务名
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
public static String TABLE_SUFFIX = "_20152016"; //汇总库汇总表的后缀名
public static String EXTRACT_LOG_LOCALTION = "/home/log"; //数据汇总日志保存位置
public static String EXTRACT_LOG_LOCALTION = "/home/log"; //数据汇总日志保存位置
public static String GATHER_TABLESPACE_NAME=""; //表空间名
public static String GATHER_TABLESPACE_NAME=""; //表空间名
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
public static String GATHER_TABLESPACE_PATH=""; //表空间路径
public static String GATHER_TABLE_PASSWORD=""; //登入密码
public static String GATHER_TABLE_PASSWORD=""; //登入密码
}

@ -11,14 +11,14 @@ public class ConfigsLoader implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sEvent) {
// TODO Auto-generated method stub
Configs.CONSOLE_LOGGER.info("系统停止..");
Configs.CONSOLE_LOGGER.info("系统停止..");
}
@SuppressWarnings("static-access")
@Override
public void contextInitialized(ServletContextEvent sEvent) {
// TODO Auto-generated method stub
Configs.CONSOLE_LOGGER.info("系统初始化..");
Configs.CONSOLE_LOGGER.info("系统初始化..");
String contextPath = sEvent.getServletContext().getRealPath("/")
+ "WEB-INF/config/config.properties";
this.cReader = ConfigPropertyReader.Builder(contextPath);

@ -8,7 +8,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
/**
*
*
*
* @author wuming
*
@ -16,7 +16,7 @@ import java.io.InputStreamReader;
public class FileOperateHelper {
/**
*
*
*
* @param path
* @param message
@ -27,7 +27,7 @@ public class FileOperateHelper {
File file = new File(path);
if (file.exists())
file.createNewFile();
FileOutputStream out = new FileOutputStream(file, true); // 如果追加方式用true
FileOutputStream out = new FileOutputStream(file, true); // 如果追加方式用true
StringBuffer sb = new StringBuffer();
sb.append(message).append("\n");
out.write(sb.toString().getBytes("utf-8"));
@ -37,7 +37,7 @@ public class FileOperateHelper {
}
/**
*
*
* @param path
* @return
*/

@ -23,7 +23,7 @@ public class UtilsHelper {
for (Field fs : fileds) {
String fieldName = fs.getName();
String fieldType = fs.getGenericType().toString()
.replace("class ", ""); // 如果type是类类型则前面包含"class ",后面跟类名
.replace("class ", ""); // 如果type是类类型则前面包含"class ",后面跟类名
if (paramMap.containsKey(fieldName)) {
Method method = clazz.getDeclaredMethod(
getAttributeSetName(fs), Class.forName(fieldType));
@ -72,11 +72,11 @@ public class UtilsHelper {
}
/**
* {@fs}set
* {@fs}set
*
* @param fs
*
* @return set
*
* @return set
*/
private static String getAttributeSetName(Field fs) {
String fieldName = fs.getName();

@ -35,8 +35,8 @@ public class TestController {
@ResponseBody
public List<User> getJson(HttpServletRequest res, HttpServletResponse req) {
List<User> list = new ArrayList<User>();
list.add(new User("lisi", 1, "ÄÐ"));
list.add(new User("zhansan", 2, "ÄÐ"));
list.add(new User("lisi", 1, ""));
list.add(new User("zhansan", 2, ""));
return list;
}

@ -32,26 +32,26 @@ public class TestEncodeInfoDao extends SMBasedTest {
@Test
public void testGetEncodeNameByCode() {
String result = eiDao.getEncodeNameByCode("1", testTableName);
Assert.assertTrue(result.equals("预算执行系统"));
Assert.assertTrue(result.equals("预算执行系统"));
}
@Test
public void testGetEncodeCodeByName() {
List<String> result = eiDao
.getEncodeCodeByName("预算执行系统", testTableName);
.getEncodeCodeByName("预算执行系统", testTableName);
Assert.assertTrue(result.size() > 0);
}
@Test
public void testUpdateEncodeNameByCode() {
int result = eiDao
.updateEncodeNameByCode("3", "财政一体化平台", testTableName);
.updateEncodeNameByCode("3", "财政一体化平台", testTableName);
Assert.assertTrue(result > 0);
}
@Test
public void testInsertEncodeEntity() {
int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统",
int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统",
"4"), testTableName);
Assert.assertTrue(result == 1);
}

@ -24,11 +24,11 @@ public class TestEncodeService extends SMBasedTest {
@Test
public void testGetEncodeNameByCode() {
String result = eis.getEncodeNameByCode("2", testTableName);
Assert.assertTrue(result.equals("²¿ÃÅÔ¤Ëã"));
Assert.assertTrue(result.equals("部门预算"));
}
/**
* ÊÂÎñ²âÊÔ
*
*/
@Test
public void testDeleteEncodeByCode() {

@ -1,23 +0,0 @@
/**
* ResourceTest.java
* : XX
* : <>
* 201697
* <>
*/
package com.test.base;
import java.io.InputStream;
import com.base.Constant;
import com.base.Resource;
public class ResourceTest {
public static void main(String[] args) {
Resource ss = new Resource();
Resource.readPropertiesFile(Constant.SYSTEM_PROPERTIES_FIEL_PATH);
}
}
Loading…
Cancel
Save