系统部分接口添加schoolId字段,新增智云3.0系统账号同步接口

master
xiaoCJ
parent 7399ddbeeb
commit 02539baec4

@ -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<String> 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<ZYUserInfo> zyUserInfoList,
// @RequestParam String systemOwner) {
// System.out.println(systemOwner);
// List<SysUser> 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<ZYUserInfo> zyUserInfoList,
@RequestParam String systemOwner) {
System.out.println(systemOwner);
List<SysUser> users = new ArrayList<>();
List<SysUserRole> userRoleList = new ArrayList<>();
List<SysDept> 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";
}
}

@ -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<Category> list(Category category)
{
Page<Category> page = categoryService.selectCategoryPage(category,PageFactory.defaultPage());
return page;
// @GetMapping("/list")
// public Page<Category> list(Category category)
// {
// Page<Category> page = categoryService.selectCategoryPage(category,PageFactory.defaultPage());
// return page;
// }
//todo 新接口 不走ES 条件查询
@PostMapping("/list")
public List<Category> list(@RequestBody Category category) {
List<String> 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<Category> 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<Category> list = categoryService.selectCategoryList(category);
ExcelUtil<Category> 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();
}

@ -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<Report> 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<Category> 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<DocInfo> 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<DocInfo> list(DocInfo docInfo)
{
Page<DocInfo> page = docInfoService.selectDocInfoPage(docInfo,PageFactory.defaultPage());
System.out.println(page.getRows().get(0));
List<DocInfo> 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<DocInfo> list(DocInfo docInfo) {
// Page<DocInfo> page = docInfoService.selectDocInfoPage(docInfo, PageFactory.defaultPage());
// System.out.println(page.getRows().get(0));
// List<DocInfo> 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<DocInfo> list2(@RequestBody DocInfo docInfo,
@RequestParam(defaultValue = "0") int page,
@RequestParam(defaultValue = "10") int size) {
List<String> 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<DocInfo> docInfoList = mongoTemplate.find(query, DocInfo.class);
Page<DocInfo> 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<WordCloudItem> 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<DocInfo> list = docInfoService.selectDocInfoList(docInfo);
ExcelUtil<DocInfo> util = new ExcelUtil<DocInfo>(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<IWord> 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.size();i++){
for (int i = 0; i < wordList.size(); i++) {
String value = wordList.get(i).getValue();
String label = wordList.get(i).getLabel();
if(MyObjects.wordsMapping.get(label)!=null){
if (MyObjects.wordsMapping.get(label) != null) {
Integer startIndex = offset;
Integer endIndex = offset+value.length();
Integer endIndex = offset + value.length();
Integer categoryId = MyObjects.wordsMapping.get(label);
JSONObject jsonObject = new JSONObject();
jsonObject.put("id",id);
if(categoryId==0){
jsonObject.put("id", id);
if (categoryId == 0) {
noun++;
}else if(categoryId==1){
} else if (categoryId == 1) {
personalName++;
}else if(categoryId==2){
} else if (categoryId == 2) {
placeName++;
}else if(categoryId==3){
} else if (categoryId == 3) {
InstitutionalGroup++;
}else if(categoryId==4){
} else if (categoryId == 4) {
verb++;
}else if(categoryId==5){
} else if (categoryId == 5) {
adjective++;
}else if(categoryId==6){
} else if (categoryId == 6) {
adverb++;
}
jsonObject.put("categoryId",categoryId);
jsonObject.put("startIndex",startIndex);
jsonObject.put("endIndex",endIndex);
jsonObject.put("categoryId", categoryId);
jsonObject.put("startIndex", startIndex);
jsonObject.put("endIndex", endIndex);
labels.add(jsonObject);
}
offset += value.length();
id++;
}
result.put("labels",labels);
result.put("labels", labels);
}
Map map=new HashMap();
map.put("noun",noun);
map.put("personalName",personalName);
map.put("placeName",placeName);
map.put("institutionalGroup",InstitutionalGroup);
map.put("verb",verb);
map.put("adjective",adjective);
map.put("adverb",adverb);
result.put("partData",map);
Map map = new HashMap();
map.put("noun", noun);
map.put("personalName", personalName);
map.put("placeName", placeName);
map.put("institutionalGroup", InstitutionalGroup);
map.put("verb", verb);
map.put("adjective", adjective);
map.put("adverb", adverb);
result.put("partData", map);
//点击词性标注后直接上传 并修改状态
Query query = new Query(Criteria.where("_id").is(docInfoId));
Update update = new Update();
update.set("posTagStatus", "已标注");
mongoTemplate.upsert(query, update, DocInfo.class);
return AjaxResult.success("查询成功",result);
return AjaxResult.success("查询成功", result);
}
@PostMapping("/getInfoDelHtmlByContent")
@ -236,35 +284,35 @@ public class DocInfoController extends BaseController {
content = MyObjects.delHTMLTag(content);
content = MyObjects.delSpace(content);
JSONArray labels = new JSONArray();
result.put("content",content);
result.put("connections",new JSONArray());
result.put("connectionCategories",MyObjects.connectionCategories);
result.put("labelCategories",MyObjects.labelCategories);
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<IWord> 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.size();i++){
for (int i = 0; i < wordList.size(); i++) {
String value = wordList.get(i).getValue();
String label = wordList.get(i).getLabel();
if(MyObjects.wordsMapping.get(label)!=null){
if (MyObjects.wordsMapping.get(label) != null) {
Integer startIndex = offset;
Integer endIndex = offset+value.length();
Integer endIndex = offset + value.length();
Integer categoryId = MyObjects.wordsMapping.get(label);
JSONObject jsonObject = new JSONObject();
jsonObject.put("id",id);
jsonObject.put("categoryId",categoryId);
jsonObject.put("startIndex",startIndex);
jsonObject.put("endIndex",endIndex);
jsonObject.put("id", id);
jsonObject.put("categoryId", categoryId);
jsonObject.put("startIndex", startIndex);
jsonObject.put("endIndex", endIndex);
labels.add(jsonObject);
}
offset += value.length();
id++;
}
result.put("labels",labels);
result.put("labels", labels);
}
return AjaxResult.success("查询成功",result);
return AjaxResult.success("查询成功", result);
}
@PostMapping("/uploadPosTag")
@ -273,14 +321,14 @@ public class DocInfoController extends BaseController {
JSONArray labels = jsonObject.getJSONArray("labels");
String docInfoId = jsonObject.getString("docInfoId");
List<IWord> wordList = new ArrayList<>();
if(labels!=null&&labels.size()>0){
for(int i=0;i<labels.size();i++){
Word word = new Word(null,null);
if (labels != null && labels.size() > 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<DocInfo> docInfoList){
public AjaxResult splitWordIds(@RequestBody List<DocInfo> 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<Term> termList = segment.seg(str);
List<String> wordList=new ArrayList<>();
List<String> 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<Term> termList = segment.seg(title);
List<String> wordList=new ArrayList<>();
List<String> 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<String> 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<String> 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("格式不正确");
}
}

@ -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<>();

@ -69,4 +69,7 @@ public class DocInfo extends BiemoEntity {
//词性标注状态 已标注 未标注
private String posTagStatus;
//学校ID
private String schoolId;
}

@ -60,7 +60,7 @@ public class DocInfoService extends EsService<DocInfo> {
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);
}

@ -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<SysDept> sysDeptList);
}

@ -152,4 +152,6 @@ public interface SysUserMapper
SysUser selectDeptIdByUserName(@Param("userName")String username);
SysUser selectDeptIdByStudentNumber(@Param("userName")String username);
void batchInsertUserInfo(@Param("list") List<SysUser> users);
}

@ -157,4 +157,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
</mapper>
<insert id="batchInsertUserInfo" parameterType="java.util.List">
insert into sys_dept(dept_id,parent_id,dept_name,ancestors,order_num,status,create_time) VALUES
<foreach collection="list" item="student" separator=",">
(#{student.deptId},#{student.parentId},#{student.deptName},#{student.ancestors},
#{student.orderNum} ,#{student.status}, #{student.createTime})
</foreach>
</insert>
</mapper>

@ -94,25 +94,27 @@
WHERE sr.role_id = 2
</select>
<!-- <select id="selectClassStuNumberNameByClass" resultMap="SysUserResult">-->
<!-- SELECT su.studentnumber, su.stuclass, su.user_name, su.user_id-->
<!-- 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-->
<!-- <where>-->
<!-- <if test="stuClass != null and stuClass != ''">-->
<!-- AND su.stuclass = #{stuClass}-->
<!-- </if>-->
<!-- AND sr.role_id = 2-->
<!-- </where>-->
<!-- </select>-->
<!-- <select id="selectClassStuNumberNameByClass" resultMap="SysUserResult">-->
<!-- SELECT su.studentnumber, su.stuclass, su.user_name, su.user_id-->
<!-- 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-->
<!-- <where>-->
<!-- <if test="stuClass != null and stuClass != ''">-->
<!-- AND su.stuclass = #{stuClass}-->
<!-- </if>-->
<!-- AND sr.role_id = 2-->
<!-- </where>-->
<!-- </select>-->
<select id="selectClassStuNumberNameByClass" resultMap="SysUserResult">
SELECT su.studentnumber, su.stuclass, su.user_name, su.user_id
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}))
</select>
<select id="selectClassStuNumberNameByClassAll" resultMap="SysUserResult">
@ -134,10 +136,12 @@
<select id="selectClassByDeptId" resultType="java.lang.String">
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}))
</select>
<select id="selectClass" resultType="java.lang.String">
@ -146,13 +150,13 @@
</select>
<select id="selectDeptIdByUserName" resultMap="SysUserResult">
SELECT su.dept_id,su.user_id
SELECT su.dept_id, su.user_id
FROM sys_user su
WHERE su.user_name = #{userName}
</select>
<select id="selectDeptIdByStudentNumber" resultMap="SysUserResult">
SELECT su.dept_id,su.user_id
SELECT su.dept_id, su.user_id
FROM sys_user su
WHERE su.studentnumber = #{userName}
</select>
@ -169,7 +173,8 @@
<if test="keyWord != null and keyWord != ''">
AND (user_name like "%"#{keyWord}"%" or studentnumber like "%"#{keyWord}"%")
</if>
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}))
</select>
<select id="selectByNameStuNumNoDeptId" resultMap="SysUserResult">
@ -378,4 +383,13 @@
</foreach>
</delete>
<insert id="batchInsertUserInfo" parameterType="java.util.List">
INSERT INTO sys_user (user_id,dept_id,user_name,nick_name,phonenumber,studentnumber,stuclass,
password,status,del_flag,create_time) VALUES
<foreach collection="list" item="student" separator=",">
(#{student.userId},#{student.deptId},#{student.userName},#{student.nickName},
#{student.phonenumber} ,#{student.studentNumber}, #{student.stuClass},#{student.password},
#{student.status},#{student.delFlag},#{student.createTime})
</foreach>
</insert>
</mapper>
Loading…
Cancel
Save