package cn.cslg.pas.service; import cn.cslg.pas.common.dto.es.AddPatentLabelDTO; import cn.cslg.pas.common.vo.PatentWithIdVO; import cn.cslg.pas.domain.es.ESCustomField; import cn.cslg.pas.domain.es.Patent; import cn.cslg.pas.exception.XiaoShiException; import cn.cslg.pas.service.business.es.EsCustomFieldService; import cn.cslg.pas.service.business.es.EsService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; @Service public class PatentLabelService { @Autowired private EsCustomFieldService esCustomFieldService; @Autowired private EsService esService; /** * 添加专利标签 * * @param addPatentLabelDTO * @return */ public String addPatentLabel(AddPatentLabelDTO addPatentLabelDTO) { String id = null; Integer projectId = addPatentLabelDTO.getProjectId(); List labels = addPatentLabelDTO.getLabels(); String patentNo = addPatentLabelDTO.getPatentNo(); try { PatentWithIdVO patentWithIdVO = esCustomFieldService.getPatentLabel(addPatentLabelDTO); if (patentWithIdVO != null) { Patent patent = patentWithIdVO.getPatent(); ESCustomField esCustomField = patent.getESCustomField(); esCustomField.setStatsValue(labels); esCustomField.setFieldValue(labels); patent.setESCustomField(esCustomField); esService.updateByQuery(patent, patentWithIdVO.getId()); id = patentWithIdVO.getId(); } else { ESCustomField esCustomField = new ESCustomField(); esCustomField.setFieldType(10); esCustomField.setCreateTime(new Date()); esCustomField.setProjectId(projectId); esCustomField.setField("0"); esCustomField.setFieldValue(labels); esCustomField.setStatsValue(labels); id = esCustomFieldService.addEsCustomFieldToEs(esCustomField, patentNo, null); } } catch (Exception e) { throw new XiaoShiException("查询失败"); } return id; } public void queryPatentLabel(){ } }