Browse Source

Merge branch 'prod-5.1.3' of http://175.6.40.68:8081/Jone/hzims-back into prod-5.1.3

zhongwei
wangyinsheng 2 months ago
parent
commit
e7edd71a00
  1. 7
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java
  2. 35
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java
  3. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java
  4. 32
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/DataOperateType.java
  5. 26
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java
  6. 99
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamLogController.java
  7. 44
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamLogEntity.java
  8. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamLogMapper.java
  9. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java
  10. 22
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamLogService.java
  11. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java
  12. 76
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamLogServiceImpl.java
  13. 40
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  14. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java

7
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/scheduled/DeviceLedgerScheduledTask.java

@ -10,6 +10,7 @@ import com.hnac.hzims.equipment.service.IEmInfoService;
import com.hnac.hzims.equipment.vo.DeviceLedgerVO; import com.hnac.hzims.equipment.vo.DeviceLedgerVO;
import com.hnac.hzims.fdp.constants.ScheduledConstant; import com.hnac.hzims.fdp.constants.ScheduledConstant;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
@ -38,7 +39,9 @@ public class DeviceLedgerScheduledTask {
@XxlJob(ScheduledConstant.DEVICE_LEDGER_DATA_GENERATE) @XxlJob(ScheduledConstant.DEVICE_LEDGER_DATA_GENERATE)
public ReturnT<String> execute(String param) throws Exception { public ReturnT<String> execute(String param) throws Exception {
JSONObject paramJson = JSONObject.parseObject(param); String jobParam = XxlJobHelper.getJobParam();
XxlJobHelper.log("传参为:" + jobParam);
JSONObject paramJson = JSONObject.parseObject(jobParam);
String emCode = Optional.ofNullable(paramJson).map(json -> json.getString("emCode")).orElse(""); String emCode = Optional.ofNullable(paramJson).map(json -> json.getString("emCode")).orElse("");
String date = Optional.ofNullable(paramJson).map(json -> json.getString("date")).orElse(LocalDate.now().minusDays(1).format(DateUtil.DATE_FORMATTER)); String date = Optional.ofNullable(paramJson).map(json -> json.getString("date")).orElse(LocalDate.now().minusDays(1).format(DateUtil.DATE_FORMATTER));
List<DeviceLedgerVO> deviceLedgerList = emInfoService.getDeviceLedgerList(emCode, date); List<DeviceLedgerVO> deviceLedgerList = emInfoService.getDeviceLedgerList(emCode, date);
@ -46,7 +49,7 @@ public class DeviceLedgerScheduledTask {
WeaviateQueryDTO query = new WeaviateQueryDTO(); WeaviateQueryDTO query = new WeaviateQueryDTO();
Map<String,String> queryMap = new HashMap<>(); Map<String,String> queryMap = new HashMap<>();
if(Func.isNotEmpty(emCode)) { if(Func.isNotEmpty(emCode)) {
queryMap.put("emCode",emCode); queryMap.put("deviceCode",emCode);
} }
queryMap.put("date",date); queryMap.put("date",date);
query.setQuery(queryMap); query.setQuery(queryMap);

35
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java

@ -178,7 +178,7 @@ public class WeaviateService {
if(Func.isEmpty(ids) && Func.isNotEmpty(className)) { if(Func.isEmpty(ids) && Func.isNotEmpty(className)) {
// 删除className // 删除className
Map<String,String> deleteTableParams = new HashMap<>(1); Map<String,String> deleteTableParams = new HashMap<>(1);
deleteTableParams.put("table_name",className); deleteTableParams.put("table_name",className.replace("Hzn_lm_",""));
RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams); RequestClientUtil.postCall(gglmUrl + invokeApi.getDeleteTable(),deleteTableParams);
} else { } else {
// 删除记录 // 删除记录
@ -333,32 +333,25 @@ public class WeaviateService {
fields.add(additionalId); fields.add(additionalId);
get.withFields(fields.toArray(new Field[fields.size()])); get.withFields(fields.toArray(new Field[fields.size()]));
if(Func.isNotEmpty(query)) { if(Func.isNotEmpty(query)) {
// waeviate 多个filter查询结果
List<WhereFilter> whereFilters = query.entrySet().stream().map(e -> WhereFilter.builder() List<WhereFilter> whereFilters = query.entrySet().stream().map(e -> WhereFilter.builder()
.path(e.getKey()) .path(e.getKey())
.operator(Operator.Equal) .operator(Operator.Equal)
.valueString(e.getValue()) .valueString(e.getValue())
.build()).collect(Collectors.toList()); .build()).collect(Collectors.toList());
whereFilters.forEach(where -> get.withWhere(where)); WhereFilter combinedFilter = WhereFilter.builder()
.operator(Operator.And)
.operands(whereFilters.toArray(new WhereFilter[whereFilters.size()]))
.build();
get.withWhere(combinedFilter);
} }
try {
// 执行查询并返回结果
return get.run().getResult().getData(); return get.run().getResult().getData();
} catch (Exception e) {
// 异常处理
System.err.println("Error occurred during query execution: " + e.getMessage());
throw new RuntimeException("Query failed.", e);
}
} }
// public static void main(String[] args) throws AuthException {
// Config config = new Config("http", "192.168.60.16:9992");
// WeaviateClient client = WeaviateAuthClient.apiKey(config, "123");
// Field itemName = Field.builder().name("item_name").build();
// Field itemId = Field.builder().name("item_id").build();
// Field additionalId = Field.builder().name("_additional { id }").build();
// WhereFilter where = WhereFilter.builder()
// .path(new String[]{ "item_name" })
// .operator(Operator.Equal)
// .valueString("湖北宜昌泵站")
// .build();
// Result<GraphQLResponse> result = client.graphQL().get()
// .withClassName("Hzn_lm_form_station")
// .withFields(itemName,itemId,additionalId)
// .withWhere(where)
// .run();
// System.out.println(JSON.toJSONString(result.getResult().getData()));
// }
} }

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/factory/AnswerResolveFactory.java

@ -51,7 +51,7 @@ public class AnswerResolveFactory {
return null; return null;
} }
} }
throw new HzServiceException(ResultCode.DEFAULT_NULL_MESSAGE,"service解析失败!"); return null;
} }
} }

32
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/DataOperateType.java

@ -0,0 +1,32 @@
package com.hnac.gglm.bigmodel.maintenance.constants;
import lombok.Getter;
/**
* @Author: ypj
* @Date: 2024/9/23 14:18
*/
@Getter
public enum DataOperateType {
CREATE("CREATE", "新增"),
UPDATE("UPDATE", "更新"),
RESET("RESET", "重置"),
DELETE("DELETE", "删除"),
SYNCHRONIZATION("SYNCHRONIZATION", "同步");
private final String code;
private final String msg;
DataOperateType(String code, String msg) {
this.code = code;
this.msg = msg;
}
public static DataOperateType getInstance(String code) {
for (DataOperateType dataOperateType : DataOperateType.values()) {
if (dataOperateType.getCode().equals(code)) {
return dataOperateType;
}
}
return null;
}
}

26
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java

@ -3,7 +3,10 @@ package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService;
import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest; import com.hnac.gglm.bigmodel.maintenance.vo.IdsRequest;
import com.hnac.hzinfo.api.annotation.ApiInterface; import com.hnac.hzinfo.api.annotation.ApiInterface;
@ -33,6 +36,7 @@ import java.util.Map;
@Slf4j @Slf4j
public class VectorParamController { public class VectorParamController {
private final VectorParamService vectorParamService; private final VectorParamService vectorParamService;
private final VectorParamLogService vectorParamLogService;
@GetMapping("/listPage") @GetMapping("/listPage")
@ApiOperation(value = "分页查询") @ApiOperation(value = "分页查询")
@ -52,21 +56,37 @@ public class VectorParamController {
@ApiOperation(value = "保存向量参数配置") @ApiOperation(value = "保存向量参数配置")
@ApiOperationSupport(order = 3) @ApiOperationSupport(order = 3)
public R save(@RequestBody VectorParamEntity req) { public R save(@RequestBody VectorParamEntity req) {
return R.status(vectorParamService.save(req)); Boolean result = vectorParamService.save(req);
if (result) {
vectorParamLogService.create(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.CREATE.getCode()).build());
}
return R.status(result);
} }
@DeleteMapping("/remove") @DeleteMapping("/remove")
@ApiOperation(value = "删除向量参数配置") @ApiOperation(value = "删除向量参数配置")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) { public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamService.removeByIds(Func.toLongList(",", ids))); Boolean result = vectorParamService.removeByIds(Func.toLongList(",", ids));
if (result) {
vectorParamLogService.delete(Func.toLongList(",", ids));
}
return R.status(result);
} }
@PutMapping("/update") @PutMapping("/update")
@ApiOperation(value = "编辑向量参数配置") @ApiOperation(value = "编辑向量参数配置")
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
public R update(@RequestBody VectorParamEntity req) { public R update(@RequestBody VectorParamEntity req) {
return R.status(vectorParamService.updateById(req)); Boolean result = vectorParamService.updateById(req);
if (result) {
vectorParamLogService.edit(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.UPDATE.getCode()).build());
}
return R.status(result);
} }
@GetMapping("/getAuthorization") @GetMapping("/getAuthorization")

99
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamLogController.java

@ -0,0 +1,99 @@
package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
/**
* @Author: ypj
* @Date: 2024/9/23 13:50
*/
@RestController
@RequestMapping("/vector/log")
@Api(value = "向量参数配置日志", tags = "向量参数配置日志")
@AllArgsConstructor
@Slf4j
public class VectorParamLogController {
private final VectorParamLogService vectorParamLogService;
@GetMapping("/listPage")
@ApiOperation(value = "分页查询")
@ApiOperationSupport(order = 1)
public R<IPage<VectorParamLogEntity>> listPage(Query query, VectorParamLogEntity req) {
return R.data(vectorParamLogService.page(Condition.getPage(query), Condition.getQueryWrapper(new VectorParamLogEntity(), req)));
}
@GetMapping("/detail")
@ApiOperation(value = "查看详情")
@ApiOperationSupport(order = 2)
public R<VectorParamLogEntity> detail(@RequestParam @ApiParam("主键ID") Long id) {
return R.data(vectorParamLogService.getById(id));
}
@GetMapping("/save")
@ApiOperation(value = "保存向量参数配置日志")
@ApiOperationSupport(order = 3)
public R save(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.save(req));
}
@GetMapping("/remove")
@ApiOperation(value = "删除向量参数配置日志")
@ApiOperationSupport(order = 4)
public R remove(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamLogService.removeByIds(Func.toLongList(",", ids)));
}
@PutMapping("/update")
@ApiOperation(value = "编辑向量参数配置日志")
@ApiOperationSupport(order = 5)
public R update(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.updateById(req));
}
@PostMapping("/create")
@ApiOperation(value = "创建向量参数配置操作记录")
@ApiOperationSupport(order = 6)
public R create(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.create(req));
}
@PostMapping("/edit")
@ApiOperation(value = "编辑向量参数配置操作记录")
@ApiOperationSupport(order = 7)
public R edit(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.edit(req));
}
@PostMapping("/reset")
@ApiOperation(value = "重置向量参数配置操作记录")
@ApiOperationSupport(order = 8)
public R reset(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.reset(req));
}
@PostMapping("/delete")
@ApiOperation(value = "删除向量参数配置操作记录")
@ApiOperationSupport(order = 9)
public R delete(@RequestParam @ApiParam("主键ID,按逗号分隔") String ids) {
return R.status(vectorParamLogService.delete(Func.toLongList(",", ids)));
}
@PostMapping("/synchronization")
@ApiOperation(value = "同步向量参数配置操作记录")
@ApiOperationSupport(order = 10)
public R synchronization(@RequestBody VectorParamLogEntity req) {
return R.status(vectorParamLogService.synchronization(req));
}
}

44
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/VectorParamLogEntity.java

@ -0,0 +1,44 @@
package com.hnac.gglm.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springblade.core.mp.support.QueryField;
import org.springblade.core.mp.support.SqlCondition;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
* @Author: ypj
* @Date: 2024/9/23 12:07
*/
@ApiModel("向量参数配置日志")
@TableName("gglm_vector_param_log")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class VectorParamLogEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("参数id")
@TableField("VECTOR_PARAM_ID")
@QueryField(condition = SqlCondition.EQUAL)
private Long vectorParamId;
@ApiModelProperty("日志内容")
@TableField("CONTENT")
@QueryField(condition = SqlCondition.LIKE)
private String content;
@ApiModelProperty("日志类型,新增CREATE,更新UPDATE,重置RESET")
@TableField("TYPE")
@QueryField(condition = SqlCondition.EQUAL)
private String type;
}

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamLogMapper.java

@ -0,0 +1,13 @@
package com.hnac.gglm.bigmodel.maintenance.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
/**
* @Author: ypj
* @Date: 2024/9/23 13:59
*/
@DS("hznlm")
public interface VectorParamLogMapper extends BaseMapper<VectorParamLogEntity> {
}

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/VectorParamMapper.java

@ -1,5 +1,6 @@
package com.hnac.gglm.bigmodel.maintenance.mapper; package com.hnac.gglm.bigmodel.maintenance.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
@ -7,5 +8,7 @@ import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
* @Author: ypj * @Author: ypj
* @Date: 2024/09/02 15:12 * @Date: 2024/09/02 15:12
*/ */
@DS("hznlm")
public interface VectorParamMapper extends BaseMapper<VectorParamEntity> { public interface VectorParamMapper extends BaseMapper<VectorParamEntity> {
} }

22
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamLogService.java

@ -0,0 +1,22 @@
package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import java.util.List;
/**
* @Author: ypj
* @Date: 2024/9/23 13:56
*/
public interface VectorParamLogService extends IService<VectorParamLogEntity> {
Boolean create(VectorParamLogEntity req);
Boolean edit(VectorParamLogEntity req);
Boolean reset(VectorParamLogEntity req);
Boolean delete(List<Long> ids);
Boolean synchronization(VectorParamLogEntity req);
}

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java

@ -19,4 +19,6 @@ public interface VectorParamService extends IService<VectorParamEntity> {
List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken); List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken);
Boolean synchronization(List<Long> id ,String bladeToken, String hzinfoToken); Boolean synchronization(List<Long> id ,String bladeToken, String hzinfoToken);
Boolean synchronization(Long id, String bladeToken, String hzinfoToken);
} }

76
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamLogServiceImpl.java

@ -0,0 +1,76 @@
package com.hnac.gglm.bigmodel.maintenance.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamLogMapper;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* @Author: ypj
* @Date: 2024/9/23 13:57
*/
@Service
@Slf4j
@AllArgsConstructor
@DS("hznlm")
public class VectorParamLogServiceImpl extends ServiceImpl<VectorParamLogMapper, VectorParamLogEntity> implements VectorParamLogService {
@Override
public Boolean create(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.CREATE.getCode());
return save(req);
}
@Override
public Boolean edit(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.UPDATE.getCode());
return save(req);
}
@Override
public Boolean reset(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.RESET.getCode());
return save(req);
}
@Override
public Boolean delete(List<Long> ids) {
ThreadPoolExecutor executor = new ThreadPoolExecutor(5, ids.size() > 5 ? ids.size() : 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
ids.forEach(id -> {
executor.execute(() -> {
save(VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.DELETE.getCode()).build());
});
});
return Boolean.TRUE;
}
@Override
public Boolean synchronization(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.SYNCHRONIZATION.getCode());
return save(req);
}
}

40
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

@ -12,10 +12,13 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.hnac.gglm.bigmodel.database.service.WeaviateService; import com.hnac.gglm.bigmodel.database.service.WeaviateService;
import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse; import com.hnac.gglm.bigmodel.maintenance.constants.DataOperateType;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.gglm.bigmodel.maintenance.entity.VectorParamLogEntity;
import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamMapper; import com.hnac.gglm.bigmodel.maintenance.mapper.VectorParamMapper;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamLogService;
import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService; import com.hnac.gglm.bigmodel.maintenance.service.VectorParamService;
import com.hnac.gglm.bigmodel.maintenance.vo.VectorUrlResponse;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -23,6 +26,9 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/** /**
* @Author: ypj * @Author: ypj
@ -37,6 +43,7 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
private static final String CLIENT_SIGN = "vector_param"; private static final String CLIENT_SIGN = "vector_param";
private final WeaviateService weaviateService; private final WeaviateService weaviateService;
private final VectorParamLogService vectorParamLogService;
@Override @Override
public String getAuthorization() { public String getAuthorization() {
@ -115,11 +122,28 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
if (null == ids && ids.isEmpty()) { if (null == ids && ids.isEmpty()) {
return false; return false;
} }
for (Long id : ids) { ThreadPoolExecutor executor = new ThreadPoolExecutor(5, ids.size() > 5 ? ids.size() : 5, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());
VectorParamEntity entity = getById(id); ids.forEach(id -> {
executor.execute(() -> {
if (synchronization(id, bladeToken, hzinfoToken)) {
log.info("synchronization vector param id:{} success", id);
} else {
log.error("synchronization vector param id:{} fail", id);
}
});
});
executor.shutdown();
return true;
}
@Override
public Boolean synchronization(Long id, String bladeToken, String hzinfoToken) {
VectorParamEntity entity = baseMapper.selectById(id);
if (null == entity) { if (null == entity) {
return false; return false;
} }
log.info("synchronization vector param id:{}", id);
VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken);
if (response != null) { if (response != null) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -135,12 +159,16 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
String key = iterator.next(); String key = iterator.next();
attrMap.put(key, rootNode.findValue(key).textValue()); attrMap.put(key, rootNode.findValue(key).textValue());
} }
String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_",""); String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", "");
weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap); weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap);
this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date()))) {
return vectorParamLogService.synchronization(VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.SYNCHRONIZATION.getCode()).build());
} else {
return false;
} }
} }
return true; return true;
} }
} }

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/schedule/FrontEndInteractiveSchedule.java

@ -70,7 +70,7 @@ public class FrontEndInteractiveSchedule {
answerVO.setExtras(resolveExtras); answerVO.setExtras(resolveExtras);
} catch(Exception e) { } catch(Exception e) {
log.error("An error occurred",e); log.error("An error occurred",e);
AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery()); answerVO = AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery());
} }
} }
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));

Loading…
Cancel
Save