1、swagger接口文档

beetlsql3-dev
陈沅 1 year ago
parent 02a9056645
commit 4327dc7186

@ -76,7 +76,16 @@ public class SchoolClass extends BaseEntity {
@ApiModelProperty("智云2.0ID")
private Long oldClassId;
@ApiModelProperty("保险系统班级id")
private Integer icibtClassId;
public Integer getIcibtClassId() {
return icibtClassId;
}
public void setIcibtClassId(Integer icibtClassId) {
this.icibtClassId = icibtClassId;
}
public Long getOldClassId() {
return oldClassId;

@ -104,6 +104,16 @@ public class UniversitiesColleges extends BaseEntity {
return oldSchoolId;
}
private Integer icibtSchoolId;
public Integer getIcibtSchoolId() {
return icibtSchoolId;
}
public void setIcibtSchoolId(Integer icibtSchoolId) {
this.icibtSchoolId = icibtSchoolId;
}
public void setOldSchoolId(Long oldSchoolId) {
this.oldSchoolId = oldSchoolId;
}
@ -280,6 +290,8 @@ public class UniversitiesColleges extends BaseEntity {
this.userId = userId;
}
public String getUniversitiesCollegesAuthCode() {
return universitiesCollegesAuthCode;
}

@ -27,6 +27,7 @@ import com.ibeetl.jlw.entity.vo.StudentLogAnalysisVO;
import com.ibeetl.jlw.entity.vo.StudentLoginLogVO;
import com.ibeetl.jlw.entity.vo.StudentUseLogVO;
import com.ibeetl.jlw.job.CacheLogJob;
import com.ibeetl.jlw.util.HttpJsonRequest;
import com.ibeetl.jlw.web.query.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -48,6 +49,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.*;
import java.math.BigDecimal;
import java.security.MessageDigest;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.DecimalFormat;
@ -148,6 +150,8 @@ public class StudentService extends CoreBaseService<Student> {
private final ExecutorService pool = Executors.newCachedThreadPool();
@Autowired
private WebPlatformService webPlatformService;
@Autowired
private UniversitiesCollegesService universitiesCollegesService;
public PageQuery<Student> queryByCondition(PageQuery query) {
PageQuery<Student> ret = studentDao.queryByCondition(query);
@ -489,14 +493,36 @@ public class StudentService extends CoreBaseService<Student> {
}
}
public static String encryptToMD5(String input) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : messageDigest) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex).append('-');
}
hexString.deleteCharAt(hexString.length() - 1); // 移除末尾多余的连字符
return hexString.toString().toUpperCase(); // 转换为大写形式
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public Student getStudentByStudentNoAndOrgId(String studentNo, Long orgId) {
List<Student> students = studentDao.getStudentByStudentNoAndOrgId(studentNo, orgId);
if(students!=null&&students.size()>0){
if (students != null && students.size() > 0) {
return students.get(0);
}
return null;
}
public JsonResult add(@NotNull Student student) {
public JsonResult add(@NotNull Student student) {
Date date = new Date();
@ -518,17 +544,25 @@ public class StudentService extends CoreBaseService<Student> {
s.setStudentId(student.getStudentId());
s.setUserId(createdUserId);
s.setOrgId(orgId);
CoreUser user = coreUserService.getUserById(createdUserId);
try{
try {
//新建学生用户资金总表
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(),orgId);
studentAccountAssetAllocationService.createFundAccountWithUserCreated(student.getStudentId(), user.getOldId(), orgId);
}catch (Exception e){
} 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());
@ -540,6 +574,14 @@ public class StudentService extends CoreBaseService<Student> {
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':'" +
sex + "','SchoolNumber':'" + studentNo + "','RoleId':'" + 4 + "','SchoolId':'" +
icibtSchoolId + "','SchoolClassId':[" + icibtClassId + "]}";
String request = HttpJsonRequest.sendPostRequest("http://120.79.161.177:8183/SignIn/AddUser", null, PostData, "application/json");
}
public Boolean edit(Student student) {
SchoolClass schoolClass = schoolClassService.queryById(student.getClassId());
student.setOrgId(schoolClass.getOrgId());
@ -1641,25 +1683,25 @@ public class StudentService extends CoreBaseService<Student> {
return studentDao.getStudentInfoByKeyword(keyword, schoolId);
}
public PageQuery<Map<String, Object>> pagedListStudentInfoByClassId(String classIds,Integer pageNo, Integer pageSize) {
public PageQuery<Map<String, Object>> pagedListStudentInfoByClassId(String classIds, Integer pageNo, Integer pageSize) {
PageQuery pageQuery = new PageQuery();
pageQuery.setPageSize(pageSize);
pageQuery.setPageNumber(pageNo);
Map<String,Object> map = new HashMap<>();
map.put("classIds",classIds);
Map<String, Object> map = new HashMap<>();
map.put("classIds", classIds);
pageQuery.setParas(map);
return studentDao.pagedListStudentInfoByClassId(pageQuery);
}
public List<Map<String,Object>> findAllBySchoolId(Long schoolId) {
public List<Map<String, Object>> findAllBySchoolId(Long schoolId) {
List<Map<String, Object>> mapList = studentDao.findAllBySchoolId(schoolId);
List<Map<String,Object>> dataList = new ArrayList<>();
List<Map<String, Object>> dataList = new ArrayList<>();
//将内部元素弄成驼峰
for (Map<String, Object> map : mapList) {
Map<String,Object> data= new HashMap<>();
data.put("studentNo",map.get("studentno"));
data.put("name",map.get("name"));
data.put("classId",map.get("classid"));
Map<String, Object> data = new HashMap<>();
data.put("studentNo", map.get("studentno"));
data.put("name", map.get("name"));
data.put("classId", map.get("classid"));
dataList.add(data);
}
return dataList;
@ -1669,16 +1711,16 @@ public class StudentService extends CoreBaseService<Student> {
return studentDao.findStudentNoByClassId(classId);
}
public List<Student> getAll(){
public List<Student> getAll() {
return studentDao.all();
}
//查询没有基础资金的学生账号
public List<Student> getNoBaseStudent(){
return studentDao.getNoBaseStudent();
public List<Student> getNoBaseStudent() {
return studentDao.getNoBaseStudent();
}
public List<Map<String,Object>> findAllStudent(){
return studentDao.findAllStudent();
public List<Map<String, Object>> findAllStudent() {
return studentDao.findAllStudent();
}
}

@ -24,6 +24,7 @@ import com.ibeetl.jlw.dao.UniversitiesCollegesDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.TeacherBatchImportAdminDTO;
import com.ibeetl.jlw.job.CacheLogJob;
import com.ibeetl.jlw.util.HttpJsonRequest;
import com.ibeetl.jlw.web.query.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -50,6 +51,7 @@ import javax.validation.constraints.NotBlank;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
@ -251,6 +253,27 @@ public class TeacherService extends CoreBaseService<Teacher> {
return null;
}
public static String encryptToMD5(String input) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] messageDigest = md.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : messageDigest) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex).append('-');
}
hexString.deleteCharAt(hexString.length() - 1); // 移除末尾多余的连字符
return hexString.toString().toUpperCase(); // 转换为大写形式
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public JsonResult add(Teacher teacher) {
Date date = new Date();
@ -274,6 +297,11 @@ public class TeacherService extends CoreBaseService<Teacher> {
t.setUserId(createdUserId);
t.setOrgId(orgId);
Integer icibtSchoolId = universitiesColleges.getIcibtSchoolId();
if(icibtSchoolId!=null){
createBxStudent(icibtSchoolId, teacher.getTeacherSn(), teacher.getTeacherName(), 1);
}
this.updateTemplate(t);
JsonResult jsonResult = new JsonResult();
@ -288,6 +316,13 @@ public class TeacherService extends CoreBaseService<Teacher> {
}
public void createBxStudent(Integer icibtSchoolId,String studentNo, String name, Integer sex) {
String PostData = "{'LoginName':'" + studentNo + "','Password':'" +
encryptToMD5("123qwe") + "','Name':'" + name + "','Sex':'" +
sex + "','SchoolNumber':'" + studentNo + "','RoleId':'" + 3 + "','SchoolId':'" +
icibtSchoolId + "'}";
String request = HttpJsonRequest.sendPostRequest("http://120.79.161.177:8183/SignIn/AddUser", null, PostData, "application/json");
}
public Boolean edit(Teacher teacher) {
this.updateTemplate(teacher);

@ -7,6 +7,7 @@ import cn.hutool.core.util.RandomUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.extra.validation.BeanValidationResult;
import cn.hutool.extra.validation.ValidationUtil;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.console.service.OrgConsoleService;
import com.ibeetl.admin.core.entity.CoreOrg;
import com.ibeetl.admin.core.entity.CoreUser;
@ -16,8 +17,11 @@ import com.ibeetl.admin.core.service.CoreUserService;
import com.ibeetl.jlw.dao.UniversitiesCollegesDao;
import com.ibeetl.jlw.entity.*;
import com.ibeetl.jlw.entity.dto.CreateUserDTO;
import com.ibeetl.jlw.util.BxJDBCUtil;
import com.ibeetl.jlw.util.HttpJsonRequest;
import com.ibeetl.jlw.web.query.SchoolClassQuery;
import com.ibeetl.jlw.web.query.UniversitiesCollegesQuery;
import jodd.http.HttpUtil;
import org.beetl.sql.core.SqlId;
import org.beetl.sql.core.engine.PageQuery;
import org.beetl.sql.core.query.LambdaQuery;
@ -28,12 +32,15 @@ import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.hutool.core.collection.CollUtil.getFirst;
import static com.aspose.pdf.printing.PrinterPaperKind.Statement;
import static com.ibeetl.admin.core.enums.MenuEnums.JT_01;
import static com.ibeetl.admin.core.enums.MenuEnums.JT_S_04;
import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
@ -45,28 +52,34 @@ import static com.ibeetl.admin.core.util.user.CacheUserUtil.getUser;
@Service
@Transactional
@Validated
public class UniversitiesCollegesService extends CoreBaseService<UniversitiesColleges>{
public class UniversitiesCollegesService extends CoreBaseService<UniversitiesColleges> {
@Autowired private UniversitiesCollegesDao universitiesCollegesDao;
@Autowired
private UniversitiesCollegesDao universitiesCollegesDao;
@Autowired private SchoolClassService schoolClassService;
@Autowired private OrgConsoleService orgConsoleService;
@Autowired private CoreUserService coreUserService;
@Autowired private WebPlatformService webPlatformService;
@Autowired private CorePlatformService corePlatformService;
@Autowired
private SchoolClassService schoolClassService;
@Autowired
private OrgConsoleService orgConsoleService;
@Autowired
private CoreUserService coreUserService;
@Autowired
private WebPlatformService webPlatformService;
@Autowired
private CorePlatformService corePlatformService;
@Autowired
private SysLogService sysLogService;
public PageQuery<UniversitiesColleges>queryByCondition(PageQuery query){
PageQuery ret = universitiesCollegesDao.queryByCondition(query);
public PageQuery<UniversitiesColleges> queryByCondition(PageQuery query) {
PageQuery ret = universitiesCollegesDao.queryByCondition(query);
queryListAfter(ret.getList());
return ret;
}
public void deleteUniversitiesColleges(String ids){
public void deleteUniversitiesColleges(String ids) {
universitiesCollegesDao.deleteUniversitiesCollegesByIds(ids);
for(int i=0;i<ids.split(",").length;i++){
for (int i = 0; i < ids.split(",").length; i++) {
final UniversitiesColleges universitiesColleges = this.queryById(Long.parseLong(ids.split(",")[i]));
Long orgId = universitiesColleges.getOrgId();
@ -74,8 +87,8 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
CoreOrg coreOrg = new CoreOrg();
coreOrg.setId(orgId);
coreOrg.setName(universitiesColleges.getUniversitiesCollegesName());
coreOrg.setCode("u_"+universitiesColleges.getUniversitiesCollegesId());
coreOrg.setDelFlag(((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())?0:1);
coreOrg.setCode("u_" + universitiesColleges.getUniversitiesCollegesId());
coreOrg.setDelFlag(((Integer) 1).equals(universitiesColleges.getUniversitiesCollegesStatus()) ? 0 : 1);
orgConsoleService.updateTemplate(coreOrg);
}
@ -89,7 +102,7 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
CoreUser user = new CoreUser();
user.setId(item.getId());
user.setCode("del_" + item.getCode());
user.setDelFlag(((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())?0:1);
user.setDelFlag(((Integer) 1).equals(universitiesColleges.getUniversitiesCollegesStatus()) ? 0 : 1);
return user;
}).collect(Collectors.toList());
@ -99,12 +112,12 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
corePlatformService.clearDictCache();
}
public boolean add(UniversitiesColleges universitiesColleges){
public boolean add(UniversitiesColleges universitiesColleges) {
universitiesCollegesDao.insert(universitiesColleges);
CoreOrg coreOrg = new CoreOrg();
coreOrg.setName(universitiesColleges.getUniversitiesCollegesName());
coreOrg.setCode("u_"+universitiesColleges.getUniversitiesCollegesId());
coreOrg.setCode("u_" + universitiesColleges.getUniversitiesCollegesId());
coreOrg.setType("ORGT1");
coreOrg.setParentOrgId(1L);
coreOrg.setDelFlag(0);
@ -119,7 +132,7 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
u.setOrgId(coreOrg.getId());
// 三位数字+三个小写字母. 组成的授权动态码
u.setUniversitiesCollegesAuthCode(RandomUtil.randomString(6));
u.setOldSchoolId(universitiesColleges.getUniversitiesCollegesId()+500);
u.setOldSchoolId(universitiesColleges.getUniversitiesCollegesId() + 500);
universitiesCollegesDao.updateTemplateById(u);
universitiesColleges.setUniversitiesCollegesAuthCode(u.getUniversitiesCollegesAuthCode());
@ -138,27 +151,43 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
public void addAndCreateCoreUser(UniversitiesColleges universitiesColleges, CreateUserDTO dto) {
// 添加院校信息,添加机构信息,修改院校的授权码
add(universitiesColleges);
// 验证 javax.validation.constraints注解
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(dto);
// 验证通过,代表是要创建院校管理员身份的用户。
// 这里不抛出异常,如果没有验证通过,则不新增用户
if(beanValidationResult.isSuccess()) {
if (beanValidationResult.isSuccess()) {
// 默认创建院校管理员权限的用户
Long defaultAdminUserId = webPlatformService.createUserWithRole(dto.getUserCode(), dto.getPassword(), universitiesColleges.getOrgId(), JT_01, JT_S_04);
//保险系统同步新增学校数据
String schoolName = universitiesColleges.getUniversitiesCollegesName();
int icibtSchoolId = createBxSchool(schoolName);
if (icibtSchoolId == 0) throw new IllegalArgumentException("新增院校异常");
// 用户添加成功后将用户ID 回传给该学校的默认管理员字段
UniversitiesColleges u = new UniversitiesColleges();
u.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
u.setUniversitiesCollegesDefaultAdminUserId(defaultAdminUserId);
u.setIcibtSchoolId(icibtSchoolId);
universitiesCollegesDao.updateTemplateById(u);
}
corePlatformService.clearDictCache();
}
public boolean edit(UniversitiesColleges universitiesColleges){
private int createBxSchool(String schoolName) {
String request = HttpJsonRequest.sendPostRequest("http://120.79.161.177:8183/SignIn/AddSchool", null, "{'SchoolName':'" + schoolName + "'}", "application/json");
JSONObject jsonObject = JSONObject.parseObject(request);
String schoolId = jsonObject.getString("schoolId");
if(schoolId!=null){
return Integer.parseInt(schoolId);
}else{
return 0;
}
}
public boolean edit(UniversitiesColleges universitiesColleges) {
universitiesCollegesDao.updateTemplateById(universitiesColleges);
@ -167,8 +196,8 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
CoreOrg coreOrg = new CoreOrg();
coreOrg.setId(universitiesColleges.getOrgId());
coreOrg.setName(universitiesColleges.getUniversitiesCollegesName());
coreOrg.setCode("u_"+universitiesColleges.getUniversitiesCollegesId());
coreOrg.setDelFlag(((Integer)1).equals(universitiesColleges.getUniversitiesCollegesStatus())?0:1);
coreOrg.setCode("u_" + universitiesColleges.getUniversitiesCollegesId());
coreOrg.setDelFlag(((Integer) 1).equals(universitiesColleges.getUniversitiesCollegesStatus()) ? 0 : 1);
orgConsoleService.updateTemplate(coreOrg);
corePlatformService.clearDictCache();
@ -176,15 +205,15 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
}
public UniversitiesColleges getByOrgId (Long orgId){
public UniversitiesColleges getByOrgId(Long orgId) {
return universitiesCollegesDao.getByOrgId(orgId);
}
public List<UniversitiesColleges> getValues (Object paras){
return sqlManager.select(SqlId.of("jlw.universitiesColleges.getUniversitiesCollegesValues"),UniversitiesColleges.class,paras);
public List<UniversitiesColleges> getValues(Object paras) {
return sqlManager.select(SqlId.of("jlw.universitiesColleges.getUniversitiesCollegesValues"), UniversitiesColleges.class, paras);
}
public List<UniversitiesColleges> getValuesByQuery(UniversitiesCollegesQuery universitiesCollegesQuery){
public List<UniversitiesColleges> getValuesByQuery(UniversitiesCollegesQuery universitiesCollegesQuery) {
List<UniversitiesColleges> universitiesCollegesList = universitiesCollegesDao.getValuesByQuery(universitiesCollegesQuery);
@ -193,16 +222,17 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
List<SchoolClass> schoolClassList = schoolClassService.getValuesByQuery(schoolClassQuery);
Map<Long, List<SchoolClass>> groupByUniversitiesCollegesId = null;
try{
try {
groupByUniversitiesCollegesId = schoolClassList.stream().collect(Collectors.groupingBy(e -> e.getUniversitiesCollegesId()));
}catch (Exception e){}
} catch (Exception e) {
}
for(int i=0;i<universitiesCollegesList.size();i++){
for (int i = 0; i < universitiesCollegesList.size(); i++) {
Long universitiesCollegesId = universitiesCollegesList.get(i).getUniversitiesCollegesId();
if(null != groupByUniversitiesCollegesId){
universitiesCollegesList.get(i).set("children",groupByUniversitiesCollegesId.get(universitiesCollegesId));
}else {
universitiesCollegesList.get(i).set("children",null);
if (null != groupByUniversitiesCollegesId) {
universitiesCollegesList.get(i).set("children", groupByUniversitiesCollegesId.get(universitiesCollegesId));
} else {
universitiesCollegesList.get(i).set("children", null);
}
}
@ -222,6 +252,7 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
/**
*
*
* @return
*/
public UniversitiesCollegesUserInfo userCenter() {
@ -253,12 +284,13 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
/**
*
* @param universitiesCollegesId ID
* @param universitiesCollegesAuthCode
*
* @param universitiesCollegesId ID
* @param universitiesCollegesAuthCode
* @return
*/
public boolean verifyUniAuthCode(@NotNull(message="院校ID不能为空") Long universitiesCollegesId,
@NotEmpty(message="院校授权码不能为空!") String universitiesCollegesAuthCode) {
public boolean verifyUniAuthCode(@NotNull(message = "院校ID不能为空") Long universitiesCollegesId,
@NotEmpty(message = "院校授权码不能为空!") String universitiesCollegesAuthCode) {
return universitiesCollegesDao.createLambdaQuery()
.andEq(UniversitiesColleges::getUniversitiesCollegesStatus, 1)
.andEq(UniversitiesColleges::getUniversitiesCollegesId, universitiesCollegesId)
@ -266,8 +298,8 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
.count() > 0;
}
public void verifyUniAuthCodeThrows(@NotNull(message="院校ID不能为空") Long universitiesCollegesId,
@NotEmpty(message="院校授权码不能为空!") String universitiesCollegesAuthCode) {
public void verifyUniAuthCodeThrows(@NotNull(message = "院校ID不能为空") Long universitiesCollegesId,
@NotEmpty(message = "院校授权码不能为空!") String universitiesCollegesAuthCode) {
boolean verifyUniAuthCode = verifyUniAuthCode(universitiesCollegesId, universitiesCollegesAuthCode);
Assert.isTrue(verifyUniAuthCode, "院校授权码,验证失败!");
}
@ -302,6 +334,7 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
/**
*
*
* @param teacher
* @return
*/
@ -334,6 +367,13 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
return getFirst(getValuesByQuery(query));
}
public UniversitiesColleges getById(Long id) {
UniversitiesCollegesQuery query = new UniversitiesCollegesQuery();
query.setUniversitiesCollegesStatus(1);
query.setUniversitiesCollegesId(id);
return getFirst(getValuesByQuery(query));
}
public UniversitiesColleges getByNameOrCreate(String name) {
UniversitiesColleges universitiesColleges = getByName(name);
@ -358,11 +398,11 @@ public class UniversitiesCollegesService extends CoreBaseService<UniversitiesCol
}
public List<Map<String,Object>> findAll(){
return universitiesCollegesDao.findAllUniversitiesColleges();
public List<Map<String, Object>> findAll() {
return universitiesCollegesDao.findAllUniversitiesColleges();
}
public List<UniversitiesColleges> getAll(){
return universitiesCollegesDao.getAll();
public List<UniversitiesColleges> getAll() {
return universitiesCollegesDao.getAll();
}
}

@ -0,0 +1,40 @@
package com.ibeetl.jlw.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class BxJDBCUtil {
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=ICIBT1.1.1;trustServerCertificate=true;encrypt=true";
private static final String USER = "sa";
private static final String PASSWORD = "sztzjy@2017";
// 打开数据库连接
public static Connection openConn() throws SQLException {
try {
Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
if (connection != null) {
System.out.println("成功建立数据库连接");
return connection;
} else {
throw new SQLException("无法建立数据库连接");
}
} catch (SQLException e) {
throw new SQLException("无法建立数据库连接: " + e.getMessage(), e);
}
}
// 关闭数据库连接
public static void closeConn(Connection connection) {
if (connection != null) {
try {
connection.close();
System.out.println("数据库连接已关闭");
} catch (SQLException e) {
System.err.println("无法关闭数据库连接: " + e.getMessage());
}
}
}
}

@ -7,8 +7,10 @@ import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
@Slf4j
public class HttpJsonRequest {
@ -45,4 +47,43 @@ public class HttpJsonRequest {
JSONObject jsonObject = new JSONObject(jsonResponse);
return jsonObject.getJSONArray("data");
}
public static String sendPostRequest(String urlString, String authorizationHeader, String postData,String contentType) {
StringBuilder response = new StringBuilder();
try {
URL url = new URL(urlString);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
// Set up the connection for POST
con.setRequestMethod("POST");
// con.setRequestProperty("Authorization", authorizationHeader);
con.setRequestProperty("Content-Type", contentType);
con.setDoOutput(true);
// Write the data to the connection
try (OutputStream os = con.getOutputStream()) {
byte[] postDataBytes = postData.getBytes(StandardCharsets.UTF_8);
os.write(postDataBytes);
os.flush();
}
int responseCode = con.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
} else {
log.info("-----------------send接口请求失败-------" + responseCode);
throw new IllegalArgumentException("HTTP POST request failed with response code: " + responseCode);
}
} catch (Exception e) {
e.printStackTrace();
}
return response.toString();
}
}

@ -0,0 +1,39 @@
package com.ibeetl.jlw.util;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class ZhiYunJDBCUtil {
private final static String URL = "jdbc:sqlserver://120.79.161.177:1433;databaseName=Test.Zhiyun_v2.0;trustServerCertificate=true;encrypt=true";
private static final String USER = "sa";
private static final String PASSWORD = "sztzjy@2017";
// 打开数据库连接
public static Connection openConn() throws SQLException {
try {
Connection connection = DriverManager.getConnection(URL, USER, PASSWORD);
if (connection != null) {
System.out.println("成功建立数据库连接");
return connection;
} else {
throw new SQLException("无法建立数据库连接");
}
} catch (SQLException e) {
throw new SQLException("无法建立数据库连接: " + e.getMessage(), e);
}
}
// 关闭数据库连接
public static void closeConn(Connection connection) {
if (connection != null) {
try {
connection.close();
System.out.println("数据库连接已关闭");
} catch (SQLException e) {
System.err.println("无法关闭数据库连接: " + e.getMessage());
}
}
}
}

@ -921,13 +921,14 @@ public class AccountController {
@PostMapping("updateUserId.json")
public JsonResult updateUserId() throws SQLException {
CoreUser coreUser = new CoreUser();
coreUser.setOrgId(248L);
List<CoreUser> coreUsers = userService.getCoreUserList(coreUser);
int i = 0;
for (CoreUser user : coreUsers) {
System.out.println("已完成:" + i++);
if (user.getOldId() != null) {
continue;
}
// if (user.getOldId() != null) {
// continue;
// }
Connection conn = openConn();
PreparedStatement ps = conn.prepareStatement("select * from EduUsers where username = '" + user.getCode() + "' and IsDeleted = 0");
@ -946,7 +947,7 @@ public class AccountController {
@ApiOperation("修改用户表userid")
@PostMapping("updateUserIdAndOldIdIsNull.json")
public JsonResult updateUserIdAndOldIdIsNull() throws SQLException {
public JsonResult updateUserIdAndOldIdIsNull() {
CoreUser coreUser = new CoreUser();
List<CoreUser> coreUsers = userService.getCoreUserListAndOldIdIsNull();
int i = 0;

@ -8,6 +8,7 @@ import cn.jlw.Interceptor.SCoreUser;
import cn.jlw.util.excel.ExcelUtil;
import cn.jlw.util.excel.listener.MyValidateExcelCellDataListener;
import cn.jlw.validate.ValidateConfig;
import com.alibaba.fastjson.JSONObject;
import com.ibeetl.admin.core.annotation.Function;
import com.ibeetl.admin.core.entity.CoreUser;
import com.ibeetl.admin.core.file.FileService;
@ -22,6 +23,7 @@ import com.ibeetl.jlw.entity.dto.SchoolClassBatchImportDTO;
import com.ibeetl.jlw.service.SchoolClassService;
import com.ibeetl.jlw.service.UniversitiesCollegesService;
import com.ibeetl.jlw.service.UniversitySystemService;
import com.ibeetl.jlw.util.HttpJsonRequest;
import com.ibeetl.jlw.web.query.SchoolClassQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -64,14 +66,20 @@ public class SchoolClassController extends BaseController {
private static final String API = "/api/schoolClass";
@Autowired private SchoolClassService schoolClassService;
@Autowired
private SchoolClassService schoolClassService;
@Autowired private UniversitiesCollegesService universitiesCollegesService;
@Autowired private UniversitiesCollegesDao universitiesCollegesDao;
@Autowired
private UniversitiesCollegesService universitiesCollegesService;
@Autowired
private UniversitiesCollegesDao universitiesCollegesDao;
@Autowired private UniversitySystemService systemService;
@Autowired private CorePlatformService corePlatformService;
@Autowired private CoreUserService coreUserService;
@Autowired
private UniversitySystemService systemService;
@Autowired
private CorePlatformService corePlatformService;
@Autowired
private CoreUserService coreUserService;
@Autowired
FileService fileService;
@ -85,17 +93,17 @@ public class SchoolClassController extends BaseController {
if (null != coreUser && !coreUser.isAdmin()) {
condition.setOrgId(coreUser.getOrgId());
}
List<SchoolClass>list = schoolClassService.getValuesByQueryNotWithPermission(condition);
return JsonResult.success(list);
List<SchoolClass> list = schoolClassService.getValuesByQueryNotWithPermission(condition);
return JsonResult.success(list);
}
@GetMapping(API + "/getListWithLogin.do")
@ResponseBody
@ApiOperation("列表")
public JsonResult<List<SchoolClass>> getListWithLogin(SchoolClassQuery param, @SCoreUser CoreUser coreUser) {
List<SchoolClass>list = schoolClassService.getValues(param);
return JsonResult.success(list);
List<SchoolClass> list = schoolClassService.getValues(param);
return JsonResult.success(list);
}
@ -106,9 +114,9 @@ public class SchoolClassController extends BaseController {
@ResponseBody
@ApiOperation("后台系统管理界面")
public ModelAndView index(@SCoreUser CoreUser coreUser) {
ModelAndView view = new ModelAndView("/jlw/schoolClass/index.html") ;
ModelAndView view = new ModelAndView("/jlw/schoolClass/index.html");
view.addObject("search", SchoolClassQuery.class.getName());
view.addObject("beTeacher",null != coreUser && "JT_S_02".equals(coreUser.getJobType1())?1:2);//是否是教师 1是 2否
view.addObject("beTeacher", null != coreUser && "JT_S_02".equals(coreUser.getJobType1()) ? 1 : 2);//是否是教师 1是 2否
return view;
}
@ -129,7 +137,7 @@ public class SchoolClassController extends BaseController {
@ApiOperation("后台系统管理界面-添加")
public ModelAndView add(Long classId, @SCoreUser CoreUser coreUser) {
ModelAndView view = new ModelAndView("/jlw/schoolClass/add.html");
if(classId != null) {
if (classId != null) {
SchoolClass schoolClass = schoolClassService.queryById(classId);
view.addObject("schoolClass", defaultIfNull(schoolClass, new SchoolClass()));
@ -138,9 +146,9 @@ public class SchoolClassController extends BaseController {
info = systemService.getInfo(schoolClass.getUniversitySystemId());
}
view.addObject("universityFacultyId", defaultIfNull(info, new UniversitySystem()).getUniversityFacultyId());
}else {
view.addObject("schoolClass",new SchoolClass());
view.addObject("universityFacultyId","");
} else {
view.addObject("schoolClass", new SchoolClass());
view.addObject("universityFacultyId", "");
}
// 如果是学校管理员则查询所在院校的信息
@ -149,7 +157,7 @@ public class SchoolClassController extends BaseController {
view.addObject("universitiesCollegesInfo", universitiesColleges);
}
view.addObject("beTeacher",null != coreUser && "JT_S_02".equals(coreUser.getJobType1())?1:2);//是否是教师 1是 2否
view.addObject("beTeacher", null != coreUser && "JT_S_02".equals(coreUser.getJobType1()) ? 1 : 2);//是否是教师 1是 2否
return view;
}
@ -169,17 +177,17 @@ public class SchoolClassController extends BaseController {
@Function("schoolClass.query")
@ResponseBody
@ApiOperation("分页列表")
public JsonResult<PageQuery> list(SchoolClassQuery condition,@SCoreUser CoreUser coreUser){
public JsonResult<PageQuery> list(SchoolClassQuery condition, @SCoreUser CoreUser coreUser) {
PageQuery page = condition.getPageQuery();
schoolClassService.queryByCondition(page);
if (!coreUser.isAdmin()) {
condition.setOrgId(coreUser.getOrgId());
}
Map<String,Object>map = new HashMap<>();
map.put("count",page.getTotalRow());
map.put("data",page.getList());
map.put("beTeacher",null != coreUser && "JT_S_02".equals(coreUser.getJobType1())?1:2);//是否是教师 1是 2否
Map<String, Object> map = new HashMap<>();
map.put("count", page.getTotalRow());
map.put("data", page.getList());
map.put("beTeacher", null != coreUser && "JT_S_02".equals(coreUser.getJobType1()) ? 1 : 2);//是否是教师 1是 2否
return JsonResult.successMap(map);
}
@ -188,15 +196,15 @@ public class SchoolClassController extends BaseController {
@Function("schoolClass.add")
@ResponseBody
@ApiOperation("添加")
public JsonResult add(@Validated(ValidateConfig.ADD.class)SchoolClass schoolClass, BindingResult result, @SCoreUser CoreUser coreUser){
if(result.hasErrors()){
public JsonResult add(@Validated(ValidateConfig.ADD.class) SchoolClass schoolClass, BindingResult result, @SCoreUser CoreUser coreUser) {
if (result.hasErrors()) {
return JsonResult.failMessage(result);
}else{
} else {
schoolClass.setAddTime(new Date());
schoolClass.setClassStatus(1);
schoolClass.setUserId(coreUser.getId());
if(null != schoolClass.getUniversitiesCollegesId()){
Integer icibtClassId = 0;
if (null != schoolClass.getUniversitiesCollegesId()) {
UniversitiesColleges universitiesColleges = universitiesCollegesService.queryById(schoolClass.getUniversitiesCollegesId());
String uniqueClassSn = schoolClassService.buildClassSnEnsureUnique(universitiesColleges, schoolClass.getClassName());
schoolClass.setClassSn(uniqueClassSn);
@ -204,42 +212,56 @@ public class SchoolClassController extends BaseController {
// 判断班级编号是否已经存在,并抛出异常
// 如果院校ID不为空则验证方法的区域缩减到院校级别的。不使用全表验证了
if(StrUtil.isNotBlank(schoolClass.getClassSn())) {
if (StrUtil.isNotBlank(schoolClass.getClassSn())) {
schoolClassService.validateClassSnListIsExistsThrow(Collections.singletonList(schoolClass), universitiesColleges.getOrgId().toString());
}
}
else {
icibtClassId = createBxClass(schoolClass.getClassName(), universitiesColleges.getIcibtSchoolId());
} else {
UniversitiesColleges universitiesColleges = new UniversitiesColleges();
universitiesColleges.setOrgId(coreUser.getOrgId());
List<UniversitiesColleges> universitiesCollegesList = universitiesCollegesService.getValues(universitiesColleges);
if(universitiesCollegesList.size() > 0){
if (universitiesCollegesList.size() > 0) {
universitiesColleges = universitiesCollegesList.get(0);
String uniqueClassSn = schoolClassService.buildClassSnEnsureUnique(universitiesColleges, schoolClass.getClassName());
schoolClass.setClassSn(uniqueClassSn);
schoolClass.setUniversitiesCollegesId(universitiesColleges.getUniversitiesCollegesId());
schoolClass.setOrgId(universitiesColleges.getOrgId());
icibtClassId = createBxClass(schoolClass.getClassName(), universitiesColleges.getIcibtSchoolId());
}
}
schoolClassService.save(schoolClass);
SchoolClass newClass = new SchoolClass();
newClass.setIcibtClassId(icibtClassId);
newClass.setClassId(schoolClass.getClassId());
newClass.setOldClassId(1500+newClass.getClassId());
newClass.setOldClassId(1500 + newClass.getClassId());
schoolClassService.updateTemplate(newClass);
corePlatformService.clearDictCache();
return JsonResult.success();
}
}
private int createBxClass(String className, Integer icibtSchoolId) {
String request = HttpJsonRequest.sendPostRequest("http://120.79.161.177:8183/SignIn/AddClass", null, "{'ClassName':'" + className + "','SchoolId': " + icibtSchoolId + "}", "application/json");
JSONObject jsonObject = JSONObject.parseObject(request);
String schoolId = jsonObject.getString("schoolClassId");
if (schoolId != null) {
return Integer.parseInt(schoolId);
} else {
return 0;
}
}
@PostMapping(MODEL + "/edit.json")
@Function("schoolClass.edit")
@ResponseBody
@ApiOperation("编辑")
public JsonResult<String> update(@Validated(ValidateConfig.UPDATE.class) SchoolClass schoolClass, BindingResult result) {
if(result.hasErrors()){
public JsonResult<String> update(@Validated(ValidateConfig.UPDATE.class) SchoolClass schoolClass, BindingResult result) {
if (result.hasErrors()) {
return JsonResult.failMessage(result);
}else {
} else {
schoolClass.setUserId(null);
schoolClass.setOrgId(null);
schoolClass.setAddTime(null);
@ -253,25 +275,25 @@ public class SchoolClassController extends BaseController {
}
}
@GetMapping(MODEL + "/view.json")
@Function("schoolClass.query")
@ResponseBody
@ApiOperation("根据ID获取数据")
public JsonResult<SchoolClass>queryInfo(Long classId) {
SchoolClass schoolClass = schoolClassService.queryById( classId);
return JsonResult.success(schoolClass);
public JsonResult<SchoolClass> queryInfo(Long classId) {
SchoolClass schoolClass = schoolClassService.queryById(classId);
return JsonResult.success(schoolClass);
}
@GetMapping(MODEL + "/getValues.json")
@ResponseBody
@ApiOperation("列表")
public JsonResult<List<SchoolClass>>getValues(SchoolClassQuery condition, @SCoreUser CoreUser coreUser) {
public JsonResult<List<SchoolClass>> getValues(SchoolClassQuery condition, @SCoreUser CoreUser coreUser) {
if (!coreUser.isAdmin()) {
condition.setOrgId(coreUser.getOrgId());
}
List<SchoolClass>list = schoolClassService.getValues(condition);
return JsonResult.success(list);
List<SchoolClass> list = schoolClassService.getValues(condition);
return JsonResult.success(list);
}
@ -287,7 +309,8 @@ public class SchoolClassController extends BaseController {
/**
*
* @param prefix
*
* @param prefix
* @return
*/
@GetMapping(MODEL + "/randomClassSn.json")
@ -299,6 +322,7 @@ public class SchoolClassController extends BaseController {
/**
*
*
* @return
*/
@SneakyThrows
@ -320,7 +344,8 @@ public class SchoolClassController extends BaseController {
/**
* : <br>
*
* excel
* excel
*
* @param file
* @return {@link JsonResult}
* @Author: 87966
@ -364,8 +389,7 @@ public class SchoolClassController extends BaseController {
listener.putFailMessage(StrUtil.format("异常的院校ID{},该院校已删除状态", e.getUniversitiesCollegesId()));
}
return sc.getOrgId();
}
else {
} else {
listener.putFailMessage(StrUtil.format("异常的院校ID{},未查询到院校信息,请联系管理员", e.getUniversitiesCollegesId()));
}
return null;
@ -373,19 +397,16 @@ public class SchoolClassController extends BaseController {
try {
schoolClassService.validateClassSnListIsExistsThrow(list, list.get(0).getOrgId().toString());
}
catch (IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
listener.putFailMessage(e.getMessage());
}
catch (Exception e) { }
finally {
} catch (Exception e) {
} finally {
// 再次判断错误的结果集
Assert.isTrue(CollectionUtil.isEmpty(listener.getFailMessage()), JSONUtil.toJsonStr(listener.getFailMessage()));
}
schoolClassService.insertBatch(list);
}
catch (IllegalArgumentException exception) {
} catch (IllegalArgumentException exception) {
return JsonResult.failMessage(exception.getMessage()).setCode(DIY_ERROR.getCode());
}

@ -68,6 +68,16 @@ public class UniversitiesCollegesQuery extends PageParam {
@ApiModelProperty("结束时间")
private Date endTime;
@ApiModelProperty("保险院校id")
private Integer icibtSchoolId;
public Integer getIcibtSchoolId() {
return icibtSchoolId;
}
public void setIcibtSchoolId(Integer icibtSchoolId) {
this.icibtSchoolId = icibtSchoolId;
}
public Long getUniversitiesCollegesId(){
return universitiesCollegesId;
@ -163,6 +173,7 @@ public class UniversitiesCollegesQuery extends PageParam {
pojo.setAddTime(this.getAddTime());
pojo.setOrgId(this.getOrgId());
pojo.setUserId(this.getUserId());
pojo.setIcibtSchoolId(this.icibtSchoolId);
return pojo;
}

Loading…
Cancel
Save