From 74153569060cf79930174716c36a3110d9e1cfa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B2=85?= <907037276@qq.com> Date: Tue, 2 Jan 2024 13:53:46 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81swagger=E6=8E=A5=E5=8F=A3=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ibeetl/jlw/service/HsValuesService.java | 14 +- .../StudentAccountAssetAllocationService.java | 406 ++++++++++++------ .../ibeetl/jlw/service/StudentService.java | 17 +- .../com/ibeetl/jlw/util/HttpJsonRequest.java | 5 +- 4 files changed, 297 insertions(+), 145 deletions(-) diff --git a/web/src/main/java/com/ibeetl/jlw/service/HsValuesService.java b/web/src/main/java/com/ibeetl/jlw/service/HsValuesService.java index 645c0d5b..13594820 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/HsValuesService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/HsValuesService.java @@ -2,6 +2,7 @@ package com.ibeetl.jlw.service; import cn.hutool.core.util.IdUtil; +import cn.jlw.oldAliPay.pc.util.Stringutils; import com.ibeetl.jlw.dao.HsValuesDao; import com.ibeetl.jlw.entity.HsValues; import com.ibeetl.jlw.util.HttpJsonRequest; @@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -35,19 +37,23 @@ public class HsValuesService { // 每天早上9点执行一次任务 - @Scheduled(cron = "0 */2 * * * *") + @Scheduled(cron = "0 0 9 * * *") public void getHsValues() throws JSONException, ParseException { log.info("------------------------------------开始执行沪深300数据导入-----------------------------"); - LocalDate startTime = LocalDate.now().minusDays(5); + LocalDate startTime = LocalDate.now().minusDays(10); LocalDate endTime = LocalDate.now().plusDays(1); - String urlTwo = "https://api.myquant.cn:9001/ds-history-rpcgw/v3/data-history/benchmark-return" + String urlTwo = "https://sim.sztzjy.com/ds-history-rpcgw/v3/data-history/benchmark-return" + "?symbol=SHSE.000300&frequency=1d&startTime=" + startTime.toString() + "&endTime=" + endTime.toString() + "&adjust=0"; - String authorizationHeader = "bearer ee2c685459aa218ded58d0d7ad2ef2faf6f0d0d4"; + String authorizationHeader = "bearer 157e2484a38880effebe57c4ee95d6c29984e2f8"; String jsonResponse = HttpJsonRequest.sendGetRequest(urlTwo, authorizationHeader); + if(!StringUtils.hasText(jsonResponse)){ + log.info("------------------------------------沪深300数据获取失败-----------------------------"); + return; + } JSONArray dataArray = HttpJsonRequest.extractDataArray(jsonResponse); //循环dataArray处理数据 SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); 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 6a239c1f..cfffd7f0 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentAccountAssetAllocationService.java @@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ibeetl.admin.core.entity.CoreUser; import com.ibeetl.admin.core.service.CoreBaseService; +import com.ibeetl.admin.core.service.CoreUserService; import com.ibeetl.admin.core.util.PlatformException; import com.ibeetl.admin.core.web.JsonResult; import com.ibeetl.admin.core.web.JsonReturnCode; @@ -25,6 +26,7 @@ import com.ibeetl.jlw.web.query.StudentAccountEquityInvestmentSystemQuery; import org.apache.commons.lang3.StringUtils; import org.beetl.sql.core.SqlId; import org.beetl.sql.core.engine.PageQuery; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; @@ -40,6 +42,11 @@ import java.math.RoundingMode; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.StandardCharsets; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.text.SimpleDateFormat; import java.util.*; import static cn.hutool.core.collection.IterUtil.getFirst; @@ -89,18 +96,14 @@ public class StudentAccountAssetAllocationService extends CoreBaseService queryByCondition(PageQuery query) { PageQuery ret = studentAccountAssetAllocationDao.queryByCondition(query); queryListAfter(ret.getList()); return ret; } - - public PageQuery queryByConditionQuery(PageQuery query) { - PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query); - queryListAfter(ret.getList()); - return ret; - } + private final static String USER = "sa"; public void deleteByList(List list) { String ids = ""; @@ -293,11 +296,171 @@ public class StudentAccountAssetAllocationService extends CoreBaseService experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager() + .lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class) + .andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select(); + + StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); + allocationQuery.setOrgId(orgId); + List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); + + //获取所以的资金账号 + for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { + int state = 1; + //获取添加院校权限,对账号进行限制 + for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) { + + if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) { + //后期添加应用开发权限,新增的时候已经有应用添加了 + state = 2; + } else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) { + //新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置 + ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery(); + if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) { + resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司"); + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) { + resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司"); + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) { + resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) { + + resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司"); + + } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) { + resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财"); + } + + if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) { + List resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery); + if (CollectionUtil.isNotEmpty(resourcesApplicationList)) { + if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) { + accountAssetAllocation.setApplicationId(item.getTypeId()); + state = 2; + } + } + } + + + } + } + accountAssetAllocation.setState(state); + + if (ObjectUtil.equals(state, 2)) { + accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); + accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); + accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); + accountAssetAllocation.setUpdateTime(new Date()); + } + if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -1L) && + !ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) && + !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) { + studentAccountAssetAllocationDao.updateById(accountAssetAllocation); + } + } + } + + /** + * 激活该校的所有学生用户的股票/期货账户 + * + * @param orgId + */ + public void allOpenAccount(Long orgId) { + + StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); + allocationQuery.setOrgId(orgId); + allocationQuery.setState(1); + List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); + + for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { + accountAssetAllocation.setState(2); + accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); + accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); + accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); + accountAssetAllocation.setUpdateTime(new Date()); + studentAccountAssetAllocationDao.updateById(accountAssetAllocation); + } + } + @Autowired + private CoreUserService coreUserService; + + // 打开数据库连接 + public static Connection openConn() throws SQLException { + try { + Connection connection = DriverManager.getConnection(URL, USER, PASSWORD); + if (connection != null) { + System.out.println("成功建立数据库连接"); + return connection; + } else { + throw new SQLException("无法建立数据库连接"); + } + } catch (SQLException e) { + throw new SQLException("无法建立数据库连接: " + e.getMessage(), e); + } + } + + // 关闭数据库连接 + public static void closeConn(Connection connection) { + if (connection != null) { + try { + connection.close(); + System.out.println("数据库连接已关闭"); + } catch (SQLException e) { + System.err.println("无法关闭数据库连接: " + e.getMessage()); + } + } + } + + public PageQuery queryByConditionQuery(PageQuery query) { + + + PageQuery ret = studentAccountAssetAllocationDao.queryByConditionQuery(query); + queryListAfter(ret.getList()); + return ret; + } /** * 用户在创建的时候,紧跟着就要创建资金账户 */ - public void createFundAccountWithUserCreated(Long studentId, Long orgId) { + public void createFundAccountWithUserCreated(Long studentId, Long oldUserId, Long orgId) throws SQLException { //开设7个账户,现金账户100万,银行账户0元,其他应用的账户开设,但是未被激活,没有初始资金 AccountTypeEnum[] values = AccountTypeEnum.values(); UniversitiesColleges universitiesColleges = universitiesCollegesDao.getByOrgId(orgId); @@ -429,8 +592,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService experimentalSystems = universitiesCollegesJurisdictionExperimentalSystemDao.getSQLManager() - .lambdaQuery(UniversitiesCollegesJurisdictionExperimentalSystem.class) - .andEq(UniversitiesCollegesJurisdictionExperimentalSystem::getOrgId, orgId).select(); - - StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); - allocationQuery.setOrgId(orgId); - List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); - - //获取所以的资金账号 - for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { - int state = 1; - //获取添加院校权限,对账号进行限制 - for (UniversitiesCollegesJurisdictionExperimentalSystem item : experimentalSystems) { - - if (ObjectUtil.equals(accountAssetAllocation.getApplicationId(), item.getTypeId()) && ObjectUtil.isNotNull(item.getUseEndTime()) && DateUtil.endOfDay(item.getUseEndTime()).getTime() >= System.currentTimeMillis() && (ObjectUtil.equals(item.getUseType(), 1) || ObjectUtil.equals(item.getUseType(), 2))) { - //后期添加应用开发权限,新增的时候已经有应用添加了 - state = 2; - } else if (ObjectUtil.isEmpty(accountAssetAllocation.getApplicationId())) { - //新增学生账号,应用还没有添加,后面才添加,授权权限的时候获取应用ID设置 - ResourcesApplicationQuery resourcesApplicationQuery = new ResourcesApplicationQuery(); - if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.P2P_ACCOUNT.getText())) { - resourcesApplicationQuery.setApplicationSecondLevelRelation("P2P网络借贷公司"); - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.CROWDFUNDING_ACCOUNT.getText())) { - resourcesApplicationQuery.setApplicationSecondLevelRelation("众筹公司"); - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT.getText())) { - resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("证券交易"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("投资银行"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.EQUITY_FUND_QUANTITATIVE_TRADING_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FUTURES_QUANTITATIVE_TRADING_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("智能交易"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.BLOCKCHAIN_ASSET_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("数字资产"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.MARGIN_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("融资融券"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.INSURANCE_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("保险公司"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.SUPPLY_CHAIN_ASSET_ACCOUNT.getText())) { - - resourcesApplicationQuery.setApplicationSecondLevelRelation("供应链金融服务公司"); - - } else if (ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FINANCIAL_ACCOUNT.getText())) { - resourcesApplicationQuery.setApplicationSecondLevelRelation("智能理财"); - } - - if (ObjectUtil.isNotNull(resourcesApplicationQuery.getApplicationSecondLevelRelation())) { - List resourcesApplicationList = resourcesApplicationDao.getValuesByQuery(resourcesApplicationQuery); - if (CollectionUtil.isNotEmpty(resourcesApplicationList)) { - if (ObjectUtil.equals(item.getTypeId(), resourcesApplicationList.get(0).getResourcesApplicationId())) { - accountAssetAllocation.setApplicationId(item.getTypeId()); - state = 2; - } - } - } - - - } - } - accountAssetAllocation.setState(state); - - if (ObjectUtil.equals(state, 2)) { - accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); - accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); - accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); - accountAssetAllocation.setUpdateTime(new Date()); - } - if (!ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -1L) && - !ObjectUtil.equals(accountAssetAllocation.getApplicationId(), -2L) && - !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.OPTIONS_INVESTMENT_ACCOUNT.getText()) && - !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT.getText()) && - !ObjectUtil.equals(accountAssetAllocation.getName().getText(), AccountTypeEnum.TRUST_ACCOUNT.getText())) { - studentAccountAssetAllocationDao.updateById(accountAssetAllocation); - } + //在2.0创建基础资金账户 + public void createBaseAccount(Long applicationId, Long oldUserId, Double initialCapital) throws SQLException { + String sql = ""; + Date currentDate = new Date(); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + String formattedDate = dateFormat.format(currentDate); + if (applicationId == 4L) { + sql = "INSERT INTO [dbo].[ExaP2PAssetAllocation]( [ApplicationId], [InitialCapital], [InitialInvestmentCapital], " + + "[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " + + "[Borrowed_Funds], [Freeze_Funds], [Cumulative_of_return], [TotalAssets_Rate_Return], " + + "[Return_on_equity], [TotalDailyInvestment], [TotalWeeklyInvestment], " + + "[TotalMonthlyInvestment], [UserId], [IsDeleted], [DeleterUserId], " + + "[DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], " + + "[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, " + + "0, 0, 0, 0, " + oldUserId + ", " + + "'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")"; + } else if (applicationId == 5L) { + sql = "INSERT INTO [dbo].[ExaTheRaiseAssetAllocation]([ApplicationId], [InitialCapital], [InitialInvestmentCapital], " + + "[The_Total_AssetsOf], [AvailableFunds], [InvestmentFunds], " + + "[TheTotalAmountOfTheRaise], [TheTotalAmountOfFrozen], [Cumulative_of_return], [ReturnOnInvestmentOwnCapital], " + + "[ReturnOnCrowdfundingInvestment], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " + + "[LastModificationTime], [LastModifierUserId], [CreationTime], " + + "[CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " + + "" + oldUserId + ", '0', " + + "NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")"; + } else if (applicationId == 16L || applicationId == -16L) { + Integer secType; + secType = applicationId == 16L ? 1 : 4; + sql = "INSERT INTO [dbo].[ExaMNJYAssetAllocation]( [ApplicationId], [InitialCapital], " + + "[InitialInvestmentCapital], [TotalAssets], [AvailableFunds], [Market_value], [Accumulative_total_profit_and_loss], " + + "[Cumulative_rate_of_return], [Annualized_rate_of_return], [Kumar_ratio], [Sharpe_ratio], " + + "[The_biggest_back_test], [Asset_Investment_Rate], [Return_on_equity], [UserId], " + + "[SecType], [IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], " + + "[LastModifierUserId], [CreationTime], [CreatorUserId]) VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", " + initialCapital + ", 0, 0, 0, 0, 0, 0, " + + "0, 0, 0, " + oldUserId + ", " + secType + ", '0', NULL, NULL, '" + formattedDate + "', NULL, '" + formattedDate + "', " + oldUserId + ")"; + } else if (applicationId == 18L) { + sql = "INSERT INTO [dbo].[ExaPEVCAssetAllocation]([ApplicationId], [InitialInvestmentCapital], " + + "[InitialCapital], [TotalAssets], [InvestmentFunds], [LPAmount], [LPInvestmentAmount], " + + "[GPInvestmentAmount], [LhAmount], [FreeMoney], [Bank_loan], [BankInvestmentFunds], " + + "[FreeInvestment_funds], [Return_On_investment], [Return_on_net_asset_investment], " + + "[Return_on_total_assets], [UserId], [IsDeleted], [DeleterUserId], [DeletionTime], " + + "[LastModificationTime], [LastModifierUserId], [CreationTime], [CreatorUserId]) " + + "VALUES (" + applicationId + ", " + initialCapital + ", " + initialCapital + ", " + + initialCapital + ", 0, 0, 0, 0, 0, " + initialCapital + ", 0, 0, 0, 0, 0, 0, " + oldUserId + ", " + + "'0', NULL, NULL, NULL, NULL, '" + formattedDate + "', " + oldUserId + ")"; + sendPostRequest("http://120.79.161.177:8029/Account/InsertPevcFunding", "UserId=" + oldUserId); } + runJdbc(sql); } - /** - * 激活该校的所有学生用户的股票/期货账户 - * - * @param orgId - */ - public void allOpenAccount(Long orgId) { - - StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); - allocationQuery.setOrgId(orgId); - allocationQuery.setState(1); - List valuesByQuery = studentAccountAssetAllocationDao.getValuesByQuery(allocationQuery); - - for (StudentAccountAssetAllocation accountAssetAllocation : valuesByQuery) { - accountAssetAllocation.setState(2); - accountAssetAllocation.setInitialCapital(Objects.equals(accountAssetAllocation.getInitialCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialCapital()); - accountAssetAllocation.setAvailableFunds(Objects.equals(accountAssetAllocation.getAvailableFunds().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getAvailableFunds()); - accountAssetAllocation.setInitialInvestmentCapital(Objects.equals(accountAssetAllocation.getInitialInvestmentCapital().compareTo(BigDecimal.ZERO), 0) ? new BigDecimal(1000000) : accountAssetAllocation.getInitialInvestmentCapital()); - accountAssetAllocation.setUpdateTime(new Date()); - studentAccountAssetAllocationDao.updateById(accountAssetAllocation); - } + //运行jdbc + public void runJdbc(String sql) throws SQLException { + Connection conn = openConn(); + PreparedStatement ps = conn.prepareStatement(sql); + ps.executeUpdate(); + closeConn(conn); } - /** * 转账 * @@ -737,22 +837,30 @@ public class StudentAccountAssetAllocationService extends CoreBaseService updateAccount = studentAccountAssetAllocationDao.getValuesByQuery(updateQuery); StudentAccountAssetAllocation allocation = updateAccount.get(0); - studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(),allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), + studentAccountEquityInvestmentSystemService.updateByTransfer(allocation.getAvailableFunds(), allocation.getInitialCapital(), allocation.getInitialInvestmentCapital(), allocation.getInitialInvestmentCapital(), allocation.getInitialInvestmentCapital(), studentId); + String sql = "update ExaPEVCAssetAllocation set FreeMoney =" + allocation.getAvailableFunds() + + " where UserId = " + coreUser.getOldId() + ""; + try{ + runJdbc(sql); + }catch (Exception e){ + e.printStackTrace(); + } + } if (outAccountAssetAllocation.getApplicationId() == 4 || toAccountAssetAllocation.getApplicationId() == 4) { - updateStudentAccountByApplicationId(studentId, 4); + updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 4); } if (outAccountAssetAllocation.getApplicationId() == 5 || toAccountAssetAllocation.getApplicationId() == 5) { - updateStudentAccountByApplicationId(studentId, 5); + updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 5); } if (outAccountAssetAllocation.getApplicationId() == 16 || toAccountAssetAllocation.getApplicationId() == 16) { - updateStudentAccountByApplicationId(studentId, 16); + updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), 16); } if (outAccountAssetAllocation.getApplicationId() == -16 || toAccountAssetAllocation.getApplicationId() == -16) { - updateStudentAccountByApplicationId(studentId, -16); + updateStudentAccountByApplicationId(studentId, coreUser.getOldId(), -16); } return JsonResult.success(); @@ -760,7 +868,7 @@ public class StudentAccountAssetAllocationService extends CoreBaseService { @Autowired private StudentAccountAssetAllocationService studentAccountAssetAllocationService; - + @Autowired + private CoreUserService coreUserService; private final ExecutorService pool = Executors.newCachedThreadPool(); @Autowired @@ -493,7 +496,7 @@ public class StudentService extends CoreBaseService { } return null; } - public JsonResult add(@NotNull Student student) { + public JsonResult add(@NotNull Student student) { Date date = new Date(); @@ -511,14 +514,18 @@ public class StudentService extends CoreBaseService { // 创建系统用户并根据身份添加角色 Long createdUserId = webPlatformService.createUserWithRole(student.getStudentSn(), student.getStudentPassword(), orgId, JT_02, JT_S_03); - Student s = new Student(); s.setStudentId(student.getStudentId()); s.setUserId(createdUserId); s.setOrgId(orgId); + CoreUser user = coreUserService.getUserById(createdUserId); + try{ + //新建学生用户资金总表 + studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(),orgId); - //新建学生用户资金总表 - studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), orgId); + }catch (Exception e){ + e.printStackTrace(); + } this.updateTemplate(s); diff --git a/web/src/main/java/com/ibeetl/jlw/util/HttpJsonRequest.java b/web/src/main/java/com/ibeetl/jlw/util/HttpJsonRequest.java index 3ec3b21b..97f16edb 100644 --- a/web/src/main/java/com/ibeetl/jlw/util/HttpJsonRequest.java +++ b/web/src/main/java/com/ibeetl/jlw/util/HttpJsonRequest.java @@ -1,5 +1,6 @@ package com.ibeetl.jlw.util; +import lombok.extern.slf4j.Slf4j; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -9,6 +10,7 @@ import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +@Slf4j public class HttpJsonRequest { @@ -30,7 +32,8 @@ public class HttpJsonRequest { } in.close(); } else { - System.out.println("HTTP GET request failed with response code: " + responseCode); + log.info("-----------------send接口请求失败:-------"+responseCode); + throw new IllegalArgumentException("HTTP GET request failed with response code: " + responseCode); } } catch (Exception e) { e.printStackTrace();