性能测试

yun-zuoyi
yunhao.wang 6 years ago
parent 95a680b5c7
commit 9fd6afe3f2

@ -20,6 +20,9 @@ public interface ISysLogSystemService {
@ApiOperation(value = "添加系统日志",notes = "添加系统日志")
void insertSysLogSystem(SysLogSystem logSystem);
@ApiOperation(value = "造数据系统日志",notes = "造数据")
void insertSysLogBatch(int num,int waitTime);
@ApiOperation(value = "删除日志",notes = "删除日志")
void deleteSysLogSystemById(Long id);
@ -31,4 +34,7 @@ public interface ISysLogSystemService {
@ApiOperation(value = "系统日志分页复杂查询",notes = "系统日志分页复杂查询")
ListPager querySysLogSystemByPager(SysLogSystem logSystem, Pager pager);
@ApiOperation(value = "系统日志批量删除",notes = "系统日志批量删除")
void deleteSysLogSystemByIds(Long[] ids);
}

@ -32,6 +32,12 @@ public interface ISysToolService {
void updateSysTool(SysTool tool);
/**
*
*/
@ApiOperation(value = "造数据")
void insertBatch(int num,int waitTime);
/**
*
* @return
*/
@ -84,4 +90,10 @@ public interface ISysToolService {
*/
@ApiOperation(value = "更新设备信息",notes = "根据 ID 批量修改硬件状态信息")
void updateSysToolStatusByIds(Long[] ids,Integer status);
/**
*
*/
@ApiOperation(value = "查询指定数量设备信息",notes = "查询指定数量设备信息")
List<SysTool> findSysToolByTop(int topNum);
}

@ -0,0 +1,19 @@
package cn.estsh.i3plus.core.api.iservice.busi;
import cn.estsh.i3plus.pojo.base.common.Pager;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-20 21:23
* @Modify:
**/
public interface ITestService {
@ApiOperation(value = "多表查询")
List<Object> queryToolAndToolType(Pager pager);
}

@ -0,0 +1,101 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import java.math.BigDecimal;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-22 17:40
* @Modify:
**/
public class ComputePi {
/**
* π   π/4=1-1/3+1/5-1/7+1/9
*   π/2=2*2/3*4/3*4/5*6/5*6/7*8/7*8/9
*/
/**
* constants used in pi computation
*/
private static final BigDecimal FOUR = BigDecimal.valueOf(4);
/**
* rounding mode to use during pi computation
*/
private static final int roundingMode = BigDecimal.ROUND_HALF_EVEN;
/**
* Compute the value of pi to the specified number of
* digits after the decimal point. The value is
* computed using Machin's formula:
* <p>
* pi/4 = 4*arctan(1/5) - arctan(1/239)
* <p>
* and a power series expansion of arctan(x) to
* sufficient precision.
*/
public static void main(String[] args) {
int digits = 8; //精度10万位
String pi = computePi(digits).toString();
System.out.println("length: " + pi.length());
System.out.println(pi);
}
public static void computePiByLBNZ() {
}
public static void computePiByWLMS() {
}
public static BigDecimal computePi(int digits) {
int scale = digits + 5;
BigDecimal arctan1_5 = arctan(5, scale);
BigDecimal arctan1_239 = arctan(239, scale);
BigDecimal pi = arctan1_5.multiply(FOUR).subtract(arctan1_239).multiply(FOUR);
return pi.setScale(digits, BigDecimal.ROUND_HALF_UP);
}
/**
* Compute the value, in radians, of the arctangent of
* the inverse of the supplied integer to the specified
* number of digits after the decimal point. The value
* is computed using the power series expansion for the
* arc tangent:
* <p>
* arctan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 +
* (x^9)/9 ...
*/
public static BigDecimal arctan(int inverseX, int scale) {
BigDecimal result, numer, term;
BigDecimal invX = BigDecimal.valueOf(inverseX);
BigDecimal invX2 = BigDecimal.valueOf(inverseX * inverseX);
numer = BigDecimal.ONE.divide(invX, scale, roundingMode);
result = numer;
int i = 1;
do {
numer =
numer.divide(invX2, scale, roundingMode);
int denom = 2 * i + 1;
term =
numer.divide(BigDecimal.valueOf(denom),
scale, roundingMode);
if ((i % 2) != 0) {
result = result.subtract(term);
} else {
result = result.add(term);
}
i++;
} while (term.compareTo(BigDecimal.ZERO) != 0);
return result;
}
}

@ -0,0 +1,617 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ISysLogSystemService;
import cn.estsh.i3plus.core.api.iservice.busi.ISysToolService;
import cn.estsh.i3plus.core.api.iservice.busi.ISystemResourceService;
import cn.estsh.i3plus.core.api.iservice.busi.ITestService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.*;
import cn.estsh.i3plus.pojo.platform.platbean.SysLogSystem;
import cn.estsh.impp.framework.boot.eureka.EurekaClientHealthCheck;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-19 11:29
* @Modify:
**/
@RestController
@Api(description = "IMPP性能测试")
@RequestMapping("/impp/white/sys-test")
public class TestController {
public static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
@Autowired
private ISysLogSystemService syslogSystemService;
@Autowired
private ISysToolService sysToolService;
@Autowired
private EntityManager entityManager;
@Autowired
public ISystemResourceService systemResourceService;
@Autowired
private ITestService testService;
@Autowired
private EurekaClientHealthCheck healthCheck;
@Resource(name = "redisRes")
private ImppRedis redisRes;
/**
*
*
* @param num /π线
* @param cpu cpu
* @param piLength π
* @param ram
* @return
*/
@GetMapping(value = "/test-pressure")
@ApiOperation(value = "压力测试", notes = "压力测试")
public ResultBean testPressure(int num, boolean cpu, int piLength, boolean ram) {
try {
long time = System.currentTimeMillis();
//测试内存
if (ram) {
SysUser user;
SysDepartment sysDepartment;
List userList = new ArrayList();
List deptList = new ArrayList();
for (int i = 0; i < num; i++) {
// 生成部门计划
for (int j = 0; j < 10; j++) {
sysDepartment = new SysDepartment();
sysDepartment.setName("部门名称");
sysDepartment.setDepartmentCode("code");
sysDepartment.setDepartmentSort(j);
deptList.add(sysDepartment);
}
user = new SysUser();
user.setDepartmentList(deptList);
userList.add(user);
}
}
// 测试cpu性能
if (cpu) {
for (int i = 0; i < num; i++) {
TestThread th1 = new TestThread(piLength);
th1.start();
}
}
return ResultBean.success("查询成功").setResultObject("耗时:" + (System.currentTimeMillis() - time))
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
*
* @param num
* @param insert
* @param update
* @param batchUpdate
* @param delete
* @param batchDelete
* @return
*/
@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) {
try {
long time = System.currentTimeMillis();
Pager page = new Pager();
page.setCurrentPage(1);
page.setPageSize(num);
List list;
SysTool sysTool;
SysLogSystem sysLogSystem;
long t1 = System.currentTimeMillis();
// 新增数据
if (insert) {
for (int i = 0; i < num * 1000; i++) {
t1 = System.currentTimeMillis();
if (!mongo) {
sysTool = new SysTool();
sysTool.setName("新增测试");
sysTool.setToolTypeId(1073140662133723136L);
sysTool.setToolIp("192.168.1.35");
sysTool.setToolPort(8888);
sysTool.setToolDescription("描述新增测试");
sysToolService.insertSysTool(sysTool);
this.wait(waitTime);
} else {
sysLogSystem = new SysLogSystem();
sysLogSystem.setLogClass("新增测试class");
sysLogSystem.setLogMethod("新增测试method");
sysLogSystem.setLogArgs("新增测试参数");
sysLogSystem.setExecuteTime(0L);
sysLogSystem.setArgsCount(1);
sysLogSystem.setLogDetail("2333");
sysLogSystem.setLogLevel(ImppEnumUtil.LOG_LEVEL.DEBUG.getValue());
sysLogSystem.setLogModuleId(CommonEnumUtil.SOFT_TYPE.CORE.getValue());
sysLogSystem.setLogTitle("新增测试");
syslogSystemService.insertSysLogSystem(sysLogSystem);
this.wait(waitTime);
}
LOGGER.info("插入耗时:" + (System.currentTimeMillis() - t1) + ",idx" + i);
}
}
if (update || delete) {
// 查询批量修改或删除的数据
if(mongo){
list = syslogSystemService.querySysLogSystemByPager(null,page).getObjectList();
}else {
list = sysToolService.findSysToolByTop(num);
}
// 是否进行修改测试,并判断进行批量或逐次修改
if (!mongo && update && batchUpdate) {
Long[] ids = new Long[num];
for (int i = 0; i < num; i++) {
ids[i] = ((SysTool) list.get(i)).getId();
}
sysToolService.updateSysToolStatusByIds(ids, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
} else if (!mongo && update) {
for (Object obj : list) {
sysTool = (SysTool) obj;
sysTool.setName("修改测试"+System.currentTimeMillis());
sysTool.setToolTypeId(1073140662133723136L);
sysTool.setToolIp("192.168.1.35");
sysTool.setToolPort(8888);
sysTool.setToolDescription("描述修改测试"+System.currentTimeMillis());
sysToolService.updateSysTool(sysTool);
}
}
// 是否进行删除测试,并判断进行批量或逐次删除
if (delete && batchDelete) {
Long[] ids = new Long[num];
for (int i = 0; i < num; i++) {
if (mongo) {
ids[i] = ((SysLogSystem) list.get(i)).getId();
} else {
ids[i] = ((SysTool) list.get(i)).getId();
}
}
if (mongo) {
syslogSystemService.deleteSysLogSystemByIds(ids);
} else {
sysToolService.deleteSysToolByIds(ids);
}
} else if (delete) {
for (Object obj : list) {
if (mongo) {
sysLogSystem = (SysLogSystem) obj;
syslogSystemService.deleteSysLogSystemById(sysLogSystem.getId());
} else {
sysTool = (SysTool) obj;
sysToolService.deleteSysToolById(sysTool.getId());
}
}
}
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + num)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
*
* @param num
* @return
*/
@GetMapping(value = "/data-insert")
@ApiOperation(value = "数据库造数据", notes = "数据库造数据")
public ResultBean dateInsert(int num,
boolean mongo,
int waitTime) {
try {
long time = System.currentTimeMillis();
SysTool sysTool;
SysLogSystem sysLogSystem;
long t1 = System.currentTimeMillis();
// 新增数据
if (!mongo) {
sysToolService.insertBatch(num,waitTime);
} else {
syslogSystemService.insertSysLogBatch(num,waitTime);
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + num)
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
*
* @param redisKey key
* @param num
* @param batchPutCache
* @param putCache
* @param db
* @param mongo mongodb
* @param cacheTime
* @param deleteCache
* @return
*/
@GetMapping(value = "/test-db-redis")
@ApiOperation(value = "缓存操作测试", notes = "数据库操作测试")
public ResultBean testDBRedis(String redisKey, int num, boolean batchPutCache, boolean putCache, boolean db, boolean mongo, int cacheTime, boolean deleteCache) {
try {
long time = System.currentTimeMillis();
List list = null;
// 是否放入缓存
if (putCache) {
// 是否需要从数据库中查询
if (db) {
Pager page = new Pager();
page.setCurrentPage(1);
page.setPageSize(num);
//是否对mongodb操作
if (mongo) {
list = sysToolService.findSysToolByTop(num);
} else {
list = syslogSystemService.querySysLogSystemByPager(null, page).getObjectList();
}
} else {
// 缓存测试
list = new ArrayList();
SysTool sysTool;
for (int i = 0; i < num; i++) {
sysTool = new SysTool();
sysTool.setName("缓存对象");
sysTool.setToolTypeId(1073141149285355520L);
sysTool.setToolIp("192.168.1.1");
sysTool.setToolPort(8080);
sysTool.setToolStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
sysTool.setToolConnType(ImppEnumUtil.TOOL_CONN_TYPE.USB.getValue());
sysTool.setToolDataType(ImppEnumUtil.TOOL_DATA_TYPE.STRING.getValue());
sysTool.setToolDescription("描述");
list.add(sysTool);
}
}
// 批量或是逐次放入缓存
if (batchPutCache) {
redisRes.putList(redisKey, list, cacheTime);
} else {
for (int i = 0; i < list.size(); i++) {
redisRes.putObject(redisKey + i, list.get(i), cacheTime);
}
}
}
if (deleteCache && batchPutCache) {
redisRes.deleteKey(redisKey);
} else if (deleteCache) {
for (int i = 0; i < list.size(); i++) {
redisRes.putObject(redisKey + i, list.get(i), cacheTime);
}
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + list.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
*
* @param num
* @param mongo 使mongodb
* @param needCache 使
* @param cacheTime
* @return
*/
@GetMapping(value = "/test-db-query")
@ApiOperation(value = "数据库查询测试", notes = "数据库查询测试")
public ResultBean testDBQuery(int num, boolean mongo, boolean needCache, int cacheTime) {
try {
long time = System.currentTimeMillis();
Pager page = new Pager();
page.setCurrentPage(1);
page.setPageSize(num);
List list;
// 是否放入缓存
if (needCache) {
// 是否使用mongodb
if (mongo) {
list = redisRes.getList(SysLogSystem.class.getSimpleName() + num, 0, num);
if (list == null || list.size() == 0) {
list = syslogSystemService.querySysLogSystemByPager(null, page).getObjectList();
redisRes.putList(SysLogSystem.class.getSimpleName() + num, list, cacheTime);
}
} else {
list = redisRes.getList(SysTool.class.getSimpleName() + num, 0, num);
if (list == null || list.size() == 0) {
list = sysToolService.findSysToolByTop(num);
redisRes.putList(SysTool.class.getSimpleName() + num, list, cacheTime);
}
}
} else {
// 是否使用mongodb
if (mongo) {
list = syslogSystemService.querySysLogSystemByPager(null, page).getObjectList();
} else {
list = sysToolService.findSysToolByTop(num);
}
}
return ResultBean.success("调用完成 耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + list.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
*
* @param num
* @param objectLevel 1.2.3.
* @return
*/
@GetMapping(value = "/test-throughput")
@ApiOperation(value = "吞吐量测试", notes = "吞吐量测试")
public ResultBean testThroughput(int num, int objectLevel) {
try {
long time = System.currentTimeMillis();
List list = new ArrayList();
SysTool sysTool;
SessionUser sessionUser;
SysUser sysUser;
SysUserInfo sysUserInfo;
SysDepartment sysDept;
List<SysDepartment> deptList;
for (int i = 0; i < num; i++) {
switch (objectLevel) {
// 单对象
case 1:
sysTool = new SysTool();
sysTool.setName("单对象测试");
sysTool.setToolTypeId(1073141149285355520L);
sysTool.setToolIp("192.168.1.1");
sysTool.setToolPort(8080);
sysTool.setToolStatus(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
sysTool.setToolConnType(ImppEnumUtil.TOOL_CONN_TYPE.USB.getValue());
sysTool.setToolDataType(ImppEnumUtil.TOOL_DATA_TYPE.STRING.getValue());
sysTool.setToolDescription("描述");
list.add(sysTool);
break;
// 大对象
case 2:
deptList = new ArrayList<>();
for (int j = 0; j < 300; j++) {
sysDept = new SysDepartment();
sysDept.setName("部门名称");
sysDept.setDepartmentCode("部门code");
sysDept.setParentNameRdd("上级部门名称");
deptList.add(sysDept);
}
sysUser = new SysUser();
sysUser.setUserName("用户名");
sysUser.setUserStatus(CommonEnumUtil.USER_STATUS.ENABLE.getValue());
sysUser.setUserLoginPassword("123456");
sysUser.setDepartmentId(1L);
sysUser.setOrganizeId(1L);
sysUser.setDepartmentNameRdd("部门名称");
sysUser.setOrganizeNameRdd("组织名称");
sysUser.setUserLoginNum(1);
sysUser.setDepartmentList(deptList);
list.add(sysUser);
break;
// 复杂对象
case 3:
deptList = new ArrayList<>();
sysDept = new SysDepartment();
sysDept.setName("部门名称");
sysDept.setDepartmentCode("部门code");
sysDept.setParentNameRdd("上级部门名称");
deptList.add(sysDept);
sysDept.setChildList(deptList);
sysUser = new SysUser();
sysUser.setUserName("用户名");
sysUser.setUserStatus(CommonEnumUtil.USER_STATUS.ENABLE.getValue());
sysUser.setUserLoginPassword("123456");
sysUser.setDepartmentId(1L);
sysUser.setOrganizeId(1L);
sysUser.setDepartmentNameRdd("部门名称");
sysUser.setOrganizeNameRdd("组织名称");
sysUser.setUserLoginNum(1);
sysUser.setDepartment(sysDept);
sysUser.setDepartmentList(deptList);
sysUserInfo = new SysUserInfo();
sysUserInfo.setName("yonghuming");
sysUserInfo.setOrganizeId(1L);
sysUserInfo.setPositionId(1L);
sysUserInfo.setDepartmentNameRdd("部门名称");
sysUserInfo.setOrganizeNameRdd("组织名称");
sessionUser = new SessionUser();
sessionUser.setUserName("用户名");
sessionUser.setLanguageCode("zh/CN");
sessionUser.setUserCode("10086");
sessionUser.setUserType("测试用户");
sessionUser.setUserId(1L);
sessionUser.setUser(sysUser);
sessionUser.setUserInfo(sysUserInfo);
list.add(sessionUser);
break;
}
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数量:" + list.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(list);
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
* @param needChangeHealth
* @param serverHealth
* @param needSleep 线
* @param sleepTime ms
* @return
*/
@GetMapping(value = "/test-network")
@ApiOperation(value = "网络测试", notes = "网络测试")
public ResultBean testNetwork(boolean needChangeHealth,boolean serverHealth,boolean needSleep, int sleepTime) {
try {
long time = System.currentTimeMillis();
if(needChangeHealth){
healthCheck.setHealth(serverHealth);
}
if (needSleep) {
Thread.sleep(sleepTime);
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time))
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
/**
*
* @param num
* @param needCache 使
* @param cacheTime
* @return
*/
@GetMapping(value = "/test-complex-query")
@ApiOperation(value = "多表查询", notes = "多表查询")
public ResultBean testComplexQuery(int num, boolean needCache, int cacheTime) {
try {
long time = System.currentTimeMillis();
Pager page = new Pager();
page.setCurrentPage(1);
page.setPageSize(num);
List list;
if (needCache) {
list = redisRes.getList(Object.class.getSimpleName() + num, 0, num);
if (list == null || list.size() == 0) {
list = testService.queryToolAndToolType(page);
redisRes.putList(SysTool.class.getSimpleName() + num, list, cacheTime);
}
} else {
list = testService.queryToolAndToolType(page);
}
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数量:" + list.size())
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@GetMapping(value = "/test-gc")
@ApiOperation(value = "垃圾回收", notes = "垃圾回收")
public ResultBean gc() {
try {
System.gc();
return ResultBean.success("调用完成").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException busExcep) {
return ResultBean.fail(busExcep);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -0,0 +1,31 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-19 18:13
* @Modify:
**/
public class TestThread implements Runnable {
private Thread t;
private int piLength = 0;
public TestThread (int piLength){
this.piLength = piLength;
}
@Override
public void run() {
ComputePi.computePi(piLength);
}
public void start () {
if (t == null) {
t = new Thread (this);
t.start ();
}
}
}

@ -0,0 +1,52 @@
package cn.estsh.i3plus.core.apiservice.controller.busi;
import java.lang.management.ManagementFactory;
import java.util.Random;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-19 11:41
* @Modify:
**/
public class Text {
public static void main(String[] args) {
String name = ManagementFactory.getRuntimeMXBean().getName();
System.out.println(name);
// get pid
String pid = name.split("@")[0];
System.out.println("Pid is:" + pid);
for (int i = 0; i < 1; i++) {
TestThread th1 = new TestThread(i);
th1.start();
}
// System.out.println("Please input times: ");
// caculatePI(100000000);
}
public static void caculatePI(int countInSquarel) {
int countInCircle = 0, i, resulttimes;
double x, y; /* 坐标 */
Random s = new Random();
for (resulttimes = 0; resulttimes < 10; resulttimes++) { /* 输出十次结果 */
for (i = 1; i <= countInSquarel; i++) {
x = s.nextDouble(); /* 在0~1之间产生一个随机x坐标 */
y = s.nextDouble(); /* 在0~1之间产生一个随机y坐标 */
if (caculateAcreage(x, y) <= 1.0)
countInCircle++; /* 统计落入单位圆中的点数 */
}
System.out.println("The result of pai is " + (double) countInCircle / countInSquarel * 4); /* 计算出π的值 */
countInCircle = 0;
}
}
private static double caculateAcreage(double xPosition, double yPosition) {
return xPosition * xPosition + yPosition * yPosition;
}
}

@ -0,0 +1,17 @@
package cn.estsh.i3plus.core.apiservice.dao;
import cn.estsh.i3plus.pojo.base.common.Pager;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-20 21:15
* @Modify:
**/
public interface ITestDao {
List<Object> queryToolAndToolType(Pager pager);
}

@ -0,0 +1,36 @@
package cn.estsh.i3plus.core.apiservice.daoimpl;
import cn.estsh.i3plus.core.apiservice.dao.ITestDao;
import cn.estsh.i3plus.pojo.base.common.Pager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-20 21:17
* @Modify:
**/
@Service
public class TestDaoImpl implements ITestDao {
public static final Logger LOGGER = LoggerFactory.getLogger(UserPermissionDaoImpl.class);
@Autowired
private EntityManager entityManager;
@Override
public List<Object> queryToolAndToolType(Pager pager) {
String hql = "select t,tt from SysTool as t " +
" left join SysToolType as tt on t.toolTypeId = tt.id " +
" where 1=1";
return entityManager.createQuery(hql).setFirstResult(pager.getStartRow())
.setMaxResults(pager.getPageSize()).getResultList();
}
}

@ -7,6 +7,7 @@ import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysMessage;
import cn.estsh.impp.framework.base.schedule.BaseImppScheduleJob;
import cn.estsh.impp.framework.boot.init.ApplicationProperties;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import org.quartz.JobExecutionContext;
import org.slf4j.Logger;

@ -199,6 +199,6 @@ public class SysLocaleLanguageService implements ISysLocaleLanguageService {
@Override
@ApiOperation(value = "根据语言状态查询语言信息")
public List<SysLocaleLanguage> findSysLocaleLanguageByStatus(Integer status) {
return sysLocaleLanguageRDao.findByProperty("isDefault",status);
return sysLocaleLanguageRDao.findByProperty("languageStatus",status);
}
}

@ -5,6 +5,9 @@ import cn.estsh.i3plus.core.apiservice.dao.ISysLogSystemDao;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
import cn.estsh.i3plus.pojo.platform.bean.SysTool;
import cn.estsh.i3plus.pojo.platform.platbean.SysLogSystem;
import cn.estsh.i3plus.pojo.platform.platrepositorymongo.SysLogSystemRepository;
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreBsonPack;
@ -39,6 +42,33 @@ public class SysLogSystemService implements ISysLogSystemService {
logSystemRDao.insert(logSystem);
}
@Override
public void insertSysLogBatch(int num,int waitTime){
long t1 = System.currentTimeMillis();
SysLogSystem sysLogSystem = null;
for (int i = 0; i < num * 1000; i++) {
sysLogSystem = new SysLogSystem();
sysLogSystem.setLogClass("新增测试class");
sysLogSystem.setLogMethod("新增测试method" +System.currentTimeMillis());
sysLogSystem.setLogArgs("新增测试参数" + System.currentTimeMillis());
sysLogSystem.setExecuteTime(0L);
sysLogSystem.setArgsCount(1);
sysLogSystem.setLogDetail("2333");
sysLogSystem.setLogLevel(ImppEnumUtil.LOG_LEVEL.DEBUG.getValue());
sysLogSystem.setLogModuleId(CommonEnumUtil.SOFT_TYPE.CORE.getValue());
sysLogSystem.setLogTitle("新增测试");
logSystemRDao.insert(sysLogSystem);
try {
this.wait(waitTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.info("插入SysLog耗时" + (System.currentTimeMillis() - t1) + ",idx" + i);
}
}
@Override
@ApiOperation(value = "删除日志",notes = "删除日志")
public void deleteSysLogSystemById(Long id) {
@ -70,4 +100,9 @@ public class SysLogSystemService implements ISysLogSystemService {
,logSystem.getAscOrDesc()),pager);
}
}
@Override
public void deleteSysLogSystemByIds(Long[] ids) {
logSystemRDao.deleteByIds(ids);
}
}

@ -74,6 +74,31 @@ public class SysToolService implements ISysToolService {
}
@Override
public void insertBatch(int num,int waitTime){
long t1 = System.currentTimeMillis();
SysTool sysTool = new SysTool();
for (int i = 0; i < num * 1000; i++) {
sysTool = new SysTool();
//sysTool.setId(System.currentTimeMillis());
sysTool.setName("新增测试");
sysTool.setToolTypeId(1073140662133723136L);
sysTool.setToolIp("192.168.1.35");
sysTool.setToolPort(8888);
sysTool.setToolDescription("描述新增测试");
toolRDao.insert(sysTool);
try {
// wait(waitTime);
Thread.sleep(waitTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
LOGGER.info("插入耗时:" + (System.currentTimeMillis() - t1) + ",idx" + i);
}
}
@Override
@ApiOperation(value = "查询设备信息",notes = "查询所有设备信息")
public List<SysTool> listSysTool() {
LOGGER.info("硬件 TOOL list");
@ -124,4 +149,8 @@ public class SysToolService implements ISysToolService {
toolRDao.updateByHqlWhere(where.toString(), "toolStatus", status);
}
public List<SysTool> findSysToolByTop(int topNum) {
return toolRDao.findByHqlTopWhere("",topNum);
}
}

@ -0,0 +1,30 @@
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.core.api.iservice.busi.ITestService;
import cn.estsh.i3plus.core.apiservice.dao.ITestDao;
import cn.estsh.i3plus.pojo.base.common.Pager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : yunhao
* @CreateDate : 2019-02-20 21:24
* @Modify:
**/
@Service
public class TestService implements ITestService {
@Autowired
ITestDao testDao;
@Override
@ApiOperation(value = "多表查询")
public List<Object> queryToolAndToolType(Pager pager) {
return testDao.queryToolAndToolType(pager);
}
}
Loading…
Cancel
Save