|
|
|
|
@ -10,6 +10,7 @@ import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
import org.apache.velocity.runtime.directive.Foreach; |
|
|
|
|
import org.springblade.common.cache.DictBizCache; |
|
|
|
|
import org.springblade.common.cache.UserCache; |
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
@ -38,6 +39,7 @@ 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.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
@ -61,7 +63,8 @@ public class KnowledgeDetailsController extends BladeController { |
|
|
|
|
|
|
|
|
|
private final IKnowledgeDetailsService knowledgeDetailsService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IAttachaService attachaService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 知识库内容提报操作 |
|
|
|
|
@ -98,20 +101,23 @@ public class KnowledgeDetailsController extends BladeController { |
|
|
|
|
@ApiOperationSupport(order = 2) |
|
|
|
|
@ApiOperation(value = "分页", notes = "传入goods") |
|
|
|
|
public R<IPage<KnowledgeDetails>> list(@ApiIgnore @RequestParam Map<String, Object> knowledgeDetails, Query query) { |
|
|
|
|
// 查找知识库类型是在dictKey字典类型的内容
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
QueryWrapper<Attachs> attachQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Attachs> eq = attachQueryWrapper.lambda().eq(Attachs::getRelationId, record.getId()); |
|
|
|
|
List<Attachs> list = attachaService.list(eq); |
|
|
|
|
record.setAttach(list); |
|
|
|
|
record.setDictKeyStr(DictBizCache.getValue(KNOWLEDGE_TYPE, record.getDictKey())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return R.data(pages); |
|
|
|
|
@ -125,18 +131,21 @@ public class KnowledgeDetailsController extends BladeController { |
|
|
|
|
@ApiOperation(value = "详情", notes = "传入device") |
|
|
|
|
public R<KnowledgeDetails> detail(KnowledgeDetails knowledgeDetails) { |
|
|
|
|
KnowledgeDetails detail = knowledgeDetailsService.getById(knowledgeDetails.getId()); |
|
|
|
|
if(detail == null){ |
|
|
|
|
return R.fail("数据不存在"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
QueryWrapper<Attachs> attachQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
// attachQueryWrapper.eq()
|
|
|
|
|
// 附件查询
|
|
|
|
|
LambdaQueryWrapper<Attachs> eq = attachQueryWrapper.lambda().eq(Attachs::getRelationId, detail.getId()); |
|
|
|
|
List<Attachs> list = attachaService.list(eq); |
|
|
|
|
detail.setAttach(list); |
|
|
|
|
|
|
|
|
|
KnowledgeDetails knowledgeBaseVO = Objects.requireNonNull(BeanUtil.copy(detail, KnowledgeDetails.class)); |
|
|
|
|
knowledgeBaseVO.setAttach(attachVOS); |
|
|
|
|
// knowledgeBaseVO.setAttach(attachVOS);
|
|
|
|
|
return R.data(knowledgeBaseVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -151,12 +160,49 @@ public class KnowledgeDetailsController extends BladeController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 资料表 修改 |
|
|
|
|
* 知识库 修改 |
|
|
|
|
*/ |
|
|
|
|
@PostMapping("/update") |
|
|
|
|
@ApiOperationSupport(order = 5) |
|
|
|
|
@ApiOperation(value = "修改", notes = "传入information") |
|
|
|
|
public R update(@Valid @RequestBody KnowledgeDetails knowledgeDetails) { |
|
|
|
|
|
|
|
|
|
// 判断入参内容
|
|
|
|
|
if(knowledgeDetails.getId() == null){ |
|
|
|
|
return R.fail(400, "输入参数不合法"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<Attachs> wrapper = Wrappers.lambdaQuery(Attachs.class).eq(Attachs::getRelationId,knowledgeDetails.getId()); |
|
|
|
|
|
|
|
|
|
attachaService.remove(wrapper); |
|
|
|
|
|
|
|
|
|
// for(Attachs attachs : knowledgeDetails.getAttach()){
|
|
|
|
|
// // 排除当前记录的ID
|
|
|
|
|
// LambdaQueryWrapper<Attachs> wrapper = Wrappers.lambdaQuery(Attachs.class)
|
|
|
|
|
// .ne(Attachs::getId, attachs.getId())
|
|
|
|
|
// .eq(Attachs::getRelationId,knowledgeDetails.getId());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 查询更新无关的数据,逻辑删除
|
|
|
|
|
// List<Attachs> list = attachaService.list(wrapper);
|
|
|
|
|
// List<Long> longs = new LinkedList<>();
|
|
|
|
|
// for(Attachs attachs : list){
|
|
|
|
|
// longs.add(attachs.getId());
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 将本次更新与数据库中不相关的数据逻辑删除
|
|
|
|
|
// attachaService.deleteLogic(longs);
|
|
|
|
|
// attachaService.remove(wrapper);
|
|
|
|
|
|
|
|
|
|
// 赋值id给附件表
|
|
|
|
|
for(Attachs attachs: knowledgeDetails.getAttach()){ |
|
|
|
|
attachs.setRelationId(knowledgeDetails.getId()); |
|
|
|
|
} |
|
|
|
|
// 更新附件表
|
|
|
|
|
attachaService.saveOrUpdateBatch(knowledgeDetails.getAttach()); |
|
|
|
|
|
|
|
|
|
// 更新知识库表,返回保存数据
|
|
|
|
|
return R.status(knowledgeDetailsService.updateById(knowledgeDetails)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|