web_backend_develope
wu ming 9 years ago
commit 83170155be

8
.gitignore vendored

@ -1,8 +1,10 @@
/target
/build
.classpath
.settings
.metadata
/RemoteSystemsTempFiles
/bin/
.project
/RemoteSystemsTempFiles
.settings
.metadata

@ -17,6 +17,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -130,7 +131,7 @@ public class DataModelController extends BaseController{
@RequestMapping(value="/oracle/{name}/extract", method= RequestMethod.POST)
public void oracleExtract(HttpServletRequest res,
HttpServletResponse req, String name) throws Exception {
HttpServletResponse req,@PathVariable String name) throws Exception {
res.setCharacterEncoding("UTF-8");
System.out.println("------extract-------");
System.out.println(name);
@ -191,8 +192,7 @@ public class DataModelController extends BaseController{
}
@RequestMapping(value = "/volume/{name}/move", method= RequestMethod.POST)
// @ResponseBody
public void volumeMove(HttpServletRequest res, HttpServletResponse req, String name,
public void volumeMove(HttpServletRequest res, HttpServletResponse req,@PathVariable String name,
FolderNode selectNode, DataInfoEntity selectItems) throws Exception {
res.setCharacterEncoding("UTF-8");
System.out.println("get Request");
@ -256,21 +256,23 @@ public class DataModelController extends BaseController{
}
@RequestMapping(value="/oracle/{id}/delete", method= RequestMethod.POST)
@ResponseBody
public void oracleDelete(int id) throws Exception {
public void oracleDelete(@PathVariable String id) throws Exception {
log.debug("----------deleteOracleInfo----------------");
mySqlService.deleteMySql(id);
Integer num = Integer.valueOf(id);
mySqlService.deleteMySql(num);
}
@RequestMapping(value="/oracle/{id}/insert", method= RequestMethod.POST)
@ResponseBody
public void oracleInsert(GatherOracleInfo oracle) throws Exception {
public void oracleInsert(@PathVariable String id, @RequestBody GatherOracleInfo oracle) throws Exception {
log.debug("----------insertOracleInfo----------------");
oracle.setId(Integer.valueOf(id));
mySqlService.insertOracle(oracle);
}
@RequestMapping(value="/oracle/{id}/update", method= RequestMethod.POST)
public void oracleUpdate(@RequestBody GatherOracleInfo oracle) throws Exception {
@ResponseBody
public void oracleUpdate(@PathVariable("id") String id, @RequestBody GatherOracleInfo oracle) throws Exception {
log.debug("----------updateOracleInfo-----------------------");
log.debug(oracle);
mySqlService.updateOracle(oracle);
@ -284,17 +286,19 @@ public class DataModelController extends BaseController{
return result;
}
@RequestMapping(value="/task/transfer/delete", method= RequestMethod.POST)
@RequestMapping(value="/task/transfer/{id}/delete", method= RequestMethod.POST)
@ResponseBody
public Object taskTransferDelete(DataInfoEntityMoveTmp move) throws Exception {
log.debug("----------/task/transfer/delete-----------------------");
int result = moveDataService.delete(move);
public Object taskTransferDelete(@PathVariable String id) throws Exception {
log.debug("----------/task/transfer/{id}/delete-----------------------");
DataInfoEntityMoveTmp move = new DataInfoEntityMoveTmp();
move.setId(Integer.valueOf(id));
int result = moveDataService.delete(move );
return result;
}
@RequestMapping(value="/task/transfer/save", method= RequestMethod.POST)
@ResponseBody
public Object taskTransferSave(DataInfoEntity move) throws Exception {
public Object taskTransferSave(@RequestBody DataInfoEntity move) throws Exception {
log.debug("---------/task/transfer/save-----------------------");
int result = dfs.save(move);
return result;

@ -27,7 +27,7 @@ import com.platform.utils.DateForm;
@Component
@Service(value = "moveDataService")
public class MoveDataServiceImpl implements IMoveDataService{
public class MoveDataServiceImpl implements IMoveDataService {
@Resource(name = "dataInfoDao")
private DataInfoDao dataInfoDao;
@ -53,36 +53,42 @@ public class MoveDataServiceImpl implements IMoveDataService{
ShowData show = new ShowData();
@Override
public boolean moveData(List<DataInfoEntity> data, String dstPath) throws Exception {
public boolean moveData(List<DataInfoEntity> data, String dstPath)
throws Exception {
boolean isSuccess = false;
String tailPath = "";
if (null != data) {
//XXX/320198_16/1,or XXX/320122KFQ_15/1 ---> /320198_16/1, or /320122KFQ_15/1
// XXX/320198_16/1,or XXX/320122KFQ_15/1 ---> /320198_16/1, or
// /320122KFQ_15/1
List<DataInfoEntityMoveTmp> exist = dataInfoMoveTmpDao.findAll();
List<String> existIds = new ArrayList<String>();
if (null != exist) {
for (DataInfoEntityMoveTmp dataInfoEntityMoveTmp : exist) {
if ("0".equals(dataInfoEntityMoveTmp.getCompleteStatus()) || "1".equals(dataInfoEntityMoveTmp.getCompleteStatus())) {
if ("0".equals(dataInfoEntityMoveTmp.getCompleteStatus())
|| "1".equals(dataInfoEntityMoveTmp
.getCompleteStatus())) {
if (null != dataInfoEntityMoveTmp.getDataPath()) {
existIds.add(dataInfoEntityMoveTmp.getDataPath());
}
}
}
}
Pattern pattern = Pattern.compile("\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$");
Pattern pattern = Pattern
.compile("\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$");
// 末尾 含有 /
Pattern pattern2 = Pattern.compile("\\/$");
Matcher matcher2 = pattern2.matcher(dstPath);
//去掉 最后 的 / 符合
// 去掉 最后 的 / 符合
if (matcher2.find()) {
dstPath = dstPath.substring(0, dstPath.length()-1);
dstPath = dstPath.substring(0, dstPath.length() - 1);
}
List<DataInfoEntityMoveTmp> moveList = new ArrayList<DataInfoEntityMoveTmp>();
for (DataInfoEntity dataInfoEntity : data) {
if (existIds.contains(dataInfoEntity.getDataPath())) {
continue;
}
//TODO 正则:取出 data 的后面 的 路径eg: XXX/320198_16/1,or XXX/320122KFQ_15/1
// TODO 正则:取出 data 的后面 的 路径eg: XXX/320198_16/1,or
// XXX/320122KFQ_15/1
Matcher matcher = pattern.matcher(dataInfoEntity.getDataPath());
// tailPath 第一个字符是 / 符号取尾:"\\/\\d+[a-z]*[A-Z]*_\\d+\\/\\d*\\/*$"
if (matcher.find()) {
@ -90,7 +96,7 @@ public class MoveDataServiceImpl implements IMoveDataService{
}
String finalDestPath = dstPath + tailPath;
Matcher matchertmp2 = pattern2.matcher(finalDestPath);
//去掉 最后 的 / 符合
// 去掉 最后 的 / 符合
if (!matchertmp2.find()) {
finalDestPath = finalDestPath + "/";
}
@ -124,14 +130,14 @@ public class MoveDataServiceImpl implements IMoveDataService{
@Override
public int delete(DataInfoEntityMoveTmp dataMove) throws Exception {
if ("1".equals(dataMove.getCompleteStatus())) {
if ("1".equals(dataMove.getCompleteStatus())
|| "3".equals(dataMove.getCompleteStatus())) {
removeservice.deleteFolder(dataMove.getDstPath());
}
int result = dataInfoMoveTmpDao.remove(dataMove.getId());
return result;
}
@Override
public int save(DataInfoEntityMoveTmp data) throws Exception {
dataInfoMoveTmpDao.save(data);

@ -1,26 +0,0 @@
package com.platform.test;
public class Brick {
private String ip;
private String path;
public Brick(String ip, String path) {
super();
this.ip = ip;
this.path = path;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}

@ -1,35 +0,0 @@
package com.platform.test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.platform.entities.FolderNode;
public class FolderReader {
public static FolderNode reader(String path) {
FolderNode folderNode = null;
File file = new File(path);
if (file.exists()) {
List<FolderNode> childrens = new ArrayList<FolderNode>();
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
FolderNode children = reader(files[i].getAbsolutePath());
if (children != null)
childrens.add(children);
}
}
}
return folderNode;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
FolderReader folderReader = new FolderReader();
FolderNode folderNode = folderReader.reader("D:/bootstrap");
//folderReader.print(folderNode);
}
}

@ -1,15 +0,0 @@
package com.platform.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
public class SMBasedTest {
public ApplicationContext applicationContext;
public SMBasedTest() {
applicationContext = new FileSystemXmlApplicationContext(
"test/spring-applicationContext-test.xml");
}
}

@ -1,29 +0,0 @@
package com.platform.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.platform.utils.Configs;
public class TestConnectOralce {
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Configs.CONSOLE_LOGGER.info("Oracle驱动加载成功");
}catch(Exception e){
System.out.println(e);
}
String url = "jdbc:oracle:thin:@192.168.0.110:60758:orcl";
try {
Connection conn = DriverManager.getConnection(url, "system", "oracle");
System.out.println("连接成功");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

@ -1,53 +0,0 @@
package com.platform.test;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.platform.entities.EncodedInfoEntity;
import com.platform.service.EncodeInfoService;
@Controller
public class TestController {
// private static Logger logger = Logger.getLogger(TestController.class);
@Resource(name = "encodeInfoService")
private EncodeInfoService eis;
public void setEis(EncodeInfoService eis) {
this.eis = eis;
}
@RequestMapping("/hello")
@ResponseBody
public List<EncodedInfoEntity> hello(String name, HttpServletResponse res) {
System.out.println(name);
return eis.getAllEncodeInfo("system_info");
}
@RequestMapping("/json")
@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, "男"));
return list;
}
@RequestMapping("log")
public void testLog(HttpServletResponse res) {
System.out.println(eis.getEncodeNameByCode("1", "system_info"));
}
@RequestMapping("/data111.json")
public void test(String name, HttpServletResponse res){
}
}

@ -1,64 +0,0 @@
package com.platform.test;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.platform.dao.EncodeInfoDao;
import com.platform.entities.EncodedInfoEntity;
public class TestEncodeInfoDao extends SMBasedTest {
private EncodeInfoDao eiDao;
private String testTableName;
@Before
public void initBeforeFunction() {
eiDao = (EncodeInfoDao) this.applicationContext
.getBean("encodeInfoDao");
testTableName = "system_info";
}
@Test
public void testGetAllEntityInfo() {
List<EncodedInfoEntity> allEntities = eiDao
.getAllEntityInfo(testTableName);
System.out.println(allEntities);
Assert.assertTrue(allEntities.size() > 0);
}
@Test
public void testGetEncodeNameByCode() {
String result = eiDao.getEncodeNameByCode("1", testTableName);
Assert.assertTrue(result.equals("预算执行系统"));
}
@Test
public void testGetEncodeCodeByName() {
List<String> result = eiDao
.getEncodeCodeByName("预算执行系统", testTableName);
Assert.assertTrue(result.size() > 0);
}
@Test
public void testUpdateEncodeNameByCode() {
int result = eiDao
.updateEncodeNameByCode("3", "财政一体化平台", testTableName);
Assert.assertTrue(result > 0);
}
@Test
public void testInsertEncodeEntity() {
int result = eiDao.insertEncodeEntity(new EncodedInfoEntity("非税收入系统",
"4"), testTableName);
Assert.assertTrue(result == 1);
}
@Test
public void testDeleteEncodeByCode() {
int result = eiDao.deleteEncodeByCode("5", testTableName);
Assert.assertTrue(result >= 1);
}
}

@ -1,45 +0,0 @@
package com.platform.test;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.platform.entities.EncodedInfoEntity;
import com.platform.service.EncodeInfoService;
public class TestEncodeService extends SMBasedTest {
private EncodeInfoService eis;
private String testTableName;
@Before
public void initBeforeFunction() {
eis = (EncodeInfoService) this.applicationContext
.getBean("encodeInfoService");
testTableName = "system_info";
}
@Test
public void testGetEncodeNameByCode() {
String result = eis.getEncodeNameByCode("2", testTableName);
Assert.assertTrue(result.equals("部门预算"));
}
/**
*
*/
@Test
public void testDeleteEncodeByCode() {
eis.deleteEncodeByCode("4", testTableName);
}
@Test
public void testGetAllEncodeInfo() {
List<EncodedInfoEntity> allEntities = eis
.getAllEncodeInfo(testTableName);
System.out.println(allEntities);
Assert.assertTrue(allEntities.size() >= 1);
}
}

@ -1,42 +0,0 @@
package com.platform.test;
public class User {
private String name;
private int id;
private String sex;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public User(String name, int id, String sex) {
super();
this.name = name;
this.id = id;
this.sex = sex;
}
public User(){
}
}

@ -1,64 +0,0 @@
package com.platform.test;
import java.util.List;
import com.platform.entities.FolderNode;
public class Volume {
private String name;
private long totalSize;
private long usedSize;
private List<Brick> bricks;
private List<FolderNode> folderNode;
public Volume(String volume, long totalSize, long usedSize,
List<Brick> bricks, List<FolderNode> folderNode) {
super();
this.name = volume;
this.totalSize = totalSize;
this.usedSize = usedSize;
this.bricks = bricks;
this.folderNode = folderNode;
}
public String getVolume() {
return name;
}
public void setVolume(String name) {
this.name = name;
}
public long getTotalSize() {
return totalSize;
}
public void setTotalSize(long totalSize) {
this.totalSize = totalSize;
}
public long getUsedSize() {
return usedSize;
}
public void setUsedSize(long usedSize) {
this.usedSize = usedSize;
}
public List<Brick> getBricks() {
return bricks;
}
public void setBricks(List<Brick> bricks) {
this.bricks = bricks;
}
public List<FolderNode> getFolderNode() {
return folderNode;
}
public void setFolderNode(List<FolderNode> folderNode) {
this.folderNode = folderNode;
}
}

@ -1,19 +0,0 @@
package com.platform.test;
import org.junit.Before;
import com.platform.dao.DataInfoDao;
public class testSystemInfoDao extends SMBasedTest {
private DataInfoDao dfDao;
@Before
public void initBeforeFunction() {
dfDao = (DataInfoDao) this.applicationContext.getBean("dataInfoDao");
}
// @Test @Test
public void test() {
//System.out.println(dfDao.getCount());
}
}

@ -1,64 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 读取db.properties中的属性值 -->
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="/WebContent/WEB-INF/config/config.properties"></property>
</bean>
<!-- 连接MySQL数据库 -->
<bean id="mySQLDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.mysql.driver}" />
<property name="url" value="${jdbc.mysql.url}" />
<property name="username" value="${jdbc.mysql.username}" />
<property name="password" value="${jdbc.mysql.password}" />
</bean>
<bean id="mySQLSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="/WebContent/WEB-INF/config/mybatis-applicationConfig.xml" />
<property name="dataSource" ref="mySQLDataSource" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.platform.dao" />
</bean>
<!-- 配置声明式事物 -->
<bean id="mySQLTxManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="mySQLDataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="mySQLTxManager">
<tx:attributes>
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="insert*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="get*" read-only="true" />
<tx:method name="select*" read-only="true" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut expression="execution(* com.platform.service.*.*(..))"
id="pointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut" />
</aop:config>
<bean id="user" class="com.platform.test.User">
<property name="name" value="伍名" />
<property name="id" value="1" />
<property name="sex" value="男" />
</bean>
<context:component-scan base-package="com.platform.*">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
</beans>
Loading…
Cancel
Save