Commit 03ff6ba5 by 涂亚平

压测工具

1 parent 85298f8d
package com.subsidy.common.configure;
import org.apache.catalina.connector.Connector;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement;
@Configuration
public class MyTomcat {
@Value("${spring.server.port}")
private String port;
@Value("${spring.server.acceptorThreadCount}")
private String acceptorThreadCount;
@Value("${spring.server.minSpareThreads}")
private String minSpareThreads;
@Value("${spring.server.maxSpareThreads}")
private String maxSpareThreads;
@Value("${spring.server.maxThreads}")
private String maxThreads;
@Value("${spring.server.maxConnections}")
private String maxConnections;
@Value("${spring.server.protocol}")
private String protocol;
@Value("${spring.server.redirectPort}")
private String redirectPort;
@Value("${spring.server.compression}")
private String compression;
@Value("${spring.server.connectionTimeout}")
private String connectionTimeout;
@Value("${spring.server.MaxFileSize}")
private String MaxFileSize;
@Value("${spring.server.MaxRequestSize}")
private String MaxRequestSize;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addConnectorCustomizers(new GwsTomcatConnectionCustomizer());
return tomcat;
}
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize(MaxFileSize); // KB,MB
/// 总上传数据大小
factory.setMaxRequestSize(MaxRequestSize);
return factory.createMultipartConfig();
}
/**
*
* 默认http连接
*
* @version
* @author liuyi 2016年7月20日 下午7:59:41
*
*/
public class GwsTomcatConnectionCustomizer implements TomcatConnectorCustomizer {
public GwsTomcatConnectionCustomizer() {
}
@Override
public void customize(Connector connector) {
connector.setPort(Integer.valueOf(port));
connector.setAttribute("connectionTimeout", connectionTimeout);
connector.setAttribute("acceptorThreadCount", acceptorThreadCount);
connector.setAttribute("minSpareThreads", minSpareThreads);
connector.setAttribute("maxSpareThreads", maxSpareThreads);
connector.setAttribute("maxThreads", maxThreads);
connector.setAttribute("maxConnections", maxConnections);
connector.setAttribute("protocol", protocol);
connector.setAttribute("redirectPort", "redirectPort");
connector.setAttribute("compression", "compression");
}
}
}
......@@ -24,6 +24,7 @@ import io.swagger.annotations.Api;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.net.InetAddress;
import java.util.Arrays;
import java.util.List;
......@@ -43,6 +44,13 @@ public class AdministerController {
@Autowired
private AdministerService administerService;
@GetMapping("getIp")
public String getIp()throws Exception{
InetAddress addr = InetAddress.getLocalHost();
System.out.println("Local HostAddress:"+addr.getHostAddress());
return addr.getHostAddress();
}
@PostMapping("/login")
@ApiOperation("登录接口 accountName password")
public ResponseVO login(@RequestBody AdministerDO administerDO){
......
......@@ -31,14 +31,14 @@ public class ClassHourDictController {
private ClassHourDictService classHourDictService;
@PostMapping("getSetting")
@ApiOperation("查看当天设置的最大学习时长")
@ApiOperation("查看当天设置的最大学习时长 companyId")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getSetting(){
return ResponseData.generateCreatedResponse(0,classHourDictService.getSetting());
public ResponseVO getSetting(@RequestBody ClassHourDictDO classHourDictDO){
return ResponseData.generateCreatedResponse(0,classHourDictService.getSetting(classHourDictDO));
}
@PostMapping("updateSetting")
@ApiOperation("修改当天设置时长 id classHour status")
@ApiOperation("修改当天设置时长 id 主键 classHour status")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO updateSetting(@RequestBody ClassHourDictDO classHourDictDO){
return ResponseData.generateCreatedResponse(0,classHourDictService.updateSetting(classHourDictDO));
......
......@@ -40,7 +40,7 @@ public class MemberController {
@PostMapping("getAll")
@ApiOperation("查询某部门成员 pageNum pageSize departmentId userName status")
@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
//@LoginRequired(value = {ConstantUtils.ADMINISTER_TERMINATE})
public ResponseVO getAll(@RequestBody GetAllDTO getAllDTO){
return ResponseData.generateCreatedResponse(0,memberService.getAll(getAllDTO));
}
......
package com.subsidy.controller;
import com.alibaba.fastjson.JSON;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.model.VodPlayHistoryDO;
......@@ -31,10 +32,15 @@ public class VodPlayHistoryController {
private VodPlayHistoryService vodPlayHistoryService;
@PostMapping("insertHistory")
@ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
@ApiOperation("记录学生看视频位置 ajax请求 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
public ResponseVO insertHistory(@RequestBody VodPlayHistoryDO vodPlayHistoryDO){
return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistory(vodPlayHistoryDO));
}
@RequestMapping("insertHistoryNew")
@ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点")
public ResponseVO insertHistoryNew(@RequestBody String param){
VodPlayHistoryDO vodPlayHistoryDO = JSON.parseObject(param,VodPlayHistoryDO.class);
return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(vodPlayHistoryDO));
}
}
......@@ -25,6 +25,8 @@ public class ClassHourDictDO extends BaseModel {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long companyId;
/**
* 课时
*/
......
......@@ -15,7 +15,7 @@ import com.subsidy.vo.hour.PollingGetVO;
*/
public interface ClassHourDictService extends IService<ClassHourDictDO> {
ClassHourDictDO getSetting();
ClassHourDictDO getSetting(ClassHourDictDO classHourDictDO);
String updateSetting(ClassHourDictDO classHourDictDO);
......
......@@ -15,4 +15,5 @@ public interface VodPlayHistoryService extends IService<VodPlayHistoryDO> {
String insertHistory(VodPlayHistoryDO vodPlayHistoryDO);
String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO);
}
......@@ -32,9 +32,19 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
@Autowired
private VodPlayHistoryMapper vodPlayHistoryMapper;
public ClassHourDictDO getSetting() {
ClassHourDictDO classHourDictDO = this.baseMapper.selectOne(null);
return classHourDictDO;
public ClassHourDictDO getSetting(ClassHourDictDO classHourDictDO) {
ClassHourDictDO classHourDictDO1 = this.baseMapper.selectOne(new QueryWrapper<ClassHourDictDO>()
.lambda()
.eq(ClassHourDictDO::getCompanyId,classHourDictDO.getCompanyId()));
if (null==classHourDictDO){
ClassHourDictDO classHourDictDO2 = new ClassHourDictDO();
classHourDictDO2.setCompanyId(classHourDictDO.getCompanyId());
classHourDictDO2.setStatus(0);
classHourDictDO2.setClassHour(6);
this.baseMapper.insert(classHourDictDO2);
return classHourDictDO2;
}
return classHourDictDO1;
}
public String updateSetting(ClassHourDictDO classHourDictDO){
......@@ -68,10 +78,14 @@ public class ClassHourDictServiceImpl extends ServiceImpl<ClassHourDictMapper, C
}
//是否超过时长 没超过 false 超过 true
if (total + vodPlayHistoryDO.getPlayLength() < classHourDictDO.getClassHour()*60*60){
pollingGetVO.setBool(false);
}else {
if (classHourDictDO==null){
pollingGetVO.setBool(true);
}else {
if (total + vodPlayHistoryDO.getPlayLength() < classHourDictDO.getClassHour()*60*60){
pollingGetVO.setBool(false);
}else {
pollingGetVO.setBool(true);
}
}
return pollingGetVO;
}
......
......@@ -272,31 +272,31 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
studyPageVO.setTotalMember(classMemberMappingDOS.size());
//多少人完成
int completedCnt = 0;
for (ClassMemberMappingDO cmmd : classMemberMappingDOS) {
Boolean flag = true;
for (VodDictDO vodDictDO : vodDictDOS) {
List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
.lambda()
.eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
.eq(VodPlayHistoryDO::getMemberId, cmmd.getMemberId())
.orderByDesc(VodPlayHistoryDO::getPlayRecord));
if (vodPlayHistoryDOS.size() > 0) {
if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength()) {
flag = false;
//break;
}
} else {
flag = false;
}
}
if (flag) {
completedCnt++;
}
}
studyPageVO.setDoneMember(completedCnt);
//int completedCnt = 0;
//for (ClassMemberMappingDO cmmd : classMemberMappingDOS) {
//
// Boolean flag = true;
//
// for (VodDictDO vodDictDO : vodDictDOS) {
// List<VodPlayHistoryDO> vodPlayHistoryDOS = vodPlayHistoryMapper.selectList(new QueryWrapper<VodPlayHistoryDO>()
// .lambda()
// .eq(VodPlayHistoryDO::getVodId, vodDictDO.getId())
// .eq(VodPlayHistoryDO::getMemberId, cmmd.getMemberId())
// .orderByDesc(VodPlayHistoryDO::getPlayRecord));
// if (vodPlayHistoryDOS.size() > 0) {
// if (vodPlayHistoryDOS.get(0).getPlayRecord() < vodDictDO.getVodLength()) {
// flag = false;
// //break;
// }
// } else {
// flag = false;
// }
// }
// if (flag) {
// completedCnt++;
// }
//}
//studyPageVO.setDoneMember(completedCnt);
}
memberStudyPageVO.setStudyPageVOS(studyPageVOS);
......
......@@ -23,4 +23,9 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl<VodPlayHistoryMapper,
return ConstantUtils.ADD_SUCCESS;
}
public String insertHistoryNew(VodPlayHistoryDO vodPlayHistoryDO){
this.baseMapper.insert(vodPlayHistoryDO);
return ConstantUtils.ADD_SUCCESS;
}
}
......@@ -65,7 +65,7 @@ public class SecretUtils {
{
algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(s.getBytes("UTF-8"));
algorithm.update(s.getBytes(StandardCharsets.UTF_8));
byte[] messageDigest = algorithm.digest();
return messageDigest;
}
......@@ -76,7 +76,7 @@ public class SecretUtils {
return null;
}
private static final String toHex(byte hash[])
private static final String toHex(byte[] hash)
{
if (hash == null)
{
......@@ -100,7 +100,7 @@ public class SecretUtils {
{
try
{
return new String(toHex(md5(s)).getBytes("UTF-8"), "UTF-8");
return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
}
catch (Exception e)
{
......
# 本地环境配置
# 端口号
server.port=23454
# 数据源配置
#spring.datasource.url=jdbc:mysql://rm-uf6n0xuw1x835h2f7ro.mysql.rds.aliyuncs.com:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.url=jdbc:mysql://116.62.57.92:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.username=ykadmin_new
#spring.datasource.password=youkedb608@good
spring.datasource.username=devloper
spring.datasource.password=dev@1553$
spring.datasource.druid.initialSize=5
spring.datasource.druid.minIdle=5
spring.datasource.druid.maxActive=20
spring.datasource.druid.maxActive=200
spring.datasource.druid.maxWait=60000
spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
spring.datasource.druid.minEvictableIdleTimeMillis=300000
......
# 生产环境配置
# 端口号
server.port=23454
# 数据源配置
spring.datasource.url=jdbc:mysql://rm-uf69w46mo6agw0ahao.mysql.rds.aliyuncs.com:3306/subsidy?autoReconnect=true&useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
......
# 环境配置
spring.profiles.active=dev
# 端口号
spring.server.port=23454
#嵌入tomcat配置
#和CPU数
spring.server.acceptorThreadCount=200
spring.server.minSpareThreads=100
spring.server.maxSpareThreads=500
spring.server.maxThreads=800
spring.server.maxConnections=50000
#10秒超时
spring.server.connectionTimeout=20000
spring.server.protocol=org.apache.coyote.http11.Http11Nio2Protocol
spring.server.redirectPort=8443
spring.server.compression=on
#文件请求大小
spring.server.MaxFileSize=300MB
spring.server.MaxRequestSize=500MB
# 文件编码 UTF8
spring.mandatory-file-encoding=UTF-8
spring.jackson.time-zone=GMT+8
# 404 交给异常处理器处理
spring.mvc.throw-exception-if-no-handler-found=true
# 关闭静态资源的映射
spring.resources.add-mappings=false
# 关闭banner打印
mybatis-plus.global-config.banner=false
# mybatis-plus相关配置
mybatis-plus.mapper-locations=classpath:mapper/*.xml
# 是否开启自动驼峰命名规则映射
mybatis-plus.configuration.map-underscore-to-camel-case=true
# 如果查询结果中包含空值的列,则 MyBatis 在映射的时候,不会映射这个字段
mybatis-plus.configuration.call-setters-on-nulls=true
# 逻辑删除
mybatis-plus.global-config.db-config.logic-delete-value=NOW()
mybatis-plus.global-config.db-config.logic-not-delete-value=NULL
#日志配置
logging.config=classpath:logback-spring.xml
# 阿里云短信
sms.product=Dysmsapi
sms.domain=dysmsapi.aliyuncs.com
sms.accessKeyId=LTAIOrpFKrDqsQ2c
sms.accessKeySecret=1Qp8huLETbWiBBJvHXJ7MOIhtKuA1G
#wechat.app-id=wx7785293ff5e31f14
#wechat.app-secret=25d57cad61fc1b45b3afa46d4c35e8f6
#wechat.agentId=1000008
vod.appId= 1302252447
vod.secretId= AKIDOcePHvZ2C5VeYHQGSO5aqtlNxJQLqfz2
vod.secretKey= vjHYRmrfDbw0rWxA7oFcj7F8lDPKCm8E
vod.api= vod.tencentcloudapi.com
vod.region= ap-shanghai
vod.classId= 848920
vod.appId=1302252447
vod.secretId=AKIDOcePHvZ2C5VeYHQGSO5aqtlNxJQLqfz2
vod.secretKey=vjHYRmrfDbw0rWxA7oFcj7F8lDPKCm8E
vod.api=vod.tencentcloudapi.com
vod.region=ap-shanghai
vod.classId=848920
# quartz
# 数据持久化方式
spring.quartz.job-store-type=jdbc
......
......@@ -66,7 +66,7 @@
t.delete_date IS NULL
AND t2.delete_date IS NULL
and t.department_id = #{departmentId}
<if test="userName = null and userName !=''">
<if test="userName != null and userName !=''">
and t2.user_name like concat('%',#{userName} ,'%')
</if>
<if test="status != null and status !=''">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!