1、swagger接口文档

beetlsql3-dev
陈沅 1 year ago
parent e443b4f9fa
commit 7415356906

@ -2,6 +2,7 @@ package com.ibeetl.jlw.service;
import cn.hutool.core.util.IdUtil;
import cn.jlw.oldAliPay.pc.util.Stringutils;
import com.ibeetl.jlw.dao.HsValuesDao;
import com.ibeetl.jlw.entity.HsValues;
import com.ibeetl.jlw.util.HttpJsonRequest;
@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -35,19 +37,23 @@ public class HsValuesService {
// 每天早上9点执行一次任务
@Scheduled(cron = "0 */2 * * * *")
@Scheduled(cron = "0 0 9 * * *")
public void getHsValues() throws JSONException, ParseException {
log.info("------------------------------------开始执行沪深300数据导入-----------------------------");
LocalDate startTime = LocalDate.now().minusDays(5);
LocalDate startTime = LocalDate.now().minusDays(10);
LocalDate endTime = LocalDate.now().plusDays(1);
String urlTwo = "https://api.myquant.cn:9001/ds-history-rpcgw/v3/data-history/benchmark-return"
String urlTwo = "https://sim.sztzjy.com/ds-history-rpcgw/v3/data-history/benchmark-return"
+ "?symbol=SHSE.000300&frequency=1d&startTime=" + startTime.toString()
+ "&endTime=" + endTime.toString() + "&adjust=0";
String authorizationHeader = "bearer ee2c685459aa218ded58d0d7ad2ef2faf6f0d0d4";
String authorizationHeader = "bearer 157e2484a38880effebe57c4ee95d6c29984e2f8";
String jsonResponse = HttpJsonRequest.sendGetRequest(urlTwo, authorizationHeader);
if(!StringUtils.hasText(jsonResponse)){
log.info("------------------------------------沪深300数据获取失败-----------------------------");
return;
}
JSONArray dataArray = HttpJsonRequest.extractDataArray(jsonResponse);
//循环dataArray处理数据
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.admin.core.web.JsonReturnCode;
@ -25,6 +26,7 @@ import com.ibeetl.jlw.web.query.StudentAccountEquityInvestmentSystemQuery;
import org.apache.commons.lang3.StringUtils;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
@ -40,6 +42,11 @@ import java.math.RoundingMode;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.*;
import static cn.hutool.core.collection.IterUtil.getFirst;
@ -89,18 +96,14 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
@Autowired
private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService;
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=Test.Zhiyun_v2.0;trustServerCertificate=true;encrypt=true";
public PageQuery<StudentAccountAssetAllocation> queryByCondition(PageQuery query) {
PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public PageQuery<StudentAccountAssetAllocation> queryByConditionQuery(PageQuery query) {
PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query);
queryListAfter(ret.getList());
return ret;
}
private final static String USER = "sa";
public void deleteByList(List list) {
String ids = "";
@ -293,11 +296,171 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
return payload;
}
private final static String PASSWORD = "sztzjy@2017";
/**
*
*
* @param orgId
*/
public void updateApplicationAuthority(Long orgId) {
List<UniversitiesCollegesJurisdictionExperimentalSystem> experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager()
.lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class)
.andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select();
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
allocationQuery.setOrgId(orgId);
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
//获取所以的资金账号
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
int state = 1;
//获取添加院校权限,对账号进行限制
for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) {
if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) {
//后期添加应用开发权限,新增的时候已经有应用添加了
state = 2;
} else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) {
//新增学生账号,应用还没有添加,后面才添加授权权限的时候获取应用ID设置
ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery();
if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财");
}
if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) {
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery);
if (CollectionUtil.isNotEmpty(resourcesApplicationList)) {
if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) {
accountAssetAllocation.setApplicationId(item.getTypeId());
state = 2;
}
}
}
}
}
accountAssetAllocation.setState(state);
if (ObjectUtil.equals(state, 2)) {
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
accountAssetAllocation.setUpdateTime(new Date());
}
if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -1L) &&
!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) {
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
}
}
}
/**
* /
*
* @param orgId
*/
public void allOpenAccount(Long orgId) {
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
allocationQuery.setOrgId(orgId);
allocationQuery.setState(1);
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
accountAssetAllocation.setState(2);
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
accountAssetAllocation.setUpdateTime(new Date());
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
}
}
@Autowired
private CoreUserService coreUserService;
// 打开数据库连接
public static Connection openConn() throws SQLException {
try {
Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
if (connection != null) {
System.out.println("成功建立数据库连接");
return connection;
} else {
throw new SQLException("无法建立数据库连接");
}
} catch (SQLException e) {
throw new SQLException("无法建立数据库连接: " + e.getMessage(), e);
}
}
// 关闭数据库连接
public static void closeConn(Connection connection) {
if (connection != null) {
try {
connection.close();
System.out.println("数据库连接已关闭");
} catch (SQLException e) {
System.err.println("无法关闭数据库连接: " + e.getMessage());
}
}
}
public PageQuery<StudentAccountAssetAllocation> queryByConditionQuery(PageQuery query) {
PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query);
queryListAfter(ret.getList());
return ret;
}
/**
*
*/
public void createFundAccountWithUserCreated(Long studentId, Long orgId) {
public void createFundAccountWithUserCreated(Long studentId, Long oldUserId, Long orgId) throws SQLException {
//开设7个账户现金账户100万银行账户0元其他应用的账户开设但是未被激活没有初始资金
AccountTypeEnum[] values = AccountTypeEnum.values();
UniversitiesColleges universitiesColleges = universitiesCollegesDao.getByOrgId(orgId);
@ -429,8 +592,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
allocation.setUpdateVersion(-1L);
allocation.setIsInstitution(j);
studentAccountAssetAllocationDao.insert(allocation);
if (allocation != null&&allocation.getApplicationId()!=null) {
if (allocation != null && allocation.getApplicationId() != null) {
if (allocation.getApplicationId() == 4 && j == 1) {
StudentAccountP2pSystem p2pSystem = new StudentAccountP2pSystem();
@ -446,6 +608,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
p2pSystem.setIsInstitution(1L);
p2pSystem.setUserId(allocation.getUserId());
studentAccountP2pSystemService.add(p2pSystem);
createBaseAccount(p2pSystem.getApplicationId(), oldUserId, 2000000D);
} else if (allocation.getApplicationId() == 5 && j == 1) {
StudentAccountCrowdfundingSystem crowdfundingSystem = new StudentAccountCrowdfundingSystem();
@ -461,6 +624,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
crowdfundingSystem.setIsInstitution(1L);
crowdfundingSystem.setUserId(allocation.getUserId());
studentAccountCrowdfundingSystemService.add(crowdfundingSystem);
createBaseAccount(crowdfundingSystem.getApplicationId(), oldUserId, 2000000D);
} else if (allocation.getApplicationId() == 16 && j == 1 && !lock) {
lock = true;
StudentAccountMockTradingSystem mockTradingSystem = new StudentAccountMockTradingSystem();
@ -476,7 +640,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
mockTradingSystem.setIsInstitution(1L);
mockTradingSystem.setUserId(allocation.getUserId());
studentAccountMockTradingSystemService.add(mockTradingSystem);
createBaseAccount(mockTradingSystem.getApplicationId(), oldUserId, 2000000D);
StudentAccountMockTradingSystem mockTradingSystem1 = new StudentAccountMockTradingSystem();
mockTradingSystem1.setStudentId(studentId);
mockTradingSystem1.setApplicationId(-16L);
@ -490,7 +654,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
mockTradingSystem1.setIsInstitution(1L);
mockTradingSystem1.setUserId(allocation.getUserId());
studentAccountMockTradingSystemService.add(mockTradingSystem1);
createBaseAccount(mockTradingSystem1.getApplicationId(), oldUserId, 2000000D);
} else if (allocation.getApplicationId() == 18 && j == 1) {
StudentAccountEquityInvestmentSystem investmentSystem = new StudentAccountEquityInvestmentSystem();
investmentSystem.setStudentId(studentId);
@ -504,6 +668,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
investmentSystem.setIsInstitution(1L);
investmentSystem.setUserId(allocation.getUserId());
studentAccountEquityInvestmentSystemService.add(investmentSystem);
createBaseAccount(investmentSystem.getApplicationId(), oldUserId, 2000000D);
}
}
}
@ -511,129 +676,64 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
}
/**
*
*
* @param orgId
*/
public void updateApplicationAuthority(Long orgId) {
List<UniversitiesCollegesJurisdictionExperimentalSystem> experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager()
.lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class)
.andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select();
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
allocationQuery.setOrgId(orgId);
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
//获取所以的资金账号
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
int state = 1;
//获取添加院校权限,对账号进行限制
for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) {
if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) {
//后期添加应用开发权限,新增的时候已经有应用添加了
state = 2;
} else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) {
//新增学生账号,应用还没有添加,后面才添加授权权限的时候获取应用ID设置
ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery();
if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司");
} else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) {
resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财");
}
if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) {
List<ResourcesApplication> resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery);
if (CollectionUtil.isNotEmpty(resourcesApplicationList)) {
if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) {
accountAssetAllocation.setApplicationId(item.getTypeId());
state = 2;
}
}
}
}
}
accountAssetAllocation.setState(state);
if (ObjectUtil.equals(state, 2)) {
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
accountAssetAllocation.setUpdateTime(new Date());
}
if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -1L) &&
!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) &&
!ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) {
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
}
//在2.0创建基础资金账户
public void createBaseAccount(Long applicationId, Long oldUserId, Double initialCapital) throws SQLException {
String sql = "";
Date currentDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
String formattedDate = dateFormat.format(currentDate);
if (applicationId == 4L) {
sql = "INSERT INTO [dbo].[ExaP2PAssetAllocation]( [ApplicationId], [InitialCapital], [InitialInvestmentCapital], " +
"[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " +
"[Borrowed_Funds], [Freeze_Funds], [Cumulative_of_return], [TotalAssets_Rate_Return], " +
"[Return_on_equity], [TotalDailyInvestment], [TotalWeeklyInvestment], " +
"[TotalMonthlyInvestment], [UserId], [IsDeleted], [DeleterUserId], " +
"[DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], " +
"[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, " +
"0, 0, 0, 0, " + oldUserId + ", " +
"'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
} else if (applicationId == 5L) {
sql = "INSERT INTO [dbo].[ExaTheRaiseAssetAllocation]([ApplicationId], [InitialCapital], [InitialInvestmentCapital], " +
"[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " +
"[TheTotalAmountOfTheRaise], [TheTotalAmountOfFrozen], [Cumulative_of_return], [ReturnOnInvestmentOwnCapital], " +
"[ReturnOnCrowdfundingInvestment], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " +
"[LastModificationTime], [LastModifierUserId], [CreationTime], " +
"[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " +
"" + oldUserId + ", '0', " +
"NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
} else if (applicationId == 16L || applicationId == -16L) {
Integer secType;
secType = applicationId == 16L ? 1 : 4;
sql = "INSERT INTO [dbo].[ExaMNJYAssetAllocation]( [ApplicationId], [InitialCapital], " +
"[InitialInvestmentCapital], [TotalAssets], [AvailableFunds], [Market_value], [Accumulative_total_profit_and_loss], " +
"[Cumulative_rate_of_return], [Annualized_rate_of_return], [Kumar_ratio], [Sharpe_ratio], " +
"[The_biggest_back_test], [Asset_Investment_Rate], [Return_on_equity], [UserId], " +
"[SecType], [IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], " +
"[LastModifierUserId], [CreationTime], [CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " +
"0, 0, 0, " + oldUserId + ", " + secType + ", '0', NULL, NULL, '" + formattedDate + "', NULL, '" + formattedDate + "', " + oldUserId + ")";
} else if (applicationId == 18L) {
sql = "INSERT INTO [dbo].[ExaPEVCAssetAllocation]([ApplicationId], [InitialInvestmentCapital], " +
"[InitialCapital], [TotalAssets], [InvestmentFunds], [LPAmount], [LPInvestmentAmount], " +
"[GPInvestmentAmount], [LhAmount], [FreeMoney], [Bank_loan], [BankInvestmentFunds], " +
"[FreeInvestment_funds], [Return_On_investment], [Return_on_net_asset_investment], " +
"[Return_on_total_assets], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " +
"[LastModificationTime], [LastModifierUserId], [CreationTime], [CreatorUserId]) " +
"VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", "
+ initialCapital + ", 0, 0, 0, 0, 0, " + initialCapital + ", 0, 0, 0, 0, 0, 0, " + oldUserId + ", " +
"'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")";
sendPostRequest("http://120.79.161.177:8029/Account/InsertPevcFunding", "UserId=" + oldUserId);
}
runJdbc(sql);
}
/**
* /
*
* @param orgId
*/
public void allOpenAccount(Long orgId) {
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
allocationQuery.setOrgId(orgId);
allocationQuery.setState(1);
List<StudentAccountAssetAllocation> valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery);
for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) {
accountAssetAllocation.setState(2);
accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital());
accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds());
accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital());
accountAssetAllocation.setUpdateTime(new Date());
studentAccountAssetAllocationDao.updateById(accountAssetAllocation);
}
//运行jdbc
public void runJdbc(String sql) throws SQLException {
Connection conn = openConn();
PreparedStatement ps = conn.prepareStatement(sql);
ps.executeUpdate();
closeConn(conn);
}
/**
*
*
@ -737,22 +837,30 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
updateQuery.setStudentId(studentId);
List<StudentAccountAssetAllocation> updateAccount = studentAccountAssetAllocationDao.getValuesByQuery(updateQuery);
StudentAccountAssetAllocation allocation = updateAccount.get(0);
studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(),allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(),
studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(),
allocation.getInitialInvestmentCapital(), allocation.getInitialInvestmentCapital(), studentId);
String sql = "update ExaPEVCAssetAllocation set FreeMoney =" + allocation.getAvailableFunds()
+ " where UserId = " + coreUser.getOldId() + "";
try{
runJdbc(sql);
}catch (Exception e){
e.printStackTrace();
}
}
if (outAccountAssetAllocation.getApplicationId() == 4 || toAccountAssetAllocation.getApplicationId() == 4) {
updateStudentAccountByApplicationId(studentId, 4);
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 4);
}
if (outAccountAssetAllocation.getApplicationId() == 5 || toAccountAssetAllocation.getApplicationId() == 5) {
updateStudentAccountByApplicationId(studentId, 5);
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 5);
}
if (outAccountAssetAllocation.getApplicationId() == 16 || toAccountAssetAllocation.getApplicationId() == 16) {
updateStudentAccountByApplicationId(studentId, 16);
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 16);
}
if (outAccountAssetAllocation.getApplicationId() == -16 || toAccountAssetAllocation.getApplicationId() == -16) {
updateStudentAccountByApplicationId(studentId, -16);
updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), -16);
}
return JsonResult.success();
@ -760,7 +868,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
// 创建一个方法来执行更新子系统资产表操作
public void updateStudentAccountByApplicationId(long studentId, int applicationId) {
public void updateStudentAccountByApplicationId(long studentId, Long oldUserId, int applicationId) {
StudentAccountAssetAllocationQuery updateQuery = new StudentAccountAssetAllocationQuery();
updateQuery.setApplicationId((long) applicationId);
updateQuery.setStudentId(studentId);
@ -770,15 +878,43 @@ public class StudentAccountAssetAllocationService extends CoreBaseService<Studen
switch (applicationId) {
case 4:
studentAccountP2pSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId);
String sql = "update ExaP2PAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ," +
"InitialCapital = " + allocation.getInitialCapital() + " , InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId = " + oldUserId + "";
try {
runJdbc(sql);
} catch (Exception e) {
e.printStackTrace();
}
break;
case 5:
studentAccountCrowdfundingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId);
String sql1 = "update ExaTheRaiseAssetAllocation set AvailableFunds = " + allocation.getAvailableFunds() + ",InitialCapital = " + allocation.getInitialCapital() + "," +
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " ";
try {
runJdbc(sql1);
} catch (Exception e) {
e.printStackTrace();
}
break;
case 16:
studentAccountMockTradingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId, Long.valueOf(16));
String sql2 = "update ExaMNJYAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ,InitialCapital= " + allocation.getInitialCapital() + ", " +
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " and ApplicationId = 16";
try {
runJdbc(sql2);
} catch (Exception e) {
e.printStackTrace();
}
break;
case -16:
studentAccountMockTradingSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), studentId, Long.valueOf(-16));
String sql3 = "update ExaMNJYAssetAllocation set AvailableFunds =" + allocation.getAvailableFunds() + " ,InitialCapital= " + allocation.getInitialCapital() + ", " +
"InitialInvestmentCapital =" + allocation.getInitialInvestmentCapital() + " where UserId =" + oldUserId + " and ApplicationId = -16";
try {
runJdbc(sql3);
} catch (Exception e) {
e.printStackTrace();
}
break;
default:
break;

@ -16,6 +16,7 @@ import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.entity.CoreUserRole;
import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.service.CorePlatformService;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.admin.core.util.TimeTool;
import com.ibeetl.admin.core.web.JsonResult;
@ -47,6 +48,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.*;
import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
@ -140,7 +142,8 @@ public class StudentService extends CoreBaseService<Student> {
@Autowired
private StudentAccountAssetAllocationService studentAccountAssetAllocationService;
@Autowired
private CoreUserService coreUserService;
private final ExecutorService pool = Executors.newCachedThreadPool();
@Autowired
@ -493,7 +496,7 @@ public class StudentService extends CoreBaseService<Student> {
}
return null;
}
public JsonResult add(@NotNull Student student) {
public JsonResult add(@NotNull Student student) {
Date date = new Date();
@ -511,14 +514,18 @@ public class StudentService extends CoreBaseService<Student> {
// 创建系统用户并根据身份添加角色
Long createdUserId = webPlatformService.createUserWithRole(student.getStudentSn(), student.getStudentPassword(), orgId, JT_02, JT_S_03);
Student s = new Student();
s.setStudentId(student.getStudentId());
s.setUserId(createdUserId);
s.setOrgId(orgId);
CoreUser user = coreUserService.getUserById(createdUserId);
try{
//新建学生用户资金总表
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(),orgId);
//新建学生用户资金总表
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), orgId);
}catch (Exception e){
e.printStackTrace();
}
this.updateTemplate(s);

@ -1,5 +1,6 @@
package com.ibeetl.jlw.util;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@ -9,6 +10,7 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@Slf4j
public class HttpJsonRequest {
@ -30,7 +32,8 @@ public class HttpJsonRequest {
}
in.close();
} else {
System.out.println("HTTP GET request failed with response code: " + responseCode);
log.info("-----------------send接口请求失败-------"+responseCode);
throw new IllegalArgumentException("HTTP GET request failed with response code: " + responseCode);
}
} catch (Exception e) {
e.printStackTrace();

Loading…
Cancel
Save