Browse Source

fix: 修复线上bug

zhongwei
haungxing 3 months ago
parent
commit
6d8e7a9ffe
  1. 5
      hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java
  2. 3
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/factory/AnswerResolveFactory.java
  3. 32
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java
  4. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java
  5. 57
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/FrontEndInteractiveSchedule.java
  6. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/XxlJobConfig.java
  7. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectUserMapper.java
  8. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.java
  9. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/TemplateProjectMapper.java
  10. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectMapper.java
  11. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectProjectContentMapper.java
  12. 3
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectProjectMapper.java
  13. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskUserMapper.java
  14. 4
      hzims-service/inspect/src/main/resources/template/template.yml
  15. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/config/XxlJobConfig.java
  16. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java
  17. 2
      hzims-service/weather/src/main/java/com/hnac/hzims/weather/config/XxlJobConfig.java
  18. 4
      hzims-service/weather/src/main/resources/template/template.yml

5
hzims-service-api/big-model-api/src/main/java/com/hnac/hzims/bigmodel/api/constants/MqttTopicConstants.java

@ -21,5 +21,10 @@ public interface MqttTopicConstants {
*/
String RUN_REPORT_ANALYSE_RESULT = "topic_run_report_analyse_result";
/**
* 识别结果
*/
String IDENTITY_RESULT = "topic_hznlm_identify_result";
}

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

@ -21,6 +21,7 @@ public class AnswerResolveFactory {
public static final String REMOTE_ANSWER_SERVICE = "remoteAnswerResolveService";
public static final String PARAM_ANSWER_SERVICE = "paramAnswerResolveService";
public static final String PRE_ANSWER_SERVICE = "preAnswerResolveService";
public static final String CONTROL_DEVICE_SERVICE = "controlAnswerResolveService";
public static IAnswerResolveService getResolveService(Object extra) {
String funcCode = JSONObject.parseObject(JSON.toJSONString(extra)).getString("func");
@ -44,6 +45,8 @@ public class AnswerResolveFactory {
return SpringUtil.getBean(REMOTE_ANSWER_SERVICE);
case SHOW_PARAM:
return SpringUtil.getBean(PARAM_ANSWER_SERVICE);
case CONTROL_DEVICE:
return SpringUtil.getBean(CONTROL_DEVICE_SERVICE);
default:
return null;
}

32
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/ControlAnswerResolveServiceImpl.java

@ -0,0 +1,32 @@
package com.hnac.hzims.bigmodel.interactive.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hnac.hzims.bigmodel.interactive.factory.AnswerResolveFactory;
import com.hnac.hzims.bigmodel.interactive.service.IAnswerResolveService;
import com.hnac.hzims.bigmodel.interactive.vo.AnswerVO;
import com.hnac.hzims.bigmodel.interactive.vo.ExtraVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @Author: huangxing
* @Date: 2024/08/30 11:33
*/
@Service(AnswerResolveFactory.CONTROL_DEVICE_SERVICE)
@Slf4j
public class ControlAnswerResolveServiceImpl implements IAnswerResolveService {
@Override
public AnswerVO resolve(AnswerVO answer) {
Object[] extraArray = this.extraStream(answer).map(this::getExtra).toArray();
answer.setExtras(extraArray);
return answer;
}
@Override
public ExtraVO getExtra(JSONObject originExtra) {
log.info("控制指令传参为:{}", JSON.toJSONString(originExtra));
return null;
}
}

5
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java

@ -65,8 +65,7 @@ public class AnswerVO implements Serializable {
return new AnswerVO(sessionId,userId,0,-2,null,query, InfoMessageConstant.ERROR_MESSAGE, null,null,new String[]{InfoMessageConstant.ERROR_MESSAGE});
}
public static void error(AnswerVO usualVO) {
usualVO.setRunning(0);
usualVO.setStatus(-2);
public static AnswerVO progress(String sessionId,String userId,String query,String message,Integer status) {
return new AnswerVO(sessionId,userId,1,status,null,query, message, null,null,new String[]{message});
}
}

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

@ -50,34 +50,35 @@ public class FrontEndInteractiveSchedule {
return ReturnT.SUCCESS;
}
List<AnswerVO> answerList = hznlmInvokeService.getAnswerBySessionIds(String.join(",", sessionIds));
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> {
// 如果已经获取到答案 则删除缓存
if(answerVO.getRunning() == 0) {
log.info("获取大模型解析答案:{}" , JSON.toJSONString(answerVO));
sessionRedisManager.removeSessionId(answerVO.getChatId());
}
Object[] extras = answerVO.getExtras();
if(ObjectUtil.isNotEmpty(answerVO.getExtras()) && extras.length > 0){
try {
// 解析答案
Object[] resolveExtras = Arrays.stream(extras).map(extra -> {
IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra);
if(Func.isNotEmpty(answerResolveService)) {
JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra));
return answerResolveService.getExtra(extraObject);
}
return extra;
}).map(JSON::toJSONString).toArray();
answerVO.setExtras(resolveExtras);
}
catch(Exception e) {
log.error("An error occurred",e);
AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery());
}
}
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
wsService.sendMessage(answerVO.getChatId(),message);
}, getAnswerPoolExecutor));
answerList.stream().parallel().forEach(answerVO -> CompletableFuture.runAsync(() -> this.formatAnswer(answerVO), getAnswerPoolExecutor));
return ReturnT.SUCCESS;
}
private void formatAnswer(AnswerVO answerVO) {
// 如果已经获取到答案 则删除缓存
if(answerVO.getRunning() == 0) {
log.info("获取大模型解析答案:{}", JSON.toJSONString(answerVO));
sessionRedisManager.removeSessionId(answerVO.getChatId());
}
Object[] extras = answerVO.getExtras();
// 格式化 extra
if(Func.isNotEmpty(extras)) {
try {
Object[] resolveExtras = Arrays.stream(extras).map(extra -> {
IAnswerResolveService answerResolveService = AnswerResolveFactory.getResolveService(extra);
if (Func.isNotEmpty(answerResolveService)) {
JSONObject extraObject = JSONObject.parseObject(JSON.toJSONString(extra));
return answerResolveService.getExtra(extraObject);
}
return extra;
}).map(JSON::toJSONString).toArray();
answerVO.setExtras(resolveExtras);
} catch(Exception e) {
log.error("An error occurred",e);
AnswerVO.error(answerVO.getChatId(), answerVO.getUserId(), answerVO.getQuery());
}
}
TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO));
wsService.sendMessage(answerVO.getChatId(),message);
}
}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/config/XxlJobConfig.java

@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
*
* @author xuxueli 2017-04-28
*/
@Configuration
//@Configuration
@Slf4j
public class XxlJobConfig {

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ObjectUserMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.obj.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.springblade.core.datascope.annotation.UserDataAuth;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.obj.entity.ObjectUserEntity;
@ -16,5 +17,6 @@ import java.util.List;
public interface ObjectUserMapper extends BaseMapper<ObjectUserEntity>{
@UserDataAuth
@InterceptorIgnore(tenantLine = "true")
List<ObjectUserListQuery> getPageList(@Param("user") ObjectUserListQuery user);
}

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/ProjectContentMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.obj.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.obj.entity.ContentEntity;
import com.hnac.hzinfo.inspect.obj.entity.ProjectContentEntity;
@ -18,6 +19,7 @@ public interface ProjectContentMapper extends BaseMapper<ProjectContentEntity>{
* @param projectId 项目id
* @return
*/
@InterceptorIgnore(tenantLine = "true")
List<ProjectContentEntity> getListByProjectId(Long projectId);
/**
@ -26,6 +28,7 @@ public interface ProjectContentMapper extends BaseMapper<ProjectContentEntity>{
* @param projectId 项目id
* @return
*/
@InterceptorIgnore(tenantLine = "true")
List<ContentEntity> getListByPrjId(Long projectId);
@ -35,5 +38,6 @@ public interface ProjectContentMapper extends BaseMapper<ProjectContentEntity>{
* @param projectId
* @return
*/
@InterceptorIgnore(tenantLine = "true")
Integer getMaxSortProjectContentByProjectId(Long projectId);
}

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/obj/mapper/TemplateProjectMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.obj.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.obj.entity.TemplateProjectEntity;
import com.hnac.hzinfo.inspect.obj.vo.ProjectContentDto;
@ -17,6 +18,7 @@ public interface TemplateProjectMapper extends BaseMapper<TemplateProjectEntity>
* 根据模板id获取项目
* @param templateId
*/
@InterceptorIgnore(tenantLine = "true")
List<TemplateProjectEntity> getListByTemplateId(Long templateId);
/**
@ -24,6 +26,7 @@ public interface TemplateProjectMapper extends BaseMapper<TemplateProjectEntity>
* 根据模板id获取项目内容
* @param templateId
*/
@InterceptorIgnore(tenantLine = "true")
List<ProjectContentDto> getProjectsByTemplateId(Long templateId);
/**
@ -31,5 +34,6 @@ public interface TemplateProjectMapper extends BaseMapper<TemplateProjectEntity>
* @param templateId
* @return
*/
@InterceptorIgnore(tenantLine = "true")
Integer getMaxSortTemplateProjectByTemplateId(Long templateId);
}

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectEntity;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectOfflineVO;
@ -17,9 +18,12 @@ import java.util.List;
@Mapper
public interface TaskObjectMapper extends BaseMapper<TaskObjectEntity> {
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectEntity> getTaskObjects(@Param("to") TaskObjectEntity to);
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectVO> getTaskObjectsDetail(@Param("to") TaskObjectEntity to);
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectOfflineVO> getExObjectData(@Param("taskIds") List<Long> taskIds);
}

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectProjectContentMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectContentEntity;
import org.apache.ibatis.annotations.Mapper;
@ -15,5 +16,6 @@ import java.util.List;
@Mapper
public interface TaskObjectProjectContentMapper extends BaseMapper<TaskObjectProjectContentEntity> {
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectProjectContentEntity> getTaskObjectProjectContents(@Param("topc")TaskObjectProjectContentEntity topc);
}

3
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskObjectProjectMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.task.entity.TaskObjectProjectEntity;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectProjectOfflineVO;
@ -16,7 +17,9 @@ import java.util.List;
@Mapper
public interface TaskObjectProjectMapper extends BaseMapper<TaskObjectProjectEntity> {
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectProjectEntity> getTaskObjectProjects(@Param("top")TaskObjectProjectEntity top);
@InterceptorIgnore(tenantLine = "true")
List<TaskObjectProjectOfflineVO> getObjectProjectData(@Param("taskIds") List<Long> taskIds);
}

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskUserMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
import org.apache.ibatis.annotations.Mapper;
@ -19,9 +20,12 @@ public interface TaskUserMapper extends BaseMapper<TaskUserEntity> {
* @param planId 计划id
* @return
*/
@InterceptorIgnore(tenantLine = "true")
int deleteByPlanId(@Param("planId") Long planId);
@InterceptorIgnore(tenantLine = "true")
int updateDeleteStatus(@Param("taskId") Long taskId);
@InterceptorIgnore(tenantLine = "true")
List<TaskUserEntity> getOfflineTaskUser(@Param("taskIds") List<Long> taskIds);
}

4
hzims-service/inspect/src/main/resources/template/template.yml

@ -36,8 +36,8 @@ swagger:
xxl:
job:
auto:
registry: 0
accessToken: ''
registry: 1
accessToken: 'hzinfo88238888!'
admin:
addresses: http://${hzims.xxljob.ip}:${hzims.xxljob.port}/xxl-job-admin
executor:

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/config/XxlJobConfig.java

@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
*
* @author xuxueli 2017-04-28
*/
@Configuration
//@Configuration
@Slf4j
public class XxlJobConfig {

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolServiceImpl.java

@ -237,7 +237,7 @@ public class SafetyToolServiceImpl extends ServiceImpl<SafetyToolMapper, SafetyT
if (CollectionUtil.isNotEmpty(entityList)) {
List<SafeProductPdf> pdfList = new ArrayList<>(entityList.size());
entityList.forEach(entity -> {
String imgPath = uploadPath + "/" + entity.getTenantId() + entity.getToolCode() + UPLOAD_IMG_SUFFIX;
String imgPath = uploadPath + "/" + entity.getTenantId() + entity.getToolCode().trim() + UPLOAD_IMG_SUFFIX;
File file = new File(imgPath);
if (!file.exists()) {
/**生成二维码**/

2
hzims-service/weather/src/main/java/com/hnac/hzims/weather/config/XxlJobConfig.java

@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
*
* @author xuxueli 2017-04-28
*/
@Configuration
//@Configuration
@Slf4j
public class XxlJobConfig {

4
hzims-service/weather/src/main/resources/template/template.yml

@ -30,8 +30,8 @@ mybatis-plus:
xxl:
job:
auto:
registry: 0
accessToken: ''
registry: 1
accessToken: 'hzinfo88238888!'
admin:
addresses: "http://${hzims.xxljob.ip}:${hzims.xxljob.port}/xxl-job-admin"
executor:

Loading…
Cancel
Save