|
|
|
@ -1,25 +1,31 @@
|
|
|
|
|
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.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;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
|
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;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
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;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -32,10 +38,7 @@ 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;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description :
|
|
|
|
@ -50,6 +53,16 @@ import java.util.Map;
|
|
|
|
|
public class TestController {
|
|
|
|
|
public static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
|
|
|
|
|
|
|
|
|
|
String TEXT = "飓风黑兹尔是1954年大西洋飓风季期间造成死亡人数最多、经济损失最惨重的飓风。这场风暴夺走了海地多达1000人的生命,然后又以四级飓风强度从南、北卡罗莱纳州边境附近袭击美国,造成95人丧生。之后黑兹尔转变成温带风暴,但仍然致使81人遇难,其中大部分来自多伦多。由于风暴造成了重大人员伤亡和财产损失,其名称“黑兹尔”因此从大西洋风暴命名名单上退役。黑兹尔摧毁了海地40%的咖啡树和50%的可可作物,对当地经济的影响持续了数年之久。飓风在南、北卡罗莱纳州登陆,冲击点附近的大部分海滨住宅被毁。气旋从北卡罗莱纳州沿大西洋海岸北上,先后影响了弗吉尼亚州、西弗吉尼亚州、马里兰州、特拉华州、新泽西州、宾夕法尼亚州和纽约州,产生的阵风时速有近160公里,造成的经济损失高达3.08亿美元。多伦多市内及周边有许多溪流溢出,导致严重的洪涝灾害。加拿大遭受的损失达到1.35亿加拿大元。由于缺少应对热带气旋的经验,加上风暴强度的保持时间异常之长,多伦多所受影响的严重程度是前所未有的";
|
|
|
|
|
|
|
|
|
|
SnowflakeIdMaker snowflakeIdMaker = new SnowflakeIdMaker();
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PersonnelController personnelController;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private IPersonnelService personnelService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysLogSystemService syslogSystemService;
|
|
|
|
|
|
|
|
|
@ -68,6 +81,21 @@ public class TestController {
|
|
|
|
|
@Autowired
|
|
|
|
|
private EurekaClientHealthCheck healthCheck;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysPositionService positionService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysOrganizeService organizeService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysDepartmentService departmentService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysMenuService menuService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysRoleService roleService;
|
|
|
|
|
|
|
|
|
|
@Resource(name = "redisRes")
|
|
|
|
|
private ImppRedis redisRes;
|
|
|
|
|
|
|
|
|
@ -77,6 +105,7 @@ public class TestController {
|
|
|
|
|
* @param num 对象生成数量/π计算线程数
|
|
|
|
|
* @param cpu 是否进行cpu测试
|
|
|
|
|
* @param piLength π精确位数
|
|
|
|
|
* @param piLength π精确位数
|
|
|
|
|
* @param ram 是否进行内存测试
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
@ -138,7 +167,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, int waitTime) {
|
|
|
|
|
try {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
Pager page = new Pager();
|
|
|
|
@ -188,9 +217,9 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
if (update || delete) {
|
|
|
|
|
// 查询批量修改或删除的数据
|
|
|
|
|
if(mongo){
|
|
|
|
|
list = syslogSystemService.querySysLogSystemByPager(null,page).getObjectList();
|
|
|
|
|
}else {
|
|
|
|
|
if (mongo) {
|
|
|
|
|
list = syslogSystemService.querySysLogSystemByPager(null, page).getObjectList();
|
|
|
|
|
} else {
|
|
|
|
|
list = sysToolService.findSysToolByTop(num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -204,11 +233,11 @@ public class TestController {
|
|
|
|
|
} else if (!mongo && update) {
|
|
|
|
|
for (Object obj : list) {
|
|
|
|
|
sysTool = (SysTool) obj;
|
|
|
|
|
sysTool.setName("修改测试"+System.currentTimeMillis());
|
|
|
|
|
sysTool.setName("修改测试" + System.currentTimeMillis());
|
|
|
|
|
sysTool.setToolTypeId(1073140662133723136L);
|
|
|
|
|
sysTool.setToolIp("192.168.1.35");
|
|
|
|
|
sysTool.setToolPort(8888);
|
|
|
|
|
sysTool.setToolDescription("描述修改测试"+System.currentTimeMillis());
|
|
|
|
|
sysTool.setToolDescription("描述修改测试" + System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
|
sysToolService.updateSysTool(sysTool);
|
|
|
|
|
}
|
|
|
|
@ -255,14 +284,12 @@ public class TestController {
|
|
|
|
|
/**
|
|
|
|
|
* 数据库操作测试
|
|
|
|
|
*
|
|
|
|
|
* @param num 操作数量
|
|
|
|
|
* @param num 操作数量
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/data-insert")
|
|
|
|
|
@ApiOperation(value = "数据库造数据", notes = "数据库造数据")
|
|
|
|
|
public ResultBean dateInsert(int num,
|
|
|
|
|
boolean mongo,
|
|
|
|
|
int waitTime) {
|
|
|
|
|
public ResultBean dateInsert(int num, boolean mongo, int waitTime) {
|
|
|
|
|
try {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
SysTool sysTool;
|
|
|
|
@ -271,9 +298,9 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
// 新增数据
|
|
|
|
|
if (!mongo) {
|
|
|
|
|
sysToolService.insertBatch(num,waitTime);
|
|
|
|
|
sysToolService.insertBatch(num, waitTime);
|
|
|
|
|
} else {
|
|
|
|
|
syslogSystemService.insertSysLogBatch(num,waitTime);
|
|
|
|
|
syslogSystemService.insertSysLogBatch(num, waitTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("调用完成-耗时:" + (System.currentTimeMillis() - time) + ",数据量:" + num)
|
|
|
|
@ -536,20 +563,21 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 可靠性测试
|
|
|
|
|
* @param needChangeHealth 是否需要修改健康状态
|
|
|
|
|
* @param serverHealth 设置微服务健康状态
|
|
|
|
|
* @param needSleep 是否需要线程睡眠
|
|
|
|
|
* @param sleepTime 睡眠时间ms
|
|
|
|
|
* 可靠性测试
|
|
|
|
|
*
|
|
|
|
|
* @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) {
|
|
|
|
|
public ResultBean testNetwork(boolean needChangeHealth, boolean serverHealth, boolean needSleep, int sleepTime) {
|
|
|
|
|
try {
|
|
|
|
|
long time = System.currentTimeMillis();
|
|
|
|
|
|
|
|
|
|
if(needChangeHealth){
|
|
|
|
|
if (needChangeHealth) {
|
|
|
|
|
healthCheck.setHealth(serverHealth);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -568,9 +596,10 @@ public class TestController {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 多表查询
|
|
|
|
|
* @param num 查询数量
|
|
|
|
|
* @param needCache 是否使用缓存
|
|
|
|
|
* @param cacheTime 缓存时间
|
|
|
|
|
*
|
|
|
|
|
* @param num 查询数量
|
|
|
|
|
* @param needCache 是否使用缓存
|
|
|
|
|
* @param cacheTime 缓存时间
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@GetMapping(value = "/test-complex-query")
|
|
|
|
@ -614,4 +643,129 @@ public class TestController {
|
|
|
|
|
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/test-user-detail-model")
|
|
|
|
|
@ApiOperation(value = "用户数据", notes = "用户数据")
|
|
|
|
|
public void testUserDetailModel() {
|
|
|
|
|
List<SysRole> roleList = roleService.findSysRoleAll();
|
|
|
|
|
List<SysPosition> positionList = positionService.listSysPosition();
|
|
|
|
|
List<SysDepartment> departmentList = departmentService.listSysDepartment();
|
|
|
|
|
for (int l = 0; l < 100; l++) {
|
|
|
|
|
|
|
|
|
|
UserDetailModel model = new UserDetailModel();
|
|
|
|
|
List<String> roleIds = new ArrayList<>();
|
|
|
|
|
List<String> positionIds = new ArrayList<>();
|
|
|
|
|
List<String> departmentIds = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < new Random().nextInt(10); i++) {
|
|
|
|
|
SysRole role = roleList.get(new Random().nextInt(roleList.size() - 1));
|
|
|
|
|
roleIds.add(role.getId().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < new Random().nextInt(10); i++) {
|
|
|
|
|
SysPosition position = positionList.get(new Random().nextInt(positionList.size() - 1));
|
|
|
|
|
positionIds.add(position.getId().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < new Random().nextInt(10); i++) {
|
|
|
|
|
SysDepartment department = departmentList.get(new Random().nextInt(departmentList.size() - 1));
|
|
|
|
|
departmentIds.add(department.getId().toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.setUserInfoId(System.currentTimeMillis() + snowflakeIdMaker.nextId() + "");
|
|
|
|
|
model.setUserId(System.currentTimeMillis() + snowflakeIdMaker.nextId() + "");
|
|
|
|
|
model.setInfoName(RandomStringUtils.random(5, TEXT));
|
|
|
|
|
model.setUserPhone(RandomStringUtils.random(11, false, true));
|
|
|
|
|
model.setUserEmail(RandomStringUtils.random(15, true, true));
|
|
|
|
|
model.setInfoEmpNo(RandomStringUtils.random(10, true, true));
|
|
|
|
|
model.setUserLoginName(RandomStringUtils.random(20, true, true));
|
|
|
|
|
model.setUserLoginPassword("123456");
|
|
|
|
|
model.setInfoPositionId(positionList.get(0).getId().toString());
|
|
|
|
|
model.setInfoDepartmentId(departmentList.get(0).getId().toString());
|
|
|
|
|
model.setUserDepartmentId(departmentList.get(0).getId().toString());
|
|
|
|
|
model.setUserRoleIdList(roleIds);
|
|
|
|
|
model.setUserDepartmentIdList(departmentIds);
|
|
|
|
|
model.setInfoPositionIdList(positionIds);
|
|
|
|
|
model.setInfoDepartmentIdList(departmentIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
SysUser user = model.getSysUser();
|
|
|
|
|
SysUserInfo info = model.getSysUserInfo();
|
|
|
|
|
|
|
|
|
|
init(user);
|
|
|
|
|
init(info);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(info.getUserJoinDate())) {
|
|
|
|
|
info.setUserJoinDate(TimeTool.getToday());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info.setUserInfoStatus(CommonEnumUtil.USER_INFO_STATUS.INCUMBENT.getValue());
|
|
|
|
|
info.setUserLoginNum(0);
|
|
|
|
|
info.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
|
|
|
|
|
user.setUserType(CommonEnumUtil.USER_TYPE.USER.getValue());
|
|
|
|
|
user.setUserStatus(CommonEnumUtil.USER_STATUS.ENABLE.getValue());
|
|
|
|
|
user.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
user.setUserLoginNum(0);
|
|
|
|
|
|
|
|
|
|
SysDepartment infoDepartment = personnelService.getSysDepartmentById(Long.parseLong(model.getInfoDepartmentId()));
|
|
|
|
|
if (infoDepartment == null) {
|
|
|
|
|
ValidatorBean.checkNotNull(infoDepartment, "用户主部门不存在");
|
|
|
|
|
}
|
|
|
|
|
SysOrganize infoOrganize = personnelService.getSysOrganizeById(infoDepartment.getOrganizeId());
|
|
|
|
|
SysPosition position = personnelService.getSysPositionById(Long.parseLong(model.getInfoPositionId()));
|
|
|
|
|
if (infoDepartment == null) {
|
|
|
|
|
ValidatorBean.checkNotNull(position, "用户主岗位存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysDepartment userDepartment = personnelService.getSysDepartmentById(Long.parseLong(model.getUserDepartmentId()));
|
|
|
|
|
if (userDepartment == null) {
|
|
|
|
|
ValidatorBean.checkNotNull(userDepartment, "账号主部门不存在");
|
|
|
|
|
}
|
|
|
|
|
SysOrganize userOrganize = personnelService.getSysOrganizeById(userDepartment.getOrganizeId());
|
|
|
|
|
|
|
|
|
|
info.setDepartmentId(infoDepartment.getId());
|
|
|
|
|
info.setDepartmentNameRdd(infoDepartment.getName());
|
|
|
|
|
info.setOrganizeId(infoOrganize.getId());
|
|
|
|
|
info.setOrganizeNameRdd(infoOrganize.getName());
|
|
|
|
|
info.setOrganizeCode(infoOrganize.getOrganizeCode());
|
|
|
|
|
info.setPositionId(position.getId());
|
|
|
|
|
info.setPositionNameRdd(position.getName());
|
|
|
|
|
personnelService.saveSysUserInfo(info);
|
|
|
|
|
|
|
|
|
|
user.setDepartmentId(userDepartment.getId());
|
|
|
|
|
user.setDepartmentNameRdd(userDepartment.getName());
|
|
|
|
|
user.setOrganizeId(userOrganize.getId());
|
|
|
|
|
user.setOrganizeNameRdd(userOrganize.getName());
|
|
|
|
|
user.setOrganizeCode(userOrganize.getOrganizeCode());
|
|
|
|
|
user.setUserInfoId(info.getId());
|
|
|
|
|
personnelController.refreshSysUserPassword(user);
|
|
|
|
|
personnelService.saveSysUser(user);
|
|
|
|
|
|
|
|
|
|
info.setUserId(user.getId());
|
|
|
|
|
personnelService.saveSysUserInfo(info);
|
|
|
|
|
|
|
|
|
|
// 关系 刷新
|
|
|
|
|
personnelController.refreshRef(user, info, model);
|
|
|
|
|
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void init(BaseBean bean)throws Exception{
|
|
|
|
|
bean.setId(System.currentTimeMillis() + snowflakeIdMaker.nextId());
|
|
|
|
|
bean.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
bean.setIsDeleted(CommonEnumUtil.IS_DEAL.NO.getValue());
|
|
|
|
|
bean.setCreateUser("系统管理员-测试");
|
|
|
|
|
bean.setModifyUser("系统管理员-测试");
|
|
|
|
|
bean.setCreateDatetime(DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
bean.setModifyDatetime(DateFormatUtils.format(System.currentTimeMillis(),"yyyy-MM-dd HH:mm:ss"));
|
|
|
|
|
|
|
|
|
|
Thread.sleep(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|