yang_shj
5 months ago
26 changed files with 248 additions and 69 deletions
@ -0,0 +1,38 @@
|
||||
package com.hnac.hzims.bigmodel.database.controller; |
||||
|
||||
import com.hnac.hzims.bigmodel.database.dto.WeaviateSaveDTO; |
||||
import com.hnac.hzims.bigmodel.database.service.WeaviateService; |
||||
import io.weaviate.client.v1.data.model.WeaviateObject; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/09/04 14:16 |
||||
*/ |
||||
@RestController |
||||
@AllArgsConstructor |
||||
@RequestMapping("/weaviate") |
||||
public class WeaviateController { |
||||
|
||||
private final WeaviateService weaviateService; |
||||
|
||||
@PostMapping("/saveBatch") |
||||
public R<Boolean> saveBatch(@RequestBody WeaviateSaveDTO req) { |
||||
weaviateService.saveBatch(req.getEntities(), req.getClassName(), req.getAttrsMap()); |
||||
return R.success("操作成功!"); |
||||
} |
||||
|
||||
@GetMapping("/list") |
||||
public R<List<WeaviateObject>> list(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { |
||||
return R.data(weaviateService.list(id,className)); |
||||
} |
||||
|
||||
@DeleteMapping("/removeById") |
||||
public R<Boolean> removeById(@RequestParam(value = "id",required = false) String id, @RequestParam("className") String className) { |
||||
return R.status(weaviateService.delete(id,className)); |
||||
} |
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.hnac.hzims.bigmodel.database.dto; |
||||
|
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/09/04 14:36 |
||||
*/ |
||||
@Data |
||||
@EqualsAndHashCode |
||||
public class WeaviateSaveDTO implements Serializable { |
||||
|
||||
/** |
||||
* 向量数据库表名 |
||||
*/ |
||||
private String className; |
||||
|
||||
/** |
||||
* 向量数据库属性名 |
||||
*/ |
||||
private Map<String,String> attrsMap; |
||||
|
||||
/** |
||||
* 向量数据库存入对象列表 |
||||
*/ |
||||
private List entities; |
||||
|
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.hnac.hzims.bigmodel.interactive.service.impl; |
||||
|
||||
import com.alibaba.fastjson.JSON; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory; |
||||
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO; |
||||
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* @Author: huangxing |
||||
* @Date: 2024/08/30 11:33 |
||||
*/ |
||||
@Service(AnswerResolveFactory.CONTROL_DEVICE_SERVICE) |
||||
@Slf4j |
||||
public class ControlAnswerResolveServiceImpl implements IAnswerResolveService { |
||||
|
||||
@Override |
||||
public AnswerVO resolve(AnswerVO answer) { |
||||
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray(); |
||||
answer.setExtras(extraArray); |
||||
return answer; |
||||
} |
||||
|
||||
@Override |
||||
public ExtraVO getExtra(JSONObject originExtra) { |
||||
log.info("控制指令传参为:{}", JSON.toJSONString(originExtra)); |
||||
return null; |
||||
} |
||||
} |
Loading…
Reference in new issue