package com.example.xiaoshiweixinback.service; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.xiaoshiweixinback.business.common.base.SystemFile; import com.example.xiaoshiweixinback.domain.TicketRightsProtection; import com.example.xiaoshiweixinback.entity.dto.ticket.TicketRightsProtectionAddDTO; import com.example.xiaoshiweixinback.entity.vo.TicketRightsProtectionVO; import com.example.xiaoshiweixinback.mapper.TicketRightsProtectionMapper; import com.example.xiaoshiweixinback.service.common.FileManagerService; import lombok.RequiredArgsConstructor; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * 知识产权维权工单Service * * @Author xiexiang * @Date 2024/4/7 */ @Service @RequiredArgsConstructor public class TicketRightsProtectionService extends ServiceImpl { @Autowired private FileManagerService fileManagerService; /** * 知识产权维权工单 * * @param ticketRightsProtectionAddDTO * @return */ public Integer add(TicketRightsProtectionAddDTO ticketRightsProtectionAddDTO) { TicketRightsProtection ticketRightsProtection = new TicketRightsProtection(); BeanUtils.copyProperties(ticketRightsProtectionAddDTO, ticketRightsProtection); List proofGuids = ticketRightsProtectionAddDTO.getProofGuids(); if (!proofGuids.isEmpty()) { String rightProof = String.join(",", proofGuids); ticketRightsProtection.setRightProof(rightProof); } ticketRightsProtection.insert(); return ticketRightsProtection.getTicketId(); } public TicketRightsProtectionVO getVOByTicId(Integer ticketId) { TicketRightsProtectionVO rightsProtectionVO = new TicketRightsProtectionVO(); LambdaQueryWrapper rightsProtectionWrapper = new LambdaQueryWrapper<>(); rightsProtectionWrapper.eq(TicketRightsProtection::getTicketId, ticketId); TicketRightsProtection ticketRightsProtection = this.getOne(rightsProtectionWrapper, false); if (ticketRightsProtection != null) { String rightProof = ticketRightsProtection.getRightProof(); if (rightProof != null){ String[] stringArray = rightProof.split(","); List proofGuids = new ArrayList<>(Arrays.asList(stringArray)); List systemFiles = new ArrayList<>(); if (proofGuids.size() != 0) { try { String res = fileManagerService.getSystemFileFromFMS(proofGuids); systemFiles = JSONObject.parseArray(res, SystemFile.class); if (systemFiles == null) { systemFiles = new ArrayList<>(); } } catch (Exception e) { } } rightsProtectionVO.setProofGuids(proofGuids); rightsProtectionVO.setProofFileList(systemFiles); } BeanUtils.copyProperties(ticketRightsProtection, rightsProtectionVO); } return rightsProtectionVO; } }