From 57755dbc43d64dfb698b0036c0228a4fa33c4da8 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 11:16:20 +0800 Subject: [PATCH 1/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/constants/FuncRouteEnum.java | 1 + .../controller/InteractiveController.java | 4 +- .../interactive/service/IInteractiveService.java | 2 +- .../service/impl/InteractiveServiceImpl.java | 4 +- .../service/impl/JumpRouteJoinStrategy.java | 46 +++++++++++++++------- .../bigmodel/schedule/InteractiveSchedule.java | 2 +- .../websocket/handler/InteractiveHandler.java | 21 ++++++++-- .../sessionManager/InteractiveSessionManager.java | 12 +++++- 8 files changed, 66 insertions(+), 26 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java index 11ef13c..4d51364 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/constants/FuncRouteEnum.java @@ -13,6 +13,7 @@ import java.util.Optional; @AllArgsConstructor public enum FuncRouteEnum { OPEN_SCADA("open_scada","打开实时画面"), + OPEN_VIDEO("open_video","打开视频监控"), ; @Getter private String funcCode; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index eebb4bf..550007c 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -48,8 +48,8 @@ public class InteractiveController { @RequestMapping(value = "/authentication",method = {RequestMethod.GET,RequestMethod.POST}) public R authentication(@RequestParam(required = false) @ApiParam("站点编号") String stationId, @RequestParam @ApiParam("用户ID") String userId, - @RequestParam(required = false) @ApiParam("菜单ID") String menuId) { - return R.status(interactiveService.authentication(stationId,userId,menuId)); + @RequestParam(required = false) @ApiParam("菜单ID") String funcCode) { + return R.status(interactiveService.authentication(stationId,userId,funcCode)); } @ApiOperation("获取问答sessionId") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index 1c718ac..938b518 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -21,6 +21,6 @@ public interface IInteractiveService { List getAnswerBySessionIds(String sessionIds); - Boolean authentication(String stationId, String userId, String menuId); + Boolean authentication(String stationId, String userId, String funcCode); } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 91c6820..8d81e3b 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -90,14 +90,14 @@ public class InteractiveServiceImpl implements IInteractiveService { HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) .body(JSON.toJSONString(params)).execute(); Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK && "1".equals(JSONObject.parseObject(response.body()).getString("success")), () -> { - throw new ServiceException("远程调用大模型【发起问答】接口失败!"); + throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); String data = JSONObject.parseObject(response.body()).getString("data"); return JSONArray.parseArray(data,AnswerVO.class); } @Override - public Boolean authentication(String stationId, String userId, String menuId) { + public Boolean authentication(String stationId, String userId, String funcCode) { //TODO 鉴权逻辑完善 return true; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java index 11e0cd4..3e2f616 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java @@ -16,6 +16,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.IntStream; /** * @Author: huangxing @@ -35,6 +36,8 @@ public class JumpRouteJoinStrategy { switch(routeEnum) { case OPEN_SCADA: return this.getScadaExtra(args,function); + case OPEN_VIDEO: + return this.getVideoExtra(args,function); default: break; } @@ -77,28 +80,41 @@ public class JumpRouteJoinStrategy { return extraVO; } + private ExtraVO getVideoExtra(Map args,FunctionEntity function) { + // 跳转页面逻辑 + ExtraVO extraVO = new ExtraVO(); + Map params = this.videoResolve(args); + String path = this.replacePath(function.getPath(), params); + extraVO.setRoute(path); + return extraVO; + } + /** - * 打开实时画面 + * 解析实时画面参数 * @param args 大模型解析参数 * @return 实时画面路径拼接所需参数 */ private Map scadaResolve(Map args) { - Map result = new HashMap<>(); - Assert.isTrue(args.containsKey("params"), () -> { - throw new ServiceException("大模型传参缺少params参数"); - }); + String params = args.get("params"); // 参数格式为:picResource^context^stationNum^projectId^taskId^name^id - List params = Func.toStrList("\\^", args.get("params")); - Assert.isTrue(params.size() == 7,() -> { - throw new ServiceException("大模型传参params长度错误,传参为:" + args.get("params")); + String[] keys = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; + return this.resolve(params,keys); + } + + private Map videoResolve(Map args) { + String params = args.get("params"); + // 参数格式为:id^name^stationCode^pointCode^host^appKey^appSecret + String[] keys = new String[]{"id","name","stationCode","pointCode","host","appKey","appSecret"}; + return this.resolve(params,keys); + } + + private Map resolve(String paramsStr,String... keys) { + Map result = new HashMap<>(); + List params = Func.toStrList("\\^", paramsStr); + Assert.isTrue(params.size() == keys.length, () -> { + throw new ServiceException("大模型传参params长度错误,传参为:" + paramsStr); }); - result.put("picResource",params.get(0)); - result.put("context",params.get(1)); - result.put("stationNum",params.get(2)); - result.put("projectId",params.get(3)); - result.put("taskId",params.get(4)); - result.put("name",params.get(5)); - result.put("id",params.get(6)); + IntStream.iterate(0,index -> index + 1).limit(params.size()).forEach(index -> result.put(keys[index],params.get(index))); return result; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index a9c3ba1..49607a3 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -72,7 +72,7 @@ public class InteractiveSchedule { AnswerList.parallelStream().forEach(answerVO -> { CompletableFuture.runAsync(() -> { WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); - TextMessage message = new TextMessage(JSON.toJSONString(answerVO)); + TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); try { session.sendMessage(message); } catch (IOException e) { diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index cf4a92f..551e5f7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.websocket.handler; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.hnac.hzims.bigmodel.interactive.service.IInteractiveService; import com.hnac.hzims.bigmodel.websocket.sessionManager.InteractiveSessionManager; import lombok.extern.slf4j.Slf4j; @@ -13,6 +14,7 @@ import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.handler.TextWebSocketHandler; +import java.io.IOException; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -46,8 +48,21 @@ public class InteractiveHandler extends TextWebSocketHandler { @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) { - IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - R askResult = interactiveService.ask(message.getPayload(), InteractiveSessionManager.getEntryBySession(session).getKey()); - log.info("message handle successful!返回结果为:"+ JSON.toJSONString(askResult)); + JSONObject messageJSON = JSONObject.parseObject(message.getPayload()); + if("0".equals(messageJSON.getString("type"))) { + // 接收心跳消息,返回一条心跳消息 + try { + session.sendMessage(InteractiveSessionManager.getTextMessage("0","收到心跳消息")); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + else { + // 发送问题 + String context = messageJSON.getString("context"); + IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); + R askResult = interactiveService.ask(context, InteractiveSessionManager.getEntryBySession(session).getKey()); + log.info("message handle successful!返回结果为:"+ JSON.toJSONString(askResult)); + } } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java index 5e3d1a6..4458970 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java @@ -1,7 +1,10 @@ package com.hnac.hzims.bigmodel.websocket.sessionManager; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; +import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import java.io.IOException; @@ -23,8 +26,6 @@ public class InteractiveSessionManager { /** ws会话池 **/ public static ConcurrentHashMap SESSION_POOL = new ConcurrentHashMap<>(); - private static final Lock lock = new ReentrantLock(); - /** * 获取sessionIds * @return sessionIds @@ -85,4 +86,11 @@ public class InteractiveSessionManager { } SESSION_POOL.remove(sessionId); } + + public static TextMessage getTextMessage(String type,String context) { + JSONObject message = new JSONObject(); + message.put("type",type); + message.put("context",context); + return new TextMessage(JSON.toJSONString(message)); + } } From 7ab75635d24b098fe923a3c2917cd4f8440cfa6f Mon Sep 17 00:00:00 2001 From: ty <1577900710@qq.com> Date: Tue, 7 May 2024 11:24:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=EF=BC=9A=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=9C=88=E6=8A=A5=E5=8F=91=E7=94=B5=E9=87=8F=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E8=BD=AC=E6=8D=A2=E4=B8=BA=E4=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MainSystemMonitoringServiceImpl.java | 36 +++++++++-------- .../impl/OperStationMonthReportServiceImpl.java | 45 ++++++++++++++++++++++ .../hnac/hzims/operational/util/ObjectUtils.java | 7 ++++ 3 files changed, 71 insertions(+), 17 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java index afe634e..ea01dee 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/service/impl/MainSystemMonitoringServiceImpl.java @@ -64,6 +64,8 @@ import java.util.*; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import static com.hnac.hzims.operational.util.ObjectUtils.objDivide; + @Service @Slf4j @RequiredArgsConstructor @@ -1369,37 +1371,37 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer Map value = deviceMap.getValue(); //当月发电量 BigDecimal powerMon = value.entrySet().stream().filter(s -> currentMon.equals(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add); - stationReportVO.setFinishPowerMon(powerMon.toString()); + stationReportVO.setFinishPowerMon(objDivide(String.valueOf(powerMon)).toString()); //获取计划月发电量 R planPowerMonR = planGenertionClient.planGenerationMonthCount(stationEntity.getCode(), month); double planPowerMon =0; if (planPowerMonR.isSuccess()&&ObjectUtil.isNotEmpty(planPowerMonR.getData())) { planPowerMon = planPowerMonR.getData().doubleValue(); } - stationReportVO.setPowerMonPlan(planPowerMon); + stationReportVO.setPowerMonPlan(objDivide(String.valueOf(planPowerMon)).doubleValue()); //当年发电量 BigDecimal powerYear = value.entrySet().stream().filter(s -> listByYear.contains(s.getKey())).map(s -> BigDecimal.valueOf(s.getValue()).setScale(1, RoundingMode.UP)).reduce(BigDecimal.ZERO, BigDecimal::add); - stationReportVO.setFinishPowerYear(powerYear.toString()); + stationReportVO.setFinishPowerYear(objDivide(String.valueOf(powerYear)).toString()); //获取计划年发电量 - Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationEntity.getId().toString()), yearMon[0]); - stationReportVO.setPowerYearPlan(planPowerYear); + Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationEntity.getCode()), yearMon[0]); + stationReportVO.setPowerYearPlan(objDivide(String.valueOf(planPowerYear)).doubleValue()); if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) && BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); - stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); + stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue())); }else { - stationReportVO.setPowerMonRate(new Double(0)+"%"); + stationReportVO.setPowerMonRate(new Double(0).toString()); } if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) && BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); - stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); + stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue())); }else { - stationReportVO.setPowerYearRate(new Double(0)+"%"); + stationReportVO.setPowerYearRate(new Double(0).toString()); } reportVOS.add(stationReportVO); } @@ -1474,33 +1476,33 @@ public class MainSystemMonitoringServiceImpl implements IMainSystemMonitoringSer } } Double finishPowerMon = BigDecimal.valueOf(powerCount.get()).doubleValue(); - stationReportVO.setFinishPowerMon(finishPowerMon.toString()); + stationReportVO.setFinishPowerMon(objDivide(String.valueOf(finishPowerMon)).toString()); Double finishPowerYear = BigDecimal.valueOf(powerCountYear.get()).doubleValue(); - stationReportVO.setFinishPowerYear(finishPowerYear.toString()); + stationReportVO.setFinishPowerYear(objDivide(String.valueOf(finishPowerYear)).toString()); //当年的计划发电量 Double planPowerYear = planGenertionClient.getPlanPowerYear(Collections.singletonList(stationId), year); - stationReportVO.setPowerYearPlan(planPowerYear); + stationReportVO.setPowerYearPlan(objDivide(String.valueOf(planPowerYear)).doubleValue()); //当月的计划发电量 R planPowerMonR = planGenertionClient.planGenerationMonthCount(stationId, month); Double planPowerMon = planPowerMonR.getData().doubleValue(); - stationReportVO.setPowerMonPlan(planPowerMon); + stationReportVO.setPowerMonPlan(objDivide(String.valueOf(planPowerMon)).doubleValue()); if (ObjectUtil.isNotEmpty(stationReportVO.getPowerMonPlan()) &&ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerMon()) && BigDecimal.valueOf(stationReportVO.getPowerMonPlan()).compareTo(BigDecimal.ZERO)!=0){ BigDecimal monRate = new BigDecimal(stationReportVO.getFinishPowerMon()).multiply(new BigDecimal(100)) .divide(BigDecimal.valueOf(stationReportVO.getPowerMonPlan()), 2, RoundingMode.UP); - stationReportVO.setPowerMonRate(monRate.doubleValue()+"%"); + stationReportVO.setPowerMonRate(String.valueOf(monRate.doubleValue())); }else { - stationReportVO.setPowerMonRate(new Double(0)+"%"); + stationReportVO.setPowerMonRate(new Double(0).toString()); } if (ObjectUtil.isNotEmpty(stationReportVO.getFinishPowerYear()) &&ObjectUtil.isNotEmpty(stationReportVO.getPowerYearPlan()) && BigDecimal.valueOf(stationReportVO.getPowerYearPlan()).compareTo(BigDecimal.ZERO)!=0){ BigDecimal yearRate = new BigDecimal(stationReportVO.getFinishPowerYear()).multiply(new BigDecimal(100)) .divide(BigDecimal.valueOf(stationReportVO.getPowerYearPlan()), 2, RoundingMode.UP); - stationReportVO.setPowerYearRate(yearRate.doubleValue()+"%"); + stationReportVO.setPowerYearRate(String.valueOf(yearRate.doubleValue())); }else { - stationReportVO.setPowerYearRate(new Double(0)+"%"); + stationReportVO.setPowerYearRate(new Double(0).toString()); } stationReportVOList.add(stationReportVO); return stationReportVOList; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java index 95b22cf..1f80b1b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/report/service/impl/OperStationMonthReportServiceImpl.java @@ -57,6 +57,7 @@ import org.springblade.system.vo.DeptVO; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -349,6 +350,7 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor reportVOS.addAll(stationReportVOList); }); } + getSumStationRunReport(reportVOS); stationReportAllVo.setStationReportVOList(reportVOS); }catch (Exception e){ log.error("", e); @@ -510,6 +512,49 @@ public class OperStationMonthReportServiceImpl implements IOperStationMonthRepor return stationReportAllVo; } + private static void getSumStationRunReport(List reportVOS) { + //合计 + StationRunReportVO stationRunReportVO=new StationRunReportVO(); + stationRunReportVO.setStationName("合计"); + if (CollectionUtil.isNotEmpty(reportVOS)){ + double sumPowerMonPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerMonPlan).sum(); + stationRunReportVO.setPowerMonPlan(sumPowerMonPlan); + double sumFinishPowerMon = reportVOS.stream().map(StationRunReportVO::getFinishPowerMon).mapToDouble(s -> Double.valueOf(s)).sum(); + stationRunReportVO.setFinishPowerMon(String.valueOf(sumFinishPowerMon)); + if (!ObjectUtils.isEmpty(sumPowerMonPlan)) { + BigDecimal powerMonRate = new BigDecimal(sumFinishPowerMon).divide(new BigDecimal(sumPowerMonPlan)).setScale(2, BigDecimal.ROUND_UP); + stationRunReportVO.setPowerMonRate(String.valueOf(powerMonRate)); + }else { + stationRunReportVO.setPowerMonRate("0.0"); + } + double sumPowerYearPlan = reportVOS.stream().mapToDouble(StationRunReportVO::getPowerYearPlan).sum(); + stationRunReportVO.setPowerYearPlan(sumPowerYearPlan); + double sumFinishPowerYear = reportVOS.stream().map(StationRunReportVO::getFinishPowerYear).mapToDouble(s -> Double.valueOf(s)).sum(); + stationRunReportVO.setFinishPowerYear(String.valueOf(sumFinishPowerYear)); + if (!ObjectUtils.isEmpty(sumPowerYearPlan)){ + BigDecimal powerYearRate = new BigDecimal(sumFinishPowerYear).divide(new BigDecimal(sumPowerYearPlan)).setScale(2, BigDecimal.ROUND_UP); + stationRunReportVO.setPowerYearRate(String.valueOf(powerYearRate)); + }else { + stationRunReportVO.setPowerYearRate("0.0"); + } + stationRunReportVO.setIndex(reportVOS.size()+1); + }else { + stationRunReportVO.setPowerMonPlan(0.0d); + stationRunReportVO.setFinishPowerMon("0.0"); + stationRunReportVO.setPowerYearPlan(0.0d); + stationRunReportVO.setFinishPowerYear("0.0"); + stationRunReportVO.setPowerMonRate("0.0"); + stationRunReportVO.setPowerYearRate("0.0"); + stationRunReportVO.setIndex(1); + } + reportVOS.add(stationRunReportVO); + reportVOS = reportVOS.stream().map(s -> { + s.setPowerMonRate(s.getPowerMonRate()+"%"); + s.setPowerYearRate(s.getPowerYearRate()+"%"); + return s; + }).collect(Collectors.toList()); + } + /** * 导出统计月报 * @param response diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java index 9feb555..341e2d5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/util/ObjectUtils.java @@ -10,6 +10,7 @@ import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import java.lang.reflect.Field; +import java.math.BigDecimal; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -81,4 +82,10 @@ public class ObjectUtils { } return result; } + + public static BigDecimal objDivide(String s){ + BigDecimal bigDecimal = new BigDecimal(s); + BigDecimal res = bigDecimal.divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_UP); + return res; + } } From 517a5996a73e49d8f5ecc08590f0eb0e3cd285b1 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 11:57:14 +0800 Subject: [PATCH 3/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java | 6 +----- .../bigmodel/websocket/service/InteractiveWsService.java | 11 ++++++++--- .../hzims/bigmodel/websocket/service/WebSocketService.java | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 49607a3..3ddf2f7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -73,11 +73,7 @@ public class InteractiveSchedule { CompletableFuture.runAsync(() -> { WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); - try { - session.sendMessage(message); - } catch (IOException e) { - XxlJobLogger.log("消息中心推送失败,推送内容为:" + JSON.toJSONString(answerVO)); - } + wsService.sendMessage(session,message); }, getAnswerPoolExecutor); }); return ReturnT.SUCCESS; diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java index c7cce27..258a376 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/InteractiveWsService.java @@ -19,13 +19,18 @@ import java.io.IOException; public class InteractiveWsService implements WebSocketService { @Override - public Boolean sendMessage(String signage, TextMessage message) { - WebSocketSession session = InteractiveSessionManager.get(signage); + public Boolean sendMessage(String sessionId, TextMessage message) { + WebSocketSession session = InteractiveSessionManager.get(sessionId); + return this.sendMessage(session,message); + } + + @Override + public Boolean sendMessage(WebSocketSession session, TextMessage message) { try { session.sendMessage(message); return true; } catch (IOException e) { - log.error("消息推送失败,推送sessionId为:" + signage + ";消息体为:" + JSON.toJSONString(message)); + log.error("消息推送失败;消息体为:" + JSON.toJSONString(message)); return false; } } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java index f4937ad..8729472 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/service/WebSocketService.java @@ -1,6 +1,7 @@ package com.hnac.hzims.bigmodel.websocket.service; import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; /** * @Author: huangxing @@ -10,4 +11,6 @@ public interface WebSocketService { Boolean sendMessage(String signage, TextMessage message); + Boolean sendMessage(WebSocketSession session, TextMessage message); + } From 0674c061b12bf3ac6bfead9740befbe3276ade83 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 15:04:00 +0800 Subject: [PATCH 4/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java index 3e2f616..31ad197 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/JumpRouteJoinStrategy.java @@ -95,14 +95,14 @@ public class JumpRouteJoinStrategy { * @return 实时画面路径拼接所需参数 */ private Map scadaResolve(Map args) { - String params = args.get("params"); + String params = args.get("canvas_id"); // 参数格式为:picResource^context^stationNum^projectId^taskId^name^id String[] keys = new String[]{"picResource","context","stationNum","projectId","taskId","name","id"}; return this.resolve(params,keys); } private Map videoResolve(Map args) { - String params = args.get("params"); + String params = args.get("canvas_id"); // 参数格式为:id^name^stationCode^pointCode^host^appKey^appSecret String[] keys = new String[]{"id","name","stationCode","pointCode","host","appKey","appSecret"}; return this.resolve(params,keys); From 46f840e419d1c789406bfb91029219a30a6044b9 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 15:47:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigmodel/websocket/sessionManager/InteractiveSessionManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java index 4458970..ea022cc 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/sessionManager/InteractiveSessionManager.java @@ -43,7 +43,7 @@ public class InteractiveSessionManager { public static Map.Entry getEntryBySession(WebSocketSession session) { Set> sessionEntrySet = InteractiveSessionManager.SESSION_POOL.entrySet(); Optional> sessionIdOptional = sessionEntrySet.stream().filter(sessionEntry -> session.equals(sessionEntry.getValue())).findFirst(); - if(sessionIdOptional.isPresent()) { + if(!sessionIdOptional.isPresent()) { log.error("当前Session Pool未查询到相关session,消息推送失败"); throw new ServiceException("当前Session Pool未查询到相关session,消息推送失败"); } From 83043a79ade14d791dd33c9ae7a44b372468eb72 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 16:29:40 +0800 Subject: [PATCH 6/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/InteractiveController.java | 4 ++-- .../interactive/service/IInteractiveService.java | 2 +- .../service/impl/InteractiveServiceImpl.java | 21 ++++++++++++--------- .../bigmodel/schedule/InteractiveSchedule.java | 3 +++ .../websocket/handler/InteractiveHandler.java | 5 +++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java index 550007c..5ca95c7 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/controller/InteractiveController.java @@ -39,8 +39,8 @@ public class InteractiveController { @ApiOperation("提问") @ApiOperationSupport(order = 2) @GetMapping("/ask") - public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId) { - return interactiveService.ask(question, sessionId); + public R ask(@RequestParam @ApiParam("用户提出问题") String question,@RequestParam @ApiParam("问答sessionId") String sessionId,@RequestParam @ApiParam("用户Id") String userId) { + return interactiveService.ask(question, sessionId, userId); } @ApiOperation("站点、菜单鉴权") diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java index 938b518..f497498 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/IInteractiveService.java @@ -17,7 +17,7 @@ public interface IInteractiveService { R resolve(ModelFunctionReq req); - R ask(String question,String sessionId); + R ask(String question,String sessionId,String userId); List getAnswerBySessionIds(String sessionIds); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 8d81e3b..92ce693 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -16,6 +16,7 @@ import lombok.AllArgsConstructor; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; @@ -46,11 +47,13 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IJumpPageService jumpPageService; private final IFunctionService functionService; private final BigModelInvokeUrl bigModelInvokeUrl; + private final BladeLogger logger; @Value("${fdp.host}") private String fdpHost; @Override public R resolve(ModelFunctionReq req) { + logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); //TODO 数据鉴权 FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); @@ -68,8 +71,7 @@ public class InteractiveServiceImpl implements IInteractiveService { } @Override - public R ask(String question,String sessionId) { - Long userId = AuthUtil.getUserId(); + public R ask(String question,String sessionId,String userId) { //TODO 保存问题 Map params = new HashMap<>(); params.put("id",sessionId); @@ -77,10 +79,11 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("query",question); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK && "1".equals(JSONObject.parseObject(response.body()).getString("success")), () -> { - throw new ServiceException("远程调用大模型【发起问答】接口失败!"); - }); - return R.data(JSONObject.parseObject(response.body()).getString("data")); + if(response.getStatus() != HttpServletResponse.SC_OK) { + log.error("远程调用大模型【发起问答】接口失败!"); + return R.fail("远程调用大模型【发起问答】接口失败!"); + } + return R.success("消息发送成功"); } @Override @@ -89,11 +92,11 @@ public class InteractiveServiceImpl implements IInteractiveService { params.put("ids",sessionIds); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) .body(JSON.toJSONString(params)).execute(); - Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK && "1".equals(JSONObject.parseObject(response.body()).getString("success")), () -> { + logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); + Assert.isTrue(response.getStatus() == HttpServletResponse.SC_OK, () -> { throw new ServiceException("远程调用大模型【获取问题答案】接口失败!"); }); - String data = JSONObject.parseObject(response.body()).getString("data"); - return JSONArray.parseArray(data,AnswerVO.class); + return JSONArray.parseArray(response.body(),AnswerVO.class); } @Override diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 3ddf2f7..25ea4a8 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -68,9 +68,12 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT execute(String params) { List sessionIds = InteractiveSessionManager.getSessionIds(); + XxlJobLogger.log("开始获取到sessionId:"+sessionIds); List AnswerList = interactiveService.getAnswerBySessionIds(sessionIds.stream().collect(Collectors.joining(","))); + XxlJobLogger.log("获取到答案:"+JSON.toJSONString(AnswerList)); AnswerList.parallelStream().forEach(answerVO -> { CompletableFuture.runAsync(() -> { + XxlJobLogger.log("开始获取"+answerVO.getSessionId()+"答案!"); WebSocketSession session = InteractiveSessionManager.get(answerVO.getSessionId()); TextMessage message = InteractiveSessionManager.getTextMessage("1",JSON.toJSONString(answerVO)); wsService.sendMessage(session,message); diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java index 551e5f7..a2dc3c6 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/websocket/handler/InteractiveHandler.java @@ -60,9 +60,10 @@ public class InteractiveHandler extends TextWebSocketHandler { else { // 发送问题 String context = messageJSON.getString("context"); + String userId = messageJSON.getString("userId"); IInteractiveService interactiveService = SpringUtil.getBean(IInteractiveService.class); - R askResult = interactiveService.ask(context, InteractiveSessionManager.getEntryBySession(session).getKey()); - log.info("message handle successful!返回结果为:"+ JSON.toJSONString(askResult)); + R askResult = interactiveService.ask(context, InteractiveSessionManager.getEntryBySession(session).getKey(), userId); + log.info("返回结果为:"+ JSON.toJSONString(askResult)); } } } From b5578a378b0ad33436bbd98100be25a648cdf867 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Tue, 7 May 2024 19:48:33 +0800 Subject: [PATCH 7/7] =?UTF-8?q?add:=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 33 +++++++++++++++++++--- .../hzims/bigmodel/interactive/vo/AnswerVO.java | 3 ++ .../bigmodel/schedule/InteractiveSchedule.java | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index 92ce693..d9e2efb 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -19,8 +19,11 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; +import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.feign.IDeptClient; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -48,13 +51,14 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IFunctionService functionService; private final BigModelInvokeUrl bigModelInvokeUrl; private final BladeLogger logger; + private final IDeptClient deptClient; + private final IUserClient userClient; @Value("${fdp.host}") private String fdpHost; @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); - //TODO 数据鉴权 FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); switch (typeEnum) { @@ -88,8 +92,8 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public List getAnswerBySessionIds(String sessionIds) { - Map params = new HashMap<>(); - params.put("ids",sessionIds); + Map params = new HashMap<>(); + params.put("ids",Func.toStrList(",",sessionIds).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) .body(JSON.toJSONString(params)).execute(); logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); @@ -101,7 +105,28 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public Boolean authentication(String stationId, String userId, String funcCode) { - //TODO 鉴权逻辑完善 + // 站点鉴权 + if(StringUtil.isNotBlank(stationId)) { + R> stationsR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(stationsR.isSuccess() && CollectionUtil.isNotEmpty(stationsR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + List stations = stationsR.getData(); + Assert.isTrue(stations.contains(stationId),() -> { + throw new ServiceException("人员站点鉴权失败!"); + }); + } + // 菜单鉴权 + if(StringUtil.isNotBlank(funcCode)) { + FunctionEntity function = functionService.getFunctionByCode(funcCode); + Assert.isTrue(Func.isNotEmpty(function) && StringUtil.isNotBlank(function.getRoute()),() -> { + throw new ServiceException("传入函数未获取到菜单,鉴权失败!"); + }); + R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); + Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { + throw new ServiceException("人员菜单鉴权失败!"); + }); + } return true; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java index ae34551..3b1ac38 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java @@ -44,4 +44,7 @@ public class AnswerVO implements Serializable { @ApiModelProperty("query对应的答案") private String answer; + @ApiModelProperty("其它调用的参数") + private String[] extra; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 25ea4a8..56af36e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -68,7 +68,7 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT execute(String params) { List sessionIds = InteractiveSessionManager.getSessionIds(); - XxlJobLogger.log("开始获取到sessionId:"+sessionIds); + XxlJobLogger.log("开始获取到sessionId:"+sessionIds.stream().collect(Collectors.joining(","))); List AnswerList = interactiveService.getAnswerBySessionIds(sessionIds.stream().collect(Collectors.joining(","))); XxlJobLogger.log("获取到答案:"+JSON.toJSONString(AnswerList)); AnswerList.parallelStream().forEach(answerVO -> {