|
|
|
@ -1,10 +1,8 @@
|
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.*;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.TimeTool;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseBean;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
@ -13,7 +11,6 @@ import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.model.platform.UserDetailModel;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.platbean.SysLogSystem;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.eureka.EurekaClientHealthCheck;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
@ -22,7 +19,6 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
|
|
|
@ -30,18 +26,18 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.lang.reflect.Parameter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
|
* @Description : IMPP性能测试
|
|
|
|
|
* @Reference :
|
|
|
|
|
* @Author : yunhao
|
|
|
|
|
* @CreateDate : 2019-02-19 11:29
|
|
|
|
@ -140,12 +136,11 @@ public class TestController {
|
|
|
|
|
// 测试cpu性能
|
|
|
|
|
if (cpu) {
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
TestThread th1 = new TestThread(piLength);
|
|
|
|
|
th1.start();
|
|
|
|
|
System.out.println(ComputePi.computePi(piLength));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("查询成功").setResultObject("耗时:" + (System.currentTimeMillis() - time))
|
|
|
|
|
return ResultBean.success("查询成功 耗时:" + (System.currentTimeMillis() - time))
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -167,7 +162,7 @@ public class TestController {
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/test-db")
|
|
|
|
|
@ApiOperation(value = "数据库操作测试", notes = "数据库操作测试")
|
|
|
|
|
public ResultBean testDBCRUD(int num, boolean mongo, boolean insert, boolean update, boolean batchUpdate, boolean delete, boolean batchDelete, int waitTime) {
|
|
|
|
|
public ResultBean testDBCRUD(int num, boolean mongo, boolean insert, boolean update, boolean batchUpdate, boolean delete, boolean batchDelete,long min,long max) {
|
|
|
|
|
try {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
Pager page = new Pager();
|
|
|
|
@ -176,12 +171,15 @@ public class TestController {
|
|
|
|
|
List list;
|
|
|
|
|
SysTool sysTool;
|
|
|
|
|
SysLogSystem sysLogSystem;
|
|
|
|
|
int insertAffect = 0;
|
|
|
|
|
int updateAffect = 0;
|
|
|
|
|
long deleteAffect = 0;
|
|
|
|
|
|
|
|
|
|
long t1 = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
// 新增数据
|
|
|
|
|
if (insert) {
|
|
|
|
|
for (int i = 0; i < num * 1000; i++) {
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
t1 = System.currentTimeMillis();
|
|
|
|
|
if (!mongo) {
|
|
|
|
|
sysTool = new SysTool();
|
|
|
|
@ -192,8 +190,6 @@ public class TestController {
|
|
|
|
|
sysTool.setToolDescription("描述新增测试");
|
|
|
|
|
|
|
|
|
|
sysToolService.insertSysTool(sysTool);
|
|
|
|
|
|
|
|
|
|
this.wait(waitTime);
|
|
|
|
|
} else {
|
|
|
|
|
sysLogSystem = new SysLogSystem();
|
|
|
|
|
sysLogSystem.setLogClass("新增测试class");
|
|
|
|
@ -207,20 +203,18 @@ public class TestController {
|
|
|
|
|
sysLogSystem.setLogTitle("新增测试");
|
|
|
|
|
|
|
|
|
|
syslogSystemService.insertSysLogSystem(sysLogSystem);
|
|
|
|
|
|
|
|
|
|
this.wait(waitTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOGGER.info("插入耗时:" + (System.currentTimeMillis() - t1) + ",idx:" + i);
|
|
|
|
|
insertAffect++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (update || delete) {
|
|
|
|
|
// 查询批量修改或删除的数据
|
|
|
|
|
if (mongo) {
|
|
|
|
|
list = syslogSystemService.querySysLogSystemByPager(null, page).getObjectList();
|
|
|
|
|
list = syslogSystemService.findSysLogSystemByIdInterval(min,max);
|
|
|
|
|
} else {
|
|
|
|
|
list = sysToolService.findSysToolByTop(num);
|
|
|
|
|
list = sysToolService.findSysToolByIdInterval(min,max);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 是否进行修改测试,并判断进行批量或逐次修改
|
|
|
|
@ -229,10 +223,10 @@ public class TestController {
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
ids[i] = ((SysTool) list.get(i)).getId();
|
|
|
|
|
}
|
|
|
|
|
sysToolService.updateSysToolStatusByIds(ids, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
updateAffect = sysToolService.updateSysToolStatusByIds(ids, (int) (Math.random() * 1000));
|
|
|
|
|
} else if (!mongo && update) {
|
|
|
|
|
for (Object obj : list) {
|
|
|
|
|
sysTool = (SysTool) obj;
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
sysTool = (SysTool) list.get(i);
|
|
|
|
|
sysTool.setName("修改测试" + System.currentTimeMillis());
|
|
|
|
|
sysTool.setToolTypeId(1073140662133723136L);
|
|
|
|
|
sysTool.setToolIp("192.168.1.35");
|
|
|
|
@ -254,25 +248,26 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mongo) {
|
|
|
|
|
syslogSystemService.deleteSysLogSystemByIds(ids);
|
|
|
|
|
deleteAffect = syslogSystemService.deleteSysLogSystemByIds(ids);
|
|
|
|
|
} else {
|
|
|
|
|
sysToolService.deleteSysToolByIds(ids);
|
|
|
|
|
deleteAffect = sysToolService.deleteSysToolByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
} else if (delete) {
|
|
|
|
|
for (Object obj : list) {
|
|
|
|
|
for (int i = 0; i < num; i++) {
|
|
|
|
|
if (mongo) {
|
|
|
|
|
sysLogSystem = (SysLogSystem) obj;
|
|
|
|
|
syslogSystemService.deleteSysLogSystemById(sysLogSystem.getId());
|
|
|
|
|
sysLogSystem = (SysLogSystem) list.get(i);
|
|
|
|
|
deleteAffect += syslogSystemService.deleteSysLogSystemById(sysLogSystem.getId());
|
|
|
|
|
} else {
|
|
|
|
|
sysTool = (SysTool) obj;
|
|
|
|
|
sysToolService.deleteSysToolById(sysTool.getId());
|
|
|
|
|
sysTool = (SysTool) list.get(i);
|
|
|
|
|
deleteAffect += sysToolService.deleteSysToolById(sysTool.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + num)
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",新增数据量:" + insertAffect
|
|
|
|
|
+ ",修改影响量" + updateAffect + ",删除影响量:" + deleteAffect)
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -280,7 +275,6 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 数据库操作测试
|
|
|
|
|
*
|
|
|
|
@ -292,9 +286,6 @@ public class TestController {
|
|
|
|
|
public ResultBean dateInsert(int num, boolean mongo, int waitTime) {
|
|
|
|
|
try {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
SysTool sysTool;
|
|
|
|
|
SysLogSystem sysLogSystem;
|
|
|
|
|
long t1 = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
// 新增数据
|
|
|
|
|
if (!mongo) {
|
|
|
|
@ -304,7 +295,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + num)
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -384,7 +375,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + list.size())
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -437,7 +428,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成 耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + list.size())
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -486,7 +477,7 @@ public class TestController {
|
|
|
|
|
case 2:
|
|
|
|
|
deptList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < 300; j++) {
|
|
|
|
|
for (int j = 0; j < 20; j++) {
|
|
|
|
|
sysDept = new SysDepartment();
|
|
|
|
|
sysDept.setName("部门名称");
|
|
|
|
|
sysDept.setDepartmentCode("部门code");
|
|
|
|
@ -511,11 +502,18 @@ public class TestController {
|
|
|
|
|
// 复杂对象
|
|
|
|
|
case 3:
|
|
|
|
|
deptList = new ArrayList<>();
|
|
|
|
|
for (int j = 0; j < 20; j++) {
|
|
|
|
|
sysDept = new SysDepartment();
|
|
|
|
|
sysDept.setName("部门名称集合" + j);
|
|
|
|
|
sysDept.setDepartmentCode("部门集合code" + j);
|
|
|
|
|
sysDept.setParentNameRdd("集合" + j);
|
|
|
|
|
deptList.add(sysDept);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
sysDept = new SysDepartment();
|
|
|
|
|
sysDept.setName("部门名称");
|
|
|
|
|
sysDept.setDepartmentCode("部门code");
|
|
|
|
|
sysDept.setParentNameRdd("上级部门名称");
|
|
|
|
|
deptList.add(sysDept);
|
|
|
|
|
|
|
|
|
|
sysDept.setChildList(deptList);
|
|
|
|
|
|
|
|
|
@ -553,7 +551,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数量:" + list.size())
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time)).setResultList(list);
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -586,7 +584,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time))
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -623,7 +621,7 @@ public class TestController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数量:" + list.size())
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(new TestInfo(time));
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
@ -768,4 +766,16 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/make-sql")
|
|
|
|
|
@ApiOperation(value = "生成sql脚本", notes = "生成sql脚本")
|
|
|
|
|
public void MakeSql(String path,int page,int pageSize){
|
|
|
|
|
try {
|
|
|
|
|
for (int i = 0; i < page; i++) {
|
|
|
|
|
Text.printUsage(path,pageSize, i);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|