1、swagger接口文档

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

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

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

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

@ -1,5 +1,6 @@
package com.ibeetl.jlw.util; package com.ibeetl.jlw.util;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -9,6 +10,7 @@ import java.io.InputStreamReader;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
@Slf4j
public class HttpJsonRequest { public class HttpJsonRequest {
@ -30,7 +32,8 @@ public class HttpJsonRequest {
} }
in.close(); in.close();
} else { } 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) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();

Loading…
Cancel
Save