parent
c59052947d
commit
ed32a15368
9 changed files with 495 additions and 0 deletions
@ -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<SeKnowGroup, ISeKnowGroupService> { |
||||
@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<SeKnowGroup> queryWrapper = QueryGenerator.initQueryWrapper(seKnowGroup, req.getParameterMap()); |
||||
Page<SeKnowGroup> page = new Page<SeKnowGroup>(pageNo, pageSize); |
||||
IPage<SeKnowGroup> 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<NodeName> 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<String> listid = seKnowGroupService.listid(seknow.getId()); |
||||
//开始循环
|
||||
for (int i=0;i<listid.size();i++){ |
||||
NodeName nodes1 = new NodeName(); |
||||
//根据id获取知识点名字,并且进行赋值
|
||||
nodes1.setName(seKonwService.getById(listid.get(i)).getName()); |
||||
nodelist.add(nodes1); |
||||
//开始第二层循环
|
||||
List<String> listid2 = seKnowGroupService.listid(listid.get(i)); |
||||
System.out.println(listid2.size()); |
||||
for (int j =0;j<listid2.size();j++ ){ |
||||
NodeName nodes2 = new NodeName(); |
||||
SeKonw sek = new SeKonw(); |
||||
sek = seKonwService.getById(listid2.get(j)); |
||||
nodes2.setName(sek.getName()); |
||||
nodelist.add(nodes2); |
||||
} |
||||
} |
||||
|
||||
|
||||
//现在开始组装知识图谱经管系节点
|
||||
List<NodeList> nodelistdss = new ArrayList<>(); |
||||
//首先根据中心知识点查询
|
||||
List<SeKonwRelationshipMain> 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<SeKonwRelationshipMain> segouplisttemp2 = new ArrayList<>(); |
||||
segouplisttemp2=seKnowGroupService.getzxzsnodelist(segouplisttemp.get(i).getNextKnowId()); |
||||
for (int j=0;j<segouplisttemp2.size();j++){ |
||||
NodeList ndoesl2 = new NodeList(); |
||||
ndoesl2.setSource(seKonwService.getById(segouplisttemp2.get(j).getPerKowId()).getName()); |
||||
ndoesl2.setTarget(seKonwService.getById(segouplisttemp2.get(j).getNextKnowId()).getName()); |
||||
ndoesl2.setValue(seKonwService.getrelaint(segouplisttemp2.get(j).getRelationId())); |
||||
nodelistdss.add(ndoesl2); |
||||
} |
||||
} |
||||
Exports exep = new Exports(); |
||||
exep.setNodes(nodelist.stream().distinct().collect(Collectors.toList())); |
||||
exep.setLinks(nodelistdss); |
||||
return exep; |
||||
}*/ |
||||
|
||||
} |
@ -0,0 +1,11 @@ |
||||
package org.jeecg.modules.demo.seknowgroup.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Data |
||||
public class Exports { |
||||
private List<NodeName> nodes; |
||||
private List<NodeList> links; |
||||
} |
@ -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; |
||||
} |
@ -0,0 +1,9 @@ |
||||
package org.jeecg.modules.demo.seknowgroup.entity; |
||||
|
||||
import lombok.Data; |
||||
|
||||
@Data |
||||
public class NodeName { |
||||
private String name; |
||||
|
||||
} |
@ -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; |
||||
} |
@ -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<SeKnowGroup> { |
||||
|
||||
|
||||
@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<String> 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<SeKonwRelationshipMain> getzxzsnodelist(String id);*/ |
||||
} |
@ -0,0 +1,5 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="org.jeecg.modules.demo.seknowgroup.mapper.SeKnowGroupMapper"> |
||||
|
||||
</mapper> |
@ -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<SeKnowGroup> { |
||||
|
||||
String findpointnode(String id); |
||||
|
||||
List<String> listid(String pointnode); |
||||
|
||||
void deleteknoe(String cid); |
||||
|
||||
void deletereal(String cid); |
||||
|
||||
|
||||
/* List<SeKonwRelationshipMain> getzxzsnodelist(String id);*/ |
||||
} |
@ -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<SeKnowGroupMapper, SeKnowGroup> implements ISeKnowGroupService { |
||||
|
||||
@Autowired |
||||
SeKnowGroupMapper knowGroupMapper; |
||||
|
||||
@Override |
||||
public String findpointnode(String id) { |
||||
return knowGroupMapper.findpointnode(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> 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<SeKonwRelationshipMain> getzxzsnodelist(String id) { |
||||
return knowGroupMapper.getzxzsnodelist(id); |
||||
}*/ |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue