feat:
parent
43f57013ad
commit
c217ec045d
@ -0,0 +1,64 @@
|
||||
package org.alis.excel.service;
|
||||
|
||||
import cn.hutool.core.lang.Pair;
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author lc
|
||||
* @date 2024/6/5 11:48
|
||||
**/
|
||||
@Component
|
||||
public class OrderTimeQueryService implements Runnable {
|
||||
|
||||
private static final String group = "prod";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try (InputStream resource = this.getClass().getClassLoader().getResourceAsStream("last.txt");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(resource)))) {
|
||||
List<String> collect = reader.lines().collect(Collectors.toList());
|
||||
List<List<String>> partition = ListUtils.partition(collect, 200);
|
||||
List<Pair<Long, Pair<String, String>>> result = new ArrayList<>();
|
||||
for (List<String> list : partition) {
|
||||
String sql = list.stream().collect(Collectors.joining(",", "(", ")"));
|
||||
List<Entity> entityList = Db.use(group).query("select order_id ,pay_time from lpay.pay where status=2 and order_id in " + sql);
|
||||
List<Entity> orderPay = Db.use(group).query("select order_id ,data->'$.payTime' as pay_time from lily_os_1.order_detail_01 where section='order-pay' and order_id in " + sql);
|
||||
Map<Long, String> orderPayMap = orderPay.stream().map(p -> {
|
||||
Long order_id = p.getLong("order_id");
|
||||
String pay_time = p.getStr("pay_time");
|
||||
return Pair.of(order_id, pay_time);
|
||||
}).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
|
||||
Map<Long, String> map = entityList.stream().map(en -> {
|
||||
Long order_id = en.getLong("order_id");
|
||||
String pay_time = en.getStr("pay_time");
|
||||
return Pair.of(order_id, pay_time);
|
||||
}).collect(Collectors.toMap(Pair::getKey, Pair::getValue));
|
||||
list.forEach(or -> {
|
||||
Long order = Long.valueOf(or);
|
||||
result.add(Pair.of(order, Pair.of(orderPayMap.getOrDefault(order, "").replace(".0", ""), map.getOrDefault(order, "").replace(".0", ""))));
|
||||
});
|
||||
}
|
||||
result.forEach(p ->{
|
||||
String key = p.getValue().getKey().replace("\"", "");
|
||||
if (key.startsWith("2024") && p.getValue().getValue().startsWith("2023")) {
|
||||
System.out.println(p.getKey() + "," + key + "," + p.getValue().getValue());
|
||||
} }
|
||||
);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package org.alis.excel.service;
|
||||
|
||||
import cn.hutool.db.Db;
|
||||
import cn.hutool.db.Entity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lc
|
||||
* @date 2024/5/15 11:34
|
||||
**/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TempNodeService implements Runnable {
|
||||
private static final String group = "prod";
|
||||
|
||||
private static final String query="select min(user_id) as id ,reason,amount from account.balance_log\n" +
|
||||
"where reason like '订单%'\n" +
|
||||
"and create_time >='2024-04-01 00:00:00'\n" +
|
||||
"and type=1\n" +
|
||||
"and amount>0\n" +
|
||||
"GROUP BY reason,amount \n" +
|
||||
"HAVING count(*)>1";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
log.info("余额校验查询任务开始----->>>>>>>>");
|
||||
List<Entity> result = Db.use(group).query(query);
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
log.info("未找到需要校验余额,任务结束----<<<<<<<");
|
||||
return;
|
||||
}
|
||||
log.error("异常报警,找到需要处理的余额日志++++共{}条->>>>>", result.size());
|
||||
log.info("开始输出相关信息-->>>>>");
|
||||
result.forEach(entity -> {
|
||||
log.info("用户id:{},余额信息:{},新增金额:{}", entity.getStr("id"), entity.getStr("reason"), entity.getStr("amount"));
|
||||
});
|
||||
log.info("信息输出结束-->>>>>");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1 @@
|
||||
215806
|
||||
212179
|
||||
72007
|
||||
216131
|
Loading…
Reference in New Issue