From ed32a15368610345916efcc936f6e2fb2e39b681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=B6=E4=B8=9C?= <1654135867@qq.com> Date: Tue, 7 May 2024 15:30:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=A5=E8=AF=86=E5=9B=BE=E8=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SeKnowGroupController.java | 276 ++++++++++++++++++ .../demo/seknowgroup/entity/Exports.java | 11 + .../demo/seknowgroup/entity/NodeList.java | 10 + .../demo/seknowgroup/entity/NodeName.java | 9 + .../demo/seknowgroup/entity/SeKnowGroup.java | 66 +++++ .../seknowgroup/mapper/SeKnowGroupMapper.java | 37 +++ .../mapper/xml/SeKnowGroupMapper.xml | 5 + .../service/ISeKnowGroupService.java | 28 ++ .../service/impl/SeKnowGroupServiceImpl.java | 53 ++++ 9 files changed, 495 insertions(+) create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/controller/SeKnowGroupController.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/Exports.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeList.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeName.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/SeKnowGroup.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/SeKnowGroupMapper.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/xml/SeKnowGroupMapper.xml create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/ISeKnowGroupService.java create mode 100644 jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/impl/SeKnowGroupServiceImpl.java diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/controller/SeKnowGroupController.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/controller/SeKnowGroupController.java new file mode 100644 index 0000000..c44362f --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/controller/SeKnowGroupController.java @@ -0,0 +1,276 @@ +package org.jeecg.modules.demo.seknowgroup.controller; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.course.controller.SeCourseController; +import org.jeecg.modules.demo.know.entity.SeKonw; +import org.jeecg.modules.demo.know.service.ISeKonwService; +import org.jeecg.modules.demo.seknowgroup.entity.Exports; +import org.jeecg.modules.demo.seknowgroup.entity.NodeList; +import org.jeecg.modules.demo.seknowgroup.entity.NodeName; +import org.jeecg.modules.demo.seknowgroup.entity.SeKnowGroup; +import org.jeecg.modules.demo.seknowgroup.service.ISeKnowGroupService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.aspect.annotation.AutoLog; + +/** + * @Description: 知识图谱表 + * @Author: jeecg-boot + * @Date: 2022-04-09 + * @Version: V1.0 + */ +@Api(tags="知识图谱表") +@RestController +@RequestMapping("/seknowgroup/seKnowGroup") +@Slf4j +public class SeKnowGroupController extends JeecgController { + @Autowired + private ISeKnowGroupService seKnowGroupService; + + @Autowired + private ISeKonwService seKonwService; + + /** + * 分页列表查询 + * + * @param seKnowGroup + * @param pageNo + * @param pageSize + * @param req + * @return + */ + @AutoLog(value = "知识图谱表-分页列表查询") + @ApiOperation(value="知识图谱表-分页列表查询", notes="知识图谱表-分页列表查询") + @GetMapping(value = "/list") + public Result queryPageList(SeKnowGroup seKnowGroup, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(seKnowGroup, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = seKnowGroupService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param seKnowGroup + * @return + */ + @AutoLog(value = "知识图谱表-添加") + @ApiOperation(value="知识图谱表-添加", notes="知识图谱表-添加") + @PostMapping(value = "/add") + public Result add(@RequestBody SeKnowGroup seKnowGroup) { + seKnowGroupService.save(seKnowGroup); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param seKnowGroup + * @return + */ + @AutoLog(value = "知识图谱表-编辑") + @ApiOperation(value="知识图谱表-编辑", notes="知识图谱表-编辑") + @PutMapping(value = "/edit") + public Result edit(@RequestBody SeKnowGroup seKnowGroup) { + seKnowGroupService.updateById(seKnowGroup); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "知识图谱表-通过id删除") + @ApiOperation(value="知识图谱表-通过id删除", notes="知识图谱表-通过id删除") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + seKnowGroupService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "知识图谱表-批量删除") + @ApiOperation(value="知识图谱表-批量删除", notes="知识图谱表-批量删除") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.seKnowGroupService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + @AutoLog(value = "知识图谱表-通过id查询") + @ApiOperation(value="知识图谱表-通过id查询", notes="知识图谱表-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + SeKnowGroup seKnowGroup = seKnowGroupService.getById(id); + if(seKnowGroup==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(seKnowGroup); + } + + /** + * 导出excel + * + * @param request + * @param seKnowGroup + */ + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, SeKnowGroup seKnowGroup) { + return super.exportXls(request, seKnowGroup, SeKnowGroup.class, "知识图谱表"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, SeKnowGroup.class); + } + + /** + * 用于更新图谱 + * + * @param request + * @param response + * @return + */ + @GetMapping(value = "/updatetp") + public Result updatetp(@RequestParam(name="id",required=true) String id,@RequestParam(name="cid",required=true) String cid) { + //根据课程id开始删除知识点关系中的数据 + seKnowGroupService.removeById(id); + //删除知识点表的数据 + seKnowGroupService.deleteknoe(cid); + //删除知识点关系表中的数据 + seKnowGroupService.deletereal(cid); + //开始重新创建只是图谱数据 + SeCourseController sec = new SeCourseController(); + sec.cretegroup(cid); + return Result.OK("更新完成"); + } + + + @GetMapping(value = "/createGroup") + public Result createGroup(@RequestParam(name="id",required=true) String id) { + System.out.println(id); + return Result.OK("更新完成"); + } + +/* + *//** + * 开始组装知识图谱 + *//* + + @RequestMapping(value = "/zzzztp") + public Exports zzzztp(@RequestParam(name="id",required=true) String id) { + //最多显示三层结构 + List nodelist = new ArrayList<>(); + //开始根据id查找中心知识点id + String pointnode = seKnowGroupService.findpointnode(id); + //开始组装知识点节点 + //获取中心知识点 + SeKonw seknow = seKonwService.getById(pointnode); + //将list的第一个位置设置成中心知识点名称 + NodeName nodes = new NodeName(); + nodes.setName(seknow.getName()); + nodelist.add(nodes); + //开是循环,根据中心知识点id,在知识点关系表中查询以中心知识点为中心查询第二层知识点 + List listid = seKnowGroupService.listid(seknow.getId()); + //开始循环 + for (int i=0;i listid2 = seKnowGroupService.listid(listid.get(i)); + System.out.println(listid2.size()); + for (int j =0;j nodelistdss = new ArrayList<>(); + //首先根据中心知识点查询 + List segouplisttemp = new ArrayList<>(); + segouplisttemp=seKnowGroupService.getzxzsnodelist(seknow.getId()); + //第二层 + for (int i=0; i< segouplisttemp.size();i++){ + NodeList ndoesl = new NodeList(); + ndoesl.setSource(seKonwService.getById(segouplisttemp.get(i).getPerKowId()).getName()); + ndoesl.setTarget(seKonwService.getById(segouplisttemp.get(i).getNextKnowId()).getName()); + ndoesl.setValue(seKonwService.getrelaint(segouplisttemp.get(i).getRelationId())); + nodelistdss.add(ndoesl); + List segouplisttemp2 = new ArrayList<>(); + segouplisttemp2=seKnowGroupService.getzxzsnodelist(segouplisttemp.get(i).getNextKnowId()); + for (int j=0;j nodes; + private List links; +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeList.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeList.java new file mode 100644 index 0000000..09d644f --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeList.java @@ -0,0 +1,10 @@ +package org.jeecg.modules.demo.seknowgroup.entity; + +import lombok.Data; + +@Data +public class NodeList { + private String source; + private String target; + private String value; +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeName.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeName.java new file mode 100644 index 0000000..a592ac0 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/NodeName.java @@ -0,0 +1,9 @@ +package org.jeecg.modules.demo.seknowgroup.entity; + +import lombok.Data; + +@Data +public class NodeName { + private String name; + +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/SeKnowGroup.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/SeKnowGroup.java new file mode 100644 index 0000000..d002041 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/entity/SeKnowGroup.java @@ -0,0 +1,66 @@ +package org.jeecg.modules.demo.seknowgroup.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: 知识图谱表 + * @Author: jeecg-boot + * @Date: 2022-04-09 + * @Version: V1.0 + */ +@Data +@TableName("se_know_group") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="se_know_group对象", description="知识图谱表") +public class SeKnowGroup implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private String id; + /**创建人*/ + @ApiModelProperty(value = "创建人") + private String createBy; + /**创建日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private Date createTime; + /**更新人*/ + @ApiModelProperty(value = "更新人") + private String updateBy; + /**更新日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "更新日期") + private Date updateTime; + /**所属部门*/ + @ApiModelProperty(value = "所属部门") + private String sysOrgCode; + /**图谱名称*/ + @Excel(name = "图谱名称", width = 15) + @ApiModelProperty(value = "图谱名称") + private String name; + /**中心知识点*/ + @ApiModelProperty(value = "中心知识点") + private String knowPoint; + @ApiModelProperty(value = "课程id") + private String courseid; +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/SeKnowGroupMapper.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/SeKnowGroupMapper.java new file mode 100644 index 0000000..34e5c8c --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/SeKnowGroupMapper.java @@ -0,0 +1,37 @@ +package org.jeecg.modules.demo.seknowgroup.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.jeecg.modules.demo.seknowgroup.entity.NodeList; +import org.jeecg.modules.demo.seknowgroup.entity.SeKnowGroup; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + + +/** + * @Description: 知识图谱表 + * @Author: jeecg-boot + * @Date: 2022-04-09 + * @Version: V1.0 + */ +public interface SeKnowGroupMapper extends BaseMapper { + + + @Select("select know_point from se_know_group where id =#{id}") + String findpointnode(String id); + + + @Select("select next_know_id from se_konw_relationship_main where per_kow_id=#{pointnode}") + List listid(String pointnode); + + @Delete("delete from se_konw where courseid =#{cid}") + void deleteknoe(String cid); + + @Delete("delete from se_konw_relationship_main where courseid =#{cid}") + void deletereal(String cid); + +/* @Select("select * from se_konw_relationship_main where per_kow_id =#{id}") + List getzxzsnodelist(String id);*/ +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/xml/SeKnowGroupMapper.xml b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/xml/SeKnowGroupMapper.xml new file mode 100644 index 0000000..e585b70 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/mapper/xml/SeKnowGroupMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/ISeKnowGroupService.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/ISeKnowGroupService.java new file mode 100644 index 0000000..2f7cfb7 --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/ISeKnowGroupService.java @@ -0,0 +1,28 @@ +package org.jeecg.modules.demo.seknowgroup.service; + +import org.jeecg.modules.demo.seknowgroup.entity.NodeList; +import org.jeecg.modules.demo.seknowgroup.entity.SeKnowGroup; +import com.baomidou.mybatisplus.extension.service.IService; + + +import java.util.List; + +/** + * @Description: 知识图谱表 + * @Author: jeecg-boot + * @Date: 2022-04-09 + * @Version: V1.0 + */ +public interface ISeKnowGroupService extends IService { + + String findpointnode(String id); + + List listid(String pointnode); + + void deleteknoe(String cid); + + void deletereal(String cid); + + + /* List getzxzsnodelist(String id);*/ +} diff --git a/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/impl/SeKnowGroupServiceImpl.java b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/impl/SeKnowGroupServiceImpl.java new file mode 100644 index 0000000..e809c9e --- /dev/null +++ b/jeecg-boot/jeecg-boot-module-system/src/main/java/org/jeecg/modules/demo/seknowgroup/service/impl/SeKnowGroupServiceImpl.java @@ -0,0 +1,53 @@ +package org.jeecg.modules.demo.seknowgroup.service.impl; + +import org.jeecg.modules.demo.seknowgroup.entity.NodeList; +import org.jeecg.modules.demo.seknowgroup.entity.SeKnowGroup; +import org.jeecg.modules.demo.seknowgroup.mapper.SeKnowGroupMapper; +import org.jeecg.modules.demo.seknowgroup.service.ISeKnowGroupService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.util.List; + +/** + * @Description: 知识图谱表 + * @Author: jeecg-boot + * @Date: 2022-04-09 + * @Version: V1.0 + */ +@Service +public class SeKnowGroupServiceImpl extends ServiceImpl implements ISeKnowGroupService { + + @Autowired + SeKnowGroupMapper knowGroupMapper; + + @Override + public String findpointnode(String id) { + return knowGroupMapper.findpointnode(id); + } + + @Override + public List listid(String pointnode) { + return knowGroupMapper.listid(pointnode); + } + + @Override + public void deleteknoe(String cid) { + knowGroupMapper.deleteknoe(cid); + } + + @Override + public void deletereal(String cid) { + knowGroupMapper.deletereal(cid); + } + +/* @Override + public List getzxzsnodelist(String id) { + return knowGroupMapper.getzxzsnodelist(id); + }*/ + + +}