1、外部接口开放

beetlsql3-dev
陈沅 1 year ago
parent 0cd01c4cab
commit 956e4d9138

@ -5,16 +5,26 @@ import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.admin.core.web.JsonResult;
import com.ibeetl.jlw.entity.ResourcesApplication;
import com.ibeetl.jlw.entity.Student;
import com.ibeetl.jlw.entity.StudentAccountAssetAllocation;
import com.ibeetl.jlw.enums.AccountTypeEnum;
import com.ibeetl.jlw.service.ResourcesApplicationService;
import com.ibeetl.jlw.service.StudentAccountAssetAllocationService;
import com.ibeetl.jlw.service.StudentService;
import com.ibeetl.jlw.web.query.ResourcesApplicationQuery;
import com.ibeetl.jlw.web.query.StudentAccountAssetAllocationQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.beans.binding.DoubleExpression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.sql.*;
import java.util.List;
import java.util.Map;
@Api(tags = "对外开放接口")
@ -26,6 +36,43 @@ public class AccountController {
private ResourcesApplicationService resourcesApplicationService;
@Autowired
private CoreUserService userService;
@Autowired
private StudentService studentService;
@Autowired
private StudentAccountAssetAllocationService studentAccountAssetAllocationService;
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=Test.Zhiyun_v2.0;trustServerCertificate=true;encrypt=true";
private final static String USER = "sa";
private final static String PASSWORD = "sztzjy@2017";
// 打开数据库连接
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());
}
}
}
@ApiOperation("查询应用信息")
@GetMapping("findApplications")
@ -43,4 +90,94 @@ public class AccountController {
Map<String, Object> objectMap = userService.getUserByUsernameAndPwd(username, password);
return JsonResult.success(objectMap);
}
@ApiOperation("为学生账号创建基础资金表")
@PostMapping("createFund.json")
public void createFund() throws SQLException {
List<Student> students = studentService.getValues(null);
if (students != null && students.size() > 0) {
for (Student student : students) {
Connection connection = openConn();
String username = student.getStudentSn();
StudentAccountAssetAllocationQuery query = new StudentAccountAssetAllocationQuery();
query.setStudentId(student.getStudentId());
// List<StudentAccountAssetAllocation> studentAccountAssetAllocations = studentAccountAssetAllocationService.getValuesByQuery(query);
// if (studentAccountAssetAllocations != null && studentAccountAssetAllocations.size() > 0) {
// continue;
// }
String sql = "select top 100 EduUsers.UserName,EduAssetAllocation.* from EduUsers " +
"join EduAssetAllocation on EduUsers.Id = EduAssetAllocation.UserId where UserName = '" + username + "'";
PreparedStatement preparedStatement = connection.prepareStatement(sql);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery();
Integer applicationId = resultSet.getInt("ApplicationId");
String applicationName = resultSet.getString("name");
Double initialCapital = resultSet.getDouble("InitialCapital");
Double AvailableFunds = resultSet.getDouble("AvailableFunds");
String IntoAccount = resultSet.getString("IntoAccount");
Double transferInAmount = resultSet.getDouble("TransferInAmount");
Double InitialInvestmentCapital = resultSet.getDouble("InitialInvestmentCapital");
Double TransferOutAmount = resultSet.getDouble("TransferOutAmount");
Double Borrowed_Funds = resultSet.getDouble("Borrowed_Funds");
Double InvestmentFunds = resultSet.getDouble("InvestmentFunds");
Double Investment_value = resultSet.getDouble("Investment_value");
Double Investment_income = resultSet.getDouble("Investment_income");
Double Total_assets_of_subaccounts = resultSet.getDouble("Total_assets_of_subaccounts");
Double Asset_Investment = resultSet.getDouble("Asset_Investment");
Double Return_on_equity = resultSet.getDouble("Return_on_equity");
allocationQuery.setStudentId(student.getStudentId());
if (applicationId == -1) {
allocationQuery.setApplicationId(Long.valueOf(-1));
allocationQuery.setName(AccountTypeEnum.BANK_ACCOUNT);
} else if (applicationId == -2) {
allocationQuery.setApplicationId(Long.valueOf(-2));
allocationQuery.setName(AccountTypeEnum.CASH_ACCOUNT);
} else if (applicationId == 4) {
allocationQuery.setApplicationId(Long.valueOf(4));
allocationQuery.setName(AccountTypeEnum.P2P_ACCOUNT);
}else if (applicationId==5){
allocationQuery.setApplicationId(Long.valueOf(5));
allocationQuery.setName(AccountTypeEnum.CROWDFUNDING_ACCOUNT);
}else if(applicationId==16){
allocationQuery.setApplicationId(Long.valueOf(16));
allocationQuery.setName(AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT);
}else if(applicationId==-16){
allocationQuery.setApplicationId(Long.valueOf(-16));
allocationQuery.setName(AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT);
}else if(applicationId==18){
allocationQuery.setApplicationId(Long.valueOf(18));
allocationQuery.setName(AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT);
}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.setTransferinAmount(BigDecimal.valueOf(transferInAmount));
allocationQuery.setTransferOutAmount(BigDecimal.valueOf(TransferOutAmount));
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));
allocationQuery.setInvestmentIncome(BigDecimal.valueOf(Investment_income));
allocationQuery.setTotalAssetsOfSubAccounts(BigDecimal.valueOf(Total_assets_of_subaccounts));
allocationQuery.setAssetInvestment(BigDecimal.valueOf(Asset_Investment));
allocationQuery.setReturnOnEquity(BigDecimal.valueOf(Return_on_equity));
allocationQuery.setIsUpdate(1);
allocationQuery.setAmountFrozen(BigDecimal.ZERO);
allocationQuery.setUpdateVersion(Long.valueOf(-1));
allocationQuery.setIsDel(1);
allocationQuery.setIsInstitution(1);
if(allocationQuery.getName()==null)continue;
studentAccountAssetAllocationService.add(allocationQuery);
}
closeConn(connection);
}
}
}
}

Loading…
Cancel
Save