Compare commits

...

2 Commits

Author SHA1 Message Date
zhangqun 6a1bacefa5 Merge remote-tracking branch 'origin/main' 1 year ago
zhangqun 52b7854cd0 知识库附件内容修改 1 year ago
  1. 2
      src/main/java/org/springblade/modules/system/service/impl/LogApiServiceImpl.java
  2. 162
      src/main/java/org/springblade/modules/workOrder/controller/KnowledgeDetailsController.java
  3. 28
      src/main/java/org/springblade/modules/workOrder/dto/KnowledgeDetailsDTO.java
  4. 32
      src/main/java/org/springblade/modules/workOrder/entity/Attachs.java
  5. 47
      src/main/java/org/springblade/modules/workOrder/entity/KnowledgeDetails.java
  6. 37
      src/main/java/org/springblade/modules/workOrder/mapper/AttachsMapper.java
  7. 12
      src/main/java/org/springblade/modules/workOrder/mapper/AttachsMapper.xml
  8. 40
      src/main/java/org/springblade/modules/workOrder/mapper/KnowledgeDetailsMapper.java
  9. 23
      src/main/java/org/springblade/modules/workOrder/service/IAttachaService.java
  10. 41
      src/main/java/org/springblade/modules/workOrder/service/IKnowledgeDetailsService.java
  11. 29
      src/main/java/org/springblade/modules/workOrder/service/impl/AttachsServiceImpl.java
  12. 143
      src/main/java/org/springblade/modules/workOrder/service/impl/KnowledgeDetailsServiceImpl.java
  13. 22
      src/main/java/org/springblade/modules/workOrder/vo/AttachVO.java

@ -31,7 +31,7 @@ public class LogApiServiceImpl extends ServiceImpl<LogApiMapper, LogApi> impleme
@Override
public List<LogRecord> logOnList(LogDTO log) {
if(log.getUserId() != null){
if(!log.getUserId().isEmpty()){
User user = UserCache.getUser(Long.valueOf(log.getUserId()));
log.setUserId(user.getAccount());
}

@ -0,0 +1,162 @@
package org.springblade.modules.workOrder.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.common.cache.DictBizCache;
import org.springblade.common.cache.UserCache;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.capital.entity.Goods;
import org.springblade.modules.resource.entity.Attach;
import org.springblade.modules.system.entity.User;
import org.springblade.modules.workOrder.dto.InformationDTO;
import org.springblade.modules.workOrder.dto.KnowledgeBaseDTO;
import org.springblade.modules.workOrder.dto.KnowledgeDetailsDTO;
import org.springblade.modules.workOrder.entity.*;
import org.springblade.modules.workOrder.excel.KnowledgeBaseExcel;
import org.springblade.modules.workOrder.service.IAttachaService;
import org.springblade.modules.workOrder.service.IDeviceService;
import org.springblade.modules.workOrder.service.IKnowledgeBaseService;
import org.springblade.modules.workOrder.service.IKnowledgeDetailsService;
import org.springblade.modules.workOrder.vo.AttachVO;
import org.springblade.modules.workOrder.vo.DeviceVO;
import org.springblade.modules.workOrder.vo.KnowledgeBaseVO;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.*;
import static org.springblade.common.enums.DictBizEnum.*;
/**
* 知识库表 控制器
*
* @author BladeX
* @since 2024-10-26
*/
@RestController
@AllArgsConstructor
@RequestMapping("/knowledgeDetails")
@Api(value = "知识库表", tags = "知识库表接口")
public class KnowledgeDetailsController extends BladeController {
private final IKnowledgeDetailsService knowledgeDetailsService;
/**
* 知识库内容提报操作
*/
@PostMapping("/insertKnowledgeContent")
@ApiOperationSupport(order = 1)
@ApiOperation(value = "知识库内容提报操作", notes = "传入knowledgeDetails")
public R<?> insertKnowledgeContent(@ApiIgnore @RequestBody KnowledgeDetailsDTO knowledgeDetailsDTO, HttpServletResponse response) {
// 查询用户信息
User user = UserCache.getUser(knowledgeDetailsDTO.getUserId());
// 查询缓存中 blade_dict_biz 字典
String value = DictBizCache.getValue(KNOWLEDGE_TYPE, knowledgeDetailsDTO.getDictKey());
// 判断用户和知识库类别入参是否合规
if(user == null && value == null){
return R.fail("入参内容不合规(userId、dictKey)");
}
// 插入数据库操作
KnowledgeDetails knowledgeDetails = knowledgeDetailsService.insertKnowledgeContent(knowledgeDetailsDTO);
// 判断是否插入成功
if(knowledgeDetails != null){
return R.data(knowledgeDetails,"知识库提报成功");
}else{
return R.fail("知识库数据插入失败");
}
}
/**
* 知识库表 分页查询
*/
@GetMapping("/list")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "分页", notes = "传入goods")
public R<IPage<KnowledgeDetails>> list(@ApiIgnore @RequestParam Map<String, Object> knowledgeDetails, Query query) {
LambdaQueryWrapper<KnowledgeDetails> wrapper = Wrappers.lambdaQuery(KnowledgeDetails.class)
.eq(StringUtils.isNotBlank((CharSequence) knowledgeDetails.get("dictKey")), KnowledgeDetails::getDictKey, knowledgeDetails.get("dictKey"));
IPage<KnowledgeDetails> pages = knowledgeDetailsService.page(Condition.getPage(query), wrapper);
List<KnowledgeDetails> records = pages.getRecords();
for (KnowledgeDetails record : records) {
LinkedList<AttachVO> attachVOS = new LinkedList<>();
for (int i = 0; i < record.getAttachUrl().split(",").length; i++) {
AttachVO attachVO1 = new AttachVO();
attachVO1.setAttachName(record.getAttachName().split(",")[i]);
attachVO1.setAttachUrl(record.getAttachUrl().split(",")[i]);
attachVOS.add(attachVO1);
}
record.setAttach(attachVOS);
}
return R.data(pages);
}
/**
* 日志表 详情
*/
@GetMapping("/detail")
@ApiOperationSupport(order = 3)
@ApiOperation(value = "详情", notes = "传入device")
public R<KnowledgeDetails> detail(KnowledgeDetails knowledgeDetails) {
KnowledgeDetails detail = knowledgeDetailsService.getById(knowledgeDetails.getId());
LinkedList<AttachVO> attachVOS = new LinkedList<>();
for (int i = 0; i < detail.getAttachUrl().split(",").length; i++) {
AttachVO attachVO1 = new AttachVO();
attachVO1.setAttachName(detail.getAttachName().split(",")[i]);
attachVO1.setAttachUrl(detail.getAttachUrl().split(",")[i]);
attachVOS.add(attachVO1);
}
KnowledgeDetails knowledgeBaseVO = Objects.requireNonNull(BeanUtil.copy(detail, KnowledgeDetails.class));
knowledgeBaseVO.setAttach(attachVOS);
return R.data(knowledgeBaseVO);
}
/**
* 知识库 删除
*/
@PostMapping("/remove")
@ApiOperationSupport(order = 4)
@ApiOperation(value = "逻辑删除", notes = "传入ids")
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
return R.status(knowledgeDetailsService.deleteLogic(Func.toLongList(ids)));
}
/**
* 资料表 修改
*/
@PostMapping("/update")
@ApiOperationSupport(order = 5)
@ApiOperation(value = "修改", notes = "传入information")
public R update(@Valid @RequestBody KnowledgeDetails knowledgeDetails) {
return R.status(knowledgeDetailsService.updateById(knowledgeDetails));
}
}

@ -0,0 +1,28 @@
package org.springblade.modules.workOrder.dto;
import lombok.Data;
import org.springblade.modules.resource.entity.Attach;
import org.springblade.modules.workOrder.entity.Attachs;
import org.springblade.modules.workOrder.vo.AttachVO;
import java.io.Serializable;
import java.util.List;
/**
知识库表提报数据插入实体类
@date: 2024年11月14日14:03:25
*/
@Data
public class KnowledgeDetailsDTO implements Serializable {
private static final long serialVersionUID = 1L;
// 知识库类别
private String dictKey;
// 知识库内容
private String content;
// 用户id
private Long userId;
// 附件集合
List<Attachs> attach;
}

@ -0,0 +1,32 @@
package org.springblade.modules.workOrder.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
/*
附件表实体类
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class Attachs extends BaseEntity {
@TableId(
value = "id",
type = IdType.ASSIGN_ID
)
private Long id;
private String attachUrl;
private String attachName;
private Long relationId;
private Long createUser;
private Long createDept;
private Date createTime;
private Long updateUser;
private Date updateTime;
private Integer isDeleted;
}

@ -0,0 +1,47 @@
package org.springblade.modules.workOrder.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.simpleframework.xml.Transient;
import org.springblade.core.mp.base.BaseEntity;
import org.springblade.modules.workOrder.vo.AttachVO;
import java.util.Date;
import java.util.List;
/**
* Auto-generated: 2024-11-14 14:23:9
*
* @author bejson.com (i@bejson.com)
* @website http://www.bejson.com/java2pojo/
*/
@Data
@TableName("busin_knowledge_details")
@ApiModel(value = "KnowledgeDetails对象", description = "知识库内容提交表")
public class KnowledgeDetails extends BaseEntity {
// 主键id
@TableId(
value = "id",
type = IdType.ASSIGN_ID
)
private Long id;
// 知识库类型
private String dictKey;
// 附件url
@JsonIgnore
private String attachUrl;
// 附件名
@JsonIgnore
private String attachName;
// 知识库内容
private String content;
@TableField(exist = false)
private List<AttachVO> attach;
}

@ -0,0 +1,37 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.workOrder.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springblade.modules.workOrder.entity.Attachs;
import org.springblade.modules.workOrder.entity.KnowledgeDetails;
import java.util.List;
/**
* 知识库表 Mapper 接口
*
* @author BladeX
* @since 2024-10-26
*/
@Mapper
public interface AttachsMapper extends BaseMapper<Attachs> {
int insertBatch(List<Attachs> list);
}

@ -0,0 +1,12 @@
<?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.springblade.modules.workOrder.mapper.AttachsMapper">
<insert id="insertBatch" parameterType="java.util.List">
insert into busin_attachs( attach_url, attach_name, relation_id,create_user,create_time) values
<foreach collection="list" item="item" separator=",">
(#{attachUrl},#{attachName},#{relationId},#{createUser},#{createTime})
</foreach>
</insert>
</mapper>

@ -0,0 +1,40 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.workOrder.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.workOrder.entity.KnowledgeBase;
import org.springblade.modules.workOrder.entity.KnowledgeDetails;
import org.springblade.modules.workOrder.excel.KnowledgeBaseExcel;
import org.springblade.modules.workOrder.vo.KnowledgeBaseVO;
import java.util.List;
/**
* 知识库表 Mapper 接口
*
* @author BladeX
* @since 2024-10-26
*/
@Mapper
public interface KnowledgeDetailsMapper extends BaseMapper<KnowledgeDetails> {
}

@ -0,0 +1,23 @@
package org.springblade.modules.workOrder.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.workOrder.entity.Attachs;
import org.springblade.modules.workOrder.entity.DeviceAttach;
import org.springblade.modules.workOrder.excel.DeviceAttachExcel;
import org.springblade.modules.workOrder.vo.DeviceAttachVO;
import java.util.List;
/**
* 设备附件表 服务类
*
* @author BladeX
* @since 2024-10-14
*/
public interface IAttachaService extends BaseService<Attachs> {
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.workOrder.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.workOrder.dto.KnowledgeBaseDTO;
import org.springblade.modules.workOrder.dto.KnowledgeDetailsDTO;
import org.springblade.modules.workOrder.entity.KnowledgeBase;
import org.springblade.modules.workOrder.entity.KnowledgeDetails;
import org.springblade.modules.workOrder.excel.KnowledgeBaseExcel;
import org.springblade.modules.workOrder.vo.KnowledgeBaseVO;
import java.util.List;
/**
* 知识库表 服务类
*
* @author BladeX
* @since 2024-10-26
*/
public interface IKnowledgeDetailsService extends BaseService<KnowledgeDetails> {
KnowledgeDetails insertKnowledgeContent(KnowledgeDetailsDTO knowledgeDetailsDTO);
}

@ -0,0 +1,29 @@
package org.springblade.modules.workOrder.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.modules.workOrder.entity.Attachs;
import org.springblade.modules.workOrder.entity.DeviceAttach;
import org.springblade.modules.workOrder.excel.DeviceAttachExcel;
import org.springblade.modules.workOrder.mapper.AttachsMapper;
import org.springblade.modules.workOrder.mapper.DeviceAttachMapper;
import org.springblade.modules.workOrder.service.IAttachaService;
import org.springblade.modules.workOrder.service.IDeviceAttachService;
import org.springblade.modules.workOrder.vo.DeviceAttachVO;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 设备附件表 服务实现类
*
* @author BladeX
* @since 2024-10-14
*/
@Service
public class AttachsServiceImpl extends BaseServiceImpl<AttachsMapper, Attachs> implements IAttachaService {
}

@ -0,0 +1,143 @@
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu.net developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163.com)
*/
package org.springblade.modules.workOrder.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springblade.common.cache.DictBizCache;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.modules.workOrder.dto.KnowledgeBaseDTO;
import org.springblade.modules.workOrder.dto.KnowledgeDetailsDTO;
import org.springblade.modules.workOrder.entity.*;
import org.springblade.modules.workOrder.excel.KnowledgeBaseExcel;
import org.springblade.modules.workOrder.mapper.AttachsMapper;
import org.springblade.modules.workOrder.mapper.KnowledgeBaseMapper;
import org.springblade.modules.workOrder.mapper.KnowledgeDetailsMapper;
import org.springblade.modules.workOrder.service.*;
import org.springblade.modules.workOrder.vo.AttachVO;
import org.springblade.modules.workOrder.vo.KnowledgeBaseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import static org.springblade.common.enums.DictBizEnum.FAULT_TYPE;
import static org.springblade.common.enums.DictBizEnum.KNOWLEDGE_TYPE;
/**
* 知识库表 服务实现类
*
* @author BladeX
* @since 2024年11月14日14:30:27
*/
@Service
@AllArgsConstructor
public class KnowledgeDetailsServiceImpl extends BaseServiceImpl<KnowledgeDetailsMapper, KnowledgeDetails> implements IKnowledgeDetailsService {
private final KnowledgeDetailsMapper knowledgeDetailsMapper;
private final IAttachaService attachaService;
@Autowired
AttachsMapper attachsMapper;
@Override
public KnowledgeDetails insertKnowledgeContent(KnowledgeDetailsDTO knowledgeDetailsDTO) {
KnowledgeDetails knowledgeDetails = new KnowledgeDetails();
// 将传入的附件
// StringBuilder resultUrl = new StringBuilder();
// StringBuilder resultName = new StringBuilder();
// for (AttachVO attachVO : knowledgeDetailsDTO.getAttach()) {
// resultUrl.append(attachVO.getAttachUrl()).append(",");
// resultName.append(attachVO.getAttachName()).append(",");
// }
// // 移除最后的逗号
// resultUrl.deleteCharAt(resultUrl.length() - 1);
// resultName.deleteCharAt(resultName.length() - 1);
try {
// knowledgeDetailsDTO.getAttach().stream().collect(Collectors.joining(","));
// 实体类数据封装
knowledgeDetails.setCreateTime(new Date());
knowledgeDetails.setContent(knowledgeDetailsDTO.getContent());
knowledgeDetails.setDictKey(knowledgeDetailsDTO.getDictKey());
knowledgeDetails.setCreateUser(knowledgeDetailsDTO.getUserId());
// 插入数据
int insert = knowledgeDetailsMapper.insert(knowledgeDetails);
// boolean save = this.save(knowledgeDetails);
// 插入附件表
// List<Attachs> attachsList = new LinkedList<>();
// for (AttachVO attachVO : knowledgeDetailsDTO.getAttach()){
// Attachs attachs = new Attachs();
// attachs.setAttachUrl(attachVO.getAttachUrl());
// attachs.setAttachName(attachVO.getAttachName());
// attachs.setCreateUser(knowledgeDetailsDTO.getUserId());
// attachs.setRelationId(knowledgeDetails.getId());
// attachsList.add(attachs);
// }
// // 插入附件
// insertAttach(attachsList);
List<Attachs> attach = knowledgeDetailsDTO.getAttach();
if (CollectionUtil.isNotEmpty(attach)) {
attach.forEach(attachVO -> attachVO.setRelationId(knowledgeDetails.getId()));
attachaService.saveBatch(attach);
}
// 判断是否插入成功
if(insert > 0) {
return knowledgeDetails;
}else {
return null;
}
}catch (Exception e){
e.printStackTrace();
}
return null;
}
/*
保存附件通用方法
*/
public void insertAttach(List<Attachs> attachs){
// 插入当前时间
for (Attachs attach : attachs) {
attach.setCreateTime(new Date());
}
// 插入附件
attachsMapper.insertBatch(attachs);
}
}

@ -0,0 +1,22 @@
package org.springblade.modules.workOrder.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.workOrder.entity.DeviceAttach;
/**
* 设备附件表 视图实体类
*
* @author BladeX
* @since 2024-10-14
*/
@Data
public class AttachVO {
private static final long serialVersionUID = 1L;
private String attachUrl;
private String attachName;
}
Loading…
Cancel
Save