From c13a10087c8fc93478e3a5f0fc4580d32cf838f1 Mon Sep 17 00:00:00 2001 From: chenyuan <907037276@qq.com> Date: Thu, 21 Mar 2024 16:14:50 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ibeetl/admin/core/dao/CoreUserDao.java | 8 + .../admin/core/service/CoreBaseService.java | 1 + .../admin/core/service/CoreUserService.java | 10 +- .../src/main/resources/sql/core/coreUser.md | 30 +- .../java/com/ibeetl/jlw/dao/StudentDao.java | 4 + .../java/com/ibeetl/jlw/dao/TeacherDao.java | 6 + .../ibeetl/jlw/dao/UniversityFacultyDao.java | 2 + .../ibeetl/jlw/dao/UniversitySystemDao.java | 2 + .../java/com/ibeetl/jlw/entity/Student.java | 9 + .../ibeetl/jlw/service/StudentService.java | 24 +- .../ibeetl/jlw/service/TeacherService.java | 18 +- .../jlw/service/UniversityFacultyService.java | 10 + .../jlw/service/UniversitySystemService.java | 10 + .../com/ibeetl/jlw/web/AccountController.java | 70 +- .../com/ibeetl/jlw/web/TestController.java | 925 ++++++++++++++++-- .../main/resources/application-dev.properties | 8 +- web/src/main/resources/sql/jlw/schoolClass.md | 2 +- web/src/main/resources/sql/jlw/student.md | 10 +- web/src/main/resources/sql/jlw/teacher.md | 12 + .../resources/sql/jlw/universityFaculty.md | 6 +- .../resources/sql/jlw/universitySystem.md | 4 + 21 files changed, 1092 insertions(+), 79 deletions(-) diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreUserDao.java b/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreUserDao.java index 7c8ee00d..86c37708 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreUserDao.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/dao/CoreUserDao.java @@ -3,8 +3,10 @@ package com.ibeetl.admin.core.dao; import com.ibeetl.admin.core.entity.CoreUser; import com.ibeetl.admin.core.web.query.CustomFilterByLcUser; import org.apache.commons.logging.Log; +import org.beetl.sql.core.SQLManager; import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Repository; import java.util.Date; @@ -76,4 +78,10 @@ public interface CoreUserDao extends BaseMapper { String keyword, String keyword2 ); + + List findBySchoolId(Long schoolId); + + List findAll(); + + void deleteById1(Long userId); } diff --git a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java index c5a70f11..033e0bde 100644 --- a/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java +++ b/admin-core/src/main/java/com/ibeetl/admin/core/service/CoreBaseService.java @@ -250,6 +250,7 @@ public class CoreBaseService extends CoreBaseAnnotationParser { return ret == 1; } + /** * 根据id删除数据 * 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 ff3bccc5..fcb5bc36 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 @@ -396,7 +396,15 @@ public class CoreUserService extends CoreBaseService { , customFilter.getKeyword2()); } + public List findBySchoolId(Long schoolId) { + return coreUserDao.findBySchoolId(schoolId); + } + public List findAll() { + return coreUserDao.findAll(); + } - + public void deleteById1(Long userId) { + sqlManager.deleteById(CoreUser.class, userId); + } } diff --git a/admin-core/src/main/resources/sql/core/coreUser.md b/admin-core/src/main/resources/sql/core/coreUser.md index c8ea161b..06116296 100644 --- a/admin-core/src/main/resources/sql/core/coreUser.md +++ b/admin-core/src/main/resources/sql/core/coreUser.md @@ -39,7 +39,7 @@ getStudentByNo === SELECT core_user.old_id AS userId, - core_user.NAME AS NAME, + student.student_name AS NAME, core_role.NAME AS roleName, universities_colleges.universities_colleges_id AS schoolId, school_class.class_id AS classId, @@ -49,7 +49,7 @@ getStudentByNo universities_colleges.universities_colleges_name AS schoolName, university_faculty.university_faculty_id AS collegeId, university_faculty.university_faculty_name AS collegeName, - student.student_id AS studentId + student.old_id AS studentId FROM core_user JOIN student ON core_user.CODE = student.student_sn @@ -69,6 +69,9 @@ getStudentByNoOfNet core_user.old_id AS userId, core_user.NAME AS NAME, core_role.NAME AS roleName, + core_user.CODE as username, + 4 as roleId, + student.student_sn as studentNo, universities_colleges.old_school_id AS schoolId, school_class.old_class_id AS classId, university_system.university_system_id AS majorId, @@ -77,7 +80,7 @@ getStudentByNoOfNet universities_colleges.universities_colleges_name AS schoolName, university_faculty.university_faculty_id AS collegeId, university_faculty.university_faculty_name AS collegeName, - student.student_id AS studentId + student.old_id AS studentId FROM core_user JOIN student ON core_user.CODE = student.student_sn @@ -95,7 +98,7 @@ getTeacherByNo === SELECT core_user.old_id AS userId, - core_user.NAME AS NAME, + teacher.teacher_name AS NAME, core_role.NAME AS roleName, universities_colleges.universities_colleges_id AS schoolId, university_system.university_system_id AS majorId, @@ -103,7 +106,7 @@ getTeacherByNo universities_colleges.universities_colleges_name AS schoolName, university_faculty.university_faculty_id AS collegeId, university_faculty.university_faculty_name AS collegeName, - teacher.teacher_id AS teacherId + teacher.old_id AS teacherId FROM core_user JOIN teacher ON core_user.CODE = teacher.teacher_job_number @@ -122,6 +125,7 @@ getTeacherByNoOfNet core_user.old_id AS userId, core_user.NAME AS NAME, core_role.NAME AS roleName, + 3 as roleId, universities_colleges.old_school_id AS schoolId, university_system.university_system_id AS majorId, university_system.university_system_name AS majorName, @@ -231,4 +235,18 @@ and (cu.name like #"%"+keyword+"%"# or cu.code like #"%"+keyword+"%"#) @if(!isEmpty(keyword2)){ and (cu.code like #"%"+keyword+"%"#) @} -order by cu.CREATE_TIME \ No newline at end of file +order by cu.CREATE_TIME + + + +findBySchoolId +=== + select * from core_user where org_id = #schoolId# + +findAll +=== + select * from core_user + +deleteById1 +=== +delete from core_user where ID = #userId# \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java b/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java index ad425b59..4efdf4ea 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/StudentDao.java @@ -133,4 +133,8 @@ public interface StudentDao extends BaseMapper{ List findStudentNoByClassId(Long classId); List> findAllStudent(); + + Student getByOldId(Long oldId); + + Student getStudentByStudentNo(String studentNo); } \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherDao.java index b75c58f2..3953a463 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherDao.java @@ -60,4 +60,10 @@ public interface TeacherDao extends BaseMapper{ List getByTeacherJobNameAndOrgId(String teacherJobName, Long orgId); List> userClassDalGetList(); + + Teacher getByOldId(Long oldId); + + Teacher getByTeacherSn(String teacherSn); + + void deleteById1(Long teacherId); } \ No newline at end of file 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 46127d77..aa627060 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversityFacultyDao.java @@ -42,4 +42,6 @@ public interface UniversityFacultyDao extends BaseMapper{ UniversityFaculty findByOldId(Long oldId); + + List findAll(); } 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 c5d97da6..3e482e36 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/UniversitySystemDao.java @@ -46,4 +46,6 @@ public interface UniversitySystemDao extends BaseMapper{ UniversitySystem findByOldId(Long oldId); + + List findAll(); } 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 11291c78..6b98b029 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/Student.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/Student.java @@ -108,6 +108,7 @@ public class Student extends BaseEntity implements AbstractToken { private String accountIdByFuture; + private Long oldId; public Student(){ } @@ -338,4 +339,12 @@ public class Student extends BaseEntity implements AbstractToken { public void setAccountIdByFuture(String accountIdByFuture) { this.accountIdByFuture = accountIdByFuture; } + + public Long getOldId() { + return oldId; + } + + public void setOldId(Long oldId) { + this.oldId = oldId; + } } 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 563a9068..05485ae4 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/StudentService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/StudentService.java @@ -522,6 +522,11 @@ public class StudentService extends CoreBaseService { return null; } + public Student getStudentByStudentNo(String studentNo) { + return studentDao.getStudentByStudentNo(studentNo); + } + + public JsonResult add(@NotNull Student student) { Date date = new Date(); @@ -544,7 +549,7 @@ public class StudentService extends CoreBaseService { s.setStudentId(student.getStudentId()); s.setUserId(createdUserId); s.setOrgId(orgId); - + s.setOldId(student.getStudentId()+80000); CoreUser user = coreUserService.getUserById(createdUserId); try { //新建学生用户资金总表 @@ -597,11 +602,13 @@ public class StudentService extends CoreBaseService { s.setStudentId(student.getStudentId()); s.setUserId(createdUserId); s.setOrgId(orgId); - + if(student.getOldId()==null){ + s.setOldId(student.getStudentId()+80000); + } CoreUser user = coreUserService.getUserById(createdUserId); try { //新建学生用户资金总表 - studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(), orgId); +// studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(), orgId); } catch (Exception e) { e.printStackTrace(); @@ -846,7 +853,7 @@ public class StudentService extends CoreBaseService { s.setStudentSn(studentSn); s.setUserId(coreUser.getId()); s.setOrgId(schoolClass.get(0).getOrgId()); - + s.setOldId(s.getStudentId()+80000); this.updateTemplate(s); if (list.size() == 0) { @@ -1776,4 +1783,13 @@ public class StudentService extends CoreBaseService { public List> findAllStudent() { return studentDao.findAllStudent(); } + + public Student getByOldId(Long oldId) { + return studentDao.getByOldId(oldId); + } + + + public void deleteById1(Long studentId) { + sqlManager.deleteById(Student.class, studentId); + } } \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherService.java index 1339c231..7d96e99b 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherService.java @@ -34,6 +34,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.beetl.sql.core.SQLManager; import org.beetl.sql.core.SqlId; import org.beetl.sql.core.engine.PageQuery; import org.beetl.sql.core.query.LambdaQuery; @@ -74,6 +75,9 @@ import static com.ibeetl.jlw.web.IpAddressController.ipAddressMap; @Transactional public class TeacherService extends CoreBaseService { + @Autowired + protected SQLManager sqlManager; + @Autowired private TeacherDao teacherDao; @@ -300,7 +304,7 @@ public class TeacherService extends CoreBaseService { t.setTeacherId(teacher.getTeacherId()); t.setUserId(createdUserId); t.setOrgId(orgId); - t.setOldId(5000L + teacher.getTeacherId()); + t.setOldId(teacher.getOldId()==null?5000L + teacher.getTeacherId():teacher.getOldId()); Integer icibtSchoolId = universitiesColleges.getIcibtSchoolId(); if (icibtSchoolId != null) { @@ -916,4 +920,16 @@ public class TeacherService extends CoreBaseService { return teacherDao.userClassDalGetList(); } + + public Teacher getByOldId(Long oldId){ + return teacherDao.getByOldId(oldId); + } + + public Teacher getByTeacherSn(String teacherSn){ + return teacherDao.getByTeacherSn(teacherSn); + } + //物理删除教师 + public void deleteById1(Long teacherId){ + sqlManager.deleteById(Teacher.class, teacherId); + } } \ No newline at end of file diff --git a/web/src/main/java/com/ibeetl/jlw/service/UniversityFacultyService.java b/web/src/main/java/com/ibeetl/jlw/service/UniversityFacultyService.java index b37f073c..ee2b0ec0 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/UniversityFacultyService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/UniversityFacultyService.java @@ -107,6 +107,12 @@ public class UniversityFacultyService extends CoreBaseService universityFaculty.setUniversityFacultyAddTime(new Date()); universityFaculty.setUniversityFacultyStatus(1); universityFacultyDao.insert(universityFaculty); + UniversityFaculty faculty = new UniversityFaculty(); + faculty.setUniversityFacultyId(universityFaculty.getUniversityFacultyId()); + if(universityFaculty.getOldId()==null){ + faculty.setOldId(universityFaculty.getUniversityFacultyId()+500); + universityFacultyDao.updateTemplateById(faculty); + } universityFacultyQuery.setUniversityFacultyId(universityFaculty.getUniversityFacultyId()); JsonResult jsonResult = new JsonResult(); jsonResult.setData(universityFaculty.getUniversityFacultyId());//自增的ID丢进去 @@ -252,4 +258,8 @@ public class UniversityFacultyService extends CoreBaseService query.setUniversityFacultyId(id); return getFirst(getValuesByQueryNotWithPermission(query)); } + + public List findAll(){ + return universityFacultyDao.findAll(); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/service/UniversitySystemService.java b/web/src/main/java/com/ibeetl/jlw/service/UniversitySystemService.java index 455e6c9b..c154d56b 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/UniversitySystemService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/UniversitySystemService.java @@ -104,6 +104,12 @@ public class UniversitySystemService extends CoreBaseService{ universitySystem.setUniversitySystemAddTime(new Date()); universitySystem.setUniversitySystemStatus(1); universitySystemDao.insert(universitySystem); + UniversitySystem u = new UniversitySystem(); + u.setUniversitySystemId(universitySystem.getUniversitySystemId()); + if(universitySystem.getOldId()==null){ + u.setOldId(universitySystem.getUniversitySystemId()+500); + universitySystemDao.updateTemplateById(u); + } universitySystemQuery.setUniversitySystemId(universitySystem.getUniversitySystemId()); JsonResult jsonResult = new JsonResult(); jsonResult.setData(universitySystem.getUniversitySystemId());//自增的ID丢进去 @@ -269,4 +275,8 @@ public class UniversitySystemService extends CoreBaseService{ query.setUniversitySystemId(id); return getFirst(universitySystemDao.getValuesByQueryNotWithPermission(query)); } + + public List findAll(){ + return universitySystemDao.findAll(); + } } 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 7eff1aff..9dd1f58a 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/AccountController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/AccountController.java @@ -180,7 +180,7 @@ public class AccountController { " CAST(EduAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity\n" + "FROM EduUsers\n" + "JOIN EduAssetAllocation ON EduUsers.Id = EduAssetAllocation.UserId\n" + - "WHERE EduUsers.UserName = '" + username + "'"; + "WHERE EduUsers.Id = '" + username + "'"; PreparedStatement preparedStatement = connection.prepareStatement(sql); ResultSet resultSet = preparedStatement.executeQuery(); while (resultSet.next()) { @@ -1276,8 +1276,74 @@ public class AccountController { @ApiOperation("理财系统userclassDAL.GetClassListById接口") @GetMapping("userClassDalGetClassListById.json") - public JsonResult userClassDalGetClassListById(){ + public JsonResult userClassDalGetClassListById() { return JsonResult.success(schoolClassService.userClassDalGetClassListById()); } + @ApiOperation("修改学生oldId") + @PostMapping("updateStudentOldId.json") + public void updateStudentOldId() throws SQLException { + List students = studentService.getAll(); + if (students != null && students.size() > 0) { + int i = 0; + for (Student student : students) { + if (student.getOldId() != null) continue; + System.out.println(i++); + Connection connection = openConn(); + String studentSn = student.getStudentSn(); + String sql = "select * from EduStudents where StudentNo = '" + studentSn + "'"; + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + + Long oldId = rs.getLong("Id"); + if (oldId > 0) { + student.setOldId(oldId); + + } + + + } + if (student.getOldId() == null) { + student.setOldId(80000 + student.getStudentId()); + } + studentService.updateTemplate(student); + connection.close(); + ps.close(); + rs.close(); + } + } + } + + + @ApiOperation("修改班级oldid") + @PostMapping("updateClassOldId.json") + public JsonResult updateClassOldId() throws SQLException { + List schoolClasses = schoolClassService.getAll(); + if (schoolClasses != null && schoolClasses.size() > 0) { + for (SchoolClass schoolClass : schoolClasses) { + Connection connection = openConn(); + String sql = "select * from EduClasses where Name = '" + schoolClass.getClassName() + "'"; + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("Id"); + if (oldId > 0) { + schoolClass.setOldClassId(oldId); + } + } + if (oldId == 0) { + oldId = schoolClass.getClassId() + 1500; + schoolClass.setOldClassId(oldId); + } + schoolClassService.updateTemplate(schoolClass); + connection.close(); + ps.close(); + rs.close(); + } + } + return JsonResult.success(); + } + } 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 8d2bdbec..646c75e3 100644 --- a/web/src/main/java/com/ibeetl/jlw/web/TestController.java +++ b/web/src/main/java/com/ibeetl/jlw/web/TestController.java @@ -11,13 +11,11 @@ import com.ibeetl.admin.core.service.CorePlatformService; import com.ibeetl.admin.core.service.CoreUserService; import com.ibeetl.jlw.entity.*; import com.ibeetl.jlw.entity.dto.CreateUserDTO; +import com.ibeetl.jlw.enums.AccountTypeEnum; import com.ibeetl.jlw.enums.GenderEnum; import com.ibeetl.jlw.service.*; import com.ibeetl.jlw.util.ZhiYunJDBCUtil; -import com.ibeetl.jlw.web.query.SchoolClassQuery; -import com.ibeetl.jlw.web.query.UniversitiesCollegesJurisdictionExperimentalSystemQuery; -import com.ibeetl.jlw.web.query.UniversityFacultyQuery; -import com.ibeetl.jlw.web.query.UniversitySystemQuery; +import com.ibeetl.jlw.web.query.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.regexp.RE; @@ -27,10 +25,15 @@ 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.text.SimpleDateFormat; import java.util.*; import java.util.Date; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; @Api(tags = "数据迁移") @RestController @@ -55,7 +58,18 @@ public class TestController { private ResourcesApplicationService resourcesApplicationService; @Autowired private UniversitiesCollegesJurisdictionExperimentalSystemService universitiesCollegesJurisdictionExperimentalSystemService; + @Autowired + private StudentAccountAssetAllocationService studentAccountAssetAllocationService; + + @Autowired + private StudentAccountP2pSystemService studentAccountP2pSystemService; + @Autowired + private StudentAccountCrowdfundingSystemService studentAccountCrowdfundingSystemService; + @Autowired + private StudentAccountMockTradingSystemService studentAccountMockTradingSystemService; + @Autowired + private StudentAccountEquityInvestmentSystemService studentAccountEquityInvestmentSystemService; 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"; @@ -102,11 +116,13 @@ public class TestController { " 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 = '西安明德理工学院'"; + " EduUserRoles.RoleId=2 "; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); while (resultSet.next()) { - + Long oldId = resultSet.getLong("id"); + UniversitiesColleges colleges = universitiesCollegesService.findByOldId(oldId); + if (colleges != null) continue; String schoolName = resultSet.getString(1); UniversitiesColleges collegesServiceByName = universitiesCollegesService.getByName(schoolName); if (collegesServiceByName != null) continue; @@ -124,6 +140,7 @@ public class TestController { universitiesColleges.setIcibtSchoolId(resultSet.getInt("icibtSchoolId")); universitiesColleges.setAddTime(new Date()); universitiesColleges.setUniversitiesCollegesStatus(1); + universitiesColleges.setOldSchoolId(resultSet.getLong("id")); createUserDTO.setUserCode(resultSet.getString(4)); createUserDTO.setPassword("123qwe"); universitiesCollegesService.addAndCreateCoreUser(universitiesColleges, createUserDTO); @@ -153,23 +170,27 @@ public class TestController { " col.Contacts," + " col.PhoneNo," + " col.Address," + - " col.IsDeleted" + + " col.IsDeleted,sch.id as schoolId " + " " + "FROM " + " EduColleges col" + " JOIN EduSchools sch " + "ON" + - " col.SchoolId = sch.id where sch.Name='西安明德理工学院'"; + " col.SchoolId = sch.id "; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; while (resultSet.next()) { + Long oldId = resultSet.getLong("collegeId"); + UniversityFaculty faculty = universityFacultyService.getByOldId(oldId); + if (faculty != null) continue; + System.out.println("-----------------------------------已处理" + i++ + "-------------------------------------------"); UniversityFacultyQuery universityFacultyQuery = new UniversityFacultyQuery(); CoreUser coreUser = new CoreUser(); universityFacultyQuery.setUniversityFacultyName(resultSet.getString(1)); String collegeName = resultSet.getString(1); - Long oldId = resultSet.getLong(2); + if (collegeName.equals("演示学院")) { int a = 0; } @@ -177,7 +198,7 @@ public class TestController { universityFacultyQuery.setUniversityFacultyContactTel(resultSet.getString(5)); universityFacultyQuery.setUniversityFacultyContactAddress(resultSet.getString(6)); - UniversitiesColleges universitiesColleges = universitiesCollegesService.getByName(resultSet.getString(3)); + UniversitiesColleges universitiesColleges = universitiesCollegesService.findByOldId(resultSet.getLong("schoolId")); if (universitiesColleges == null) { continue; } @@ -230,11 +251,11 @@ public class TestController { " col.Name AS colName, " + " sch.Name AS schName," + " col.Id as colId," + - " ma.Id as majorId " + + " ma.Id as majorId,sch.id as schoolId " + "FROM " + " EduMajors ma " + " JOIN EduColleges col ON ma.CollegeId = col.Id " + - " JOIN EduSchools sch ON col.schoolId = sch.id where sch.Name='西安明德理工学院'"; + " JOIN EduSchools sch ON col.schoolId = sch.id "; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; @@ -242,6 +263,10 @@ public class TestController { System.out.println("-----------------------------------已处理" + i++ + "-------------------------------------------"); Long oldCollegeId = resultSet.getLong(7); Long oldId = resultSet.getLong(8); + UniversitySystem universitySystem = universitySystemService.getByOldId(oldId); + if (universitySystem != null) { + continue; + } UniversitySystemQuery universitySystemQuery = new UniversitySystemQuery(); universitySystemQuery.setOldId(oldId); universitySystemQuery.setUniversitySystemName(resultSet.getString(1)); @@ -252,7 +277,7 @@ public class TestController { if (resultSet.getString(6).equals("安阳学院")) { int a = 0; } - UniversitiesColleges universitiesColleges = universitiesCollegesService.getByName(resultSet.getString(6)); + UniversitiesColleges universitiesColleges = universitiesCollegesService.findByOldId(resultSet.getLong("schoolId")); if (resultSet.getString(6).equals("安徽建筑大学2")) { continue; } @@ -304,17 +329,21 @@ public class TestController { " cla.Name as majName, \n" + " cla.Name as claName, \n" + " cla.IsDeleted, \n" + - " cla.CollegeId, \n" + - " cla.MajorId, \n" + + " cla.CollegeId as collegeId, \n" + + " cla.MajorId as majorId, \n" + " cla.id," + - " cla.schoolId \n" + + " cla.schoolId as schoolId \n" + " FROM \n" + - " EduClasses cla where schoolId=175"; + " EduClasses cla "; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; while (resultSet.next()) { System.out.println("-----------------------------------已处理" + i++ + "-------------------------------------------"); + SchoolClass schoolClass1 = schoolClassService.getByOldId(resultSet.getLong("id")); + if (schoolClass1 != null) { + continue; + } String claName = resultSet.getString(4); if (claName.equals("内部体验1班")) { int a = 0; @@ -322,26 +351,26 @@ public class TestController { if (resultSet.getString(9).equals("16")) { continue; } - SchoolClass serviceByName = schoolClassService.getByOldId(resultSet.getLong(8)); + SchoolClass serviceByName = schoolClassService.getByOldId(resultSet.getLong("id")); if (serviceByName != null) { - serviceByName.setOldClassId(resultSet.getLong(8)); + serviceByName.setOldClassId(resultSet.getLong("id")); schoolClassService.updateTemplate(serviceByName); continue; } - UniversitySystem universitySystem = universitySystemService.getByOldId(resultSet.getLong(7)); + UniversitySystem universitySystem = universitySystemService.getByOldId(resultSet.getLong("majorId")); if (universitySystem == null) { continue; } - UniversitiesColleges universitiesColleges = universitiesCollegesService.getByOrgId(universitySystem.getOrgId()); + UniversitiesColleges universitiesColleges = universitiesCollegesService.findByOldId(resultSet.getLong("schoolId")); if (universitiesColleges == null) { continue; } SchoolClass schoolClass = new SchoolClass(); - schoolClass.setClassName(resultSet.getString(4)); + schoolClass.setClassName(resultSet.getString("claName")); if (universitiesColleges == null) { continue; } @@ -358,7 +387,7 @@ public class TestController { schoolClass.setOrgId(universitiesColleges.getOrgId()); schoolClass.setUserId(Long.valueOf(100)); schoolClass.setClassStatus(1); - schoolClass.setOldClassId(resultSet.getLong(8)); + schoolClass.setOldClassId(resultSet.getLong("id")); schoolClassService.save(schoolClass); } @@ -379,9 +408,9 @@ public class TestController { conn = openConn(); String sql = "SELECT " + - " sch.Name AS schName, " + - " col.Name AS colName, " + - " maj.Name AS majName, " + + " sch.Name AS schName,sch.id as schoolId, " + + " col.Name AS colName,col.id as collegeId, " + + " maj.Name AS majName,maj.id as majorId, " + " tea.Name AS teacherName, " + " tea.TeacherNo AS teacherNo, " + " tea.PhoneNo, " + @@ -392,38 +421,47 @@ 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 where sch.Name='西安明德理工学院'"; + " JOIN EduSchools sch ON tea.SchoolId = sch.Id "; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; while (resultSet.next()) { System.out.println("--------------------------------已处理:" + i++ + "------------------------"); + Long oldId = resultSet.getLong("id"); + Teacher teacher1 = teacherService.getByOldId(oldId); + if (teacher1 != null) continue; + + Teacher teacher2 = teacherService.getByTeacherSn(resultSet.getString("teacherNo")); + if (teacher2 != null) { + coreUserService.deleteById1(teacher2.getUserId()); + teacherService.deleteById1(teacher2.getTeacherId()); + } Teacher teacher = new Teacher(); - UniversitiesColleges universitiesColleges = universitiesCollegesService.getByName(resultSet.getString(1)); + UniversitiesColleges universitiesColleges = universitiesCollegesService.findByOldId(resultSet.getLong("schoolId")); if (universitiesColleges == null) { continue; } - UniversityFaculty universityFaculty = universityFacultyService.getByNameAndSchoolId(resultSet.getString(2), universitiesColleges.getUniversitiesCollegesId()); + UniversityFaculty universityFaculty = universityFacultyService.getByOldId(resultSet.getLong("collegeId")); if (universityFaculty == null) { continue; } - UniversitySystem universitySystem = universitySystemService.getByNameAndSchoolIdAndCollegeId(resultSet.getString(3), universityFaculty.getUniversityFacultyId(), universitiesColleges.getOrgId()); + UniversitySystem universitySystem = universitySystemService.getByOldId(resultSet.getLong("majorId")); if (universitySystem == null) { continue; } - teacher.setTeacherName(resultSet.getString(4)); + teacher.setTeacherName(resultSet.getString("teacherName")); teacher.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId()); teacher.setUniversityFacultyId(universityFaculty.getUniversityFacultyId()); teacher.setUniversitySystemId(universitySystem.getUniversitySystemId()); - teacher.setTeacherMobile(resultSet.getString(6)); - teacher.setTeacherJobNumber(resultSet.getString(5)); + teacher.setTeacherMobile(resultSet.getString("PhoneNo")); + teacher.setTeacherJobNumber(resultSet.getString("teacherNo")); Teacher byTeacherJobNameAndOrgId = teacherService.getByTeacherJobNameAndOrgId(teacher.getTeacherJobNumber(), universitiesColleges.getOrgId()); if (byTeacherJobNameAndOrgId != null) continue; - teacher.setTeacherStatus(resultSet.getInt(8) + 1); - int anInt = resultSet.getInt(7); + teacher.setTeacherStatus(resultSet.getInt("IsDeleted") + 1); + int anInt = resultSet.getInt("Sex"); GenderEnum genderEnum; if (anInt == 1) { genderEnum = GenderEnum.MAN; @@ -455,38 +493,47 @@ public class TestController { try { conn = openConn(); String sql = "SELECT " + - " sch.Name AS schName, " + - " col.Name AS colName, " + - " maj.Name AS majName, " + + " sch.Name AS schName,sch.id as schoolId, " + + " col.Name AS colName,col.id as collegeId, " + + " maj.Name AS majName,maj.id as majorId, " + " stu.Name AS studentName, " + " stu.StudentNo AS StudentNo, " + " stu.PhoneNo, " + " stu.Sex, " + " stu.IsDeleted, " + - " cla.Name ," + - " col.Id," + - " maj.Id,cla.id ,\n" + - " us.Id as userId " + + " cla.Name,cla.id as classId," + + " " + + " \n" + + " us.Id as userId,stu.id as id " + "FROM " + " EduStudents stu " + " 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 EduUsers us on stu.StudentNo = us.UserName where sch.Name='西安明德理工学院'"; + " join EduUsers us on stu.StudentNo = us.UserName where stu.isdeleted=0"; ps = conn.prepareStatement(sql); ResultSet resultSet = ps.executeQuery(); int i = 0; while (resultSet.next()) { + Long oldId = resultSet.getLong("id"); + Student student1 = studentService.getByOldId(oldId);//防止重复() System.out.println("-----------------------------------已处理" + i++ + "-------------------------------------------"); - if (resultSet.getString(9).contains("内部体验")) { + if (i == 149) { int a = 0; } + if (student1 != null) continue; + Student student2 = studentService.getStudentByStudentNo(resultSet.getString("StudentNo")); + if (student2 != null) { + coreUserService.deleteById1(student2.getUserId()); + studentService.deleteById1(student2.getStudentId()); + } Student student = new Student(); - student.setStudentName(resultSet.getString(4)); - student.setStudentSn(resultSet.getString(5)); - student.setStudentMobile(resultSet.getString(6)); - String username = resultSet.getString(5); + student.setStudentName(resultSet.getString("studentName")); + student.setStudentSn(resultSet.getString("StudentNo")); + student.setStudentMobile(resultSet.getString("PhoneNo")); + String username = resultSet.getString("StudentNo"); + student.setOldId(oldId); // Map studentByNo = coreUserService.getStudentByNo(username); if (username.length() == 36) { @@ -496,7 +543,7 @@ public class TestController { if (aBoolean) { continue; } - int anInt = resultSet.getInt(7); + int anInt = resultSet.getInt("Sex"); GenderEnum genderEnum; if (anInt == 1) { genderEnum = GenderEnum.MAN; @@ -506,8 +553,7 @@ public class TestController { student.setStudentGender(genderEnum); student.setAddTime(new Date()); - SchoolClass schoolClass = schoolClassService.getByOldId(resultSet.getLong(12) - ); + SchoolClass schoolClass = schoolClassService.getByOldId(resultSet.getLong("classId")); if (schoolClass == null) { continue; } @@ -516,8 +562,8 @@ public class TestController { continue; } student.setClassId(schoolClass.getClassId()); - Long oldId = resultSet.getLong("userId"); - studentService.add(student,oldId); + Long oldUserId = resultSet.getLong("userId"); + studentService.add(student, oldUserId); } } catch (Exception ex) { ex.printStackTrace(); @@ -695,26 +741,789 @@ public class TestController { public void updateTeacherId() { List teachers = teacherService.findAll(); for (Teacher teacher : teachers) { - String sql = "select * from EduTeachers where TeacherNo ='" + teacher.getTeacherJobNumber()+"'"; + String sql = "select * from EduTeachers where TeacherNo ='" + teacher.getTeacherJobNumber() + "'"; try { Connection connection = ZhiYunJDBCUtil.openConn(); PreparedStatement ps = connection.prepareStatement(sql); ResultSet rs = ps.executeQuery(); - while (rs.next()){ + while (rs.next()) { teacher.setOldId(rs.getLong("id")); teacherService.updateTemplate(teacher); } - if(teacher.getOldId()==null){ - teacher.setOldId(5000L+teacher.getTeacherId()); + if (teacher.getOldId() == null) { + teacher.setOldId(5000L + teacher.getTeacherId()); teacherService.updateTemplate(teacher); } connection.close(); ps.close(); - }catch (Exception ex){ + } catch (Exception ex) { ex.printStackTrace(); } } } + @ApiOperation("修改给定学校用户old_id") + @PostMapping("updateOldIdByUser.json") + public void updateOldIdByUser(Long schoolId) throws SQLException { + List users = coreUserService.findBySchoolId(schoolId); + for (CoreUser user : users) { + Connection conn = openConn(); + + String sql = "select * from EduUsers where UserName = '" + user.getCode() + "'"; + PreparedStatement ps = conn.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + int oldId = 0; + while (rs.next()) { + oldId = rs.getInt("id"); + user.setOldId(rs.getLong("id")); + coreUserService.updateTemplate(user); + } + if (oldId == 0) { + user.setOldId(50000L + user.getId()); + coreUserService.updateTemplate(user); + } + conn.close(); + ps.close(); + } + } + + @ApiOperation("修改给定学校学生old_id") + @PostMapping("updateOldIdByStudent.json") + public void updateOldIdByStudent(Long schoolId) throws SQLException { + List users = coreUserService.findBySchoolId(schoolId); + for (CoreUser user : users) { + Connection conn = openConn(); + String sql = "select * from EduStudents where StudentNo = '" + user.getCode() + "'"; + PreparedStatement ps = conn.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + int oldId = 0; + while (rs.next()) { + oldId = rs.getInt("id"); + user.setOldId(rs.getLong("id")); + coreUserService.updateTemplate(user); + } + if (oldId == 0) { + user.setOldId(80000 + user.getId()); + coreUserService.updateTemplate(user); + } + conn.close(); + ps.close(); + } + } + + + @ApiOperation("********************************清洗学校oldId") + @PostMapping("clearSchoolOldId.json") + public void clearSchoolOldId() throws SQLException { + List colleges = universitiesCollegesService.getAll(); + if (colleges != null && colleges.size() > 0) { + int i = 0; + for (UniversitiesColleges universitiesColleges : colleges) { + i++; + System.out.println("修改学校" + i + "/" + colleges.size()); + Connection connection = openConn(); + String sql = "select * from EduSchools where Name = '" + universitiesColleges.getUniversitiesCollegesName() + "' and IsDeleted = 0"; + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = universitiesColleges.getUniversitiesCollegesId() + 500; + } + universitiesColleges.setOldSchoolId(oldId); + universitiesCollegesService.updateTemplate(universitiesColleges); + } + } + } + + @ApiOperation("********************************清洗院系oldId") + @PostMapping("clearCollegeOldId.json") + public void clearCollegeOldId() throws SQLException { + List faculties = universityFacultyService.findAll(); + if (faculties != null && faculties.size() > 0) { + int i = 0; + for (UniversityFaculty faculty : faculties) { + i++; + System.out.println("修改院系" + i + "/" + faculties.size()); + Connection connection = openConn(); + UniversitiesColleges universitiesColleges = universitiesCollegesService.queryById(faculty.getUniversitiesCollegesId()); + if (faculty.getUniversityFacultyName().equals("金融与数学学院")) { + int a = 0; + } + String sql = "select * from EduColleges where Name = '" + faculty.getUniversityFacultyName() + "' and IsDeleted = 0 and schoolId = " + universitiesColleges.getOldSchoolId(); + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = faculty.getUniversityFacultyId() + 500; + } + faculty.setOldId(oldId); + universityFacultyService.updateTemplate(faculty); + } + } + } + + @ApiOperation("********************************清洗专业OldId") + @PostMapping("clearMajorOldId.json") + public void clearMajorOldId() throws SQLException { + List majors = universitySystemService.findAll(); + if (majors != null && majors.size() > 0) { + int i = 0; + for (UniversitySystem system : majors) { + i++; + UniversityFaculty universityFaculty = universityFacultyService.getById(system.getUniversityFacultyId()); + System.out.println("修改专业" + i + "/" + majors.size()); + Connection connection = openConn(); + String sql = "select * from EduMajors where Name = '" + system.getUniversitySystemName() + "' and IsDeleted = 0 and collegeId = " + universityFaculty.getOldId(); + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = system.getUniversitySystemId() + 500; + } + system.setOldId(oldId); + universitySystemService.updateTemplate(system); + } + } + } + + @ApiOperation("********************************清洗班级OldId") + @PostMapping("clearClassOldId.json") + public void clearClassOldId() throws SQLException { + List classes = schoolClassService.getAll(); + if (classes != null && classes.size() > 0) { + int i = 0; + for (SchoolClass schoolClass : classes) { + i++; + UniversitySystem system = universitySystemService.getById(schoolClass.getUniversitySystemId()); + System.out.println("修改班级" + i + "/" + classes.size()); + Connection connection = openConn(); + if(schoolClass.getClassName().equals("产品演示1班")){ + int a = 0; + } + String sql = "select * from EduClasses where Name = '" + schoolClass.getClassName() + "' and IsDeleted = 0 and majorId = " + system.getOldId(); + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = schoolClass.getClassId() + 1500; + } + schoolClass.setOldClassId(oldId); + schoolClassService.updateTemplate(schoolClass); + } + } + } + + + @ApiOperation("********************************清洗教师OldId") + @PostMapping("clearTeacherOldId.json") + public void clearTeacherOldId() throws SQLException { + List teachers = teacherService.findAll(); + if (teachers != null && teachers.size() > 0) { + int i = 0; + for (Teacher teacher : teachers) { + i++; + System.out.println("修改教师" + i + "/" + teachers.size()); + Connection connection = openConn(); + String sql = "select * from EduTeachers where teacherNo = '" + teacher.getTeacherJobNumber() + "' and IsDeleted = 0"; + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = teacher.getTeacherId() + 5000; + } + teacher.setOldId(oldId); + teacherService.updateTemplate(teacher); + } + } + } + + @ApiOperation("********************************清洗学生oldId") + @PostMapping("clearStudentOldId.json") + public void clearStudentOldId() throws SQLException { + List students = studentService.getAll(); + if (students != null && students.size() > 0) { + int totalStudents = students.size(); + int numThreads = Runtime.getRuntime().availableProcessors(); // 获取可用处理器数量 + ExecutorService executor = Executors.newFixedThreadPool(numThreads); + + // 将学生列表分组,每组分配给一个线程处理 + List> studentGroups = partitionList(students, numThreads); + + for (List studentGroup : studentGroups) { + executor.execute(() -> { + try { + int processedCount = 0; + System.out.println(Thread.currentThread().getName() + ": 开始处理"); + for (Student student : studentGroup) { + processedCount++; + System.out.println(Thread.currentThread().getName() + ": 修改学生" + student.getStudentSn() + ",处理到第" + processedCount + "/" + studentGroup.size()); + Connection connection = openConn(); + String sql = "select * from EduStudents where StudentNo = ? and IsDeleted = 0"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setString(1, student.getStudentSn()); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = student.getStudentId() + 80000; + } + student.setOldId(oldId); + studentService.updateTemplate(student); + } + System.out.println(Thread.currentThread().getName() + ": 处理完成"); + } catch (SQLException e) { + e.printStackTrace(); + } + }); + } + executor.shutdown(); + while (!executor.isTerminated()) { + // 等待所有线程完成 + } + System.out.println("线程结束"); + } + } + // 将列表分成几组 + private List> partitionList(List list, int partitions) { + List> result = new ArrayList<>(); + int size = list.size(); + int batchSize = size / partitions; + int remainder = size % partitions; + int fromIndex = 0; + + for (int i = 0; i < partitions; i++) { + int toIndex = fromIndex + batchSize + (i < remainder ? 1 : 0); + result.add(list.subList(fromIndex, toIndex)); + fromIndex = toIndex; + } + + return result; + } + + @ApiOperation("********************************清洗用户oldId") + @PostMapping("clearUserOldId.json") + public void clearUserOldId() throws SQLException { + List users = coreUserService.findAll(); + if (users != null && users.size() > 0) { + int totalUsers = users.size(); + int numThreads = Runtime.getRuntime().availableProcessors(); // Number of available processors + ExecutorService executor = Executors.newFixedThreadPool(numThreads); + + // Divide users into groups + List> userGroups = users.stream() + .collect(Collectors.groupingBy(user -> user.hashCode() % numThreads)) + .values().stream().collect(Collectors.toList()); + + for (List userGroup : userGroups) { + executor.execute(() -> { + int processedCount = 0; + for (CoreUser user : userGroup) { + processedCount++; + System.out.println(Thread.currentThread().getName() + ":修改用户" + user.getCode() + ",处理到第" + processedCount + "/" + userGroup.size()); + try { + Connection connection = openConn(); + String sql = "select * from eduusers where UserName = ? and IsDeleted = 0"; + PreparedStatement ps = connection.prepareStatement(sql); + ps.setString(1, user.getCode()); + ResultSet rs = ps.executeQuery(); + Long oldId = 0L; + while (rs.next()) { + oldId = rs.getLong("id"); + } + connection.close(); + ps.close(); + if (oldId == 0) { + oldId = user.getId() + 100000; + } + user.setOldId(oldId); + coreUserService.updateTemplate(user); + } catch (SQLException e) { + e.printStackTrace(); + } + } + System.out.println(Thread.currentThread().getName() + ":处理了" + processedCount + "条数据"); + }); + } + executor.shutdown(); + while (!executor.isTerminated()) { + // Wait until all threads finish + } + } + System.out.println("线程结束"); + } + + + @ApiOperation("多线程同步用户资产数据") + @PostMapping("syncUserAssets.json") + public void syncUserAssets() throws SQLException { + List students = studentService.getAll(); + if (students != null && students.size() > 0) { + int numThreads = Runtime.getRuntime().availableProcessors(); // 获取可用处理器数量作为线程数 + ExecutorService executor = Executors.newFixedThreadPool(numThreads); + + int chunkSize = students.size() / numThreads; + int fromIndex = 0; + int toIndex = chunkSize; + + for (int i = 0; i < numThreads; i++) { + List chunk = students.subList(fromIndex, toIndex); + executor.execute(() -> { + try { + runTask(chunk); + } catch (SQLException e) { + e.printStackTrace(); + } + }); + fromIndex = toIndex; + toIndex = (i == numThreads - 2) ? students.size() : toIndex + chunkSize; + } + + executor.shutdown(); + try { + executor.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); + System.out.println("所有任务已完成。"); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + + private void runTask(List students) throws SQLException { + for (Student student : students) { + Connection connection = openConn(); + CoreUser coreUser = coreUserService.getUserById(student.getUserId()); + String sql = "SELECT\n" + + " EduUsers.UserName,\n" + + " EduAssetAllocation.ApplicationId,\n" + + " CAST(EduAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" + + " CAST(EduAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" + + " EduAssetAllocation.IntoAccount," + + " EduAssetAllocation.name,\n" + + " CAST(EduAssetAllocation.TransferInAmount AS DECIMAL(18, 2)) AS TransferInAmount,\n" + + " CAST(EduAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" + + " CAST(EduAssetAllocation.TransferOutAmount AS DECIMAL(18, 2)) AS TransferOutAmount,\n" + + " CAST(EduAssetAllocation.Borrowed_Funds AS DECIMAL(18, 2)) AS Borrowed_Funds,\n" + + " CAST(EduAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" + + " CAST(EduAssetAllocation.Investment_value AS DECIMAL(18, 2)) AS Investment_value,\n" + + " CAST(EduAssetAllocation.Investment_income AS DECIMAL(18, 2)) AS Investment_income,\n" + + " CAST(EduAssetAllocation.Total_assets_of_subaccounts AS DECIMAL(18, 2)) AS Total_assets_of_subaccounts,\n" + + " CAST(EduAssetAllocation.Asset_Investment AS DECIMAL(18, 2)) AS Asset_Investment,\n" + + " CAST(EduAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity\n" + + "FROM EduUsers\n" + + "JOIN EduAssetAllocation ON EduUsers.Id = EduAssetAllocation.UserId\n" + + "WHERE EduUsers.Id = " + coreUser.getOldId(); + + PreparedStatement ps = connection.prepareStatement(sql); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + List studentAccountAssetAllocations = studentAccountAssetAllocationService.getInfoByStudentId(student.getStudentId()); + if (studentAccountAssetAllocations != null && studentAccountAssetAllocations.size() == 8) { + continue; + } + StudentAccountAssetAllocationQuery allocationQuery = new StudentAccountAssetAllocationQuery(); + + + Integer applicationId = resultSet.getInt("ApplicationId"); + if (applicationId.equals("-1")) { + continue; + } + 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); + StudentAccountCrowdfundingSystem info = studentAccountCrowdfundingSystemService.getInfo(student.getStudentId()); + if (info != null) { + continue; + } + Connection connection1 = openConn(); + String sql1 = "SELECT\n" + + " ExaP2PAssetAllocation.Id,\n" + + " ExaP2PAssetAllocation.ApplicationId,\n" + + " CAST(ExaP2PAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" + + " CAST(ExaP2PAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" + + " CAST(ExaP2PAssetAllocation.The_Total_AssetsOf AS DECIMAL(18, 2)) AS The_Total_AssetsOf,\n" + + " CAST(ExaP2PAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" + + " CAST(ExaP2PAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" + + " CAST(ExaP2PAssetAllocation.Borrowed_Funds AS DECIMAL(18, 2)) AS Borrowed_Funds,\n" + + " CAST(ExaP2PAssetAllocation.Freeze_Funds AS DECIMAL(18, 2)) AS Freeze_Funds,\n" + + " CAST(ExaP2PAssetAllocation.Cumulative_of_return AS DECIMAL(18, 2)) AS Cumulative_of_return,\n" + + " CAST(ExaP2PAssetAllocation.TotalAssets_Rate_Return AS DECIMAL(18, 2)) AS TotalAssets_Rate_Return,\n" + + " CAST(ExaP2PAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity,\n" + + " CAST(ExaP2PAssetAllocation.TotalDailyInvestment AS DECIMAL(18, 2)) AS TotalDailyInvestment,\n" + + " CAST(ExaP2PAssetAllocation.TotalWeeklyInvestment AS DECIMAL(18, 2)) AS TotalWeeklyInvestment,\n" + + " CAST(ExaP2PAssetAllocation.TotalMonthlyInvestment AS DECIMAL(18, 2)) AS TotalMonthlyInvestment,\n" + + " ExaP2PAssetAllocation.UserId,\n" + + " ExaP2PAssetAllocation.IsDeleted,\n" + + " ExaP2PAssetAllocation.DeleterUserId,\n" + + " ExaP2PAssetAllocation.DeletionTime,\n" + + " ExaP2PAssetAllocation.LastModificationTime,\n" + + " ExaP2PAssetAllocation.LastModifierUserId,\n" + + " ExaP2PAssetAllocation.CreationTime,\n" + + " ExaP2PAssetAllocation.CreatorUserId\n" + + "FROM ExaP2PAssetAllocation\n" + + "JOIN EduUsers ON ExaP2PAssetAllocation.UserId = EduUsers.Id\n" + + "WHERE EduUsers.Id = " + coreUser.getOldId(); + PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1); + ResultSet resultSet1 = preparedStatement1.executeQuery(); + while (resultSet1.next()) { + + + StudentAccountP2pSystem studentAccountP2pSystem = new StudentAccountP2pSystem(); + BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital"); + BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital"); + BigDecimal The_Total_AssetsOf1 = resultSet1.getBigDecimal("The_Total_AssetsOf"); + BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds"); + BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds"); + BigDecimal Borrowed_Funds1 = resultSet1.getBigDecimal("Borrowed_Funds"); + BigDecimal Freeze_Funds1 = resultSet1.getBigDecimal("Freeze_Funds"); + BigDecimal Cumulative_of_return1 = resultSet1.getBigDecimal("Cumulative_of_return"); + BigDecimal TotalAssets_Rate_Return1 = resultSet1.getBigDecimal("TotalAssets_Rate_Return"); + BigDecimal Return_on_equity1 = resultSet1.getBigDecimal("Return_on_equity"); + BigDecimal TotalDailyInvestment1 = resultSet1.getBigDecimal("TotalDailyInvestment"); + BigDecimal TotalWeeklyInvestment1 = resultSet1.getBigDecimal("TotalWeeklyInvestment"); + BigDecimal TotalMonthlyInvestment1 = resultSet1.getBigDecimal("TotalMonthlyInvestment"); + studentAccountP2pSystem.setStudentId(student.getStudentId()); + studentAccountP2pSystem.setApplicationId(Long.valueOf(applicationId)); + studentAccountP2pSystem.setUniversitiesCollegesId(student.getOrgId()); + studentAccountP2pSystem.setInitialCapital(InitialCapital1); + studentAccountP2pSystem.setState(Long.valueOf(1)); + studentAccountP2pSystem.setInitialInvestmentCapital(InitialInvestmentCapital1); + studentAccountP2pSystem.setAvailableBalance(AvailableFunds1); + studentAccountP2pSystem.setTotalAssets(The_Total_AssetsOf1); + studentAccountP2pSystem.setTotalInvestment(InvestmentFunds1); + studentAccountP2pSystem.setTotalBorrow(Borrowed_Funds1); + studentAccountP2pSystem.setFrozenFunds(Freeze_Funds1); + studentAccountP2pSystem.setCumulativeIncome(Cumulative_of_return1); + studentAccountP2pSystem.setTotalAssetIncome(TotalAssets_Rate_Return1); + studentAccountP2pSystem.setNetAssetIncome(Return_on_equity1); + studentAccountP2pSystem.setTotalDailyInvestmentAmount(TotalDailyInvestment1); + studentAccountP2pSystem.setTotalAmountWeeklyInvestment(TotalWeeklyInvestment1); + studentAccountP2pSystem.setTotalAmountMonthlyInvestment(TotalMonthlyInvestment1); + studentAccountP2pSystem.setIsDel(Long.valueOf(1)); + studentAccountP2pSystem.setOrgId(student.getOrgId()); + studentAccountP2pSystem.setIsInstitution(Long.valueOf(1)); + studentAccountP2pSystemService.add(studentAccountP2pSystem); + } + closeConn(connection1); + preparedStatement1.close(); + + } else if (applicationId == 5) { + allocationQuery.setApplicationId(Long.valueOf(5)); + allocationQuery.setName(AccountTypeEnum.CROWDFUNDING_ACCOUNT); + + StudentAccountCrowdfundingSystem info = studentAccountCrowdfundingSystemService.getInfo(student.getStudentId()); + if (info != null) continue; + + Connection connection1 = openConn(); + String sql1 = "SELECT\n" + + " ExaTheRaiseAssetAllocation.Id,\n" + + " ExaTheRaiseAssetAllocation.ApplicationId,\n" + + " CAST(ExaTheRaiseAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" + + " CAST(ExaTheRaiseAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" + + " CAST(ExaTheRaiseAssetAllocation.The_Total_AssetsOf AS DECIMAL(18, 2)) AS The_Total_AssetsOf,\n" + + " CAST(ExaTheRaiseAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" + + " CAST(ExaTheRaiseAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" + + " CAST(ExaTheRaiseAssetAllocation.TheTotalAmountOfTheRaise AS DECIMAL(18, 2)) AS TheTotalAmountOfTheRaise,\n" + + " CAST(ExaTheRaiseAssetAllocation.TheTotalAmountOfFrozen AS DECIMAL(18, 2)) AS TheTotalAmountOfFrozen,\n" + + " CAST(ExaTheRaiseAssetAllocation.Cumulative_of_return AS DECIMAL(18, 2)) AS Cumulative_of_return,\n" + + " CAST(ExaTheRaiseAssetAllocation.ReturnOnInvestmentOwnCapital AS DECIMAL(18, 2)) AS ReturnOnInvestmentOwnCapital,\n" + + " CAST(ExaTheRaiseAssetAllocation.ReturnOnCrowdfundingInvestment AS DECIMAL(18, 2)) AS ReturnOnCrowdfundingInvestment,\n" + + " ExaTheRaiseAssetAllocation.UserId,\n" + + " ExaTheRaiseAssetAllocation.IsDeleted,\n" + + " ExaTheRaiseAssetAllocation.DeleterUserId,\n" + + " ExaTheRaiseAssetAllocation.DeletionTime,\n" + + " ExaTheRaiseAssetAllocation.LastModificationTime,\n" + + " ExaTheRaiseAssetAllocation.LastModifierUserId,\n" + + " ExaTheRaiseAssetAllocation.CreationTime,\n" + + " ExaTheRaiseAssetAllocation.CreatorUserId\n" + + "FROM ExaTheRaiseAssetAllocation\n" + + "JOIN EduUsers ON ExaTheRaiseAssetAllocation.UserId = EduUsers.Id\n" + + "WHERE EduUsers.Id =" + coreUser.getOldId(); + PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1); + ResultSet resultSet1 = preparedStatement1.executeQuery(); + while (resultSet1.next()) { + StudentAccountCrowdfundingSystem system = new StudentAccountCrowdfundingSystem(); + system.setStudentId(student.getStudentId()); + system.setState(Long.valueOf(1)); + system.setApplicationId(Long.valueOf(applicationId)); + system.setUniversitiesCollegesId(student.getOrgId()); + system.setIsDel(1L); + system.setIsInstitution(1L); + system.setOrgId(student.getOrgId()); + BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital"); + BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital"); + BigDecimal The_Total_AssetsOf1 = resultSet1.getBigDecimal("The_Total_AssetsOf"); + BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds"); + BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds"); + BigDecimal TheTotalAmountOfTheRaise1 = resultSet1.getBigDecimal("TheTotalAmountOfTheRaise"); + BigDecimal TheTotalAmountOfFrozen1 = resultSet1.getBigDecimal("TheTotalAmountOfFrozen"); + BigDecimal Cumulative_of_return1 = resultSet1.getBigDecimal("Cumulative_of_return"); + BigDecimal ReturnOnInvestmentOwnCapital1 = resultSet1.getBigDecimal("ReturnOnInvestmentOwnCapital"); + BigDecimal ReturnOnCrowdfundingInvestment1 = resultSet1.getBigDecimal("ReturnOnCrowdfundingInvestment"); + system.setInitialCapital(InitialCapital1); + system.setInitialInvestmentCapital(InitialInvestmentCapital1); + system.setAvailableBalance(AvailableFunds1); + system.setTotalAssets(The_Total_AssetsOf1); + system.setTotalInvestment(InvestmentFunds1); + system.setTotalCrowdfunding(TheTotalAmountOfTheRaise1); + system.setTotalFrozen(TheTotalAmountOfFrozen1); + system.setCumulativeIncome(Cumulative_of_return1); + system.setFrozenInvestmentIncome(ReturnOnInvestmentOwnCapital1); + system.setCrowdfundingFrozenInvestmentIncome(ReturnOnCrowdfundingInvestment1); + + studentAccountCrowdfundingSystemService.add(system); + } + closeConn(connection1); + preparedStatement1.close(); + + } else if (applicationId == 16) { + allocationQuery.setApplicationId(Long.valueOf(16)); + allocationQuery.setName(AccountTypeEnum.EQUITY_FUND_INVESTMENT_ACCOUNT); + +// List byStudentId = studentAccountMockTradingSystemService.getByStudentId(student.getStudentId()); +// if(byStudentId!=null&&byStudentId.size()>0)continue; + Connection connection1 = openConn(); + String sql1 = "SELECT\n" + + " ExaMNJYAssetAllocation.Id,\n" + + " ExaMNJYAssetAllocation.ApplicationId,\n" + + " CAST(ExaMNJYAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" + + " CAST(ExaMNJYAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" + + " CAST(ExaMNJYAssetAllocation.TotalAssets AS DECIMAL(18, 2)) AS TotalAssets,\n" + + " CAST(ExaMNJYAssetAllocation.AvailableFunds AS DECIMAL(18, 2)) AS AvailableFunds,\n" + + " CAST(ExaMNJYAssetAllocation.Market_value AS DECIMAL(18, 2)) AS Market_value,\n" + + " CAST(ExaMNJYAssetAllocation.Accumulative_total_profit_and_loss AS DECIMAL(18, 2)) AS Accumulative_total_profit_and_loss,\n" + + " CAST(ExaMNJYAssetAllocation.Cumulative_rate_of_return AS DECIMAL(18, 2)) AS Cumulative_rate_of_return,\n" + + " CAST(ExaMNJYAssetAllocation.Annualized_rate_of_return AS DECIMAL(18, 2)) AS Annualized_rate_of_return,\n" + + " CAST(ExaMNJYAssetAllocation.Kumar_ratio AS DECIMAL(18, 2)) AS Kumar_ratio,\n" + + " CAST(ExaMNJYAssetAllocation.Sharpe_ratio AS DECIMAL(18, 2)) AS Sharpe_ratio,\n" + + " CAST(ExaMNJYAssetAllocation.The_biggest_back_test AS DECIMAL(18, 2)) AS The_biggest_back_test,\n" + + " CAST(ExaMNJYAssetAllocation.Asset_Investment_Rate AS DECIMAL(18, 2)) AS Asset_Investment_Rate,\n" + + " CAST(ExaMNJYAssetAllocation.Return_on_equity AS DECIMAL(18, 2)) AS Return_on_equity,\n" + + " ExaMNJYAssetAllocation.UserId,\n" + + " ExaMNJYAssetAllocation.SecType,\n" + + " ExaMNJYAssetAllocation.IsDeleted,\n" + + " ExaMNJYAssetAllocation.DeleterUserId,\n" + + " ExaMNJYAssetAllocation.DeletionTime,\n" + + " ExaMNJYAssetAllocation.LastModificationTime,\n" + + " ExaMNJYAssetAllocation.LastModifierUserId,\n" + + " ExaMNJYAssetAllocation.CreationTime,\n" + + " ExaMNJYAssetAllocation.CreatorUserId\n" + + "FROM ExaMNJYAssetAllocation\n" + + "JOIN EduUsers ON ExaMNJYAssetAllocation.UserId = EduUsers.Id\n" + + "WHERE EduUsers.Id =" + coreUser.getOldId(); + PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1); + ResultSet resultSet1 = preparedStatement1.executeQuery(); + while (resultSet1.next()) { + StudentAccountMockTradingSystem system = new StudentAccountMockTradingSystem(); + BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital"); + BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital"); + BigDecimal TotalAssets1 = resultSet1.getBigDecimal("TotalAssets"); + BigDecimal AvailableFunds1 = resultSet1.getBigDecimal("AvailableFunds"); + BigDecimal Market_value1 = resultSet1.getBigDecimal("Market_value"); + BigDecimal Accumulative_total_profit_and_loss1 = resultSet1.getBigDecimal("Accumulative_total_profit_and_loss"); + BigDecimal Cumulative_rate_of_return1 = resultSet1.getBigDecimal("Cumulative_rate_of_return"); + BigDecimal Annualized_rate_of_return1 = resultSet1.getBigDecimal("Annualized_rate_of_return"); + BigDecimal Kumar_ratio1 = resultSet1.getBigDecimal("Kumar_ratio"); + BigDecimal Sharpe_ratio1 = resultSet1.getBigDecimal("Sharpe_ratio"); + BigDecimal The_biggest_back_test1 = resultSet1.getBigDecimal("The_biggest_back_test"); + BigDecimal Asset_Investment_Rate1 = resultSet1.getBigDecimal("Asset_Investment_Rate"); + BigDecimal Return_on_equity1 = resultSet1.getBigDecimal("Return_on_equity"); + Long applicationId1 = resultSet1.getLong("ApplicationId"); + system.setStudentId(student.getStudentId()); + system.setApplicationId(applicationId1); + system.setUniversitiesCollegesId(student.getOrgId()); + system.setState(Long.valueOf(1)); + system.setIsDel(1L); + system.setInitialCapital(InitialCapital1); + system.setInitialInvestmentCapital(InitialInvestmentCapital1); + system.setTotalAssets(TotalAssets1); + system.setAvailableCapital(AvailableFunds1); + system.setMarketValue(Market_value1); + system.setCumulativeProfitAndLoss(Accumulative_total_profit_and_loss1); + system.setCumulativeIncome(Cumulative_rate_of_return1); + system.setAnnualRateOfIncome(Annualized_rate_of_return1); + system.setKamarRatio(Kumar_ratio1); + system.setSharpeRatio(Sharpe_ratio1); + system.setMaximumBacktest(The_biggest_back_test1); + system.setTotalAssetsIncome(Asset_Investment_Rate1); + system.setNetAssetsIncome(Return_on_equity1); + studentAccountMockTradingSystemService.add(system); + } + closeConn(connection1); + preparedStatement1.close(); + + } else if (applicationId == -16) { + allocationQuery.setApplicationId(Long.valueOf(-16)); + allocationQuery.setName(AccountTypeEnum.FUTURES_INVESTMENT_ACCOUNT); + + } else if (applicationId == 18) { + allocationQuery.setApplicationId(Long.valueOf(18)); + allocationQuery.setName(AccountTypeEnum.EQUITY_INVESTMENT_ACCOUNT); + + StudentAccountEquityInvestmentSystemQuery query1 = new StudentAccountEquityInvestmentSystemQuery(); + query1.setStudentId(student.getStudentId()); +// List valuesByQuery = studentAccountEquityInvestmentSystemService.getInfo(student.getStudentId()); +// if (valuesByQuery != null && valuesByQuery.size() > 0) continue; + Connection connection1 = openConn(); + String sql1 = "SELECT\n" + + " ExaPEVCAssetAllocation.Id,\n" + + " ExaPEVCAssetAllocation.ApplicationId,\n" + + " CAST(ExaPEVCAssetAllocation.InitialInvestmentCapital AS DECIMAL(18, 2)) AS InitialInvestmentCapital,\n" + + " CAST(ExaPEVCAssetAllocation.InitialCapital AS DECIMAL(18, 2)) AS InitialCapital,\n" + + " CAST(ExaPEVCAssetAllocation.TotalAssets AS DECIMAL(18, 2)) AS TotalAssets,\n" + + " CAST(ExaPEVCAssetAllocation.InvestmentFunds AS DECIMAL(18, 2)) AS InvestmentFunds,\n" + + " CAST(ExaPEVCAssetAllocation.LPAmount AS DECIMAL(18, 2)) AS LPAmount,\n" + + " CAST(ExaPEVCAssetAllocation.LPInvestmentAmount AS DECIMAL(18, 2)) AS LPInvestmentAmount,\n" + + " CAST(ExaPEVCAssetAllocation.GPInvestmentAmount AS DECIMAL(18, 2)) AS GPInvestmentAmount,\n" + + " CAST(ExaPEVCAssetAllocation.LhAmount AS DECIMAL(18, 2)) AS LhAmount,\n" + + " CAST(ExaPEVCAssetAllocation.FreeMoney AS DECIMAL(18, 2)) AS FreeMoney,\n" + + " CAST(ExaPEVCAssetAllocation.Bank_loan AS DECIMAL(18, 2)) AS Bank_loan,\n" + + " CAST(ExaPEVCAssetAllocation.BankInvestmentFunds AS DECIMAL(18, 2)) AS BankInvestmentFunds,\n" + + " CAST(ExaPEVCAssetAllocation.FreeInvestment_funds AS DECIMAL(18, 2)) AS FreeInvestment_funds,\n" + + " CAST(ExaPEVCAssetAllocation.Return_On_investment AS DECIMAL(18, 2)) AS Return_On_investment,\n" + + " CAST(ExaPEVCAssetAllocation.Return_on_net_asset_investment AS DECIMAL(18, 2)) AS Return_on_net_asset_investment,\n" + + " CAST(ExaPEVCAssetAllocation.Return_on_total_assets AS DECIMAL(18, 2)) AS Return_on_total_assets,\n" + + " ExaPEVCAssetAllocation.UserId,\n" + + " ExaPEVCAssetAllocation.IsDeleted,\n" + + " ExaPEVCAssetAllocation.DeleterUserId,\n" + + " ExaPEVCAssetAllocation.DeletionTime,\n" + + " ExaPEVCAssetAllocation.LastModificationTime,\n" + + " ExaPEVCAssetAllocation.LastModifierUserId,\n" + + " ExaPEVCAssetAllocation.CreationTime,\n" + + " ExaPEVCAssetAllocation.CreatorUserId\n" + + "FROM ExaPEVCAssetAllocation\n" + + "JOIN EduUsers ON ExaPEVCAssetAllocation.UserId = EduUsers.Id\n" + + "WHERE EduUsers.Id =" + coreUser.getOldId(); + PreparedStatement preparedStatement1 = connection1.prepareStatement(sql1); + + ResultSet resultSet1 = preparedStatement1.executeQuery(); + while (resultSet1.next()) { + StudentAccountEquityInvestmentSystem system = new StudentAccountEquityInvestmentSystem(); + BigDecimal InitialInvestmentCapital1 = resultSet1.getBigDecimal("InitialInvestmentCapital"); + BigDecimal InitialCapital1 = resultSet1.getBigDecimal("InitialCapital"); + BigDecimal TotalAssets1 = resultSet1.getBigDecimal("TotalAssets"); + BigDecimal InvestmentFunds1 = resultSet1.getBigDecimal("InvestmentFunds"); + BigDecimal LPAmount1 = resultSet1.getBigDecimal("LPAmount"); + BigDecimal LPInvestmentAmount1 = resultSet1.getBigDecimal("LPInvestmentAmount"); + BigDecimal GPInvestmentAmount1 = resultSet1.getBigDecimal("GPInvestmentAmount"); + BigDecimal LhAmount1 = resultSet1.getBigDecimal("LhAmount"); + BigDecimal FreeMoney1 = resultSet1.getBigDecimal("FreeMoney"); + BigDecimal Bank_loan1 = resultSet1.getBigDecimal("Bank_loan"); + BigDecimal BankInvestmentFunds1 = resultSet1.getBigDecimal("BankInvestmentFunds"); + BigDecimal FreeInvestment_funds1 = resultSet1.getBigDecimal("FreeInvestment_funds"); + BigDecimal Return_On_investment1 = resultSet1.getBigDecimal("Return_On_investment"); + BigDecimal Return_on_net_asset_investment1 = resultSet1.getBigDecimal("Return_on_net_asset_investment"); + BigDecimal Return_on_total_assets1 = resultSet1.getBigDecimal("Return_on_total_assets"); + + + system.setStudentId(student.getStudentId()); + system.setApplicationId(Long.valueOf(applicationId)); + system.setUniversitiesCollegesId(student.getOrgId()); + system.setState(Long.valueOf(1)); + system.setIsDel(1L); + system.setInitialCapital(InitialCapital1); + system.setInitialInvestmentCapital(InitialInvestmentCapital1); + system.setTotalCollectAssets(TotalAssets1); + system.setTotalInvestment(InvestmentFunds1); + system.setLpCollectAssets(LPAmount1); + system.setLpInvestmentAssets(LPInvestmentAmount1); + system.setGlInvestmentAssets(GPInvestmentAmount1); + system.setOwnFunds(FreeMoney1); + system.setBankLoan(Bank_loan1); + system.setBankLoanInvestment(BankInvestmentFunds1); + system.setInvestmentIncome(Return_On_investment1); + system.setNetAssetInvestmentIncome(Return_on_net_asset_investment1); + system.setTotalAssetsIncome(Return_on_total_assets1); + system.setOwnInvestmentAssets(FreeInvestment_funds1); + system.setPoorInvestmentAssets(LhAmount1); + + studentAccountEquityInvestmentSystemService.add(system); + } + + } else if (applicationName.equals("外汇投资账户")) { + allocationQuery.setApplicationId(Long.valueOf(113)); + allocationQuery.setName(AccountTypeEnum.FOREX_INVESTMENT_ACCOUNT); + } + allocationQuery.setUniversitiesCollegesId(student.getOrgId()); + allocationQuery.setState(1); + allocationQuery.setInitialCapital(applicationName.equals("外汇投资账户") ? new BigDecimal(1000000D) : BigDecimal.valueOf(initialCapital)); + allocationQuery.setAvailableFunds(applicationName.equals("外汇投资账户") ? new BigDecimal(1000000D) : BigDecimal.valueOf(AvailableFunds)); + allocationQuery.setIntoAccount(applicationId == -1 ? null : AccountTypeEnum.BANK_ACCOUNT); + allocationQuery.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); + } + connection.close(); + ps.close(); + List infoByStudentId = studentAccountAssetAllocationService.getInfoByStudentId(student.getStudentId()); + if (infoByStudentId == null || infoByStudentId.size() == 0) { + studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), coreUser.getOldId(), coreUser.getOrgId()); + } + } + } + } diff --git a/web/src/main/resources/application-dev.properties b/web/src/main/resources/application-dev.properties index 8e345e62..493278f7 100644 --- a/web/src/main/resources/application-dev.properties +++ b/web/src/main/resources/application-dev.properties @@ -6,7 +6,7 @@ springext.cache.enabled=true # \u6307\u5B9A\u4E3B\u7F13\u5B58\u5230\u671F\u65F6\u95F4\uFF0C\u5355\u4F4D\uFF08\u79D2\uFF09 springext.cache.redis.ttl=300 -spring.redis.host=localhost +spring.redis.host=118.31.7.2 spring.redis.port=6379 logging.level.root=INFO @@ -25,9 +25,9 @@ spring.datasource.dynamic.hikari.connection-test-query=SELECT 1 # master spring.datasource.dynamic.datasource.master.driverClassName=com.mysql.cj.jdbc.Driver -spring.datasource.dynamic.datasource.master.url=jdbc:mysql://124.223.219.235:3306/tzcj?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true -spring.datasource.dynamic.datasource.master.username=root -spring.datasource.dynamic.datasource.master.password=shuchuang123@. +spring.datasource.dynamic.datasource.master.url=jdbc:mysql://121.40.130.32:3306/tianze-pro?useUnicode=true&characterEncoding=utf-8&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true +spring.datasource.dynamic.datasource.master.username=tianze-pro +spring.datasource.dynamic.datasource.master.password=xYR3A4EXCWxkHmNX spring.datasource.dynamic.datasource.master.hikari.max-lifetime=60000 # ds2 diff --git a/web/src/main/resources/sql/jlw/schoolClass.md b/web/src/main/resources/sql/jlw/schoolClass.md index 0ac3a2e2..491200e2 100644 --- a/web/src/main/resources/sql/jlw/schoolClass.md +++ b/web/src/main/resources/sql/jlw/schoolClass.md @@ -253,7 +253,7 @@ SELECT class_name as name FROM school_class WHERE old_class_id = #classId# findClassesByTeacherId === -select school_class.class_id as classId,school_class.class_name as className +select school_class.old_class_id as classId,school_class.class_name as className from school_class join universities_colleges uc on school_class.universities_colleges_id = uc.universities_colleges_id join teacher t on uc.universities_colleges_id = t.universities_colleges_id diff --git a/web/src/main/resources/sql/jlw/student.md b/web/src/main/resources/sql/jlw/student.md index e6ff9ea5..a656ce6c 100644 --- a/web/src/main/resources/sql/jlw/student.md +++ b/web/src/main/resources/sql/jlw/student.md @@ -2242,4 +2242,12 @@ select student_sn as studentNo from student where class_id =#classId# findAllStudent === -select student_id as id,student_name as name,student_sn as schoolNumber,4 as roleId, old_class_id as classId from student join school_class on student.class_id = school_class.class_id \ No newline at end of file +select student_id as id,student_name as name,student_sn as schoolNumber,4 as roleId, old_class_id as classId from student join school_class on student.class_id = school_class.class_id + +getByOldId +=== +select * from student where old_id = #oldId# + +getStudentByStudentNo +=== +select * from student where student_sn =#studentNo# \ No newline at end of file diff --git a/web/src/main/resources/sql/jlw/teacher.md b/web/src/main/resources/sql/jlw/teacher.md index a023ee7c..4267500d 100644 --- a/web/src/main/resources/sql/jlw/teacher.md +++ b/web/src/main/resources/sql/jlw/teacher.md @@ -583,3 +583,15 @@ WHERE sc.universities_colleges_id = t.universities_colleges_id ) AS classIds FROM teacher t + +getByOldId +=== +select * from teacher where old_id=#oldId# + +getByTeacherSn +=== +select * from teacher where teacher_job_number =#teacherSn# + +deleteById1 +=== +delete from teacher where teacher_id = #teacherId# \ 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 a7cf6911..4eedcc8a 100644 --- a/web/src/main/resources/sql/jlw/universityFaculty.md +++ b/web/src/main/resources/sql/jlw/universityFaculty.md @@ -377,4 +377,8 @@ getAllUniversityFacultyWithColleges findByOldId === -select * from university_faculty where old_id =#oldId# \ No newline at end of file +select * from university_faculty where old_id =#oldId# + +findAll +=== + select * from university_faculty \ 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 2b4371ff..059df24b 100644 --- a/web/src/main/resources/sql/jlw/universitySystem.md +++ b/web/src/main/resources/sql/jlw/universitySystem.md @@ -378,3 +378,7 @@ university_system join university_faculty on university_system.university_facul findByOldId === select * from university_system where old_id =#oldId# + +findAll +=== + select * from university_system \ No newline at end of file