1、swagger接口文档

beetlsql3-dev
陈沅 1 year ago
parent 96a7e96e4f
commit 5e59bec0dc

@ -46,6 +46,10 @@ public class StudentAccountMockTradingSystemService extends CoreBaseService<Stud
return studentAccountMockTradingSystemDao.getByStudentId(studentId);
}
public StudentAccountMockTradingSystem getByStudentIdAndAppId(Long studentId, Long applicationId){
return studentAccountMockTradingSystemDao.getByStudentIdAndAppId(studentId, applicationId);
}
public void add(StudentAccountMockTradingSystem studentAccountMockTradingSystem) {
studentAccountMockTradingSystemDao.insert(studentAccountMockTradingSystem);

@ -24,9 +24,12 @@ import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Service
@ -150,18 +153,13 @@ public class UserStockTradesService extends CoreBaseService<UserStockTrades> {
return null;
}
public Map<String, BigDecimal> findListByStudentId(Long studentId) {
List<Map<String, Object>> maps = userStockTradesDao.findListByStudentId(studentId);
Map<String, BigDecimal> resultMap = new HashMap<>();
if (maps == null || maps.size() == 0) {
maps = userStockTradesDao.findListByStudentId(4048L);
}
for (Map<String, Object> map : maps) {
String strCreateTime = (String) map.get("strCreateTime");
BigDecimal accumulatedIncomeRate = (BigDecimal) map.get("accumulatedIncomeRate");
resultMap.put(strCreateTime, accumulatedIncomeRate);
private static <T> List<List<T>> partitionList(List<T> list, int batchSize) {
List<List<T>> partitions = new ArrayList<>();
for (int i = 0; i < list.size(); i += batchSize) {
int end = Math.min(i + batchSize, list.size());
partitions.add(list.subList(i, end));
}
return resultMap;
return partitions;
}
@ -199,14 +197,48 @@ public class UserStockTradesService extends CoreBaseService<UserStockTrades> {
}
}
public Map<String, Object> findListByStudentId(Long studentId) {
List<Map<String,Object>> maps = userStockTradesDao.findListByStudentId(studentId);
Map<String, Object> resultMap = new HashMap<>();
if (maps == null || maps.size() == 0) {
maps = userStockTradesDao.findListByStudentId(4048L);
}
for (Map<String,Object> map : maps) {
String strCreateTime = (String) map.get("strCreateTime");
BigDecimal accumulatedTotalProfitLoss = (BigDecimal) map.get("accumulatedTotalProfitLoss");
resultMap.put(strCreateTime, accumulatedTotalProfitLoss.doubleValue());
}
return resultMap;
}
//定时获取交易数据
@Scheduled(cron = "0 32 11 * * ?")
public void fetchTransactionData() {
@Scheduled(cron = "0 30 0 * * ?")
public void threadRun() {
ExecutorService executorService = Executors.newFixedThreadPool(10);
// 获取所有学生数据
List<Student> students = studentService.getAll();
int i =0;
// 定义每个线程处理的学生数量
int batchSize = 2000;
// 将学生列表分成多个子列表
List<List<Student>> studentBatches = partitionList(students, batchSize);
// 提交每个子列表的任务给线程池
for (List<Student> batch : studentBatches) {
executorService.submit(() -> fetchTransactionData(batch));
}
// 关闭线程池
executorService.shutdown();
}
public void fetchTransactionData(List<Student> students) {
// List<Student> students = studentService.getAll();
int i = 0;
SimpleDateFormat stringDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (Student student : students) {
System.out.println("-------------------已处理:"+i++);
System.out.println("-------------------已处理:" + i++);
if (StringUtils.hasText(student.getAccountIdByStock())) {
if (userStockTradesDao.findBySecTypeAndStudentIdAndCreateTime(student.getStudentId(), 1, stringDateFormat.format(new java.util.Date())) == null) {
UserStockTrades userStockTrades = getUserStockTrades(student.getAccountIdByStock());

@ -4,6 +4,8 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ibeetl.admin.core.conf.PasswordConfig;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreUserService;
@ -18,6 +20,7 @@ import com.ibeetl.jlw.entity.dto.StudentEditPasswordDTO;
import com.ibeetl.jlw.entity.dto.StudentRegisterDTO;
import com.ibeetl.jlw.service.*;
import com.ibeetl.jlw.service.api.ApiIndexBaseService;
import com.ibeetl.jlw.util.HttpJsonRequest;
import com.ibeetl.jlw.web.query.TeacherOpenCourseMergeStudentQuery;
import com.ibeetl.jlw.web.query.TeacherOpenCourseNoticeQuery;
import org.checkerframework.checker.units.qual.A;
@ -27,10 +30,7 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import static cn.jlw.util.CacheUserUtil.getStudent;
@ -75,6 +75,14 @@ public class ApiStudentService {
private HsValuesService hsValuesService;
@Autowired
private UserStockTradesService userStockTradesService;
@Autowired
private StudentAccountCrowdfundingSystemService studentAccountCrowdfundingSystemService;
@Autowired
private StudentAccountEquityInvestmentSystemService studentAccountEquityInvestmentSystemService;
@Autowired
private StudentAccountP2pSystemService studentAccountP2pSystemService;
@Autowired
private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService;
/**
* -
@ -91,6 +99,8 @@ public class ApiStudentService {
// 学生ID
final Long studentId = ((Student) identityInfo).getStudentId();
CoreUser coreUser = currentUserInfo.getCoreUser();
// 获取该学生的学校信息
StudentExtendSchoolInfo studentExtendSchoolInfo = studentService.getStudentExtendSchoolInfo(studentId.toString());
@ -163,6 +173,36 @@ public class ApiStudentService {
// pieMaps.add(map7);
//我的收益率
//获取众筹收益
StudentAccountCrowdfundingSystem cfEarnings = studentAccountCrowdfundingSystemService.getInfo(studentId);
List<StudentAccountEquityInvestmentSystem> accountEquityInvestmentSystems = studentAccountEquityInvestmentSystemService.getInfo(studentId);
Double pevcEarnings = getPevcEarnings(coreUser.getOldId());
StudentAccountEquityInvestmentSystem accountEquityInvestmentSystem = accountEquityInvestmentSystems == null ? null : accountEquityInvestmentSystems.get(0);
StudentAccountP2pSystem p2pEarnings = studentAccountP2pSystemService.getValuesByStudentId(studentId);
StudentAccountMockTradingSystem qhEarnings = studentAccountMockTradingSystemService.getByStudentIdAndAppId(studentId, -16L);
StudentAccountMockTradingSystem gpEarnings = studentAccountMockTradingSystemService.getByStudentIdAndAppId(studentId, 16L);
//总资产
Double initialTotalAssets = 0D;
if (cfEarnings != null) {
initialTotalAssets = initialTotalAssets + cfEarnings.getInitialCapital().doubleValue();
}
if (accountEquityInvestmentSystem != null) {
initialTotalAssets = initialTotalAssets + accountEquityInvestmentSystem.getInitialCapital().doubleValue();
}
if (p2pEarnings != null) {
initialTotalAssets = initialTotalAssets + p2pEarnings.getInitialCapital().doubleValue();
}
if (qhEarnings != null) {
initialTotalAssets = initialTotalAssets + qhEarnings.getInitialCapital().doubleValue();
}
if (gpEarnings != null) {
initialTotalAssets = initialTotalAssets + gpEarnings.getInitialCapital().doubleValue();
}
Double cf = cfEarnings == null ? 0D : cfEarnings.getCumulativeIncome().doubleValue();
Double p2p = p2pEarnings == null ? 0D : p2pEarnings.getCumulativeIncome().doubleValue();
List<HsValues> all = hsValuesService.findAll();
Map<String, Object> lineMap = new HashMap<>();
if (all != null && all.size() > 0) {
@ -170,14 +210,15 @@ public class ApiStudentService {
List<String> yList = new ArrayList<>();
List<String> yList1 = new ArrayList<>();
List<List<String>> yLists = new ArrayList<>();
Map<String, BigDecimal> stockTrades = userStockTradesService.findListByStudentId(studentId);
Map<String, Object> stockTrades = userStockTradesService.findListByStudentId(studentId);
for (HsValues values : all) {
xList.add(values.getCreateTimeStr());
yList.add(String.valueOf(values.getHsValue() * 100));
if (stockTrades != null) {
BigDecimal accRate = stockTrades.get(values.getCreateTimeStr());
//accRate乘以100
double accumulatedTotalProfitLoss =stockTrades.get(values.getCreateTimeStr())==null?0:(Double) stockTrades.get(values.getCreateTimeStr());
Double accRate = (accumulatedTotalProfitLoss + pevcEarnings + cf + p2p) / initialTotalAssets * 100;
//模拟交易累计盈亏
yList1.add(accRate == null ? "0" : String.valueOf(accRate));
}
}
@ -320,4 +361,20 @@ public class ApiStudentService {
.studentInfo(studentExtendSchoolInfo).activeInfo(studentActiveInfo)
.build();
}
private Double getPevcEarnings(Long userId) {
String url = "http://120.79.161.177:8029/Account/GetZyAmount?UserId=" + userId;
String ret = HttpJsonRequest.sendPostRequest(url, null, "UserId=" + userId, "application/x-www-form-urlencoded");
double resultValue=0;
ObjectMapper objectMapper = new ObjectMapper();
try {
JsonNode jsonNode = objectMapper.readTree(ret);
resultValue = jsonNode.get("result").asDouble();
} catch (Exception e) {
e.printStackTrace();
}
// 获取result字段的值
return resultValue;
}
}

@ -14,6 +14,7 @@ import com.ibeetl.jlw.entity.dto.CreateUserDTO;
import com.ibeetl.jlw.enums.GenderEnum;
import com.ibeetl.jlw.service.*;
import com.ibeetl.jlw.util.ZhiYunJDBCUtil;
import com.ibeetl.jlw.web.query.SchoolClassQuery;
import com.ibeetl.jlw.web.query.UniversitiesCollegesJurisdictionExperimentalSystemQuery;
import com.ibeetl.jlw.web.query.UniversityFacultyQuery;
import com.ibeetl.jlw.web.query.UniversitySystemQuery;
@ -632,7 +633,9 @@ public class TestController {
@ApiOperation("修改班级2.0id")
@PostMapping("updateOldClassId.json")
public void updateOldClassId() throws SQLException {
List<SchoolClass> classes = schoolClassService.getAll();
SchoolClassQuery query = new SchoolClassQuery();
query.setUniversitiesCollegesId(184L);
List<SchoolClass> classes = schoolClassService.getValuesByQuery(query);
Connection connection = openConn();
PreparedStatement ps = null;
for (SchoolClass schoolClass : classes) {

@ -5,7 +5,7 @@ select * from user_stock_trades where student_id=#studentId# and str_create_time
findListByStudentId
===
select str_create_time,accumulated_income_rate from user_stock_trades where student_id=#studentId#
select str_create_time,sum(accumulated_total_profit_loss) as accumulatedTotalProfitLoss from user_stock_trades where student_id=#studentId# group by str_create_time

Loading…
Cancel
Save