Browse Source

Merge remote-tracking branch 'origin/prod-5.1.3' into prod-5.1.3

# Conflicts:
#	hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
zhongwei
haungxing 2 months ago
parent
commit
5db23bafe6
  1. 23
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java
  2. 32
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/DataOperateType.java
  3. 10
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamController.java
  4. 99
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/VectorParamLogController.java
  5. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceAttrDTO.java
  6. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.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. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java
  11. 1
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java
  12. 22
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamLogService.java
  13. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/VectorParamService.java
  14. 78
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamLogServiceImpl.java
  15. 69
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

23
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/impl/VectorDataServiceImpl.java

@ -10,6 +10,8 @@ import com.hnac.hzinfo.sdk.v5.model.ModelClient;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelAttrVO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelEventVO;
import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO; import com.hnac.hzinfo.sdk.v5.model.vo.ModelFuncVO;
import com.hnac.hzinfo.sdk.v5.project.ProjectClient;
import com.hnac.hzinfo.sdk.v5.project.vo.ProjectNameVo;
import com.hnac.hzinfo.sdk.v5.scada.ScadaClient; import com.hnac.hzinfo.sdk.v5.scada.ScadaClient;
import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo; import com.hnac.hzinfo.sdk.v5.scada.vo.CanvasInfo;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -32,6 +35,7 @@ public class VectorDataServiceImpl implements VectorDataService {
private final ModelClient modelClient; private final ModelClient modelClient;
private final DeviceClient deviceClient; private final DeviceClient deviceClient;
private final ScadaClient scadaClient; private final ScadaClient scadaClient;
private final ProjectClient projectClient;
@Override @Override
@ -75,7 +79,6 @@ public class VectorDataServiceImpl implements VectorDataService {
List<DeviceAttrInfoDTO> list = deviceClient.listDeviceAttr().getData(); List<DeviceAttrInfoDTO> list = deviceClient.listDeviceAttr().getData();
if (null != list && !list.isEmpty()) { if (null != list && !list.isEmpty()) {
list.forEach(item -> { list.forEach(item -> {
item.setItemName(item.getProjectName() + " " + item.getDeviceName() + " " + item.getName());
String rule = AccessRules.getDescByCode(item.getRule()); String rule = AccessRules.getDescByCode(item.getRule());
if (null != rule) { if (null != rule) {
item.setRule(rule); item.setRule(rule);
@ -92,6 +95,22 @@ public class VectorDataServiceImpl implements VectorDataService {
@Override @Override
public List<CanvasInfo> getScadaCanvas() { public List<CanvasInfo> getScadaCanvas() {
return scadaClient.listCanvas().getData(); List<CanvasInfo> list = scadaClient.listCanvas().getData();
if (null == list || list.isEmpty()) {
return new LinkedList<>();
}
List<String> projectIds = list.stream().map(CanvasInfo::getProjectId).collect(Collectors.toList());
List<ProjectNameVo> nameList = projectClient.getProjectNameList(projectIds).getData();
if (null == nameList || nameList.isEmpty()) {
return list;
}
Map<String, String> map = nameList.stream().collect(Collectors.toMap(ProjectNameVo::getId, ProjectNameVo::getName));
list.forEach(item -> {
String projectName = map.get(item.getProjectId());
if (null != projectName) {
item.setProjectName(projectName);
}
});
return list;
} }
} }

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;
}
}

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

@ -1,9 +1,13 @@
package com.hnac.gglm.bigmodel.maintenance.controller; package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.dynamic.datasource.annotation.DS;
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;
@ -52,21 +56,21 @@ 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)); return R.status(vectorParamService.saveWithLog(req));
} }
@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))); return R.status(vectorParamService.removeByIdsWithLog(Func.toLongList(",", ids)));
} }
@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)); return R.status(vectorParamService.updateWithLog(req));
} }
@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));
}
}

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

@ -22,9 +22,6 @@ public class DeviceAttrDTO {
@ApiModelProperty("遥控的设备ID") @ApiModelProperty("遥控的设备ID")
private String deviceId; private String deviceId;
@ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称")
private String itemName;
@ApiModelProperty("记录名称") @ApiModelProperty("记录名称")
private String recordName; private String recordName;

4
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/dto/DeviceFuncDTO.java

@ -22,7 +22,7 @@ public class DeviceFuncDTO {
@ApiModelProperty("遥控的设备ID") @ApiModelProperty("遥控的设备ID")
private String deviceId; private String deviceId;
@ApiModelProperty("用于展示和匹配的全称,一般可设为 站点名称-遥控名称") @ApiModelProperty("遥控名称")
private String itemName; private String ykName;
} }

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> {
} }

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

@ -61,7 +61,7 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
deviceFuncDTO.setDeviceId(deviceFunc.getDeviceId()); deviceFuncDTO.setDeviceId(deviceFunc.getDeviceId());
deviceFuncDTO.setDeviceName(deviceFunc.getDeviceName()); deviceFuncDTO.setDeviceName(deviceFunc.getDeviceName());
deviceFuncDTO.setItemId(deviceFunc.getSignage()); deviceFuncDTO.setItemId(deviceFunc.getSignage());
deviceFuncDTO.setItemName(deviceFunc.getItemName()); deviceFuncDTO.setYkName(deviceFunc.getName());
deviceFuncDTO.setStationName(deviceFunc.getProjectName()); deviceFuncDTO.setStationName(deviceFunc.getProjectName());
deviceFuncDTO.setStationId(deviceFunc.getProjectId()); deviceFuncDTO.setStationId(deviceFunc.getProjectId());
deviceFuncDTOS.add(deviceFuncDTO); deviceFuncDTOS.add(deviceFuncDTO);

1
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java

@ -92,7 +92,6 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
deviceAttrDTO.setRecordName(deviceAttr.getName()); deviceAttrDTO.setRecordName(deviceAttr.getName());
deviceAttrDTO.setItemId(deviceAttr.getSignage()); deviceAttrDTO.setItemId(deviceAttr.getSignage());
deviceAttrDTO.setRule(deviceAttr.getRule()); deviceAttrDTO.setRule(deviceAttr.getRule());
deviceAttrDTO.setItemName(deviceAttr.getItemName());
deviceAttrDTOS.add(deviceAttrDTO); deviceAttrDTOS.add(deviceAttrDTO);
} }
} }

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);
}

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

@ -19,4 +19,12 @@ 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);
Boolean removeByIdsWithLog(List<Long> isList);
Boolean saveWithLog(VectorParamEntity req);
Boolean updateWithLog(VectorParamEntity req);
} }

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

@ -0,0 +1,78 @@
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.secure.utils.AuthUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @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());
req.setCreateUser(AuthUtil.getUserId());
return save(req);
}
@Override
public Boolean edit(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.UPDATE.getCode());
req.setCreateUser(AuthUtil.getUserId());
return save(req);
}
@Override
public Boolean reset(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.RESET.getCode());
req.setCreateUser(AuthUtil.getUserId());
return save(req);
}
@Override
public Boolean delete(List<Long> ids) {
final Long userId = AuthUtil.getUserId();
ids.forEach(id -> {
VectorParamLogEntity log = VectorParamLogEntity.builder()
.vectorParamId(id)
.type(DataOperateType.DELETE.getCode()).build();
log.setCreateUser(userId);
save(log);
});
return Boolean.TRUE;
}
@Override
public Boolean synchronization(VectorParamLogEntity req) {
if (ObjectUtil.isEmpty(req.getVectorParamId())) {
return false;
}
req.setType(DataOperateType.SYNCHRONIZATION.getCode());
req.setCreateUser(AuthUtil.getUserId());
return save(req);
}
}

69
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,47 @@ 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;
} }
@Override
public Boolean removeByIdsWithLog(List<Long> idList) {
Boolean result = baseMapper.deleteBatchIds(idList) > 0;
if (result) {
vectorParamLogService.delete(idList);
}
return result;
}
@Override
public Boolean saveWithLog(VectorParamEntity req) {
Boolean result = baseMapper.insert(req) > 0;
if (result) {
vectorParamLogService.create(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.CREATE.getCode()).build());
}
return result;
}
@Override
public Boolean updateWithLog(VectorParamEntity req) {
Boolean result = baseMapper.updateById(req) > 0;
if (result) {
vectorParamLogService.edit(VectorParamLogEntity.builder()
.vectorParamId(req.getId())
.type(DataOperateType.UPDATE.getCode()).build());
}
return result;
}
} }

Loading…
Cancel
Save