GST002精简

gst2base
Gitea 2 days ago
parent 13d2df7443
commit c3777b9453
  1. 319
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/controller/BasicsskillController.java
  2. 77
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/entity/Basicsskill.java
  3. 35
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/mapper/BasicsskillMapper.java
  4. 25
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/mapper/xml/BasicsskillMapper.xml
  5. 74
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/service/IBasicsskillService.java
  6. 219
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/basicsskill/service/impl/BasicsskillServiceImpl.java
  7. 265
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/controller/CompskillController.java
  8. 71
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/entity/Compskill.java
  9. 53
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/entity/Compskillvo.java
  10. 17
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/mapper/CompskillMapper.java
  11. 5
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/mapper/xml/CompskillMapper.xml
  12. 14
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/service/ICompskillService.java
  13. 19
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/compskill/service/impl/CompskillServiceImpl.java

@ -0,0 +1,319 @@
package org.jeecg.modules.demo.basicsskill.controller;
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.common.system.vo.SelectTreeModel;
import org.jeecg.modules.demo.basicsskill.entity.Basicsskill;
import org.jeecg.modules.demo.basicsskill.service.IBasicsskillService;
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;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 基础能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Api(tags="基础能力设置")
@RestController
@RequestMapping("/basicsskill/basicsskill")
@Slf4j
public class BasicsskillController extends JeecgController<Basicsskill, IBasicsskillService>{
@Autowired
private IBasicsskillService basicsskillService;
/**
* 分页列表查询
*
* @param basicsskill
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "基础能力设置-分页列表查询")
@ApiOperation(value="基础能力设置-分页列表查询", notes="基础能力设置-分页列表查询")
@GetMapping(value = "/rootList")
public Result<IPage<Basicsskill>> queryPageList(Basicsskill basicsskill,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
String hasQuery = req.getParameter("hasQuery");
if(hasQuery != null && "true".equals(hasQuery)){
QueryWrapper<Basicsskill> queryWrapper = QueryGenerator.initQueryWrapper(basicsskill, req.getParameterMap());
List<Basicsskill> list = basicsskillService.queryTreeListNoPage(queryWrapper);
IPage<Basicsskill> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
}else{
String parentId = basicsskill.getPid();
if (oConvertUtils.isEmpty(parentId)) {
parentId = "0";
}
basicsskill.setPid(null);
QueryWrapper<Basicsskill> queryWrapper = QueryGenerator.initQueryWrapper(basicsskill, req.getParameterMap());
// 使用 in 防止模糊查询
queryWrapper.in("pid", "0","1");
Page<Basicsskill> page = new Page<Basicsskill>(pageNo, pageSize);
IPage<Basicsskill> pageList = basicsskillService.page(page, queryWrapper);
for(Basicsskill basicsskill1:pageList.getRecords()){
if(basicsskill1.getPid().equals("0")){
basicsskill1.setPid("专业认证能力评价体系");
}else{
basicsskill1.setPid("创新能力评价体系");
}
}
return Result.OK(pageList);
}
}
/**
* vue3专用加载节点的子数据
*
* @param pid
* @return
*/
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeChildren(@RequestParam(name = "pid") String pid) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = basicsskillService.queryListByPid(pid);
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* vue3专用加载一级节点/如果是同步 则所有数据
*
* @param async
* @param pcode
* @return
*/
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
public Result<List<SelectTreeModel>> loadTreeRoot(@RequestParam(name = "async") Boolean async, @RequestParam(name = "pcode") String pcode) {
Result<List<SelectTreeModel>> result = new Result<>();
try {
List<SelectTreeModel> ls = basicsskillService.queryListByCode(pcode);
if (!async) {
loadAllChildren(ls);
}
result.setResult(ls);
result.setSuccess(true);
} catch (Exception e) {
e.printStackTrace();
result.setMessage(e.getMessage());
result.setSuccess(false);
}
return result;
}
/**
* vue3专用递归求子节点 同步加载用到
*
* @param ls
*/
private void loadAllChildren(List<SelectTreeModel> ls) {
for (SelectTreeModel tsm : ls) {
List<SelectTreeModel> temp = basicsskillService.queryListByPid(tsm.getKey());
if (temp != null && temp.size() > 0) {
tsm.setChildren(temp);
loadAllChildren(temp);
}
}
}
/**
* 获取子数据
* @param basicsskill
* @param req
* @return
*/
//@AutoLog(value = "基础能力设置-获取子数据")
@ApiOperation(value="基础能力设置-获取子数据", notes="基础能力设置-获取子数据")
@GetMapping(value = "/childList")
public Result<IPage<Basicsskill>> queryPageList(Basicsskill basicsskill,HttpServletRequest req) {
QueryWrapper<Basicsskill> queryWrapper = QueryGenerator.initQueryWrapper(basicsskill, req.getParameterMap());
List<Basicsskill> list = basicsskillService.list(queryWrapper);
IPage<Basicsskill> pageList = new Page<>(1, 10, list.size());
for(Basicsskill basicsskill1: list){
Basicsskill basicsskill2=basicsskillService.query().eq("id",basicsskill1.getPid()).one();
if(basicsskill2!=null)
basicsskill1.setPid(basicsskill2.getName());
}
pageList.setRecords(list);
return Result.OK(pageList);
}
/**
* 批量查询子节点
* @param parentIds 父ID多个采用半角逗号分割
* @return 返回 IPage
* @param parentIds
* @return
*/
//@AutoLog(value = "基础能力设置-批量获取子数据")
@ApiOperation(value="基础能力设置-批量获取子数据", notes="基础能力设置-批量获取子数据")
@GetMapping("/getChildListBatch")
public Result getChildListBatch(@RequestParam("parentIds") String parentIds) {
try {
QueryWrapper<Basicsskill> queryWrapper = new QueryWrapper<>();
List<String> parentIdList = Arrays.asList(parentIds.split(","));
queryWrapper.in("pid", parentIdList);
List<Basicsskill> list = basicsskillService.list(queryWrapper);
IPage<Basicsskill> pageList = new Page<>(1, 10, list.size());
pageList.setRecords(list);
return Result.OK(pageList);
} catch (Exception e) {
log.error(e.getMessage(), e);
return Result.error("批量查询子节点失败:" + e.getMessage());
}
}
/**
* 添加
*
* @param basicsskill
* @return
*/
@AutoLog(value = "基础能力设置-添加")
@ApiOperation(value="基础能力设置-添加", notes="基础能力设置-添加")
//@RequiresPermissions("basicsskill:basicsskill:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody Basicsskill basicsskill) {
basicsskillService.addBasicsskill(basicsskill);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param basicsskill
* @return
*/
@AutoLog(value = "基础能力设置-编辑")
@ApiOperation(value="基础能力设置-编辑", notes="基础能力设置-编辑")
// @RequiresPermissions("basicsskill:basicsskill:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody Basicsskill basicsskill) {
if(basicsskill.getPid().equals("专业认证能力评价体系")){
basicsskill.setPid("0");
}else if(basicsskill.getPid().equals("创新能力评价体系")){
basicsskill.setPid("1");
}else {
basicsskill.setPid(basicsskillService.getById(basicsskill.getId()).getPid());
}
basicsskillService.updateBasicsskill(basicsskill);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "基础能力设置-通过id删除")
@ApiOperation(value="基础能力设置-通过id删除", notes="基础能力设置-通过id删除")
//@RequiresPermissions("basicsskill:basicsskill:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
basicsskillService.deleteBasicsskill(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "基础能力设置-批量删除")
@ApiOperation(value="基础能力设置-批量删除", notes="基础能力设置-批量删除")
//@RequiresPermissions("basicsskill:basicsskill:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.basicsskillService.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<Basicsskill> queryById(@RequestParam(name="id",required=true) String id) {
Basicsskill basicsskill = basicsskillService.getById(id);
if(basicsskill==null) {
return Result.error("未找到对应数据");
}
return Result.OK(basicsskill);
}
/**
* 导出excel
*
* @param request
* @param basicsskill
*/
// @RequiresPermissions("basicsskill:basicsskill:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Basicsskill basicsskill) {
return super.exportXls(request, basicsskill, Basicsskill.class, "基础能力设置");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
/* @RequiresPermissions("basicsskill:basicsskill:importExcel")*/
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Basicsskill.class);
}
}

@ -0,0 +1,77 @@
package org.jeecg.modules.demo.basicsskill.entity;
import java.io.Serializable;
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 com.baomidou.mybatisplus.annotation.TableLogic;
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 java.io.UnsupportedEncodingException;
/**
* @Description: 基础能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Data
@TableName("basicsskill")
@ApiModel(value="basicsskill对象", description="基础能力设置")
public class Basicsskill 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 pid;
/**名称*/
@Excel(name = "名称", width = 15)
@ApiModelProperty(value = "名称")
private String name;
/**备注*/
@Excel(name = "备注", width = 15)
@ApiModelProperty(value = "备注")
private String remark;
/**是否有子节点*/
@Excel(name = "是否有子节点", width = 15, dicCode = "yn")
@Dict(dicCode = "yn")
@ApiModelProperty(value = "是否有子节点")
private String hasChild;
/**
* 启停
*/
@Excel(name = "启停", width = 15)
@ApiModelProperty(value = "启停")
private String startstop;
}

@ -0,0 +1,35 @@
package org.jeecg.modules.demo.basicsskill.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.demo.basicsskill.entity.Basicsskill;
import java.util.List;
import java.util.Map;
/**
* @Description: 基础能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface BasicsskillMapper extends BaseMapper<Basicsskill> {
/**
* 编辑节点状态
* @param id
* @param status
*/
void updateTreeNodeStatus(@Param("id") String id,@Param("status") String status);
/**
* vue3专用根据父级ID查询树节点数据
*
* @param pid
* @param query
* @return
*/
List<SelectTreeModel> queryListByPid(@Param("pid") String pid, @Param("query") Map<String, String> query);
}

@ -0,0 +1,25 @@
<?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.basicsskill.mapper.BasicsskillMapper">
<update id="updateTreeNodeStatus" parameterType="java.lang.String">
update basicsskill set has_child = #{status} where id = #{id}
</update>
<!-- 【vue3专用】 -->
<select id="queryListByPid" parameterType="java.lang.Object" resultType="org.jeecg.common.system.vo.SelectTreeModel">
select
id as "key",
name as "title",
(case when has_child = '1' then 0 else 1 end) as isLeaf,
pid as parentId
from basicsskill
where pid = #{pid}
<if test="query != null">
<foreach collection="query.entrySet()" item="value" index="key">
and ${key} = #{value}
</foreach>
</if>
</select>
</mapper>

@ -0,0 +1,74 @@
package org.jeecg.modules.demo.basicsskill.service;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.demo.basicsskill.entity.Basicsskill;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.common.exception.JeecgBootException;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.util.List;
/**
* @Description: 基础能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface IBasicsskillService extends IService<Basicsskill> {
/**根节点父ID的值*/
public static final String ROOT_PID_VALUE = "0";
/**树节点有子节点状态值*/
public static final String HASCHILD = "1";
/**树节点无子节点状态值*/
public static final String NOCHILD = "0";
/**
* 新增节点
*
* @param basicsskill
*/
void addBasicsskill(Basicsskill basicsskill);
/**
* 修改节点
*
* @param basicsskill
* @throws JeecgBootException
*/
void updateBasicsskill(Basicsskill basicsskill) throws JeecgBootException;
/**
* 删除节点
*
* @param id
* @throws JeecgBootException
*/
void deleteBasicsskill(String id) throws JeecgBootException;
/**
* 查询所有数据无分页
*
* @param queryWrapper
* @return List<Basicsskill>
*/
List<Basicsskill> queryTreeListNoPage(QueryWrapper<Basicsskill> queryWrapper);
/**
* vue3专用根据父级编码加载分类字典的数据
*
* @param parentCode
* @return
*/
List<SelectTreeModel> queryListByCode(String parentCode);
/**
* vue3专用根据pid查询子节点集合
*
* @param pid
* @return
*/
List<SelectTreeModel> queryListByPid(String pid);
}

@ -0,0 +1,219 @@
package org.jeecg.modules.demo.basicsskill.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.common.system.vo.SelectTreeModel;
import org.jeecg.modules.demo.basicsskill.entity.Basicsskill;
import org.jeecg.modules.demo.basicsskill.mapper.BasicsskillMapper;
import org.jeecg.modules.demo.basicsskill.service.IBasicsskillService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 基础能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Service
public class BasicsskillServiceImpl extends ServiceImpl<BasicsskillMapper, Basicsskill> implements IBasicsskillService {
@Override
public void addBasicsskill(Basicsskill basicsskill) {
//新增时设置hasChild为0
basicsskill.setHasChild(IBasicsskillService.NOCHILD);
if(oConvertUtils.isEmpty(basicsskill.getPid())){
basicsskill.setPid(IBasicsskillService.ROOT_PID_VALUE);
}else{
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
Basicsskill parent = baseMapper.selectById(basicsskill.getPid());
if(parent!=null && !"1".equals(parent.getHasChild())){
parent.setHasChild("1");
baseMapper.updateById(parent);
}
}
baseMapper.insert(basicsskill);
}
@Override
public void updateBasicsskill(Basicsskill basicsskill) {
Basicsskill entity = this.getById(basicsskill.getId());
if(entity==null) {
throw new JeecgBootException("未找到对应实体");
}
String old_pid = entity.getPid();
String new_pid = basicsskill.getPid();
if(!old_pid.equals(new_pid)) {
updateOldParentNode(old_pid);
if(oConvertUtils.isEmpty(new_pid)){
basicsskill.setPid(IBasicsskillService.ROOT_PID_VALUE);
}
if(!IBasicsskillService.ROOT_PID_VALUE.equals(basicsskill.getPid())) {
baseMapper.updateTreeNodeStatus(basicsskill.getPid(), IBasicsskillService.HASCHILD);
}
}
baseMapper.updateById(basicsskill);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBasicsskill(String id) throws JeecgBootException {
//查询选中节点下所有子节点一并删除
id = this.queryTreeChildIds(id);
if(id.indexOf(",")>0) {
StringBuffer sb = new StringBuffer();
String[] idArr = id.split(",");
for (String idVal : idArr) {
if(idVal != null){
Basicsskill basicsskill = this.getById(idVal);
String pidVal = basicsskill.getPid();
//查询此节点上一级是否还有其他子节点
List<Basicsskill> dataList = baseMapper.selectList(new QueryWrapper<Basicsskill>().eq("pid", pidVal).notIn("id",Arrays.asList(idArr)));
boolean flag = (dataList == null || dataList.size() == 0) && !Arrays.asList(idArr).contains(pidVal) && !sb.toString().contains(pidVal);
if(flag){
//如果当前节点原本有子节点 现在木有了,更新状态
sb.append(pidVal).append(",");
}
}
}
//批量删除节点
baseMapper.deleteBatchIds(Arrays.asList(idArr));
//修改已无子节点的标识
String[] pidArr = sb.toString().split(",");
for(String pid : pidArr){
this.updateOldParentNode(pid);
}
}else{
Basicsskill basicsskill = this.getById(id);
if(basicsskill==null) {
throw new JeecgBootException("未找到对应实体");
}
updateOldParentNode(basicsskill.getPid());
baseMapper.deleteById(id);
}
}
@Override
public List<Basicsskill> queryTreeListNoPage(QueryWrapper<Basicsskill> queryWrapper) {
List<Basicsskill> dataList = baseMapper.selectList(queryWrapper);
List<Basicsskill> mapList = new ArrayList<>();
for(Basicsskill data : dataList){
String pidVal = data.getPid();
//递归查询子节点的根节点
if(pidVal != null && !IBasicsskillService.NOCHILD.equals(pidVal)){
Basicsskill rootVal = this.getTreeRoot(pidVal);
if(rootVal != null && !mapList.contains(rootVal)){
mapList.add(rootVal);
}
}else{
if(!mapList.contains(data)){
mapList.add(data);
}
}
}
return mapList;
}
@Override
public List<SelectTreeModel> queryListByCode(String parentCode) {
String pid = ROOT_PID_VALUE;
if (oConvertUtils.isNotEmpty(parentCode)) {
LambdaQueryWrapper<Basicsskill> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(Basicsskill::getPid, parentCode);
List<Basicsskill> list = baseMapper.selectList(queryWrapper);
if (list == null || list.size() == 0) {
throw new JeecgBootException("该编码【" + parentCode + "】不存在,请核实!");
}
if (list.size() > 1) {
throw new JeecgBootException("该编码【" + parentCode + "】存在多个,请核实!");
}
pid = list.get(0).getId();
}
return baseMapper.queryListByPid(pid, null);
}
@Override
public List<SelectTreeModel> queryListByPid(String pid) {
if (oConvertUtils.isEmpty(pid)) {
pid = ROOT_PID_VALUE;
}
return baseMapper.queryListByPid(pid, null);
}
/**
* 根据所传pid查询旧的父级节点的子节点并修改相应状态值
* @param pid
*/
private void updateOldParentNode(String pid) {
if(!IBasicsskillService.ROOT_PID_VALUE.equals(pid)) {
Long count = baseMapper.selectCount(new QueryWrapper<Basicsskill>().eq("pid", pid));
if(count==null || count<=1) {
baseMapper.updateTreeNodeStatus(pid, IBasicsskillService.NOCHILD);
}
}
}
/**
* 递归查询节点的根节点
* @param pidVal
* @return
*/
private Basicsskill getTreeRoot(String pidVal){
Basicsskill data = baseMapper.selectById(pidVal);
if(data != null && !IBasicsskillService.ROOT_PID_VALUE.equals(data.getPid())){
return this.getTreeRoot(data.getPid());
}else{
return data;
}
}
/**
* 根据id查询所有子节点id
* @param ids
* @return
*/
private String queryTreeChildIds(String ids) {
//获取id数组
String[] idArr = ids.split(",");
StringBuffer sb = new StringBuffer();
for (String pidVal : idArr) {
if(pidVal != null){
if(!sb.toString().contains(pidVal)){
if(sb.toString().length() > 0){
sb.append(",");
}
sb.append(pidVal);
this.getTreeChildIds(pidVal,sb);
}
}
}
return sb.toString();
}
/**
* 递归查询所有子节点
* @param pidVal
* @param sb
* @return
*/
private StringBuffer getTreeChildIds(String pidVal,StringBuffer sb){
List<Basicsskill> dataList = baseMapper.selectList(new QueryWrapper<Basicsskill>().eq("pid", pidVal));
if(dataList != null && dataList.size()>0){
for(Basicsskill tree : dataList) {
if(!sb.toString().contains(tree.getId())){
sb.append(",").append(tree.getId());
}
this.getTreeChildIds(tree.getId(),sb);
}
}
return sb;
}
}

@ -0,0 +1,265 @@
package org.jeecg.modules.demo.compskill.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.demo.annual.entity.Annual;
import org.jeecg.modules.demo.annual.service.IAnnualService;
import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint;
import org.jeecg.modules.demo.annualCompPoint.service.IAnnualCompPointService;
import org.jeecg.modules.demo.annualcomp.entity.AnnualComp;
import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService;
import org.jeecg.modules.demo.basicsskill.entity.Basicsskill;
import org.jeecg.modules.demo.basicsskill.service.IBasicsskillService;
import org.jeecg.modules.demo.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
import org.jeecg.modules.demo.compskill.entity.Compskill;
import org.jeecg.modules.demo.compskill.entity.Compskillvo;
import org.jeecg.modules.demo.compskill.service.ICompskillService;
import org.jeecg.modules.system.entity.SysRole;
import org.jeecg.modules.system.service.ISysUserRoleService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 项目能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Api(tags = "项目能力设置")
@RestController
@RequestMapping("/compskill/compskill")
@Slf4j
public class CompskillController extends JeecgController<Compskill, ICompskillService> {
@Autowired
private ICompskillService compskillService;
@Autowired
private IAnnualCompPointService annualCompPointService;
@Autowired
private IBasicsskillService basicsskillService;
@Autowired
private IAnnualService annualService;
@Autowired
private IAnnualCompService annualCompService;
@Autowired
private ICompService iCompService;
@Autowired
private ISysUserRoleService iSysUserRoleService;
/**
* 分页列表查询
*
* @param compskill
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "项目能力设置-分页列表查询")
@ApiOperation(value = "项目能力设置-分页列表查询", notes = "项目能力设置-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<Compskillvo>> queryPageList(Compskill compskill,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Subject subject = SecurityUtils.getSubject();
// 获取当前登录用户
LoginUser loginUser = (LoginUser) subject.getPrincipal();
List<SysRole> roleList = iSysUserRoleService.getUserRoleByUserId(loginUser.getId());
Map<String, String> roleMap = Optional.ofNullable(roleList).orElse(new LinkedList<>()).stream().collect(Collectors.toMap(SysRole::getRoleCode, SysRole::getRoleCode));
//角色编码 管理员&组委会&学校管理员 可以看到所有,其它用户可见到所属自己数据
Map<String, String> efficientRoleMap = new LinkedHashMap<>();
efficientRoleMap.put("admin", "admin");
efficientRoleMap.put("committee", "committee");
efficientRoleMap.put("superAdmin", "superAdmin");
LambdaQueryWrapper<Compskill> queryWrapper = new LambdaQueryWrapper<>();
// 查询所属当前登录用户数据
if (efficientRoleMap.containsValue(roleMap.get("admin"))
|| efficientRoleMap.containsValue(roleMap.get("committee"))
|| efficientRoleMap.containsValue(roleMap.get("superAdmin"))) {
List<Comp> compList = iCompService.list(new LambdaQueryWrapper<Comp>().eq(Comp::getCompAdmin, loginUser.getUsername()));
if (!ObjectUtils.isEmpty(compList)) {
Set<String> compIds = compList.stream().map(c -> c.getId()).collect(Collectors.toSet());
List<AnnualComp> annualCompList = annualCompService.list(new LambdaQueryWrapper<AnnualComp>().in(AnnualComp::getCompid, compIds));
if (!ObjectUtils.isEmpty(annualCompList)) {
Set<String> annualCompIds = annualCompList.stream().map(d -> d.getId()).collect(Collectors.toSet());
List<AnnualCompPoint> annualCompPointList = annualCompPointService.list(new LambdaQueryWrapper<AnnualCompPoint>().in(AnnualCompPoint::getAnnualCompId, annualCompIds));
if (!ObjectUtils.isEmpty(annualCompPointList)) {
Set<String> annualCompPointIds = annualCompPointList.stream().map(e -> e.getId()).collect(Collectors.toSet());
queryWrapper.in(Compskill::getAnnucompid, annualCompPointIds);
}
}
}
}
Page<Compskill> page = new Page<Compskill>(pageNo, pageSize);
Page<Compskillvo> page1 = new Page<>();
compskillService.page(page, queryWrapper);
BeanUtils.copyProperties(page, page1, "records");
List<Compskillvo> list = page.getRecords().stream().map((item) -> {
Compskillvo compskill1 = new Compskillvo();
BeanUtils.copyProperties(item, compskill1);
AnnualCompPoint annualCompPoint = annualCompPointService.query().eq("id", compskill1.getAnnucompid()).one();
AnnualComp annualComp = null;
Annual annual = null;
if (annualCompPoint != null) {
annualComp = annualCompService.query().eq("id", annualCompPoint.getAnnualCompId()).one();
}
if (annualComp != null) {
annual = annualService.query().eq("id", annualComp.getAnnualid()).one();
}
List<Basicsskill> basicsskillList= basicsskillService.query().eq("id", compskill1.getCapacityid()).list();
Basicsskill basicsskill=null;
if(basicsskillList.size()>0)
{
basicsskill=basicsskillList.get(0);
}
if (annualCompPoint != null && basicsskill != null && annualComp != null && annual != null) {
compskill1.setAnnucompid(annualCompPoint.getObjName());
compskill1.setCapacityid(basicsskill.getName());
compskill1.setComp(annualComp.getName());
compskill1.setAnnual(annual.getAnnualName());
}
return compskill1;
}).collect(Collectors.toList());
page1.setRecords(list);
return Result.OK(page1);
}
/**
* 添加
*
* @param compskill
* @return
*/
@AutoLog(value = "项目能力设置-添加")
@ApiOperation(value = "项目能力设置-添加", notes = "项目能力设置-添加")
//@RequiresPermissions("compskill:compskill:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody Compskill compskill) {
/* if (compskill != null) {
AnnualCompPoint annualCompPoint = annualCompPointService.query().eq("obj_name", compskill.getAnnucompid()).one();
Basicsskill basicsskill = basicsskillService.query().eq("name", compskill.getCapacityid()).one();
if (annualCompPoint != null && basicsskill != null) {
compskill.setAnnucompid(annualCompPoint.getId());
compskill.setCapacityid(basicsskill.getId());
}
}*/
compskillService.save(compskill);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param compskill
* @return
*/
@AutoLog(value = "项目能力设置-编辑")
@ApiOperation(value = "项目能力设置-编辑", notes = "项目能力设置-编辑")
//@RequiresPermissions("compskill:compskill:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody Compskill compskill) {
compskillService.updateById(compskill);
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "项目能力设置-通过id删除")
@ApiOperation(value = "项目能力设置-通过id删除", notes = "项目能力设置-通过id删除")
//@RequiresPermissions("compskill:compskill:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
compskillService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "项目能力设置-批量删除")
@ApiOperation(value = "项目能力设置-批量删除", notes = "项目能力设置-批量删除")
//@RequiresPermissions("compskill:compskill:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.compskillService.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<Compskill> queryById(@RequestParam(name = "id", required = true) String id) {
Compskill compskill = compskillService.getById(id);
if (compskill == null) {
return Result.error("未找到对应数据");
}
return Result.OK(compskill);
}
/**
* 导出excel
*
* @param request
* @param compskill
*/
// @RequiresPermissions("compskill:compskill:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, Compskill compskill) {
return super.exportXls(request, compskill, Compskill.class, "项目能力设置");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("compskill:compskill:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, Compskill.class);
}
}

@ -0,0 +1,71 @@
package org.jeecg.modules.demo.compskill.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 com.baomidou.mybatisplus.annotation.TableLogic;
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: 2023-08-17
* @Version: V1.0
*/
@Data
@TableName("compskill")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="compskill对象", description="项目能力设置")
public class Compskill 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;
/**年度比赛项目id*/
@Excel(name = "年度比赛项目id", width = 15)
@ApiModelProperty(value = "年度比赛项目id")
private String annucompid;
/**能力id*/
@Excel(name = "能力id", width = 15)
@ApiModelProperty(value = "能力id")
private String capacityid;
/**权值*/
@Excel(name = "权值", width = 15)
@ApiModelProperty(value = "权值")
private Integer weight;
}

@ -0,0 +1,53 @@
package org.jeecg.modules.demo.compskill.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class Compskillvo {
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;
/**年度比赛项目id*/
@Excel(name = "年度比赛项目id", width = 15)
@ApiModelProperty(value = "年度比赛项目id")
private String annucompid;
/**能力id*/
@Excel(name = "能力id", width = 15)
@ApiModelProperty(value = "能力id")
private String capacityid;
/**权值*/
@Excel(name = "权值", width = 15)
@ApiModelProperty(value = "权值")
private Integer weight;
private String annual;
private String comp;
}

@ -0,0 +1,17 @@
package org.jeecg.modules.demo.compskill.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.compskill.entity.Compskill;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 项目能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface CompskillMapper extends BaseMapper<Compskill> {
}

@ -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.compskill.mapper.CompskillMapper">
</mapper>

@ -0,0 +1,14 @@
package org.jeecg.modules.demo.compskill.service;
import org.jeecg.modules.demo.compskill.entity.Compskill;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 项目能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
public interface ICompskillService extends IService<Compskill> {
}

@ -0,0 +1,19 @@
package org.jeecg.modules.demo.compskill.service.impl;
import org.jeecg.modules.demo.compskill.entity.Compskill;
import org.jeecg.modules.demo.compskill.mapper.CompskillMapper;
import org.jeecg.modules.demo.compskill.service.ICompskillService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 项目能力设置
* @Author: jeecg-boot
* @Date: 2023-08-17
* @Version: V1.0
*/
@Service
public class CompskillServiceImpl extends ServiceImpl<CompskillMapper, Compskill> implements ICompskillService {
}
Loading…
Cancel
Save