package com.akali.order.distributed.utils;
import com.akali.common.utils.JSONUtils;
import com.akali.order.distributed.utils.model.TaskInstance;
import com.akali.order.distributed.utils.model.Test1;
import com.akali.order.distributed.utils.model.mock.*;
import com.akali.order.distributed.utils.repository.*;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.*;
@Slf4j
@SpringBootTest
class OrderDistributedUtilsApplicationTests {
@Autowired
private TaskInstanceRepository taskInstanceRepository;
@Autowired
private ApiImproveRepository apiImproveRepository;
@Autowired
private ApiCostReduceRepository apiCostReduceRepository;
@Autowired
private ApiIncomeRepository apiIncomeRepository;
@Autowired
private HotApiRepository hotApiRepository;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
@Test
void contextLoads() {
System.out.println("启动成功!!");
}
@Test
void testTaskInstanceRepository() {
// TaskInstance taskInstance = new TaskInstance();
// taskInstance.setId(UUID.randomUUID().toString());
// taskInstance.setTaskName("TestTaskName");
// // 新增
// taskInstanceRepository.save(taskInstance);
// 根据id查询
// TaskInstance taskById = findTaskById("bedd3268-bbee-4938-ae37-6f75aafa8dcc");
// if (taskById != null) {
// // 更新
// taskById.setTaskName("NewTaskname");
// taskInstanceRepository.save(taskById);
// }
// 分页查询
PageRequest pageRequest = PageRequest.of(0, 10);
Page<TaskInstance> tasks = taskInstanceRepository.findByTaskNameAndSliceAndStatus("NewTaskname", "01", "01", pageRequest);
for (TaskInstance task : tasks) {
System.out.println(task);
}
}
private TaskInstance findTaskById(String id) {
Optional<TaskInstance> existedTask = taskInstanceRepository.findById(id);
return existedTask.orElse(null);
}
@Test
void testStrStartWith() {
String testStr = "CRON: 0 45 7 * * ?";
// if (testStr.startsWith("CRON:")) {
// new CronSe
// }
}
@Test
void testJsonExam() {
List<String> test1s = new ArrayList<>();
test1s.add(JSONUtils.toJson(new Test1(1, "我是1")));
test1s.add(JSONUtils.toJson(new Test1(1, "我是2")));
test1s.add(JSONUtils.toJson(new Test1(2, "我是3")));
List<String> attributes = getAttributes(1, test1s);
System.out.println(attributes);
}
private List<String> getAttributes(Integer type, List<String> jsonList) {
List<String> attributes = new ArrayList<>();
if (jsonList == null || jsonList.isEmpty()) {
return attributes;
}
for (String s : jsonList) {
Test1 test1 = JSONUtils.fromJson(s, Test1.class);
if (test1 != null && type.equals(test1.getType())) {
attributes.add(test1.getDesc());
}
}
return attributes;
}
// 插入1万条收入信息
@Test
void testApiIncome() {
List<ApiIncome> apiIncomes = new ArrayList<>();
LocalDateTime currentTime = LocalDateTime.now();
for (int i = 0; i < 1000; i++) {
ApiIncome apiIncome = new ApiIncome();
apiIncome.setIncome(new BigDecimal("10000"));
apiIncome.setOrderId("ORDER001");
apiIncome.setTitle("测试");
apiIncome.setCreateTime(currentTime);
apiIncome.setUpdateTime(currentTime);
apiIncomes.add(apiIncome);
}
apiIncomeRepository.saveAll(apiIncomes);
}
// 插入1万条降本信息
@Test
void testApiCostReduce() {
List<ApiCostReduce> apiCostReduces = new ArrayList<>();
LocalDateTime currentTime = LocalDateTime.now();
for (int i = 0; i < 1000; i++) {
ApiCostReduce apiCostReduce = new ApiCostReduce();
apiCostReduce.setCostReduce(new BigDecimal("10000"));
apiCostReduce.setOrderId("ORDER001");
apiCostReduce.setTitle("测试");
apiCostReduce.setCreateTime(currentTime);
apiCostReduce.setUpdateTime(currentTime);
apiCostReduces.add(apiCostReduce);
}
apiCostReduceRepository.saveAll(apiCostReduces);
}
// 插入1万条提效信息
@Test
void testApiImprove() {
List<ApiImprove> apiImproves = new ArrayList<>();
LocalDateTime currentTime = LocalDateTime.now();
for (int i = 0; i < 1000; i++) {
ApiImprove apiImprove = new ApiImprove();
apiImprove.setImprove(new BigDecimal("10000"));
apiImprove.setOrderId("ORDER001");
apiImprove.setTitle("测试");
apiImprove.setCreateTime(currentTime);
apiImprove.setUpdateTime(currentTime);
apiImproves.add(apiImprove);
}
apiImproveRepository.saveAll(apiImproves);
}
// 不使用CompletableFuture并行加载能力统计模块的数据
@Test
void testUnCompletableFuture() {
long start = System.currentTimeMillis();
ApiStatistics apiStatistics = new ApiStatistics();
// 能力收入信息 api_income
List<ApiIncome> all = apiIncomeRepository.findAll();
apiStatistics.setApiIncomeList(all);
// 能力降本信息 api_cost_reduce
List<ApiCostReduce> all1 = apiCostReduceRepository.findAll();
apiStatistics.setApiCostReduceList(all1);
// 能力提效信息 api_improve
List<ApiImprove> all2 = apiImproveRepository.findAll();
apiStatistics.setApiImproveList(all2);
log.info("不使用Future花费时间:{}", System.currentTimeMillis() - start);
// 326
}
// 使用CompletableFuture并行加载能力统计模块的数据
@Test
void testCompletableFuture() throws ExecutionException, InterruptedException {
long start = System.currentTimeMillis();
ApiStatistics apiStatistics = new ApiStatistics();
ExecutorService executorService = Executors.newWorkStealingPool();
CompletableFuture<List<ApiIncome>> list1 = CompletableFuture.supplyAsync(() -> apiIncomeRepository.findAll(), executorService);
CompletableFuture<List<ApiCostReduce>> list2 = CompletableFuture.supplyAsync(() -> apiCostReduceRepository.findAll(), executorService);
CompletableFuture<List<ApiImprove>> list3 = CompletableFuture.supplyAsync(() -> apiImproveRepository.findAll(), executorService);
CompletableFuture.allOf(list1, list2, list3).join();
apiStatistics.setApiIncomeList(list1.get());
apiStatistics.setApiCostReduceList(list2.get());
apiStatistics.setApiImproveList(list3.get());
log.info("使用Future花费时间:{}", System.currentTimeMillis() - start);
// 332
}
/**
* 使用redis缓存,降低热门能力接口的响应时间
*/
@Test
void testSaveHotApi() {
// 先存入10万热门能力
List<HotApi> hotApis = new ArrayList<>();
for (int i = 0; i < 100000; i++) {
HotApi hotApi = new HotApi();
hotApi.setApiName("牛头测试能力名称");
hotApi.setApiCode("牛头测试能力编码");
hotApi.setApiDesc("牛头测试能力描述");
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目是一款基于Java和HTML技术的二手商城设计源码,包含266个文件,其中Java源文件179个,XML配置文件33个,gitignore文件12个,properties文件12个,yml文件11个,jar文件9个,log文件4个,sql文件2个,LICENSE文件1个,iml文件1个。该系统以Java为核心,结合HTML进行界面展示,旨在提供一个功能完善的二手交易平台。
资源推荐
资源详情
资源评论
收起资源包目录
基于Java与HTML的阿卡丽二手商城设计源码 (270个子文件)
.gitignore 396B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
.gitignore 395B
mail-template.html 855B
akali-store.iml 205B
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
maven-wrapper.jar 61KB
OrderDistributedUtilsApplicationTests.java 10KB
InterviewRecord.java 8KB
TaskServiceImpl.java 8KB
UserServiceImpl.java 7KB
DistributedTaskJedisImpl.java 6KB
VerifyCodeUtils.java 5KB
SelfServiceImpl.java 5KB
DeliveryAddressServiceImpl.java 5KB
SneakersMailSender.java 4KB
MsgUtils.java 4KB
XssHttpServletRequestWrapper.java 4KB
SecurityConfig.java 4KB
ShopCartServiceImpl.java 4KB
DeliveryAddressController.java 4KB
SecurityConfig.java 3KB
DateUtils.java 3KB
DateUtils.java 3KB
DateUtils.java 3KB
TaskTrigger.java 3KB
UserServiceImpl.java 3KB
DistributedLockJedisImpl.java 3KB
JwtAuthenticationTokenFilter.java 3KB
OrderServiceApplicationTests.java 3KB
JwtAuthenticationTokenFilter.java 3KB
UserInfo.java 2KB
ShopCartController.java 2KB
DeliveryAddressMsgTranslator.java 2KB
GoodsServiceApplicationTests.java 2KB
SpringSecurityDemoApplicationTests.java 2KB
SearchServiceApplicationTests.java 2KB
JwtUtils.java 2KB
JwtUtils.java 2KB
GoodsController.java 2KB
RestResponse.java 2KB
FileUtils.java 2KB
TaskListenerFactory.java 2KB
TaskInstance.java 2KB
RestResponseObject.java 2KB
RedisConfig.java 2KB
RedisConfig.java 2KB
RedisConfig.java 2KB
RedisConfig.java 2KB
Orders.java 2KB
UserCenterServiceApplicationTests.java 2KB
DistributedIdGeneratorJedisImpl.java 2KB
GoodsServiceImpl.java 2KB
JSONUtils.java 1KB
JSONUtils.java 1KB
UserController.java 1KB
CustomAsyncUncaughtExceptionHandler.java 1KB
SearchController.java 1KB
UserInfo.java 1KB
RecommendGoods.java 1KB
AddressDetail.java 1KB
SubOrders.java 1KB
UserInfo.java 1KB
UserDetailsServiceImpl.java 1KB
SelfController.java 1KB
Product.java 1KB
AuthenticationEntryPointImpl.java 1KB
AuthenticationEntryPointImpl.java 1KB
CommonResult.java 1KB
AccessDeniedHandlerImpl.java 1KB
UserController.java 1KB
SearchServiceImpl.java 1KB
FileController.java 1KB
GlobalExceptionHandler.java 1KB
TaskService.java 1014B
UserDetailsServiceImpl.java 958B
UpdateAddressReq.java 956B
GetAddressListResp.java 954B
AddAddressReq.java 933B
DeliveryAddressService.java 925B
ApiIncome.java 878B
CorsConfig.java 877B
XssFilter.java 855B
AppContextConfig.java 852B
共 270 条
- 1
- 2
- 3
资源评论
lsx202406
- 粉丝: 2784
- 资源: 5657
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 超好看倒计时特效单页html模板源码.zip
- 荒地、农田、森林、湖、山姆、住宅检测11-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 基于epoll的reactor模型
- 人力资源领域人员简历模板docx文档
- 使用python基于CNN的10种水果识别-含1w张以上的数据集图片
- 基于Delaunay三角化的点云数据三维曲面重建matlab仿真,包括程序,中文注释,仿真操作步骤视频
- 船舶检测20-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 船舶检测19-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord、VOC数据集合集.rar
- 华为ENSP基本配置!!!
- Java高级软件工程师简历模板-技能特长与项目经历
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功