Commit 6956c938 by liuyu

2024/07/15 长鑫存储ai标注接入。

parent ea0e714d
package com.zhiwei.middleware.automatic.server.pojo;
import java.util.Objects;
/**
* author:liu-yu
* date: 2024/6/13 9:46
......@@ -20,12 +22,48 @@ public class AiApiResult {
private String related;
private String sensitive;
private String project;
private String result;
private Long createAt;
@Override
public String toString() {
StringBuilder builder = new StringBuilder("AiApiResult{");
builder.append("status='").append(status).append('\'');
if (Objects.nonNull(info_class)) {
builder.append(", info_class='").append(info_class).append('\'');
}
if (Objects.nonNull(sent)) {
builder.append(", sent='").append(sent).append('\'');
}
if (Objects.nonNull(noise)) {
builder.append(", noise='").append(noise).append('\'');
}
if (Objects.nonNull(negLabel)) {
builder.append(", negLabel='").append(negLabel).append('\'');
}
if (Objects.nonNull(related)) {
builder.append(", related='").append(related).append('\'');
}
if (Objects.nonNull(sensitive)) {
builder.append(", sensitive='").append(sensitive).append('\'');
}
builder.append("}");
return builder.toString();
}
public String getSensitive() {
return sensitive;
}
public void setSensitive(String sensitive) {
this.sensitive = sensitive;
}
public String getRelated() {
return related;
}
......
......@@ -10,7 +10,9 @@ public enum AiInterfaceEnums {
LAO_XIANG_JI("老乡鸡", "665d8791b36dd11c5e453955"),
JIA_NAN_KE_JI("嘉楠科技", "65efecab7d8b3a478260e7b6");
JIA_NAN_KE_JI("嘉楠科技", "65efecab7d8b3a478260e7b6"),
CHANG_XIN_CUN_CHU("长鑫存储", "65b89d4515e6c42baff23e74");
final String project;
......
......@@ -64,23 +64,24 @@ public abstract class AbstractAiTaskService implements AiTaskService {
log.info("项目:{},数据url:{},耗时:{},ai接口返回信息不完整:{}", aiInterfaceEnums.getProject(), param.getJSONObject("data").getString(GenericAttribute.URL), endTime, s);
return null;
}
log.info("项目:{},数据url:{},ai标签:{},耗时:{},具体数据:{}", aiInterfaceEnums.getProject(), param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.getSent(), endTime, aiRes.getResult());
log.info("项目:{},数据url:{},ai标签:{},耗时:{},具体数据:{}", aiInterfaceEnums.getProject(), param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.toString(), endTime, aiRes.getResult());
List<AIMark.TagRelation> tagRelations = aiParam.getAiMark().getTagRelations();
Map<String, List<AIMark.TagRelation>> relateGroup = tagRelations.stream().collect(Collectors.groupingBy(AIMark.TagRelation::getRelateKey, Collectors.toList()));
List<AIMark.TagRelation> tagRelationList = relateGroup.values().stream().map(relations -> relations.stream().filter(x -> relateValueVerify(x, aiRes)).findFirst().orElse(null)).filter(Objects::nonNull).collect(Collectors.toList());
if (tagRelationList.isEmpty()) {
markNotRelation(timeKey);
log.info("数据url:{},ai标签:{},没有绑定关系,以过滤", param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.getSent());
log.info("数据url:{},ai标签:{},没有绑定关系,以过滤", param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.toString());
return null;
}
JSONObject json = aiParam.getJson();
String mtag = tagRelationList.stream().map(AIMark.TagRelation::getUniqueId).collect(Collectors.joining());
String logTag = tagRelationList.stream().map(AIMark.TagRelation::getName).collect(Collectors.joining());
json.put(GenericAttribute.ES_M_TAG, mtag);
json.put(GenericAttribute.ES_M_PERSON, GenericAttribute.AI_PERSON);
json.put(GenericAttribute.ES_M_TIME, System.currentTimeMillis());
json.put(GenericAttribute.ES_M_GROUP, aiParam.getAiMark().getProject());
json.put(GenericAttribute.ES_M_GROUP_ID, aiParam.getAiMark().getProjectId());
log.info("数据url:{},ai标签:{},标注标签:{},成功标注", param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.getSent(), mtag);
log.info("数据url:{},ai标签:{},标注标签:{},成功标注", param.getJSONObject("data").getString(GenericAttribute.URL), aiRes.toString(), logTag);
return json;
}
......@@ -158,6 +159,7 @@ public abstract class AbstractAiTaskService implements AiTaskService {
aiRes.setStatus(waitRes.getString("status"));
aiRes.setNegLabel(result.getString("neg_label"));
aiRes.setRelated(result.getString("related"));
aiRes.setSensitive(result.getString("sensitive"));
aiRes.setResult(res.toJSONString());
aiRes.setProject(aiInterfaceEnums.getProject());
aiApiResultDao.insert(aiRes);
......
package com.zhiwei.middleware.automatic.son.task.aiTask;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.middleware.automatic.server.pojo.AiInterfaceParam;
import com.zhiwei.middleware.automatic.server.pojo.enums.AiInterfaceEnums;
import com.zhiwei.middleware.automatic.server.util.RedissonUtil;
import com.zhiwei.middleware.automatic.son.dao.AiApiResultDao;
import org.springframework.stereotype.Service;
/**
* author:liu-yu
* date: 2024/7/15 11:04
**/
@Service
public class AiTaskServiceCJCC extends AbstractAiTaskService {
public AiTaskServiceCJCC(RedissonUtil redissonUtil, AiApiResultDao aiApiResultDao) {
super(AiInterfaceEnums.CHANG_XIN_CUN_CHU, redissonUtil, aiApiResultDao);
}
@Override
public JSONObject httpParamByMetadata(AiInterfaceParam aiParam) {
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment