diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index b46d3eb..71794cf 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -5,9 +5,12 @@ import java.util.*; import cn.hutool.core.util.IdUtil; import com.ruoyi.biemo.business.domain.ZYUserInfo; import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.SysDeptMapper; import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserRoleMapper; import com.ruoyi.web.config.exception.UnAuthorizedException; @@ -18,6 +21,7 @@ import com.ruoyi.web.util.RsaUtil; import com.ruoyi.web.util.TzApi; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import io.swagger.models.auth.In; import org.apache.catalina.User; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -67,6 +71,9 @@ public class SysLoginController { @Resource private AuthenticationManagerBuilder authenticationManagerBuilder; + @Autowired + private SysDeptMapper sysDeptMapper; + /** * 登录方法 @@ -79,6 +86,8 @@ public class SysLoginController { public AjaxResult login(@RequestBody(required = false) LoginBody loginBody, @RequestParam(required = false) String TOKEN) { + //todo user表中的deptId等于classId + if (StringUtils.isBlank(TOKEN)) { String username = loginBody.getUsername(); SysUser sysUser = sysUserMapper.selectUserByStudentNumber(username); @@ -123,12 +132,18 @@ public class SysLoginController { String tokenWbdsj = loginService.login(sysUser.getUserName(), "123456", "1", String.valueOf(UUID.randomUUID())); ajax.put(Constants.TOKEN, tokenWbdsj); - ajax.put("deptId",sysUser.getDeptId()); + ajax.put("deptId",sysUser.getDeptId()); //班级ID ajax.put("UserId",sysUser.getUserId()); + + SysDept sysDept = sysDeptMapper.selectDeptById(sysUser.getDeptId()); + Long parentId = sysDept.getParentId(); + ajax.put("schoolId",parentId.toString()); //学校ID return ajax; } } + + //todo 多加一个deptId /** * 获取用户信息 * @@ -142,9 +157,11 @@ public class SysLoginController { // 权限集合 Set permissions = permissionService.getMenuPermission(user); AjaxResult ajax = AjaxResult.success(); + Long deptId = user.getDeptId(); ajax.put("user", user); ajax.put("roles", roles); ajax.put("permissions", permissions); + ajax.put("deptId",deptId); //这是班级ID return ajax; } @@ -169,43 +186,111 @@ public class SysLoginController { return AjaxResult.success(menuService.buildMenus(menus)); } -// @ApiOperation("根据用户Code查询该用户是否存在个人赛用户数据,存在则返回,不存在则新增后返回,用于智云3.0创建用户后调用该接口创建用户个人赛") -// @PostMapping("/checkOrCreateForexSimulationUser") -// public String checkOrCreateForexSimulationUser(@RequestBody List zyUserInfoList, -// @RequestParam String systemOwner) { -// System.out.println(systemOwner); -// List users = new ArrayList<>(); -// for (int i = 0; i < zyUserInfoList.size(); i++) { -// ZYUserInfo zyUserInfo = zyUserInfoList.get(i); -// Integer zyUserId = zyUserInfo.getUserId(); -// String username = zyUserInfo.getUsername(); // studentid -// String name = zyUserInfo.getName(); -// String password = zyUserInfo.getPassword(); -// Integer roleId = zyUserInfo.getRoleId(); //3教师 4学生 -// -// SysUser userInfo = sysUserMapper.selectUserById(Long.valueOf(zyUserId)); -// if (userInfo!=null) { -// continue; -// } -// SysUser stuUser = new SysUser(); -// stuUser.setUserid(IdUtil.randomUUID()); -// stuUser.setStudentId(zyUserInfo.getUsername()); -// stuUser.setName(name); -// stuUser.setUsername(username); -// stuUser.setClassId(zyUserInfo.getClassId().toString()); -// stuUser.setPassword(password); -// stuUser.setPhone(zyUserInfo.getPhone()); -// stuUser.setMajor(zyUserInfo.getMajorName()); -// stuUser.setRoleId(roleId); -// stuUser.setSchoolId(zyUserInfo.getSchoolId().toString()); -// stuUser.setSchoolName(zyUserInfo.getSchoolName()); -// stuUser.setCreateTime(new Date()); -// users.add(stuUser); -// } -// if (users.isEmpty()) { -// return "账号已全部存在"; -// } -// userInfoMapper.batchInsertUserInfo(users); -// return "ok"; -// } + @ApiOperation("根据用户Code查询该用户是否存在个人赛用户数据,存在则返回,不存在则新增后返回,用于智云3.0创建用户后调用该接口创建用户个人赛") + @PostMapping("/checkOrCreateForexSimulationUser") + public String checkOrCreateForexSimulationUser(@RequestBody List zyUserInfoList, + @RequestParam String systemOwner) { + System.out.println(systemOwner); + List users = new ArrayList<>(); + List userRoleList = new ArrayList<>(); + List sysDeptList = new ArrayList<>(); + for (int i = 0; i < zyUserInfoList.size(); i++) { + ZYUserInfo zyUserInfo = zyUserInfoList.get(i); + Integer zyUserId = zyUserInfo.getUserId(); + String username = zyUserInfo.getUsername(); // studentid + String name = zyUserInfo.getName(); + String password = zyUserInfo.getPassword(); + Integer roleId = zyUserInfo.getRoleId(); //3教师 4学生 + Integer classId = zyUserInfo.getClassId(); + Long userId = Long.valueOf(zyUserId); + SysUser userInfo = sysUserMapper.selectUserById(userId); + if (userInfo!=null) { + continue; + } + //填充用户信息 + SysUser stuUser = new SysUser(); + stuUser.setUserId(userId); //使用智云的 + stuUser.setDeptId(Long.valueOf(classId)); + stuUser.setUserName(username); + stuUser.setNickName(name); + stuUser.setPassword(password); + stuUser.setPhonenumber(zyUserInfo.getPhone()); + stuUser.setStuClass(zyUserInfo.getClassName()); + stuUser.setStudentNumber(zyUserInfo.getUsername()); + stuUser.setCreateTime(new Date()); + stuUser.setStatus("0"); + stuUser.setDelFlag("0"); + + users.add(stuUser); + + //填充角色信息 + SysUserRole sysUserRole =new SysUserRole(); + sysUserRole.setUserId(userId); + if (roleId==3) { + sysUserRole.setRoleId(100L); //100是老师 2是学生 + } + if (roleId==4){ + sysUserRole.setRoleId(2L); + } + userRoleList.add(sysUserRole); + + //填充学校和班级信息 + SysDept sysDept = sysDeptMapper.selectDeptById(Long.valueOf(zyUserInfo.getSchoolId())); //判断学校是否存在 + if (sysDept==null){ + //添加一条学校数据 + SysDept newSysDept =new SysDept(); + newSysDept.setDeptId(Long.valueOf(zyUserInfo.getSchoolId())); + newSysDept.setDeptName(zyUserInfo.getSchoolName()); + newSysDept.setParentId(0L); //顶级节点 + newSysDept.setAncestors("0,100"); + Integer sort = sysDeptMapper.getOrderNumMax(); + newSysDept.setOrderNum(sort+1);//排序 + newSysDept.setCreateTime(new Date()); + newSysDept.setUpdateBy(new Date().toString()); + newSysDept.setStatus("0"); + newSysDept.setDelFlag("0"); + sysDeptList.add(newSysDept); + + //添加一条班级数据 + SysDept newSysDeptByClass =new SysDept(); + newSysDeptByClass.setDeptId(Long.valueOf(zyUserInfo.getClassId())); + newSysDeptByClass.setDeptName(zyUserInfo.getClassName()); + newSysDeptByClass.setParentId(newSysDept.getDeptId()); //学校的ID + newSysDeptByClass.setAncestors("0,100,"+newSysDept.getDeptId()); + newSysDeptByClass.setOrderNum(1);//排序 + newSysDeptByClass.setCreateTime(new Date()); + newSysDeptByClass.setUpdateBy(new Date().toString()); + newSysDeptByClass.setStatus("0"); + newSysDeptByClass.setDelFlag("0"); + sysDeptList.add(newSysDeptByClass); + + }else { // 学校存在 判断班级是否存在 + SysDept sysDeptByClass = sysDeptMapper.selectDeptById(Long.valueOf(classId)); + //为空则新增一条数据 + if (sysDeptByClass==null){ + Long deptId = sysDept.getDeptId(); //已有的学校ID + + Integer classSort = sysDeptMapper.selectByParentId(deptId); + SysDept newSysDeptByClass =new SysDept(); + newSysDeptByClass.setDeptId(Long.valueOf(zyUserInfo.getClassId())); + newSysDeptByClass.setDeptName(zyUserInfo.getClassName()); + newSysDeptByClass.setParentId(deptId); //学校的ID + newSysDeptByClass.setAncestors("0,100,"+deptId); + newSysDeptByClass.setOrderNum(classSort);//排序 + newSysDeptByClass.setCreateTime(new Date()); + newSysDeptByClass.setUpdateBy(new Date().toString()); + newSysDeptByClass.setStatus("0"); + newSysDeptByClass.setDelFlag("0"); + sysDeptList.add(newSysDeptByClass); + } + } + } + if (users.isEmpty()) { + return "账号已全部存在"; + } + sysUserMapper.batchInsertUserInfo(users); + sysUserRoleMapper.batchUserRole(userRoleList); + sysDeptMapper.batchInsertUserInfo(sysDeptList); + return "ok"; + } } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/CategoryController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/CategoryController.java index 2da3670..d85514e 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/CategoryController.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/CategoryController.java @@ -1,6 +1,7 @@ package com.ruoyi.biemo.business.controller; import com.ruoyi.biemo.business.domain.Category; +import com.ruoyi.biemo.business.domain.DocInfo; import com.ruoyi.biemo.business.service.CategoryService; import com.ruoyi.biemo.core.page.Page; import com.ruoyi.biemo.core.page.PageFactory; @@ -10,38 +11,63 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.query.Criteria; +import org.springframework.data.mongodb.core.query.Query; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import java.util.Arrays; import java.util.List; @RestController @RequestMapping(value = "/makesoft/category") public class CategoryController { - + @Autowired + private MongoTemplate mongoTemplate; @Autowired private CategoryService categoryService; + /** * 查询分类管理列表 */ //@PreAuthorize("@ss.hasPermi('biemo:category:list')") - @GetMapping("/list") - public Page list(Category category) - { - Page page = categoryService.selectCategoryPage(category,PageFactory.defaultPage()); - return page; +// @GetMapping("/list") +// public Page list(Category category) +// { +// Page page = categoryService.selectCategoryPage(category,PageFactory.defaultPage()); +// return page; +// } + + //todo 新接口 不走ES 条件查询 + @PostMapping("/list") + public List list(@RequestBody Category category) { + List schoolIds = Arrays.asList("管理员", category.getSchoolId()); // 构建 schoolId 列表 + //创建查询条件 + Criteria criteria = Criteria.where("schoolId").in(schoolIds); // schoolId 过滤条件 + + // 添加 cateId 条件(精确匹配) + if (category.getName() != null && !category.getName().isEmpty()) { + criteria.and("name").is(category.getName()); + } + // 构建查询对象 + Query query = new Query().addCriteria(criteria); // 添加所有条件 + List docInfoList = mongoTemplate.find(query, Category.class); + return docInfoList; } + /** * 导出分类管理列表 */ //@PreAuthorize("@ss.hasPermi('biemo:category:export')") @Log(title = "分类管理", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, Category category) - { + public void export(HttpServletResponse response, Category category) { List list = categoryService.selectCategoryList(category); ExcelUtil util = new ExcelUtil<>(Category.class); util.exportExcel(response, list, "分类管理数据"); @@ -52,8 +78,7 @@ public class CategoryController { */ //@PreAuthorize("@ss.hasPermi('biemo:category:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") String id) - { + public AjaxResult getInfo(@PathVariable("id") String id) { return AjaxResult.success(categoryService.selectCategoryById(id)); } @@ -63,14 +88,13 @@ public class CategoryController { //@PreAuthorize("@ss.hasPermi('biemo:category:add')") @Log(title = "分类管理", businessType = BusinessType.INSERT) @RequestMapping - public AjaxResult add(MultipartFile[] files , String id,String name,String parentId,Integer orderNum) - { + public AjaxResult add(MultipartFile[] files, String id, String name, String parentId, Integer orderNum) { Category category = new Category(); category.setId(id); category.setName(name); category.setParentId(parentId); category.setOrderNum(orderNum); - TextClassificationUtils.myTrainOrLoadModel(files,name); + TextClassificationUtils.myTrainOrLoadModel(files, name); categoryService.insertOrUpdateCategory(category); return AjaxResult.success(); } @@ -82,8 +106,7 @@ public class CategoryController { //@PreAuthorize("@ss.hasPermi('biemo:category:remove')") @Log(title = "分类管理", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable String[] ids) - { + public AjaxResult remove(@PathVariable String[] ids) { categoryService.deleteCategoryByIds(ids); return AjaxResult.success(); } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java index 6e60b0c..fda6cdd 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/controller/DocInfoController.java @@ -13,7 +13,6 @@ import com.ruoyi.biemo.business.domain.*; import com.ruoyi.biemo.business.service.CategoryService; import com.ruoyi.biemo.business.service.DocInfoService; import com.ruoyi.biemo.core.page.Page; -import com.ruoyi.biemo.core.page.PageFactory; import com.ruoyi.biemo.mongodb.utils.MongoHelper; import com.ruoyi.biemo.nlp.DependencyParserUtils; import com.ruoyi.biemo.nlp.TextClassificationUtils; @@ -25,6 +24,8 @@ import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -32,12 +33,9 @@ import org.springframework.data.mongodb.core.query.Update; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; -import javax.swing.plaf.synth.SynthOptionPaneUI; import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.regex.Pattern; /** @@ -58,47 +56,97 @@ public class DocInfoController extends BaseController { @Autowired private MongoHelper mongoHelper; + @GetMapping("/test") - public void test(){ + public void test() { List all2 = mongoHelper.findAll(Report.class); - System.out.println("ZZZ1:"+all2.size()); - System.out.println("ZZZ11:"+all2.get(0).getId()); + System.out.println("ZZZ1:" + all2.size()); + System.out.println("ZZZ11:" + all2.get(0).getId()); List all1 = mongoHelper.findAll(Category.class); - System.out.println("ZZZ2:"+all1.size()); - System.out.println("ZZZ22:"+all1.get(0).getId()); + System.out.println("ZZZ2:" + all1.size()); + System.out.println("ZZZ22:" + all1.get(0).getId()); List all = mongoHelper.findAll(DocInfo.class); - System.out.println("ZZZ3:"+all.size()); - System.out.println("ZZZ33:"+all.get(0).getId()); + System.out.println("ZZZ3:" + all.size()); + System.out.println("ZZZ33:" + all.get(0).getId()); DocInfo byId1 = mongoTemplate.findById("648c3996656fae4c70ccde97", DocInfo.class); - System.out.println("BBBDDD:"+byId1); - System.out.println("BBBDDD:"+byId1.getId()); + System.out.println("BBBDDD:" + byId1); + System.out.println("BBBDDD:" + byId1.getId()); DocInfo byId = mongoHelper.findById("648c3996656fae4c70ccde97", DocInfo.class); - System.out.println("bbb:"+byId); - System.out.println("bbb:"+byId.getId()); + System.out.println("bbb:" + byId); + System.out.println("bbb:" + byId.getId()); } /** * 查询文章管理列表 */ //@PreAuthorize("@ss.hasPermi('biemo:docInfo:list')") - @GetMapping("/list") - public Page list(DocInfo docInfo) - { - Page page = docInfoService.selectDocInfoPage(docInfo,PageFactory.defaultPage()); - System.out.println(page.getRows().get(0)); - List rows = page.getRows(); - page.getRows().forEach(doc->{ - Category category = new Category(); - category = categoryService.selectCategoryById(doc.getCateId()); - if(category!=null&&category.getName()!=null){ - doc.setCateName(category.getName()); - } - }); - return page; +// @GetMapping("/list") +// public Page list(DocInfo docInfo) { +// Page page = docInfoService.selectDocInfoPage(docInfo, PageFactory.defaultPage()); +// System.out.println(page.getRows().get(0)); +// List rows = page.getRows(); +// page.getRows().forEach(doc -> { +// Category category = new Category(); +// category = categoryService.selectCategoryById(doc.getCateId()); +// if (category != null && category.getName() != null) { +// doc.setCateName(category.getName()); +// } +// }); +// return page; +// } + + //todo 新查询,不使用ES,直接查询mongo page从0开始 + @PostMapping("/list") + public Page list2(@RequestBody DocInfo docInfo, + @RequestParam(defaultValue = "0") int page, + @RequestParam(defaultValue = "10") int size) { + List schoolIds = Arrays.asList("管理员", docInfo.getSchoolId()); // 构建 schoolId 列表 + + //创建查询条件 + Criteria criteria = Criteria.where("schoolId").in(schoolIds); // schoolId 过滤条件 + + // 添加 cateId 条件(精确匹配) + if (docInfo.getCateId() != null && !docInfo.getCateId().isEmpty()) { + criteria.and("cateId").is(docInfo.getCateId()); + } + + // 添加 content 条件(模糊查询) + if (docInfo.getContent() != null && !docInfo.getContent().isEmpty()) { + Pattern contentPattern = Pattern.compile("^.*" + docInfo.getContent() + ".*$", Pattern.CASE_INSENSITIVE); + criteria.and("content").regex(contentPattern); + } + + // 添加 title 条件(模糊查询) + if (docInfo.getTitle() != null && !docInfo.getTitle().isEmpty()) { + Pattern titlePattern = Pattern.compile("^.*" + docInfo.getTitle() + ".*$", Pattern.CASE_INSENSITIVE); + criteria.and("title").regex(titlePattern); + } + + // 添加 status 条件(精确匹配) + if (docInfo.getStatus() != null) { + criteria.and("status").is(docInfo.getStatus()); + } + // 构建查询对象 + Query query = new Query().addCriteria(criteria); // 添加所有条件 + // 添加排序条件,按照 createTime 字段升序排列 + query.with(Sort.by(Sort.Direction.DESC, "createTime")); + // 计算总记录数 + long totalRecords = mongoTemplate.count(query, DocInfo.class); + // 设置分页条件并执行查询 + query.with(PageRequest.of(page, size)); + + // 执行查询 + List docInfoList = mongoTemplate.find(query, DocInfo.class); + Page resultPage = new Page<>(page, size, totalRecords); + resultPage.setRows(docInfoList); // 设置查询结果 + resultPage.setCode(200); // 设置状态码 + resultPage.setMsg("查询成功"); // 设置消息 + + return resultPage; } @GetMapping("/getWordCloudByCateId/{categoryId}") - public AjaxResult getWordCloudByCateId(@PathVariable String categoryId){ + public AjaxResult getWordCloudByCateId(@PathVariable String categoryId) { System.out.println("进来了 开始****************"); List wordCloudItems = docInfoService.getWordCloudByCateId(categoryId); @@ -106,18 +154,18 @@ public class DocInfoController extends BaseController { } @GetMapping("/getEmotionAnalysisByCateId/{categoryId}") - public AjaxResult getEmotionAnalysis(@PathVariable String categoryId) throws IOException { + public AjaxResult getEmotionAnalysis(@PathVariable String categoryId) throws IOException { EmotionResult emotionResult = docInfoService.getEmotionAnalysis(categoryId); return AjaxResult.success(emotionResult); } + /** * 导出文章管理列表 */ //@PreAuthorize("@ss.hasPermi('biemo:docInfo:export')") @Log(title = "文章管理", businessType = BusinessType.EXPORT) @PostMapping("/export") - public void export(HttpServletResponse response, DocInfo docInfo) - { + public void export(HttpServletResponse response, DocInfo docInfo) { List list = docInfoService.selectDocInfoList(docInfo); ExcelUtil util = new ExcelUtil(DocInfo.class); util.exportExcel(response, list, "文章管理数据"); @@ -128,12 +176,12 @@ public class DocInfoController extends BaseController { */ //@PreAuthorize("@ss.hasPermi('biemo:docInfo:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") String id) - { - System.out.println("传入的ID值为=====》"+id); + public AjaxResult getInfo(@PathVariable("id") String id) { + System.out.println("传入的ID值为=====》" + id); return AjaxResult.success(docInfoService.selectDocInfoById(id)); } + /** * 批量标注 */ @@ -160,74 +208,74 @@ public class DocInfoController extends BaseController { content = MyObjects.delHTMLTag(content); content = MyObjects.delSpace(content); JSONArray labels = new JSONArray(); - result.put("docInfoId",docInfoId); + result.put("docInfoId", docInfoId); result.put("content", content); result.put("connections", new JSONArray()); result.put("connectionCategories", MyObjects.connectionCategories); result.put("labelCategories", MyObjects.labelCategories); Sentence sentence = DependencyParserUtils.nerAnalysis(content); List wordList = sentence.wordList; - int noun=0; - int personalName=0; - int placeName=0; - int InstitutionalGroup=0; - int verb=0; - int adjective=0; - int adverb=0; - if(wordList!=null&&wordList.size()>0){ + int noun = 0; + int personalName = 0; + int placeName = 0; + int InstitutionalGroup = 0; + int verb = 0; + int adjective = 0; + int adverb = 0; + if (wordList != null && wordList.size() > 0) { int offset = 0; int id = 0; - for(int i=0;i wordList = sentence.wordList; - if(wordList!=null&&wordList.size()>0){ + if (wordList != null && wordList.size() > 0) { int offset = 0; int id = 0; - for(int i=0;i wordList = new ArrayList<>(); - if(labels!=null&&labels.size()>0){ - for(int i=0;i 0) { + for (int i = 0; i < labels.size(); i++) { + Word word = new Word(null, null); JSONObject labelJSONObject = labels.getJSONObject(i); Integer startIndex = labelJSONObject.getInteger("startIndex"); Integer endIndex = labelJSONObject.getInteger("endIndex"); Integer categoryId = labelJSONObject.getInteger("categoryId"); - String value = content.substring(startIndex,endIndex); + String value = content.substring(startIndex, endIndex); String label = MyObjects.wordsMappingIndex.get(categoryId); word.setLabel(label); word.setValue(value); @@ -300,10 +348,9 @@ public class DocInfoController extends BaseController { * 新增文章管理或修改文章 */ //@PreAuthorize("@ss.hasPermi('biemo:docInfo:add')") - @Log(title = "文章新增", businessType = BusinessType.INSERT) +// @Log(title = "文章新增", businessType = BusinessType.INSERT) @RequestMapping - public AjaxResult add(@RequestBody DocInfo docInfo) - { + public AjaxResult add(@RequestBody DocInfo docInfo) { docInfoService.insertOrUpdateDocInfo(docInfo); return AjaxResult.success(); } @@ -314,15 +361,14 @@ public class DocInfoController extends BaseController { //@PreAuthorize("@ss.hasPermi('biemo:docInfo:remove')") @Log(title = "文章删除", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable String[] ids) - { + public AjaxResult remove(@PathVariable String[] ids) { docInfoService.deleteDocInfoByIds(ids); return AjaxResult.success(); } @GetMapping("/analysis/{id}") - public AjaxResult analysis(@PathVariable String id){ - return AjaxResult.success(docInfoService.analysis(id,false)); + public AjaxResult analysis(@PathVariable String id) { + return AjaxResult.success(docInfoService.analysis(id, false)); } @@ -338,29 +384,29 @@ public class DocInfoController extends BaseController { //文章管理--批量分析 @GetMapping("/batchAnalysis/{ids}") - public AjaxResult batchAnalysis(@PathVariable String[] ids){ + public AjaxResult batchAnalysis(@PathVariable String[] ids) { return AjaxResult.success(docInfoService.batchAnalysis(ids)); } //社会网络分析 @PostMapping("/socialNetworkAnalysis") - public AjaxResult batchAnalysisByIds(@RequestBody String [] ids) { + public AjaxResult batchAnalysisByIds(@RequestBody String[] ids) { return AjaxResult.success(docInfoService.socialNetworkAnalysis(ids)); } @GetMapping("/summary/{id}") - public AjaxResult summary(@PathVariable String id){ + public AjaxResult summary(@PathVariable String id) { return AjaxResult.success(docInfoService.summary(id)); } @GetMapping("/handleClassification/{id}") - public AjaxResult handleClassification(@PathVariable String id){ + public AjaxResult handleClassification(@PathVariable String id) { DocInfo docInfo = docInfoService.selectDocInfoById(id); JSONObject result = new JSONObject(); String content = docInfo.getContent(); content = MyObjects.delHTMLTag(content); content = MyObjects.delSpace(content); - return AjaxResult.success("查询成功",TextClassificationUtils.getClassification(content)); + return AjaxResult.success("查询成功", TextClassificationUtils.getClassification(content)); } // @PostMapping("/createEsIndex") @@ -370,34 +416,34 @@ public class DocInfoController extends BaseController { // } @PostMapping("/splitWordIds") - public AjaxResult splitWordIds(@RequestBody List docInfoList){ + public AjaxResult splitWordIds(@RequestBody List docInfoList) { for (int i = 0; i < docInfoList.size(); i++) { splitWordDocInfo(docInfoList.get(i)); } return AjaxResult.success("批量分词成功"); } - @PostMapping ("/splitWordStr") - public AjaxResult splitWordStr(@RequestBody String str){ - Segment segment= HanLP.newSegment(); + @PostMapping("/splitWordStr") + public AjaxResult splitWordStr(@RequestBody String str) { + Segment segment = HanLP.newSegment(); List termList = segment.seg(str); - List wordList=new ArrayList<>(); + List wordList = new ArrayList<>(); for (Term term : termList) { String word = term.toString().substring(0, term.length()); wordList.add(word); } - return AjaxResult.success("分词成功",wordList); + return AjaxResult.success("分词成功", wordList); } - @PostMapping ("/splitWordDocInfo") - public AjaxResult splitWordDocInfo(@RequestBody DocInfo docInfo){ - if("".equals(docInfo.getContent()) || docInfo.getContent()==null){ - return AjaxResult.error(400,"文章不能为空"); + @PostMapping("/splitWordDocInfo") + public AjaxResult splitWordDocInfo(@RequestBody DocInfo docInfo) { + if ("".equals(docInfo.getContent()) || docInfo.getContent() == null) { + return AjaxResult.error(400, "文章不能为空"); } String title = docInfo.getContent(); - Segment segment= HanLP.newSegment(); + Segment segment = HanLP.newSegment(); List termList = segment.seg(title); - List wordList=new ArrayList<>(); + List wordList = new ArrayList<>(); //遍历分词结果 for (Term term : termList) { String word = term.toString().substring(0, term.length()); @@ -406,7 +452,7 @@ public class DocInfoController extends BaseController { docInfo.setAnalyzeTitle(wordList); List analyzeTitleList = docInfo.getAnalyzeTitle(); for (int i = 0; i < analyzeTitleList.size(); i++) { - if(StringUtils.isNotBlank(analyzeTitleList.get(i))){ + if (StringUtils.isNotBlank(analyzeTitleList.get(i))) { CustomDictionary.add(analyzeTitleList.get(i)); } } @@ -414,7 +460,7 @@ public class DocInfoController extends BaseController { Update update = new Update(); update.set("splitWordStatus", "已分词"); mongoTemplate.upsert(query, update, DocInfo.class); - return AjaxResult.success("分词成功",docInfo); + return AjaxResult.success("分词成功", docInfo); } /** @@ -433,7 +479,7 @@ public class DocInfoController extends BaseController { } } return AjaxResult.success("分词上传成功"); - }catch (Exception e){ + } catch (Exception e) { return AjaxResult.error("格式不正确"); } } @@ -443,7 +489,7 @@ public class DocInfoController extends BaseController { try { List analyzeTitleList = docInfo.getAnalyzeTitle(); for (int i = 0; i < analyzeTitleList.size(); i++) { - if(StringUtils.isNotBlank(analyzeTitleList.get(i))){ + if (StringUtils.isNotBlank(analyzeTitleList.get(i))) { CustomDictionary.add(analyzeTitleList.get(i)); } } @@ -452,7 +498,7 @@ public class DocInfoController extends BaseController { update.set("splitWordStatus", "已分词"); mongoTemplate.upsert(query, update, DocInfo.class); return AjaxResult.success("分词上传成功"); - }catch (Exception e){ + } catch (Exception e) { return AjaxResult.error("格式不正确"); } } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/Category.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/Category.java index a820750..1941c0b 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/Category.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/Category.java @@ -55,6 +55,8 @@ public class Category extends BiemoEntity { @FieldInfo(type = "keyword",participle = 0) private Integer orderNum; + //学校ID + private String schoolId; // /** 子类 */ // @Transient // private List children = new ArrayList<>(); diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/DocInfo.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/DocInfo.java index a629949..c627fcb 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/DocInfo.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/domain/DocInfo.java @@ -69,4 +69,7 @@ public class DocInfo extends BiemoEntity { //词性标注状态 已标注 未标注 private String posTagStatus; + //学校ID + private String schoolId; + } diff --git a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java index c3394f1..863bf33 100644 --- a/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java +++ b/ruoyi-biemo/src/main/java/com/ruoyi/biemo/business/service/DocInfoService.java @@ -60,7 +60,7 @@ public class DocInfoService extends EsService { System.out.println("hit.getId()222===========>:" + id); if (Objects.isNull(id) || StringUtil.isEmpty(id)) return null; System.out.println("hit.getId()===========>:" + id); - DocInfo byId = mongoHelper.findById(id, DocInfo.class); + DocInfo byId = mongoHelper.findById(id,DocInfo.class); System.out.println("mongo.FindById结果======》:" + byId.getId()); return mongoHelper.findById(id, DocInfo.class); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 67e5efe..faa384a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -122,4 +122,12 @@ public interface SysDeptMapper public int deleteDeptById(Long deptId); SysDept selectDeptByDeptName(@Param("stuClass") String stuClass); + + @Select("SELECT order_num FROM `sys_dept` ORDER BY order_num desc LIMIT 1") + Integer getOrderNumMax(); + + @Select("SELECT order_num FROM `sys_dept` where parent_id = #{deptId} ORDER BY order_num desc LIMIT 1") + Integer selectByParentId(@Param("deptId") Long deptId); + + void batchInsertUserInfo(@Param("list") List sysDeptList); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index 5c80710..df477e9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -152,4 +152,6 @@ public interface SysUserMapper SysUser selectDeptIdByUserName(@Param("userName")String username); SysUser selectDeptIdByStudentNumber(@Param("userName")String username); + + void batchInsertUserInfo(@Param("list") List users); } diff --git a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index d9297cb..ae9372c 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -157,4 +157,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update sys_dept set del_flag = '2' where dept_id = #{deptId} - \ No newline at end of file + + insert into sys_dept(dept_id,parent_id,dept_name,ancestors,order_num,status,create_time) VALUES + + (#{student.deptId},#{student.parentId},#{student.deptName},#{student.ancestors}, + #{student.orderNum} ,#{student.status}, #{student.createTime}) + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 3325130..bc2be52 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -94,25 +94,27 @@ WHERE sr.role_id = 2 - - - - - - - - - - - - + + + + + + + + + + + + SELECT DISTINCT stuclass FROM sys_user su - JOIN sys_user_role sur ON su.user_id = sur.user_id - JOIN sys_role sr ON sur.role_id = sr.role_id + JOIN sys_user_role sur ON su.user_id = sur.user_id + JOIN sys_role sr ON sur.role_id = sr.role_id WHERE sr.role_id = 2 - and dept_id in (select dept_id from sys_dept where parent_id=(select parent_id from sys_dept where dept_id=#{deptId})) + and dept_id in (select dept_id + from sys_dept + where parent_id = (select parent_id from sys_dept where dept_id = #{deptId})) @@ -169,7 +173,8 @@ AND (user_name like "%"#{keyWord}"%" or studentnumber like "%"#{keyWord}"%") - and dept_id in (select dept_id from sys_dept where parent_id=(select parent_id from sys_dept where dept_id=#{deptId})) + and dept_id in (select dept_id from sys_dept where parent_id=(select parent_id from sys_dept where + dept_id=#{deptId}))