diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountCrowdfundingSystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountCrowdfundingSystemDao.java index 5cbf99d1..a2e9a27e 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountCrowdfundingSystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountCrowdfundingSystemDao.java @@ -9,6 +9,7 @@ import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.springframework.stereotype.Repository; +import java.math.BigDecimal; import java.util.List; /** @@ -21,4 +22,7 @@ public interface StudentAccountCrowdfundingSystemDao extends BaseMapper queryByCondition(PageQuery query); List getValuesByQueryNotWithPermission(StudentAccountCrowdfundingSystemQuery studentAccountCrowdfundingSystemQuery); + + + void updateByTransfer(BigDecimal availableFunds, BigDecimal initialCapital, BigDecimal initialInvestmentCapital,Long studentId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountEquityInvestmentSystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountEquityInvestmentSystemDao.java index 4c81dbf9..9c2c0fe2 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountEquityInvestmentSystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountEquityInvestmentSystemDao.java @@ -10,6 +10,7 @@ import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.springframework.stereotype.Repository; +import java.math.BigDecimal; import java.util.List; /** @@ -22,4 +23,9 @@ public interface StudentAccountEquityInvestmentSystemDao extends BaseMapper queryByCondition(PageQuery query); List getValuesByQueryNotWithPermission(StudentAccountEquityInvestmentSystemQuery studentAccountEquityInvestmentSystemQuery); + + List getValuesByQuery(StudentAccountEquityInvestmentSystemQuery studentAccountEquityInvestmentSystemQuery); + + + void updateByTransfer(BigDecimal initialCapital,BigDecimal initialInvestmentCapital,BigDecimal totalAssets,BigDecimal freeMoney,Long studentId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountMockTradingSystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountMockTradingSystemDao.java index 629343ac..db0f6c2c 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountMockTradingSystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountMockTradingSystemDao.java @@ -7,6 +7,7 @@ import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.springframework.stereotype.Repository; +import java.math.BigDecimal; import java.util.List; /** @@ -19,4 +20,9 @@ public interface StudentAccountMockTradingSystemDao extends BaseMapper queryByCondition(PageQuery query); List getValuesByQueryNotWithPermission(StudentAccountMockTradingSystemQuery studentAccountMockTradingSystemQuery); + + + void updateByTransfer(BigDecimal availableFunds, BigDecimal initialCapital, BigDecimal initialInvestmentCapital, Long studentId,Long applicationId); + + List getByStudentId(Long studentId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountP2pSystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountP2pSystemDao.java index cf9ce69d..6ab82f7a 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountP2pSystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentAccountP2pSystemDao.java @@ -7,6 +7,7 @@ import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.springframework.stereotype.Repository; +import java.math.BigDecimal; import java.util.List; /** @@ -19,4 +20,6 @@ public interface StudentAccountP2pSystemDao extends BaseMapper queryByCondition(PageQuery query); List getValuesByQueryNotWithPermission(StudentAccountP2pSystemQuery studentAccountP2pSystemQuery); + + void updateByTransfer(BigDecimal availableFunds, BigDecimal initialCapital, BigDecimal initialInvestmentCapital,Long studentId); } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountCrowdfundingSystem.java b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountCrowdfundingSystem.java index ef856251..8fb63fca 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountCrowdfundingSystem.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountCrowdfundingSystem.java @@ -7,6 +7,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 众筹系统用户资金数据表 @@ -39,40 +41,40 @@ public class StudentAccountCrowdfundingSystem extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("可用余额") - private Long availableBalance ; + private BigDecimal availableBalance ; @ApiModelProperty("资产总额") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("众筹总额") - private Long totalCrowdfunding ; + private BigDecimal totalCrowdfunding ; @ApiModelProperty("冻结总额") - private Long totalFrozen ; + private BigDecimal totalFrozen ; @ApiModelProperty("累计收益") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("自有资金投资收益率") - private Long frozenInvestmentIncome ; + private BigDecimal frozenInvestmentIncome ; @ApiModelProperty("众筹投资收益率") - private Long crowdfundingFrozenInvestmentIncome ; + private BigDecimal crowdfundingFrozenInvestmentIncome ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountEquityInvestmentSystem.java b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountEquityInvestmentSystem.java index 7d044e80..87f1b2bc 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountEquityInvestmentSystem.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountEquityInvestmentSystem.java @@ -7,6 +7,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 股权投资系统用户资金数据表 @@ -39,49 +41,52 @@ public class StudentAccountEquityInvestmentSystem extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("总募集资金") - private Long totalCollectAssets ; + private BigDecimal totalCollectAssets ; @ApiModelProperty("已投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("LP募集金额") - private Long lpCollectAssets ; + private BigDecimal lpCollectAssets ; @ApiModelProperty("LP投资金额") - private Long lpInvestmentAssets ; + private BigDecimal lpInvestmentAssets ; @ApiModelProperty("GP投资金额") - private Long glInvestmentAssets ; - + private BigDecimal glInvestmentAssets ; + @ApiModelProperty("劣后级投资金额") + private BigDecimal poorInvestmentAssets ; @ApiModelProperty("自有资金") - private Long ownFunds ; + private BigDecimal ownFunds ; @ApiModelProperty("银行借款") - private Long bankLoan ; + private BigDecimal bankLoan ; - @ApiModelProperty("投资资金") - private Long investmentAssets ; + @ApiModelProperty("银行借款投资金额") + private BigDecimal bankLoanInvestment ; @ApiModelProperty("投资收益") - private Long investmentIncome ; + private BigDecimal investmentIncome ; @ApiModelProperty("净资产投资收益率") - private Long netAssetInvestmentIncome ; + private BigDecimal netAssetInvestmentIncome ; @ApiModelProperty("总资产收益率") - private Long totalAssetsIncome ; + private BigDecimal totalAssetsIncome ; + @ApiModelProperty("自有投资资金") + private BigDecimal ownInvestmentAssets ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountMockTradingSystem.java b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountMockTradingSystem.java index 4d5d40a0..32f6b326 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountMockTradingSystem.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountMockTradingSystem.java @@ -7,6 +7,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 模拟交易系统用户资金数据表 @@ -39,43 +41,47 @@ public class StudentAccountMockTradingSystem extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("总资产") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("可用资金") - private Long availableCapital ; + private BigDecimal availableCapital ; @ApiModelProperty("市值") - private Long marketValue ; + private BigDecimal marketValue ; @ApiModelProperty("累计盈亏") - private Long cumulativeProfitAndLoss ; + private BigDecimal cumulativeProfitAndLoss ; @ApiModelProperty("累计收益率") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("年化收益率") - private Long annualRateOfIncome ; + private BigDecimal annualRateOfIncome ; @ApiModelProperty("卡玛比率") - private Long kamarRatio ; + private BigDecimal kamarRatio ; @ApiModelProperty("夏普比率") - private Long sharpeRatio ; + private BigDecimal sharpeRatio ; @ApiModelProperty("最大回测") - private Long maximumBacktest ; + private BigDecimal maximumBacktest ; + @ApiModelProperty("总资产投资收益率") + private BigDecimal totalAssetsIncome ; + @ApiModelProperty("净资产投资收益率") + private BigDecimal netAssetsIncome ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountP2pSystem.java b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountP2pSystem.java index 8db15321..f380caf1 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountP2pSystem.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/StudentAccountP2pSystem.java @@ -45,49 +45,49 @@ public class StudentAccountP2pSystem extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("可用余额") - private Long availableBalance ; + private BigDecimal availableBalance ; @ApiModelProperty("资产总额") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("借款总额") - private Long totalBorrow ; + private BigDecimal totalBorrow ; @ApiModelProperty("冻结资金") - private Long frozenFunds ; + private BigDecimal frozenFunds ; @ApiModelProperty("累计收益") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("总资产收益率") - private Long totalAssetIncome ; + private BigDecimal totalAssetIncome ; @ApiModelProperty("净资产收益率") - private Long netAssetIncome ; + private BigDecimal netAssetIncome ; @ApiModelProperty("日投资总金额") - private Long totalDailyInvestmentAmount ; + private BigDecimal totalDailyInvestmentAmount ; @ApiModelProperty("周投资总金额") - private Long totalAmountWeeklyInvestment ; + private BigDecimal totalAmountWeeklyInvestment ; @ApiModelProperty("月投资总金额") - private Long totalAmountMonthlyInvestment ; + private BigDecimal totalAmountMonthlyInvestment ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java index ca548c4a..53b48bdb 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java @@ -21,17 +21,24 @@ import com.ibeetl.jlw.enums.AccountTypeEnum; import com.ibeetl.jlw.web.query.ResourcesApplicationCourseQuery; import com.ibeetl.jlw.web.query.ResourcesApplicationQuery; import com.ibeetl.jlw.web.query.StudentAccountAssetAllocationQuery; +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.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.validation.annotation.Validated; import javax.validation.constraints.NotBlank; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.math.BigDecimal; import java.math.RoundingMode; +import java.net.HttpURLConnection; +import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.*; @@ -73,6 +80,15 @@ public class StudentAccountAssetAllocationService extends CoreBaseService queryByCondition(PageQuery query) { PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query); @@ -322,11 +338,11 @@ public class StudentAccountAssetAllocationService extends CoreBaseService= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) { + 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())){ + } else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) { //新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置 ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery(); if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) { @@ -434,11 +450,11 @@ public class StudentAccountAssetAllocationService extends CoreBaseService resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery); - if (CollectionUtil.isNotEmpty(resourcesApplicationList)){ - if (ObjectUtil.equals(item.getTypeId(),resourcesApplicationList.get(0).getResourcesApplicationId())){ + if (CollectionUtil.isNotEmpty(resourcesApplicationList)) { + if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) { accountAssetAllocation.setApplicationId(item.getTypeId()); state = 2; } @@ -469,11 +485,11 @@ public class StudentAccountAssetAllocationService extends CoreBaseService transferAccounts(Long toAccountsApplicationId, Long outAccountsApplicationId, BigDecimal money, Long studentId,CoreUser coreUser){ + public JsonResult transferAccounts(Long toAccountsApplicationId, Long outAccountsApplicationId, BigDecimal money, Long studentId, CoreUser coreUser) { - if (ObjectUtil.isEmpty(money)){ + if (ObjectUtil.isEmpty(money)) { return JsonResult.failMessage("转账金额为空"); } @@ -525,7 +542,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService outAccountsList = studentAccountAssetAllocationDao.getValuesByQuery(outAccounts); - if (CollectionUtil.isEmpty(outAccountsList)){ + if (CollectionUtil.isEmpty(outAccountsList)) { return JsonResult.failMessage("转出账号未开通"); } StudentAccountAssetAllocation outAccountAssetAllocation = outAccountsList.get(0); @@ -539,25 +556,25 @@ public class StudentAccountAssetAllocationService extends CoreBaseService toAccountsList = studentAccountAssetAllocationDao.getValuesByQuery(toAccounts); - if (CollectionUtil.isEmpty(toAccountsList)){ + if (CollectionUtil.isEmpty(toAccountsList)) { return JsonResult.failMessage("转入账号未开通"); } StudentAccountAssetAllocation toAccountAssetAllocation = toAccountsList.get(0); - if (ObjectUtil.equals(outAccountAssetAllocation.getName(),toAccountAssetAllocation.getName())){ + if (ObjectUtil.equals(outAccountAssetAllocation.getName(), toAccountAssetAllocation.getName())) { return JsonResult.failMessage("不能转入相同账户"); } - if (!ObjectUtil.equals(outAccountAssetAllocation.getName(),AccountTypeEnum.BANK_ACCOUNT) && !ObjectUtil.equals(toAccountAssetAllocation.getName(),AccountTypeEnum.BANK_ACCOUNT)){ + if (!ObjectUtil.equals(outAccountAssetAllocation.getName(), AccountTypeEnum.BANK_ACCOUNT) && !ObjectUtil.equals(toAccountAssetAllocation.getName(), AccountTypeEnum.BANK_ACCOUNT)) { return JsonResult.failMessage("只能转入银行账号"); } - if (Objects.equals(availableFunds.compareTo(BigDecimal.ZERO), 0)){ + if (Objects.equals(availableFunds.compareTo(BigDecimal.ZERO), 0)) { return JsonResult.failMessage("可用资金不足"); } - if (availableFunds.compareTo(transfer) < 0){ + if (availableFunds.compareTo(transfer) < 0) { return JsonResult.failMessage("超出可用资金总额"); } @@ -580,16 +597,116 @@ public class StudentAccountAssetAllocationService extends CoreBaseService getCapitalAccount(Long studentId){ + public List getCapitalAccount(Long studentId) { List select = studentAccountAssetAllocationDao.getSQLManager().lambdaQuery(StudentAccountAssetAllocation.class) .andEq(StudentAccountAssetAllocation::getStudentId, studentId) .andEq(StudentAccountAssetAllocation::getState, 2) @@ -683,4 +800,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService getValuesByQuery(StudentAccountEquityInvestmentSystemQuery query){ + return studentAccountEquityInvestmentSystemDao.getValuesByQuery(query); + } + + public void updateByTransfer(BigDecimal initialCapital, BigDecimal initialInvestmentCapital, BigDecimal totalAssets, BigDecimal freeMoney, Long studentId){ + studentAccountEquityInvestmentSystemDao.updateByTransfer(initialCapital,initialInvestmentCapital,totalAssets,freeMoney,studentId); + } + } diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountMockTradingSystemService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountMockTradingSystemService.java index 9f561969..31d3e1ba 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountMockTradingSystemService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountMockTradingSystemService.java @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; +import java.math.BigDecimal; import java.util.List; /** @@ -41,4 +42,24 @@ public class StudentAccountMockTradingSystemService extends CoreBaseService getByStudentId(Long studentId){ + return studentAccountMockTradingSystemDao.getByStudentId(studentId); + } + + + public void add(StudentAccountMockTradingSystem studentAccountMockTradingSystem) { + studentAccountMockTradingSystemDao.insert(studentAccountMockTradingSystem); + } + + public boolean update(StudentAccountMockTradingSystem system){ + studentAccountMockTradingSystemDao.updateTemplateById(system); + return true; + } + + + public void updateByTransfer(BigDecimal availableFunds, BigDecimal initialCapital, BigDecimal initialInvestmentCapital, Long studentId,Long applicationId) { + studentAccountMockTradingSystemDao.updateByTransfer(availableFunds,initialCapital,initialInvestmentCapital,studentId,applicationId); + + } + } diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountP2pSystemService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountP2pSystemService.java index c0b2dc7c..23afb89e 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountP2pSystemService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountP2pSystemService.java @@ -10,6 +10,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; +import java.math.BigDecimal; import java.util.List; /** @@ -25,12 +26,10 @@ public class StudentAccountP2pSystemService extends CoreBaseService> getList(StudentAccountP2pSystemQuery query) { return JsonResult.success(studentAccountP2pSystemDao.getValuesByQueryNotWithPermission(query)); } - /** * 对接智云子系统 */ @@ -41,4 +40,18 @@ public class StudentAccountP2pSystemService extends CoreBaseService 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 students = studentService.getValues(null); + if (students != null && students.size() > 0) { + for (Student student : students) { + Connection connection = openConn(); + String username = student.getStudentSn(); + List 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); + } + } + } + } + } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountCrowdfundingSystemQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountCrowdfundingSystemQuery.java index 106c9ebe..e2dd28af 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountCrowdfundingSystemQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountCrowdfundingSystemQuery.java @@ -9,6 +9,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 众筹系统用户资金数据表 @@ -41,40 +43,40 @@ public class StudentAccountCrowdfundingSystemQuery extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("可用余额") - private Long availableBalance ; + private BigDecimal availableBalance ; @ApiModelProperty("资产总额") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("众筹总额") - private Long totalCrowdfunding ; + private BigDecimal totalCrowdfunding ; @ApiModelProperty("冻结总额") - private Long totalFrozen ; + private BigDecimal totalFrozen ; @ApiModelProperty("累计收益") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("自有资金投资收益率") - private Long frozenInvestmentIncome ; + private BigDecimal frozenInvestmentIncome ; @ApiModelProperty("众筹投资收益率") - private Long crowdfundingFrozenInvestmentIncome ; + private BigDecimal crowdfundingFrozenInvestmentIncome ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountEquityInvestmentSystemQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountEquityInvestmentSystemQuery.java index 2a73fe4e..25d42807 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountEquityInvestmentSystemQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountEquityInvestmentSystemQuery.java @@ -9,6 +9,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 股权投资系统用户资金数据表 @@ -41,49 +43,52 @@ public class StudentAccountEquityInvestmentSystemQuery extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("总募集资金") - private Long totalCollectAssets ; + private BigDecimal totalCollectAssets ; @ApiModelProperty("已投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("LP募集金额") - private Long lpCollectAssets ; + private BigDecimal lpCollectAssets ; @ApiModelProperty("LP投资金额") - private Long lpInvestmentAssets ; + private BigDecimal lpInvestmentAssets ; @ApiModelProperty("GP投资金额") - private Long glInvestmentAssets ; - + private BigDecimal glInvestmentAssets ; + @ApiModelProperty("劣后级投资金额") + private BigDecimal poorInvestmentAssets ; @ApiModelProperty("自有资金") - private Long ownFunds ; + private BigDecimal ownFunds ; @ApiModelProperty("银行借款") - private Long bankLoan ; + private BigDecimal bankLoan ; - @ApiModelProperty("投资资金") - private Long investmentAssets ; + @ApiModelProperty("银行借款投资金额") + private BigDecimal bankLoanInvestment ; @ApiModelProperty("投资收益") - private Long investmentIncome ; + private BigDecimal investmentIncome ; @ApiModelProperty("净资产投资收益率") - private Long netAssetInvestmentIncome ; + private BigDecimal netAssetInvestmentIncome ; @ApiModelProperty("总资产收益率") - private Long totalAssetsIncome ; + private BigDecimal totalAssetsIncome ; + @ApiModelProperty("自有投资资金") + private BigDecimal ownInvestmentAssets ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; @@ -122,7 +127,7 @@ public class StudentAccountEquityInvestmentSystemQuery extends BaseEntity{ pojo.setGlInvestmentAssets(this.getGlInvestmentAssets()); pojo.setOwnFunds(this.getOwnFunds()); pojo.setBankLoan(this.getBankLoan()); - pojo.setInvestmentAssets(this.getInvestmentAssets()); + pojo.setBankLoanInvestment(this.getBankLoanInvestment()); pojo.setInvestmentIncome(this.getInvestmentIncome()); pojo.setNetAssetInvestmentIncome(this.getNetAssetInvestmentIncome()); pojo.setTotalAssetsIncome(this.getTotalAssetsIncome()); @@ -132,6 +137,7 @@ public class StudentAccountEquityInvestmentSystemQuery extends BaseEntity{ pojo.setIsInstitution(this.getIsInstitution()); pojo.setUserId(this.getUserId()); pojo.setOrgId(this.getOrgId()); + pojo.setPoorInvestmentAssets(this.getPoorInvestmentAssets()); return pojo; } diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountMockTradingSystemQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountMockTradingSystemQuery.java index 74d449b8..e4301880 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountMockTradingSystemQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountMockTradingSystemQuery.java @@ -9,6 +9,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * 模拟交易系统用户资金数据表 @@ -41,43 +43,43 @@ public class StudentAccountMockTradingSystemQuery extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("总资产") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("可用资金") - private Long availableCapital ; + private BigDecimal availableCapital ; @ApiModelProperty("市值") - private Long marketValue ; + private BigDecimal marketValue ; @ApiModelProperty("累计盈亏") - private Long cumulativeProfitAndLoss ; + private BigDecimal cumulativeProfitAndLoss ; @ApiModelProperty("累计收益率") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("年化收益率") - private Long annualRateOfIncome ; + private BigDecimal annualRateOfIncome ; @ApiModelProperty("卡玛比率") - private Long kamarRatio ; + private BigDecimal kamarRatio ; @ApiModelProperty("夏普比率") - private Long sharpeRatio ; + private BigDecimal sharpeRatio ; @ApiModelProperty("最大回测") - private Long maximumBacktest ; + private BigDecimal maximumBacktest ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountP2pSystemQuery.java b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountP2pSystemQuery.java index d4989cfa..8c5cae0b 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountP2pSystemQuery.java +++ b/web/src/main/java/com/ibeetl/jlw/web/query/StudentAccountP2pSystemQuery.java @@ -9,6 +9,8 @@ import lombok.Data; import org.beetl.sql.annotation.entity.AssignID; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; /* * P2P系统用户资金数据表 @@ -41,49 +43,49 @@ public class StudentAccountP2pSystemQuery extends BaseEntity{ private Long state ; @ApiModelProperty("期初资金") - private Long initialCapital ; + private BigDecimal initialCapital ; @ApiModelProperty("期初投资资金") - private Long initialInvestmentCapital ; + private BigDecimal initialInvestmentCapital ; @ApiModelProperty("可用余额") - private Long availableBalance ; + private BigDecimal availableBalance ; @ApiModelProperty("资产总额") - private Long totalAssets ; + private BigDecimal totalAssets ; @ApiModelProperty("投资总额") - private Long totalInvestment ; + private BigDecimal totalInvestment ; @ApiModelProperty("借款总额") - private Long totalBorrow ; + private BigDecimal totalBorrow ; @ApiModelProperty("冻结资金") - private Long frozenFunds ; + private BigDecimal frozenFunds ; @ApiModelProperty("累计收益") - private Long cumulativeIncome ; + private BigDecimal cumulativeIncome ; @ApiModelProperty("总资产收益率") - private Long totalAssetIncome ; + private BigDecimal totalAssetIncome ; @ApiModelProperty("净资产收益率") - private Long netAssetIncome ; + private BigDecimal netAssetIncome ; @ApiModelProperty("日投资总金额") - private Long totalDailyInvestmentAmount ; + private BigDecimal totalDailyInvestmentAmount ; @ApiModelProperty("周投资总金额") - private Long totalAmountWeeklyInvestment ; + private BigDecimal totalAmountWeeklyInvestment ; @ApiModelProperty("月投资总金额") - private Long totalAmountMonthlyInvestment ; + private BigDecimal totalAmountMonthlyInvestment ; @ApiModelProperty("'修改时间'") - private Long updateTime ; + private Date updateTime ; @ApiModelProperty("'创建时间'") - private Long createTime ; + private Date createTime ; @ApiModelProperty("是否删除 1: 正常,2: 删除") private Long isDel ; diff --git a/web/src/main/resources/sql/jlw/studentAccountCrowdfundingSystem.md b/web/src/main/resources/sql/jlw/studentAccountCrowdfundingSystem.md index eb6dc1ba..82506497 100644 --- a/web/src/main/resources/sql/jlw/studentAccountCrowdfundingSystem.md +++ b/web/src/main/resources/sql/jlw/studentAccountCrowdfundingSystem.md @@ -185,3 +185,10 @@ getValuesByQueryNotWithPermission @if(!isEmpty(orgIdPlural)){ and find_in_set(t.org_id,#orgIdPlural#) @} + + +updateByTransfer +=== + + update student_account_crowdfunding_system set available_balance = #availableFunds# +,initial_capital =#initialCapital# ,initial_investment_capital=#initialInvestmentCapital# , total_assets =#availableFunds# where student_id =#studentId# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/studentAccountEquityInvestmentSystem.md b/web/src/main/resources/sql/jlw/studentAccountEquityInvestmentSystem.md index a31f7591..4c0566dd 100644 --- a/web/src/main/resources/sql/jlw/studentAccountEquityInvestmentSystem.md +++ b/web/src/main/resources/sql/jlw/studentAccountEquityInvestmentSystem.md @@ -202,4 +202,8 @@ getValuesByQueryNotWithPermission @} @if(!isEmpty(orgIdPlural)){ and find_in_set(t.org_id,#orgIdPlural#) - @} \ No newline at end of file + @} + +updateByTransfer +==== +update student_account_equity_investment_system set initial_capital =#initialCapital# ,initial_investment_capital =#initialInvestmentCapital# ,total_assets=#initialInvestmentCapital# , own_funds = #initialInvestmentCapital# where student_id = #studentId# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/studentAccountMockTradingSystem.md b/web/src/main/resources/sql/jlw/studentAccountMockTradingSystem.md index 9a724219..4a07ba34 100644 --- a/web/src/main/resources/sql/jlw/studentAccountMockTradingSystem.md +++ b/web/src/main/resources/sql/jlw/studentAccountMockTradingSystem.md @@ -190,4 +190,15 @@ getValuesByQueryNotWithPermission @} @if(!isEmpty(orgIdPlural)){ and find_in_set(t.org_id,#orgIdPlural#) - @} \ No newline at end of file + @} + +updateByTransfer +=== + +update student_account_mock_trading_system set available_capital = #availableFunds#, +initial_capital =#initialCapital# ,initial_investment_capital=#initialInvestmentCapital# , total_assets =#availableFunds# where student_id = #studentId# and application_id=#applicationId# + + +getByStudentId +=== +select * from student_account_mock_trading_system where student_id = #studentId# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/studentAccountP2pSystem.md b/web/src/main/resources/sql/jlw/studentAccountP2pSystem.md new file mode 100644 index 00000000..c8d5ed30 --- /dev/null +++ b/web/src/main/resources/sql/jlw/studentAccountP2pSystem.md @@ -0,0 +1,5 @@ +updateByTransfer +======= +update student_account_p2p_system set available_balance = #availableFunds#, +initial_capital =#initialCapital# ,initial_investment_capital=#initialInvestmentCapital# , +total_assets = #availableFunds# where student_id = #studentId# \ No newline at end of file