Browse Source

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

zhongwei
yang_shj 2 months ago
parent
commit
2280d83e30
  1. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java
  2. 20
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/AgentLogController.java
  3. 11
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/DataInstructController.java
  4. 7
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/AgentLogEntity.java
  5. 3
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/AgentLogMapper.java
  6. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/AgentLogService.java
  7. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataInstructService.java
  8. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/DataRecordService.java
  9. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileInfoService.java
  10. 34
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/AgentLogServiceImpl.java
  11. 28
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

3
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInteractiveServiceImpl.java

@ -17,8 +17,8 @@ import com.hnac.gglm.bigmodel.interactive.vo.AuthDataVO;
import com.hnac.gglm.bigmodel.interactive.vo.ExtraVO;
import com.hnac.gglm.bigmodel.interactive.vo.SessionContentVO;
import com.hnac.gglm.bigmodel.manager.SessionRedisManager;
import groovy.util.logging.Slf4j;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func;
@ -97,6 +97,7 @@ public class HznlmInteractiveServiceImpl implements IHznlmInteractiveService {
}
String levelAuth = ParamCache.getValue(ParamKeyConstants.LIBRARY_AUTH_LEVEL);
result.put("levelAuth",Optional.ofNullable(levelAuth).map(Integer::valueOf).orElse(0));
log.info("知识库鉴权:{}",result);
return result;
}

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

@ -13,10 +13,15 @@ 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.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/**
* @Author: ypj
* @Date: 2024/9/9 10:37
@ -40,7 +45,11 @@ public class AgentLogController {
@ApiOperation(value = "查看详情")
@ApiOperationSupport(order = 2)
public R<AgentLogEntity> detail(@RequestParam @ApiParam("主键ID") Long id) {
return R.data(agentLogService.getById(id));
AgentLogEntity result = agentLogService.getById(id);
if (result != null) {
result.setLabelOperator(agentLogService.getUsername(result.getLabelOperatorId()));
}
return R.data(result);
}
@PostMapping("/save")
@ -77,4 +86,13 @@ public class AgentLogController {
public R label(@RequestBody LabelRequest req) {
return R.status(agentLogService.label(req));
}
@GetMapping("/test")
public R test(@RequestHeader("Hzinfo-Auth") String token) {
BladeUser user = AuthUtil.getUser();
Map<String, Object> result = new HashMap<>();
result.put("user", user);
result.put("token", token);
return R.data(result);
}
}

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

@ -50,14 +50,11 @@ public class DataInstructController {
@ApiOperationSupport(order = 3)
public R<IPage<DataInstructEntity>> listPage(Query query, DataInstructEntity req) {
QueryWrapper<DataInstructEntity> wrapper = new QueryWrapper<>();
if (StringUtils.isNotBlank(req.getItemId())) {
wrapper.lambda().eq(DataInstructEntity::getItemId, req.getItemId());
if (StringUtils.isNotBlank(req.getStationName())) {
wrapper.lambda().like(DataInstructEntity::getStationName, req.getStationName());
}
if (StringUtils.isNotBlank(req.getStationId())) {
wrapper.lambda().eq(DataInstructEntity::getStationId, req.getStationId());
}
if (StringUtils.isNotBlank(req.getDeviceId())) {
wrapper.lambda().eq(DataInstructEntity::getDeviceId, req.getDeviceId());
if (StringUtils.isNotBlank(req.getDeviceName())) {
wrapper.lambda().like(DataInstructEntity::getDeviceName, req.getDeviceName());
}
if (StringUtils.isNotBlank(req.getYkName())) {
wrapper.lambda().like(DataInstructEntity::getYkName, req.getYkName());

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

@ -82,9 +82,14 @@ public class AgentLogEntity extends TenantEntity implements Serializable {
@TableField("label_content")
private String labelContent;
@ApiModelProperty("标注人id")
@QueryField(condition = SqlCondition.EQUAL)
@TableField("label_operator")
private String labelOperatorId;
@ApiModelProperty("标注人名称")
@QueryField(condition = SqlCondition.LIKE)
@TableField("label_operator")
@TableField(exist = false)
private String labelOperator;
@ApiModelProperty("标注时间")

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

@ -1,5 +1,6 @@
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.AgentLogEntity;
@ -7,5 +8,7 @@ import com.hnac.gglm.bigmodel.maintenance.entity.AgentLogEntity;
* @Author: ypj
* @Date: 2024/9/9 11:07
*/
@DS("hznlm")
public interface AgentLogMapper extends BaseMapper<AgentLogEntity> {
}

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

@ -16,4 +16,6 @@ public interface AgentLogService extends IService<AgentLogEntity> {
Boolean label(LabelRequest req);
IPage<AgentLogEntity> listPage(IPage<AgentLogEntity> page, AgentLogEntity req);
String getUsername(String userIdStr);
}

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

@ -58,7 +58,7 @@ public class DataInstructService extends BaseServiceImpl<DataInstructMapper, Dat
List<DataInstructEntity> list = baseMapper.selectList(null);
List<DeviceFuncDTO> deviceFuncDTOS = BeanUtil.copyProperties(list, DeviceFuncDTO.class);
if(Func.isNotEmpty(deviceFuncDTOS)) {
deviceFuncDTOS.forEach(deviceFuncDTO -> deviceFuncDTO.setType("业务"));
deviceFuncDTOS.forEach(deviceFuncDTO -> deviceFuncDTO.setType("数据中心"));
result.addAll(deviceFuncDTOS);
}
List<DeviceFuncInfoDTO> deviceFuncList = vectorDataService.getDeviceFunc();

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

@ -52,11 +52,11 @@ public class DataRecordService extends BaseServiceImpl<DataRecordMapper, DataRec
if (StringUtils.isNotBlank(req.getItemId())) {
wrapper.lambda().eq(DataRecordEntity::getItemId, req.getItemId());
}
if (StringUtils.isNotBlank(req.getStationId())) {
wrapper.lambda().eq(DataRecordEntity::getStationId, req.getStationId());
if (StringUtils.isNotBlank(req.getStationName())) {
wrapper.lambda().like(DataRecordEntity::getStationName, req.getStationName());
}
if (StringUtils.isNotBlank(req.getDeviceId())) {
wrapper.lambda().eq(DataRecordEntity::getDeviceId, req.getDeviceId());
if (StringUtils.isNotBlank(req.getDeviceName())) {
wrapper.lambda().like(DataRecordEntity::getDeviceName, req.getDeviceName());
}
if (StringUtils.isNotBlank(req.getRecordName())) {
wrapper.lambda().like(DataRecordEntity::getRecordName, req.getRecordName());

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

@ -17,7 +17,7 @@ import java.util.List;
*/
public interface KnowledgeFileInfoService extends IService<KnowledgeFileInfo> {
String SEGMENT_URL = "/kn/doc_segment";
String VECTOR_DATABASE_NAME = "knowledge_data";
String VECTOR_DATABASE_NAME = "Hzims_knowledge_data";
Boolean store(IdRequest req);

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

@ -1,6 +1,5 @@
package com.hnac.gglm.bigmodel.maintenance.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -13,8 +12,11 @@ import com.hnac.gglm.bigmodel.maintenance.vo.LabelRequest;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.stereotype.Service;
import java.util.Date;
@ -26,8 +28,8 @@ import java.util.Date;
@Service
@Slf4j
@AllArgsConstructor
@DS("hznlm")
public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEntity> implements AgentLogService {
private final IUserClient userClient;
@Override
public Boolean BatchLabel(IdsRequest ids) {
@ -35,7 +37,7 @@ public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEnt
return this.update(Wrappers.<AgentLogEntity>lambdaUpdate()
.set(AgentLogEntity::getLabelStatus, 1)
.set(AgentLogEntity::getLabelResult, 1)
.set(AgentLogEntity::getLabelOperator, AuthUtil.getUserName())
.set(AgentLogEntity::getLabelOperatorId, AuthUtil.getUserId())
.set(AgentLogEntity::getLabelTime, now)
.set(AgentLogEntity::getUpdateTime, now)
.in(AgentLogEntity::getId, ids.getIds()));
@ -51,7 +53,7 @@ public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEnt
.set(AgentLogEntity::getLabelStatus, 1)
.set(AgentLogEntity::getLabelResult, labelResult)
.set(StringUtil.isNotBlank(req.getLabelContent()), AgentLogEntity::getLabelContent, req.getLabelContent())
.set(AgentLogEntity::getLabelOperator, AuthUtil.getUserAccount())
.set(AgentLogEntity::getLabelOperatorId, AuthUtil.getUserId())
.set(AgentLogEntity::getLabelTime, now)
.set(AgentLogEntity::getUpdateTime, now)
.eq(AgentLogEntity::getId, req.getId()));
@ -70,7 +72,29 @@ public class AgentLogServiceImpl extends ServiceImpl<AgentLogMapper, AgentLogEnt
.eq(ObjectUtil.isNotEmpty(req.getLabelStatus()), AgentLogEntity::getLabelStatus, req.getLabelStatus())
.orderByAsc(AgentLogEntity::getCreateTime)
.orderByAsc(AgentLogEntity::getChatId);
return this.page(page, queryWrapper);
IPage<AgentLogEntity> pageResult = baseMapper.selectPage(page, queryWrapper);
pageResult.getRecords().forEach(item -> {
String userIdStr = item.getLabelOperatorId();
String userName = getUsername(userIdStr);
item.setLabelOperator(userName == null ? userIdStr : userName);
});
return pageResult;
}
@Override
public String getUsername(String userIdStr) {
String userName = null;
if (null != userIdStr) {
try {
Long userId = Long.parseLong(userIdStr);
R<User> userR = userClient.userInfoById(userId);
if (userR.isSuccess() && userR.getData() != null) {
userName = userR.getData().getName();
}
} catch (Exception ignore) {
}
}
return userName;
}
}

28
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/zhipuai/service/impl/ZhipuAnalysisServiceImpl.java

@ -97,15 +97,9 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
return response;
}
String getSendUrl(ZhipuAnalysisFileRequest request) {
public String getSendUrl(ZhipuAnalysisFileRequest request) {
if (StringUtil.isNotBlank(request.getUrl())) {
String base64 = null;
try {
base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(request.getUrl()));
} catch (Exception e) {
log.info("get base64 error", e);
}
return StringUtil.isBlank(base64) ? request.getUrl() : base64;
return getBase64FromUrl(request.getUrl());
}
Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> {
throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException();
@ -117,6 +111,17 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
}
}
public String getBase64FromUrl(String url) {
log.info("get base64 from url ,url : {}", url);
String base64 = null;
try {
base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(url));
} catch (Exception e) {
log.info("get base64 error", e);
}
return StringUtil.isBlank(base64) ? url : base64;
}
@Override
public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) {
ZhipuAnalysisInfoEntity result = null;
@ -143,7 +148,8 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
Assert.isTrue(CollectionUtil.isNotEmpty(request.getCodeList()) || CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), () -> {
throw ErrorCode.EMPTY_ANALYSIS_TYPE.throwException();
});
List<ZhipuAnalysisInfoEntity> infoList = infoService.list(Wrappers.<ZhipuAnalysisInfoEntity>lambdaQuery().in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList())
List<ZhipuAnalysisInfoEntity> infoList = infoService.list(Wrappers.<ZhipuAnalysisInfoEntity>lambdaQuery()
.in(CollectionUtil.isNotEmpty(request.getCodeList()), ZhipuAnalysisInfoEntity::getCode, request.getCodeList())
.in(CollectionUtil.isNotEmpty(request.getCheckTypeSonList()), ZhipuAnalysisInfoEntity::getCheckTypeSon, request.getCheckTypeSonList()));
Assert.isTrue(CollectionUtil.isNotEmpty(infoList), () -> {
throw ErrorCode.UNKNOWN_ANALYSIS_TYPE.throwException();
@ -151,7 +157,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel());
String text = getMultiAnalyserText(infoList);
Map<String, Object> resultMap = analyser.getResultMap(text, request.getUrl());
Map<String, Object> resultMap = analyser.getResultMap(text, getBase64FromUrl(request.getUrl()));
if (null == resultMap) {
response.setCode(ResultCode.FAILURE.getCode());
@ -207,7 +213,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService {
formatBuilder.append("{");
for (int index = 1; index <= infoList.size(); index++) {
ZhipuAnalysisInfoEntity infoEntity = infoList.get(index - 1);
stringBuilder.append(StringUtil.format(MULTI_QUESTION_PREFIX, index));
stringBuilder.append(StringUtil.format(MULTI_QUESTION_PREFIX, index)).append(infoEntity.getRequestContent());
titleBuilder.append(StringUtil.format(MULTI_QUESTION_CONSTRAINS_LIST, infoEntity.getResultKey(), index));
formatBuilder.append(infoEntity.getRequestOutputFormat()).append(",");
}

Loading…
Cancel
Save