TicketRightsProtectionService.java 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package com.example.xiaoshiweixinback.service;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.example.xiaoshiweixinback.business.common.base.SystemFile;
  6. import com.example.xiaoshiweixinback.domain.TicketRightsProtection;
  7. import com.example.xiaoshiweixinback.entity.dto.ticket.TicketRightsProtectionAddDTO;
  8. import com.example.xiaoshiweixinback.entity.vo.TicketRightsProtectionVO;
  9. import com.example.xiaoshiweixinback.mapper.TicketRightsProtectionMapper;
  10. import com.example.xiaoshiweixinback.service.common.FileManagerService;
  11. import lombok.RequiredArgsConstructor;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import java.util.ArrayList;
  16. import java.util.Arrays;
  17. import java.util.List;
  18. /**
  19. * 知识产权维权工单Service
  20. *
  21. * @Author xiexiang
  22. * @Date 2024/4/7
  23. */
  24. @Service
  25. @RequiredArgsConstructor
  26. public class TicketRightsProtectionService extends ServiceImpl<TicketRightsProtectionMapper, TicketRightsProtection> {
  27. @Autowired
  28. private FileManagerService fileManagerService;
  29. /**
  30. * 知识产权维权工单
  31. *
  32. * @param ticketRightsProtectionAddDTO
  33. * @return
  34. */
  35. public Integer add(TicketRightsProtectionAddDTO ticketRightsProtectionAddDTO) {
  36. TicketRightsProtection ticketRightsProtection = new TicketRightsProtection();
  37. BeanUtils.copyProperties(ticketRightsProtectionAddDTO, ticketRightsProtection);
  38. List<String> proofGuids = ticketRightsProtectionAddDTO.getProofGuids();
  39. if (!proofGuids.isEmpty()) {
  40. String rightProof = String.join(",", proofGuids);
  41. ticketRightsProtection.setRightProof(rightProof);
  42. }
  43. ticketRightsProtection.insert();
  44. return ticketRightsProtection.getTicketId();
  45. }
  46. public TicketRightsProtectionVO getVOByTicId(Integer ticketId) {
  47. TicketRightsProtectionVO rightsProtectionVO = new TicketRightsProtectionVO();
  48. LambdaQueryWrapper<TicketRightsProtection> rightsProtectionWrapper = new LambdaQueryWrapper<>();
  49. rightsProtectionWrapper.eq(TicketRightsProtection::getTicketId, ticketId);
  50. TicketRightsProtection ticketRightsProtection = this.getOne(rightsProtectionWrapper, false);
  51. if (ticketRightsProtection != null) {
  52. String rightProof = ticketRightsProtection.getRightProof();
  53. if (rightProof != null){
  54. String[] stringArray = rightProof.split(",");
  55. List<String> proofGuids = new ArrayList<>(Arrays.asList(stringArray));
  56. List<SystemFile> systemFiles = new ArrayList<>();
  57. if (proofGuids.size() != 0) {
  58. try {
  59. String res = fileManagerService.getSystemFileFromFMS(proofGuids);
  60. systemFiles = JSONObject.parseArray(res, SystemFile.class);
  61. if (systemFiles == null) {
  62. systemFiles = new ArrayList<>();
  63. }
  64. } catch (Exception e) {
  65. }
  66. }
  67. rightsProtectionVO.setProofGuids(proofGuids);
  68. rightsProtectionVO.setProofFileList(systemFiles);
  69. }
  70. BeanUtils.copyProperties(ticketRightsProtection, rightsProtectionVO);
  71. }
  72. return rightsProtectionVO;
  73. }
  74. }