main
luochuan 5 months ago
parent 43f57013ad
commit c217ec045d

@ -1,6 +1,8 @@
package org.alis.excel;
import org.alis.excel.service.TempNodeService;
import org.alis.excel.service.ClassInventory;
import org.alis.excel.service.ExportClassInService;
import org.alis.excel.service.OrderTimeQueryService;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
@ -17,8 +19,8 @@ public class EasyExcelApplication {
.run(args);
// Runnable runnable = context.getBean(TempNodeService.class);
// runnable.run();
Runnable runnable = context.getBean(OrderTimeQueryService.class);
runnable.run();
}
}

@ -28,7 +28,7 @@ public class ClassInventory implements Runnable {
"and date_format(ci.create_time, '%Y-%m-%d') =date_format(st.create_time, '%Y-%m-%d')\n" +
"left JOIN (select user_id from class.class_student where class_id in (select id from class.class_info where status = 3)) as cl\n" +
"on cl.user_id = st.user_id\n" +
"where ci.id is null and st.create_time >'2024-05-01 00:00:00' and st.user_id in ";
"where ci.id is null and st.user_id in ";
private static final String selectSql = "select st.user_id,st.id,st.week_id,st.create_time from \n" +
" study.student_record st left JOIN class.class_inventory ci\n" +

@ -74,7 +74,7 @@ public class ExcelExportService implements Runnable {
private String getCookie() {
return "source=12; user_id=10751; timestamp=1710906609609; token=eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJVU0VSX0NFTlRFUiIsInN1YiI6IntcImlkXCI6MTA3NTEsXCJuYW1lXCI6XCLnvZflt51cIixcImVtYWlsXCI6XCJjaHVhbi5sdW9AZGF5dWFuMTk5Ny5jb21cIixcInBob25lXCI6XCIxODEqKioqNzIzOVwiLFwic3RhdHVzXCI6MSxcInR5cGVcIjoyLFwibG9naW5EYXRlXCI6XCIyMDI0LTAzLTIwIDExOjUwOjA5XCIsXCJleHBpcmVEYXRlXCI6XCIyMDI0LTA0LTE5IDExOjUwOjA5XCIsXCJkdXJhdGlvblwiOjI1OTIwMDB9IiwiYXVkIjoiTElMWV9wcm9kIiwiaWF0IjoxNzEwOTA2NjA5LCJleHAiOjE3MTM0OTg2MDl9.4w8wsmfvnu2HoUboJkLPc-2XD8aDJfKAdqaYL1xM98ZN_-Y3pdOPbER9BxdoiDvO20wXGq_GggwRJqTWc9AI-w";
return "source=12; user_id=10751; timestamp=1716862389932; token=eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJVU0VSX0NFTlRFUiIsInN1YiI6IntcImlkXCI6MTA3NTEsXCJuYW1lXCI6XCLnvZflt51cIixcImVtYWlsXCI6XCJjaHVhbi5sdW9AZGF5dWFuMTk5Ny5jb21cIixcInBob25lXCI6XCIxODEqKioqNzIzOVwiLFwic3RhdHVzXCI6MSxcInR5cGVcIjoyLFwibG9naW5EYXRlXCI6XCIyMDI0LTA1LTIxIDEwOjMwOjM3XCIsXCJleHBpcmVEYXRlXCI6XCIyMDI0LTA2LTIwIDEwOjMwOjM3XCIsXCJkdXJhdGlvblwiOjI1OTIwMDB9IiwiYXVkIjoiTElMWV9wcm9kIiwiaWF0IjoxNzE2MjU4NjM3LCJleHAiOjE3MTg4NTA2Mzd9.OP_KdkJkwQBwWt57hJg1jjmTyQmRbsW7qwbwu2eZf1rBTrUcGZlavRu3DFYuDNGg6nueE8_X3gzaorUxRMtcww";
}

@ -13,9 +13,14 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.File;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -27,10 +32,10 @@ import java.util.stream.Stream;
@Component
public class ExportClassInService implements Runnable {
private static final String master = "/Users/lily/Downloads/ClassIn平台课节消费_30428872_20240522102754.xlsx";
private static final String master = "/Users/lily/Downloads/ClassIn平台考勤统计_30428872_20240620210040/ClassIn平台课节消费_30428872_20240620210102.xlsx";
private static final List<String> salve = ListUtil.toList("/Users/lily/Downloads/ClassIn平台考勤统计_30428872_20240522102820 2/ClassIn平台考勤统计_30428872_20240522102820_1.xlsx",
"/Users/lily/Downloads/ClassIn平台考勤统计_30428872_20240522102820 2/ClassIn平台考勤统计_30428872_20240522102820_2.xlsx");
private static final List<String> salve = ListUtil.toList("/Users/lily/Downloads/ClassIn平台考勤统计_30428872_20240620210040/ClassIn平台考勤统计_30428872_20240620210040_1.xlsx",
"/Users/lily/Downloads/ClassIn平台考勤统计_30428872_20240620210040/ClassIn平台考勤统计_30428872_20240620210040_2.xlsx");
private static final String exportPath = "/Users/lily/Downloads/classIn-导出结果.xlsx";
@ -68,8 +73,14 @@ public class ExportClassInService implements Runnable {
}).sheet().doRead();
Map<String, DoubleSummaryStatistics> doubleMap = slaveList.stream().filter(s->Objects.nonNull(s.getLessonId())).filter(sl -> sl.getIdentity().equals("学生")).filter(sl -> Objects.nonNull(sl.getDuration()) && sl.getDuration() > 5d).collect(Collectors.groupingBy(Slave::getLessonId, Collectors.summarizingDouble(Slave::getTime)));
log.info("总计有:{}",masterList.size());
AtomicInteger cursor=new AtomicInteger();
NumberFormat percent = NumberFormat.getPercentInstance();
percent.setMaximumFractionDigits(2);
// 计算值
masterList.forEach(ma -> {
cursor.incrementAndGet();
DoubleSummaryStatistics doubleSummaryStatistics = doubleMap.get(ma.getLessonId());
String sql = Stream.of(ma.getClassName().split("、")).map(cl->"'"+cl+"'").collect(Collectors.joining(",", "(", ")"));
long shouldNum = 0L;
@ -97,6 +108,9 @@ public class ExportClassInService implements Runnable {
String rate = numberFormat.format((double) ma.getActualNum() / ma.getStuNum());
ma.setRate(rate);
}
if(ThreadLocalRandom.current().nextInt(0,3) % 3 == 0){
log.info("进度:{}",percent.format(BigDecimal.valueOf(cursor.get()).divide(BigDecimal.valueOf(masterList.size()), 4,BigDecimal.ROUND_HALF_UP)));
}
});

@ -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…
Cancel
Save