|
|
|
@ -4,15 +4,12 @@ package com.ibeetl.jlw.web;
|
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreUserService;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.jlw.entity.ResourcesApplication;
|
|
|
|
|
import com.ibeetl.jlw.entity.Student;
|
|
|
|
|
import com.ibeetl.jlw.entity.StudentAccountAssetAllocation;
|
|
|
|
|
import com.ibeetl.jlw.entity.*;
|
|
|
|
|
import com.ibeetl.jlw.enums.AccountTypeEnum;
|
|
|
|
|
import com.ibeetl.jlw.service.ResourcesApplicationService;
|
|
|
|
|
import com.ibeetl.jlw.service.StudentAccountAssetAllocationService;
|
|
|
|
|
import com.ibeetl.jlw.service.StudentService;
|
|
|
|
|
import com.ibeetl.jlw.service.*;
|
|
|
|
|
import com.ibeetl.jlw.web.query.ResourcesApplicationQuery;
|
|
|
|
|
import com.ibeetl.jlw.web.query.StudentAccountAssetAllocationQuery;
|
|
|
|
|
import com.ibeetl.jlw.web.query.StudentAccountEquityInvestmentSystemQuery;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import javafx.beans.binding.DoubleExpression;
|
|
|
|
@ -40,7 +37,15 @@ public class AccountController {
|
|
|
|
|
private StudentService studentService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountAssetAllocationService studentAccountAssetAllocationService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountP2pSystemService studentAccountP2pSystemService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountCrowdfundingSystemService studentAccountCrowdfundingSystemService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private StudentAccountEquityInvestmentSystemService studentAccountEquityInvestmentSystemService;
|
|
|
|
|
|
|
|
|
|
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=Test.Zhiyun_v2.0;trustServerCertificate=true;encrypt=true";
|
|
|
|
|
private final static String USER = "sa";
|
|
|
|
@ -106,8 +111,26 @@ public class AccountController {
|
|
|
|
|
// if (studentAccountAssetAllocations != null && studentAccountAssetAllocations.size() > 0) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
String sql = "select top 100 EduUsers.UserName,EduAssetAllocation.* from EduUsers " +
|
|
|
|
|
"join EduAssetAllocation on EduUsers.Id = EduAssetAllocation.UserId where UserName = '" + username + "'";
|
|
|
|
|
String sql = "SELECT\n" +
|
|
|
|
|
" EduUsers.UserName,\n" +
|
|
|
|
|
" EduAssetAllocation.ApplicationId,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" +
|
|
|
|
|
" EduAssetAllocation.IntoAccount," +
|
|
|
|
|
" EduAssetAllocation.name,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.TransferInAmount AS DECIMAL(18, 2)) AS TransferInAmount,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.TransferOutAmount AS DECIMAL(18, 2)) AS TransferOutAmount,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Borrowed_Funds AS DECIMAL(18, 2)) AS Borrowed_Funds,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Investment_value AS DECIMAL(18, 2)) AS Investment_value,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Investment_income AS DECIMAL(18, 2)) AS Investment_income,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Total_assets_of_subaccounts AS DECIMAL(18, 2)) AS Total_assets_of_subaccounts,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Asset_Investment AS DECIMAL(18, 2)) AS Asset_Investment,\n" +
|
|
|
|
|
" CAST(EduAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity\n" +
|
|
|
|
|
"FROM EduUsers\n" +
|
|
|
|
|
"JOIN EduAssetAllocation ON EduUsers.Id = EduAssetAllocation.UserId\n" +
|
|
|
|
|
"WHERE EduUsers.UserName = '" + username + "'";
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
|
|
|
|
ResultSet resultSet = preparedStatement.executeQuery();
|
|
|
|
|
while (resultSet.next()) {
|
|
|
|
@ -137,30 +160,310 @@ public class AccountController {
|
|
|
|
|
} else if (applicationId == 4) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(4));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.P2P_ACCOUNT);
|
|
|
|
|
}else if (applicationId==5){
|
|
|
|
|
Connection connection1 = openConn();
|
|
|
|
|
String sql1 = "SELECT\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.Id,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.ApplicationId,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.The_Total_AssetsOf AS DECIMAL(18, 2)) AS The_Total_AssetsOf,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.Borrowed_Funds AS DECIMAL(18, 2)) AS Borrowed_Funds,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.Freeze_Funds AS DECIMAL(18, 2)) AS Freeze_Funds,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.Cumulative_of_return AS DECIMAL(18, 2)) AS Cumulative_of_return,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.TotalAssets_Rate_Return AS DECIMAL(18, 2)) AS TotalAssets_Rate_Return,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.TotalDailyInvestment AS DECIMAL(18, 2)) AS TotalDailyInvestment,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.TotalWeeklyInvestment AS DECIMAL(18, 2)) AS TotalWeeklyInvestment,\n" +
|
|
|
|
|
" CAST(ExaP2PAssetAllocation.TotalMonthlyInvestment AS DECIMAL(18, 2)) AS TotalMonthlyInvestment,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.UserId,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.IsDeleted,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.DeleterUserId,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.DeletionTime,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.LastModificationTime,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.LastModifierUserId,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.CreationTime,\n" +
|
|
|
|
|
" ExaP2PAssetAllocation.CreatorUserId\n" +
|
|
|
|
|
"FROM ExaP2PAssetAllocation\n" +
|
|
|
|
|
"JOIN EduUsers ON ExaP2PAssetAllocation.UserId = EduUsers.Id\n" +
|
|
|
|
|
"WHERE EduUsers.UserName = '" + username + "'";
|
|
|
|
|
PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1);
|
|
|
|
|
ResultSet resultSet1 = preparedStatement1.executeQuery();
|
|
|
|
|
while (resultSet1.next()) {
|
|
|
|
|
StudentAccountP2pSystem studentAccountP2pSystem = new StudentAccountP2pSystem();
|
|
|
|
|
BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital");
|
|
|
|
|
BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital");
|
|
|
|
|
BigDecimal The_Total_AssetsOf1 = resultSet1.getBigDecimal("The_Total_AssetsOf");
|
|
|
|
|
BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds");
|
|
|
|
|
BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds");
|
|
|
|
|
BigDecimal Borrowed_Funds1 = resultSet1.getBigDecimal("Borrowed_Funds");
|
|
|
|
|
BigDecimal Freeze_Funds1 = resultSet1.getBigDecimal("Freeze_Funds");
|
|
|
|
|
BigDecimal Cumulative_of_return1 = resultSet1.getBigDecimal("Cumulative_of_return");
|
|
|
|
|
BigDecimal TotalAssets_Rate_Return1 = resultSet1.getBigDecimal("TotalAssets_Rate_Return");
|
|
|
|
|
BigDecimal Return_on_equity1 = resultSet1.getBigDecimal("Return_on_equity");
|
|
|
|
|
BigDecimal TotalDailyInvestment1 = resultSet1.getBigDecimal("TotalDailyInvestment");
|
|
|
|
|
BigDecimal TotalWeeklyInvestment1 = resultSet1.getBigDecimal("TotalWeeklyInvestment");
|
|
|
|
|
BigDecimal TotalMonthlyInvestment1 = resultSet1.getBigDecimal("TotalMonthlyInvestment");
|
|
|
|
|
studentAccountP2pSystem.setStudentId(student.getStudentId());
|
|
|
|
|
studentAccountP2pSystem.setApplicationId(Long.valueOf(applicationId));
|
|
|
|
|
studentAccountP2pSystem.setUniversitiesCollegesId(student.getOrgId());
|
|
|
|
|
studentAccountP2pSystem.setInitialCapital(InitialCapital1);
|
|
|
|
|
studentAccountP2pSystem.setState(Long.valueOf(1));
|
|
|
|
|
studentAccountP2pSystem.setInitialInvestmentCapital(InitialInvestmentCapital1);
|
|
|
|
|
studentAccountP2pSystem.setAvailableBalance(AvailableFunds1);
|
|
|
|
|
studentAccountP2pSystem.setTotalAssets(The_Total_AssetsOf1);
|
|
|
|
|
studentAccountP2pSystem.setTotalInvestment(InvestmentFunds1);
|
|
|
|
|
studentAccountP2pSystem.setTotalBorrow(Borrowed_Funds1);
|
|
|
|
|
studentAccountP2pSystem.setFrozenFunds(Freeze_Funds1);
|
|
|
|
|
studentAccountP2pSystem.setCumulativeIncome(Cumulative_of_return1);
|
|
|
|
|
studentAccountP2pSystem.setTotalAssetIncome(TotalAssets_Rate_Return1);
|
|
|
|
|
studentAccountP2pSystem.setNetAssetIncome(Return_on_equity1);
|
|
|
|
|
studentAccountP2pSystem.setTotalDailyInvestmentAmount(TotalDailyInvestment1);
|
|
|
|
|
studentAccountP2pSystem.setTotalAmountWeeklyInvestment(TotalWeeklyInvestment1);
|
|
|
|
|
studentAccountP2pSystem.setTotalAmountMonthlyInvestment(TotalMonthlyInvestment1);
|
|
|
|
|
studentAccountP2pSystem.setIsDel(Long.valueOf(1));
|
|
|
|
|
studentAccountP2pSystem.setOrgId(student.getOrgId());
|
|
|
|
|
studentAccountP2pSystem.setIsInstitution(Long.valueOf(1));
|
|
|
|
|
studentAccountP2pSystemService.add(studentAccountP2pSystem);
|
|
|
|
|
}
|
|
|
|
|
closeConn(connection1);
|
|
|
|
|
preparedStatement1.close();
|
|
|
|
|
|
|
|
|
|
} else if (applicationId == 5) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(5));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.CROWDFUNDING_ACCOUNT);
|
|
|
|
|
}else if(applicationId==16){
|
|
|
|
|
Connection connection1 = openConn();
|
|
|
|
|
String sql1 = "SELECT\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.Id,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.ApplicationId,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.The_Total_AssetsOf AS DECIMAL(18, 2)) AS The_Total_AssetsOf,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.TheTotalAmountOfTheRaise AS DECIMAL(18, 2)) AS TheTotalAmountOfTheRaise,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.TheTotalAmountOfFrozen AS DECIMAL(18, 2)) AS TheTotalAmountOfFrozen,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.Cumulative_of_return AS DECIMAL(18, 2)) AS Cumulative_of_return,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.ReturnOnInvestmentOwnCapital AS DECIMAL(18, 2)) AS ReturnOnInvestmentOwnCapital,\n" +
|
|
|
|
|
" CAST(ExaTheRaiseAssetAllocation.ReturnOnCrowdfundingInvestment AS DECIMAL(18, 2)) AS ReturnOnCrowdfundingInvestment,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.UserId,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.IsDeleted,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.DeleterUserId,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.DeletionTime,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.LastModificationTime,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.LastModifierUserId,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.CreationTime,\n" +
|
|
|
|
|
" ExaTheRaiseAssetAllocation.CreatorUserId\n" +
|
|
|
|
|
"FROM ExaTheRaiseAssetAllocation\n" +
|
|
|
|
|
"JOIN EduUsers ON ExaTheRaiseAssetAllocation.UserId = EduUsers.Id\n" +
|
|
|
|
|
"WHERE EduUsers.UserName ='" + username + "'";
|
|
|
|
|
PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1);
|
|
|
|
|
ResultSet resultSet1 = preparedStatement1.executeQuery();
|
|
|
|
|
while (resultSet1.next()) {
|
|
|
|
|
StudentAccountCrowdfundingSystem system = new StudentAccountCrowdfundingSystem();
|
|
|
|
|
system.setStudentId(student.getStudentId());
|
|
|
|
|
system.setState(Long.valueOf(1));
|
|
|
|
|
system.setApplicationId(Long.valueOf(applicationId));
|
|
|
|
|
system.setUniversitiesCollegesId(student.getOrgId());
|
|
|
|
|
system.setIsDel(1L);
|
|
|
|
|
system.setIsInstitution(1L);
|
|
|
|
|
system.setOrgId(student.getOrgId());
|
|
|
|
|
BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital");
|
|
|
|
|
BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital");
|
|
|
|
|
BigDecimal The_Total_AssetsOf1 = resultSet1.getBigDecimal("The_Total_AssetsOf");
|
|
|
|
|
BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds");
|
|
|
|
|
BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds");
|
|
|
|
|
BigDecimal TheTotalAmountOfTheRaise1 = resultSet1.getBigDecimal("TheTotalAmountOfTheRaise");
|
|
|
|
|
BigDecimal TheTotalAmountOfFrozen1 = resultSet1.getBigDecimal("TheTotalAmountOfFrozen");
|
|
|
|
|
BigDecimal Cumulative_of_return1 = resultSet1.getBigDecimal("Cumulative_of_return");
|
|
|
|
|
BigDecimal ReturnOnInvestmentOwnCapital1 = resultSet1.getBigDecimal("ReturnOnInvestmentOwnCapital");
|
|
|
|
|
BigDecimal ReturnOnCrowdfundingInvestment1 = resultSet1.getBigDecimal("ReturnOnCrowdfundingInvestment");
|
|
|
|
|
system.setInitialCapital(InitialCapital1);
|
|
|
|
|
system.setInitialInvestmentCapital(InitialInvestmentCapital1);
|
|
|
|
|
system.setAvailableBalance(AvailableFunds1);
|
|
|
|
|
system.setTotalAssets(The_Total_AssetsOf1);
|
|
|
|
|
system.setTotalInvestment(InvestmentFunds1);
|
|
|
|
|
system.setTotalCrowdfunding(TheTotalAmountOfTheRaise1);
|
|
|
|
|
system.setTotalFrozen(TheTotalAmountOfFrozen1);
|
|
|
|
|
system.setCumulativeIncome(Cumulative_of_return1);
|
|
|
|
|
system.setFrozenInvestmentIncome(ReturnOnInvestmentOwnCapital1);
|
|
|
|
|
system.setCrowdfundingFrozenInvestmentIncome(ReturnOnCrowdfundingInvestment1);
|
|
|
|
|
|
|
|
|
|
studentAccountCrowdfundingSystemService.add(system);
|
|
|
|
|
}
|
|
|
|
|
closeConn(connection1);
|
|
|
|
|
preparedStatement1.close();
|
|
|
|
|
|
|
|
|
|
} else if (applicationId == 16) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(16));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT);
|
|
|
|
|
}else if(applicationId==-16){
|
|
|
|
|
Connection connection1 = openConn();
|
|
|
|
|
String sql1 = "SELECT\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.Id,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.ApplicationId,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.TotalAssets AS DECIMAL(18, 2)) AS TotalAssets,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Market_value AS DECIMAL(18, 2)) AS Market_value,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Accumulative_total_profit_and_loss AS DECIMAL(18, 2)) AS Accumulative_total_profit_and_loss,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Cumulative_rate_of_return AS DECIMAL(18, 2)) AS Cumulative_rate_of_return,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Annualized_rate_of_return AS DECIMAL(18, 2)) AS Annualized_rate_of_return,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Kumar_ratio AS DECIMAL(18, 2)) AS Kumar_ratio,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Sharpe_ratio AS DECIMAL(18, 2)) AS Sharpe_ratio,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.The_biggest_back_test AS DECIMAL(18, 2)) AS The_biggest_back_test,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Asset_Investment_Rate AS DECIMAL(18, 2)) AS Asset_Investment_Rate,\n" +
|
|
|
|
|
" CAST(ExaMNJYAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.UserId,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.SecType,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.IsDeleted,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.DeleterUserId,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.DeletionTime,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.LastModificationTime,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.LastModifierUserId,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.CreationTime,\n" +
|
|
|
|
|
" ExaMNJYAssetAllocation.CreatorUserId\n" +
|
|
|
|
|
"FROM ExaMNJYAssetAllocation\n" +
|
|
|
|
|
"JOIN EduUsers ON ExaMNJYAssetAllocation.UserId = EduUsers.Id\n" +
|
|
|
|
|
"WHERE EduUsers.UserName ='" + username + "'";
|
|
|
|
|
PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1);
|
|
|
|
|
ResultSet resultSet1 = preparedStatement1.executeQuery();
|
|
|
|
|
while (resultSet1.next()) {
|
|
|
|
|
StudentAccountMockTradingSystem system = new StudentAccountMockTradingSystem();
|
|
|
|
|
BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital");
|
|
|
|
|
BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital");
|
|
|
|
|
BigDecimal TotalAssets1 = resultSet1.getBigDecimal("TotalAssets");
|
|
|
|
|
BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds");
|
|
|
|
|
BigDecimal Market_value1 = resultSet1.getBigDecimal("Market_value");
|
|
|
|
|
BigDecimal Accumulative_total_profit_and_loss1 = resultSet1.getBigDecimal("Accumulative_total_profit_and_loss");
|
|
|
|
|
BigDecimal Cumulative_rate_of_return1 = resultSet1.getBigDecimal("Cumulative_rate_of_return");
|
|
|
|
|
BigDecimal Annualized_rate_of_return1 = resultSet1.getBigDecimal("Annualized_rate_of_return");
|
|
|
|
|
BigDecimal Kumar_ratio1 = resultSet1.getBigDecimal("Kumar_ratio");
|
|
|
|
|
BigDecimal Sharpe_ratio1 = resultSet1.getBigDecimal("Sharpe_ratio");
|
|
|
|
|
BigDecimal The_biggest_back_test1 = resultSet1.getBigDecimal("The_biggest_back_test");
|
|
|
|
|
BigDecimal Asset_Investment_Rate1 = resultSet1.getBigDecimal("Asset_Investment_Rate");
|
|
|
|
|
BigDecimal Return_on_equity1 = resultSet1.getBigDecimal("Return_on_equity");
|
|
|
|
|
Long applicationId1 = resultSet1.getLong("ApplicationId");
|
|
|
|
|
system.setStudentId(student.getStudentId());
|
|
|
|
|
system.setApplicationId(applicationId1);
|
|
|
|
|
system.setUniversitiesCollegesId(student.getOrgId());
|
|
|
|
|
system.setState(Long.valueOf(1));
|
|
|
|
|
system.setIsDel(1L);
|
|
|
|
|
system.setInitialCapital(InitialCapital1);
|
|
|
|
|
system.setInitialInvestmentCapital(InitialInvestmentCapital1);
|
|
|
|
|
system.setTotalAssets(TotalAssets1);
|
|
|
|
|
system.setAvailableCapital(AvailableFunds1);
|
|
|
|
|
system.setMarketValue(Market_value1);
|
|
|
|
|
system.setCumulativeProfitAndLoss(Accumulative_total_profit_and_loss1);
|
|
|
|
|
system.setCumulativeIncome(Cumulative_rate_of_return1);
|
|
|
|
|
system.setAnnualRateOfIncome(Annualized_rate_of_return1);
|
|
|
|
|
system.setKamarRatio(Kumar_ratio1);
|
|
|
|
|
system.setSharpeRatio(Sharpe_ratio1);
|
|
|
|
|
system.setMaximumBacktest(The_biggest_back_test1);
|
|
|
|
|
system.setTotalAssetsIncome(Asset_Investment_Rate1);
|
|
|
|
|
system.setNetAssetsIncome(Return_on_equity1);
|
|
|
|
|
studentAccountMockTradingSystemService.add(system);
|
|
|
|
|
}
|
|
|
|
|
closeConn(connection1);
|
|
|
|
|
preparedStatement1.close();
|
|
|
|
|
|
|
|
|
|
} else if (applicationId == -16) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(-16));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT);
|
|
|
|
|
}else if(applicationId==18){
|
|
|
|
|
|
|
|
|
|
} else if (applicationId == 18) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(18));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT);
|
|
|
|
|
}else if(applicationName.equals("外汇投资账户")){
|
|
|
|
|
|
|
|
|
|
Connection connection1 = openConn();
|
|
|
|
|
String sql1 = "SELECT\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.Id,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.ApplicationId,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.TotalAssets AS DECIMAL(18, 2)) AS TotalAssets,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.LPAmount AS DECIMAL(18, 2)) AS LPAmount,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.LPInvestmentAmount AS DECIMAL(18, 2)) AS LPInvestmentAmount,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.GPInvestmentAmount AS DECIMAL(18, 2)) AS GPInvestmentAmount,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.LhAmount AS DECIMAL(18, 2)) AS LhAmount,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.FreeMoney AS DECIMAL(18, 2)) AS FreeMoney,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.Bank_loan AS DECIMAL(18, 2)) AS Bank_loan,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.BankInvestmentFunds AS DECIMAL(18, 2)) AS BankInvestmentFunds,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.FreeInvestment_funds AS DECIMAL(18, 2)) AS FreeInvestment_funds,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.Return_On_investment AS DECIMAL(18, 2)) AS Return_On_investment,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.Return_on_net_asset_investment AS DECIMAL(18, 2)) AS Return_on_net_asset_investment,\n" +
|
|
|
|
|
" CAST(ExaPEVCAssetAllocation.Return_on_total_assets AS DECIMAL(18, 2)) AS Return_on_total_assets,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.UserId,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.IsDeleted,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.DeleterUserId,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.DeletionTime,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.LastModificationTime,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.LastModifierUserId,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.CreationTime,\n" +
|
|
|
|
|
" ExaPEVCAssetAllocation.CreatorUserId\n" +
|
|
|
|
|
"FROM ExaPEVCAssetAllocation\n" +
|
|
|
|
|
"JOIN EduUsers ON ExaPEVCAssetAllocation.UserId = EduUsers.Id\n" +
|
|
|
|
|
"WHERE EduUsers.UserName ='" + username + "'";
|
|
|
|
|
PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1);
|
|
|
|
|
|
|
|
|
|
ResultSet resultSet1 = preparedStatement1.executeQuery();
|
|
|
|
|
while (resultSet1.next()) {
|
|
|
|
|
StudentAccountEquityInvestmentSystem system = new StudentAccountEquityInvestmentSystem();
|
|
|
|
|
BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital");
|
|
|
|
|
BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital");
|
|
|
|
|
BigDecimal TotalAssets1 = resultSet1.getBigDecimal("TotalAssets");
|
|
|
|
|
BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds");
|
|
|
|
|
BigDecimal LPAmount1 = resultSet1.getBigDecimal("LPAmount");
|
|
|
|
|
BigDecimal LPInvestmentAmount1 = resultSet1.getBigDecimal("LPInvestmentAmount");
|
|
|
|
|
BigDecimal GPInvestmentAmount1 = resultSet1.getBigDecimal("GPInvestmentAmount");
|
|
|
|
|
BigDecimal LhAmount1 = resultSet1.getBigDecimal("LhAmount");
|
|
|
|
|
BigDecimal FreeMoney1 = resultSet1.getBigDecimal("FreeMoney");
|
|
|
|
|
BigDecimal Bank_loan1 = resultSet1.getBigDecimal("Bank_loan");
|
|
|
|
|
BigDecimal BankInvestmentFunds1 = resultSet1.getBigDecimal("BankInvestmentFunds");
|
|
|
|
|
BigDecimal FreeInvestment_funds1 = resultSet1.getBigDecimal("FreeInvestment_funds");
|
|
|
|
|
BigDecimal Return_On_investment1 = resultSet1.getBigDecimal("Return_On_investment");
|
|
|
|
|
BigDecimal Return_on_net_asset_investment1 = resultSet1.getBigDecimal("Return_on_net_asset_investment");
|
|
|
|
|
BigDecimal Return_on_total_assets1 = resultSet1.getBigDecimal("Return_on_total_assets");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
system.setStudentId(student.getStudentId());
|
|
|
|
|
system.setApplicationId(Long.valueOf(applicationId));
|
|
|
|
|
system.setUniversitiesCollegesId(student.getOrgId());
|
|
|
|
|
system.setState(Long.valueOf(1));
|
|
|
|
|
system.setIsDel(1L);
|
|
|
|
|
system.setInitialCapital(InitialCapital1);
|
|
|
|
|
system.setInitialInvestmentCapital(InitialInvestmentCapital1);
|
|
|
|
|
system.setTotalCollectAssets(TotalAssets1);
|
|
|
|
|
system.setTotalInvestment(InvestmentFunds1);
|
|
|
|
|
system.setLpCollectAssets(LPAmount1);
|
|
|
|
|
system.setLpInvestmentAssets(LPInvestmentAmount1);
|
|
|
|
|
system.setGlInvestmentAssets(GPInvestmentAmount1);
|
|
|
|
|
system.setOwnFunds(FreeMoney1);
|
|
|
|
|
system.setBankLoan(Bank_loan1);
|
|
|
|
|
system.setBankLoanInvestment(BankInvestmentFunds1);
|
|
|
|
|
system.setInvestmentIncome(Return_On_investment1);
|
|
|
|
|
system.setNetAssetInvestmentIncome(Return_on_net_asset_investment1);
|
|
|
|
|
system.setTotalAssetsIncome(Return_on_total_assets1);
|
|
|
|
|
system.setOwnInvestmentAssets(FreeInvestment_funds1);
|
|
|
|
|
system.setPoorInvestmentAssets(LhAmount1);
|
|
|
|
|
|
|
|
|
|
studentAccountEquityInvestmentSystemService.add(system);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (applicationName.equals("外汇投资账户")) {
|
|
|
|
|
allocationQuery.setApplicationId(Long.valueOf(113));
|
|
|
|
|
allocationQuery.setName(AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT);
|
|
|
|
|
}
|
|
|
|
|
allocationQuery.setUniversitiesCollegesId(student.getOrgId());
|
|
|
|
|
allocationQuery.setState(1);
|
|
|
|
|
allocationQuery.setInitialCapital(applicationName.equals("外汇投资账户")?new BigDecimal(1000000D):BigDecimal.valueOf(initialCapital));
|
|
|
|
|
allocationQuery.setAvailableFunds(applicationName.equals("外汇投资账户")?new BigDecimal(1000000D):BigDecimal.valueOf(AvailableFunds));
|
|
|
|
|
allocationQuery.setIntoAccount(applicationId==-1?null:AccountTypeEnum.BANK_ACCOUNT);
|
|
|
|
|
allocationQuery.setInitialCapital(applicationName.equals("外汇投资账户") ? new BigDecimal(1000000D) : BigDecimal.valueOf(initialCapital));
|
|
|
|
|
allocationQuery.setAvailableFunds(applicationName.equals("外汇投资账户") ? new BigDecimal(1000000D) : BigDecimal.valueOf(AvailableFunds));
|
|
|
|
|
allocationQuery.setIntoAccount(applicationId == -1 ? null : AccountTypeEnum.BANK_ACCOUNT);
|
|
|
|
|
allocationQuery.setTransferinAmount(BigDecimal.valueOf(transferInAmount));
|
|
|
|
|
allocationQuery.setTransferOutAmount(BigDecimal.valueOf(TransferOutAmount));
|
|
|
|
|
allocationQuery.setInitialInvestmentCapital(applicationName.equals("外汇投资账户")?new BigDecimal(1000000D):BigDecimal.valueOf(InitialInvestmentCapital));
|
|
|
|
|
allocationQuery.setInitialInvestmentCapital(applicationName.equals("外汇投资账户") ? new BigDecimal(1000000D) : BigDecimal.valueOf(InitialInvestmentCapital));
|
|
|
|
|
allocationQuery.setBorrowedFunds(BigDecimal.valueOf(Borrowed_Funds));
|
|
|
|
|
allocationQuery.setInvestmentFunds(BigDecimal.valueOf(InvestmentFunds));
|
|
|
|
|
allocationQuery.setInvestmentValue(BigDecimal.valueOf(Investment_value));
|
|
|
|
@ -173,11 +476,103 @@ public class AccountController {
|
|
|
|
|
allocationQuery.setUpdateVersion(Long.valueOf(-1));
|
|
|
|
|
allocationQuery.setIsDel(1);
|
|
|
|
|
allocationQuery.setIsInstitution(1);
|
|
|
|
|
if(allocationQuery.getName()==null)continue;
|
|
|
|
|
if (allocationQuery.getName() == null) continue;
|
|
|
|
|
studentAccountAssetAllocationService.add(allocationQuery);
|
|
|
|
|
}
|
|
|
|
|
closeConn(connection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateMnjyAccount() throws SQLException {
|
|
|
|
|
List<Student> students = studentService.getValues(null);
|
|
|
|
|
if (students != null && students.size() > 0) {
|
|
|
|
|
for (Student student : students) {
|
|
|
|
|
Connection connection = openConn();
|
|
|
|
|
String username = student.getStudentSn();
|
|
|
|
|
List<StudentAccountMockTradingSystem> valuesByQuery = studentAccountMockTradingSystemService.getByStudentId(student.getStudentId());
|
|
|
|
|
for (StudentAccountMockTradingSystem system : valuesByQuery) {
|
|
|
|
|
Integer secType = system.getApplicationId() == 16 ? 1 : 4;
|
|
|
|
|
String sql = "SELECT\n" +
|
|
|
|
|
" \n" +
|
|
|
|
|
" top 1" +
|
|
|
|
|
" CompetitionId,\n" +
|
|
|
|
|
" StudentId,\n" +
|
|
|
|
|
" CAST(InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" +
|
|
|
|
|
" CAST(TotalAssets AS DECIMAL(18, 2)) AS TotalAssets,\n" +
|
|
|
|
|
" CAST(Available AS DECIMAL(18, 2)) AS Available,\n" +
|
|
|
|
|
" CAST(Market_value AS DECIMAL(18, 2)) AS Market_value,\n" +
|
|
|
|
|
" CAST(Accumulative_total_profit_loss AS DECIMAL(18, 2)) AS Accumulative_total_profit_loss,\n" +
|
|
|
|
|
" CAST(Fpnl AS DECIMAL(18, 2)) AS Fpnl,\n" +
|
|
|
|
|
" CAST(Cum_Commission AS DECIMAL(18, 2)) AS Cum_Commission,\n" +
|
|
|
|
|
" CAST(Pnl_ration AS DECIMAL(18, 2)) AS Pnl_ration,\n" +
|
|
|
|
|
" CAST(Benchmark_rate_return AS DECIMAL(18, 2)) AS Benchmark_rate_return,\n" +
|
|
|
|
|
" CAST(Pnl_ratio_annual AS DECIMAL(18, 2)) AS Pnl_ratio_annual,\n" +
|
|
|
|
|
" CAST(Max_drawdown AS DECIMAL(18, 2)) AS Max_drawdown,\n" +
|
|
|
|
|
" CAST(Calmar_ratio AS DECIMAL(18, 2)) AS Calmar_ratio,\n" +
|
|
|
|
|
" CAST(Sharp_ratio AS DECIMAL(18, 2)) AS Sharp_ratio,\n" +
|
|
|
|
|
" Open_count,\n" +
|
|
|
|
|
" Close_count,\n" +
|
|
|
|
|
" CAST(Win_ratio AS DECIMAL(18, 2)) AS Win_ratio,\n" +
|
|
|
|
|
" Sec_Type\n" +
|
|
|
|
|
"FROM EduCompetitionofStudents\n" +
|
|
|
|
|
"JOIN EduStudents ON EduCompetitionofStudents.StudentId = EduStudents.Id\n" +
|
|
|
|
|
"WHERE EduStudents.StudentNo = '" + username + "'\n" +
|
|
|
|
|
" AND CompetitionId = 0\n" +
|
|
|
|
|
" AND Sec_Type = " + secType +
|
|
|
|
|
" ORDER BY EduCompetitionofStudents.CreationTime DESC";
|
|
|
|
|
PreparedStatement ps = connection.prepareStatement(sql);
|
|
|
|
|
ResultSet resultSet = ps.executeQuery();
|
|
|
|
|
while (resultSet.next()) {
|
|
|
|
|
|
|
|
|
|
BigDecimal initialCapital = resultSet.getBigDecimal("InitialCapital");
|
|
|
|
|
BigDecimal totalAssets = resultSet.getBigDecimal("TotalAssets");
|
|
|
|
|
BigDecimal available = resultSet.getBigDecimal("Available");
|
|
|
|
|
BigDecimal marketValue = resultSet.getBigDecimal("Market_value");
|
|
|
|
|
BigDecimal accumulativeTotalProfitLoss = resultSet.getBigDecimal("Accumulative_total_profit_loss");
|
|
|
|
|
BigDecimal fpnl = resultSet.getBigDecimal("Fpnl");
|
|
|
|
|
BigDecimal cumCommission = resultSet.getBigDecimal("Cum_Commission");
|
|
|
|
|
BigDecimal pnlRation = resultSet.getBigDecimal("Pnl_ration");
|
|
|
|
|
BigDecimal benchmarkRateReturn = resultSet.getBigDecimal("Benchmark_rate_return");
|
|
|
|
|
BigDecimal pnlRatioAnnual = resultSet.getBigDecimal("Pnl_ratio_annual");
|
|
|
|
|
BigDecimal maxDrawdown = resultSet.getBigDecimal("Max_drawdown");
|
|
|
|
|
BigDecimal calmarRatio = resultSet.getBigDecimal("Calmar_ratio");
|
|
|
|
|
BigDecimal sharpRatio = resultSet.getBigDecimal("Sharp_ratio");
|
|
|
|
|
|
|
|
|
|
system.setInitialInvestmentCapital(initialCapital);
|
|
|
|
|
system.setTotalAssets(totalAssets);
|
|
|
|
|
system.setAvailableCapital(available);
|
|
|
|
|
system.setMarketValue(marketValue);
|
|
|
|
|
system.setCumulativeProfitAndLoss(accumulativeTotalProfitLoss);
|
|
|
|
|
system.setAnnualRateOfIncome(pnlRatioAnnual);
|
|
|
|
|
system.setKamarRatio(calmarRatio);
|
|
|
|
|
system.setSharpeRatio(sharpRatio);
|
|
|
|
|
system.setMaximumBacktest(maxDrawdown);
|
|
|
|
|
if (totalAssets.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
BigDecimal totalAssetRate = accumulativeTotalProfitLoss.divide(totalAssets);
|
|
|
|
|
system.setTotalAssetsIncome(totalAssetRate);
|
|
|
|
|
system.setNetAssetsIncome(totalAssetRate);
|
|
|
|
|
} else {
|
|
|
|
|
system.setTotalAssetsIncome(BigDecimal.ZERO);
|
|
|
|
|
system.setNetAssetsIncome(BigDecimal.ZERO);
|
|
|
|
|
}
|
|
|
|
|
studentAccountMockTradingSystemService.update(system);
|
|
|
|
|
|
|
|
|
|
StudentAccountAssetAllocationQuery query = new StudentAccountAssetAllocationQuery();
|
|
|
|
|
query.setStudentId(student.getStudentId());
|
|
|
|
|
query.setApplicationId(system.getApplicationId());
|
|
|
|
|
StudentAccountAssetAllocation info = studentAccountAssetAllocationService.getInfo(query);
|
|
|
|
|
info.setAvailableFunds(available);
|
|
|
|
|
info.setInitialCapital(system.getInitialCapital());
|
|
|
|
|
info.setInitialInvestmentCapital(system.getInitialInvestmentCapital());
|
|
|
|
|
info.setInvestmentValue(marketValue);
|
|
|
|
|
info.setAssetInvestment(system.getTotalAssetsIncome());
|
|
|
|
|
info.setReturnOnEquity(system.getNetAssetsIncome());
|
|
|
|
|
studentAccountAssetAllocationService.updateTemplate(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|