PatentInstructionTextService.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package cn.cslg.pas.service;
  2. import cn.cslg.pas.common.model.params.PatentInstructionTextParams;
  3. import cn.cslg.pas.domain.PatentInstructionText;
  4. import cn.cslg.pas.mapper.PatentInstructionTextMapper;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  7. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8. import lombok.RequiredArgsConstructor;
  9. import org.springframework.context.annotation.Lazy;
  10. import org.springframework.stereotype.Service;
  11. import java.util.ArrayList;
  12. import java.util.List;
  13. /**
  14. * @author Administrator
  15. * @description 针对表【os_patent_instruction_text(专利说明书(文本))】的数据库操作Service
  16. * @createDate 2022-04-16 08:38:10
  17. */
  18. @Service
  19. @RequiredArgsConstructor(onConstructor_ = {@Lazy})
  20. public class PatentInstructionTextService extends ServiceImpl<PatentInstructionTextMapper, PatentInstructionText> {
  21. private final PatentService patentService;
  22. public PatentInstructionText getPatentInstructionTextByPatentId(Integer patentId) {
  23. LambdaQueryWrapper<PatentInstructionText> queryWrapper = new LambdaQueryWrapper<>();
  24. queryWrapper.eq(PatentInstructionText::getPatentId, patentId);
  25. return this.getOne(queryWrapper);
  26. }
  27. public List<PatentInstructionText> getPatentInstructionTextByPatentIds(List<Integer> patentIds) {
  28. if (patentIds == null || patentIds.size() == 0) {
  29. return new ArrayList<>();
  30. }
  31. LambdaQueryWrapper<PatentInstructionText> queryWrapper = new LambdaQueryWrapper<>();
  32. queryWrapper.in(PatentInstructionText::getPatentId, patentIds);
  33. return this.list(queryWrapper);
  34. }
  35. public void deleteByPatentId(Integer patentId) {
  36. this.remove(Wrappers.<PatentInstructionText>lambdaQuery().eq(PatentInstructionText::getPatentId, patentId));
  37. }
  38. public void importPatentInstructionText(Integer localPatentId, Integer importPatentId, List<PatentInstructionText> importPatentInstructionTextList) {
  39. this.deleteByPatentId(localPatentId);
  40. PatentInstructionText patentInstructionText = importPatentInstructionTextList.stream().filter(item -> item.getPatentId().equals(importPatentId)).findFirst().orElse(null);
  41. if (patentInstructionText != null) {
  42. patentInstructionText.setId(null);
  43. patentInstructionText.setPatentId(localPatentId);
  44. patentInstructionText.insert();
  45. }
  46. }
  47. public void updatePatentInstructionText(PatentInstructionTextParams params) {
  48. PatentInstructionText patentInstructionText = this.getPatentInstructionTextByPatentId(params.getPatentId());
  49. if (patentInstructionText == null) {
  50. patentInstructionText = new PatentInstructionText();
  51. }
  52. patentInstructionText.setPatentId(params.getPatentId());
  53. patentInstructionText.setManual(params.getManual());
  54. patentInstructionText.setManualOut(params.getManualOut());
  55. patentInstructionText.insertOrUpdate();
  56. }
  57. }