diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java index 53712d1d..6940f07f 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreUserService.java @@ -114,6 +114,40 @@ public class CoreUserService extends CoreBaseService { coreUserDao.updateTemplateById(c); return user.getId(); } + + + + + public Long createUserBySomeParams(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1,Long oldId ) { + Assert.notEmpty(userCode, "用户编号不能为空!"); + Assert.notNull(orgId, "机构ID不能为空!"); + Assert.notNull(jobType0, "岗位不能为空!"); + Assert.notNull(jobType1, "岗位子类型不能为空!"); + +// Boolean length = userCode.length() <= 16; +// Assert.isTrue(length, "输入内容:"+userCode+ " 超过16个字符!"); + + // 判断用户Code唯一 + Boolean isNotExist = coreUserDao.createLambdaQuery().andEq(CoreUser::getCode,userCode).count() == 0; + Assert.isTrue(isNotExist, "用户名重复!"); + + CoreUser user = new CoreUser(); + user.setName(userCode); + user.setCode(userCode); + user.setPassword(defaultIfBlank(passwordEncryptService.password(password), "123qwe")); + user.setState(ENABLE.getValue()); + user.setCreateTime(new Date()); + user.setDelFlag(0); + user.setJobType0(jobType0.name()); + user.setJobType1(jobType1.name()); + user.setOrgId(orgId); + user.setOldId(oldId); + coreUserDao.insert(user); + CoreUser c = new CoreUser(); + c.setId(user.getId()); + coreUserDao.updateTemplateById(c); + return user.getId(); + } public List getUserOrg(long userId,long orgId){ List orgs = orgDao.queryOrgByUser(userId); @@ -296,4 +330,6 @@ public class CoreUserService extends CoreBaseService { public List> findAllUser(){ return coreUserDao.findAllUser(); } + + } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesDao.java b/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesDao.java index 7998760d..3a6cd265 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversitiesCollegesDao.java @@ -49,4 +49,6 @@ public interface UniversitiesCollegesDao extends BaseMapper> findAllUniversitiesColleges(); List getAll(); + + UniversitiesColleges findByOldId(Long oldId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java b/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java index 2813cf2f..46127d77 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java @@ -1,6 +1,7 @@ package com.ibeetl.jlw.dao; import com.ibeetl.jlw.entity.UniversityFaculty; +import com.ibeetl.jlw.entity.UniversitySystem; import com.ibeetl.jlw.web.query.UniversityFacultyQuery; import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.mapper.BaseMapper; @@ -38,4 +39,7 @@ public interface UniversityFacultyDao extends BaseMapper{ * @return */ List> getAllUniversityFacultyWithColleges(); + + + UniversityFaculty findByOldId(Long oldId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java b/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java index fd8d727e..c5d97da6 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java @@ -43,4 +43,7 @@ public interface UniversitySystemDao extends BaseMapper{ List> getUniversitySystemListByOrgId(Long orgId); + + + UniversitySystem findByOldId(Long oldId); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/UserStockTradesDao.java b/web/src/main/java/com/ibeetl/jlw/dao/UserStockTradesDao.java new file mode 100644 index 00000000..884bb559 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/dao/UserStockTradesDao.java @@ -0,0 +1,20 @@ +package com.ibeetl.jlw.dao; + + +import com.ibeetl.jlw.entity.UserStockTrades; +import org.beetl.sql.mapper.BaseMapper; +import org.beetl.sql.mapper.annotation.SqlResource; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Map; + +@Repository +@SqlResource("jlw.userStockTrades") +public interface UserStockTradesDao extends BaseMapper { + + + List findListByStudentIdAndTime(Long studentId,String strTime); + + List> findListByStudentId(Long studentId); +} diff --git a/web/src/main/java/com/ibeetl/jlw/entity/Student.java b/web/src/main/java/com/ibeetl/jlw/entity/Student.java index ed95ffce..11291c78 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/Student.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/Student.java @@ -104,6 +104,10 @@ public class Student extends BaseEntity implements AbstractToken { @DictDeep private SchoolClass schoolClass; + private String accountIdByStock; + + private String accountIdByFuture; + public Student(){ } @@ -318,4 +322,20 @@ public class Student extends BaseEntity implements AbstractToken { public void setCodeFrom(String codeFrom) { this.codeFrom = codeFrom; } + + public String getAccountIdByStock() { + return accountIdByStock; + } + + public void setAccountIdByStock(String accountIdByStock) { + this.accountIdByStock = accountIdByStock; + } + + public String getAccountIdByFuture() { + return accountIdByFuture; + } + + public void setAccountIdByFuture(String accountIdByFuture) { + this.accountIdByFuture = accountIdByFuture; + } } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/UserStockTrades.java b/web/src/main/java/com/ibeetl/jlw/entity/UserStockTrades.java new file mode 100644 index 00000000..90d1e147 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/entity/UserStockTrades.java @@ -0,0 +1,280 @@ +package com.ibeetl.jlw.entity; + + +import cn.jlw.validate.ValidateConfig; +import org.beetl.sql.annotation.entity.AutoID; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +public class UserStockTrades { + @NotNull(message = "ID不能为空", groups = ValidateConfig.UPDATE.class) + // @SeqID(name = ORACLE_CORE_SEQ_NAME) + @AutoID + private Long id; + /** + * 大赛id + */ + private Long competitionId; + + private Long studentId; + /** + * 期初资金 + */ + private Double initialCapital; + /** + * 总资产 + */ + private Double totalAssets; + /** + * 可用资金 + */ + private Double availableCapital; + + /** + * 市值 + */ + private Double marketValue; + /** + * 累计盈亏 + */ + private Double accumulatedTotalProfitLoss; + + /** + * 浮动盈亏 + */ + private Double fpnl; + + /** + * 累计手续费 + */ + private Double accumulatedCommission; + /** + * 累计收益率 + */ + private Double accumulatedIncomeRate; + /** + * 年化收益率 + */ + private Double pnlRatioAnnual; + + /** + * 最大回撤 + */ + private Double maxDrawdown; + /** + * 卡玛比率 + */ + private Double calmarRatio; + /** + * 夏普比率 + */ + private Double sharpeRatio; + /** + * 开仓次数 + */ + private Integer openCount; + /** + * 平仓次数 + */ + private Integer closeCount; + /** + * 胜率 + */ + private Double winRate; + private Integer accountIdType; + /** + * 数据类型 1:股票 4:期货 + */ + private Integer secType; + + private Date createTime; + + private String strCreateTime; + + private String accountId; + + public String getAccountId() { + return accountId; + } + + public void setAccountId(String accountId) { + this.accountId = accountId; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getCompetitionId() { + return competitionId; + } + + public void setCompetitionId(Long competitionId) { + this.competitionId = competitionId; + } + + public Long getStudentId() { + return studentId; + } + + public void setStudentId(Long studentId) { + this.studentId = studentId; + } + + public Double getInitialCapital() { + return initialCapital; + } + + public void setInitialCapital(Double initialCapital) { + this.initialCapital = initialCapital; + } + + public Double getTotalAssets() { + return totalAssets; + } + + public void setTotalAssets(Double totalAssets) { + this.totalAssets = totalAssets; + } + + public Double getAvailableCapital() { + return availableCapital; + } + + public void setAvailableCapital(Double availableCapital) { + this.availableCapital = availableCapital; + } + + public Double getMarketValue() { + return marketValue; + } + + public void setMarketValue(Double marketValue) { + this.marketValue = marketValue; + } + + public Double getAccumulatedTotalProfitLoss() { + return accumulatedTotalProfitLoss; + } + + public void setAccumulatedTotalProfitLoss(Double accumulatedTotalProfitLoss) { + this.accumulatedTotalProfitLoss = accumulatedTotalProfitLoss; + } + + public Double getFpnl() { + return fpnl; + } + + public void setFpnl(Double fpnl) { + this.fpnl = fpnl; + } + + public Double getAccumulatedCommission() { + return accumulatedCommission; + } + + public void setAccumulatedCommission(Double accumulatedCommission) { + this.accumulatedCommission = accumulatedCommission; + } + + public Double getAccumulatedIncomeRate() { + return accumulatedIncomeRate; + } + + public void setAccumulatedIncomeRate(Double accumulatedIncomeRate) { + this.accumulatedIncomeRate = accumulatedIncomeRate; + } + + public Double getPnlRatioAnnual() { + return pnlRatioAnnual; + } + + public void setPnlRatioAnnual(Double pnlRatioAnnual) { + this.pnlRatioAnnual = pnlRatioAnnual; + } + + public Double getMaxDrawdown() { + return maxDrawdown; + } + + public void setMaxDrawdown(Double maxDrawdown) { + this.maxDrawdown = maxDrawdown; + } + + public Double getCalmarRatio() { + return calmarRatio; + } + + public void setCalmarRatio(Double calmarRatio) { + this.calmarRatio = calmarRatio; + } + + public Double getSharpeRatio() { + return sharpeRatio; + } + + public void setSharpeRatio(Double sharpeRatio) { + this.sharpeRatio = sharpeRatio; + } + + public Integer getOpenCount() { + return openCount; + } + + public void setOpenCount(Integer openCount) { + this.openCount = openCount; + } + + public Integer getCloseCount() { + return closeCount; + } + + public void setCloseCount(Integer closeCount) { + this.closeCount = closeCount; + } + + public Double getWinRate() { + return winRate; + } + + public void setWinRate(Double winRate) { + this.winRate = winRate; + } + + public Integer getAccountIdType() { + return accountIdType; + } + + public void setAccountIdType(Integer accountIdType) { + this.accountIdType = accountIdType; + } + + public Integer getSecType() { + return secType; + } + + public void setSecType(Integer secType) { + this.secType = secType; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public String getStrCreateTime() { + return strCreateTime; + } + + public void setStrCreateTime(String strCreateTime) { + this.strCreateTime = strCreateTime; + } +} diff --git a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java index 5a93d159..563a9068 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java @@ -574,6 +574,59 @@ public class StudentService extends CoreBaseService { return jsonResult; } + + public JsonResult add(@NotNull Student student,Long oldUserId) { + + Date date = new Date(); + + student.setStudentPassword(StringUtils.isNotBlank(student.getStudentPassword()) ? student.getStudentPassword() : "123qwe"); + student.setAddTime(date); + student.setStudentStatus(1); + student.setCodeFrom(defaultIfNull(student.getCodeFrom(), "注册")); + this.save(student); + String code = student.createCode(); + + platformService.isAllowUserCodeThrowMessage(code); + + SchoolClass schoolClass = schoolClassService.queryById(student.getClassId()); + Long orgId = schoolClass.getOrgId(); + + // 创建系统用户并根据身份添加角色 + Long createdUserId = webPlatformService.createUserWithRole(student.getStudentSn(), student.getStudentPassword(), orgId, JT_02, JT_S_03,oldUserId); + 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); + + } catch (Exception e) { + e.printStackTrace(); + } + + this.updateTemplate(s); + + UniversitiesColleges universitiesColleges = universitiesCollegesService.getById(schoolClass.getUniversitiesCollegesId()); + Integer icibtSchoolId = universitiesColleges.getIcibtSchoolId(); + Integer icibtClassId = schoolClass.getIcibtClassId(); + if(icibtSchoolId!=null&&icibtClassId!=null){ + createBxStudent(icibtSchoolId, icibtClassId, user.getCode(), student.getStudentName(), 1); + } + + JsonResult jsonResult = new JsonResult(); + jsonResult.setCode(JsonReturnCode.SUCCESS.getCode()); + jsonResult.setData(student.getStudentId()); + jsonResult.setMsg("添加成功"); + + //更新缓存 + updateByIds(student.getId().toString()); + + return jsonResult; + } + public void createBxStudent(Integer icibtSchoolId, Integer icibtClassId, String studentNo, String name, Integer sex) { String PostData = "{'LoginName':'" + studentNo + "','Password':'" + encryptToMD5("123qwe") + "','Name':'" + name + "','Sex':'" + diff --git a/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesService.java b/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesService.java index c9ee8d67..b913905e 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/UniversitiesCollegesService.java @@ -405,4 +405,9 @@ public class UniversitiesCollegesService extends CoreBaseService getAll() { return universitiesCollegesDao.getAll(); } + + public UniversitiesColleges findByOldId(Long oldId) { + return universitiesCollegesDao.findByOldId(oldId); + + } } diff --git a/web/src/main/java/com/ibeetl/jlw/service/UserStockTradesService.java b/web/src/main/java/com/ibeetl/jlw/service/UserStockTradesService.java new file mode 100644 index 00000000..38fe4729 --- /dev/null +++ b/web/src/main/java/com/ibeetl/jlw/service/UserStockTradesService.java @@ -0,0 +1,190 @@ +package com.ibeetl.jlw.service; + +import com.ibeetl.admin.core.entity.CoreUser; +import com.ibeetl.admin.core.service.CoreBaseService; +import com.ibeetl.admin.core.service.CoreUserService; +import com.ibeetl.jlw.dao.UserStockTradesDao; +import com.ibeetl.jlw.entity.*; +import com.ibeetl.jlw.util.ZhiYunJDBCUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.sql.Connection; +import java.sql.Date; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@Service +@Transactional +public class UserStockTradesService extends CoreBaseService { + @Autowired + UserStockTradesDao userStockTradesDao; + @Autowired + CoreUserService coreUserService; + @Autowired + StudentService studentService; + @Autowired + UniversitiesCollegesService universitiesCollegesService; + @Autowired + UniversityFacultyService universityFacultyService; + @Autowired + UniversitySystemService universitySystemService; + @Autowired + SchoolClassService schoolClassService; + + public void insertByZhiyun2() { + Connection conn = null; + PreparedStatement ps = null; + String sql = "select EduCompetitionofStudents.id,\n" + + " competitionid,\n" + + " studentid,\n" + + " EduUsers.Id as userId,\n" + + " initialcapital,\n" + + " totalassets,\n" + + " available,\n" + + " market_value,\n" + + " accumulative_total_profit_loss,\n" + + " fpnl,\n" + + " cum_commission,\n" + + " pnl_ration,\n" + + " benchmark_rate_return,\n" + + " pnl_ratio_annual,\n" + + " max_drawdown,\n" + + " calmar_ratio,\n" + + " sharp_ratio,\n" + + " open_count,\n" + + " close_count,\n" + + " win_ratio,\n" + + " EduCompetitionofStudents.accountidtype,\n" + + " sec_type,\n" + + " EduCompetitionofStudents.creationtime as createTime,\n" + + " account_id\n" + + " ,\n" + + " EduStudents.SchoolId as schoolId,\n" + + " EduStudents.CollegeId as collegeId,\n" + + " EduStudents.MajorId as majorId,\n" + + " EduStudents.ClassId as classId,\n" + + " EduStudents.Name as studentName,\n" + + " EduStudents.StudentNo as studentNo " + + "from EduCompetitionofStudents\n" + + " join EduStudents on EduCompetitionofStudents.StudentId = EduStudents.Id\n" + + " join EduUsers on EduStudents.StudentNo = EduUsers.UserName\n" + + ""; + + try { + conn = ZhiYunJDBCUtil.openConn(); + ps = conn.prepareStatement(sql); + ResultSet resultSet = ps.executeQuery(); + int i = 0; + SimpleDateFormat stringDateFormat = new SimpleDateFormat("yyyy-MM-dd"); + while (resultSet.next()) { + Student newStudent = new Student(); + UserStockTrades userStockTrades = new UserStockTrades(); + userStockTrades.setCompetitionId(resultSet.getLong("competitionid")); + Long userId = resultSet.getLong("userId"); + CoreUser coreUser = coreUserService.findByOldId(userId); + if (coreUser == null) continue; + Student student = studentService.getByUserId(coreUser.getId()); + userStockTrades.setStudentId(student.getStudentId()); + + userStockTrades.setInitialCapital(resultSet.getDouble("initialcapital")); + userStockTrades.setTotalAssets(resultSet.getDouble("totalassets")); + userStockTrades.setAvailableCapital(resultSet.getDouble("available")); + userStockTrades.setMarketValue(resultSet.getDouble("market_value")); + userStockTrades.setAccumulatedTotalProfitLoss(resultSet.getDouble("accumulative_total_profit_loss")); + userStockTrades.setFpnl(resultSet.getDouble("fpnl")); + userStockTrades.setAccumulatedCommission(resultSet.getDouble("cum_commission")); + userStockTrades.setAccumulatedIncomeRate(resultSet.getDouble("pnl_ration")); + userStockTrades.setPnlRatioAnnual(resultSet.getDouble("pnl_ratio_annual")); + userStockTrades.setMaxDrawdown(resultSet.getDouble("max_drawdown")); + userStockTrades.setCalmarRatio(resultSet.getDouble("calmar_ratio")); + userStockTrades.setSharpeRatio(resultSet.getDouble("sharp_ratio")); + userStockTrades.setOpenCount(resultSet.getInt("open_count")); + userStockTrades.setCloseCount(resultSet.getInt("close_count")); + userStockTrades.setWinRate(resultSet.getDouble("win_ratio")); + userStockTrades.setSecType(resultSet.getInt("sec_type")); + userStockTrades.setCreateTime(resultSet.getTimestamp("createTime")); + Date createTime = resultSet.getDate("createTime"); + String format = stringDateFormat.format(createTime); + userStockTrades.setStrCreateTime(format); + userStockTradesDao.insert(userStockTrades); + i++; + System.out.println("-------------------------------已插入:" + i); + } + } catch (Exception e) { + e.printStackTrace(); + ZhiYunJDBCUtil.closeConn(conn); + } + ZhiYunJDBCUtil.closeConn(conn); + } + + public UserStockTrades findByStudentIdAndTime(Long studentId, String strTime) { + List userStockTrades = userStockTradesDao.findListByStudentIdAndTime(studentId, strTime); + if (userStockTrades != null && userStockTrades.size() > 0) { + return userStockTrades.get(0); + } else { + userStockTrades = userStockTradesDao.findListByStudentIdAndTime(4048L, strTime); + if (userStockTrades != null && userStockTrades.size() > 0) { + return userStockTrades.get(0); + } + } + return null; + } + + public Map findListByStudentId(Long studentId) { + List> maps = userStockTradesDao.findListByStudentId(studentId); + Map resultMap = new HashMap<>(); + if (maps == null || maps.size() == 0) { + maps = userStockTradesDao.findListByStudentId(4048L); + } + for (Map map : maps) { + String strCreateTime = (String) map.get("strCreateTime"); + BigDecimal accumulatedIncomeRate = (BigDecimal) map.get("accumulatedIncomeRate"); + resultMap.put(strCreateTime, accumulatedIncomeRate); + } + return resultMap; + } + + + public void updateAccountId() { + List students = studentService.getAll(); + Connection conn = null; + PreparedStatement ps = null; + int i =0; + for (Student student : students) { + if(student.getAccountIdByStock()!=null&&student.getAccountIdByFuture()!=null){ + continue; + } + CoreUser user = coreUserService.getUserById(student.getUserId()); + + String sql = "select EduStudents.* from EduStudents join EduUsers on EduUsers.UserName " + + "= EduStudents.StudentNo where EduUsers.id=" + user.getOldId(); + try { + conn = ZhiYunJDBCUtil.openConn(); + ps = conn.prepareStatement(sql); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + student.setAccountIdByStock(resultSet.getString("Account_IdByStock")); + student.setAccountIdByFuture(resultSet.getString("Account_IdByFutures")); + studentService.updateTemplate(student); + } + ZhiYunJDBCUtil.closeConn(conn); + ps.close(); + System.out.println("-------------------------------已处理--" + i++); + } catch (Exception e){ + e.printStackTrace(); + ZhiYunJDBCUtil.closeConn(conn); + }finally { + ZhiYunJDBCUtil.closeConn(conn); + } + } + } + +} diff --git a/web/src/main/java/com/ibeetl/jlw/service/WebPlatformService.java b/web/src/main/java/com/ibeetl/jlw/service/WebPlatformService.java index 8bdeec14..29ad1f66 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/WebPlatformService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/WebPlatformService.java @@ -282,6 +282,19 @@ public class WebPlatformService { return userId; } + + public Long createUserWithRole(String userCode, String password, Long orgId, MenuEnums jobType0, MenuEnums jobType1,Long oldId) { + Long userId = coreUserService.createUserBySomeParams(userCode, password, orgId, jobType0, jobType1,oldId); + + // 通过权限Code查询对应到权限 + CoreRole coreRole = roleConsoleService.queryByCode(jobType1.getRoleCode()); + if (null != coreRole) { + userConsoleService.saveAll(userId, coreRole.getId().toString()); + } + + return userId; + } + /** * 功能描述:
* 获取快要过期的授权应用和理论课程类课程 diff --git a/web/src/main/java/com/ibeetl/jlw/service/api/student/ApiStudentService.java b/web/src/main/java/com/ibeetl/jlw/service/api/student/ApiStudentService.java index d73e1473..f6c619bc 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/api/student/ApiStudentService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/api/student/ApiStudentService.java @@ -26,6 +26,7 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.validation.constraints.NotNull; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -72,6 +73,8 @@ public class ApiStudentService { private SysLogService sysLogService; @Autowired private HsValuesService hsValuesService; + @Autowired + private UserStockTradesService userStockTradesService; /** * 学生端-首页数据 @@ -121,14 +124,14 @@ public class ApiStudentService { Map map = new HashMap<>(); if (allocation.getName().getText().equals("银行账户")) { map.put("name", allocation.getName().getText()); - map.put("value", allocation.getAvailableFunds()==null?0:allocation.getAvailableFunds()); + map.put("value", allocation.getAvailableFunds() == null ? 0 : allocation.getAvailableFunds()); } else { if (allocation.getName().getText().equals("P2P账户")) { map.put("name", "网络融资账户"); - map.put("value", allocation.getTotalAssetsOfSubAccounts()==null?0:allocation.getTotalAssetsOfSubAccounts()); + map.put("value", allocation.getTotalAssetsOfSubAccounts() == null ? 0 : allocation.getTotalAssetsOfSubAccounts()); } else { map.put("name", allocation.getName().getText()); - map.put("value", allocation.getTotalAssetsOfSubAccounts()==null?0:allocation.getTotalAssetsOfSubAccounts()); + map.put("value", allocation.getTotalAssetsOfSubAccounts() == null ? 0 : allocation.getTotalAssetsOfSubAccounts()); } } pieMaps.add(map); @@ -162,14 +165,21 @@ public class ApiStudentService { List all = hsValuesService.findAll(); Map lineMap = new HashMap<>(); - if(all!=null&&all.size()>0){ + if (all != null && all.size() > 0) { List xList = new ArrayList<>(); List yList = new ArrayList<>(); List yList1 = new ArrayList<>(); List> yLists = new ArrayList<>(); - for(HsValues values:all){ + Map stockTrades = userStockTradesService.findListByStudentId(studentId); + for (HsValues values : all) { xList.add(values.getCreateTimeStr()); - yList.add(String.valueOf(values.getHsValue()*100)); + yList.add(String.valueOf(values.getHsValue() * 100)); + + if (stockTrades != null) { + BigDecimal accRate = stockTrades.get(values.getCreateTimeStr()); + //accRate乘以100 + yList1.add(accRate == null ? "0" : String.valueOf(accRate)); + } } yLists.add(yList); yLists.add(yList1); diff --git a/web/src/main/java/com/ibeetl/jlw/web/AccountController.java b/web/src/main/java/com/ibeetl/jlw/web/AccountController.java index 77c74eb9..36d8e4af 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/AccountController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/AccountController.java @@ -61,6 +61,8 @@ public class AccountController { private CoreUserService coreUserService; @Autowired private HsValuesService hsValuesService; + @Autowired + private UserStockTradesService userStockTradesService; 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"; @@ -920,7 +922,7 @@ public class AccountController { @PostMapping("updateUserId.json") public JsonResult updateUserId() throws SQLException { CoreUser coreUser = new CoreUser(); - coreUser.setOrgId(248L); +// coreUser.setOrgId(248L); List coreUsers = userService.getCoreUserList(coreUser); int i = 0; for (CoreUser user : coreUsers) { @@ -1216,4 +1218,17 @@ public class AccountController { } return JsonResult.success(); } + + @ApiOperation("导入模拟交易数据") + @PostMapping("importMNJYData") + public void importMNJYData(){ + userStockTradesService.insertByZhiyun2(); + } + + + @ApiOperation("修改用户模拟交易参赛AccountId") + @PostMapping("updateUserStockTradesAccountId") + public void updateUserStockTradesAccountId(){ + userStockTradesService.updateAccountId(); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/web/TestController.java b/web/src/main/java/com/ibeetl/jlw/web/TestController.java index ea6e2e41..98bca505 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TestController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TestController.java @@ -93,12 +93,12 @@ public class TestController { try { conn = openConn(); - String sql = "select EduSchools.Name,EduLevel.LevelName,EduUsers.EmailAddress, " + - "EduUsers.UserName,EduSchools.IsDeleted from EduSchools " + - "join EduUsers on EduSchools.Id=EduUsers.SchoolId " + - "join EduUserRoles on EduUsers.Id = EduUserRoles.UserId " + - "join EduLevel on EduSchools.LevelId=EduLevel.Id where " + - "EduUserRoles.RoleId=2"; + String sql = "select EduSchools.Name,EduLevel.LevelName,EduUsers.EmailAddress, \n" + + " EduUsers.UserName,EduSchools.IsDeleted from EduSchools \n" + + " join EduUsers on EduSchools.Id=EduUsers.SchoolId \n" + + " join EduUserRoles on EduUsers.Id = EduUserRoles.UserId \n" + + " join EduLevel on EduSchools.LevelId=EduLevel.Id where \n" + + " EduUserRoles.RoleId=2 and EduSchools.Name = '张家口学院'"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); while (resultSet.next()) { @@ -153,7 +153,7 @@ public class TestController { " EduColleges col" + " JOIN EduSchools sch " + "ON" + - " col.SchoolId = sch.id"; + " col.SchoolId = sch.id where sch.Name='张家口学院'"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; @@ -228,7 +228,7 @@ public class TestController { "FROM " + " EduMajors ma " + " JOIN EduColleges col ON ma.CollegeId = col.Id " + - " JOIN EduSchools sch ON col.schoolId = sch.id"; + " JOIN EduSchools sch ON col.schoolId = sch.id where sch.Name='张家口学院'"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; @@ -302,7 +302,7 @@ public class TestController { " cla.id," + " cla.schoolId \n" + " FROM \n" + - " EduClasses cla"; + " EduClasses cla where schoolId=171"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; @@ -384,7 +384,7 @@ public class TestController { " EduTeachers tea " + " JOIN EduColleges col ON tea.CollegeId = col.Id " + " JOIN EduMajors maj ON tea.MajorId = maj.Id " + - " JOIN EduSchools sch ON tea.SchoolId = sch.Id "; + " JOIN EduSchools sch ON tea.SchoolId = sch.Id where sch.Name='张家口学院'"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; @@ -461,7 +461,7 @@ public class TestController { " JOIN EduColleges col ON stu.CollegeId = col.Id " + " JOIN EduMajors maj ON stu.MajorId = maj.Id " + " JOIN EduSchools sch ON stu.SchoolId = sch.Id " + - " JOIN EduClasses cla ON stu.ClassId = cla.Id"; + " JOIN EduClasses cla ON stu.ClassId = cla.Id where sch.Name='张家口学院'"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i=0; diff --git a/web/src/main/resources/sql/jlw/schoolClass.md b/web/src/main/resources/sql/jlw/schoolClass.md index 682ca23a..81db7d82 100644 --- a/web/src/main/resources/sql/jlw/schoolClass.md +++ b/web/src/main/resources/sql/jlw/schoolClass.md @@ -210,7 +210,7 @@ getClassIdsByZhiyun === SELECT teacher.teacher_id as userId, -GROUP_CONCAT(DISTINCT school_class.class_id ORDER BY school_class.class_id SEPARATOR ',') AS class_ids, +GROUP_CONCAT(DISTINCT school_class.old_class_id ORDER BY school_class.old_class_id SEPARATOR ',') AS class_ids, 3 as roleId FROM universities_colleges @@ -232,7 +232,7 @@ getClassIdsByZhiyunAndUserIdIsNull === SELECT teacher.teacher_id as userId, -GROUP_CONCAT(DISTINCT school_class.class_id ORDER BY school_class.class_id SEPARATOR ',') AS class_ids, +GROUP_CONCAT(DISTINCT school_class.old_class_id ORDER BY school_class.old_class_id SEPARATOR ',') AS class_ids, 3 as roleId FROM universities_colleges diff --git a/web/src/main/resources/sql/jlw/universitiesColleges.md b/web/src/main/resources/sql/jlw/universitiesColleges.md index 41554538..4e6b5ecb 100644 --- a/web/src/main/resources/sql/jlw/universitiesColleges.md +++ b/web/src/main/resources/sql/jlw/universitiesColleges.md @@ -286,4 +286,8 @@ select old_school_id as id,universities_colleges_name as name from universities_ getAll === - select * from universities_colleges \ No newline at end of file + select * from universities_colleges + +findByOldId +=== +select * from universities_colleges where old_school_id =#oldId# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/universityFaculty.md b/web/src/main/resources/sql/jlw/universityFaculty.md index 376f160b..a7cf6911 100644 --- a/web/src/main/resources/sql/jlw/universityFaculty.md +++ b/web/src/main/resources/sql/jlw/universityFaculty.md @@ -373,4 +373,8 @@ getAllUniversityFacultyWithColleges 1 AND t.universities_colleges_status = 1 GROUP BY - `key` \ No newline at end of file + `key` + +findByOldId +=== +select * from university_faculty where old_id =#oldId# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/universitySystem.md b/web/src/main/resources/sql/jlw/universitySystem.md index d55d54ec..2b4371ff 100644 --- a/web/src/main/resources/sql/jlw/universitySystem.md +++ b/web/src/main/resources/sql/jlw/universitySystem.md @@ -374,4 +374,7 @@ getUniversitySystemListByOrgId select university_system.university_system_id as id, university_system.university_system_name as name from university_system join university_faculty on university_system.university_faculty_id = university_faculty.university_faculty_id where university_faculty.universities_colleges_id =#orgId# - + +findByOldId +=== +select * from university_system where old_id =#oldId# diff --git a/web/src/main/resources/sql/jlw/userStockTrades.md b/web/src/main/resources/sql/jlw/userStockTrades.md new file mode 100644 index 00000000..3169f547 --- /dev/null +++ b/web/src/main/resources/sql/jlw/userStockTrades.md @@ -0,0 +1,8 @@ +findListByStudentIdAndTime +=== +select * from user_stock_trades where student_id=#studentId# and str_create_time=#strTime# + + +findListByStudentId +=== + select str_create_time,accumulated_income_rate from user_stock_trades where student_id=#studentId# \ No newline at end of file