Browse Source

fix: 大模型模块名调整

zhongwei
haungxing 2 months ago
parent
commit
ca02b11a45
  1. 1
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/FunctionEntity.java
  2. 2
      hzims-service-api/big-model-api/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/WhitelistEntity.java
  3. 25
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java
  4. 0
      hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java
  5. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java
  6. 13
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInteraction.java
  7. 5
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java
  8. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/database/service/WeaviateService.java
  9. 30
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java
  10. 9
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java
  11. 119
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/impl/HznlmInvokeServiceImpl.java
  12. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/constants/StoreStatus.java
  13. 6
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/controller/KnowledgeFileFragmentController.java
  14. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/DatasourceEntity.java
  15. 0
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KeysMatchEntity.java
  16. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/KnowledgeFileFragment.java
  17. 40
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/SyncPropertyEntity.java
  18. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/entity/TablePropertyEntity.java
  19. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/mapper/KnowledgeFileFragmentMapper.java
  20. 4
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/KnowledgeFileFragmentService.java
  21. 8
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/service/impl/KnowledgeFileFragmentServiceImpl.java
  22. 2
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/maintenance/vo/IdRequest.java
  23. 32
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/MultipartFileToBase64Converter.java
  24. 7
      hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java
  25. 31
      hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/vo/DeptUserVO.java
  26. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

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

@ -17,7 +17,6 @@ import javax.validation.constraints.Size;
*/ */
@Data @Data
@ApiModel(value = "大模型函数entity",description = "大模型函数entity") @ApiModel(value = "大模型函数entity",description = "大模型函数entity")
@TableName("HZIMS_FUNCTION")
public class FunctionEntity extends TenantEntity { public class FunctionEntity extends TenantEntity {
@ApiModelProperty("函数名称") @ApiModelProperty("函数名称")

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

@ -11,7 +11,7 @@ import org.springblade.core.tenant.mp.TenantEntity;
* @author ysj * @author ysj
*/ */
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("hzims_whitelist") @TableName("gglm_whitelist")
@ApiModel(value = "白名单实体类",description = "大模型白名单") @ApiModel(value = "白名单实体类",description = "大模型白名单")
@Data @Data
public class WhitelistEntity extends TenantEntity { public class WhitelistEntity extends TenantEntity {

25
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/service/impl/EmInfoServiceImpl.java

@ -28,6 +28,7 @@ import com.hnac.hzims.spare.vo.SparePartVO;
import com.hnac.hzims.util.TableJsonUtils; import com.hnac.hzims.util.TableJsonUtils;
import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient; import com.hnac.hzinfo.datasearch.analyse.IAnalyseDataSearchClient;
import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO; import com.hnac.hzinfo.datasearch.analyse.vo.AnalyzeCodeBySignagesVO;
import com.hnac.hzinfo.exception.HzServiceException;
import com.hnac.hzinfo.inspect.obj.dto.ContentDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDTO;
import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO; import com.hnac.hzinfo.inspect.obj.dto.ContentDefinitionDTO;
import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO; import com.hnac.hzinfo.inspect.obj.dto.ProjectDTO;
@ -996,4 +997,28 @@ public class EmInfoServiceImpl extends ServiceImpl<EmInfoMapper, EmInfoEntity> i
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }
@Override
public List<StationEmInfoVO> getStationEmList() {
R<List<StationEntity>> stationsResult = stationClient.getListAll();
if(!stationsResult.isSuccess()) {
throw new HzServiceException("获取站点列表失败!");
}
List<StationEntity> stationList = stationsResult.getData();
List<EmInfoEntity> emInfoList = this.baseMapper.getAllEmInfo();
List<StationEmInfoVO> result = emInfoList.stream().map(emInfo -> {
Optional<StationEntity> stationOptional = stationList.stream().filter(station -> emInfo.getDepartment().equals(station.getRefDept())).findFirst();
if (stationOptional.isPresent()) {
StationEntity stationEntity = stationOptional.get();
StationEmInfoVO stationEmInfoVO = new StationEmInfoVO();
stationEmInfoVO.setEmName(emInfo.getName());
stationEmInfoVO.setEmCode(emInfo.getNumber());
stationEmInfoVO.setStationCode(stationEntity.getCode());
stationEmInfoVO.setStationName(stationEntity.getName());
return stationEmInfoVO;
}
return null;
}).filter(Func::isNotEmpty).collect(Collectors.toList());
return result;
}
} }

0
hzims-service/equipment/src/main/java/com/hnac/hzims/equipment/vo/StationEmInfoVO.java

2
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/business/service/DataSourceService.java

@ -1,5 +1,6 @@
package com.hnac.gglm.bigmodel.business.service; package com.hnac.gglm.bigmodel.business.service;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -30,6 +31,7 @@ import java.util.regex.Pattern;
@Service @Service
@AllArgsConstructor @AllArgsConstructor
@Slf4j @Slf4j
@DS("hznlm")
public class DataSourceService { public class DataSourceService {
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;

13
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInteraction.java

@ -0,0 +1,13 @@
package com.hnac.gglm.bigmodel.configuration;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
public class BigModelInteraction {
private String url;
}

5
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/configuration/BigModelInvokeApi.java

@ -67,4 +67,9 @@ public class BigModelInvokeApi {
*/ */
private String compute; private String compute;
/**
* 通过图片或文字抽取表单内容进行填写
*/
private String identifyForm;
} }

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

@ -171,7 +171,7 @@ public class WeaviateService {
if(Func.isNotEmpty(className)) { if(Func.isNotEmpty(className)) {
objectsGetter.withClassName(className); objectsGetter.withClassName(className);
} }
Result<List<WeaviateObject>> result = objectsGetter.withLimit(pageSize).withOffset((current-1) * pageSize).run(); Result<List<WeaviateObject>> result = objectsGetter.withVector().withLimit(pageSize).withOffset((current-1) * pageSize).run();
if(result.hasErrors()) { if(result.hasErrors()) {
throw new HzServiceException("查询失败!"); throw new HzServiceException("查询失败!");
} }

30
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/controller/FontEndInteractiveController.java

@ -5,18 +5,23 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.gglm.bigmodel.BigModelConstants; import com.hnac.gglm.bigmodel.BigModelConstants;
import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService; import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService;
import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.IResultCode; import org.springblade.core.tool.api.IResultCode;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import java.util.UUID;
/** /**
* @Author: huangxing * @Author: huangxing
@ -67,4 +72,29 @@ public class FontEndInteractiveController {
hznlmInvokeService.interruptSession(sessionId); hznlmInvokeService.interruptSession(sessionId);
return R.success("操作成功!"); return R.success("操作成功!");
} }
@ApiOperation("识别智能表单")
@ApiOperationSupport(order = 6)
@GetMapping("/identifyForm")
public R identifyForm(@RequestParam("formStructure") @ApiParam("表单结构") String formStructure
, @RequestParam(value = "file",required = false) @ApiParam("表单文件") MultipartFile file
, @RequestParam(value = "content",required = false) @ApiParam("用于提取的文本") String content
, @RequestParam(value = "chatId") String chatId) {
if(Func.isEmpty(chatId)) {
chatId = UUID.randomUUID().toString();
}
hznlmInvokeService.identifyForm(formStructure,file,content,chatId,AuthUtil.getUserId());
return R.data(chatId);
}
@ApiOperation("根据chatId获取问答结果")
@ApiOperationSupport(order = 7)
@GetMapping("/getAnswerByChatId")
public R getAnswerByChatId(@RequestParam("chatId") @ApiParam("会话ID") String chatId){
List<AnswerVO> answers = hznlmInvokeService.getAnswerBySessionIds(chatId);
if(Func.isNotEmpty(answers) && answers.size() == 1 && answers.get(0).getStatus().intValue() == 0) {
return R.data(answers.get(0));
}
return R.data(null);
}
} }

9
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/interactive/service/IHznlmInvokeService.java

@ -3,6 +3,7 @@ package com.hnac.gglm.bigmodel.interactive.service;
import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest; import com.hnac.gglm.bigmodel.business.dto.RunReportAnalyseRequest;
import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO;
import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; import com.hnac.gglm.bigmodel.question.dto.QuestionDTO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -94,4 +95,12 @@ public interface IHznlmInvokeService {
*/ */
void updateKnowledge(String name); void updateKnowledge(String name);
/**
* 获取智能表单图文识别结果
* @param formStructure 表单结构
* @param file 上传文件
* @return 识别结果
*/
void identifyForm(String formStructure, MultipartFile file, String content, String chatId, Long userId);
} }

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

@ -12,6 +12,7 @@ import com.hnac.gglm.bigmodel.interactive.service.IHznlmInvokeService;
import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO; import com.hnac.gglm.bigmodel.interactive.vo.AnswerVO;
import com.hnac.gglm.bigmodel.manager.SessionRedisManager; import com.hnac.gglm.bigmodel.manager.SessionRedisManager;
import com.hnac.gglm.bigmodel.question.dto.QuestionDTO; import com.hnac.gglm.bigmodel.question.dto.QuestionDTO;
import com.hnac.gglm.bigmodel.utils.MultipartFileToBase64Converter;
import com.hnac.gglm.bigmodel.utils.RequestClientUtil; import com.hnac.gglm.bigmodel.utils.RequestClientUtil;
import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants; import com.hnac.gglm.bigmodel.websocket.constants.RedisKeyConstants;
import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager; import com.hnac.gglm.bigmodel.websocket.sessionManager.InteractiveSessionManager;
@ -19,12 +20,15 @@ import com.hnac.hzims.common.constant.CommonConstant;
import com.hnac.hzinfo.exception.HzServiceException; import com.hnac.hzinfo.exception.HzServiceException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.resource.feign.IOssClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -46,17 +50,18 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
private final SessionRedisManager sessionRedisManager; private final SessionRedisManager sessionRedisManager;
private final IAuthClient authClient; private final IAuthClient authClient;
private final RedisTemplate redisTemplate; private final RedisTemplate redisTemplate;
private final IOssClient ossClient;
@Value("${gglm.url}") @Value("${gglm.url}")
private String gglmUrl; private String gglmUrl;
@Override @Override
public void ask(String question, String sessionId, String userId) { public void ask(String question, String sessionId, String userId) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("chat_id", sessionId); params.put("chat_id",sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("query", question); params.put("q_id", UUID.randomUUID().toString());
params.put("q_id", UUID.randomUUID()); params.put("query",question);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); params.putAll(authDataIds);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params);
@ -65,40 +70,42 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void ask(QuestionDTO question) { public void ask(QuestionDTO question) {
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), JSON.toJSONString(question)); Map<String, Object> params = Func.toMap(question);
params.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAsk(), params);
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@Override @Override
public void specialAsk(String sessionId, String userId, Map<String, Object> extra) { public void specialAsk(String sessionId, String userId, Map<String, Object> extra) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("chat_id", sessionId); params.put("chat_id",sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("extra", extra); params.put("q_id", UUID.randomUUID().toString());
params.put("q_id", UUID.randomUUID()); params.put("extra",extra);
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); params.putAll(authDataIds);
log.info("调用大模型接口:{},传参为:{}", gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(params)); log.info("调用大模型接口:{},传参为:{}",gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(),JSON.toJSONString(params));
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params);
sessionRedisManager.addSessionId(sessionId); sessionRedisManager.addSessionId(sessionId);
} }
@Override @Override
public void specialAsk(QuestionDTO question) { public void specialAsk(QuestionDTO question) {
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); Map<String, Object> params = Func.toMap(question);
questionMap.put("q_id", UUID.randomUUID()); params.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), JSON.toJSONString(questionMap)); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantSpecialAsk(), params);
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@Override @Override
public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) { public void knowledgeAsk(String question, String sessionId, String userId, String knowledge) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("chat_id", sessionId); params.put("chat_id", sessionId);
params.put("user_id", userId); params.put("user_id", userId);
params.put("query", question); params.put("query", question);
params.put("q_id", UUID.randomUUID().toString());
params.put("knowledge", knowledge); params.put("knowledge", knowledge);
params.put("q_id", UUID.randomUUID());
Map<String, String[]> authDataIds = this.getAuthDataIds(userId); Map<String, String[]> authDataIds = this.getAuthDataIds(userId);
params.putAll(authDataIds); params.putAll(authDataIds);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params);
@ -107,17 +114,17 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void knowledgeAsk(QuestionDTO question) { public void knowledgeAsk(QuestionDTO question) {
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); Map<String, Object> params = Func.toMap(question);
questionMap.put("q_id", UUID.randomUUID()); params.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), JSON.toJSONString(questionMap)); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantKnowledgeAsk(), params);
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@Override @Override
public void analyseAsk(QuestionDTO question) { public void analyseAsk(QuestionDTO question) {
Map<String, Object> questionMap = JsonUtil.toMap(JSON.toJSONString(question)); Map<String, Object> params = Func.toMap(question);
questionMap.put("q_id", UUID.randomUUID()); params.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), JSON.toJSONString(questionMap)); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantAnalyseAsk(), params);
sessionRedisManager.addSessionId(question.getChatId()); sessionRedisManager.addSessionId(question.getChatId());
} }
@ -131,8 +138,8 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
@Override @Override
public void askAbort(String sessionId) { public void askAbort(String sessionId) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("chat_id", sessionId); params.put("chat_id",sessionId);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAskAbort(), params);
sessionRedisManager.removeSessionId(sessionId); sessionRedisManager.removeSessionId(sessionId);
} }
@ -144,71 +151,91 @@ public class HznlmInvokeServiceImpl implements IHznlmInvokeService {
int attempts = 0; int attempts = 0;
while (status > 0) { while (status > 0) {
// 若重连超过10次 则抛出错误 // 若重连超过10次 则抛出错误
if (attempts >= 8) { if(attempts >= 8) {
throw new HzServiceException("中断失败!长时间未获取到中断状态"); throw new HzServiceException("中断失败!长时间未获取到中断状态");
} }
List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId); List<AnswerVO> answers = this.getAnswerBySessionIds(sessionId);
if (Func.isNotEmpty(answers)) { if(Func.isNotEmpty(answers)) {
log.info(answers.get(0).getStatus() + ""); log.info(answers.get(0).getStatus()+"");
status = answers.get(0).getStatus(); status = answers.get(0).getStatus();
} }
// 若获取到的状态不等于2 则延时0.5秒 // 若获取到的状态不等于2 则延时0.5秒
if (status > 0) { if(status > 0) {
try { try {
Thread.sleep(500); Thread.sleep(500);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
attempts++; attempts ++;
} }
} }
@Override @Override
public void smartReportGeneratePower(RunReportAnalyseRequest req) { public void smartReportGeneratePower(RunReportAnalyseRequest req) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
String sessionId = IdWorker.get32UUID(); String sessionId = IdWorker.get32UUID();
params.put("chat_id", sessionId); params.put("chat_id",sessionId);
params.put("user_id", CommonConstant.SYSTEM_USER.toString()); params.put("user_id", CommonConstant.SYSTEM_USER.toString());
params.put("data", req.getAnalyseDTOS()); params.put("data", req.getAnalyseDTOS());
params.put("query", ""); params.put("query", "");
params.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getSmartReportGeneratePower(), params);
// 将sessionId存入redis,拿到数据之后输入月报中 // 将sessionId存入redis,拿到数据之后输入月报中
JSONObject report = new JSONObject(); JSONObject report = new JSONObject();
report.put("stationCode", req.getStationCode()); report.put("stationCode",req.getStationCode());
report.put("month", req.getMonth()); report.put("month",req.getMonth());
report.put("sessionId", sessionId); report.put("sessionId",sessionId);
redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID, JSON.toJSONString(report)); redisTemplate.opsForList().leftPush(RedisKeyConstants.RUN_REPORT_SESSION_ID,JSON.toJSONString(report));
redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID, 5, TimeUnit.MINUTES); redisTemplate.expire(RedisKeyConstants.RUN_REPORT_SESSION_ID,5, TimeUnit.MINUTES);
} }
@Override @Override
public void updateKnowledge(String name) { public void updateKnowledge(String name) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("name", name); params.put("name",name);
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params); RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getUpdateKnowledge(), params);
} }
@Override @Override
public void identifyForm(String formStructure, MultipartFile file, String content, String chatId, Long userId) {
// 若 file 不为空,则转换为base64编码格式字符串传给大模型
String pic = null;
if(Func.isNotEmpty(file)) {
pic = MultipartFileToBase64Converter.convertToBase64(file);
}
Map<String,Object> param = new HashMap<>(5);
Map<String,Object> data = new HashMap<>(3);
data.put("form",JSONObject.parseObject(formStructure));
data.put("pic", pic);
data.put("content", content);
param.put("chat_id", chatId);
param.put("user_id", userId.toString());
param.put("query", "");
param.put("data",data);
param.put("q_id", UUID.randomUUID().toString());
RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getIdentifyForm(), param, new TypeReference<JSONObject>(){});
}
@Override
public List hotQuestions() { public List hotQuestions() {
try { try {
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>() { return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getHotQuestion(), null, new TypeReference<List<String>>(){});
}); }
} catch (Exception e) { catch (Exception e) {
log.error("An error occurred", e); log.error("An error occurred",e);
return Lists.newArrayList(); return Lists.newArrayList();
} }
} }
@Override @Override
public List<AnswerVO> getAnswerBySessionIds(String sessionIds) { public List<AnswerVO> getAnswerBySessionIds(String sessionIds) {
Map<String, Object> params = new HashMap<>(); Map<String,Object> params = new HashMap<>();
params.put("chat_ids", Func.toStrList(",", sessionIds).toArray()); params.put("chat_ids",Func.toStrList(",",sessionIds).toArray());
return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>() { return RequestClientUtil.postCall(gglmUrl + bigModelInvokeApi.getAssistantStatus(), params, new TypeReference<List<AnswerVO>>(){});
});
} }
private Map<String, String[]> getAuthDataIds(String userId) { private Map<String,String[]> getAuthDataIds(String userId) {
Map<String, String[]> result = new HashMap<>(2); Map<String, String[]> result = new HashMap<>(2);
R<Map<String, String[]>> authDataR = authClient.getAuthData(userId); R<Map<String, String[]>> authDataR = authClient.getAuthData(userId);
result.putAll(authDataR.getData()); result.putAll(authDataR.getData());

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

@ -1,4 +1,4 @@
package com.hnac.hzims.bigmodel.maintenance.constants; package com.hnac.gglm.bigmodel.maintenance.constants;
import lombok.Getter; import lombok.Getter;

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

@ -1,9 +1,9 @@
package com.hnac.hzims.bigmodel.maintenance.controller; package com.hnac.gglm.bigmodel.maintenance.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileFragmentService; import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;

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

@ -18,7 +18,7 @@ import java.io.Serializable;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper=false) @EqualsAndHashCode(callSuper=false)
@TableName("HZIMS_DATASOURCE") @TableName("gglm_datasource")
@ApiModel(value = "数据源配置",description = "数据源配置") @ApiModel(value = "数据源配置",description = "数据源配置")
public class DatasourceEntity extends TenantEntity implements Serializable { public class DatasourceEntity extends TenantEntity implements Serializable {

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

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

@ -1,4 +1,4 @@
package com.hnac.hzims.bigmodel.maintenance.entity; package com.hnac.gglm.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;

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

@ -1,40 +0,0 @@
package com.hnac.gglm.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/08/21 08:33
*/
@Data
@EqualsAndHashCode
@ApiModel(value = "同步向量库基础配置",description = "同步向量库基础配置")
@TableName("")
public class SyncPropertyEntity extends TenantEntity implements Serializable {
@ApiModelProperty("配置编号")
private String code;
@ApiModelProperty("数据源")
private String datasource;
@ApiModelProperty("数据源名称")
private String datasourceName;
@ApiModelProperty("数据库表名")
private String tableName;
@ApiModelProperty("向量数据库表名,由小写字母以及_组成")
private String vectorTableName;
@ApiModelProperty("表描述")
private String tableDesc;
}

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

@ -17,7 +17,7 @@ import java.io.Serializable;
* @Date: 2024/07/05 14:49 * @Date: 2024/07/05 14:49
*/ */
@ApiModel("数据库表配置") @ApiModel("数据库表配置")
@TableName("HZIMS_TABLE_PROPERTY") @TableName("gglm_table_property")
@Data @Data
public class TablePropertyEntity extends TenantEntity implements Serializable { public class TablePropertyEntity extends TenantEntity implements Serializable {

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

@ -1,7 +1,7 @@
package com.hnac.hzims.bigmodel.maintenance.mapper; package com.hnac.gglm.bigmodel.maintenance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
/** /**
* @Author: ypj * @Author: ypj

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

@ -1,7 +1,7 @@
package com.hnac.hzims.bigmodel.maintenance.service; package com.hnac.gglm.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import java.util.List; import java.util.List;

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

@ -1,12 +1,12 @@
package com.hnac.hzims.bigmodel.maintenance.service.impl; package com.hnac.gglm.bigmodel.maintenance.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.maintenance.entity.KnowledgeFileFragment; import com.hnac.gglm.bigmodel.maintenance.entity.KnowledgeFileFragment;
import com.hnac.hzims.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper; import com.hnac.gglm.bigmodel.maintenance.mapper.KnowledgeFileFragmentMapper;
import com.hnac.hzims.bigmodel.maintenance.service.KnowledgeFileFragmentService; import com.hnac.gglm.bigmodel.maintenance.service.KnowledgeFileFragmentService;
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;

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

@ -1,4 +1,4 @@
package com.hnac.hzims.bigmodel.maintenance.vo; package com.hnac.gglm.bigmodel.maintenance.vo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;

32
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/MultipartFileToBase64Converter.java

@ -0,0 +1,32 @@
package com.hnac.gglm.bigmodel.utils;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Base64;
/**
* @Author: huangxing
* @Date: 2024/09/13 08:36
*/
public class MultipartFileToBase64Converter {
public static String convertToBase64(MultipartFile file) {
if (file.isEmpty()) {
return null;
}
try {
// 读取文件内容到字节数组
byte[] bytes = file.getBytes();
// 使用Base64编码字节数组
String encodedString = Base64.getEncoder().encodeToString(bytes);
return encodedString;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}

7
hzims-service/gglm-big-model/src/main/java/com/hnac/gglm/bigmodel/utils/RequestClientUtil.java

@ -27,9 +27,8 @@ public class RequestClientUtil {
* @param body 传参body * @param body 传参body
*/ */
public static void postCall(String url, String body) { public static void postCall(String url, String body) {
log.info("开始远程调用{}接口",url);
HttpResponse response = HttpRequest.post(url).body(body).execute(); HttpResponse response = HttpRequest.post(url).body(body).execute();
log.info("远程调用{}接口结束",url); log.info("接口调用结果为:{}",response.body());
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!");
}); });
@ -41,9 +40,8 @@ public class RequestClientUtil {
* @param body 传参body * @param body 传参body
*/ */
public static void postCall(String url, Map body) { public static void postCall(String url, Map body) {
log.info("开始远程调用{}接口",url);
HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute(); HttpResponse response = HttpRequest.post(url).body(JSON.toJSONString(body)).execute();
log.info("远程调用{}接口结束",url); log.info("接口调用结果为:{}",response.body());
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!"); throw new HzServiceException(ResultCode.FAILURE, "远程调用接口" + url + "失败!");
}); });
@ -62,6 +60,7 @@ public class RequestClientUtil {
Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> {
throw new HzServiceException(ResultCode.FAILURE, "远程调用大模型接口" + url + "失败!"); throw new HzServiceException(ResultCode.FAILURE, "远程调用大模型接口" + url + "失败!");
}); });
log.info("接口调用结果为:{}",response.body());
return JSONObject.parseObject(response.body(), typeRef); return JSONObject.parseObject(response.body(), typeRef);
} }

31
hzims-service/hzims-basic/src/main/java/com/hnac/hzims/basic/vo/DeptUserVO.java

@ -0,0 +1,31 @@
package com.hnac.hzims.basic.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @Author: huangxing
* @Date: 2024/09/11 20:03
*/
@Data
@ApiModel(value = "机构-用户VO对象",description = "机构-用户VO对象")
@EqualsAndHashCode
public class DeptUserVO implements Serializable {
@ApiModelProperty(value = "机构ID")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
@ApiModelProperty(value = "用户ID")
private Long userId;
@ApiModelProperty(value = "用户名称")
private String userName;
}

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/RunMonthServiceImpl.java

@ -9,8 +9,8 @@ import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.hnac.hzims.alarm.config.constants.AlarmConstants; import com.hnac.hzims.alarm.config.constants.AlarmConstants;
import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant; import com.hnac.hzims.alarm.config.constants.AlarmHandleConstant;
import com.hnac.hzims.bigmodel.api.feign.IDataAnalyseClient; import com.hnac.gglm.bigmodel.api.feign.IDataAnalyseClient;
import com.hnac.hzims.bigmodel.business.dto.*; import com.hnac.gglm.bigmodel.business.dto.*;
import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.logs.utils.StringUtils;
import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.entity.EmInfoEntity;
import com.hnac.hzims.equipment.entity.PlanGenerationEntity; import com.hnac.hzims.equipment.entity.PlanGenerationEntity;

Loading…
Cancel
Save